DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
collisiondata.cpp
1#include "collisiondata.hpp"
2
3#include <cstdio>
4#include <cstring>
5
6#include "camerafollow.hpp"
7#include "debugfont.hpp"
8#include "dngmessageman.hpp"
9#include "dun/gameloop.hpp"
10#include "dungeoneventman.hpp"
11#include "dungeonmap.hpp"
12#include "gamepad.hpp"
13#include "hitmark.hpp"
14#include "itemdata.hpp"
15#ifdef PAL
16#include "mainselect.hpp"
17#endif
18#include "mglib.hpp"
19#include "rect.hpp"
20#include "snd.hpp"
21#ifdef PAL
22#include "userstatus.hpp"
23#endif
24
28int DebugInfoCode[15] = {DEBUG_INFO_MINIMAP_VIEW, DEBUG_INFO_COLLISION, DEBUG_INFO_BGM_PLAY, DEBUG_INFO_PARAMETER, DEBUG_INFO_VIEW_INFO, DEBUG_INFO_ULTRA_MAN, DEBUG_INFO_RELOAD_ENEMY, DEBUG_INFO_ITEM_PUT_ZONE, DEBUG_INFO_LIGHT_MODE, DEBUG_INFO_FLOOR_ATRA_GET, DEBUG_INFO_EVENT_TEST, DEBUG_INFO_SET_STATUS, DEBUG_INFO_SE_PLAY, DEBUG_INFO_SET_CHR_KEY, -1};
29
30// clang-format off
34char *DebugInfoMsg[15] = {
35 DebugInfoMsgMiniMapView, DebugInfoMsgCollision, DebugInfoMsgBgmPlay, DebugInfoMsgParameter,
36 DebugInfoMsgViewInfo, DebugInfoMsgUltraMan, DebugInfoMsgReloadEnemy, DebugInfoMsgItemPutZone,
37 DebugInfoMsgLightMode, DebugInfoMsgFloorAtraGet, DebugInfoMsgEventTest, DebugInfoMsgSetStatus,
38 DebugInfoMsgSePlay, DebugInfoMsgSetChrKey, NULL,
39};
40// clang-format on
41
45int DebugInfoNowCursor;
46
48int gateKeyStack[32];
49
53char nameblock[64];
54
62void DebugInfomationDraw() {
63 if (DebugStatus[0] != 1) {
64 if (DebugStatus[4] != 0) {
65 sceVu0FVECTOR pos;
66 sceVu0FVECTOR rot;
67 sceVu0FVECTOR cam_pos;
68 sceVu0FVECTOR cam_ref;
69 float angle;
70 float distance;
71 float height;
72 int tile_x;
73 float local_x;
74 int tile_z;
75 float local_z;
76 float cam_local_x;
77 float cam_local_y;
78 float cam_local_z;
79 float ref_local_x;
80 float ref_local_y;
81 float local_y;
82 float ref_local_z;
83 CDungeonEventData *event_data;
84 int event_count;
85
86 DbgMsg.length = sprintf(DbgMsg.text, " ---Infomation---\n");
87 sceVu0CopyVector(pos, CharaMain.pos);
88 CharaMain.GetRotation(rot);
89 NowCamera__3->GetPos(cam_pos);
90 NowCamera__3->GetRef(cam_ref);
91 angle = NowCamera__3->GetAngle();
92 distance = NowCamera__3->GetDistance();
93 height = NowCamera__3->GetHeight();
94 tile_x = (int) ((pos[0] - 80.0f) / 160.0f) * 160;
95 local_x = pos[0] - tile_x - 160.0f;
96 local_y = pos[1];
97 tile_z = (int) ((pos[2] - 80.0f) / 160.0f) * 160;
98 local_z = pos[2] - tile_z - 160.0f;
99 cam_local_x = cam_pos[0] - tile_x - 160.0f;
100 cam_local_y = cam_pos[1];
101 cam_local_z = cam_pos[2] - tile_z - 160.0f;
102 ref_local_x = cam_ref[0] - tile_x - 160.0f;
103 ref_local_y = cam_ref[1];
104 ref_local_z = cam_ref[2] - tile_z - 160.0f;
105 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "gpos %.2f/ %.2f/ %.2f\n", pos[0], pos[1], pos[2]);
106 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "lpos %.2f/ %.2f/ %.2f\n", local_x, local_y, local_z);
107 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "rot %.2f/ %.2f/ %.2f\n", rot[0], rot[1], rot[2]);
108 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "CAM\n");
109 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "cpos %.2f/ %.2f/ %.2f\n", cam_pos[0], cam_pos[1], cam_pos[2]);
110 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "cref %.2f/ %.2f/ %.2f\n", cam_ref[0], cam_ref[1], cam_ref[2]);
111 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "lcpos %.2f/ %.2f/ %.2f\n", cam_local_x, cam_local_y, cam_local_z);
112 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "lcref %.2f/ %.2f/ %.2f\n", ref_local_x, ref_local_y, ref_local_z);
113 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "Angle = %.3f\n", angle);
114 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "Dist = %.3f\n", distance);
115 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "Height = %.3f\n", height);
116 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "RANDOM MAP CODE = %d\n", NowDngMap->map_seed);
117 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "WeaponList Ver 2000/%d\n", VERSION_VOL);
118 event_data = NowEventMan->SearchDataSlotPos(pos);
119 event_count = 0;
120
121 if (event_data != NULL) {
122 event_count = 1;
123 }
124
125 event_count = NowEventMan->GetDataNum();
126 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], "EventID = %d\n", event_count);
127#ifdef PAL
128 MGFillBox(CRect_i_(0x200, 0x280, 0x1000, 0x780), 8, 8, 8, 0x60);
129#else
130 MGFillBox(CRect_i_(0x200, 0x280, 0x1000, 0x700), 8, 8, 8, 0x60);
131#endif
132 DbgMsg.Draw();
133 }
134
135 return;
136 }
137
138 DbgMsg.length = sprintf(DbgMsg.text, "");
139 char *on_off_names[2] = {"OFF", "ON"};
140 char *main_sub_names[2] = {"MAIN", "SUB"};
141 char *condition_names[6] = {"RESET", "STONE", "BIN2", "POISON", "CURSE", "NEBA2"};
142 char *power_names[3] = {"HUMAN ", "SUPERMAN", "ULTRAMAN"};
143 char bgm_text[32];
144
145 for (int i = 0; DebugInfoMsg[i] != NULL; i++) {
146 if (DebugInfoNowCursor == i) {
147 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], ">>");
148 } else {
149 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], " ");
150 }
151
152 switch (DebugInfoCode[i]) {
153 case DEBUG_INFO_NONE:
154 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i]);
155 break;
156 case DEBUG_INFO_UNK_28:
157 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], DebugStatus[8]);
158 break;
159 case DEBUG_INFO_BGM_PLAY:
160 if (DebugStatus[9] == -1) {
161 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], "OFF");
162 } else {
163 sprintf(bgm_text, "%d", DebugStatus[9] + 1);
164 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], bgm_text);
165 }
166
167 break;
168 case DEBUG_INFO_PARAMETER:
169 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], on_off_names[DebugStatus[10]]);
170 break;
171 case DEBUG_INFO_COLLISION:
172 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], on_off_names[DebugStatus[5]]);
173 break;
174 case DEBUG_INFO_VIEW_INFO:
175 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], on_off_names[DebugStatus[4]]);
176 break;
177 case DEBUG_INFO_ITEM_PUT_ZONE:
178 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], on_off_names[DebugStatus[6]]);
179 break;
180 case DEBUG_INFO_MINIMAP_VIEW:
181 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], on_off_names[DebugStatus[3]]);
182 break;
183 case DEBUG_INFO_ULTRA_MAN:
184 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], power_names[DebugStatus[20]]);
185 break;
186 case DEBUG_INFO_RELOAD_ENEMY:
187 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], DebugStatus[14], DebugStatus[15]);
188 break;
189 case DEBUG_INFO_FLOOR_ATRA_GET:
190 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i]);
191 break;
192 case DEBUG_INFO_LIGHT_MODE:
193 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], main_sub_names[DebugStatus[16]]);
194 break;
195 case DEBUG_INFO_EVENT_TEST:
196 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], DebugStatus[11]);
197 break;
198 case DEBUG_INFO_SET_STATUS:
199 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], condition_names[DebugStatus[17]]);
200 break;
201 case DEBUG_INFO_SE_PLAY:
202 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], DebugStatus[18]);
203 break;
204 case DEBUG_INFO_SET_CHR_KEY:
205 DbgMsg.length += sprintf(&DbgMsg.text[DbgMsg.length], DebugInfoMsg[i], DebugStatus[19]);
206 break;
207 }
208 }
209
210#ifdef PAL
211 MGFillBox(CRect_i_(0x200, 0x280, 0x1000, 0x780), 8, 8, 8, 0x60);
212#else
213 MGFillBox(CRect_i_(0x200, 0x280, 0x1000, 0x700), 8, 8, 8, 0x60);
214#endif
215 DbgMsg.Draw();
216}
217
225void DebugInfomationInit() {
226 DebugStatus[0] = 0;
227 DebugStatus[1] = 0;
228 DebugStatus[2] = 0;
229 DebugStatus[3] = 0;
230 DebugStatus[5] = 1;
231 DebugStatus[6] = 0;
232 DebugStatus[4] = 0;
233 DebugStatus[7] = 0;
234 DebugStatus[8] = 150;
235 DebugStatus[9] = -1;
236 DebugStatus[10] = 0;
237 DebugStatus[11] = 100;
238 DebugStatus[12] = 0;
239 DebugStatus[13] = 16;
240 DebugStatus[14] = 0;
241 DebugStatus[15] = 16;
242 DebugStatus[16] = 0;
243 DebugStatus[17] = 0;
244 DebugStatus[18] = 400;
245 DebugStatus[19] = 1;
246 DebugStatus[20] = 0;
247}
248
252static inline void ClearEventData(CDungeonEventMan *event_man) {
253 int i;
254
255 for (i = 0; i < 96; i++) {
256 CDungeonEventData *data = &event_man->event[i];
257
258 data->event = NULL;
259 data->switch_on = false;
260 data->enabled = false;
261 data->hold = 0;
262 data->chara_done = -1;
263 }
264}
265
269static inline void ClearMapEvent(CDungeonMap *map) {
270 int i;
271
272 for (i = 0; i < 48; i++) {
273 map->events[i].kind = DNG_EVENT_NONE;
274 map->events[i].reset_flag = 0;
275 }
276
277 for (i = 0; i < 24; i++) {
278 map->boxes[i].used = 0;
279 map->boxes[i].lid_angle = 0;
280 map->boxes[i].trap_no = 0;
281 }
282
283 map->box_num = 0;
284
285 for (i = 0; i < 8; i++) {
286 map->atra[i].used = 0;
287 }
288
289 map->atra_num = 0;
290
291 for (i = 0; i < 4; i++) {
292 map->room_link[i].used = 0;
293 }
294}
295
303int DebugInfomationIF() {
304 int line_count;
305
306 if (GamePad.Down(PAD_R3)) {
307 DebugStatus[0] = 0;
308 GamePad.AutoRepeatOff();
309 GamePad.MenuModeOff();
310 return DEBUG_INFO_CLOSE;
311 }
312
313 if (GamePad.Down(PAD_TRIANGLE)) {
314 switch (DebugInfoCode[DebugInfoNowCursor]) {
315 case DEBUG_INFO_EVENT_TEST:
316 DebugStatus[0] = 0;
317 DebugStatus[12] = 1;
318 GamePad.AutoRepeatOff();
319 GamePad.MenuModeOff();
320 return DEBUG_INFO_UNK_28;
321 }
322 }
323
324 if (GamePad.Down(PAD_CIRCLE)) {
325 switch (DebugInfoCode[DebugInfoNowCursor]) {
326 case DEBUG_INFO_UNK_28:
327 DebugStatus[0] = 0;
328 GamePad.AutoRepeatOff();
329 GamePad.MenuModeOff();
330 return DEBUG_INFO_UNK_28;
331 case DEBUG_INFO_UNK_3C:
332 DebugStatus[0] = 0;
333 GamePad.AutoRepeatOff();
334 GamePad.MenuModeOff();
335 return DEBUG_INFO_UNK_3C;
336 case DEBUG_INFO_RELOAD_ENEMY:
337 DebugStatus[0] = 0;
338 GamePad.AutoRepeatOff();
339 GamePad.MenuModeOff();
340 return DEBUG_INFO_RELOAD_ENEMY;
341 case DEBUG_INFO_FLOOR_ATRA_GET:
342 DebugStatus[0] = 0;
343 GamePad.AutoRepeatOff();
344 GamePad.MenuModeOff();
345 return DEBUG_INFO_FLOOR_ATRA_GET;
346 case DEBUG_INFO_EVENT_TEST:
347 DebugStatus[0] = 0;
348 DebugStatus[12] = 0;
349 GamePad.AutoRepeatOff();
350 GamePad.MenuModeOff();
351 return DEBUG_INFO_EVENT_TEST;
352 case DEBUG_INFO_SET_STATUS:
353 DebugStatus[0] = 0;
354 GamePad.AutoRepeatOff();
355 GamePad.MenuModeOff();
356 return DEBUG_INFO_SET_STATUS;
357 case DEBUG_INFO_SE_PLAY:
358 SndSePlay(DebugStatus[18], -1, 0);
359 break;
360 case DEBUG_INFO_SET_CHR_KEY:
361 DebugStatus[0] = 0;
362 GamePad.AutoRepeatOff();
363 GamePad.MenuModeOff();
364 ClearEventData(NowEventMan);
365 printf("trap num = %d\n", NowDngMap->SetCharaDoor(DebugStatus[19]));
366 ClearMapEvent(NowDngMap);
367 {
368 int mode = NowDngMap->map_type;
369
370 NowEventMan->SetupEvent(NowDngMap, mode);
371 }
372 return DEBUG_INFO_SET_CHR_KEY;
373 }
374 }
375
376 for (line_count = 0; DebugInfoCode[line_count] != -1; line_count++) {
377 }
378
379 switch (DebugStatus[2]) {
380 case 0:
381 if (GamePad.Down(PAD_DOWN)) {
382 if (DebugInfoNowCursor == line_count - 1) {
383 DebugInfoNowCursor = 0;
384 } else {
385 DebugInfoNowCursor++;
386 }
387 }
388
389 if (GamePad.Down(PAD_UP)) {
390 if (DebugInfoNowCursor == 0) {
391 DebugInfoNowCursor = line_count - 1;
392 } else {
393 DebugInfoNowCursor--;
394 }
395 }
396
397 if (GamePad.Down(PAD_RIGHT)) {
398 switch (DebugInfoCode[DebugInfoNowCursor]) {
399 case DEBUG_INFO_MINIMAP_VIEW:
400 if (DebugStatus[3] == 0) {
401 DebugStatus[3] = 1;
402 } else {
403 DebugStatus[3] = 0;
404 }
405
406 break;
407 case DEBUG_INFO_COLLISION:
408 if (DebugStatus[5] == 0) {
409 DebugStatus[5] = 1;
410 } else {
411 DebugStatus[5] = 0;
412 }
413
414 break;
415 case DEBUG_INFO_ITEM_PUT_ZONE:
416 if (DebugStatus[6] == 0) {
417 DebugStatus[6] = 1;
418 } else {
419 DebugStatus[6] = 0;
420 }
421
422 break;
423 case DEBUG_INFO_VIEW_INFO:
424 if (DebugStatus[4] == 0) {
425 DebugStatus[4] = 1;
426 } else {
427 DebugStatus[4] = 0;
428 }
429
430 break;
431 case DEBUG_INFO_PARAMETER:
432 if (DebugStatus[10] == 0) {
433 DebugStatus[10] = 1;
434 } else {
435 DebugStatus[10] = 0;
436 }
437
438 break;
439 case DEBUG_INFO_ULTRA_MAN:
440 if (DebugStatus[20] == 2) {
441 DebugStatus[20] = 0;
442 } else {
443 DebugStatus[20]++;
444 }
445
446 break;
447 case DEBUG_INFO_RELOAD_ENEMY:
448 if (DebugStatus[14] < 4) {
449 DebugStatus[14]++;
450 } else {
451 DebugStatus[14] = 0;
452 }
453
454 break;
455 case DEBUG_INFO_BGM_PLAY:
456 DebugStatus[9]++;
457
458 if (DebugStatus[9] != -1) {
459 SndBgmLoad(DebugStatus[9] * 10 + 100);
460 SndBgmPlay(0);
461 } else {
462 SndBgmStop();
463 }
464
465 break;
466 case DEBUG_INFO_EVENT_TEST:
467 DebugStatus[11]++;
468 break;
469 case DEBUG_INFO_LIGHT_MODE:
470 if (DebugStatus[16] == 0) {
471 DebugStatus[16] = 1;
472 } else {
473 DebugStatus[16] = 0;
474 }
475
476 break;
477 case DEBUG_INFO_SET_STATUS:
478 if (DebugStatus[17] == 5) {
479 DebugStatus[17] = 0;
480 } else {
481 DebugStatus[17]++;
482 }
483
484 break;
485 case DEBUG_INFO_SE_PLAY:
486 DebugStatus[18]++;
487 break;
488 case DEBUG_INFO_SET_CHR_KEY:
489 if (DebugStatus[19] >= 5) {
490 DebugStatus[19] = 0;
491 } else {
492 DebugStatus[19]++;
493 }
494
495 break;
496 }
497 }
498
499 if (GamePad.Down(PAD_LEFT)) {
500 switch (DebugInfoCode[DebugInfoNowCursor]) {
501 case DEBUG_INFO_MINIMAP_VIEW:
502 if (DebugStatus[3] == 0) {
503 DebugStatus[3] = 1;
504 } else {
505 DebugStatus[3] = 0;
506 }
507
508 break;
509 case DEBUG_INFO_COLLISION:
510 if (DebugStatus[5] == 0) {
511 DebugStatus[5] = 1;
512 } else {
513 DebugStatus[5] = 0;
514 }
515
516 break;
517 case DEBUG_INFO_ITEM_PUT_ZONE:
518 if (DebugStatus[6] == 0) {
519 DebugStatus[6] = 1;
520 } else {
521 DebugStatus[6] = 0;
522 }
523
524 break;
525 case DEBUG_INFO_VIEW_INFO:
526 if (DebugStatus[4] == 0) {
527 DebugStatus[4] = 1;
528 } else {
529 DebugStatus[4] = 0;
530 }
531
532 break;
533 case DEBUG_INFO_PARAMETER:
534 if (DebugStatus[10] == 0) {
535 DebugStatus[10] = 1;
536 } else {
537 DebugStatus[10] = 0;
538 }
539
540 break;
541 case DEBUG_INFO_ULTRA_MAN:
542 if (DebugStatus[20] == 0) {
543 DebugStatus[20] = 2;
544 } else {
545 DebugStatus[20]--;
546 }
547
548 break;
549 case DEBUG_INFO_RELOAD_ENEMY:
550 if (DebugStatus[14] > 0) {
551 DebugStatus[14]--;
552 } else {
553 DebugStatus[14] = 4;
554 }
555
556 break;
557 case DEBUG_INFO_BGM_PLAY:
558 if (DebugStatus[9] > -1) {
559 DebugStatus[9]--;
560 }
561
562 if (DebugStatus[9] != -1) {
563 SndBgmLoad(DebugStatus[9] * 10 + 100);
564 SndBgmPlay(0);
565 } else {
566 SndBgmStop();
567 }
568
569 break;
570 case DEBUG_INFO_EVENT_TEST:
571 if (DebugStatus[11] > 0) {
572 DebugStatus[11]--;
573 }
574
575 break;
576 case DEBUG_INFO_LIGHT_MODE:
577 if (DebugStatus[16] == 0) {
578 DebugStatus[16] = 1;
579 } else {
580 DebugStatus[16] = 0;
581 }
582
583 break;
584 case DEBUG_INFO_SET_STATUS:
585 if (DebugStatus[17] == 0) {
586 DebugStatus[17] = 5;
587 } else {
588 DebugStatus[17]--;
589 }
590
591 break;
592 case DEBUG_INFO_SE_PLAY:
593 DebugStatus[18]--;
594 break;
595 case DEBUG_INFO_SET_CHR_KEY:
596 if (DebugStatus[19] <= 0) {
597 DebugStatus[19] = 5;
598 } else {
599 DebugStatus[19]--;
600 }
601
602 break;
603 }
604 }
605
606 if (GamePad.Down(PAD_L1)) {
607 switch (DebugInfoCode[DebugInfoNowCursor]) {
608 case DEBUG_INFO_EVENT_TEST:
609 if (DebugStatus[11] > 0) {
610 DebugStatus[11] -= 10;
611 }
612
613 if (DebugStatus[11] < 0) {
614 DebugStatus[11] = 0;
615 }
616
617 break;
618 case DEBUG_INFO_RELOAD_ENEMY:
619 if (DebugStatus[15] > 0) {
620 DebugStatus[15]--;
621 } else {
622 DebugStatus[15] = 16;
623 }
624
625 break;
626 case DEBUG_INFO_SE_PLAY:
627 if (DebugStatus[18] > 0) {
628 DebugStatus[18] -= 10;
629 }
630
631 if (DebugStatus[18] < 0) {
632 DebugStatus[18] = 0;
633 }
634
635 break;
636 }
637 }
638
639 if (GamePad.Down(PAD_R1)) {
640 switch (DebugInfoCode[DebugInfoNowCursor]) {
641 case DEBUG_INFO_EVENT_TEST:
642 DebugStatus[11] += 10;
643 break;
644 case DEBUG_INFO_RELOAD_ENEMY:
645 if (DebugStatus[15] < 16) {
646 DebugStatus[15]++;
647 } else {
648 DebugStatus[15] = 0;
649 }
650
651 break;
652 case DEBUG_INFO_SE_PLAY:
653 DebugStatus[18] += 10;
654 break;
655 }
656 }
657
658 break;
659 }
660
661 return DEBUG_INFO_NONE;
662}
663
664#ifdef PAL
668int center_us[7] = {0xCE, 0x125, 0x101, 0x100, 0x87, 0x57, 0x101};
669
673int center_fr[7] = {0xCD, 0x113, 0xF8, 0xF8, 0xB2, 0x59, 0xFF};
674
678int center_gr[7] = {0xFE, 0x103, 0x13D, 0xFD, 0x78, 0x38, 0xFF};
679
683int center_it[7] = {0xCC, 0x129, 0xF3, 0xFF, 0xFA, 0x75, 0xF9};
684
688int center_sp[7] = {0xCE, 0x12C, 0xF2, 0xFA, 0x7C, 0xBA, 0xFA};
689
693int *center_ptr[7] = {center_sp, center_us, center_us, center_fr, center_gr, center_it, center_sp};
694
695void StartMessageDraw(CTexture *texture, int dungeon, int floor, int ura, int alpha) {
696 int *centers = center_ptr[LanguageCode];
697 int x = centers[dungeon] + 0x82;
698 int digit_x;
699
700 set2DSprite(Vif1Packet, texture, CRect_i_(0x82, 0xAA, 0x17C, 0x32), CRect_i_(0, 0, 0x17C, 0x32), alpha);
701
702 floor++;
703
704 if (dungeon == DUNGEON_GALLERY_OF_TIME) {
705 floor = BtGetFloorLevel(floor - 1);
706 }
707
708 if (floor < 10) {
709 x -= 0x13;
710 digit_x = floor % 10 * 0x26;
711 set2DSprite(Vif1Packet, texture, CRect_i_(x, 0xAA, 0x26, 0x32), CRect_i_(digit_x, 0x32, 0x26, 0x32), alpha);
712 }
713
714 if (floor >= 10 && floor < 100) {
715 x -= 0x26;
716 digit_x = floor / 10 * 0x26;
717 set2DSprite(Vif1Packet, texture, CRect_i_(x, 0xAA, 0x26, 0x32), CRect_i_(digit_x, 0x32, 0x26, 0x32), alpha);
718 digit_x = floor % 10 * 0x26;
719 set2DSprite(Vif1Packet, texture, CRect_i_(x + 0x26, 0xAA, 0x26, 0x32), CRect_i_(digit_x, 0x32, 0x26, 0x32), alpha);
720 }
721
722 if (floor >= 100) {
723 int digit = floor / 100;
724
725 digit_x = digit * 0x26;
726 floor -= digit * 100;
727 set2DSprite(Vif1Packet, texture, CRect_i_(x - 0x39, 0xAA, 0x26, 0x32), CRect_i_(digit_x, 0x32, 0x26, 0x32), alpha);
728 digit_x = floor / 10 * 0x26;
729 set2DSprite(Vif1Packet, texture, CRect_i_(x - 0x13, 0xAA, 0x26, 0x32), CRect_i_(digit_x, 0x32, 0x26, 0x32), alpha);
730 digit_x = floor % 10 * 0x26;
731 set2DSprite(Vif1Packet, texture, CRect_i_(x + 0x13, 0xAA, 0x26, 0x32), CRect_i_(digit_x, 0x32, 0x26, 0x32), alpha);
732 }
733
734 if (ura != 0) {
735 set2DSprite(Vif1Packet, texture, CRect_i_(0x10E, 0xE6, 0x64, 0x32), CRect_i_(0x114, 0x7C, 0x64, 0x32), alpha);
736 return;
737 }
738
739 if (UserStatus->res_limit_zone_current >= 0) {
740 set2DSprite(Vif1Packet, texture, CRect_i_(0xC8, 0xE6, 0xF0, 0x32), CRect_i_(0, 0x7C, 0xF0, 0x32), alpha);
741 }
742}
743#endif
744
752void ClearGateKeyStack() {
753 for (int i = 0; i < 32; i++) {
754 gateKeyStack[i] = -1;
755 }
756}
757
758int SetGateKeyStack(int item) {
759 if (item == -1) {
760 return 0;
761 }
762
763 // One of a key item is enough, so a second is refused rather than stacked.
764 for (int i = 0; i < 32; i++) {
765 if (item == gateKeyStack[i]) {
766 return 0;
767 }
768 }
769
770 for (int i = 0; i < 32; i++) {
771 if (gateKeyStack[i] == -1) {
772 gateKeyStack[i] = item;
773 return 1;
774 }
775 }
776
777 return 0;
778}
779
787char *NameExchg(char *name, int language) {
788#ifdef PAL
789 strcpy(nameblock, LanguageStr[LanguageCode]);
790#else
791 strcpy(nameblock, LanguageStr[language][1]);
792#endif
793 strcat(nameblock, name);
794 return nameblock;
795}
796
797int CCollisionData::Set(float *position, int damage, int life, float radius, float scale_rate, int target_mask, int kind, int flags, int attribute) {
798 for (int i = 0; i < 96; i++) {
799 if (active[i] == 0) {
800 active[i] = 1;
801 sceVu0CopyVector(hit[i].pos, position);
802 hit[i].base_point[0] = hit[i].base_point[1] = hit[i].base_point[2] = 0.0f;
803 hit[i].base_point[3] = 1.0f;
804 hit[i].velocity[0] = hit[i].velocity[1] = hit[i].velocity[2] = 0.0f;
805 hit[i].velocity[0] = 1.0f;
806 hit[i].damage = damage;
807 hit[i].scale_rate = scale_rate;
808 hit[i].life = life;
809 hit[i].radius = radius;
810 hit[i].target_mask = target_mask;
811 hit[i].kind = kind;
812 hit[i].flags = flags;
813 hit[i].attribute = attribute;
814 hit[i].owner = -1;
815 hit[i].monster_no = -1;
816 hit[i].attack_no = -1;
817 hit[i].vs_monster = NULL;
818 hit[i].weapon_flags = 1;
819 hit[i].target_kind = -1;
820 hit[i].knockback_origin[0] = hit[i].knockback_origin[1] = hit[i].knockback_origin[2] = 0.0f;
821 hit[i].knockback_origin[3] = 1.0f;
822 hit[i].knockback_speed = 0.0f;
823 hit[i].knockback_decay = 0.0f;
824 hit[i].knockback_mode = 0;
825 hit[i].phase = hit[i].ready_phase = 0;
826 now_hit = i;
827 return i;
828 }
829 }
830 // With every record in use nothing is set and no index is returned.
831 PORT_RETURN(-1);
832}
833
841int CCollisionData::CheckHitUser(float *position, int mask, float height) {
842 sceVu0FVECTOR user_position;
843 sceVu0FVECTOR hit_position;
844 sceVu0CopyVector(user_position, position);
845 user_position[1] = 0.0f;
846 float user_top;
847 float user_bottom = position[1];
848 user_top = user_bottom + height;
849
850 for (int i = 0; i < 96; i++) {
851 if (active[i] == 0 || (mask & hit[i].target_mask) == 0 || hit[i].phase != hit[i].ready_phase) {
852 continue;
853 }
854
855 sceVu0CopyVector(hit_position, hit[i].pos);
856 hit_position[1] = 0.0f;
857
858 if (DistVector(user_position, hit_position) > hit[i].radius) {
859 continue;
860 }
861
862 int miss = 1;
863 float hit_top = hit[i].pos[1] + hit[i].radius;
864 float hit_bottom = hit[i].pos[1] - hit[i].radius;
865
866 if (!(hit_top < user_top) && hit_bottom < user_top) {
867 miss = 0;
868 }
869
870 if (!(hit_top < user_bottom) && hit_bottom < user_bottom) {
871 miss = 0;
872 }
873
874 if (hit_top <= user_top && !(hit_bottom <= user_bottom)) {
875 miss = 0;
876 }
877
878 if (!(hit_top < user_top) && hit_bottom < user_bottom) {
879 miss = 0;
880 }
881
882 if (miss == 0) {
883 return i;
884 }
885 }
886
887 return -1;
888}
889
897void CCollisionData::SetKickBack(float *origin, float speed, float decay, int mode) {
898 hit[now_hit].knockback_origin[0] = origin[0];
899 hit[now_hit].knockback_origin[1] = origin[1];
900 hit[now_hit].knockback_origin[2] = origin[2];
901 hit[now_hit].knockback_speed = speed;
902 hit[now_hit].knockback_decay = decay;
903 hit[now_hit].knockback_mode = mode;
904}
void GetRef(float *ref)
Definition camera.cpp:234
void GetPos(float *pos)
Definition camera.cpp:230
int CheckHitUser(float *position, int mask, float height)
int Set(float *position, int damage, int life, float radius, float scale_rate, int target_mask, int kind, int flags, int attribute)
COLLISION_HIT hit[96]
void SetKickBack(float *origin, float speed, float decay, int mode)
void Draw()
Definition dispctrl.cpp:60
char text[0x200]
Definition gameloop.cpp:167
CDungeonEvent * event
CDungeonEventData event[96]
void SetupEvent(CDungeonMap *map, int mode)
CDungeonEventData * SearchDataSlotPos(float *position)
ROOM_LINK_RESULT room_link[4]
int SetCharaDoor(int chara_no)
TREASURE_BOX boxes[24]
ATRA_BOLL atra[8]
DUNGEON_EVENT events[48]
int Down(int mask)
Definition gamepad.cpp:583
void MenuModeOff()
Definition gamepad.cpp:617
void AutoRepeatOff()
Definition gamepad.cpp:609
virtual void GetRotation(float *out_rotation)
Definition object.cpp:116
float pos[4]
Definition object.hpp:18
s32 res_limit_zone_current
@ DNG_EVENT_NONE
sceVu0FVECTOR knockback_origin
sceVu0FVECTOR pos
sceVu0FVECTOR base_point
sceVu0FVECTOR velocity