DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
edit_in.cpp
1#include "common.h"
2
3#include <libvu0.h>
4
5#include <cmath>
6#include <cstdio>
7#include <cstdlib>
8#include <cstring>
9
10#include "battlemenu.hpp"
11#include "boxvu0.hpp"
12#include "camera.hpp"
13#include "camerafollow.hpp"
14#include "character.hpp"
15#include "clsmes.hpp"
16#include "collision.hpp"
17#include "dataalloc.hpp"
18#include "dataread.hpp"
19#include "dataset.hpp"
20#include "dispctrl.hpp"
21#include "ebattle.hpp"
22#include "edit.hpp"
23#include "edit_in.hpp"
24#include "editground.hpp"
25#include "editloop.hpp"
26#include "editloop3.hpp"
27#include "editpartsinfo.hpp"
28#include "effectgroup.hpp"
29#include "effectmacro.hpp"
30#include "fireomni.hpp"
31#include "frame.hpp"
32#include "framevu1.hpp"
33#include "gamemode.hpp"
34#include "gamepad.hpp"
35#include "mainselect.hpp"
36#include "mapparts.hpp"
37#include "mathutil.hpp"
38#include "mds.hpp"
39#include "menu_misc.hpp"
40#include "mglib.hpp"
41#include "npcharacter.hpp"
42#include "objanime.hpp"
43#include "rect.hpp"
44#include "savedata.hpp"
45#include "scriptinterpreter.hpp"
46#include "snd.hpp"
47#include "sysmes.hpp"
48#include "texture.hpp"
49#include "water.hpp"
50
54// clang-format off
55enum EdInMode {
56 ED_IN_MODE_WALK = 0,
57 ED_IN_MODE_DOOR_OPEN = 1,
58 ED_IN_MODE_LEAVE = 2,
59 ED_IN_MODE_TALK = 3,
60 ED_IN_MODE_EVENT = 4,
61 ED_IN_MODE_PAUSE = 5,
62 ED_IN_MODE_MENU_INIT = 6,
63 ED_IN_MODE_MENU = 7,
64};
65
66// clang-format on
67
68/* Where the camera sits for one camera marker of the interior, and the box the player must stand in. */
70 u8 unk_000[0x60];
72 sceVu0FVECTOR max;
73 sceVu0FVECTOR min;
74 int link_id;
75 u8 unk_2e4[0xC];
76};
77
78static void LoadInfo(char *script, int size);
79static void setTexAnim();
80static void StepWater();
81static void MainDraw();
82static void MoveCharacter();
83static void MoveCamera(CCameraFollow *camera);
84static int GetDoorPos(int door_no, float *position, float *rotation, int *door_sound, int *motion);
85static void VillagerCollision();
86static int LoadTexture();
87static void LoadChara();
88void LoadData();
89
90int LoadPTS(CMapParts *parts, u_int *archive);
91
96 u_int words[sizeof(EPARTS_FUNC_DATA) / sizeof(u_int)];
97};
98
99int GetFuncPoint(int parts_no, u_int *archive, EPARTS_FUNC_DATA *points);
100void DrawWaterSurface(CCamera *camera);
101void SetCameraPos(CFrame *frame, CCamera *camera, CCharacter *chara);
102
103/* Word-aligned image of one function marker as stored in a part resource. */
105 int words[0x30];
106};
107
109static int fix_camera = 1;
110
112static int camera_dist_mode = 1;
113
115EDIT_IN_INFO *EdInInfo;
116
118static int GameMode;
119
121static INTERIOR_CAMERA *active_camera;
122
124static int camera_change_count;
125
127static int camera_num;
128
130static int door_open_cnt;
131
133static CCamera *NowCamera;
134
136static CCharacter *Chara;
137
139static float NowTime;
140
142static int obj_anime_num;
143
145static int effect_num;
146
148static int parts_num;
149
151static EPARTS_FUNC_DATA *func_point;
152
154static int func_num;
155
157static int start_event_no;
158
160static int start_system_event;
161
163static int goto_menu;
164
166static int goto_return_menu;
167
169static int key_counter;
170
172static int loop_counter;
173
175static CTextureAnime TexAnime;
176
178static CTexAnimeData TexAnimeData[64];
179
181static CFireOmni Fire;
182
184static sceVu0FVECTOR fix_chara_pos;
185
187static sceVu0FVECTOR fix_chara_rot;
188
190static CMapParts InteriorParts[10];
191
193static CCharacter MotionParts__2[4];
194
196static CGroundWater Water[1];
197
199static CCameraFollow MainCamera(60.0f, 20.0f, 0.0f, 4.0f);
200
202static CCameraFollow TalkCamera(60.0f, 20.0f, 0.0f, 4.0f);
203
205static CCameraFollow EventCamera(60.0f, 20.0f, 0.0f, 4.0f);
206
208static CCamera ViewCamera__2(4.0f);
209
211static CCamera ExitCamera(4.0f);
212
216// clang-format off
217enum EFFECT_TYPE {
218 EFFECT_FIRE = 1,
219 EFFECT_FLAME,
220 EFFECT_BRIGHT,
221};
222
223// clang-format on
224
228void GetElementObjName(EDITPARTS_INFO *info, char **names, int element, int mode) {
229 names[0][0] = '\0';
230
231 if (info == NULL) {
232 return;
233 }
234
235 if (element < 0 || element >= 6) {
236 return;
237 }
238
239 if (mode < 0 || mode >= 4) {
240 return;
241 }
242
243 char *text = info->elements[element].names[mode];
244
245 if (text == NULL) {
246 return;
247 }
248
249 int word = 0;
250 int length = 0;
251 char c;
252
253 while ((c = *text) != '\0') {
254 if (c == ' ') {
255 names[word][length] = '\0';
256 length = 0;
257 word++;
258 } else {
259 names[word][length] = c;
260 length++;
261 }
262
263 text++;
264 }
265
266 names[word][length] = '\0';
267 word++;
268 names[word][0] = '\0';
269}
270
278void LoadMapObject(CMapParts *parts, u_int **data, CDataAlloc2<1> *alloc) {
279 CFrameVu1 *frames[4];
280 int i;
281
282 LoadMDSFileLOD(frames, data, alloc, 1);
283 CFrameAttr attr;
284 attr.fog_enable = true;
285 attr.clip_enable = false;
286 attr.alpha_ref = 0x40;
287
288 for (i = 1; i < 4; i++) {
289 if (frames[i] != NULL) {
290 frames[i]->SetAttr(attr, 1, 0x44);
291 SetFrameAttr(frames[i], 1);
292 }
293 }
294
295 attr.clip_depth = 100.0f;
296 attr.clip_enable = true;
297 frames[0]->SetAttr(attr, 1, 0);
298 SetFrameAttr(frames[0], 1);
299
300 for (i = 0; i < 4; i++) {
301 parts->SetFrame(frames[i], i);
302 }
303
304 if (data[4] != NULL) {
305 parts->shadow_frame = LoadMDSFile(data[4], alloc, 14, NULL, NULL);
306 }
307
308 if (data[5] != NULL) {
309 parts->collision_frame = LoadCollisionFile(data[5], alloc);
310 } else {
311 parts->collision_frame = NULL;
312 }
313
314 if (data[6] != NULL) {
315 parts->shade_frame = LoadMDSFile(data[6], alloc, 0, NULL, NULL);
316 }
317
318 if (data[7] != NULL) {
319 parts->ripple_frame = LoadMDSFile(data[7], alloc, 0, NULL, NULL);
320 }
321
322 if (data[8] != NULL) {
323 parts->camera_frame = LoadCollisionFile(data[8], alloc);
324 }
325}
326
335static void LoadScript() {
336 char event_path[0x80];
337 char directory[0x40];
338 char message_path[0x40];
339 char language[0x1c];
340 int size;
341 char *message_data;
342
343 EdScriptBuffer.used = 0;
344 EdEventData = (char *) (EdScriptBuffer.base + EdScriptBuffer.used * 16);
345 sprintf(language, "_%d.mes", LanguageCode);
346 strcpy(message_path, EdInInfo->name);
347 int length = strlen(message_path);
348
349 if (length > 0) {
350 char last = message_path[length - 1];
351
352 if (last == 'm' || last == 'n' || last == 'e') {
353 message_path[length - 1] = '\0';
354 }
355 }
356
357 strcat(message_path, language);
358 printf("mes = %s\n", message_path);
359 strcpy(directory, EdInInfo->name);
360 char *cursor = directory;
361 char *slash = cursor;
362 char c;
363
364 while ((c = *cursor) != '\0') {
365 if (c == '/') {
366 slash = cursor;
367 }
368
369 cursor++;
370 }
371
372 *slash = '\0';
373 sprintf(event_path, "%s/event.stb", directory);
374
375 if (LoadFile2(event_path, EdEventData, &size, 0) != 0) {
376 EdScriptBuffer.Alloc((size >> 4) + 1);
377 message_data = (char *) (EdScriptBuffer.base + EdScriptBuffer.used * 16);
378
379 if (LoadFile2(message_path, message_data, &size, 0) != 0) {
380 EdScriptBuffer.Alloc((size >> 4) + 1);
381 } else {
382 message_data = NULL;
383 }
384
385 EdSetEventScript(EdEventData, message_data, &EdScriptBuffer);
386 } else {
387 EdEventData = NULL;
388 EdSetEventScript(NULL, NULL, &EdScriptBuffer);
389 EdInitEventParam();
390 }
391
392 EdScriptBuffer.Align64();
393 EdSystemEventData = (char *) (EdScriptBuffer.base + EdScriptBuffer.used * 16);
394
395 if (LoadFile2("gedit/system/event.stb", EdSystemEventData, &size, 0) != 0) {
396 EdScriptBuffer.Alloc((size >> 4) + 1);
397 return;
398 }
399
400 EdSystemEventData = NULL;
401}
402
411static void RunEvent(int event_no, CCamera *camera) {
412 sceVu0FVECTOR position;
413 sceVu0FVECTOR reference;
414
415 if (start_event_no <= 0) {
416 if (camera != NULL) {
417 camera->GetPos(position);
418 camera->GetRef(reference);
419 EventCamera.SetPos(position);
420 EventCamera.SetRef(reference);
421 EventCamera.FollowOff();
422 EventCamera.SetRoll(0.0f);
423 }
424
425 start_event_no = event_no;
426 }
427}
428
437static void RunSystemEvent(int event_no, CCamera *camera) {
438 sceVu0FVECTOR position;
439 sceVu0FVECTOR reference;
440
441 if (start_system_event <= 0) {
442 if (camera != NULL) {
443 camera->GetPos(position);
444 camera->GetRef(reference);
445 EventCamera.SetPos(position);
446 EventCamera.SetRef(reference);
447 EventCamera.FollowOff();
448 }
449
450 start_system_event = event_no;
451 }
452}
453
462static void InitWorkBuffer() {
463 u_char *free_start = EdNPCBuffer.base + EdNPCBuffer.used * 16;
464 int free_quads = EdNPCBuffer.limit - EdNPCBuffer.used;
465 free_start = (u_char *) ((((int) free_start >> 6) + 1) << 6);
466 EdWorkBuffer.base = free_start;
467 EdWorkBuffer.limit = free_quads - 4;
468 EdWorkBuffer.used = 0;
469 int villagers_loaded;
470
471 if (EdVillagerBuffer.used > 0) {
472 villagers_loaded = 1;
473 }
474
475 free_start = (u_char *) read_buffer;
476 EdMenuBuffer.base = free_start - 0x180000;
477 EdMenuBuffer.limit = 0x3A2E0;
478 EdMenuBuffer.used = 0;
479}
480
488int EditInInit(float time, char *name) {
489 MGSetFogParm(10000.0f, 50000.0f, 0, 0, 0, 255.0f, 255.0f);
490 memset(EdInInfo, 0, sizeof(EDIT_IN_INFO));
491 EdInInfo->projection = 800.0f;
492 strcpy(EdInInfo->name, name);
493 PlayTimeCountFlag(1);
494 simple_event = 0;
495 LoadScript();
496 NowTime = time;
497 int hour = (int) (time / 3.0f);
498 EdNPCBuffer.used = 0;
499
500 for (int i = 0; i < 10; i++) {
501 EdVillager[i].Initialize();
502 EdVillager[i].texture_block = 0x36;
503 }
504
505 LoadTexture();
506 BG_READ_INFO *bg_file = GetReadBGFile(1);
507
508 if (bg_file != NULL) {
509 char *script_text = (char *) EdNPCBuffer.Alloc((bg_file->size >> 4) + 1);
510 memcpy(script_text, bg_file->buffer, bg_file->size);
511 LoadInfo(script_text, bg_file->size);
512 }
513
514 LoadData();
515 int used = EdNPCBuffer.used;
516 u_char *start = EdNPCBuffer.base + used * 16;
517 int remaining = EdNPCBuffer.limit - used;
518 EdVillagerBuffer.base = start;
519 EdVillagerBuffer.limit = remaining;
520 EdVillagerBuffer.used = 0;
521 printf("buffer %d\n", remaining);
522 LoadChara();
523 MGSetRenderInfo(EdInInfo->projection, 5.0f, 65535.0f);
524 MGSetPLight(EdInInfo->light_direction, EdInInfo->light_colour);
525 MGSetAmbient(EdInInfo->ambient);
526 MGSetBGColor(EdInInfo->background_colour);
527 Chara = EdExchangeInfo.player;
528 camera_dist_mode = 1;
529
530 if (Chara != NULL) {
531 Chara->SetPosition(0.0f, 0.0f, 0.0f);
532 }
533
534 EdFadeIn(0x40, 0.0f, 0.0f, 0.0f);
535 door_open_cnt = 0;
536 GameMode = ED_IN_MODE_WALK;
537 Chara->wind = 0;
538 Chara->SetPosition(0.0f, 0.0f, 0.0f);
539 Chara->SetRotation(0.0f, 0.0f, 0.0f);
540 GetMapJumpPos(Chara);
541 Chara->ClothStep(-1);
542
543 if (EdInteriorDoorSound >= 0) {
544 sceVu0FVECTOR position;
545 sceVu0FVECTOR reference = {0.0f, 0.0f, 10.0f, 0.0f};
546 Chara->GetPosition(position);
547 position[2] -= 10.0f;
548 SndSetCamera(position, reference);
549 Chara->GetPosition(position);
550 EdDoorCloseSe(EdInteriorDoorSound, position);
551 }
552
553 EdMoveCharaInit();
554 active_camera = NULL;
555 camera_change_count = 0;
556 MainCamera.FollowOff();
557 NowCamera = &MainCamera;
558 start_event_no = EdInteriorStartEvent;
559 start_system_event = -1;
560 goto_menu = 0;
561 goto_return_menu = 0;
562 key_counter = 0;
563 loop_counter = 0;
564 EdEventInfo.interior_parts_count = parts_num;
565 EdEventInfo.interior_parts = InteriorParts;
566 EdInitEventParam();
567 InitWorkBuffer();
568 printf("buffer %d\n", EdWorkBuffer.limit - EdWorkBuffer.used);
569 EdSaveFrameImageInit();
570 EdInitMenu(ED_MENU_RESET);
571 EdInitSoundSrc();
572 return 0;
573}
574
582int EditInLoop() {
583 sceVu0FMATRIX view;
584 sceVu0FVECTOR position;
585
586 if (EdSystemMesCheck() || EdCheckItemOver()) {
587 EdSetKeyMode(0);
588 } else {
589 EdSetKeyMode(0xFFFF);
590 }
591
592 if (EdPadDown(0x800, 4)) {
593 goto_return_menu = 1;
594 }
595
596 int hour = (int) (NowTime / 3.0f);
597
598 if (GameMode != 14) {
599 if (!EdCheckViewMode()) {
600 MGSetRenderInfo(EdInInfo->projection, 5.0f, 65535.0f);
601 } else {
602 MGSetRenderInfo(600.0f, 4.0f, 65535.0f);
603 }
604 }
605
606 Chara->GetPosition(position);
607
608 switch (GameMode) {
609 case ED_IN_MODE_MENU_INIT:
610 case ED_IN_MODE_MENU:
611 case ED_IN_MODE_PAUSE:
612 break;
613 default:
614 int i;
615 OBJ_ANIME_SEQ *anime = EdInInfo->obj_anime;
616
617 for (i = 0; i < obj_anime_num; i++, anime++) {
618 int completion_flag = anime->completion_flag;
619
620 if (completion_flag <= 0 || EdGetMapFlag(completion_flag) == 0) {
621 ObjAnimePlay(anime);
622 }
623 }
624
625 StepWater();
626 break;
627 }
628
629 if (fix_camera != 0 && camera_num > 0 && GameMode == ED_IN_MODE_WALK) {
630 SetCameraPos((CFrame *) InteriorParts[0].frame[0], &MainCamera, Chara);
631 }
632
633 EdSetCharaCursor(0);
634
635 switch (GameMode) {
636 case ED_IN_MODE_WALK:
637 if (loop_counter > 0) {
638 MoveCharacter();
639 }
640
641 EdSetCharaCursor(1);
642
643 for (int i = 0; i < 10; i++) {
644 EdVillager[i].Step();
645 EdVillager[i].ShadowStep();
646 EdVillager[i].ClothStep(0);
647 }
648
649 NowCamera = &MainCamera;
650
651 if (EdCheckViewMode() != 0) {
652 NowCamera = &ViewCamera__2;
653 }
654
655 break;
656 case ED_IN_MODE_EVENT: {
657 NowCamera = &EventCamera;
658 Chara->SetVelocity(CVector3_f_(0.0f, 0.0f, 0.0f));
659 EdEventInfo.current_time = NowTime;
660 int result = EdEventMode(&EventCamera, 0);
661
662 if (result != 0) {
663 GameMode = ED_IN_MODE_WALK;
664 NowCamera = &MainCamera;
665
666 if (result == ED_EVENT_RETURN_OUTSIDE) {
667 if (MapNo == TOWN_MUSKA_LACKA && strcmp(EdInteriorName, "i04h04") == 0) {
668 EdInteriorDoorSound = -1;
669 }
670
671 return 1;
672 }
673
674 if (result == ED_EVENT_RETURN_MAP_JUMP) {
675 return 99;
676 }
677
678 if (result == ED_EVENT_RETURN_TALK) {
679 GameMode = ED_IN_MODE_TALK;
680 }
681
682 if (EdEventInfo.reset_camera_angle < 0) {
683 sceVu0FVECTOR event_pos;
684 sceVu0FVECTOR event_ref;
685 EventCamera.GetPos(event_pos);
686 EventCamera.GetRef(event_ref);
687 MainCamera.SetPos(event_pos);
688 MainCamera.SetRef(event_ref);
689 }
690
691 camera_change_count = 0;
692 }
693
694 VillagerCollision();
695 EdEventNPCStep();
696 goto_return_menu = 0;
697 break;
698 }
699 case ED_IN_MODE_DOOR_OPEN: {
700 NowCamera = &MainCamera;
701 CVector3_f_ velocity(0.0f, 0.0f, 0.0f);
702 Chara->SetVelocity(velocity);
703 Chara->Step();
704 Chara->ShadowStep();
705 Chara->SetPosition(fix_chara_pos);
706 Chara->SetRotation(fix_chara_rot[0], fix_chara_rot[1], fix_chara_rot[2]);
707 Chara->ClothStep(0);
708
709 for (int i = 0; i < 10; i++) {
710 EdVillager[i].Step();
711 EdVillager[i].ShadowStep();
712 EdVillager[i].ClothStep(0);
713 }
714
715 door_open_cnt--;
716
717 if (door_open_cnt == 100 && EdInteriorDoorSound >= 0) {
718 sceVu0FVECTOR chara_pos;
719 Chara->GetPosition(chara_pos);
720 EdDoorOpenSe(EdInteriorDoorSound, chara_pos);
721 }
722
723 if (door_open_cnt < 0) {
724 door_open_cnt = 0;
725 GameMode = ED_IN_MODE_LEAVE;
726 }
727
728 break;
729 }
730 case ED_IN_MODE_LEAVE:
731 NowCamera = &MainCamera;
732 EdStopSoundSrc();
733
734 if (EdEventInfo.map_jump_bgm_stop != 0) {
735 SndBgmFadeOutStop();
736 } else {
737 EdBeforeInBgmNo = -1;
738 }
739
740 return 1;
741 case ED_IN_MODE_TALK: {
742 sceVu0FVECTOR direction;
743 NowCamera = &MainCamera;
744
745 if (EdCheckViewMode() != 0) {
746 NowCamera = &ViewCamera__2;
747 }
748
749 Chara->SetMotion(0, 0);
750 Chara->SetVelocity(CVector3_f_(0.0f, 0.0f, 0.0f));
751 Chara->Step();
752 Chara->ShadowStep();
753 Chara->ClothStep(0);
754
755 for (int i = 0; i < 10; i++) {
756 EdVillager[i].Step();
757 EdVillager[i].ShadowStep();
758 EdVillager[i].ClothStep(0);
759 }
760
761 CNPCharacter *talker = EdNowTalkChara();
762 float distance = Chara->GetDistance(*talker);
763 Chara->GetDir(*talker, direction);
764 float pitch = -atan2f(-Chara->body_height + (1.3f + talker->body_height + direction[1]), distance);
765 float yaw = atan2f(direction[0], direction[2]);
766 float view_h = EdAGetViewAngleH();
767 float view_v = EdAGetViewAngleV();
768 view_h = AngleInterpolate(view_h, yaw, 0.05f, INTERPOLATE_STEP);
769 view_v = AngleInterpolate(view_v, pitch, 0.03f, INTERPOLATE_STEP);
770 EdASetViewAngle(view_h, view_v);
771 EdEyeCamera(&ViewCamera__2, Chara);
772
773 if (EdCheckViewMode() == 0 || ((view_h - yaw < 0.0f ? -(view_h - yaw) : view_h - yaw) < 0.001f && (view_v - pitch < 0.0f ? -(view_v - pitch) : view_v - pitch) < 0.001f)) {
774 int event_no;
775 EdASetViewAngle(yaw, pitch);
776 event_no = 0;
777 int result = EdTalkMode(Chara, NULL, EdCheckViewMode(), &event_no);
778
779 if (result != 0) {
780 if (result == 2) {
781 goto_menu = ED_MENU_SHOP;
782 }
783
784 if (result == 3) {
785 goto_menu = ED_MENU_UNK_4;
786 }
787
788 if (result == 4 && event_no > 0) {
789 RunEvent(event_no, NowCamera);
790 }
791
792 GameMode = ED_IN_MODE_WALK;
793 }
794 }
795
796 break;
797 }
798 case ED_IN_MODE_MENU_INIT:
799 Chara->SetMotion(Chara->motion_no, 1);
800 Chara->Step();
801 Chara->ShadowStep();
802
803 for (int i = 0; i < 10; i++) {
804 EdVillager[i].SetMotion(EdVillager[i].motion_no, 1);
805 EdVillager[i].Step();
806 EdVillager[i].ShadowStep();
807 }
808
809 break;
810 case ED_IN_MODE_MENU:
811 MenuMapJumpMode = -1;
812
813 if (EdMenuMode() != 0) {
814 GameMode = ED_IN_MODE_WALK;
815 EdExitMenu();
816
817 if (GetInteriorOutFlag() != 0) {
818 EdViewModeOff();
819 return 1;
820 }
821
822 for (int i = 0; i < 10; i++) {
823 EdVillager[i].SetMotion(EdVillager[i].motion_no, 0);
824 EdVillager[i].Step();
825 EdVillager[i].ShadowStep();
826 }
827
828 return 0;
829 }
830
831 break;
832 }
833
834 if (EdEventInfo.lighting_override != 0) {
835 MGSetPLight(EdEventInfo.light_direction, EdEventInfo.light_color);
836 MGSetAmbient(EdEventInfo.ambient_color);
837 }
838
839 NowCamera->Step(1);
840 sceVu0FVECTOR eye;
841 sceVu0FVECTOR dir;
842 CMapParts *parts[64];
843 NowCamera->GetCameraMatrix(view);
844 NowCamera->GetPos(eye);
845 NowCamera->GetDir(dir);
846 MGSetViewMatrix(view, eye);
847
848 for (int i = 0; i < parts_num; i++) {
849 parts[i] = &InteriorParts[i];
850 }
851
852 EdSetSoundSrcVol(NowTime, parts, parts_num, eye, dir);
853
854 if (GameMode != ED_IN_MODE_MENU) {
855 MainDraw();
856 } else {
857 EdFadeInOut();
858 }
859
860 if (GameMode == ED_IN_MODE_MENU_INIT && EdInitModeFinish(NowCamera, TexManager.GetTexture("frame_image", -1)) != 0) {
861 GameMode = ED_IN_MODE_MENU;
862 }
863
864 EdSaveFrameImageTask();
865
866 if (GameMode == ED_IN_MODE_WALK && ((EdPadDown(0x10, 1) != 0 && loop_counter >= 2) || goto_menu != 0 || (SystemMesCheck() == 0 && EdCheckItemOver() != 0))) {
867 int menu = ED_MENU_BATTLE;
868
869 if (goto_menu != 0) {
870 menu = goto_menu;
871 goto_menu = 0;
872 printf("%d\n", menu);
873 }
874
875 if (EdInitMenu(menu) != 0) {
876 SndSePlay(MENU_SOUND_CONFIRM, -1, 0);
877 GameMode = ED_IN_MODE_MENU_INIT;
878 }
879 }
880
881 static int event_text = 0;
882
883 if (GamePad.Down2(PAD_SQUARE) != 0) {
884 event_text = 4;
885 EdEventAllClear();
886 simple_event = 0;
887 }
888
889 event_text--;
890
891 if (event_text < 0) {
892 event_text = 0;
893 }
894
895 if (event_text == 1) {
896 start_event_no = 150;
897 }
898
899 if (GameMode != ED_IN_MODE_EVENT && ((CMainChara *) Chara)->move_info.landed != 0) {
900 int ground_event = ((CMainChara *) Chara)->move_info.ground_poly.attr.ground_kind;
901
902 if (ground_event > 0) {
903 start_event_no = ground_event;
904 }
905 }
906
907 if (EdDebugEventEnable != 0 && (start_event_no > 0 || start_system_event > 0)) {
908 if (start_system_event > 0) {
909 if (EdEventInit(start_system_event, &EdNPCBuffer, (char *) EdSystemEventData) != 0) {
910 EdInitMesParam();
911 GameMode = ED_IN_MODE_EVENT;
912 }
913 } else if (EdEventInit(start_event_no, &EdNPCBuffer, (char *) EdEventData) != 0) {
914 EdInitMesParam();
915 GameMode = ED_IN_MODE_EVENT;
916 } else if (EdEventInfo.return_code == ED_EVENT_RETURN_TALK) {
917 EdInitMesParam();
918 GameMode = ED_IN_MODE_TALK;
919 simple_event = 0;
920 }
921
922 start_event_no = -1;
923 start_system_event = -1;
924 } else {
925 simple_event = 0;
926 }
927
928 static int old_mode;
929
930 if (GameMode == ED_IN_MODE_PAUSE && GamePad.Down(PAD_START) != 0) {
931 GameMode = old_mode;
932 EdSePlay((ED_SOUND_ID) 2, -1);
933 PlayTimeCountFlag(1);
934 } else if (GameMode != ED_IN_MODE_EVENT && goto_return_menu != 0 && loop_counter > 1 && GameMode == ED_IN_MODE_WALK) {
935 old_mode = GameMode;
936 GameMode = ED_IN_MODE_PAUSE;
937 EdSePlay((ED_SOUND_ID) 1, -1);
938 PlayTimeCountFlag(0);
939 }
940
941 goto_return_menu = 0;
942 static int end_count = 0;
943
944#ifdef PAL
945 if (GamePad.AllOn() != 0 || DebugMode) {
946 key_counter = 0;
947 }
948
949 if (DebugMode && GamePad.On(PAD_SELECT) && GamePad.On(PAD_START) && end_count == 0) {
950 float zero = 0.0f;
951
952 end_count = 100;
953 EdFadeOut(64, zero, zero, zero);
954 }
955
956#else
957 if (GamePad.AllOn() != 0) {
958 key_counter = 0;
959 }
960
961#endif
962 if (end_count == 1) {
963 end_count = 0;
964 MapJump(800, -1);
965 return 99;
966 }
967
968 end_count--;
969
970 if (end_count < 0) {
971 end_count = 0;
972 }
973
974 key_counter++;
975 loop_counter++;
976 SndStep();
977 return 0;
978}
979
988static void MainDraw() {
989 sceVu0FVECTOR position;
990 int i;
991
992 if (EdDrawOffFlag != 0) {
993 return;
994 }
995
996 if (GameMode == ED_IN_MODE_PAUSE) {
998 } else {
1000 }
1001
1002 EdDrawOffMap = EdEventInfo.suppress_background;
1003 EdDrawOffMapShadow = EdEventInfo.suppress_shadows;
1004 Chara->GetPosition(position);
1005 int hour = (int) (NowTime / 3.0f);
1006
1007 if (EdDrawOffMap == 0) {
1008 TexManager.ReloadTexture(GetVif1Packet(), 15);
1009 TexAnime.TexAnime(15);
1010 setTexAnim();
1011 sceVu0FVECTOR lod_distance = {0.0f, 1000.0f, 10000.0f, 1000000.0f};
1012
1013 for (i = 0; i < parts_num; i++) {
1014 InteriorParts[i].DrawParts(NowTime, lod_distance, 0, 0, NULL);
1015 }
1016 }
1017
1018 sceGsTex0 frame_tex;
1019 CRect_i_ screen;
1020 sceGsTex0 water_tex;
1021 MGGetFBuffTex(&frame_tex);
1022 screen.x = 0;
1023 screen.y = 0;
1024 screen.width = 0x280;
1025 screen.height = SCREEN_HALF_HEIGHT;
1026 water_tex = *(sceGsTex0 *) &TexManager.GetTexture("water_buff", -1)->tex0;
1027 MGMoveImage(&frame_tex, screen, &water_tex, 0, 0, 0);
1028 sceVu0FVECTOR ref;
1029 MainCamera.GetRef(ref);
1030 sceGsZbuf zbuf = mgZBuffer;
1031 zbuf.bits.zmsk = 1;
1032 MGSetGsZBUF(&zbuf);
1033 DrawWaterSurface(NowCamera);
1034 MGSetGsZBUF(&mgZBuffer);
1035
1036 if (GameMode == ED_IN_MODE_EVENT) {
1037 EdEventBackSpriteDraw();
1038 }
1039
1040 if (GameMode == ED_IN_MODE_EVENT) {
1041 EdDrawItem();
1042 }
1043
1044 ED_EVENT_INFO *event = NULL;
1045 int detail = 3;
1046 int marks_store[10];
1047 int *marks = marks_store;
1048
1049 if (EdCheckViewMode() != 0) {
1050 detail = 0;
1051 }
1052
1053 if (GameMode == ED_IN_MODE_LEAVE) {
1054 marks = NULL;
1055 } else {
1056 for (i = 0; i < 10; i++) {
1057 marks_store[i] = 3;
1058 }
1059 }
1060
1061 if (GameMode == ED_IN_MODE_EVENT) {
1062 event = &EdEventInfo;
1063 detail = 3;
1064 }
1065
1066 EdDrawCharacter(Chara, detail, 10, EdVillager, marks, 1, event);
1067 TexManager.ReloadTexture(GetVif1Packet(), 0x18);
1068 sceVu0FVECTOR wind = {0.0f, 0.0f, 0.0f, 0.0f};
1069
1070 if (GameMode != ED_IN_MODE_PAUSE || EdPauseFlag == 0) {
1071 EditEffectStep();
1072 EffectMacroStep(wind);
1073 EdEffectGroup.Step(1);
1074
1075 for (i = 0; i < 4; i++) {
1076 MotionParts__2[i].Step();
1077 }
1078 }
1079
1080 EditEffectStep2();
1081
1082 if (EdDrawOffMap == 0) {
1083 EDIT_EFFECT_INFO *effect = EdInInfo->effects;
1084
1085 for (i = 0; i < effect_num; i++, effect++) {
1086 if (CheckEditEffect(effect, NowTime) != 0) {
1087 DrawEditEffect(effect, NowCamera, &EdEffectGroup);
1088 }
1089 }
1090 }
1091
1092 EdEffectGroup.Draw();
1093
1094 for (i = 0; i < 4; i++) {
1095 TexManager.ReloadTexture(GetVif1Packet(), i + 0x32);
1096 MotionParts__2[i].Draw();
1097 }
1098
1099 TexManager.ReloadTexture(Vif1Packet, 0x14);
1100 EdDrawSysCursor(EdInInfo->event_points, 32);
1101
1102 if (GameMode == ED_IN_MODE_EVENT) {
1103 EdEventSpriteDraw();
1104 }
1105
1106 if ((unsigned int) (GameMode - 3) < 2U) {
1107 TexManager.ReloadTexture(Vif1Packet, EditMes1.tex_block);
1108 EditMes1.DrawMesWin();
1109
1110 if (GameMode == ED_IN_MODE_EVENT) {
1111 EditEventMes1.DrawMesWin();
1112 EditSystemMes.DrawMesWin();
1113 }
1114 }
1115
1116 if (GameMode == ED_IN_MODE_WALK) {
1117 MonsterNameDraw();
1118 } else {
1119 MonsterNameMake(-1);
1120 }
1121
1122 EdSystemMesStep();
1123 EdSystemMesDraw();
1124 static int debug_flag = 0;
1125 static int debug_menu_mode = 0;
1126
1127#ifdef PAL
1128 if (DebugMode) {
1129 if (GamePad.Down(PAD_L3)) {
1130 debug_flag = !debug_flag;
1131 }
1132
1133 if (debug_menu_mode) {
1134 GamePad.KeyLock(0);
1135 EdDebugMenu();
1136
1137 if (GamePad.Down(PAD_R3) || EdDebugRunEventNo > 0) {
1138 debug_menu_mode = 0;
1139 GamePad.AutoRepeatOff();
1140 RunEvent(EdDebugRunEventNo, NowCamera);
1141 } else {
1142 GamePad.KeyLock(1);
1143 }
1144 } else {
1145 if (GameMode != ED_IN_MODE_EVENT && GamePad.Down(PAD_R3)) {
1146 GamePad.SetAutoRepeat(PAD_DPAD, 25, 3);
1147 GamePad.SetAutoRepeat(PAD_L1 | PAD_R1, 25, 3);
1148 debug_menu_mode = 1;
1149 debug_flag = 0;
1150 }
1151
1152 EdDDebug(debug_flag);
1153 EdDPrintChara((CMainChara *) Chara);
1154 EdDPrintCamera(NowCamera);
1155 EdDDrawFont();
1156 }
1157 }
1158
1159#endif
1160 if (EdDebugParamDrawOff == 0) {
1161 char pause_texture[] = "pause";
1162
1163 if (GameMode == ED_IN_MODE_PAUSE || EdPauseFlag != 0) {
1164 TexManager.ReloadTexture(GetVif1Packet(), 0x14);
1165 CRect_i_ fade;
1166 fade.x = 0;
1167 fade.y = 0;
1168 fade.width = 0x2800;
1169 fade.height = SCREEN_HALF_HEIGHT * 16;
1170 MGFillBox(fade, 0, 0, 0, 0x40);
1171 setbilinear(0);
1172 CRect_i_ place;
1173 CRect_i_ texel;
1174 texel.x = 0;
1175 texel.y = 0;
1176 texel.width = 0x80;
1177 texel.height = 0x28;
1178 place.x = 0x100;
1179 place.y = SCREEN_HALF_HEIGHT - 20;
1180 place.width = 0x80;
1181 place.height = 0x28;
1182 sceVif1Packet *packet = GetVif1Packet();
1183 set2DSprite(packet, TexManager.GetTexture(pause_texture, -1), place, texel, 0x80);
1184 }
1185 }
1186
1187 EdFadeInOut();
1188}
1189
1197void DrawWaterSurface(CCamera *camera) {
1198 sceVu0FVECTOR eye;
1199 sceVu0FVECTOR position;
1200 sceVu0FVECTOR dir;
1201 int i;
1202 CGroundWater *surface = Water;
1203
1204 camera->GetPos(eye);
1205 camera->GetDir(dir);
1206 dir[1] = 0.0f;
1207 sceVu0Normalize(dir, dir);
1208
1209 for (i = 0; i < 1; i++, surface++) {
1210 if (surface->draw == 0) {
1211 continue;
1212 }
1213
1214 CWater *water = &surface->water;
1215 sceVu0CopyVector(position, surface->offset);
1216
1217 if (surface->follow[0]) {
1218 position[0] = eye[0] + 50.0f * dir[0];
1219 }
1220
1221 if (surface->follow[1]) {
1222 position[1] = eye[1];
1223 }
1224
1225 if (surface->follow[2]) {
1226 position[2] = eye[2] + 50.0f * dir[2];
1227 }
1228
1229 CVector3_f_ rotation;
1230 rotation.x = rotation.y = rotation.z = 0.0f;
1231 water->frame.SetRotation(rotation.x, rotation.y, rotation.z);
1232 water->frame.SetPosition(position);
1233 DrawVu1__6CWaterFP10RenderInfoP13sceVif1PacketP1(water, &mgRenderInfo, GetVif1Packet(), NULL);
1234 }
1235}
1236
1244static void StepWater() {
1245 int i;
1246 int j;
1247 CGroundWater *surface = Water;
1248
1249 for (i = 0; i < 1; i++, surface++) {
1250 if (surface->draw == 0) {
1251 continue;
1252 }
1253
1254 if (surface->water.CheckClip()) {
1255 continue;
1256 }
1257
1258 for (j = 0; j < 4; j++) {
1259 if (surface->ripples[j].power == 0.0f && surface->ripples[j].range == 0.0f) {
1260 break;
1261 }
1262
1263 int row = surface->ripples[j].row;
1264 int column = surface->ripples[j].column;
1265
1266 if (row < 0) {
1267 int rows = surface->water.rows;
1268 row = rows * (float) rand() / 2.1474836e9f;
1269 }
1270
1271 if (column < 0) {
1272 int rows = surface->water.rows;
1273 column = rows * (float) rand() / 2.1474836e9f;
1274 }
1275
1276 surface->water.Shake(row, column, surface->ripples[j].power + surface->ripples[j].range * (float) rand() / 2.1474836e9f);
1277 }
1278
1279 surface->water.Hamon();
1280 }
1281}
1282
1290static void MoveCharacter() {
1291 sceVu0FVECTOR follow;
1292 static sceVu0FVECTOR fix_pos;
1293
1294 EdMoveCharaInfo.time = NowTime;
1295 EdMoveCharaInfo.camera = &MainCamera;
1296 EdMoveCharaInfo.view_camera = &ViewCamera__2;
1297 EdMoveCharaInfo.key_lock = false;
1298 EdMoveCharaInfo.chara = Chara;
1299 EdMoveCharaInfo.interior = true;
1300 EdMoveCharaInfo.parts = InteriorParts;
1301 EdMoveCharaInfo.parts_count = parts_num;
1302 EdMoveCharaInfo.points = EdInInfo->event_points;
1303 EdMoveCharaInfo.point_count = 32;
1304 EdMoveCharaInfo.acted = false;
1305 EdMoveChara();
1306
1307 if (EdDebugCameraFlag != 0 && GamePad.Down(PAD_CIRCLE) != 0) {
1308 fix_camera = !fix_camera;
1309 MainCamera.GetPos(fix_pos);
1310 }
1311
1312 if (fix_camera != 0) {
1313 MainCamera.FollowOff();
1314 } else {
1315 MainCamera.FollowOn();
1316 Chara->GetPosition(follow);
1317 MainCamera.SetFollow(follow[0], 14.0f + follow[1], follow[2]);
1318 MoveCamera(&MainCamera);
1319 }
1320
1321 if (EdMoveCharaInfo.system_event_no > 0) {
1322 RunSystemEvent(EdMoveCharaInfo.system_event_no, &MainCamera);
1323 return;
1324 }
1325
1326 if (EdMoveCharaInfo.event_no > 0) {
1327 RunEvent(EdMoveCharaInfo.event_no, &MainCamera);
1328 return;
1329 }
1330
1331 if (EdMoveCharaInfo.acted == 0 && EdPadDown(0x40, 1) != 0) {
1332 sceVu0FVECTOR position;
1333 sceVu0FVECTOR start = {-40.5f, 0.0f, -12.55f, 1.0f};
1334 sceVu0FVECTOR rotation = {0.0f, 0.0f, 0.0f, 0.0f};
1335 Chara->GetPosition(position);
1336 Chara->GetRotation(rotation);
1337 EPARTS_FUNC_DATA *jump;
1338
1339#ifdef PAL
1340 jump = NULL;
1341
1342 if ((DebugMode && GamePad.Down(PAD_SELECT)) || (jump = SearchMapJump(position, rotation))) {
1343#else
1344 if (jump = SearchMapJump(position, rotation)) {
1345#endif
1346 int motion;
1347
1348 EdMoveCharaInit();
1349 motion = 0;
1350 door_open_cnt = 140;
1351
1352 if (jump != NULL) {
1353 GetDoorPos(jump->link_id, position, rotation, &EdInteriorDoorSound, &motion);
1354 }
1355
1356 Chara->SetMotion(motion, 6);
1357 sceVu0CopyVector(fix_chara_pos, position);
1358 sceVu0CopyVector(fix_chara_rot, rotation);
1359 Chara->SetPosition(fix_chara_pos);
1360 Chara->SetRotation(fix_chara_rot[0], fix_chara_rot[1], fix_chara_rot[2]);
1361 Chara->Step();
1362 Chara->ClothStep(-1);
1363 GameMode = ED_IN_MODE_DOOR_OPEN;
1364 EdFadeOut(100, 0.0f, 0.0f, 0.0f);
1365 }
1366 }
1367}
1368
1378static void MoveCamera(CCameraFollow *camera) {
1379 static float camera_distance[3] = {20.0f, 60.0f, 100.0f};
1380
1381 float horizontal = GamePad.GetRXf();
1382 camera->AddHeight(-GamePad.GetRYf());
1383
1384 if (!(camera->GetHeight() <= 30.0f)) {
1385 camera->SetHeight(30.0f);
1386 }
1387
1388 camera->AddAngle(0.04f * -horizontal);
1389
1390 if (GamePad.On(PAD_R1) != 0) {
1391 camera->AddAngle(-DEG_TO_RAD);
1392 }
1393
1394 if (GamePad.On(PAD_L1) != 0) {
1395 camera->AddAngle(DEG_TO_RAD);
1396 }
1397
1398 camera->SetDistance(camera_distance[camera_dist_mode]);
1399
1400 if (GamePad.Down(PAD_TRIANGLE) != 0) {
1401 camera_dist_mode++;
1402 }
1403
1404 if (camera_dist_mode >= 3) {
1405 camera_dist_mode = 0;
1406 }
1407}
1408
1416EPARTS_FUNC_DATA *SearchMapJump(float *position, float *rotation) {
1417 sceVu0FVECTOR world;
1418 int i;
1419 EPARTS_FUNC_DATA *point = func_point;
1420
1421 for (i = 0; i < func_num; i++, point++) {
1422 if (point->kind == EPARTS_FUNC_DOOR) {
1423 CFrame *frame = (CFrame *) point->parts;
1424 point->position[3] = 1.0f;
1425 frame->GetWorldPosition(world, point->position);
1426 EdInteriorJumpID = point->link_id;
1427
1428 if (DistVector(position, world) < 10.0f && AngleCmp(rotation[1], point->rotation[1], 0.87f) == 0) {
1429 return point;
1430 }
1431 }
1432 }
1433
1434 return NULL;
1435}
1436
1444void GetMapJumpPos(CCharacter *chara) {
1445 EPARTS_FUNC_DATA *point = func_point;
1446
1447 for (int i = 0; i < func_num; i++, point++) {
1448 if (point->kind == EPARTS_FUNC_DOOR && point->link_id == EdInteriorJumpID) {
1449 chara->SetPosition(point->position[0], point->position[1], point->position[2]);
1450 printf("%f %f %f\n", point->position[0], point->position[1], point->position[2]);
1451 chara->SetRotation(0.0f, AngleLimit(PI_SHORT + point->rotation[1]), 0.0f);
1452 return;
1453 }
1454 }
1455}
1456
1464static int GetDoorPos(int door_no, float *position, float *rotation, int *door_sound, int *motion) {
1465 EPARTS_FUNC_DATA *point = func_point;
1466
1467 for (int i = 0; i < func_num; i++, point++) {
1468 if ((point->kind == EPARTS_FUNC_DOOR_SIDE_A || point->kind == EPARTS_FUNC_DOOR_SIDE_B) && point->link_id == door_no) {
1469 sceVu0CopyVector(position, point->position);
1470 sceVu0CopyVector(rotation, point->rotation);
1471 *door_sound = point->values[0];
1472 *motion = EdGetDoorMotion(*door_sound, point->kind == EPARTS_FUNC_DOOR_SIDE_A);
1473 return point->kind == EPARTS_FUNC_DOOR_SIDE_B;
1474 }
1475 }
1476
1477 return -1;
1478}
1479
1487void SetCameraPos(CFrame *frame, CCamera *camera, CCharacter *chara) {
1488 sceVu0FVECTOR position;
1489 sceVu0FVECTOR local;
1490 int i;
1491 EPARTS_FUNC_DATA *point = func_point;
1492 int count;
1493 INTERIOR_CAMERA *entry;
1494
1495 chara->GetPosition(position);
1496 INTERIOR_CAMERA cameras[8];
1497 sceVu0FMATRIX matrix;
1498 count = 0;
1499
1500 for (i = 0; i < func_num; i++, point++) {
1501 if (point->kind == EPARTS_FUNC_CAMERA) {
1502 entry = &cameras[count];
1503 entry->link_id = point->link_id;
1504 CFrame *owner = (CFrame *) point->parts;
1505 sceVu0CopyVector(entry->min, point->parameters);
1506 sceVu0CopyVector(entry->max, point->values);
1507 sceVu0UnitMatrix(matrix);
1508
1509 if (owner != NULL) {
1510 CFrame *found = owner->SearchFrame((char *) point->frame_name);
1511
1512 if (found != NULL) {
1513 found->GetLWMatrix(matrix);
1514 }
1515 }
1516
1517 sceVu0MulMatrix(matrix, matrix, point->matrix);
1518 entry->frame.SetTransMatrix(matrix);
1519 count++;
1520
1521 if (count >= 8) {
1522 break;
1523 }
1524 }
1525 }
1526
1527 if (count <= 0) {
1528 return;
1529 }
1530
1531 INTERIOR_CAMERA *inside = NULL;
1532 static int cnt = 0;
1533
1534 for (i = 0; i < count; i++) {
1535 entry = &cameras[i];
1536
1537 if (entry->link_id == 0) {
1538 inside = entry;
1539 continue;
1540 }
1541
1542 float (*inverse)[4] = entry->frame.GetInverseMatrix();
1543 position[3] = 1.0f;
1544 sceVu0ApplyMatrix(local, inverse, position);
1545
1546 if (!(local[0] < entry->min[0]) && !(local[1] < entry->min[1]) && !(local[2] < entry->min[2]) && local[0] <= entry->max[0] && local[1] <= entry->max[1] && local[2] <= entry->max[2]) {
1547 inside = entry;
1548 break;
1549 }
1550 }
1551
1552 cnt++;
1553
1554 if (cnt > 60) {
1555 cnt = 0;
1556 }
1557
1558 if (active_camera == NULL) {
1559 active_camera = inside;
1560 }
1561
1562 if (inside == NULL) {
1563 return;
1564 }
1565
1566 if (camera_change_count <= 0) {
1567 active_camera = inside;
1568 camera_change_count = 0;
1569 }
1570
1571 if (inside == active_camera) {
1572 camera_change_count = 20;
1573 } else {
1574 camera_change_count--;
1575 }
1576
1577 if (active_camera != NULL) {
1578 sceVu0FVECTOR eye = {0.0f, 0.0f, 0.0f, 1.0f};
1579 active_camera->frame.GetWorldPosition(eye, eye);
1580 position[1] += 17.0f;
1581 camera->SetPos(eye);
1582 camera->SetRef(position);
1583 camera->SetNextPos(NULL, eye[0], eye[1], eye[2]);
1584 camera->SetNextRef(NULL, position[0], position[1], position[2]);
1585 }
1586}
1587
1596static int GetCollision(CCPoly *poly, CBoxVu0 *box) {
1597 int count = 0;
1598
1599 for (int i = 0; i < parts_num; i++) {
1600 CFrame *frame = InteriorParts[i].GetCollisionFrame();
1601
1602 if (frame != NULL) {
1603 count += frame->PickUpNearPoly(&poly[count], *box);
1604 }
1605 }
1606
1607 return count;
1608}
1609
1618static void VillagerCollision() {
1619 sceVu0FVECTOR position;
1620 CBoxVu0 box;
1621 sceVu0FVECTOR ground;
1622 CCPoly poly;
1623
1624 for (int i = -1; i < 10; i++) {
1625 int snap;
1626 CCharacter *chara;
1627 CNPCharacter *villager = NULL;
1628 int foot_sound;
1629
1630 if (i >= 0) {
1631 villager = &EdVillager[i];
1632 snap = EdEventInfo.npc_collision[i];
1633
1634 if (villager->CheckDraw() == 0) {
1635 continue;
1636 }
1637
1638 villager->GetPosition(position);
1639 foot_sound = EdEventInfo.npc_foot_sound[i];
1640 } else {
1641 snap = EdEventInfo.player_collision;
1642 Chara->GetPosition(position);
1643 foot_sound = EdEventInfo.player_foot_sound;
1644 }
1645
1646 WorkBuffer__2->used = 0;
1647 CCPoly *polys = (CCPoly *) WorkBuffer__2->Alloc(2000);
1648 box.max[0] = 1.0f + position[0];
1649 box.min[0] = position[0] - 1.0f;
1650 box.max[2] = 1.0f + position[2];
1651 box.min[2] = position[2] - 1.0f;
1652 box.max[1] = 1000.0f;
1653 box.min[1] = -1000.0f;
1654
1655 if (i >= 0) {
1656 chara = villager;
1657 } else {
1658 chara = Chara;
1659 }
1660
1661 chara->FootSoundEnable(0);
1662 int count = GetCollision(polys, &box);
1663
1664 if (count > 300) {
1665 printf("cpoly over!!!! %d\n", count);
1666 }
1667
1668 if (count > 0) {
1669 position[1] += 20.0f;
1670
1671 if (GetFootPoly(position, 1000.0f, &poly, ground, polys, count, 0) != 0) {
1672 sceVu0CopyVector(position, ground);
1673 chara->FootSoundEnable(foot_sound);
1674
1675 if (foot_sound == 1) {
1676 chara->SetFootSoundID(poly.attr.foot_sound);
1677 }
1678 } else {
1679 position[1] = 0.0f;
1680 }
1681 } else {
1682 position[1] = 0.0f;
1683 }
1684
1685 if (snap != 0) {
1686 if (i >= 0) {
1687 villager->SetPosition(position);
1688 } else {
1689 Chara->SetPosition(position);
1690 }
1691 }
1692 }
1693}
1694
1703static int LoadTexture() {
1704 static LOADTEXTURE_INFO2 texdata[16] = {
1705 {NULL, 15}
1706 };
1707
1708 BG_READ_INFO *file = GetReadBGFile(2);
1709
1710 if (file == NULL) {
1711 return 0;
1712 }
1713
1714 char *ext = file->name;
1715 char c;
1716
1717 while ((c = *ext) != '\0') {
1718 if (c == '.') {
1719 ext++;
1720 break;
1721 }
1722
1723 ext++;
1724 }
1725
1726 u_int *cfg_data = NULL;
1727 int size;
1728 TexAnime.Initialize(NULL, 0);
1729
1730 if (strcmp(ext, "img") == 0) {
1731 texdata[0].name = (char *) file->buffer;
1732 } else {
1733 u_int *found;
1734 int cfg_size;
1735
1736 if (GetPackFileExt((u_int *) file->buffer, "img", &found, 1, NULL, NULL) > 0) {
1737 texdata[0].name = (char *) found;
1738 }
1739
1740 if (GetPackFileExt((u_int *) file->buffer, "cfg", &found, 1, &cfg_size, NULL) > 0) {
1741 TexAnime.Initialize(TexAnimeData, 64);
1742 cfg_data = found;
1743 size = cfg_size;
1744
1745 for (int i = 0; i < 64; i++) {
1746 TexAnimeData[i].Initialize();
1747 }
1748 }
1749 }
1750
1751 TexManager.LoadTextureBlockEX(15, texdata);
1752
1753 if (cfg_data != NULL) {
1754 TexAnime.LoadCFGFile((char *) cfg_data, size);
1755 }
1756
1757 EdNPCBuffer.Alloc((file->size >> 4) + 1);
1758 return 0;
1759}
1760
1764static void LoadChara() {
1765}
1766
1774void LoadData() {
1775 func_point = new ((u_long128 *) (EdNPCBuffer.base + EdNPCBuffer.used * 16)) EPARTS_FUNC_DATA[128];
1776 EdNPCBuffer.Alloc(0x600);
1777
1778 for (int i = 0; i < 128; i++) {
1779 func_point[i].kind = 0;
1780 }
1781
1782 func_num = 0;
1783 BG_READ_INFO *file = GetReadBGFile(0);
1784 u_int *archive = NULL;
1785
1786 if (file != NULL) {
1787 archive = (u_int *) file->buffer;
1788 }
1789
1790 int count;
1791
1792 for (count = 0;; count++) {
1793 u_int *part_archive = SearchPTS(archive, count);
1794
1795 if (part_archive == NULL) {
1796 break;
1797 }
1798
1799 CMapParts *parts = &InteriorParts[count];
1800 LoadPTS(parts, part_archive);
1801 parts->handle = count;
1802 parts->category_no = 15;
1803 int first_point = func_num;
1804 func_num += GetFuncPoint(count, part_archive, &func_point[first_point]);
1805
1806 if (EdInteriorPartsNo >= 0) {
1807 EDITPARTS_INFO *info = EditPartsInfo.GetPartsInfo(EdInteriorPartsNo);
1808
1809 if (info != NULL) {
1810 EDITPARTS_INFO info_copy = *info;
1811 EdPartsObjectOnOff(parts, info, EdInteriorJumpID + 1);
1812 }
1813 }
1814
1815 CFrame *frames[9];
1816
1817 for (int i = 0; i < 9; i++) {
1818 frames[i] = NULL;
1819 }
1820
1821 for (int i = 0; i < 4; i++) {
1822 CFrame *frame = parts->frame[i];
1823 frames[i] = frame;
1824 }
1825
1826 frames[4] = parts->shadow_frame;
1827 frames[5] = parts->GetCollisionFrame();
1828 frames[6] = parts->shade_frame;
1829 frames[7] = parts->ripple_frame;
1830 CFrame *extra_collision;
1831
1832 if (parts->camera_frame == NULL) {
1833 extra_collision = NULL;
1834 } else {
1835 parts->camera_frame->SetPosition(parts->pos[0], parts->pos[1], parts->pos[2]);
1836 parts->camera_frame->SetRotation(parts->rotation.x, parts->rotation.y, parts->rotation.z);
1837 extra_collision = parts->camera_frame;
1838 }
1839
1840 frames[8] = extra_collision;
1841 EPARTS_FUNC_DATA *point = &func_point[first_point];
1842 effect_num = 32;
1843
1844 for (int i = 0; i < 24; i++) {
1845 parts->effect_on[i] = 0;
1846 parts->effect[i] = NULL;
1847 }
1848
1849 for (; first_point < func_num; first_point++, point++) {
1850 EnterPartsEffect(parts, point, EdInInfo->effects, 32);
1851
1852 if (obj_anime_num < 32) {
1853 OBJ_ANIME_SEQ *seq = &EdInInfo->obj_anime[obj_anime_num];
1854
1855 if (InitObjAnime(frames, 9, point, seq) != 0) {
1856 obj_anime_num++;
1857 }
1858 }
1859 }
1860
1861 EdInitEventPoint(parts, NULL, func_point, func_num, EdInInfo->event_points, 32);
1862 }
1863
1864 parts_num = count;
1865
1866 for (int i = 0; i < func_num; i++) {
1867 func_point[i].parts = (CMapParts *) InteriorParts[(int) func_point[i].parts].frame[0];
1868
1869 if (func_point[i].completion_flag > 0 && SaveData->GetMapInitFlag(MapNo, func_point[i].completion_flag) == 0) {
1870 SaveData->SetMapInitFlag(MapNo, func_point[i].completion_flag, 1);
1871 SaveData->SetMapFlag(MapNo, func_point[i].completion_flag, !(s8) func_point[i].unk_28[0]);
1872 }
1873 }
1874
1875 camera_num = 0;
1876 EPARTS_FUNC_DATA *point = func_point;
1877
1878 for (int i = 0; i < func_num; i++, point++) {
1879 if (point->kind == EPARTS_FUNC_CAMERA) {
1880 camera_num++;
1881 }
1882 }
1883
1884 for (int i = 0; i < 4; i++) {
1885 EDIT_MOTION_PARTS_INFO *motion = &EdInInfo->motion_parts[i];
1886 MotionParts__2[i].Initialize();
1887
1888 if (motion->name[0] != '\0') {
1889 LoadFile(motion->name, read_buffer, NULL);
1890 MotionParts__2[i].LoadPackData2((u_int *) read_buffer, "info.cfg", &EdNPCBuffer, i + 0x32, &EdNPCBuffer, 0);
1891 MotionParts__2[i].SetPosition(motion->values[0], motion->values[1], motion->values[2]);
1892 MotionParts__2[i].SetRotation(motion->values[3], motion->values[4], motion->values[5]);
1893 MotionParts__2[i].SetScale(motion->values[6], motion->values[7], motion->values[8]);
1894 }
1895 }
1896
1897 for (int i = 0; i < 1; i++) {
1898 Water[i].draw = false;
1899 }
1900
1901 for (int i = 0; i < 1; i++) {
1902 EDIT_WATER_INFO *info = &EdInInfo->water_surfaces[i];
1903
1904 if (info->grid_rows <= 0) {
1905 break;
1906 }
1907
1908 CWater *water;
1909 int j;
1910 CGroundWater *surface = &Water[i];
1911 water = &surface->water;
1912 sceVu0FVECTOR near_left = {info->corner_a[0], info->corner_a[1], info->corner_a[2], 1.0f};
1913 sceVu0FVECTOR near_right = {info->corner_b[0], info->corner_a[1], info->corner_a[2], 1.0f};
1914 sceVu0FVECTOR far_left = {info->corner_a[0], info->corner_a[1], info->corner_b[2], 1.0f};
1915 sceVu0FVECTOR far_right = {info->corner_b[0], info->corner_a[1], info->corner_b[2], 1.0f};
1916
1917 surface->draw = true;
1918 strcpy(surface->name, info->name);
1919 surface->parts_no = info->parts_no;
1920 sceVu0CopyVector(surface->offset, info->corner_c);
1921
1922 for (int j = 0; j < 3; j++) {
1923 surface->follow[j] = info->follow[j];
1924 }
1925
1926 for (j = 0; j < 4; j++) {
1927 sceVu0CopyVector(&surface->ripples[j].row, &info->wave[j].row);
1928 }
1929
1930 water->SetVertex(near_left, near_right, far_left, far_right);
1931 water->frame.SetPosition(info->corner_c);
1932 water->SetSize(info->grid_rows, info->grid_columns, &EdNPCBuffer);
1933 water->SetParam(info->ripple_params[0], info->ripple_params[1], info->ripple_params[2], info->ripple_params[3]);
1934 water->SetColor(info->red, info->green, info->blue, 0x80);
1935 }
1936}
1937
1945int LoadPTS(CMapParts *parts, u_int *archive) {
1946 EPARTS_INFO_HEADER *header = (EPARTS_INFO_HEADER *) ((char *) archive + archive[1]);
1947 u_int *files[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
1948 EPARTS_ARCHIVE *pack = (EPARTS_ARCHIVE *) archive;
1949
1950 if (pack->lod0_size > 0) {
1951 files[0] = (u_int *) ((char *) archive + pack->lod0_offset);
1952 } else {
1953 return 0;
1954 }
1955
1956 if (pack->lod1_size > 0) {
1957 files[1] = (u_int *) ((char *) archive + pack->lod1_offset);
1958 }
1959
1960 if (pack->lod2_size > 0) {
1961 files[2] = (u_int *) ((char *) archive + pack->lod2_offset);
1962 }
1963
1964 if (pack->lod3_size > 0) {
1965 files[3] = (u_int *) ((char *) archive + pack->lod3_offset);
1966 }
1967
1968 if (pack->shadow_size > 0) {
1969 files[4] = (u_int *) ((char *) archive + pack->shadow_offset);
1970 }
1971
1972 if (pack->collision_size > 0) {
1973 files[5] = (u_int *) ((char *) archive + pack->collision_offset);
1974 }
1975
1976 if (pack->shade_size > 0) {
1977 files[6] = (u_int *) ((char *) archive + pack->shade_offset);
1978 }
1979
1980 if (pack->extra_size > 0) {
1981 files[7] = (u_int *) ((char *) archive + pack->extra_offset);
1982 }
1983
1984 if (pack->camera_size > 0) {
1985 files[8] = (u_int *) ((char *) archive + pack->camera_offset);
1986 }
1987
1988 parts->SetFrame(LoadMDSFile(files[0], &EdNPCBuffer, 0, NULL, NULL), 0);
1989
1990 if (files[5] != NULL) {
1991 parts->collision_frame = LoadCollisionFile(files[5], &EdNPCBuffer);
1992 }
1993
1994 if (files[8] != NULL) {
1995 parts->camera_frame = LoadCollisionFile(files[8], &EdNPCBuffer);
1996 } else {
1997 parts->camera_frame = NULL;
1998 }
1999
2000 sceVu0FVECTOR position = {0.0f, 0.0f, 0.0f, 1.0f};
2001 position[0] = header->position[0];
2002 position[1] = header->position[1];
2003 position[2] = header->position[2];
2004 parts->SetPosition(position);
2005 parts->SetRotation(header->rotation[0], header->rotation[1], header->rotation[2]);
2006 return 0;
2007}
2008
2016int GetFuncPoint(int parts_no, u_int *archive, EPARTS_FUNC_DATA *points) {
2017 EPARTS_INFO_HEADER *header = (EPARTS_INFO_HEADER *) ((char *) archive + archive[1]);
2018 int i;
2019 EPARTS_FUNC_DATA *source = (EPARTS_FUNC_DATA *) ((char *) header + (int) header->func);
2020
2021 for (i = 0; i < header->func_count; points++) {
2022 *(EPARTS_FUNC_RECORD *) points = *(EPARTS_FUNC_RECORD *) source;
2023 source++;
2024 points->parts = (CMapParts *) parts_no;
2025 i++;
2026 }
2027
2028 return header->func_count;
2029}
2030
2032static int setTexAnimCnt;
2033
2035static float setTexAnimCntf;
2036
2044static void setTexAnim() {
2045 sceVif1PkCnt(Vif1Packet, 0);
2046 sceVif1PkOpenDirectCode(Vif1Packet, 0);
2047 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &GiftagAD);
2048 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEXFLUSH, 0);
2049 sceVif1PkCloseGifTag(Vif1Packet);
2050 sceVif1PkCloseDirectCode(Vif1Packet);
2051
2052 if (setTexAnimCntf >= 7.0f) {
2053 setTexAnimCntf = 0.0f;
2054 } else {
2055 setTexAnimCntf += 0.2f;
2056 }
2057
2058 setTexAnimCnt = (int) setTexAnimCntf;
2059
2060 CTexture *strip = TexManager.GetTexture("i01e01_a", -1);
2061 CTexture *plate = TexManager.GetTexture("i01e01", -1);
2062
2063 if (strip == 0 || plate == 0) {
2064 return;
2065 }
2066
2067 MGMoveImage((sceGsTex0 *) &strip->tex0, CRect_i_(0, setTexAnimCnt * 64, 64, 64), (sceGsTex0 *) &plate->tex0, 0, 0, 0);
2068 sceVif1PkCnt(Vif1Packet, 0);
2069 sceVif1PkOpenDirectCode(Vif1Packet, 0);
2070 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &GiftagAD);
2071 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEXFLUSH, 0);
2072 sceVif1PkCloseGifTag(Vif1Packet);
2073 sceVif1PkCloseDirectCode(Vif1Packet);
2074}
2075
2077static int npc_count;
2078
2080static int objanime_list;
2081
2083static int effect_list;
2084
2086static int debug;
2087
2089static int motion_parts_list;
2090
2092static int water_list;
2093
2095static EDIT_WATER_INFO *water_info;
2096
2098static char CurrentDir[0x80];
2099
2100static void CommandAMBIENT(void **arguments);
2101static void CommandLIGHT_C(void **arguments);
2102static void CommandFOG(void **arguments);
2103static void CommandBG_COL(void **arguments);
2104static void CommandPROJECTION(void **arguments);
2105static void CommandPEOPLE(void **arguments);
2106static void CommandCD(void **arguments);
2107static void CommandOBJ_ANIME(void **arguments);
2108static void CommandFIRE(void **arguments);
2109static void CommandFLAME(void **arguments);
2110static void CommandBRIGHT(void **arguments);
2111static void CommandDEBUG(void **arguments);
2112static void CommandMOTION_PARTS(void **arguments);
2113static void CommandWATER_SURFACE(void **arguments);
2114static void CommandWATER_SHAKE(void **arguments);
2115
2117static TAG_PARAM Command[15] = {
2118 {"AMBIENT", {SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, -1} },
2119 {"LIGHT_C", {SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_INTEGER, -1} },
2120 {"FOG", {SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, -1} },
2121 {"BG_COL", {SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, -1} },
2122 {"PROJECTION", {SCRIPT_ARGUMENT_FLOAT, -1} },
2123 {"PEOPLE", {SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, -1} },
2124 {"CD", {SCRIPT_ARGUMENT_STRING, -1} },
2125 {"OBJ_ANIME", {SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_STRING, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, -1} },
2126 {"FIRE", {SCRIPT_ARGUMENT_STRING, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, -1} },
2127 {"FLAME", {SCRIPT_ARGUMENT_STRING, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, -1} },
2128 {"BRIGHT", {SCRIPT_ARGUMENT_STRING, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, -1} },
2129 {"DEBUG", {-1} },
2130 {"MOTION_PARTS", {SCRIPT_ARGUMENT_STRING, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, -1} },
2131 {"WATER_SURFACE", {SCRIPT_ARGUMENT_STRING, SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_INTEGER, -1}},
2132 {"WATER_SHAKE", {SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_INTEGER, SCRIPT_ARGUMENT_FLOAT, SCRIPT_ARGUMENT_FLOAT, -1} },
2133};
2134
2136static void (*CommandExe[15])(void **) = {
2137 CommandAMBIENT,
2138 CommandLIGHT_C,
2139 CommandFOG,
2140 CommandBG_COL,
2141 CommandPROJECTION,
2142 CommandPEOPLE,
2143 CommandCD,
2144 CommandOBJ_ANIME,
2145 CommandFIRE,
2146 CommandFLAME,
2147 CommandBRIGHT,
2148 CommandDEBUG,
2149 CommandMOTION_PARTS,
2150 CommandWATER_SURFACE,
2151 CommandWATER_SHAKE,
2152};
2153
2161static void LoadInfo(char *script, int size) {
2162 CScriptInterpreter interpreter;
2163 int command;
2164
2165 interpreter.SetScript(script, size);
2166 interpreter.SetTAG(Command, 15);
2167 CurrentDir[0] = '\0';
2168 npc_count = 0;
2169 objanime_list = 0;
2170 effect_list = 0;
2171 motion_parts_list = 0;
2172 water_list = 0;
2173 water_info = NULL;
2174 debug = 0;
2175
2176 for (;;) {
2177 command = interpreter.GetNextTAG();
2178
2179 if (command < 0) {
2180 break;
2181 }
2182
2183 CommandExe[command](interpreter.arguments);
2184 }
2185
2186 obj_anime_num = objanime_list;
2187 effect_num = effect_list;
2188}
2189
2198static void CommandAMBIENT(void **arguments) {
2199 EdInInfo->ambient[0] = *(float *) arguments[0];
2200 EdInInfo->ambient[1] = *(float *) arguments[1];
2201 EdInInfo->ambient[2] = *(float *) arguments[2];
2202 EdInInfo->ambient[3] = 128.0f;
2203}
2204
2213static void CommandLIGHT_C(void **arguments) {
2214 sceVu0FVECTOR direction;
2215 int light = *(int *) arguments[6];
2216
2217 direction[0] = *(float *) arguments[0];
2218 direction[1] = *(float *) arguments[1];
2219 direction[2] = *(float *) arguments[2];
2220 direction[3] = 0.0f;
2221 sceVu0Normalize(direction, direction);
2222 light--;
2223 EdInInfo->light_direction[0][light] = direction[0];
2224 EdInInfo->light_direction[1][light] = direction[1];
2225 EdInInfo->light_direction[2][light] = direction[2];
2226 EdInInfo->light_direction[3][light] = direction[3];
2227 EdInInfo->light_colour[light][0] = *(float *) arguments[3];
2228 EdInInfo->light_colour[light][1] = *(float *) arguments[4];
2229 EdInInfo->light_colour[light][2] = *(float *) arguments[5];
2230 EdInInfo->light_colour[light][3] = 128.0f;
2231}
2232
2241static void CommandFOG(void **arguments) {
2242 EdInInfo->fog.near_distance = *(float *) arguments[0];
2243 EdInInfo->fog.far_distance = *(float *) arguments[1];
2244 EdInInfo->fog.red = *(int *) arguments[2];
2245 EdInInfo->fog.green = *(int *) arguments[3];
2246 EdInInfo->fog.blue = *(int *) arguments[4];
2247 EdInInfo->fog.intensity = *(float *) arguments[5];
2248 EdInInfo->fog.exponent = *(float *) arguments[6];
2249}
2250
2259static void CommandBG_COL(void **arguments) {
2260 EdInInfo->background_colour[0] = *(float *) arguments[0];
2261 EdInInfo->background_colour[1] = *(float *) arguments[1];
2262 EdInInfo->background_colour[2] = *(float *) arguments[2];
2263 EdInInfo->background_colour[3] = 128.0f;
2264}
2265
2273static void CommandPROJECTION(void **arguments) {
2274 EdInInfo->projection = *(float *) arguments[0];
2275}
2276
2285static void CommandPEOPLE(void **arguments) {
2286}
2287
2296static void CommandCD(void **arguments) {
2297 GetEditDataDir(CurrentDir);
2298 strcat(CurrentDir, "in/");
2299 strcat(CurrentDir, (char *) arguments[0]);
2300}
2301
2310static void CommandOBJ_ANIME(void **arguments) {
2311}
2312
2316static void SetEffect(EFFECT_TYPE type, char *name, float *position, float *scale, float *rotation) {
2317}
2318
2327static void CommandFIRE(void **arguments) {
2328 sceVu0FVECTOR position;
2329 sceVu0FVECTOR scale;
2330 sceVu0FVECTOR rotation = {0.0f, 0.0f, 0.0f, 0.0f};
2331
2332 position[0] = *(float *) arguments[1];
2333 position[1] = *(float *) arguments[2];
2334 position[2] = *(float *) arguments[3];
2335 position[3] = 1.0f;
2336 scale[0] = *(float *) arguments[4];
2337 scale[1] = *(float *) arguments[4];
2338 scale[2] = *(float *) arguments[4];
2339 SetEffect(EFFECT_FIRE, (char *) arguments[0], position, scale, rotation);
2340}
2341
2350static void CommandFLAME(void **arguments) {
2351 sceVu0FVECTOR position;
2352 sceVu0FVECTOR scale;
2353 sceVu0FVECTOR rotation = {0.0f, 0.0f, 0.0f, 0.0f};
2354
2355 position[0] = *(float *) arguments[1];
2356 position[1] = *(float *) arguments[2];
2357 position[2] = *(float *) arguments[3];
2358 position[3] = 1.0f;
2359 scale[0] = *(float *) arguments[4];
2360 scale[1] = *(float *) arguments[4];
2361 scale[2] = *(float *) arguments[4];
2362 SetEffect(EFFECT_FLAME, (char *) arguments[0], position, scale, rotation);
2363}
2364
2373static void CommandBRIGHT(void **arguments) {
2374 sceVu0FVECTOR position;
2375 sceVu0FVECTOR scale;
2376 sceVu0FVECTOR rotation = {0.0f, 0.0f, 0.0f, 0.0f};
2377
2378 position[0] = *(float *) arguments[1];
2379 position[1] = *(float *) arguments[2];
2380 position[2] = *(float *) arguments[3];
2381 position[3] = 1.0f;
2382 scale[0] = *(float *) arguments[4];
2383 scale[1] = *(float *) arguments[4];
2384 scale[2] = *(float *) arguments[4];
2385 SetEffect(EFFECT_BRIGHT, (char *) arguments[0], position, scale, rotation);
2386}
2387
2395static void CommandDEBUG(void **arguments) {
2396 debug = 1;
2397}
2398
2407static void CommandMOTION_PARTS(void **arguments) {
2408 if (motion_parts_list < 4) {
2409 EDIT_MOTION_PARTS_INFO *motion = &EdInInfo->motion_parts[motion_parts_list];
2410 motion_parts_list++;
2411 strcpy(motion->name, CurrentDir);
2412 strcat(motion->name, (char *) arguments[0]);
2413 motion->values[0] = *(float *) arguments[1];
2414 motion->values[1] = *(float *) arguments[2];
2415 motion->values[2] = *(float *) arguments[3];
2416 motion->values[3] = *(float *) arguments[4];
2417 motion->values[4] = *(float *) arguments[5];
2418 motion->values[5] = *(float *) arguments[6];
2419 motion->values[6] = *(float *) arguments[7];
2420 motion->values[7] = *(float *) arguments[8];
2421 motion->values[8] = *(float *) arguments[9];
2422 }
2423}
2424
2433static void CommandWATER_SURFACE(void **arguments) {
2434 if (water_list < 8) {
2435 EDIT_WATER_INFO *surface = &EdInInfo->water_surfaces[water_list];
2436 water_list++;
2437 strcpy(surface->name, (char *) arguments[0]);
2438 surface->grid_rows = *(int *) arguments[1];
2439 surface->grid_columns = *(int *) arguments[2];
2440 surface->corner_a[0] = *(float *) arguments[3];
2441 surface->corner_a[1] = *(float *) arguments[4];
2442 surface->corner_a[2] = *(float *) arguments[5];
2443 surface->corner_a[3] = 1.0f;
2444 surface->corner_b[0] = *(float *) arguments[6];
2445 surface->corner_b[1] = *(float *) arguments[7];
2446 surface->corner_b[2] = *(float *) arguments[8];
2447 surface->corner_b[3] = 1.0f;
2448 surface->corner_c[0] = *(float *) arguments[9];
2449 surface->corner_c[1] = *(float *) arguments[10];
2450 surface->corner_c[2] = *(float *) arguments[11];
2451 surface->corner_c[3] = 1.0f;
2452 surface->ripple_params[0] = *(float *) arguments[12];
2453 surface->ripple_params[1] = *(float *) arguments[13];
2454 surface->ripple_params[2] = *(float *) arguments[14];
2455 surface->ripple_params[3] = *(float *) arguments[15];
2456 surface->red = *(int *) arguments[16];
2457 surface->green = *(int *) arguments[17];
2458 surface->blue = *(int *) arguments[18];
2459 surface->follow[0] = *(int *) arguments[19];
2460 surface->follow[1] = *(int *) arguments[20];
2461 surface->follow[2] = *(int *) arguments[21];
2462 surface->parts_no = -1;
2463 water_info = surface;
2464 }
2465}
2466
2475static void CommandWATER_SHAKE(void **arguments) {
2476 EDIT_WATER_INFO *info = water_info;
2477
2478 if (info != NULL) {
2479 int i = 0;
2480
2481 while (1) {
2482 if (info->wave[i].power == 0.0f && info->wave[i].range == 0.0f) {
2484 wave->row = (float) *(int *) arguments[0];
2485 wave->column = (float) *(int *) arguments[1];
2486 wave->range = *(float *) arguments[3];
2487 wave->power = *(float *) arguments[2];
2488 break;
2489 }
2490
2491 i++;
2492 }
2493 }
2494}
sceVu0FVECTOR min
Definition collision.hpp:29
sceVu0FVECTOR max
Definition collision.hpp:28
s16 foot_sound
Definition collision.hpp:56
void SetHeight(float height)
void SetFollow(float x, float y, float z)
void AddAngle(float delta)
void SetDistance(float distance)
void AddHeight(float delta)
virtual void Step(int steps)
Definition camera.cpp:13
void SetNextRef(CFrame *parent, float x, float y, float z)
Definition camera.cpp:141
void GetCameraMatrix(float(*matrix)[4])
Definition camera.cpp:153
void GetRef(float *ref)
Definition camera.cpp:234
void SetRef(CFrame *parent, float x, float y, float z)
Definition camera.cpp:124
void SetPos(CFrame *parent, float x, float y, float z)
Definition camera.cpp:103
void GetPos(float *pos)
Definition camera.cpp:230
void SetNextPos(CFrame *parent, float x, float y, float z)
Definition camera.cpp:118
void GetDir(float *dir)
Definition camera.cpp:147
void SetRoll(float roll)
Definition camera.cpp:226
void SetMotion(int no, int mode, float speed=-1.0f)
virtual void GetPosition(float *out_position)
virtual void LoadPackData2(unsigned int *pack, char *name, CDataAlloc2< 1 > *alloc, int texture_block_no, CDataAlloc2< 1 > *image_alloc, int visual_type)
virtual void SetScale(float x, float y, float z)
void SetFootSoundID(int id)
virtual void Step()
virtual void ShadowStep()
virtual void SetRotation(float x, float y, float z)
void FootSoundEnable(int on)
virtual void Initialize()
float body_height
virtual void Draw()
virtual void SetPosition(float x, float y, float z)
virtual void ClothStep(int step)
EDITPARTS_INFO * GetPartsInfo(int index)
char clip_enable
Definition frame.hpp:29
short alpha_ref
Definition frame.hpp:43
float clip_depth
Definition frame.hpp:28
char fog_enable
Definition frame.hpp:33
int On(int mask)
Definition gamepad.cpp:557
int AllOn()
Definition gamepad.cpp:465
void KeyLock(int mask)
Definition gamepad.cpp:501
int Down2(int mask)
Definition gamepad.cpp:601
float GetRYf()
Definition gamepad.cpp:537
int Down(int mask)
Definition gamepad.cpp:583
void SetAutoRepeat(int mask, int initial_delay, int repeat_delay)
Definition gamepad.cpp:485
float GetRXf()
Definition gamepad.cpp:533
void AutoRepeatOff()
Definition gamepad.cpp:609
char name[32]
GROUND_WATER_RIPPLE ripples[4]
sceVu0FVECTOR offset
CFrameVu1 * collision_frame
Definition op_b.cpp:90
int handle
Definition op_b.cpp:96
CFrameVu1 * shadow_frame
Definition op_b.cpp:91
int category_no
Definition title.cpp:134
CFrameVu1 * shade_frame
Definition op_b.cpp:92
CFrame * GetCollisionFrame()
Definition mapobject.cpp:12
CFrameVu1 * camera_frame
Definition op_b.cpp:93
virtual void SetPosition(float *position)
Definition mapparts.cpp:20
CFrame * ripple_frame
Definition mapparts.hpp:56
virtual void SetRotation(float x, float y, float z)
Definition mapparts.cpp:30
void DrawParts(float time, float *distance, int lowest, int highest, int *out_level)
Definition mapparts.cpp:335
EDIT_EFFECT_INFO * effect[MAP_PARTS_EFFECT_MAX]
Definition mapparts.hpp:73
s32 effect_on[MAP_PARTS_EFFECT_MAX]
Definition mapparts.hpp:72
virtual void Step()
virtual void Initialize()
virtual void ShadowStep()
CFrameVu1 * frame[4]
Definition op_b.cpp:76
virtual void GetRotation(float *out_rotation)
Definition object.cpp:116
CVector3_f_ rotation
Definition object.hpp:23
void GetDir(CObject &other, float *out_direction)
Definition object.cpp:25
virtual void SetVelocity(CVector3_f_ velocity)
Definition object.cpp:50
float GetDistance(CObject &other)
Definition object.cpp:16
float pos[4]
Definition object.hpp:18
s32 x
Definition rect.hpp:18
s32 width
Definition rect.hpp:20
s32 height
Definition rect.hpp:21
s32 y
Definition rect.hpp:19
int GetMapInitFlag(int map_no, int flag_no)
Definition savedata.cpp:391
int SetMapFlag(int map_no, int flag_no, int value)
Definition savedata.cpp:356
int SetMapInitFlag(int map_no, int flag_no, int value)
Definition savedata.cpp:420
void SetScript(char *script, int script_size)
void SetTAG(TAG_PARAM *tags, int count)
void Initialize(CTexAnimeData *records, int count)
void TexAnime(int texture_block)
void LoadCFGFile(char *script, int script_size)
static s32 stop_anime
u_long tex0
Definition texture.hpp:57
int CheckClip()
Definition water.cpp:303
s32 rows
Definition op_c.cpp:137
CFrameVu1 frame
Definition op_c.cpp:151
void DrawMesWin()
Definition clsmes.cpp:2619
s32 tex_block
Definition clsmes.hpp:227
int completion_flag
Definition op_a.cpp:210
CDataAlloc2< 1 > * WorkBuffer__2
Definition dataread.hpp:250
ED_SOUND_ID
Definition edit.hpp:132
@ ED_EVENT_RETURN_MAP_JUMP
Definition edit.hpp:18
@ ED_EVENT_RETURN_TALK
Definition edit.hpp:19
@ ED_EVENT_RETURN_OUTSIDE
Definition edit.hpp:17
@ ED_MENU_UNK_4
Definition edit.hpp:36
@ ED_MENU_BATTLE
Definition edit.hpp:34
@ ED_MENU_SHOP
Definition edit.hpp:35
@ ED_MENU_RESET
Definition edit.hpp:31
GameMode
Definition main.hpp:16
@ INTERPOLATE_STEP
Definition mathutil.hpp:15
char name[128]
Definition dataread.hpp:28
u_long128 * buffer
Definition dataread.hpp:29
EDITPARTS_ELEMENT elements[6]
float near_distance
Definition editloop.hpp:227
float far_distance
Definition editloop.hpp:228
float ambient[4]
Definition edit_in.hpp:16
OBJ_ANIME_SEQ obj_anime[32]
Definition edit_in.hpp:22
ED_EVENT_POINT event_points[32]
Definition edit_in.hpp:24
float light_direction[4][4]
Definition edit_in.hpp:17
EDIT_FOG_INFO fog
Definition edit_in.hpp:20
float background_colour[4]
Definition edit_in.hpp:19
EDIT_WATER_INFO water_surfaces[8]
Definition edit_in.hpp:26
char name[0x40]
Definition edit_in.hpp:12
EDIT_MOTION_PARTS_INFO motion_parts[4]
Definition edit_in.hpp:25
float projection
Definition edit_in.hpp:14
EDIT_EFFECT_INFO effects[32]
Definition edit_in.hpp:23
float light_colour[4][4]
Definition edit_in.hpp:18
sceVu0FVECTOR corner_c
Definition editloop.hpp:177
EDIT_WATER_WAVE_INFO wave[4]
Definition editloop.hpp:185
sceVu0FVECTOR corner_b
Definition editloop.hpp:176
sceVu0FVECTOR ripple_params
Definition editloop.hpp:182
char name[0x10]
Definition editloop.hpp:170
sceVu0FVECTOR corner_a
Definition editloop.hpp:175
float current_time
Definition edit.hpp:179
s32 npc_foot_sound[16]
Definition edit.hpp:172
sceVu0FMATRIX light_color
Definition edit.hpp:210
s32 npc_collision[16]
Definition edit.hpp:169
CMapParts * interior_parts
Definition edit.hpp:188
s32 suppress_shadows
Definition edit.hpp:200
s32 player_collision
Definition edit.hpp:163
s32 player_foot_sound
Definition edit.hpp:166
s32 lighting_override
Definition edit.hpp:207
s32 reset_camera_angle
Definition edit.hpp:157
s32 map_jump_bgm_stop
Definition edit.hpp:152
s32 interior_parts_count
Definition edit.hpp:187
s32 suppress_background
Definition edit.hpp:199
s32 return_code
Definition edit.hpp:217
sceVu0FMATRIX light_direction
Definition edit.hpp:209
sceVu0FVECTOR ambient_color
Definition edit.hpp:211
CCharacter * player
Definition editloop3.hpp:37
CCamera * view_camera
Definition edit.hpp:87
CCameraFollow * camera
Definition edit.hpp:86
CCharacter * chara
Definition edit.hpp:85
ED_EVENT_POINT * points
Definition edit.hpp:97
CMapParts * parts
Definition edit.hpp:92
CMapParts * parts
Definition objanime.hpp:100
u_int words[sizeof(EPARTS_FUNC_DATA)/sizeof(u_int)]
Definition edit_in.cpp:96
EPARTS_FUNC_DATA * func
sceVu0FVECTOR max
Definition edit_in.cpp:72
sceVu0FVECTOR min
Definition edit_in.cpp:73