DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
edit.cpp
1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3#pragma name_counter 338
4
5#include "common.h"
6
7#include <libgraph.h>
8#include <libpkt.h>
9#include <libvu0.h>
10#include <sifdev.h>
11
12#include <cmath>
13#include <cstdio>
14#include <cstdlib>
15#include <cstring>
16
17#include "battle_globals.hpp"
18#include "battlemenu.hpp"
19#include "boxvu0.hpp"
20#include "btmisc.hpp"
21#include "camera.hpp"
22#include "character.hpp"
23#include "clsmes.hpp"
24#include "debugfont.hpp"
25#include "dngstatusdata.hpp"
26#include "edit.hpp"
27#include "editground.hpp"
28#include "editloop3.hpp"
29#include "editmapscript.hpp"
30#include "editpartsinfo.hpp"
31#include "effectmacro.hpp"
32#include "frame.hpp"
33#include "framevu1.hpp"
34#include "gamepad.hpp"
35#include "mainselect.hpp"
36#include "mapparts.hpp"
37#include "mathutil.hpp"
38#include "memcard.hpp"
39#include "menu_misc.hpp"
40#include "menu_save.hpp"
41#include "mglib.hpp"
42#include "npcharacter.hpp"
43#include "objanime.hpp"
44#include "rect.hpp"
45#include "savedata.hpp"
46#include "shop.hpp"
47#include "snd.hpp"
48#include "sound.hpp"
49#include "texture.hpp"
50
51/* Retail editetc.cpp: shared editor presentation, sound, menus and message helpers. */
52
53static void DrawBound(CFrame *frame);
54static void DrawLine(int *from, int *to, u_char r, u_char g, u_char b, u_char a);
55
59struct SOUND_SRC {
60 int se;
61 int num;
62 float volume[16];
63 float pan[16];
64};
65
66void EdSaveFrameImage(CTexture texture);
67
68/* 28 bytes nothing reads other than a word at a time, so it is spelled as words rather than as a
69 layout nothing supports. */
70#include "dataset.hpp"
71#include "editloop.hpp"
72#include "editmenu.hpp"
73#include "main.hpp"
74
75void ClearSystemMes();
76int SystemMesCheck();
77void SystemMesStep();
78void SystemMesDraw();
79void ItemGetMes(int item, int value, int duration, int input_key);
80
81/* The map editor's own debug layer: a text overlay anything may append a line to, a free camera
82 and a free character driven straight off the pad, and a wireframe box drawn through the GS by
83 hand because nothing else in the game draws lines.
84 Two switches gate all of it. Debug starts on and EdDDebug turns it off for good - the argument
85 it is handed is not read - so a build reaches the overlay only until the first call. DebugFont
86 is null until somebody hands one over, and every entry point checks it, because the overlay
87 writes into that object's buffer rather than one of its own. */
88int EdDebugEventEnable = 1;
89int EdDebugCameraFlag;
90int EdDebugParamDrawOff;
91int EdDebugCharaDrawOff;
92int EdDebugMoveFlag;
93#ifdef PAL
94int EdDebugRunEventNo;
95#endif
96
97static int Debug = 1;
98static CDebugFont *DebugFont;
99
100void EdDDebug(int on) {
101 Debug = 0;
102}
103
104void EdDSetFont(CDebugFont *font) {
105 DebugFont = font;
106}
107
108/* The frame counter is printed first, so it stands at the top of whatever the frame appended
109 after it. With the overlay switched off the buffer is still emptied every frame, which is what
110 keeps a switched-off build from overrunning it. */
111void EdDDrawFont() {
112 char work[112];
113 static int count = 0;
114
115 if (DebugFont == 0) {
116 return;
117 }
118
119 sprintf(work, "%d\n", count++);
120 EdDPrint(work);
121
122 if (Debug == 0) {
123 DebugFont->length = 0;
124 return;
125 }
126
127 TexManager.ReloadTexture(GetVif1Packet(), 31);
128 DebugFont->Draw();
129}
130
131/* The overflow guard for the frames nothing draws the overlay on: the buffer is 512 bytes and a
132 line is short, so emptying it at 500 leaves room for whatever is already on its way in. */
133void EdDCheck() {
134 if (DebugFont == 0) {
135 return;
136 }
137
138 if (DebugFont->length > 500) {
139 DebugFont->length = 0;
140 }
141}
142
143void EdOutPutFile() {
144 int fd;
145
146 if (Debug == 0) {
147 return;
148 }
149
150 if (DebugFont == 0) {
151 return;
152 }
153
154 fd = sceOpen("host0:debug.txt", SCE_WRONLY | SCE_CREAT | SCE_TRUNC);
155
156 if (fd < 0) {
157 return;
158 }
159
160 sceWrite(fd, DebugFont->text, DebugFont->length);
161 sceClose(fd);
162}
163
164/* The append is length-counted on the way out, and the length it adds goes to whatever DebugFont
165 points at now rather than to the object it was handed. */
166static int AddStr(CDebugFont *font, char *str) {
167 int len;
168
169 len = strlen(str);
170 strcpy(&font->text[font->length], str);
171 DebugFont->length += len;
172 return len;
173}
174
175#ifdef PAL
176void EdDPrintChara(CMainChara *chara) {
177 sceVu0FVECTOR vector;
178 char work[128];
179
180 if (Debug == 0) {
181 return;
182 }
183
184 if (DebugFont == 0) {
185 return;
186 }
187
188 chara->GetPosition(vector);
189 sprintf(work, "chara\n pos = %7.2f,%7.2f,%7.2f\n", vector[0], vector[1], vector[2]);
190 AddStr(DebugFont, work);
191 chara->GetRotation(vector);
192 sprintf(work, " rot = %7.2f,%7.2f,%7.2f\n", vector[0], vector[1], vector[2]);
193 AddStr(DebugFont, work);
194 sprintf(work, " (%d %d %d)\n", chara->move_info.ground_poly.attr.ground_kind, chara->move_info.ground_poly.attr.foot_sound, chara->move_info.ground_poly.attr.area_kind);
195
196 if (chara->move_info.landed) {
197 AddStr(DebugFont, work);
198 }
199}
200#endif
201
202#ifdef PAL
203void EdDPrintCamera(CCamera *camera) {
204 sceVu0FVECTOR vector;
205 char work[128];
206
207 if (Debug == 0) {
208 return;
209 }
210
211 if (DebugFont == 0) {
212 return;
213 }
214
215 camera->GetPos(vector);
216 sprintf(work, "camera\n pos = %7.2f,%7.2f,%7.2f\n", vector[0], vector[1], vector[2]);
217 AddStr(DebugFont, work);
218 camera->GetRef(vector);
219 sprintf(work, " ref = %7.2f,%7.2f,%7.2f\n", vector[0], vector[1], vector[2]);
220 AddStr(DebugFont, work);
221 sprintf(work, " projection = %7.1f\n", MGGetProjection());
222 AddStr(DebugFont, work);
223}
224
225#pragma name_counter 421
226#endif
227
228void EdDPrintVector(char *name, float *vector) {
229 char work[128];
230
231 if (Debug == 0) {
232 return;
233 }
234
235 if (DebugFont == 0) {
236 return;
237 }
238
239 sprintf(work, "%s %7.2f,%7.2f,%7.2f\n", name, vector[0], vector[1], vector[2]);
240 AddStr(DebugFont, work);
241}
242
243void EdDPrint(char *text) {
244 if (Debug == 0) {
245 return;
246 }
247
248 if (DebugFont == 0) {
249 return;
250 }
251
252 AddStr(DebugFont, text);
253}
254
255/* The free camera: the sticks move the eye in the plane the eye already looks along, so pushing
256 forward closes on whatever is being looked at whichever way the camera faces, and the shoulder
257 buttons swing it around the reference point at a rate proportional to how far away it is.
258 R1 drags the reference point along with the eye, which is what turns a swing into a pan, and
259 the D-pad works the field of view. The box is drawn where the reference point is, so the point
260 being orbited is visible. */
261void EdDMoveCamera(float *position, float *reference) {
262 sceVu0FVECTOR offset;
263 sceVu0FVECTOR move;
264 float distance;
265 float angle;
266 float x;
267 float y;
268 float z;
269 float projection;
270 int i;
271
272 if (Debug == 0) {
273 return;
274 }
275
276 sceVu0SubVector(offset, reference, position);
277 distance = sqrtf(offset[0] * offset[0] + offset[2] * offset[2]);
278 angle = atan2f(offset[0], offset[2]);
279
280 x = -GamePad.GetLXf();
281
282 if (GamePad.On(PAD_R1)) {
283 x = 0.02f * distance;
284 }
285
286 if (GamePad.On(PAD_L1)) {
287 x = 0.02f * -distance;
288 }
289
290 y = -GamePad.GetRYf();
291 z = -GamePad.GetLYf();
292
293 move[0] = x * cosf(angle) + z * sinf(angle);
294 move[1] = y;
295 move[2] = z * cosf(angle) - x * sinf(angle);
296
297 if (GamePad.On(PAD_CROSS)) {
298 sceVu0ScaleVector(move, move, 3.0f);
299 }
300
301 sceVu0AddVector(position, position, move);
302
303 if (GamePad.On(PAD_SQUARE) && !GamePad.On(PAD_L1 | PAD_R1)) {
304 sceVu0AddVector(reference, reference, move);
305 }
306
307 projection = MGGetProjection();
308
309 if (GamePad.On(PAD_RIGHT)) {
310 projection += 1.0f;
311 }
312
313 if (GamePad.On(PAD_LEFT)) {
314 projection -= 1.0f;
315 }
316
317 if (projection < 100.0f) {
318 projection = 100.0f;
319 }
320
321 if (projection > 2000.0f) {
322 projection = 2000.0f;
323 }
324
325 MGSetProjection(projection);
326
327 {
328 CFrame frame;
329 float unit[2] = {-1.0f, 1.0f};
330
331 for (i = 0; i < 8; i++) {
332 frame.corner[i][0] = unit[(i & 1) != 0];
333 frame.corner[i][1] = unit[(i & 2) != 0];
334 frame.corner[i][2] = unit[(i & 4) != 0];
335 frame.corner[i][3] = 1.0f;
336 }
337
338 frame.SetPosition(reference);
339 DrawBound(&frame);
340 }
341}
342
343/* The same camera driven from the other end: the sticks move the reference point and R1 drags the
344 eye after it, which is what lets the point being orbited be placed before it is orbited. */
345void EdDMoveCameraRef(float *position, float *reference) {
346 sceVu0FVECTOR offset;
347 sceVu0FVECTOR move;
348 float distance;
349 float angle;
350 float x;
351 float y;
352 float z;
353 int i;
354
355 if (Debug == 0) {
356 return;
357 }
358
359 sceVu0SubVector(offset, reference, position);
360 distance = sqrtf(offset[0] * offset[0] + offset[2] * offset[2]);
361 angle = atan2f(offset[0], offset[2]);
362
363 x = -GamePad.GetLXf();
364
365 if (GamePad.On(PAD_R1)) {
366 x = 0.02f * -distance;
367 }
368
369 if (GamePad.On(PAD_L1)) {
370 x = 0.02f * distance;
371 }
372
373 y = GamePad.GetRYf();
374 z = -GamePad.GetLYf();
375
376 move[0] = x * cosf(angle) + z * sinf(angle);
377 move[1] = y;
378 move[2] = z * cosf(angle) - x * sinf(angle);
379
380 sceVu0AddVector(reference, reference, move);
381
382 if (GamePad.On(PAD_SQUARE) && !GamePad.On(PAD_L1 | PAD_R1)) {
383 sceVu0AddVector(position, position, move);
384 }
385
386 {
387 CFrame frame;
388 float unit[2] = {-1.0f, 1.0f};
389
390 for (i = 0; i < 8; i++) {
391 frame.corner[i][0] = unit[(i & 1) != 0];
392 frame.corner[i][1] = unit[(i & 2) != 0];
393 frame.corner[i][2] = unit[(i & 4) != 0];
394 frame.corner[i][3] = 1.0f;
395 }
396
397 frame.SetPosition(reference);
398 DrawBound(&frame);
399 }
400}
401
402/* The free character: the same plane-relative stick mapping as the camera, plus a facing the
403 shoulder buttons turn and keep inside one revolution, and an ambient offset the face buttons
404 work. Triangle re-aims the camera at the body rather than at the feet, which is why the height
405 of the body is what the reference point is lifted by.
406 The box is ten across and twenty tall - a stand-in for the body rather than the body's own
407 size - and it is drawn with the character's own rotation so the facing can be seen. */
408void EdDMoveChara(CCharacter *character, CCamera *camera) {
409 sceVu0FVECTOR pos;
410 sceVu0FVECTOR camera_pos;
411 sceVu0FVECTOR camera_ref;
412 sceVu0FVECTOR rot;
413 sceVu0FVECTOR view;
414 sceVu0FVECTOR move;
415 float angle;
416 float speed;
417 float x;
418 float y;
419 float z;
420 float ambient;
421 int i;
422
423 if (character == 0) {
424 return;
425 }
426
427 character->GetPosition(pos);
428 character->GetRotation(rot);
429 camera->GetPos(camera_pos);
430 camera->GetRef(camera_ref);
431
432 sceVu0SubVector(view, camera_ref, camera_pos);
433 angle = atan2f(view[0], view[2]);
434 speed = 0.5f;
435
436 x = -GamePad.GetLXf();
437 y = -GamePad.GetRYf();
438 z = -GamePad.GetLYf();
439
440 if (GamePad.On(PAD_R1)) {
441 rot[1] += -0.06f;
442 }
443
444 if (GamePad.On(PAD_L1)) {
445 rot[1] += 0.06f;
446 }
447
448 if (rot[1] > PI_SHORT) {
449 rot[1] -= TWO_PI_SHORT;
450 }
451
452 if (rot[1] < -PI_SHORT) {
453 rot[1] += TWO_PI_SHORT;
454 }
455
456 move[0] = x * cosf(angle) + z * sinf(angle);
457 move[1] = y;
458 move[2] = z * cosf(angle) - x * sinf(angle);
459
460 if (GamePad.On(PAD_SQUARE)) {
461 speed = 1.0f;
462 }
463
464 sceVu0ScaleVector(move, move, speed);
465 sceVu0AddVector(pos, pos, move);
466 character->SetPosition(pos);
467 character->SetRotation(rot);
468
469 if (GamePad.Down(PAD_TRIANGLE)) {
470 sceVu0CopyVector(camera_ref, pos);
471 camera_ref[1] += 0.7f * character->body_height;
472 camera->SetRef(camera_ref);
473 }
474
475 ambient = character->ambient_offset[0];
476
477 if (GamePad.On(PAD_R2)) {
478 ambient += 0.1f;
479 }
480
481 if (GamePad.On(PAD_L2)) {
482 ambient -= 0.1f;
483 }
484
485 if (ambient != character->ambient_offset[0]) {
486 character->ambient_offset[0] = ambient;
487 character->ambient_offset[1] = ambient;
488 character->ambient_offset[2] = ambient;
489 }
490
491 {
492 CFrame frame;
493 float ground[2] = {-5.0f, 5.0f};
494 float height[2] = {0.0f, 20.0f};
495
496 for (i = 0; i < 8; i++) {
497 frame.corner[i][0] = ground[(i & 1) != 0];
498 frame.corner[i][1] = height[(i & 2) != 0];
499 frame.corner[i][2] = ground[(i & 4) != 0];
500 frame.corner[i][3] = 1.0f;
501 }
502
503 frame.SetPosition(pos);
504 frame.SetRotation(rot[0], rot[1], rot[2]);
505 DrawBound(&frame);
506 }
507}
508
509#ifdef PAL
510void EdDebugMenu() {
511 static int mode = 0;
512
513 switch (mode) {
514 case 0:
515 DM_Main();
516 break;
517 case 2:
518 DM_Sound();
519 break;
520 case 1:
521 DM_Flag();
522 break;
523 }
524
525 if (GamePad.Down(PAD_R2)) {
526 mode++;
527 }
528
529 if (GamePad.Down(PAD_L2)) {
530 mode--;
531 }
532
533 if (mode < 0) {
534 mode = 0;
535 }
536
537 if (mode >= 3) {
538 mode = 2;
539 }
540
541 TexManager.ReloadTexture(GetVif1Packet(), 31);
542 DebugFont->Draw();
543}
544#endif
545
546#ifdef PAL
547void DM_Main() {
548 static int select = 0;
549 static int run_event = 150;
550 static int talk_chara = 0;
551 char work[128];
552 char *on_off[2] = {"OFF", "ON"};
553 char *cursor[2] = {" ", "->"};
554
555 AddStr(DebugFont, " MAIN ->R2\n");
556 sprintf(work, "%sDEBUG CAMERA %s\n", cursor[select == 0], on_off[EdDebugCameraFlag]);
557 AddStr(DebugFont, work);
558 sprintf(work, "%sPARAMETER %s\n", cursor[select == 1], on_off[!EdDebugParamDrawOff]);
559 AddStr(DebugFont, work);
560 sprintf(work, "%sCHARACTER %s\n", cursor[select == 2], on_off[!EdDebugCharaDrawOff]);
561 AddStr(DebugFont, work);
562 sprintf(work, "%sMESSAGE %s\n", cursor[select == 3], on_off[!MesAbsDrawOff]);
563 AddStr(DebugFont, work);
564 sprintf(work, "%sDEBUG MOVE %d\n", cursor[select == 4], EdDebugMoveFlag);
565 AddStr(DebugFont, work);
566 sprintf(work, "%sRUN EVENT %d\n", cursor[select == 5], run_event);
567 AddStr(DebugFont, work);
568 sprintf(work, "%sTALK EVENT %d\n", cursor[select == 6], talk_chara);
569 AddStr(DebugFont, work);
570 sprintf(work, "%sEVENT %s\n", cursor[select == 7], on_off[EdDebugEventEnable]);
571 AddStr(DebugFont, work);
572 sprintf(work, "%sLANGUAGE %d\n", cursor[select == 8], LanguageCode);
573 AddStr(DebugFont, work);
574
575 EdDebugRunEventNo = -1;
576
577 switch (select) {
578 case 0:
579 if (GamePad.Down(PAD_RIGHT)) {
580 EdDebugCameraFlag = 1;
581 }
582
583 if (GamePad.Down(PAD_LEFT)) {
584 EdDebugCameraFlag = 0;
585 }
586
587 break;
588 case 1:
589 if (GamePad.Down(PAD_RIGHT)) {
590 EdDebugParamDrawOff = 0;
591 }
592
593 if (GamePad.Down(PAD_LEFT)) {
594 EdDebugParamDrawOff = 1;
595 }
596
597 break;
598 case 2:
599 if (GamePad.Down(PAD_RIGHT)) {
600 EdDebugCharaDrawOff = 0;
601 }
602
603 if (GamePad.Down(PAD_LEFT)) {
604 EdDebugCharaDrawOff = 1;
605 }
606
607 break;
608 case 3:
609 if (GamePad.Down(PAD_RIGHT)) {
610 MesAbsDrawOff = 0;
611 }
612
613 if (GamePad.Down(PAD_LEFT)) {
614 MesAbsDrawOff = 1;
615 }
616
617 break;
618 case 4:
619 if (GamePad.Down(PAD_RIGHT)) {
620 EdDebugMoveFlag++;
621 }
622
623 if (GamePad.Down(PAD_LEFT)) {
624 EdDebugMoveFlag--;
625 }
626
627 if (EdDebugMoveFlag < 0) {
628 EdDebugMoveFlag = 0;
629 }
630
631 if (EdDebugMoveFlag > 2) {
632 EdDebugMoveFlag = 2;
633 }
634
635 break;
636 case 5:
637 if (GamePad.Down(PAD_RIGHT)) {
638 run_event++;
639 }
640
641 if (GamePad.Down(PAD_LEFT)) {
642 run_event--;
643 }
644
645 if (GamePad.Down(PAD_L1)) {
646 run_event -= 10;
647 }
648
649 if (GamePad.Down(PAD_R1)) {
650 run_event += 10;
651 }
652
653 if (GamePad.On(PAD_CIRCLE)) {
654 EdDebugRunEventNo = run_event;
655 }
656
657 break;
658 case 6:
659 if (GamePad.Down(PAD_RIGHT)) {
660 talk_chara++;
661 }
662
663 if (GamePad.Down(PAD_LEFT)) {
664 talk_chara--;
665 }
666
667 if (GamePad.Down(PAD_L1)) {
668 talk_chara -= 10;
669 }
670
671 if (GamePad.Down(PAD_R1)) {
672 talk_chara += 10;
673 }
674
675 if (GamePad.On(PAD_CIRCLE)) {
676 EdTalkModeInit(EdVillager, talk_chara);
677 EdDebugRunEventNo = 256;
678 }
679
680 break;
681 case 7:
682 if (GamePad.Down(PAD_RIGHT)) {
683 EdDebugEventEnable = 1;
684 }
685
686 if (GamePad.Down(PAD_LEFT)) {
687 EdDebugEventEnable = 0;
688 }
689
690 break;
691 case 8:
692 if (GamePad.Down(PAD_RIGHT)) {
693 LanguageCode++;
694 }
695
696 if (GamePad.Down(PAD_LEFT)) {
697 LanguageCode--;
698 }
699
700 if (LanguageCode < LANG_JAPANESE) {
701 LanguageCode = LANG_JAPANESE;
702 }
703
704 if (LanguageCode > LANG_SPANISH) {
705 LanguageCode = LANG_SPANISH;
706 }
707
708 break;
709 }
710
711 if (GamePad.Down(PAD_DOWN)) {
712 select++;
713 }
714
715 if (GamePad.Down(PAD_UP)) {
716 select--;
717 }
718
719 if (select < 0) {
720 select = 8;
721 }
722
723 if (select >= 9) {
724 select = 0;
725 }
726}
727
728void DM_Sound() {
729 static int select = 0;
730 static int bgm_no = 0;
731 static int se_no = 0;
732 static int set_no = 0;
733 static int bgm_seq = 0;
734 char work[128];
735 char *on_off[2] = {"OFF", "ON"};
736 char *cursor[2] = {" ", "->"};
737
738 AddStr(DebugFont, "L2<-SOUND ->\n");
739 sprintf(work, "%sBGM PLAY %d SEQ = %d o:PLAY x:STOP\n", cursor[select == 0], bgm_no, bgm_seq);
740 AddStr(DebugFont, work);
741 sprintf(work, "%sBGM OFF = %s\n", cursor[select == 1], on_off[SndGetBgmDisableFlag()]);
742 AddStr(DebugFont, work);
743 sprintf(work, "%sSE PLAY %d O:PLAY X:STOP\n", cursor[select == 2], se_no);
744 AddStr(DebugFont, work);
745 sprintf(work, "%sSOUND SET %d O:PLAY X:STOP\n", cursor[select == 3], set_no);
746 AddStr(DebugFont, work);
747
748 switch (select) {
749 case 0:
750 if (GamePad.Down(PAD_RIGHT)) {
751 bgm_no++;
752 }
753
754 if (GamePad.Down(PAD_LEFT)) {
755 bgm_no--;
756 }
757
758 if (GamePad.Down(PAD_L1)) {
759 bgm_no -= 10;
760 }
761
762 if (GamePad.Down(PAD_R1)) {
763 bgm_no += 10;
764 }
765
766 if (GamePad.Down(PAD_TRIANGLE)) {
767 bgm_seq++;
768 }
769
770 if (GamePad.Down(PAD_SQUARE)) {
771 bgm_seq--;
772 }
773
774 if (bgm_seq < 0) {
775 bgm_seq = 0;
776 }
777
778 if (bgm_seq > 3) {
779 bgm_seq = 3;
780 }
781
782 if (GamePad.Down(PAD_CIRCLE)) {
783 SndBgmStop();
784 SndBgmInit();
785 SndBgmLoad(bgm_no);
786 SndBgmPlay(bgm_seq);
787 }
788
789 if (GamePad.Down(PAD_CROSS)) {
790 SndBgmStop();
791 SndBgmInit();
792 }
793
794 break;
795 case 1:
796 if (GamePad.Down(PAD_RIGHT)) {
797 SndBgmDisable(1);
798 }
799
800 if (GamePad.Down(PAD_LEFT)) {
801 SndBgmDisable(0);
802 }
803
804 break;
805 case 2:
806 if (GamePad.Down(PAD_RIGHT)) {
807 se_no++;
808 }
809
810 if (GamePad.Down(PAD_LEFT)) {
811 se_no--;
812 }
813
814 if (GamePad.Down(PAD_L1)) {
815 se_no -= 10;
816 }
817
818 if (GamePad.Down(PAD_R1)) {
819 se_no += 10;
820 }
821
822 if (GamePad.Down(PAD_CIRCLE)) {
823 SndSePlay(se_no, -1, 0);
824 }
825
826 if (GamePad.Down(PAD_CROSS)) {
827 SndSeStop(se_no, 0);
828 }
829
830 break;
831 case 3:
832 if (GamePad.Down(PAD_RIGHT)) {
833 set_no++;
834 }
835
836 if (GamePad.Down(PAD_LEFT)) {
837 set_no--;
838 }
839
840 if (GamePad.Down(PAD_L1)) {
841 set_no -= 10;
842 }
843
844 if (GamePad.Down(PAD_R1)) {
845 set_no += 10;
846 }
847
848 if (GamePad.Down(PAD_CIRCLE)) {
849 SndSoundLoad(set_no);
850 }
851
852 break;
853 }
854
855 if (GamePad.Down(PAD_DOWN)) {
856 select++;
857 }
858
859 if (GamePad.Down(PAD_UP)) {
860 select--;
861 }
862
863 if (select < 0) {
864 select = 0;
865 }
866
867 if (select >= 4) {
868 select = 3;
869 }
870}
871
875static inline void RaiseFloorReached(CDngStatusData *status, int dungeon, int floor) {
876 if (floor > status->floor_reached[dungeon]) {
877 status->floor_reached[dungeon] = floor;
878 }
879}
880
881void DM_Flag() {
882 static int select = 0;
883 static int game_no = 0;
884 static int map_no = 0;
885 static int comp_no = 0;
886 static int dun_map = MapNo;
887 static int chara = 0;
888 char work[128];
889 CDngStatusData *status;
890 SV_GRD_NPC *npc;
891 int *value;
892 int floor;
893 int talk;
894 int i;
895
896 // Maps inside a dungeon count as that dungeon.
897 if (dun_map == 11) {
898 dun_map = 1;
899 }
900
901 if (dun_map == 13) {
902 dun_map = 1;
903 }
904
905 if (dun_map == 33) {
906 dun_map = 1;
907 }
908
909 if (dun_map == 19) {
910 dun_map = 2;
911 }
912
913 if (dun_map == 42) {
914 dun_map = 3;
915 }
916
917 if (dun_map == 23) {
918 dun_map = 4;
919 }
920
921 if (dun_map == 38) {
922 dun_map = 5;
923 }
924
925 if (dun_map == 40) {
926 dun_map = 5;
927 }
928
929 if (dun_map > 5) {
930 dun_map = 0;
931 }
932
933 char *on_off[2] = {"OFF", "ON"};
934 char *cursor[2] = {" ", "->"};
935
936 AddStr(DebugFont, "L2<-FALG ->R\n");
937 status = SaveData->GetDngStatus();
938 sprintf(work, "%sGAMEFLAG %3d = %s\n", cursor[select == 0], game_no, on_off[SaveData->GetGameFlag(game_no)]);
939 AddStr(DebugFont, work);
940 sprintf(work, "%sMAPFLAG %3d = %s\n", cursor[select == 1], map_no, on_off[!SaveData->GetMapFlag(MapNo, map_no)]);
941 AddStr(DebugFont, work);
942 sprintf(work, "%sCOMPFLAG %3d = %s\n", cursor[select == 2], comp_no, on_off[EditPartsInfo.GetCompEvent(comp_no)]);
943 AddStr(DebugFont, work);
944 sprintf(work, "%sGAME INT FALG 0 = %d\n", cursor[select == 3], SaveData->GetGameIntFlag(0));
945 AddStr(DebugFont, work);
946 sprintf(work, "%sQUEST DUNGEON = %d\n", cursor[select == 4], SaveData->QuestDungeon(dun_map, 0));
947 AddStr(DebugFont, work);
948 floor = status->floor_reached[dun_map];
949 sprintf(work, "%sDUNGEON FLOOR = %d\n", cursor[select == 5], floor);
950 AddStr(DebugFont, work);
951 sprintf(work, "%sPARTY NUM = %d\n", cursor[select == 6], status->party_size);
952 AddStr(DebugFont, work);
953 npc = SaveData->GetGrdNPCData(MapNo, chara);
954 talk = false;
955
956 if (npc) {
957 talk = npc->talk_message;
958 }
959
960 sprintf(work, "%sTALKFLAG %3d = %d\n", cursor[select == 7], chara, talk);
961 AddStr(DebugFont, work);
962
963 value = NULL;
964
965 switch (select) {
966 case 0:
967 value = &game_no;
968
969 if (GamePad.Down(PAD_CIRCLE)) {
970 SaveData->SetGameFlag(game_no, 1);
971 }
972
973 if (GamePad.Down(PAD_CROSS)) {
974 SaveData->SetGameFlag(game_no, 0);
975 }
976
977 break;
978 case 1:
979 value = &map_no;
980
981 if (GamePad.Down(PAD_CIRCLE)) {
982 SaveData->SetMapFlag(MapNo, map_no, 0);
983 }
984
985 if (GamePad.Down(PAD_CROSS)) {
986 SaveData->SetMapFlag(MapNo, map_no, 1);
987 }
988
989 break;
990 case 2:
991 value = &comp_no;
992
993 if (GamePad.Down(PAD_CIRCLE)) {
994 EditPartsInfo.SetCompEvent(comp_no, 1);
995 }
996
997 if (GamePad.Down(PAD_CROSS)) {
998 EditPartsInfo.SetCompEvent(comp_no, 0);
999 }
1000
1001 if (GamePad.Down(PAD_TRIANGLE)) {
1002 SV_GEORAMA_DATA *georama;
1003
1004 for (i = 0; i < 24; i++) {
1005 EditPartsInfo.SetCompEvent(i, 1);
1006 }
1007
1008 georama = SaveData->GetGrdData(MapNo);
1009
1010 if (georama) {
1011 georama->request_event_flag = 1;
1012 }
1013 }
1014
1015 if (GamePad.Down(PAD_SQUARE)) {
1016 SV_GEORAMA_DATA *georama;
1017
1018 for (i = 0; i < 24; i++) {
1019 EditPartsInfo.SetCompEvent(i, 0);
1020 }
1021
1022 georama = SaveData->GetGrdData(MapNo);
1023
1024 if (georama) {
1025 georama->request_event_flag = 0;
1026 }
1027 }
1028
1029 break;
1030 case 3: {
1031 int flag = SaveData->GetGameIntFlag(0);
1032
1033 if (GamePad.Down(PAD_RIGHT)) {
1034 flag++;
1035 }
1036
1037 if (GamePad.Down(PAD_LEFT)) {
1038 flag--;
1039 }
1040
1041 if (GamePad.Down(PAD_R1)) {
1042 flag += 10;
1043 }
1044
1045 if (GamePad.Down(PAD_L1)) {
1046 flag -= 10;
1047 }
1048
1049 if (flag < 0) {
1050 flag = 0;
1051 }
1052
1053 SaveData->SetGameIntFlag(0, flag);
1054 break;
1055 }
1056 case 4:
1057 if (GamePad.Down(PAD_RIGHT)) {
1058 SaveData->QuestDungeon(dun_map, 1);
1059 }
1060
1061 if (GamePad.Down(PAD_LEFT)) {
1062 SaveData->QuestDungeon(dun_map, -1);
1063 }
1064
1065 if (GamePad.Down(PAD_R1)) {
1066 SaveData->QuestDungeon(dun_map, 10);
1067 }
1068
1069 if (GamePad.Down(PAD_L1)) {
1070 SaveData->QuestDungeon(dun_map, -10);
1071 }
1072
1073 break;
1074 case 5: {
1075 floor = status->floor_reached[dun_map];
1076
1077 if (GamePad.Down(PAD_RIGHT)) {
1078 floor++;
1079 }
1080
1081 if (GamePad.Down(PAD_LEFT)) {
1082 floor--;
1083 }
1084
1085 if (GamePad.Down(PAD_R1)) {
1086 floor += 10;
1087 }
1088
1089 if (GamePad.Down(PAD_L1)) {
1090 floor -= 10;
1091 }
1092
1093 RaiseFloorReached(status, dun_map, floor);
1094 break;
1095 }
1096 case 6:
1097 if (GamePad.Down(PAD_RIGHT)) {
1098 status->party_size++;
1099 }
1100
1101 if (GamePad.Down(PAD_LEFT)) {
1102 status->party_size--;
1103 }
1104
1105 if (GamePad.Down(PAD_R1)) {
1106 status->party_size += 10;
1107 }
1108
1109 if (GamePad.Down(PAD_L1)) {
1110 status->party_size -= 10;
1111 }
1112
1113 break;
1114 case 7:
1115 value = &chara;
1116
1117 if (GamePad.Down(PAD_CIRCLE) && npc) {
1118 npc->talk_message++;
1119 }
1120
1121 if (GamePad.Down(PAD_CROSS) && npc) {
1122 npc->talk_message--;
1123 }
1124
1125 if (GamePad.Down(PAD_TRIANGLE)) {
1126 for (i = 0; i < 20; i++) {
1127 SV_GRD_NPC *other = SaveData->GetGrdNPCData(MapNo, i);
1128
1129 if (other) {
1130 other->talk_message = 1;
1131 }
1132 }
1133 }
1134
1135 if (GamePad.Down(PAD_SQUARE)) {
1136 for (i = 0; i < 20; i++) {
1137 SV_GRD_NPC *other = SaveData->GetGrdNPCData(MapNo, i);
1138
1139 if (other) {
1140 other->talk_message = 0;
1141 }
1142 }
1143 }
1144
1145 break;
1146 }
1147
1148 if (value) {
1149 if (GamePad.Down(PAD_RIGHT)) {
1150 (*value)++;
1151 }
1152
1153 if (GamePad.Down(PAD_LEFT)) {
1154 (*value)--;
1155 }
1156
1157 if (GamePad.Down(PAD_R1)) {
1158 *value += 10;
1159 }
1160
1161 if (GamePad.Down(PAD_L1)) {
1162 *value -= 10;
1163 }
1164
1165 if (*value < 0) {
1166 *value = 0;
1167 }
1168 }
1169
1170 if (GamePad.Down(PAD_DOWN)) {
1171 select++;
1172 }
1173
1174 if (GamePad.Down(PAD_UP)) {
1175 select--;
1176 }
1177
1178 if (select < 0) {
1179 select = 7;
1180 }
1181
1182 if (select >= 8) {
1183 select = 0;
1184 }
1185}
1186#endif
1187
1188/* The box drawn as twelve edges of the frame's own corner list, taken to the screen in one go and
1189 drawn only if every corner survived: a box with one corner behind the eye would otherwise be
1190 drawn through a projected point that means nothing. */
1191static void DrawBound(CFrame *frame) {
1192 int screen[8][4];
1193 sceVu0FVECTOR world[8];
1194 sceVu0FMATRIX matrix;
1195 int i;
1196 int visible;
1197
1198 if (frame == 0) {
1199 return;
1200 }
1201
1202 frame->GetLWMatrix(matrix);
1203 visible = true;
1204 ApplyMatrixN(world, matrix, frame->corner, 8);
1205
1206 for (i = 0; i < 8; i++) {
1207 visible &= MGRotTransPers(screen[i], world[i], 0);
1208 }
1209
1210 if (visible == 0) {
1211 return;
1212 }
1213
1214 DrawLine(screen[0], screen[1], 128, 64, 64, 80);
1215 DrawLine(screen[1], screen[5], 128, 64, 64, 80);
1216 DrawLine(screen[5], screen[4], 128, 64, 64, 80);
1217 DrawLine(screen[4], screen[0], 128, 64, 64, 80);
1218 DrawLine(screen[2], screen[3], 128, 64, 64, 80);
1219 DrawLine(screen[3], screen[7], 128, 64, 64, 80);
1220 DrawLine(screen[7], screen[6], 128, 64, 64, 80);
1221 DrawLine(screen[6], screen[2], 128, 64, 64, 80);
1222 DrawLine(screen[0], screen[2], 128, 64, 64, 80);
1223 DrawLine(screen[4], screen[6], 128, 64, 64, 80);
1224 DrawLine(screen[5], screen[7], 128, 64, 64, 80);
1225 DrawLine(screen[1], screen[3], 128, 64, 64, 80);
1226}
1227
1228/* One line straight into the frame's packet as an A+D list, which is the only way this game draws
1229 one at all. The depth test is left enabled with a comparison that never rejects, so the line
1230 comes out over whatever is already in front of it, and the two registers that costs are put back
1231 at the end of the same list, so whatever draws next finds the state this found. */
1232static void DrawLine(int *from, int *to, u_char r, u_char g, u_char b, u_char a) {
1233 sceVif1Packet *packet;
1234 sceGsTest test;
1235 sceGsZbuf zbuf;
1236 float q;
1237
1238 q = 1.0f;
1239 packet = GetVif1Packet();
1240
1241 test = mgPixelTest;
1242 test.bits.ate = 0;
1243 test.bits.aref = 0;
1244 test.bits.atst = SCE_GS_ALWAYS;
1245 test.bits.zte = 1;
1246 test.bits.ztst = SCE_GS_ALWAYS;
1247
1248 zbuf = mgZBuffer;
1249
1250 sceVif1PkCnt(packet, 0);
1251 sceVif1PkOpenDirectCode(packet, 0);
1252 sceVif1PkOpenGifTag(packet, *(u_long128 *) &GiftagAD);
1253
1254 sceVif1PkAddGsAD(packet, SCE_GS_TEST_1, *(u_long *) &test);
1255 sceVif1PkAddGsAD(packet, SCE_GS_ZBUF_1, *(u_long *) &zbuf);
1256 sceVif1PkAddGsAD(packet, SCE_GS_PRIM, SCE_GS_SET_PRIM(SCE_GS_PRIM_LINE, 0, 0, 0, 1, 0, 1, 0, 0));
1257 sceVif1PkAddGsAD(packet, SCE_GS_RGBAQ, SCE_GS_SET_RGBAQ(r, g, b, a, *(u_int *) &q));
1258 sceVif1PkAddGsAD(packet, SCE_GS_XYZF2, SCE_GS_SET_XYZF2(from[0], from[1], from[2], 0));
1259 sceVif1PkAddGsAD(packet, SCE_GS_XYZF2, SCE_GS_SET_XYZF2(to[0], to[1], to[2], 0));
1260 sceVif1PkAddGsAD(packet, SCE_GS_TEST_1, *(u_long *) &mgPixelTest);
1261 sceVif1PkAddGsAD(packet, SCE_GS_ZBUF_1, *(u_long *) &mgZBuffer);
1262
1263 sceVif1PkCloseGifTag(packet);
1264 sceVif1PkCloseDirectCode(packet);
1265}
1266
1267void EdSetBgmVol(float time) {
1268 float level = 1.0f;
1269
1270 // The town music plays at night and is silent through the day, fading out
1271 // over the hour before four.
1272 if (EdCheckTime(time, 4.0f, 11.0f) != 0) {
1273 level = 0.0f;
1274 }
1275
1276 if (!(time < 3.0f) && time < 4.0f) {
1277 level = 4.0f - time;
1278 }
1279
1280 int volume = (int) (level * (float) SndGetDefaultBgmVol());
1281
1282 if (volume < 2) {
1283 level = 0.0f;
1284 }
1285
1286 if (SndBgmCheck() == 1) {
1287 if (volume > 0) {
1288 SndSetBgmVol(volume);
1289 } else {
1290 SndBgmStop();
1291 }
1292 } else if (level > 0.0) {
1293 SndBgmPlay(0);
1294 SndSetBgmVol(volume);
1295 }
1296}
1297
1298void EdAmbientPlay(float time) {
1299 // The ambient sets run one behind the four times of day, and roll over.
1300 int ambient_no = EdGetTime(time);
1301
1302 if (++ambient_no >= 4) {
1303 ambient_no = 0;
1304 }
1305
1306 SndAmbientPlay(ambient_no);
1307}
1308
1309void EdSetAmbientVol(float volume) {
1310 SndAmbientSetVolf(volume);
1311}
1312
1313/* The sound the map editor puts in the world: every effect a map part carries that names a sound
1314 is measured against the camera each frame, and what survives is entered into one of four
1315 sources. A source is one sound effect and the set of places it is coming from at once, so a
1316 fountain heard from two sides occupies one slot and arrives as a single volume and a single
1317 pan. */
1318static SOUND_SRC sound_src[4];
1319static int now_play_se[4];
1320static int now_play_se_flag[4];
1321
1322static void init_sound_src() {
1323 int i;
1324
1325 for (i = 0; i < 4; i++) {
1326 sound_src[i].se = -1;
1327 sound_src[i].num = 0;
1328 }
1329}
1330
1331/* The slot a sound effect already occupies, or a free one, or nothing - which is what caps the
1332 world at four sounds at once. */
1333static SOUND_SRC *get_sound_src(int se) {
1334 int i;
1335
1336 for (i = 0; i < 4; i++) {
1337 if (se == sound_src[i].se) {
1338 return &sound_src[i];
1339 }
1340 }
1341
1342 for (i = 0; i < 4; i++) {
1343 if (sound_src[i].se < 0) {
1344 return &sound_src[i];
1345 }
1346 }
1347
1348 return 0;
1349}
1350
1351/* Whether the effect is already sounding, answered by claiming a channel for it when it is not:
1352 one for a sound that was playing, zero for one the caller now has to start, and -1 when every
1353 channel is spoken for. The flag beside the channel is what keeps this frame's sounds alive past
1354 the sweep at the end of the frame. */
1355static int check_se_play(int se) {
1356 int i;
1357
1358 if (se < 0) {
1359 return 0;
1360 }
1361
1362 for (i = 0; i < 4; i++) {
1363 if (se == now_play_se[i]) {
1364 now_play_se_flag[i] = 1;
1365 return 1;
1366 }
1367 }
1368
1369 for (i = 0; i < 4; i++) {
1370 if (now_play_se[i] < 0) {
1371 now_play_se[i] = se;
1372 now_play_se_flag[i] = 1;
1373 return 0;
1374 }
1375 }
1376
1377 return -1;
1378}
1379
1380void EdInitSoundSrc() {
1381 int i;
1382
1383 for (i = 0; i < 4; i++) {
1384 now_play_se[i] = -1;
1385 now_play_se_flag[i] = 0;
1386 }
1387
1388 init_sound_src();
1389}
1390
1391/* The frame's sources turned into commands. A sound gets one volume and one pan out of however
1392 many places it was entered from: the volumes add, and the pan is their average weighted by the
1393 same volumes, so the nearer place decides where the sound sits. Whatever was playing and was not
1394 entered this frame is stopped at the end, which is what a source leaving the camera behind comes
1395 to. */
1396void EdPlaySoundSrc() {
1397 int i;
1398 int j;
1399 int se;
1400 int playing;
1401 float volume;
1402 float pan;
1403
1404 for (i = 0; i < 4; i++) {
1405 now_play_se_flag[i] = 0;
1406 }
1407
1408 for (i = 0; i < 4; i++) {
1409 se = sound_src[i].se;
1410
1411 if (se < 0) {
1412 continue;
1413 }
1414
1415 playing = check_se_play(se);
1416
1417 if (playing < 0) {
1418 continue;
1419 }
1420
1421 if (playing == 0) {
1422 SndSePlay(se, 0, 0);
1423 }
1424
1425 volume = 0.0f;
1426
1427 for (j = 0; j < sound_src[i].num; j++) {
1428 volume += sound_src[i].volume[j];
1429 }
1430
1431 pan = 0.0f;
1432
1433 for (j = 0; j < sound_src[i].num; j++) {
1434 pan += sound_src[i].pan[j] * sound_src[i].volume[j] / volume;
1435 }
1436
1437 if (volume > 1.0f) {
1438 volume = 1.0f;
1439 }
1440
1441 SndSetSeVolf(se, volume, 0);
1442
1443 if (pan > 1.0f) {
1444 pan = 1.0f;
1445 }
1446
1447 if (pan < -1.0f) {
1448 pan = -1.0f;
1449 }
1450
1451 SndSetSePanf(se, pan, 0);
1452 }
1453
1454 for (i = 0; i < 4; i++) {
1455 if (now_play_se_flag[i]) {
1456 continue;
1457 }
1458
1459 if (now_play_se[i] < 0) {
1460 continue;
1461 }
1462
1463 SndSeStop(now_play_se[i], 0);
1464 now_play_se[i] = -1;
1465 }
1466}
1467
1468void EdStopSoundSrc() {
1469 int i;
1470
1471 for (i = 0; i < 4; i++) {
1472 if (now_play_se[i] < 0) {
1473 continue;
1474 }
1475
1476 SndSeStop(now_play_se[i], 0);
1477 now_play_se[i] = -1;
1478 }
1479
1480 SndSeStop(SE_AMBIENT_TOWN_PATTER, 0);
1481 SndSeStop(SE_AMBIENT_TOWN_NOISE, 0);
1482}
1483
1484/* How far a point is from a segment, and where on the segment it is nearest to. The projection is
1485 taken first and answers both when it falls inside the segment; outside it, the nearer end is the
1486 answer and the distance is the distance to that end. */
1487static float GetDistLine(float *point, float *from, float *to, float *near_point) {
1488 sceVu0FVECTOR offset;
1489 sceVu0FVECTOR to_offset;
1490 sceVu0FVECTOR projection;
1491 sceVu0FVECTOR line;
1492 float length;
1493 float from_dist;
1494 float to_dist;
1495 float fraction;
1496
1497 sceVu0SubVector(offset, from, point);
1498 sceVu0SubVector(to_offset, to, point);
1499 sceVu0SubVector(line, to_offset, offset);
1500 length = DistVector(line);
1501 length = length * length;
1502 fraction = -sceVu0InnerProduct(offset, line) / length;
1503
1504 if (fraction < 0.0f || fraction > 1.0f) {
1505 from_dist = DistVector(point, from);
1506 to_dist = DistVector(point, to);
1507
1508 if (from_dist < to_dist) {
1509 sceVu0CopyVector(near_point, from);
1510 return from_dist;
1511 }
1512
1513 sceVu0CopyVector(near_point, to);
1514 return to_dist;
1515 }
1516
1517 sceVu0ScaleVector(projection, line, fraction);
1518 sceVu0AddVector(projection, offset, projection);
1519 sceVu0AddVector(near_point, projection, point);
1520 return DistVector(projection);
1521}
1522
1523/* Every effect of every part measured against the camera, and the sources rebuilt from scratch:
1524 nothing survives a frame, so a part that stopped being audible simply is not entered again. The
1525 part's own frame is moved first because the effects hang off it, and a door is the one source
1526 the part itself carries rather than one of its effects. */
1527void EdSetSoundSrcVol(float time, CMapParts **parts, int count, float *camera_pos, float *camera_dir) {
1528 int i;
1529 int j;
1530 CFrame *frame;
1531 EDIT_EFFECT_INFO *effect;
1532 int se;
1533 SOUND_SRC *source;
1534 SOUND_SRC *door_source;
1535 float distance;
1536 float far_dist;
1537 float near_dist;
1538 sceVu0FVECTOR position;
1539 sceVu0FVECTOR rotation;
1540 sceVu0FVECTOR from;
1541 sceVu0FVECTOR to;
1542 sceVu0FVECTOR line;
1543 float volume;
1544 float pan;
1545 float door_volume;
1546 float door_pan;
1547
1548 SndSetCamera(camera_pos, camera_dir);
1549 init_sound_src();
1550
1551 for (i = 0; i < count; i++) {
1552 if (parts[i] == 0) {
1553 continue;
1554 }
1555
1556 frame = parts[i]->frame[0];
1557
1558 if (frame == 0) {
1559 continue;
1560 }
1561
1562 parts[i]->GetPosition(position);
1563 frame->SetPosition(position);
1564 parts[i]->GetRotation(rotation);
1565 frame->SetRotation(rotation[0], rotation[1], rotation[2]);
1566
1567 for (j = 0; j < 24; j++) {
1568 effect = parts[i]->effect[j];
1569
1570 if (parts[i]->effect_on[j] == 0) {
1571 continue;
1572 }
1573
1574 if (effect == 0) {
1575 continue;
1576 }
1577
1578 if (effect->kind != EDIT_EFFECT_SOUND && effect->kind != EDIT_EFFECT_FIRE_LARGE && effect->kind != EDIT_EFFECT_FIRE_SMALL) {
1579 continue;
1580 }
1581
1582 if (effect->frame == 0) {
1583 continue;
1584 }
1585
1586 if (CheckEditEffect(effect, time) == 0) {
1587 continue;
1588 }
1589
1590 effect->frame->GetWorldPosition(from, effect->offset);
1591
1592 if (effect->colour[3] == 1.0f) {
1593 effect->frame->GetWorldPosition(to, effect->colour);
1594 sceVu0CopyVector(line, from);
1595 distance = GetDistLine(camera_pos, line, to, from);
1596 } else {
1597 distance = DistVector(camera_pos, from);
1598 }
1599
1600 far_dist = effect->far_distance;
1601 near_dist = effect->near_distance;
1602 se = (int) effect->sound_no;
1603
1604 /* A torch and a fire are one sound at one range whatever the description says. */
1605 if (effect->kind == EDIT_EFFECT_FIRE_LARGE || effect->kind == EDIT_EFFECT_FIRE_SMALL) {
1606 se = 54;
1607 near_dist = 20.0f;
1608 far_dist = 150.0f;
1609 }
1610
1611 if (distance > far_dist) {
1612 continue;
1613 }
1614
1615 source = get_sound_src(se);
1616
1617 if (source == 0) {
1618 continue;
1619 }
1620
1621 SndGetVolPan(&volume, &pan, from, near_dist, far_dist);
1622 source->se = se;
1623
1624 if (source->num < 16) {
1625 source->volume[source->num] = volume;
1626 source->pan[source->num] = pan;
1627 source->num++;
1628 }
1629 }
1630
1631 if (parts[i]->subtype != MAP_PARTS_SUBTYPE_RIVER) {
1632 continue;
1633 }
1634
1635 if (DistVector(camera_pos, position) >= 300.0f) {
1636 continue;
1637 }
1638
1639 door_source = get_sound_src(52);
1640
1641 if (door_source == 0) {
1642 continue;
1643 }
1644
1645 SndGetVolPan(&door_volume, &door_pan, position, 100.0f, 300.0f);
1646 door_source->se = 52;
1647
1648 if (door_source->num < 16) {
1649 door_source->volume[door_source->num] = door_volume;
1650 door_source->pan[door_source->num] = door_pan;
1651 door_source->num++;
1652 }
1653 }
1654
1655 EdPlaySoundSrc();
1656}
1657
1665void EdDoorOpenSe(int door_no, float *position) {
1666 static int se_open[8] = {0x6C, 0x7E, 0x6E, 0x80, 0x74, 0x82, 0x70, 0x72};
1667
1668 if (door_no < 0 || door_no >= 8) {
1669 return;
1670 }
1671
1672 SndSePlay(se_open[door_no], -1, 0);
1673}
1674
1682void EdDoorCloseSe(int door_no, float *position) {
1683 static int se_close[8] = {0x6D, 0x7F, 0x6F, 0x81, 0x75, 0x83, 0x71, 0x73};
1684
1685 if (door_no < 0 || door_no >= 8) {
1686 return;
1687 }
1688
1689 SndSePlay(se_close[door_no], -1, 0);
1690}
1691
1692int EdGetDoorMotion(int door_no, int state) {
1693 static int motion[8][2] = {
1694 {3, 4 },
1695 {10, 10},
1696 {3, 4 },
1697 {10, 10},
1698 {3, 4 },
1699 {10, 10},
1700 {10, 10},
1701 {10, 10},
1702 };
1703
1704 if (door_no < 0 || door_no >= 8) {
1705 return 0;
1706 }
1707
1708 return motion[door_no][state != 0];
1709}
1710
1711/* The map editor's depth of field: one description at a time, taken from the map's own data or
1712 replaced by a default set, and handed every frame to the effect the rest of the game draws. */
1713static DEPTH_OF_FIELD_INFO dof;
1714
1715void EdSetDOFLevel(int level) {
1716 dof.level = level;
1717
1718 if (level == 0) {
1719 dof.start = ConvertTime(0.0f);
1720 dof.end = ConvertTime(24.0f);
1721 dof.distance[0] = 400.0f;
1722 dof.distance[1] = 1000.0f;
1723 dof.level = 2;
1724 dof.alpha = 64;
1725 dof.blur = 0;
1726 }
1727}
1728
1729void EdSetDOF(DEPTH_OF_FIELD_INFO *info) {
1730 dof = *info;
1731 EdSetDOFLevel(info->level);
1732}
1733
1734/* The argument is a cap rather than the level to draw at, so a configuration that asks for less
1735 than the map does gets less and one that asks for more does not get more. */
1736void EdDrawDOF(int level) {
1737 int drawn_level;
1738
1739 drawn_level = dof.level;
1740
1741 if (drawn_level < 0) {
1742 return;
1743 }
1744
1745 if (level < drawn_level) {
1746 drawn_level = level;
1747 }
1748
1749 DepthOfField(dof.distance, drawn_level, dof.alpha, dof.blur);
1750}
1751
1752/* The lightning three of the game's towns get, which is a model node shown for a few frames and a
1753 flash added to the parallel lights rather than anything drawn over the frame. The node is named
1754 in the ground's own model, so a map without it is simply a map without lightning. */
1755static int thunder_count;
1756static int start_thunder;
1757static int next_thunder_cnt;
1758static sceVu0FMATRIX thd_light;
1759static sceVu0FMATRIX thd_color;
1760
1761void EdInitThunderEffect() {
1762 thunder_count = 0;
1763 next_thunder_cnt = 60;
1764 start_thunder = 0;
1765}
1766
1767void EdThunderEffect(int map, CEditGround *ground) {
1768 CFrame *frame;
1769 sceVu0FMATRIX color;
1770 sceVu0FMATRIX light;
1771 int i;
1772 int j;
1773 int light_no;
1774 int channel;
1775
1776 if (map == 40 || map == 50 || map == 24) {
1777 frame = ground->fixed_parts[1].frame[0];
1778
1779 if (frame) {
1780 frame = frame->SearchFrame("inazuma");
1781 }
1782
1783 if (frame == 0) {
1784 return;
1785 }
1786
1787 /* The lights the map itself is lit by, kept from the first flash so that every later one
1788 decays back to them rather than to whatever the previous flash left. */
1789 if (start_thunder == 0) {
1790 MGGetPLight(thd_light, thd_color);
1791 }
1792
1793 MGGetPLight(light, color);
1794
1795 if (thunder_count > 0) {
1796 frame->attr.draw_on = 1;
1797 } else {
1798 thunder_count = 0;
1799
1800 if (next_thunder_cnt == 0) {
1801 thunder_count = 4;
1802
1803 for (light_no = 0; light_no < 2; light_no++) {
1804 for (channel = 0; channel < 3; channel++) {
1805 thd_color[light_no][channel] = 255.0f;
1806 }
1807 }
1808
1809 SndSePlay(rand() % 6 + SE_THUNDER_RUMBLE, -1, 0);
1810
1811 if (start_thunder == 0) {
1812 SndSePlay(SE_THUNDER_CLAP, -1, 0);
1813 start_thunder = 1;
1814 }
1815
1816 next_thunder_cnt = rand() % 200 + 10;
1817 }
1818
1819 frame->attr.draw_on = 2;
1820 }
1821
1822 thunder_count--;
1823 next_thunder_cnt--;
1824
1825 for (i = 0; i < 2; i++) {
1826 for (j = 0; j < 3; j++) {
1827 thd_color[i][j] -= 6.0f;
1828
1829 if (thd_color[i][j] < color[i][j]) {
1830 thd_color[i][j] = color[i][j];
1831 }
1832 }
1833 }
1834
1835 MGSetPLight(light, thd_color);
1836 }
1837}
1838
1842static inline int IsVisible(CNPCharacter *npc) {
1843 return (bool) (npc->initialized != 0 && npc->draw_enabled != 0);
1844}
1845
1849static inline int IsShadowVisible(CNPCharacter *npc) {
1850 bool visible = false;
1851
1852 if (npc->initialized != 0 && npc->draw_enabled != 0) {
1853 visible = true;
1854 }
1855
1856 return visible;
1857}
1858
1866void EdDrawCharacter(CCharacter *player, int player_draw_mask, int npc_count, CNPCharacter *npcs, int *npc_draw_masks, int draw_shadows, ED_EVENT_INFO *event) {
1867 int i;
1868
1869 if (EdDebugCharaDrawOff != 0) {
1870 player_draw_mask = 0;
1871 }
1872
1873 if (event != NULL) {
1874 draw_shadows = 0;
1875 player_draw_mask = 3;
1876
1877 if (event->player_draw == 0) {
1878 player_draw_mask &= ~1;
1879 }
1880
1881 if (event->player_shadow_draw == 0) {
1882 player_draw_mask &= ~2;
1883 } else {
1884 draw_shadows |= 1;
1885 }
1886
1887 if (npc_draw_masks != NULL) {
1888 for (i = 0; i < npc_count; i++) {
1889 if (event->npc_draw[i] == 0) {
1890 npc_draw_masks[i] = 0;
1891 }
1892
1893 if (event->npc_shadow_draw[i] == 0) {
1894 npc_draw_masks[i] &= ~2;
1895 } else {
1896 draw_shadows |= 1;
1897 }
1898 }
1899 }
1900
1901 // Villagers the event wants in front are drawn before the shadows.
1902 for (i = 0; i < npc_count && npc_draw_masks != NULL; i++) {
1903 CNPCharacter *npc = &npcs[i];
1904
1905 if (npc->CheckDraw() != 0 && event->npc_draw_before[i] != 0 && (npc_draw_masks[i] & 1) != 0) {
1906 if (IsVisible(&npcs[i])) {
1907 npc_draw_masks[i] = 0;
1908 TexManager.ReloadTexture(Vif1Packet, npcs[i].texture_block);
1909 npc->TextureAnime(npcs[i].texture_block);
1910 CCharacter *chara = npc;
1911 chara->Draw();
1912 }
1913 }
1914 }
1915 }
1916
1917 if (draw_shadows != 0) {
1918 sceVu0FMATRIX light_direction;
1919 sceVu0FMATRIX shadow_direction;
1920 sceVu0FMATRIX light_colour;
1921 sceVu0FMATRIX saved_colour;
1922
1923 MGGetPLight(light_direction, light_colour);
1924 sceVu0CopyMatrix(shadow_direction, light_direction);
1925 sceVu0CopyMatrix(saved_colour, light_colour);
1926 EdLimitShadowLight(shadow_direction, 3.0f);
1927 MGSetPLight(shadow_direction, light_colour);
1928 TexManager.ReloadTexture(Vif1Packet, 22);
1929 MGBeginDrawShadow(*(sceGsTex0 *) &TexManager.GetTexture("shadow_buff", -1)->tex0);
1930
1931 if (player_draw_mask & 2) {
1932 player->DrawShadow();
1933 }
1934
1935 for (i = 0; i < npc_count && npc_draw_masks != NULL; i++) {
1936 if (npc_draw_masks[i] & 2) {
1937 if (IsShadowVisible(&npcs[i])) {
1938 CCharacter *chara = &npcs[i];
1939 chara->DrawShadow();
1940 }
1941 }
1942 }
1943
1944 MGEndDrawShadow(0x34);
1945 MGSetPLight(light_direction, light_colour);
1946 }
1947
1948 if (player_draw_mask & 1) {
1949 TexManager.ReloadTexture(Vif1Packet, 8);
1950 player->TextureAnime(8);
1951 player->Draw();
1952 }
1953
1954 for (i = 0; i < npc_count && npc_draw_masks != NULL; i++) {
1955 if (npcs[i].CheckDraw() != 0 && (npc_draw_masks[i] & 1) != 0) {
1956 if (IsVisible(&npcs[i])) {
1957 TexManager.ReloadTexture(Vif1Packet, npcs[i].texture_block);
1958 npcs[i].TextureAnime(npcs[i].texture_block);
1959 CCharacter *chara = &npcs[i];
1960 chara->Draw();
1961 }
1962 }
1963 }
1964}
1965
1966/* Giving a map part one more effect: the description table is scanned from the front for an entry
1967 nothing has claimed, the effect is built on the part's own frame, and the part is told which
1968 entry it now owns. The part's slot table is what the sound and the drawing walk later, so an
1969 effect that is built and not registered here is an effect nothing ever reaches. */
1970void EnterPartsEffect(CMapParts *parts, EPARTS_FUNC_DATA *func_data, EDIT_EFFECT_INFO *effects, int count) {
1971 int i;
1972 int j;
1973
1974 /* The last entry is never handed out, so a full table refuses rather than overruns. */
1975 for (i = 1; i <= count; i++, effects++) {
1976 if (i == count) {
1977 return;
1978 }
1979
1980 if (effects->kind <= EDIT_EFFECT_NONE) {
1981 break;
1982 }
1983 }
1984
1985 if (InitEditEffect(parts->frame[0], func_data, effects) == 0) {
1986 return;
1987 }
1988
1989 for (j = 0; j < 24; j++) {
1990 if (parts->effect_on[j] == 0) {
1991 parts->effect_on[j] = 1;
1992 parts->effect[j] = effects;
1993 return;
1994 }
1995 }
1996}
1997
1998/* The map editor's gate in front of the menus the town runs: one mode word says which menu is up,
1999 and the same four calls — enter, finish entering, step, leave — reach whichever it is. The menus
2000 themselves live elsewhere and are only ever named from here.
2001 Entering takes four frames rather than one and nothing here says what the other three are for:
2002 the counter below is set by the first call and only the fourth reaches a menu. */
2003static int init_menu_cnt;
2004static int menu_mode;
2005static int use_item;
2006static int shop_no;
2007static int name_reg_chara;
2008static int use_item_list[32];
2009
2010/* The item numbering the menus use is not the one the rest of the game passes around: weapons are
2011 renumbered on the way in and back again on the way out, so every item number crossing this gate
2012 goes through one of these two. */
2013static int ConvertItemNo(int item) {
2014 return TransWepNo(item);
2015}
2016
2017static int InvertItemNo(int item) {
2018 return TransWepNoNewToOld(item);
2019}
2020
2021void EdUseItemInit() {
2022 use_item_list[0] = ITEM_ATTACH_PEARL;
2023 use_item_list[1] = -1;
2024 use_item = -1;
2025}
2026
2027void EdSetUseItem(int *items) {
2028 int i;
2029
2030 for (i = 0; i < 32; i++) {
2031 use_item_list[i] = ConvertItemNo(items[i]);
2032
2033 if (use_item_list[i] < 0) {
2034 break;
2035 }
2036 }
2037}
2038
2039int EdGetUseItem() {
2040 return InvertItemNo(use_item);
2041}
2042
2043void EdSetNameRegChara(int character) {
2044 name_reg_chara = character;
2045}
2046
2047void EdSetShopNo(int shop) {
2048 shop_no = shop;
2049}
2050
2051int EdInitMenu(int mode) {
2052 menu_mode = mode;
2053 init_menu_cnt = 0;
2054
2055 if (mode <= 0) {
2056 return 0;
2057 }
2058
2059 MGFlipWaitVSync(1);
2060 EdClearSystemMes();
2061 ClearSystemMes();
2062 SetInteriorOutFlag(0);
2063 return 1;
2064}
2065
2066/* The frame the menu is actually built on: the picture behind it is kept first, because the menus
2067 draw over a still of the last game frame rather than over the game. */
2068int EdInitModeFinish(CCamera *camera, CTexture *texture) {
2069 init_menu_cnt++;
2070
2071 if (init_menu_cnt > 3) {
2072 init_menu_cnt = 4;
2073 }
2074
2075 if (init_menu_cnt < 4) {
2076 return 0;
2077 }
2078
2079 if (texture) {
2080 EdSaveFrameImage(*texture);
2081 }
2082
2083 GamePad.MenuModeOn(120);
2084
2085#ifdef PAL
2086 int texture_block[6] = {16, 17, 18, 25, 32, 33};
2087#else
2088 int texture_block[5] = {16, 17, 18, 25, 32};
2089#endif
2090
2091 switch (menu_mode) {
2092 case ED_MENU_EDIT:
2093 EditMenuInit(texture_block, EditMenuStatus.mode == EDIT_MENU_MODE_PLACE);
2094 return ED_MODE_GEORAMA_MENU;
2095 case ED_MENU_BATTLE:
2096 BattleMenuInit(texture_block, BATTLE_MENU_MODE_TOWN);
2097 break;
2098 case ED_MENU_SHOP:
2099 case ED_MENU_UNK_4:
2100 ShopNoInput(texture_block, shop_no, 1);
2101 break;
2102 case ED_MENU_USE_ITEM:
2103 InitEventItemSelect(16, use_item_list, &SaveData->GetDngStatus()->item_pack, 180, 210, 1, 0);
2104 break;
2105 case ED_MENU_CHANGE_ESA:
2106 InitEventItemSelect(16, use_item_list, &SaveData->GetDngStatus()->item_pack, 180, 210, 1, 1);
2107 break;
2109 InitNameRegist(name_reg_chara, 16, 0);
2110 break;
2111 case ED_MENU_WORLD_MAP:
2112 InitMenuMove(MENU_MOVE_WORLD_MAP_DIRECT, 16, (u_long128 *) read_buffer);
2113 break;
2115 InitFishingExchange(0, texture_block, 0);
2116 break;
2118 InitFishRecordView(0, texture_block, 0);
2119 break;
2120 }
2121
2122 return ED_MODE_MENU;
2123}
2124
2125void EdExitMenu() {
2126 GamePad.AutoRepeatOff();
2127 GamePad.MenuModeOff();
2128 MGFlipWaitVSync(0);
2129}
2130
2131int EdMenuMode() {
2132 int finished;
2133
2134 finished = 0;
2135
2136 switch (menu_mode) {
2137 case ED_MENU_BATTLE:
2138 finished = !BattleMenuCursor();
2139 BattleMenuDraw();
2140
2141 if (finished) {
2142 EdClearItemOverFlag();
2143 }
2144
2145 break;
2146 case ED_MENU_SHOP:
2147 case ED_MENU_UNK_4:
2148 finished = CommonShopLoop();
2149 break;
2150 case ED_MENU_USE_ITEM:
2151 case ED_MENU_CHANGE_ESA:
2152 finished = EventItemSelectLoop(&use_item);
2153 break;
2155 finished = NameEnterKey();
2156 NameEnterDraw();
2157 break;
2158 case ED_MENU_WORLD_MAP:
2159 finished = !MenuMoveKey();
2160 DrawMenuMove();
2161 break;
2163 finished = FishingExchangeLoop();
2164 break;
2166 finished = FishRecordViewLoop();
2167 break;
2168 }
2169
2170 return finished;
2171}
2172
2173/* A count below zero means one, so a caller that has nothing to say about how many gets one. */
2174void EdGetItem(int item, int count, int attachment) {
2175 CDngStatusData *status;
2176 int item_no;
2177 int i;
2178
2179 if (count < 0) {
2180 count = 1;
2181 }
2182
2183 status = SaveData->GetDngStatus();
2184 item_no = ConvertItemNo(item);
2185
2186 if (item_no < 0) {
2187 return;
2188 }
2189
2190 for (i = 0; i < count; i++) {
2191 if (attachment > 0) {
2192 status->GetItem(item_no, attachment);
2193 } else {
2194 status->GetItem(item_no, 0);
2195 }
2196 }
2197}
2198
2199/* Growing the pack clears the slots it opens rather than leaving what was in them, because a slot
2200 is read up to the count and an old number inside the new range would be an item again. */
2201int EdAddMaxItem(int amount) {
2202 ITEM_PACK *pack;
2203 int new_count;
2204 int i;
2205
2206 pack = &SaveData->GetDngStatus()->item_pack;
2207 new_count = pack->num + amount;
2208
2209 if (new_count < 0) {
2210 new_count = 0;
2211 }
2212
2213 if (new_count > 100) {
2214 new_count = 100;
2215 }
2216
2217 for (i = pack->num; i < new_count; i++) {
2218 pack->item[i] = -1;
2219 }
2220
2221 pack->num = (char) new_count;
2222 return new_count;
2223}
2224
2225int EdCheckItemOver() {
2226 return SaveData->GetDngStatus()->overflow_flag;
2227}
2228
2229void EdClearItemOverFlag() {
2230 SaveData->GetDngStatus()->overflow_flag = false;
2231}
2232
2233int EdCheckItem(int item) {
2234 CDngStatusData *status;
2235 int item_no;
2236
2237 status = SaveData->GetDngStatus();
2238 item_no = ConvertItemNo(item);
2239
2240 if (item_no >= 0) {
2241 return status->SearchItemIndexNo(item_no);
2242 }
2243
2244 return -1;
2245}
2246
2247int EdCheckGetItem(int item) {
2248 CDngStatusData *status;
2249 int item_no;
2250
2251 status = SaveData->GetDngStatus();
2252 item_no = ConvertItemNo(item);
2253
2254 if (item_no >= 0) {
2255 return status->CheckItemGet(item_no);
2256 }
2257
2258 return 0;
2259}
2260
2261void EdGetItemFile(int item_no, char *model_path, char *texture_path) {
2262 BtGetItemNamePath(model_path, texture_path, item_no);
2263}
2264
2272void EdDrawItem() {
2273 if (EdEventInfo.item_frame[0] != NULL) {
2274 TexManager.ReloadTexture(GetVif1Packet(), 0x28);
2275 MGDraw((CFrame *) EdEventInfo.item_frame[0]);
2276 }
2277}
2278
2279/* The map editor's own system and help messages, in front of the ones the town runs: every call
2280 here reaches the town's message code first and then does the same thing again to a window of the
2281 editor's own, so both are up at once and the editor's is the one drawn last.
2282 A help message is a system message that has been handed over: it is built through
2283 EdSetSystemMes and its number and count are then moved into the pair below, which leaves the
2284 system slot free for the next real message. */
2285static int SystemMesNo = -1;
2286static int HelpMesNo = -1;
2287static int SystemMesCount;
2288static int SystemMesPosition;
2289static int SystemMesW;
2290static int SystemMesH;
2291static int SystemMesX;
2292static int SystemMesY;
2293static int SystemMesWait;
2294static int SystemMesInputKey;
2295static int HelpMesCount;
2296static int cnt1;
2297static int cnt2;
2298
2299void EdSetSystemMes(int mes_no, int count, int position, int input_key, int *args, int value) {
2300 int i;
2301
2302 SystemMesInputKey = input_key;
2303 SystemMesPosition = position;
2304
2305 if (args) {
2306 for (i = 0; i < 4; i++) {
2307 EditSystemMes.mes_no[i] = -1;
2308
2309 if (*args >= 0) {
2310 EditSystemMes.mes_no[i] = *args;
2311 }
2312
2313 args++;
2314 }
2315 }
2316
2317 if (value >= 0) {
2318 EditSystemMes.value = value;
2319 }
2320
2321 EditSystemMes.MakeMesWin(mes_no);
2322 SystemMesNo = mes_no;
2323 SystemMesCount = count;
2324}
2325
2326/* Message 120 is the only one that offers a choice, and its two positions are placed rather than
2327 authored: the first is indented by however much narrower than the window the laid-out text came
2328 out, and the second a fixed distance to the right of it. Every other message says there is no
2329 choice by putting both off screen. */
2330void EdSetHelpMes(int mes_no, int count, int position, int *args, int value) {
2331 int x;
2332 int y;
2333 int indent;
2334
2335 if (mes_no == 120) {
2336 indent = EditSystemMes.text_columns - 30;
2337 indent = 16 - indent;
2338
2339 if (indent < 0) {
2340 indent = 0;
2341 }
2342
2343 y = SystemMesY;
2344 x = SystemMesX + ((indent * EditSystemMes.char_width) >> 1);
2345 EditSystemMes.line_pos[0].x = x;
2346 EditSystemMes.line_pos[0].y = y;
2347#ifdef PAL
2348 x = SystemMesX + 220;
2349#else
2350 x = SystemMesX + 180;
2351#endif
2352 EditSystemMes.line_pos[1].x = x;
2353 EditSystemMes.line_pos[1].y = y;
2354 } else {
2355 EditSystemMes.line_pos[0].x = -1;
2356 EditSystemMes.line_pos[0].y = -1;
2357 EditSystemMes.line_pos[1].x = -1;
2358 EditSystemMes.line_pos[1].y = -1;
2359 }
2360
2361 EditSystemMes.auto_pos = SystemMesPosition;
2362 EditSystemMes.text_x = SystemMesX;
2363 EditSystemMes.text_y = SystemMesY;
2364 EditSystemMes.stay_width = SystemMesW;
2365 EditSystemMes.stay_height = SystemMesH;
2366 EditSystemMes.auto_pos = SystemMesPosition;
2367 EdSetSystemMes(mes_no, count, position, 0, args, value);
2368 EditSystemMes.auto_pos = SystemMesPosition;
2369 HelpMesNo = SystemMesNo;
2370 HelpMesCount = SystemMesCount;
2371 SystemMesNo = -1;
2372 SystemMesCount = 0;
2373}
2374
2375void EdClearSystemMes() {
2376 ClearSystemMes();
2377 EditSystemMes.MakeMesWin(-1);
2378 SystemMesNo = -1;
2379 SystemMesCount = 0;
2380 SystemMesInputKey = 0;
2381 HelpMesNo = -1;
2382 HelpMesCount = 0;
2383 SystemMesWait = 0;
2384 SystemMesW = 0;
2385 SystemMesH = 0;
2386 SystemMesX = 0;
2387 SystemMesY = 0;
2388}
2389
2390int EdSystemMesCheck() {
2391 return SystemMesCheck();
2392}
2393
2394/* A message counts down to nothing and is cleared at one rather than at zero, so the frame that
2395 would have shown it empty is the frame it goes away on. A message that asked for a button holds
2396 at two until the button is pressed. */
2397void EdSystemMesStep() {
2398 if (SystemMesWait > 0) {
2399 SystemMesWait--;
2400 return;
2401 }
2402
2403 SystemMesStep();
2404
2405 if (SystemMesCount == 1 || HelpMesCount == 1) {
2406 EdClearSystemMes();
2407 }
2408
2409 if (SystemMesNo > 0 || HelpMesCount >= 0) {
2410 EditSystemMes.Step();
2411 }
2412
2413 if (SystemMesInputKey == 0 || SystemMesCount != 2 || GamePad.Down(PAD_CROSS)) {
2414 if (SystemMesCount > 0) {
2415 SystemMesCount--;
2416 }
2417
2418 if (HelpMesCount > 0) {
2419 HelpMesCount--;
2420 }
2421 }
2422}
2423
2424/* The window's own textures are put back every frame it is drawn, because whatever the game drew
2425 in between is free to have taken the video memory they were in. */
2426void EdSystemMesDraw() {
2427 if (SystemMesWait > 0) {
2428 return;
2429 }
2430
2431 SystemMesDraw();
2432
2433 if (HelpMesNo <= 0) {
2434 return;
2435 }
2436
2437 TexManager.ReloadTexture(Vif1Packet, EditSystemMes.tex_block);
2438 setbilinear(0);
2439 EditSystemMes.DrawMesWin();
2440}
2441
2442/* The width the window will come to is not known before the text is laid out, so the messages
2443 below place it by hand: this one centres a forty-character line on the screen and the rest give
2444 a left edge outright. */
2445void EdEditMainHelpMes(int building) {
2446 SystemMesW = 0;
2447 SystemMesH = 0;
2448 SystemMesX = 320 - ((EditSystemMes.char_width * 40) >> 1);
2449 SystemMesY = 380;
2450 EdSetHelpMes(100 + (building != 0), 2, -1, 0, -1);
2451}
2452
2453void EdWalkToEditMes(int wait) {
2454 SystemMesW = 0;
2455 SystemMesH = 0;
2456 SystemMesX = 40;
2457 SystemMesY = 380;
2458 SystemMesWait = wait;
2459 EdSetHelpMes(110, 120, -1, 0, -1);
2460}
2461
2462/* The build and move prompts take turns: each counts down the other's delay before showing itself
2463 and then arms the other, so the two alternate rather than both being up. */
2464void EdEditBuildHelpMes(int part_no) {
2465 if (part_no < 0) {
2466 return;
2467 }
2468
2469 if (cnt1 > 0) {
2470 cnt1--;
2471 return;
2472 }
2473
2474 cnt1 = 0;
2475 cnt2 = 1;
2476
2477 int args[4] = {-1, -1, -1, -1};
2478
2479 args[0] = GetAtraMsgNo(MapNo, part_no);
2480#ifdef PAL
2481 SystemMesW = 600;
2482#else
2483 SystemMesW = 560;
2484#endif
2485 SystemMesH = 50;
2486#ifdef PAL
2487 SystemMesX = 30;
2488#else
2489 SystemMesX = 40;
2490#endif
2491 SystemMesY = 380;
2492 EdSetHelpMes(120, 2, -1, args, -1);
2493}
2494
2495void EdEditMoveHelpMes() {
2496 if (cnt2 > 0) {
2497 cnt2--;
2498 return;
2499 }
2500
2501 cnt2 = 0;
2502 cnt1 = 1;
2503 SystemMesW = 0;
2504 SystemMesH = 0;
2505 SystemMesX = 230;
2506#ifdef PAL
2507 SystemMesY = 412;
2508#else
2509 SystemMesY = 380;
2510#endif
2511 EdSetHelpMes(130, 2, -1, 0, -1);
2512}
2513
2514/* Two messages a hundred apart for the same two states, since the argument names the fish and the
2515 message number says whether there is one. */
2516void EdFishingWalkHelpMes(int bait) {
2517 int mes_no;
2518
2519 SystemMesW = 0;
2520 SystemMesH = 0;
2521
2522 int args[4] = {-1, -1, -1, -1};
2523
2524 args[0] = bait + 100;
2525 mes_no = 200;
2526
2527 if (bait >= 0) {
2528 mes_no++;
2529 }
2530
2531 EdSetHelpMes(mes_no, 2, 9, args, -1);
2532}
2533
2534void EdFishingAngleHelpMEs(int bait) {
2535}
2536
2537void EdFishingLostEsaMes() {
2538 SystemMesW = 0;
2539 SystemMesH = 0;
2540 EdSetHelpMes(210, 180, 8, 0, -1);
2541}
2542
2543/* The second argument is dropped rather than forwarded, so a caller that passes one is passing it
2544 to nothing. */
2545void EdItemGetMes(int item, int kind, int attachment, int duration) {
2546 ItemGetMes(item, attachment, duration, 1);
2547}
2548
2549/* The treasure box the map editor opens in front of the player: one box at a time, placed where the
2550 caller says, with its lid turned by a count that runs down from 40 and the ambient light lifted
2551 over the last twenty of them. The lid is a node of the box's own model called `top`, so the
2552 opening is a rotation of one frame rather than anything the model file carries. */
2553static int ibox_open_flag;
2554static int ibox_open_close_flag;
2555static int ibox_open_cnt;
2556static CFrameVu1 *ibox_frame;
2557static CFrameVu1 *ibox_base_frame;
2558static sceVu0FVECTOR ibox_pos;
2559static sceVu0FVECTOR ibox_rot;
2560
2561void EdInitOpenItemBox(CFrameVu1 *frame, CFrameVu1 *base) {
2562 ibox_open_close_flag = 0;
2563 ibox_open_flag = 0;
2564 ibox_open_cnt = 0;
2565 ibox_frame = frame;
2566 ibox_base_frame = base;
2567}
2568
2569void EdSetOpenItemBox(float *position, float *rotation) {
2570 if (ibox_frame) {
2571 ibox_open_flag = 1;
2572 ibox_open_close_flag = 0;
2573 ibox_open_cnt = 40;
2574 sceVu0CopyVector(ibox_pos, position);
2575 sceVu0CopyVector(ibox_rot, rotation);
2576 }
2577}
2578
2579void EdStepOpenItemBox() {
2580 CFrame *lid;
2581 float open_angle;
2582 float close_angle;
2583
2584 if (ibox_open_flag == 0 && ibox_open_close_flag == 0) {
2585 return;
2586 }
2587
2588 ibox_open_cnt--;
2589
2590 if (ibox_open_cnt < 0) {
2591 ibox_open_flag = 0;
2592 ibox_open_close_flag = 0;
2593 return;
2594 }
2595
2596 if (ibox_frame == 0) {
2597 return;
2598 }
2599
2600 ibox_frame->SetPosition(ibox_pos);
2601 ibox_frame->SetRotation(ibox_rot[0], ibox_rot[1], ibox_rot[2]);
2602 lid = ibox_frame->SearchFrame("top");
2603 lid->SetRotType(2);
2604
2605 if (ibox_open_flag) {
2606 /* The lid swings over the first half of the count and then stands open through the second,
2607 which is the half the ambient is faded over. */
2608 if (ibox_open_cnt <= 20) {
2609 return;
2610 }
2611
2612 open_angle = -(HALF_PI - HALF_PI * (float) (ibox_open_cnt - 20) / 20.0f);
2613 lid->SetRotation(open_angle, 0.0f, 0.0f);
2614 } else {
2615 if (ibox_open_cnt >= 6) {
2616 close_angle = HALF_PI - HALF_PI * (float) (ibox_open_cnt - 5) / 5.0f;
2617 } else {
2618 close_angle = HALF_PI * (float) ibox_open_cnt / 5.0f;
2619 }
2620
2621 lid->SetRotation(0.2f * -close_angle, 0.0f, 0.0f);
2622 }
2623}
2624
2625// The villager file names and script command names editmapscript's tables point at.
2626const char EditCharaFileP47a[] = "p47a";
2627const char EditCharaFileP12a[] = "p12a";
2628const char EditCharaFileP07a[] = "p07a";
2629const char EditCharaFileP01a[] = "p01a";
2630const char EditCharaFileP13a[] = "p13a";
2631const char EditCharaFileP06a[] = "p06a";
2632const char EditCharaFileP09a[] = "p09a";
2633const char EditCharaFileP08a[] = "p08a";
2634const char EditCharaFileP05a[] = "p05a";
2635const char EditCharaFileP03a[] = "p03a";
2636const char EditCharaFileP04a[] = "p04a";
2637const char EditCharaFileP02a[] = "p02a";
2638const char EditCharaFileP10a[] = "p10a";
2639const char EditCharaFileP14a[] = "p14a";
2640const char EditCharaFileC04cat[] = "c04cat";
2641const char EditCharaFileNone[] = "";
2642const char EditCharaFileP27a[] = "p27a";
2643const char EditCharaFileP30a[] = "p30a";
2644const char EditCharaFileP29a[] = "p29a";
2645const char EditCharaFileP28a[] = "p28a";
2646const char EditCharaFileP31a[] = "p31a";
2647const char EditCharaFileP25a[] = "p25a";
2648const char EditCharaFileP59a[] = "p59a";
2649const char EditCharaFileP24a[] = "p24a";
2650const char EditCharaFileP26a[] = "p26a";
2651const char EditCharaFileP23a[] = "p23a";
2652const char EditCharaFileP21a[] = "p21a";
2653const char EditCharaFileP22a[] = "p22a";
2654const char EditCharaFileP49a[] = "p49a";
2655const char EditCharaFileP35a[] = "p35a";
2656const char EditCharaFileP37a[] = "p37a";
2657const char EditCharaFileP36a[] = "p36a";
2658const char EditCharaFileP41a[] = "p41a";
2659const char EditCharaFileP39a[] = "p39a";
2660const char EditCharaFileP33a[] = "p33a";
2661const char EditCharaFileP40a[] = "p40a";
2662const char EditCharaFileP43a[] = "p43a";
2663const char EditCharaFileP45a[] = "p45a";
2664const char EditCharaFileP44a[] = "p44a";
2665const char EditCharaFileP34a[] = "p34a";
2666const char EditCharaFileP42a[] = "p42a";
2667const char EditCharaFileP48a[] = "p48a";
2668const char EditCharaFileP46a[] = "p46a";
2669const char EditCharaFileP50a[] = "p50a";
2670const char EditCharaFileP51a[] = "p51a";
2671const char EditCharaFileP52a[] = "p52a";
2672const char EditCharaFileP53a[] = "p53a";
2673const char EditCharaFileP54a[] = "p54a";
2674const char EditCharaFileP55a[] = "p55a";
2675const char EditCharaFileP56a[] = "p56a";
2676const char EditCharaFileP57a[] = "p57a";
2677const char EditCharaFileP58a[] = "p58a";
2678const char EditCharaFileP64a[] = "p64a";
2679const char EditCharaFileP62a[] = "p62a";
2680const char EditCharaFileP63a[] = "p63a";
2681const char EditCharaFileP61a[] = "p61a";
2682const char EditCommandScn[] = "SCN";
2683const char EditCommandLightNo[] = "LIGHT_NO";
2684const char EditCommandAmbient[] = "AMBIENT";
2685const char EditCommandLightC[] = "LIGHT_C";
2686const char EditCommandFog[] = "FOG";
2687const char EditCommandBgCol[] = "BG_COL";
2688const char EditCommandBgCol2[] = "BG_COL2";
2689const char EditCommandDof[] = "DOF";
2690const char EditCommandCd[] = "CD";
2691const char EditCommandGrdImg[] = "GRD_IMG";
2692const char EditCommandBldImg[] = "BLD_IMG";
2693const char EditCommandSkyImg[] = "SKY_IMG";
2694const char EditCommandSunImg[] = "SUN_IMG";
2695const char EditCommandWaterImg[] = "WATER_IMG";
2696const char EditCommandFireImg[] = "FIRE_IMG";
2697const char EditCommandFlerImg[] = "FLER_IMG";
2698const char EditCommandImg[] = "IMG";
2699const char EditCommandSky[] = "SKY";
2700const char EditCommandSun[] = "SUN";
2701const char EditCommandGround[] = "GROUND";
2702const char EditCommandBuild[] = "BUILD";
2703const char EditCommandWater[] = "WATER";
2704const char EditCommandWaterSurface[] = "WATER_SURFACE";
2705const char EditCommandWaterShake[] = "WATER_SHAKE";
2706const char EditCommandEditarea[] = "EDITAREA";
2707const char EditCommandBldParts[] = "BLD_PARTS";
2708const char EditCommandGrdParts[] = "GRD_PARTS";
2709const char EditCommandPartsInfo[] = "PARTS_INFO";
2710const char EditCommandRoadParts[] = "ROAD_PARTS";
2711const char EditCommandRoad[] = "ROAD";
2712const char EditCommandRiverParts[] = "RIVER_PARTS";
2713const char EditCommandRiver[] = "RIVER";
2714const char EditCommandBridgeParts[] = "BRIDGE_PARTS";
2715const char EditCommandLakeParts[] = "LAKE_PARTS";
2716const char EditCommandOnRiverParts[] = "ON_RIVER_PARTS";
2717const char EditCommandObjAnime[] = "OBJ_ANIME";
2718const char EditCommandFire[] = "FIRE";
2719const char EditCommandFlame[] = "FLAME";
2720const char EditCommandBright[] = "BRIGHT";
2721const char EditCommandObjectTimer[] = "OBJECT_TIMER";
2722const char EditCommandEntrance[] = "ENTRANCE";
2723const char EditCommandMapjump[] = "MAPJUMP";
2724const char EditCommandPeople[] = "PEOPLE";
2725const char EditCommandTimeTableNo[] = "TIME_TABLE_NO";
2726const char EditCommandTimeTable[] = "TIME_TABLE";
2727const char EditCommandTimeStop[] = "TIME_STOP";
2728const char EditCommandSkyFollow[] = "SKY_FOLLOW";
2729const char EditCommandShadowLevel[] = "SHADOW_LEVEL";
2730const char EditCommandEditareaRect[] = "EDITAREA_RECT";
2731const char EditCommandBgmNo[] = "BGM_NO";
2732const char EditCommandSoundSet[] = "SOUND_SET";
2733const char EditCommandReverbe[] = "REVERBE";
2734const char EditCommandMotionParts[] = "MOTION_PARTS";
2735const char EditCommandPeople2[] = "PEOPLE2";
2736const char EditCommandSeAmbientOff[] = "SE_AMBIENT_OFF";
2737const char EditCommandWind[] = "WIND";
2738const char EditCommandTalkEvent[] = "TALK_EVENT";
2739const char EditCommandCharaAmbient[] = "CHARA_AMBIENT";
2740const char EditCommandTalkRot[] = "TALK_ROT";
2741const char EditCommandTalkDir[] = "TALK_DIR";
2742const char EditCommandPeopleList[] = "PEOPLE_LIST";
2743const char EditFuncNameTest[] = "test";
2744
2745void EdDrawOpenItemBox() {
2746 sceVu0FVECTOR ambient;
2747 sceVu0FVECTOR saved_ambient;
2748
2749 if (ibox_open_flag == 0 && ibox_open_close_flag == 0) {
2750 return;
2751 }
2752
2753 if (ibox_frame) {
2754 ibox_frame->SetPosition(ibox_pos);
2755 ibox_frame->SetRotation(ibox_rot[0], ibox_rot[1], ibox_rot[2]);
2756 }
2757
2758 MGGetAmbient(ambient);
2759 sceVu0CopyVector(saved_ambient, ambient);
2760
2761 if (ibox_open_cnt < 20) {
2762 ambient[3] = 128.0f * (float) ibox_open_cnt / 20.0f;
2763 }
2764
2765 if (ibox_open_flag) {
2766 MGSetAmbient(ambient);
2767 }
2768
2769 MGDraw(ibox_frame);
2770 MGSetAmbient(saved_ambient);
2771}
2772
2773int frame_image_flag;
2774CTexture frame_image_tex;
2775
2783void EdSaveFrameImage(CTexture texture) {
2784 frame_image_flag = 1;
2785 frame_image_tex = texture;
2786}
2787
2788void EdSaveFrameImageTask() {
2789 if (frame_image_flag != 0) {
2790 MGMoveFrameBuffImage((sceGsTex0 *) &frame_image_tex.tex0, 0, 0, 0);
2791 frame_image_tex.Initialize();
2792 frame_image_flag = 0;
2793 }
2794}
2795
2796void EdSaveFrameImageInit() {
2797 frame_image_tex.Initialize();
2798 frame_image_flag = 0;
2799}
2800
2801int EdMenuLoop(ClsMes *message) {
2802 if (message == NULL) {
2803 return 1;
2804 }
2805
2806 message->Step();
2807
2808 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
2809 // A confirm on the last page closes the window and leaves it ready
2810 // for the next one.
2811 if (message->State() == CLSMES_SHOWN) {
2812 message->text_rate = message->text_rate_set;
2813 message->mes_made = -1;
2814 message->fade_in = false;
2815 message->text_columns = MES_WIN_COLUMNS;
2816 message->text_rows = 0xA;
2817 message->text_len = 0;
2818 message->text_width = 0;
2819 message->text_height = 0;
2820 message->fade = 0.0f;
2821 message->fade_in = true;
2822 message->text_rate = message->text_rate_set;
2823 message->waiting = false;
2824 message->text_at = 0.0f;
2825 message->text_no = 0;
2826 message->text_from = 0;
2827 message->page_from = 0;
2828 message->InitMesWinTbl();
2829 message->clut_now = message->clut_default;
2830 message->wait = 0;
2831 message->blink = 0;
2832 message->auto_page_wait = 0;
2833 message->mes_made = -1;
2834 message->edge_alpha = 0x80;
2835
2836 for (int i = 0; i < 10; i++) {
2837 message->mes_no[i] = -1;
2838 }
2839
2840 for (int i = 0; i < 8; i++) {
2841 message->values[i] = 0;
2842 }
2843
2844 message->value = 0;
2845 message->value_signed = false;
2846 message->value_show = true;
2847 message->value_narrow = false;
2848 message->space_width = -1;
2849 message->space_area = -1;
2850 message->cursor_row = -1;
2851 message->cursor_y = 0;
2852 message->cursor_lit = false;
2853
2854 for (int i = 0; i < 10; i++) {
2855 message->line_pos[i].x = -1;
2856 message->line_pos[i].y = -1;
2857 }
2858
2859 return 1;
2860 }
2861
2862 if (message->State() == CLSMES_PAGE_WAIT) {
2863 message->GoNextPage();
2864 } else {
2865 message->text_rate = 0.0f;
2866 }
2867 }
2868
2869 return 0;
2870}
2871
2872float ConvertTime(float hour) {
2873 hour -= 10.0f;
2874
2875 if (hour < 0.0f) {
2876 hour += 24.0f;
2877 }
2878
2879 hour /= 2.0f;
2880 return hour;
2881}
2882
2883float InvertTime(float time) {
2884 time *= 2.0f;
2885 time += 10.0f;
2886
2887 if (time > 24.0f) {
2888 time -= 24.0f;
2889 }
2890
2891 return time;
2892}
s16 foot_sound
Definition collision.hpp:56
s16 area_kind
Definition collision.hpp:57
s16 ground_kind
Definition collision.hpp:55
void GetRef(float *ref)
Definition camera.cpp:234
void SetRef(CFrame *parent, float x, float y, float z)
Definition camera.cpp:124
void GetPos(float *pos)
Definition camera.cpp:230
virtual void GetPosition(float *out_position)
sceVu0FVECTOR ambient_offset
virtual void SetRotation(float x, float y, float z)
void TextureAnime(int step)
virtual void DrawShadow()
float body_height
virtual void Draw()
virtual void SetPosition(float x, float y, float z)
void Draw()
Definition dispctrl.cpp:60
char text[0x200]
Definition gameloop.cpp:167
int GetItem(int item_id, int qty)
int SearchItemIndexNo(int item_id)
int CheckItemGet(int item_id)
CMapParts fixed_parts[64]
int GetCompEvent(int index)
void SetCompEvent(int index, int completed)
short draw_on
Definition frame.hpp:27
sceVu0FVECTOR corner[8]
Definition frame.hpp:64
CFrameAttr attr
Definition frame.hpp:65
int On(int mask)
Definition gamepad.cpp:557
float GetRYf()
Definition gamepad.cpp:537
int Down(int mask)
Definition gamepad.cpp:583
void MenuModeOff()
Definition gamepad.cpp:617
float GetLXf()
Definition gamepad.cpp:541
void MenuModeOn(int threshold)
Definition gamepad.cpp:613
float GetLYf()
Definition gamepad.cpp:545
void AutoRepeatOff()
Definition gamepad.cpp:609
MoveCheckInfo move_info
void GetPosition(float *out_position)
Definition mapparts.cpp:16
EDIT_EFFECT_INFO * effect[MAP_PARTS_EFFECT_MAX]
Definition mapparts.hpp:73
s32 effect_on[MAP_PARTS_EFFECT_MAX]
Definition mapparts.hpp:72
CFrameVu1 * frame[4]
Definition op_b.cpp:76
virtual void GetRotation(float *out_rotation)
Definition object.cpp:116
SV_GRD_NPC * GetGrdNPCData(int map_no, int npc_no)
Definition savedata.cpp:215
CDngStatusData * GetDngStatus()
Definition savedata.cpp:250
int QuestDungeon(int dungeon_no, int add)
Definition savedata.cpp:535
int GetGameFlag(int flag_no)
Definition savedata.cpp:258
int SetMapFlag(int map_no, int flag_no, int value)
Definition savedata.cpp:356
int SetGameFlag(int flag_no, int value)
Definition savedata.cpp:279
int GetGameIntFlag(int flag_no)
Definition savedata.cpp:310
SV_GEORAMA_DATA * GetGrdData(int georama_no)
Definition savedata.cpp:175
int GetMapFlag(int map_no, int flag_no)
Definition savedata.cpp:327
int SetGameIntFlag(int flag_no, int value)
Definition savedata.cpp:318
u_long tex0
Definition texture.hpp:57
ITEM_PACK item_pack
s8 floor_reached[7]
s32 text_rows
Definition clsmes.hpp:158
s32 auto_pos
Definition clsmes.hpp:172
s32 text_y
Definition clsmes.hpp:152
s32 text_from
Definition clsmes.hpp:198
s32 cursor_y
Definition clsmes.hpp:225
s32 text_x
Definition clsmes.hpp:151
float text_rate_set
Definition clsmes.hpp:193
void DrawMesWin()
Definition clsmes.cpp:2619
s32 wait
Definition clsmes.hpp:204
s32 text_no
Definition clsmes.hpp:197
void Step()
Definition clsmes.cpp:575
s32 mes_no[10]
Definition clsmes.hpp:216
s32 page_from
Definition clsmes.hpp:199
s32 text_height
Definition clsmes.hpp:161
s32 text_width
Definition clsmes.hpp:160
s32 char_width
Definition clsmes.hpp:153
s32 text_columns
Definition clsmes.hpp:157
s32 text_len
Definition clsmes.hpp:159
s32 value
Definition clsmes.hpp:218
void InitMesWinTbl()
Definition clsmes.cpp:1265
s32 waiting
Definition clsmes.hpp:194
s32 cursor_lit
Definition clsmes.hpp:226
s32 auto_page_wait
Definition clsmes.hpp:206
s32 fade_in
Definition clsmes.hpp:188
void GoNextPage()
Definition clsmes.cpp:663
s32 space_width
Definition clsmes.hpp:222
s32 clut_now
Definition clsmes.hpp:203
s32 blink
Definition clsmes.hpp:205
s32 cursor_row
Definition clsmes.hpp:224
s32 stay_width
Definition clsmes.hpp:190
float fade
Definition clsmes.hpp:187
s32 mes_made
Definition clsmes.hpp:207
s32 values[8]
Definition clsmes.hpp:217
s32 value_narrow
Definition clsmes.hpp:221
s32 tex_block
Definition clsmes.hpp:227
s32 value_signed
Definition clsmes.hpp:219
float text_rate
Definition clsmes.hpp:192
s32 edge_alpha
Definition clsmes.hpp:213
s32 clut_default
Definition clsmes.hpp:202
MES_LINE_POS line_pos[10]
Definition clsmes.hpp:228
int MakeMesWin(int mes_no)
Definition clsmes.cpp:1669
s32 stay_height
Definition clsmes.hpp:191
s32 value_show
Definition clsmes.hpp:220
int State()
Definition clsmes.cpp:637
s32 space_area
Definition clsmes.hpp:223
float text_at
Definition clsmes.hpp:196
@ ED_MENU_UNK_4
Definition edit.hpp:36
@ ED_MENU_EDIT
Definition edit.hpp:33
@ ED_MENU_BATTLE
Definition edit.hpp:34
@ ED_MENU_CHANGE_ESA
Definition edit.hpp:41
@ ED_MENU_FISHING_EXCHANGE
Definition edit.hpp:40
@ ED_MENU_USE_ITEM
Definition edit.hpp:37
@ ED_MENU_NAME_REGISTRY
Definition edit.hpp:38
@ ED_MENU_SHOP
Definition edit.hpp:35
@ ED_MENU_FISH_RANKING
Definition edit.hpp:42
@ ED_MENU_WORLD_MAP
Definition edit.hpp:39
@ MAP_PARTS_SUBTYPE_RIVER
Definition mapparts.hpp:20
float distance[2]
Definition edit.hpp:299
sceVu0FVECTOR offset
Definition objanime.hpp:171
sceVu0FVECTOR colour
Definition objanime.hpp:173
s32 player_draw
Definition edit.hpp:164
s32 npc_draw[16]
Definition edit.hpp:170
s32 npc_shadow_draw[16]
Definition edit.hpp:171
s32 player_shadow_draw
Definition edit.hpp:165
CFrameVu1 * item_frame[1]
Definition edit.hpp:189
s32 npc_draw_before[16]
Definition edit.hpp:174
s16 item[103]
CCPoly ground_poly
Definition gameutil.hpp:471
float pan[16]
Definition edit.cpp:63
float volume[16]
Definition edit.cpp:62
int num
Definition edit.cpp:61
int se
Definition edit.cpp:60
s32 talk_message
Definition savedata.hpp:89