DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
editloop.cpp
1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3#pragma name_counter 414
4#ifdef PAL
5#pragma argument_flag 0
6#pragma argument_flag_ones 118, 119, 120, 243, 245, 256, 263, 265, 275, 277
7#pragma argument_flag_ones 287, 289, 299, 301, 312, 344, 360, 371, 433, 434
8#pragma argument_flag_ones 435, 596, 630, 636, 784, 793, 864, 868, 930, 1014
9#pragma argument_flag_ones 1018, 1038, 1082, 1122, 1223, 1358, 1359, 1360, 1361, 1389
10#pragma argument_flag_ones 1390, 1507, 1512, 1538, 1546, 1547, 1551, 1564, 1632, 1633
11#pragma argument_flag_ones 1634, 1635, 1710, 1722, 1742, 1744, 1792, 1799, 1806, 1813
12#pragma argument_flag_ones 1820, 1827, 1834, 1841, 1848, 1855, 1862, 1869, 1876, 1903
13#pragma argument_flag_ones 1905, 1920, 1922, 1931, 1933, 1953, 2204, 2205, 2206, 2341
14#pragma argument_flag_ones 2342, 2343, 2348, 2405, 2684, 2825, 2879, 2889, 2917, 2932
15#pragma argument_flag_ones 2948, 2950, 2952, 2967, 2977, 3091, 3142, 3144, 3177, 3179
16#pragma argument_flag_ones 3182, 3192, 3377, 3605, 3613, 3621, 3629, 3646, 3652, 3760
17#pragma argument_flag_ones 3790, 3792, 3793, 3795, 3796, 3797, 3800, 3802, 3803, 3805
18#pragma argument_flag_ones 3806, 3807, 3810, 3812, 3813, 3815, 3816, 3817, 3820, 3822
19#pragma argument_flag_ones 3823, 3825, 3826, 3827, 3830, 3832, 3833, 3835, 3836, 3837
20#pragma argument_flag_ones 3840, 3842, 3843, 3845, 3846, 3847
21#else
22#pragma argument_flag_ones 0, 207, 208, 215, 626
23#endif
24
25#include "common.h"
26
27#include <libgraph.h>
28#include <libpkt.h>
29#include <libvu0.h>
30#include <sifdev.h>
31
32#include <cmath>
33#include <cstdio>
34#include <cstdlib>
35#include <cstring>
36
37#include "boxvu0.hpp"
38#include "camera.hpp"
39#include "camerafollow.hpp"
40#include "character.hpp"
41#include "clsmes.hpp"
42#include "collision.hpp"
43#include "dataalloc.hpp"
44#include "dataread.hpp"
45#include "dataset.hpp"
46#include "debugfont.hpp"
47#include "dngstatusdata.hpp"
48#include "ebattle.hpp"
49#include "edit.hpp"
50#include "edit_in.hpp"
51#include "editarea.hpp"
52#include "editground.hpp"
53#include "editloop.hpp"
54#include "editloop3.hpp"
55#include "editmapscript.hpp"
56#include "editpartsinfo.hpp"
57#include "effect.hpp"
58#include "effectgroup.hpp"
59#include "frame.hpp"
60#include "framevu1.hpp"
61#include "gamemode.hpp"
62#include "gamepad.hpp"
63#include "mainselect.hpp"
64#include "mapparts.hpp"
65#include "mathutil.hpp"
66#include "mds.hpp"
67#include "menu_misc.hpp"
68#include "menuitemstep.hpp"
69#include "mglib.hpp"
70#include "npcharacter.hpp"
71#include "objanime.hpp"
72#include "objectframe.hpp"
73#include "rect.hpp"
74#include "runeffect.hpp"
75#include "savedata.hpp"
76#include "snd.hpp"
77#include "sysmes.hpp"
78#include "texture.hpp"
79
80/* Retail editloop.cpp: town-script parsing, map construction and pre-event editor state. */
81
82void BtSetMapJumpFloor(int floor);
83
84#include "battlemenu.hpp"
85#include "editmenu.hpp"
86#include "effectmacro.hpp"
87#include "fishing.hpp"
88#include "gameutil.hpp"
89#include "memcard.hpp"
90#include "menu_draw.hpp"
91#include "menuetc.hpp"
92#include "nowload.hpp"
93#include "vutext.hpp"
94#include "weaponlevelup.hpp"
95#include "wind.hpp"
96
97CTexture *StayTexture;
98int NowEditMap;
99u_long128 *EdNPCReadBuffer;
100int EdStepTimeFlag;
101int EdInteriorFlag;
102int EdInteriorPartsNo;
103int EdInteriorJumpID;
104int EdInteriorDoorSound;
105int EdInteriorStartEvent;
106int EdBeforeInBgmNo;
107
108ED_EXCHANGE_INFO EdExchangeInfo;
109EDIT_MENU_STATUS EditMenuStatus;
110CEditPartsInfo EditPartsInfo;
111EDIT_ELEMENT_INFO EditElementInfo[36];
112CDataAlloc2<1> EdInteriorBuffer(-1);
113CDataAlloc2<1> EdNPCBuffer(-1);
114CDataAlloc2<1> EdVillagerBuffer(-1);
115CDataAlloc2<1> EdEventBuffer(-1);
116CDataAlloc2<1> EdEventExBuffer(-1);
117CDataAlloc2<1> EdMesBuffer(-1);
118CDataAlloc2<1> EdScriptBuffer(-1);
119CDataAlloc2<1> EdExtMessBuffer(-1);
120CDataAlloc2<1> EdWorkBuffer(-1);
121CDataAlloc2<1> EdMenuBuffer(-1);
122char EditDataDir[0x100];
123char EditMapName[0x20];
124char EdInteriorName[0x20];
125
126CEffectGroup EdEffectGroup;
128CEffect *EffectTable__3;
130static int D_002A2844;
132static int D_002A2848;
134static int D_002A284C;
135EDIT_MAP_INFO *EditMapInfo;
136char *EdEventData;
137char *EdSystemEventData;
138int EdDrawOffFlag;
139int EdDrawOffMap;
140int EdDrawOffMapShadow;
141int EdThunderEffectFlag;
142int EdPauseFlag;
143int clear_screen;
144int key_lock;
145int goto_dungeon;
146int exit_loop;
148int loop_counter;
150int key_counter;
152int goto_menu;
154int goto_return_menu;
155int sound_off_cnt;
156int debug_menu_mode;
157int goto_cmp_event;
158int goto_cmp_event_level;
159int change_time_event;
160int draw_npc_cursor;
161int draw_clock;
162int edit_mode_draw;
163int edit_mode_grd_draw;
164int depth_of_field;
165int edit_mode_lighting;
166int draw_sky;
168int start_event_no;
170int start_system_event;
171int move_count;
172int interior_test;
173char **interior_name;
174int oldGameMode;
175CEditGround *pEditGround;
176CEditArea *EditArea;
177CMapParts *ObjParts;
178CMapParts *RiverParts;
179CMapParts *RoadParts;
181CCharacter *MotionParts;
183CCamera *NowCamera;
185float NowTime;
186CFrameVu1 *SkyBackFrame;
187CFrame *CharaCursor0;
188CFrame *CharaCursor1;
189CFrame *CharaCursor2;
190CFrameVu1 *TreasureCursor;
191CFrameVu1 *TreasureCursorOpen;
192int end_counter;
193int bgm_vol;
194int bgm_play_flag;
195int bgm_play_start;
197int door_open_cnt;
198int door_open;
199int fix_pos_enble;
200int talk_villager;
201int chg_time_cnt;
202int NowSelectAngle;
203int OldSelectAngle;
204float NowCursorRotY;
205CMapParts *NowFocusParts;
206CMapParts *OldFocusParts;
207int DrawPartsNameCount;
208
209CWind EdWind;
210ClsMes EditMes1;
211ClsMes EditMes2;
212ClsMes EditEventMes1;
213ClsMes EditEventMes2;
214ClsMes EditNameMes;
215ClsMes EditSystemMes;
216ClsMes EditHelpMes;
217CNPCharacter EdVillager[10];
218VILLAGER_INFO EdVillagerInfo[10];
220CDebugFont DebugFont__3;
221EDIT_FOG_INFO now_fog;
222CDataAlloc2<1> EPartsInfoBuff(-1);
223CMainChara MainChara;
224CRunEffect RunEffect;
225/* The six cameras' destructor records carry retail's names, @372 to @377. */
226#pragma name_counter 372
228CCameraFollow MainCamera(60.0f, 20.0f, 0.0f, 4.0f);
229CCameraFollow EditCamera(60.0f, 20.0f, 0.0f, 4.0f);
230CCameraFollow IntroCamera(60.0f, 20.0f, 0.0f, 4.0f);
232CCameraFollow TalkCamera(60.0f, 20.0f, 0.0f, 4.0f);
234CCameraFollow EventCamera(60.0f, 20.0f, 0.0f, 4.0f);
236CCameraFollow ViewCamera(60.0f, 20.0f, 0.0f, 4.0f);
237#pragma name_counter 471
238CFrameVu1 *SkyFrame[4];
239CFrame *SunFrame[4];
241C3DSprite SystemEffect[8];
243sceVu0FVECTOR fix_chara_pos;
245sceVu0FVECTOR fix_chara_rot;
246sceVu0FVECTOR fix_camera_pos;
247char interior_map_name[0x40];
248float NowPartsCursorPos[4];
250static CFrameVu1 ecursorframe;
251sceVu0FVECTOR NowCursorPos;
252sceVu0FVECTOR NextCursorPos;
254CTextureAnime TexAnime;
256CTexAnimeData TexAnimeData[64];
258CTexAnimeData CharaTexAnimeData[0x80];
260CDataAlloc2<1> DataBuffer__2(-1);
261CDataAlloc2<1> CharaBuffer(-1);
262CDataAlloc2<1> InteriorBuffer(-1);
263CDataAlloc2<1> EtcDataBuffer(-1);
264
266CCharacter *Chara = &MainChara;
268int camera_dist_mode = 1;
269int NowSelectParts = -1;
270CFrame *ECursorFrame = &ecursorframe;
271int PartsNameNum = -1;
272
273/* editloop's own functions, in the order the unit defines them; the prototypes
274 * let each call ahead of its definition. */
275void CopyCMapParts(CMapParts *to, CMapParts *from, CDataAlloc2<1> *arena);
276EPARTS_INFO_HEADER *LoadPTS(CMapParts *parts, unsigned int *archive, MAP_PARTS_INFO *info, OBJ_ANIME_SEQ *anime, EDIT_EFFECT_INFO *effects, EDIT_OBJECT_TIMER *timers, ED_EVENT_POINT *points, CMapParts *shared);
277void LoadPTS(CMapParts *parts, MAP_PARTS_INFO *info, OBJ_ANIME_SEQ *anime, EDIT_EFFECT_INFO *effects, EDIT_OBJECT_TIMER *timers, ED_EVENT_POINT *points);
278u_int *SearchPTS(u_int *archive, char *name);
279int LoadEditMapData(EDIT_MAP_INFO *info, char *name, int kind);
280void LoadObjectParts();
281void LoadGroundData();
282int LoadTexture();
283int CheckEditToWalk(float *position);
284int GotoInterior(char *name, int entrance, int direction, ED_EVENT_PARAM *param, int start_event);
285void MoveEditCursor();
286void VillagerCollision();
287void MoveChara();
288void MainEditMode();
289void OpenDoorMode();
290void TalkMode();
291void EventMode();
292void MainDraw();
293void EditPartsObjectOnOff();
294void MainMode();
295void EditMode();
296void PlayAmbient(float volume);
297
298/* The ground the player has built on one map, as the save holds it. */
300 u8 unk_00[0x64];
302};
303
304void EBDraw();
305
309void GetLanguageName(char *name) {
310 if (LanguageCode > LANG_JAPANESE) {
311 sprintf(name, "_%d", LanguageCode);
312 } else {
313 *name = '\0';
314 }
315}
316
320void GetEditDataDir(char *name) {
321 strcpy(name, EditDataDir);
322}
323
327void LoadScript() {
328 char common_path[0x40];
329 char map_path[0x40];
330 char language[0x1c];
331 int size;
332 char *map_script;
333
334 EdScriptBuffer.used = 0;
335 EdEventData = (char *) (EdScriptBuffer.base + EdScriptBuffer.used * 16);
336 sprintf(language, "_%d.mes", LanguageCode);
337 GetEditDataDir(common_path);
338 GetEditDataDir(map_path);
339 strcat(common_path, "event.stb");
340 strcat(map_path, EditMapName);
341 strcat(map_path, language);
342
343 if (LoadFile2(common_path, EdEventData, &size, 0) != 0) {
344 EdScriptBuffer.Alloc((size >> 4) + 1);
345 map_script = (char *) (EdScriptBuffer.base + EdScriptBuffer.used * 16);
346
347 if (LoadFile2(map_path, map_script, &size, 0) != 0) {
348 EdScriptBuffer.Alloc((size >> 4) + 1);
349 } else {
350 map_script = NULL;
351 }
352
353 EdSetEventScript(EdEventData, map_script, &EdScriptBuffer);
354 } else {
355 EdEventData = NULL;
356 }
357
358 EdScriptBuffer.Align64();
359 EdSystemEventData = (char *) (EdScriptBuffer.base + EdScriptBuffer.used * 16);
360
361 if (LoadFile2("gedit/system/event.stb", EdSystemEventData, &size, 0) != 0) {
362 EdScriptBuffer.Alloc((size >> 4) + 1);
363 return;
364 }
365
366 EdSystemEventData = NULL;
367}
368
372static int RunEvent(int event_no, CCamera *camera) {
373 sceVu0FVECTOR position;
374 sceVu0FVECTOR reference;
375
376 if (start_event_no > 0 && simple_event == 0) {
377 return 0;
378 }
379
380 if (camera != NULL) {
381 camera->GetPos(position);
382 camera->GetRef(reference);
383 EventCamera.SetPos(position);
384 EventCamera.SetRef(reference);
385 EventCamera.FollowOff();
386 EventCamera.SetRoll(0.0f);
387 }
388
389 start_event_no = event_no;
390 return 1;
391}
392
396static void RunSystemEvent(int event_no, CCamera *camera) {
397 sceVu0FVECTOR position;
398 sceVu0FVECTOR reference;
399
400 start_event_no = -1;
401
402 if (start_system_event <= 0) {
403 if (camera != NULL) {
404 camera->GetPos(position);
405 camera->GetRef(reference);
406 EventCamera.SetPos(position);
407 EventCamera.SetRef(reference);
408 EventCamera.FollowOff();
409 }
410
411 start_system_event = event_no;
412 }
413}
414
418int FadeOutToEvent(int event_no, int level) {
419 if (EdDebugEventEnable == 0) {
420 return 0;
421 }
422
423 if (goto_cmp_event != 0) {
424 if (level > goto_cmp_event_level) {
425 } else {
426 return 0;
427 }
428 }
429
430 goto_cmp_event = event_no;
431 goto_cmp_event_level = level;
432 float zero = 0.0f;
433 EdFadeOut(60, zero, zero, zero);
434 return 1;
435}
436
440void EditSave() {
441 int map_no = MapNo;
442
443 if (map_no < TOWN_COUNT && map_no >= 0) {
444 pEditGround->Save(NowEditMap, SaveData);
445 EditPartsInfo.Save(NowEditMap, SaveData);
446 }
447
448 EDIT_MAP_INFO *info = EditMapInfo;
449
450 if (info != NULL && info->time_stop == 0) {
451 SaveData->SetNowTime(NowTime);
452 }
453}
454
458void EditLoad() {
459 if (MapNo < TOWN_COUNT) {
460 EditPartsInfo.Load(NowEditMap, SaveData, 0);
461 pEditGround->Load(NowEditMap, SaveData);
462 }
463
464 EditPartsObjectOnOff();
465 pEditGround->MakePartsBox();
466 NowTime = 0.01f * (float) ((int) (100.0f * SaveData->GetNowTime()) % 1200);
467}
468
472void EditExit() {
473 sceVu0FVECTOR fade;
474
475 EditSave();
476 MGSetBGColor(0.0f, 0.0f, 0.0f, 128.0f);
477 StopAllSound();
478
479 while (ReadBGSync() != 0) {
480 }
481
482 SndAmbientStop();
483
484 if (EdEventInfo.map_jump_bgm_stop != 0) {
485 SndBgmFadeOutStop();
486 SndBgmStop();
487 SndBgmInit();
488 }
489
490 EdStopSoundSrc();
491 SndStopAllSe();
492 SndStep();
493 MGScisioringForce(0);
494 GamePad.KeyLock(0);
495 EdGetFadeColor(fade);
496 MGSetBGColor(fade);
497}
498
502void InitWorkBuffer() {
503 int quads = EdNPCBuffer.used;
504 u_char *free_start = EdNPCBuffer.base + quads * 16;
505 quads = EdNPCBuffer.limit - quads;
506 EdVillagerBuffer.base = free_start;
507 EdVillagerBuffer.limit = quads;
508 EdVillagerBuffer.used = 0;
509 free_start = (u_char *) ((((int) free_start >> 6) + 1) << 6);
510 EdWorkBuffer.base = free_start;
511 EdWorkBuffer.limit = quads - 4;
512 EdWorkBuffer.used = 0;
513 free_start = (u_char *) read_buffer;
514 EdMenuBuffer.base = free_start - 0x180000;
515 EdMenuBuffer.limit = 0x3A2E0;
516 EdMenuBuffer.used = 0;
517}
518
522int run_event_check() {
523 if (goto_dungeon != 0 || goto_menu != 0 || goto_cmp_event != 0 || debug_menu_mode != 0 || EdSystemMesCheck() != 0 || EdCheckItemOver() != 0) {
524 return 1;
525 }
526
527 return 0;
528}
529
533void CheckKeyLock() {
534 if (run_event_check() != 0) {
535 key_lock = true;
536 }
537
538 if (key_lock != 0 || loop_counter < 2) {
539 EdSetKeyMode(0);
540 }
541}
542
546void EdSetFlag() {
547 key_lock = false;
548
549 if (run_event_check() != 0) {
550 key_lock = true;
551 }
552
553 if (key_lock != 0) {
554 EdSetKeyMode(0);
555 } else {
556 EdSetKeyMode(0xFFFF);
557 }
558
559 draw_npc_cursor = GameMode == ED_MODE_WALK;
560
561 if (key_lock != 0) {
562 draw_npc_cursor = 0;
563 }
564
565 EDIT_CONFIG_VIEW *config = (EDIT_CONFIG_VIEW *) SaveData->GetConfigData();
566
567 draw_clock = !(bool) config->clock_hidden;
568
569 if (key_lock != 0) {
570 draw_clock = 0;
571 }
572}
573
577int EdGetMapFlag(int flag_no) {
578 if (flag_no <= 0) {
579 return 0;
580 }
581
582 return SaveData->GetMapFlag(MapNo, flag_no);
583}
584
588int EdSetMapFlag(int flag_no, int value) {
589 if (flag_no <= 0) {
590 return 0;
591 }
592
593 return SaveData->SetMapFlag(MapNo, flag_no, value);
594}
595
599void PauseOffCheck() {
600 if (run_event_check() != 0) {
601 goto_return_menu = 0;
602 }
603}
604
608int EdExitLoop() {
609 return exit_loop = 1;
610}
611
615void EdDrawOffAll() {
616 EdDrawOffFlag = 1;
617}
618
622void EdDrawOnAll() {
623 EdDrawOffFlag = 0;
624}
625
629float EdGetClock() {
630 return InvertTime(NowTime);
631}
632
636void EdSetClock(float time) {
637 if (time < 0.0f || !(time <= 24.0f)) {
638 return;
639 }
640
641 NowTime = ConvertTime(time);
642}
643
647void EdInitMesParam() {
648 float text_rate;
649 EDIT_CONFIG_VIEW *config = (EDIT_CONFIG_VIEW *) SaveData->GetConfigData();
650
651 if (config->message_speed != 0) {
652 text_rate = 0.6f;
653 } else {
654 text_rate = 0.3f;
655 }
656
657 EditMes1.columns = 21;
658 EditMes1.rows = 4;
659 EditMes1.text_rate = text_rate;
660 EditMes1.text_rate_set = text_rate;
661 EditMes1.tex_block = 26;
662 EditMes1.style = MES_EDGE_NONE;
663 EditMes1.page_arrow = false;
664 EditMes1.centre_rows = true;
665 float fade_speed = 0.1f;
666 EditMes1.fade_speed = fade_speed;
667 EditMes1.page_arrow = true;
668
669 EditEventMes1.columns = 21;
670 EditEventMes1.rows = 4;
671 EditEventMes1.text_rate = text_rate;
672 EditEventMes1.text_rate_set = text_rate;
673 EditEventMes1.tex_block = 26;
674 EditEventMes1.style = MES_EDGE_NONE;
675 EditEventMes1.page_arrow = false;
676 EditEventMes1.centre_rows = true;
677 EditEventMes1.fade_speed = fade_speed;
678 EditEventMes1.page_arrow = true;
679
680 EditSystemMes.Preset(MES_PRESET_SYSTEM);
681 EditSystemMes.fukidashi = false;
682 EditSystemMes.stay_frame = true;
683 EditSystemMes.text_rate = 0.0f;
684 EditSystemMes.text_rate_set = 0.0f;
685 EditSystemMes.page_arrow = false;
686 EditSystemMes.fade_speed = 1.0f;
687 EditSystemMes.columns = 26;
688 EditSystemMes.rows = 1;
689 EditSystemMes.centre_rows = false;
690 EditSystemMes.style = MES_EDGE_TABLE;
691
692 EditNameMes.Preset(MES_PRESET_NAME);
693 EditNameMes.tex_block = 26;
694 EditNameMes.rows = 4;
695 EditNameMes.fukidashi = false;
696 EditNameMes.stay_frame = false;
697 EditNameMes.style = MES_EDGE_TABLE;
698}
699
703int EditInit(void *param) {
704 char map_path[0x80];
705 char save_path[0x80];
706 int size;
707 int mes_size;
708
709 oldGameMode = ED_MODE_NONE;
710 NowTime = 0.0f;
711 SaveData->VisitMap(MapNo, 1);
712 PlayTimeCountFlag(1);
713 MGFlipWaitVSync(0);
714 EdSetKeyMode(0xFFFF);
715 GamePad.MenuModeOff();
716 GamePad.AutoRepeatOff();
717 int map_no = MapNo;
718 NowEditMap = map_no;
719 interior_test = 0;
720
721 if (map_no < 9) {
722 sprintf(EditMapName, "e0%d", map_no + 1);
723 }
724
725 int map_id = MapNo;
726
727 if (map_id > 10) {
728 int interior = map_id - 10;
729
730 if (interior < 10) {
731 sprintf(EditMapName, "s0%d", interior);
732 } else {
733 sprintf(EditMapName, "s%d", interior);
734 }
735 }
736
737 if (NowEditMap == 99) {
738 strcpy(EditDataDir, "");
739 interior_test = 1;
740 } else {
741 strcpy(EditDataDir, "gedit/");
742 strcat(EditDataDir, EditMapName);
743 strcat(EditDataDir, "/");
744 }
745
746 bgm_play_flag = 0;
747 bgm_play_start = 0;
748 InitializeDataBuffer();
749 SetDataBuffer(&VisualData, 100);
750 SetDataBuffer(&EtcDataBuffer, 40000);
751#ifdef PAL
752 SetDataBuffer(&EdScriptBuffer, 20000);
753#else
754 SetDataBuffer(&EdScriptBuffer, 16000);
755#endif
756 SetDataBuffer(&EPartsInfoBuff, 8000);
757 SetDataBuffer(&CharaBuffer, 115000);
758 SetDataBuffer(&TextureData, 10);
759 SetDataBuffer(&MotionData, 7900);
760 SetDataBuffer(&EdMesBuffer, 13000);
761 SetDataBuffer(&DataBuffer__2, 1216000);
762 EdNPCBuffer.base = DataBuffer__2.base + DataBuffer__2.used * 16 + 0xCF8500;
763 EdNPCBuffer.limit = 326000;
764 EdNPCBuffer.used = 0;
765 SetPacketReadBuffer(30000, 140000);
766 EPartsInfoBuff.used = 0;
767 EditArea = new ((u_long128 *) EtcDataBuffer.Alloc(0x81C)) CEditArea[4];
768 pEditGround = new ((u_long128 *) EtcDataBuffer.Alloc(0x2097)) CEditGround;
769 ObjParts = new ((u_long128 *) EtcDataBuffer.Alloc(0x3F1)) CMapParts[24];
770 MotionParts = new ((u_long128 *) EtcDataBuffer.Alloc(0x470)) CCharacter[4];
771 RiverParts = new ((u_long128 *) EtcDataBuffer.Alloc(0x2B0)) CMapParts[16];
772 RoadParts = new ((u_long128 *) EtcDataBuffer.Alloc(0x102)) CMapParts[6];
773 float near_clip = 10.0f;
774 MGSetRenderInfo(800.0f, near_clip, 65535.0f);
775 GetEditDataDir(map_path);
776 strcat(map_path, "mapinfo.cfb");
777 EditMapInfo = (EDIT_MAP_INFO *) EtcDataBuffer.Alloc(0x2C27);
778 EdInInfo = (EDIT_IN_INFO *) EtcDataBuffer.Alloc(0x44D);
779
780 if (interior_test == 0) {
781 LoadEditMapData(EditMapInfo, map_path, MapNo);
782 } else {
783 LoadEditMapData(EditMapInfo, "gedit/interior/mapinfo.cfg", MapNo);
784 LoadFile("gedit/interior/interior.cfg", read_buffer, &size);
785 int c;
786 int column;
787 int row;
788 int count;
789 int read_pos;
790 u8 *text;
791
792 text = (u8 *) read_buffer;
793 read_pos = 0;
794 count = size;
795 column = 0;
796 row = 0;
797
798 while (c = text[read_pos++], (count < read_pos) ? 0 : 1) {
799 if (c >= 'a' && c < '{') {
800 interior_name[row][column] = c;
801 column++;
802 continue;
803 }
804
805 if (c >= '0' && c < ':') {
806 interior_name[row][column] = c;
807 column++;
808 continue;
809 }
810
811 if (c == '/' || c == '_') {
812 interior_name[row][column] = c;
813 column++;
814 continue;
815 }
816
817 if (column > 1) {
818 interior_name[row][column] = '\0';
819 column = 0;
820 row++;
821 }
822
823 if (row >= 63) {
824 break;
825 }
826 }
827
828 interior_name[row][0] = '\0';
829 }
830
831 SndSetReadBuffer(read_buffer);
832
833 if (StartEventNo < 0) {
834 int bgm = EditMapInfo->bgm_no;
835
836 if (bgm >= 0) {
837 if (old_main_mode == 5) {
838 SndBgmLoad(0);
839 } else {
840 SndBgmLoad(bgm);
841 }
842
843 if (EditMapInfo->time_stop == 0) {
844 EdSetBgmVol(SaveData->GetNowTime());
845 } else {
846 SndBgmPlay(0);
847 }
848
849 SndStep();
850 }
851 }
852
853 int sound_set = EditMapInfo->sound_set_no;
854
855 if (sound_set < 0) {
856 if (SndGetNowSetNo() < 0) {
857 SndSoundLoad(0);
858 }
859 } else {
860 SndSoundLoad(sound_set);
861 }
862
863 EdInitSoundSrc();
864 EdEventInfo.world_coord_enable = false;
865 EdEventInfo.main_character = Chara;
866 EdEventInfo.main_texture_animation = CharaTexAnimeData;
867 EdEventInfo.main_texture_animation_count = 128;
868 EdEventInfo.npcs = EdVillager;
869 EdEventInfo.npc_count = 10;
870 EdEventInfo.messages[0] = &EditMes1;
871 EdEventInfo.villagers = EditMapInfo->villagers;
872 CEditGround *ground = pEditGround;
873 EdEventInfo.edit_ground = ground;
874 EdEventInfo.fixed_parts_count = 64;
875 EdEventInfo.fixed_parts = ground->fixed_parts;
876 EdEventInfo.edit_parts_count = 24;
877 EdEventInfo.edit_parts = ObjParts;
878 EdEventInfo.player_texture_block = 8;
879 EdEventInfo.npc_texture_block = 54;
880 EdEventInfo.messages[0] = &EditMes1;
881 EdEventInfo.messages[1] = &EditEventMes1;
882 EdEventInfo.messages[4] = &EditSystemMes;
883 EdInitEventParam();
884 EdEventData = NULL;
885 simple_event = 0;
886 LoadScript();
887 now_fog = EditMapInfo->fog[0];
888 MainCamera.SetFollow(0.0f, 0.0f, 0.0f);
889 MainCamera.Step(10);
890 MainCamera.SetSpeed(7.0f);
891 EditCamera.SetFollow(0.0f, 0.0f, 0.0f);
892 EditCamera.SetSpeed(8.0f);
893 EditCamera.snap_range = 1.0f;
894 EditCamera.Step(10);
895 MainCamera.SetHeight(-10.0f);
896 MainCamera.FollowOff();
897 LoadTexture();
898
899 if (interior_test == 0) {
900 LoadGroundData();
901 }
902
903 EdSetDOF((DEPTH_OF_FIELD_INFO *) &EditMapInfo->dof_start_time);
904 camera_dist_mode = 1;
905 NowCamera = &MainCamera;
906 EditMenuStatus.mode = EDIT_MENU_MODE_CLOSED;
907 EditMenuStatus.parts = -1;
908 DebugFont__3.texture_name = "font_buff";
909 DebugFont__3.x = 16;
910 DebugFont__3.y = 16;
911 DebugFont__3.width = 280;
912 DebugFont__3.height = SCREEN_HALF_HEIGHT;
913 DebugFont__3.alpha = 64;
914 EdDSetFont(&DebugFont__3);
915
916 if (interior_test == 0) {
917 if (old_main_mode != 7 || main_select_padrup != 0) {
918 EditLoad();
919 } else {
920 GetEditDataDir(save_path);
921 strcat(save_path, "gdata0.edt");
922 int loaded = LoadFile2(save_path, read_buffer, NULL, 0);
923
924 for (int i = 0; i < 22; i++) {
925 EditPartsInfo.parts[i].obtained = 1;
926 EDITPARTS_INFO *info = EditPartsInfo.GetPartsInfo(i);
927
928 for (int j = 0; j < 6; j++) {
929 info->elements[j].enabled = true;
930 }
931 }
932
933 for (int i = 0; i < 36; i++) {
934 EditElementInfo[i].element_no = i % 15 + 1;
935 }
936
937 // clang-format off
938 short element_table[40] = {
939 0, 3, 12, 0, 11, 4, 1, 0, 16, 2, 0, 5, 17, 6, 1, 10, 2, 2, 0, 15,
940 1, 1, 1, 2, 1, 2, 12, 3, 14, 7, 8, 9, 1, 2, 1, 8, 13, 0, 0, -1,
941 };
942 // clang-format on
943 short *element_data = SaveData->GetElemData(0);
944
945 if (loaded != 0) {
946 pEditGround->Load((char *) read_buffer);
947 }
948
949 pEditGround->MakePartsBox();
950
951 for (int i = 0; i < 128; i++) {
952 *element_data = -1;
953 element_data++;
954 }
955 }
956
957 EditPartsObjectOnOff();
958 }
959
960 pEditGround->RemakeGrid();
961 GameMode = ED_MODE_UNK_0;
962 EdMoveCharaInit();
963 end_counter = 0;
964 door_open_cnt = 0;
965 EdStepTimeFlag = 1;
966 int free_start = (int) DataBuffer__2.base + (int) (DataBuffer__2.used * 16);
967 int free_quads = DataBuffer__2.limit - DataBuffer__2.used;
968
969 if (free_quads < 326000) {
970 printf("Allocation error!!\n");
971 }
972
973 int misalign = free_start & 0x3F;
974
975 if (free_start < 0 && misalign != 0) {
976 misalign -= 0x40;
977 }
978
979 if (misalign != 0) {
980 free_start += ((0x40 - misalign) >> 4) * 16;
981 }
982
983 EdNPCBuffer.base = (u_char *) free_start;
984 EdNPCBuffer.limit = free_quads - 4;
985 EdNPCBuffer.used = 0;
986 EdVillagerBuffer.base = (u_char *) free_start;
987 EdVillagerBuffer.limit = free_quads - 4;
988 EdVillagerBuffer.used = 0;
989 EdNPCReadBuffer = (u_long128 *) (EdNPCBuffer.base + EdNPCBuffer.used * 16 + (free_quads >> 1) * 16);
990 int read_misalign = (int) EdNPCReadBuffer & 0x3F;
991
992 if ((int) EdNPCReadBuffer < 0 && read_misalign != 0) {
993 read_misalign -= 0x40;
994 }
995
996 if (read_misalign != 0) {
997 EdNPCReadBuffer += (0x40 - read_misalign) >> 4;
998 }
999
1000 EdCreateVillagerTable(EditMapInfo);
1001 EdInitVillagerControl();
1002 EdInitVillagerTable(NowTime, EditMapInfo);
1003 EdLoadMainChara("chara/c01d.chr", "info.cfg", &CharaBuffer);
1004 sceVu0FVECTOR start_position = {0.0f, 0.0f, 0.0f, 1.0f};
1005 sceVu0FVECTOR start_rotation = {0.0f, 0.0f, 0.0f, 0.0f};
1006 sceVu0FVECTOR fade;
1007 GameMode = ED_MODE_WALK;
1008 EdGetFadeColor(fade);
1009 EdFadeIn(128, (float) (int) fade[0], (float) (int) fade[1], (float) (int) fade[2]);
1010 Chara->SetPosition(start_position);
1011 Chara->SetRotation(start_rotation);
1012 float yaw = start_rotation[1] - PI_SHORT;
1013
1014 if (yaw < PI_SHORT) {
1015 yaw -= TWO_PI;
1016 }
1017
1018 MainCamera.SetAngleSoon(yaw);
1019 MainCamera.SetFollow(start_position[0], 14.0f + start_position[1], start_position[2]);
1020 MainCamera.Step(-1);
1021 EffectTable__3 = (CEffect *) EtcDataBuffer.Alloc(0x800);
1022 EdEffectGroup.Initialize(EffectTable__3, 128);
1023 EdEffectGroup.Clear();
1024 EdInitMesParam();
1025 EditMes1.tex_block = 26;
1026 EditEventMes1.tex_block = 26;
1027 EditMes1.tex_buff = MesWinTexBuff_01;
1028 EditEventMes1.tex_buff = MesWinTexBuff_02;
1029 short *talk_mes = (short *) (EdMesBuffer.base + EdMesBuffer.used * 16);
1030 char mes_path[0x40];
1031 char sys_path[0x40];
1032 char language[0x10];
1033 GetEditDataDir(sys_path);
1034 GetEditDataDir(mes_path);
1035 strcat(mes_path, EditMapName);
1036 strcat(mes_path, "talk");
1037 GetLanguageName(language);
1038 strcat(mes_path, language);
1039 strcat(mes_path, ".mes");
1040 strcat(sys_path, "fconv.bin");
1041
1042 if (LoadFile2(mes_path, talk_mes, &mes_size, 0) == 0 && LoadFile2(sys_path, talk_mes, &mes_size, 0) == 0) {
1043 LoadFile("gedit/e01/fconv.bin", talk_mes, &mes_size);
1044 }
1045
1046 EdMesBuffer.Alloc((mes_size >> 4) + 1);
1047 EditMes1.SetBuff(talk_mes);
1048 EdMesBuffer.Align64();
1049 short *system_mes = (short *) (EdMesBuffer.base + EdMesBuffer.used * 16);
1050#ifdef PAL
1051 sprintf(mes_path, "gedit/system/editsys%s.mes", language);
1052 LoadFile(mes_path, system_mes, &mes_size);
1053#else
1054 LoadFile("gedit/system/editsys.bin", system_mes, &mes_size);
1055#endif
1056 EdMesBuffer.Alloc((mes_size >> 4) + 1);
1057 EditSystemMes.tex_buff = MesWinTexBuff_01;
1058 EditSystemMes.tex_block = 26;
1059 EditSystemMes.SetBuff(system_mes);
1060 static ClsMes name_mes;
1061 name_mes.fukidashi = false;
1062 name_mes.stay_frame = true;
1063 MonsterNameInit(&name_mes, system_mes, MesWinTexBuff_11);
1064 EditNameMes.tex_block = 26;
1065 EditNameMes.tex_buff = MesWinTexBuff_11;
1066 EditNameMes.SetBuff(system_mes);
1067 EdMesBuffer.Align64();
1068 short *window_mes = (short *) (EdMesBuffer.base + EdMesBuffer.used * 16);
1069 char window_path[0x40] = "meswin/system14";
1070 int language_no = LanguageCode;
1071
1072 if (language_no > 0) {
1073 sprintf(window_path, "meswin/system14_%d", language_no);
1074 }
1075
1076 strcat(window_path, ".mes");
1077
1078 if (LoadFile2(window_path, window_mes, &mes_size, 0) == 0) {
1079 LoadFile("meswin/system14e.bin", window_mes, &mes_size);
1080 }
1081
1082 EdMesBuffer.Alloc((mes_size >> 4) + 1);
1083 EditMes1.SetBuff_system(window_mes);
1084 EditEventMes1.SetBuff_system(window_mes);
1085 EditNameMes.SetBuff_system(window_mes);
1086 EditSystemMes.SetBuff_system(window_mes);
1087 CommonMenuMes1.SetBuff_system(SystemMes);
1088 CommonMenuMes2.SetBuff_system(SystemMes);
1089 CommonMenuMes3.SetBuff_system(SystemMes);
1090 EdClearSystemMes();
1091 EdInitOpenItemBox(TreasureCursorOpen, TreasureCursor);
1092 exit_loop = 0;
1093 loop_counter = 0;
1094 key_counter = 0;
1095 sound_off_cnt = 1;
1096 clear_screen = 0;
1097 goto_dungeon = 0;
1098 key_lock = false;
1099 goto_menu = 0;
1100 draw_npc_cursor = 0;
1101 edit_mode_draw = 0;
1102 edit_mode_grd_draw = 0;
1103 depth_of_field = 1;
1104 edit_mode_lighting = 0;
1105 draw_sky = 1;
1106 goto_cmp_event = 0;
1107 goto_cmp_event_level = -1;
1108 change_time_event = 0;
1109 start_event_no = -1;
1110 start_system_event = -1;
1111 move_count = 0;
1112 EdBeforeInBgmNo = -1;
1113 EdDrawOffFlag = 0;
1114 EdDrawOffMap = 0;
1115 EdDrawOffMapShadow = 0;
1116 EdThunderEffectFlag = 1;
1117 EdPauseFlag = 0;
1118 debug_menu_mode = 0;
1119 EdSaveFrameImageInit();
1120 EdInitMenu(ED_MENU_RESET);
1121 BtSetMapJumpFloor(-1);
1122 EBInitialize();
1123 EdInitThunderEffect();
1124 EdInitDrawDay();
1125 InitWorkBuffer();
1126 int event_no = StartEventNo;
1127
1128 if (event_no < 0) {
1129 RunEvent(128, NULL);
1130 } else {
1131 RunEvent(event_no, NULL);
1132 }
1133
1134 StartEventNo = -1;
1135 SaveData->GetDngStatus()->cur_chara = 0;
1136 static int debug_flag_set = 0;
1137
1138 if (debug_flag_set == 0) {
1139 EdDebugCameraFlag = 0;
1140 EdDebugMoveFlag = 0;
1141 }
1142
1143 debug_flag_set = 1;
1144 ItemVolumeStep.CheckItemVolume();
1145 return 0;
1146}
1147
1151int cat_end() {
1152 int total = 0;
1153
1154 for (int category = 0; category < 10; category++) {
1155 total += category;
1156 }
1157
1158 return total;
1159}
1160
1168int EditLoop() {
1169 goto_return_menu = 0;
1170
1171 if (EdPadDown(0x800, 4) != 0) {
1172 goto_return_menu = 1;
1173 }
1174
1175 if (MapNo < TOWN_COUNT && loop_counter == 60 && GameMode == ED_MODE_WALK) {
1176 EdWalkToEditMes(0);
1177 }
1178
1179 static int end_count = -1;
1180
1181 if (GameMode != ED_MODE_EVENT) {
1182 if (EdCheckViewMode() != 0) {
1183 MGSetRenderInfo(800.0f, 4.0f, 0x20000 - 2);
1184 MGScisioringForce(1);
1185 } else {
1186 MGSetRenderInfo(800.0f, 5.0f, 0x20000 - 2);
1187 MGScisioringForce(0);
1188 }
1189 }
1190
1191 EdExchangeInfo.player = Chara;
1192 EdExchangeInfo.ground = pEditGround;
1193 EdExchangeInfo.camera = (CCameraFollow *) NowCamera;
1194 EdExchangeInfo.event_marker = TreasureCursor;
1195 EdExchangeInfo.system_effect = SystemEffect;
1196 sceVif1PkCall(Vif1Packet, (u_long128 *) Vu_prog0f, 0);
1197 EdSetFlag();
1198 EdEventInfo.current_time = NowTime;
1199 CEditGround *ground = pEditGround;
1200
1201 ground->focus_parts_id = -1;
1202
1203 if (((int *) SaveData->GetConfigData())[4] != 0) {
1204 EditMes1.text_rate_set = 0.6f;
1205 } else {
1206 EditMes1.text_rate_set = 0.3f;
1207 }
1208
1209 int mode = GameMode;
1210
1211 if (mode == 0xC) {
1212 EdInteriorFlag = 1;
1213
1214 int interior_result = EditInLoop();
1215
1216 if (interior_result != 0) {
1217 if (interior_result == 0x63) {
1218 EditExit();
1219 return 1;
1220 }
1221
1222 sceGsSyncV(0);
1223 sceGsSyncV(0);
1224 sceGsSyncV(0);
1225 sceGsSyncV(0);
1226 simple_event = 0;
1227 LoadScript();
1228
1229 MGFillBox(CRect_i_(0, 0, 0x2800, SCREEN_HALF_HEIGHT * 16), 0, 0, 0, 0x80);
1230 MGEndFrame();
1231 TexManager.DeleteTextureBlock(0xF);
1232 EdNPCBuffer.used = 0;
1233 EdVillagerBuffer.used = 0;
1234 InitWorkBuffer();
1235 EdSelectVillager(EdVillagerInfo, NowTime, EditMapInfo);
1236 EdInitVilager(EdVillagerInfo, EdExchangeInfo.ground, NULL);
1237 EdInitVilagerPosition(EdVillager, EdVillagerInfo, pEditGround, NULL);
1238 MGBeginFrame();
1239
1240 MGFillBox(CRect_i_(0, 0, 0x2800, SCREEN_HALF_HEIGHT * 16), 0, 0, 0, 0x80);
1241
1242 ED_EVENT_PARAM entry;
1243
1244 if (EdSearchEvent(&entry, EdInteriorName, EdInteriorJumpID, NowTime) != 0) {
1245 sceVu0CopyVector(fix_chara_pos, entry.position);
1246 sceVu0CopyVector(fix_chara_rot, entry.rotation);
1247 sceVu0CopyVector(fix_camera_pos, entry.camera_pos);
1248 }
1249
1250 Chara->SetPosition(fix_chara_pos);
1251
1252 float turn = fix_chara_rot[1];
1253
1254 turn += PI_SHORT;
1255
1256 if (!(turn <= PI_SHORT)) {
1257 turn -= TWO_PI_SHORT;
1258 }
1259
1260 Chara->SetRotation(fix_chara_rot[0], turn, fix_chara_rot[2]);
1261 MainCamera.FollowOff();
1262 MainCamera.SetPos(fix_camera_pos);
1263 MainCamera.SetRef(fix_chara_pos[0], 14.0f + fix_chara_pos[1], fix_chara_pos[2]);
1264 MainCamera.Step(-1);
1265
1266 sceVu0FVECTOR direction;
1267
1268 MainCamera.GetDir(direction);
1269
1270 float angle = MainCamera.GetAngleH();
1271
1272 MainCamera.FollowOn();
1273 MainCamera.SetAngleSoon(angle);
1274 Chara->ClothStep(-1);
1275 sceGsSyncV(0);
1276 sceGsSyncV(0);
1277 EdInitSoundSrc();
1278 PlayAmbient(NowTime);
1279 EdSetAmbientVol(1.0f);
1280
1281 if (EdBeforeInBgmNo >= 0) {
1282 SndBgmLoad(EdBeforeInBgmNo);
1283 }
1284
1285 sceGsSyncV(0);
1286 sceGsSyncV(0);
1287 EdFadeIn(0x40, 0.0f, 0.0f, 0.0f);
1288 GameMode = ED_MODE_WALK;
1289
1290 if (EdInteriorDoorSound >= 0) {
1291 SndSetCamera((CCamera *) &MainCamera);
1292 EdDoorCloseSe(EdInteriorDoorSound, fix_chara_pos);
1293 }
1294
1295 if (MapNo < TOWN_COUNT) {
1296 EdWalkToEditMes(60);
1297 }
1298
1299 if (EdEventInfo.outside_map_no >= 0) {
1300 RunEvent(EdEventInfo.outside_map_no, NULL);
1301 }
1302 }
1303
1304 return 0;
1305 }
1306
1307 EdInteriorFlag = 0;
1308
1309 if (interior_test != 0) {
1310 static int top = 0;
1311 static int select = 0;
1312 static int cur = 0;
1313 static char *menu[64];
1314
1315 for (int i = 0; i < 64; i++) {
1316 menu[i] = interior_name[i];
1317 }
1318
1319 int count;
1320
1321 for (count = 0; menu[count][0] != '\0'; count++) {
1322 }
1323
1324 GamePad.SetAutoRepeat(PAD_UP | PAD_DOWN, 20, 5);
1325
1326 if (GamePad.Down(PAD_DOWN) != 0) {
1327 select++;
1328 }
1329
1330 if (GamePad.Down(PAD_UP) != 0) {
1331 select--;
1332 }
1333
1334 if (select < 0) {
1335 select = 0;
1336 }
1337
1338 if (select >= count) {
1339 select = count - 1;
1340 }
1341
1342 top = 0;
1343
1344 if (select >= 14) {
1345 top = select - 13;
1346 }
1347
1348 char *mark[2] = {" ", ">"};
1349
1350 DebugFont__3.length = 0;
1351
1352 for (int i = top; i < top + 14; i++) {
1353 DebugFont__3.length += sprintf(&DebugFont__3.text[DebugFont__3.length], "%s %s\n", mark[i == select], menu[i]);
1354 }
1355
1356 TexManager.ReloadTexture(GetVif1Packet(), 0x1F);
1357 DebugFont__3.Draw();
1358
1359 if (GamePad.Down(PAD_CIRCLE) != 0) {
1360 float period_time = NowTime / 3.0f;
1361 int period = (int) period_time;
1362
1363 EdMapJump((int) period_time, menu[select]);
1364 GameMode = ED_MODE_MAP_JUMP;
1365
1366 while (ReadBGSync() != 0) {
1367 }
1368
1369 strcpy(interior_map_name, menu[select]);
1370 EditInInit(NowTime, interior_map_name);
1371 }
1372
1373 if (GamePad.On(PAD_SELECT) != 0 && GamePad.On(PAD_START) != 0) {
1374 return 1;
1375 }
1376
1377 return 0;
1378 }
1379
1380 switch (mode) {
1381 case ED_MODE_FISHING:
1382 draw_clock = 0;
1383 MainMode();
1384 MainEditMode();
1385
1386 if (EdCheckViewMode() == 0) {
1387 NowCamera = (CCamera *) &MainCamera;
1388 } else {
1389 NowCamera = (CCamera *) &ViewCamera;
1390 }
1391
1392 if (EdCheckViewMode() == 0) {
1393 NowCamera->Step(1);
1394 }
1395
1396 break;
1397 case ED_MODE_WALK:
1398 if (loop_counter > 0) {
1399 MainMode();
1400 }
1401
1402 MainEditMode();
1403
1404 if (EdCheckViewMode() == 0) {
1405 NowCamera = (CCamera *) &MainCamera;
1406 } else {
1407 NowCamera = (CCamera *) &ViewCamera;
1408 }
1409
1410 if (EdCheckViewMode() == 0) {
1411 NowCamera->Step(1);
1412 }
1413
1414 if (goto_cmp_event != 0) {
1415 goto_return_menu = 0;
1416
1417 if (EdFadeOutCheck() != 0) {
1418 if (goto_cmp_event < 0) {
1419 EdExitLoop();
1420 } else {
1421 RunEvent(goto_cmp_event, NULL);
1422 EdFadeIn(60, 0.0f, 0.0f, 0.0f);
1423 }
1424
1425 goto_cmp_event = 0;
1426 }
1427 }
1428
1429 break;
1430 case ED_MODE_EVENT:
1431 NowCamera = (CCamera *) &EventCamera;
1432 MainEditMode();
1433 EventMode();
1434 VillagerCollision();
1435 EdEventNPCStep();
1436 NowCamera->Step(1);
1437 draw_npc_cursor = 0;
1438 draw_clock = 0;
1439 goto_return_menu = 0;
1440 break;
1441 case ED_MODE_TALK:
1442 NowCamera = (CCamera *) &TalkCamera;
1443 TalkMode();
1444 MainEditMode();
1445 NowCamera->Step(1);
1446 draw_npc_cursor = 0;
1447 draw_clock = 0;
1448 break;
1449 case ED_MODE_GEORAMA:
1450 GamePad.SetAutoRepeat(PAD_DPAD, 20, 5);
1451 NowCamera = (CCamera *) &EditCamera;
1452 MainEditMode();
1453 EditMode();
1454 NowCamera->Step(1);
1455 pEditGround->EditAreaClip(NowCamera, -1.0f);
1456
1457 if (goto_cmp_event != 0) {
1458 goto_return_menu = 0;
1459
1460 if (EdFadeOutCheck() != 0) {
1461 RunEvent(goto_cmp_event, NULL);
1462 EdFadeIn(60, 0.0f, 0.0f, 0.0f);
1463 goto_cmp_event = 0;
1464 }
1465 }
1466
1467 break;
1468 case ED_MODE_DOOR_OPEN:
1469 if (door_open_cnt == 0x9C) {
1470 EdMapJump(EdGetTime(NowTime), interior_map_name);
1471 }
1472
1473 if (door_open_cnt < 0x9C) {
1474 ReadBG();
1475 }
1476
1477 if (door_open != 0) {
1478 NowCamera = (CCamera *) &MainCamera;
1479 }
1480
1481 OpenDoorMode();
1482 MainEditMode();
1483 door_open_cnt--;
1484 NowCamera->Step(1);
1485
1486 if (door_open_cnt == 100 && EdInteriorDoorSound >= 0) {
1487 sceVu0FVECTOR chara_pos;
1488
1489 Chara->GetPosition(chara_pos);
1490 EdDoorOpenSe(EdInteriorDoorSound, chara_pos);
1491 }
1492
1493 if (door_open_cnt < 0x96 && EdFadeOutCheck() != 0) {
1494 door_open_cnt = -1;
1495 }
1496
1497 if (door_open_cnt < 0) {
1498 door_open_cnt = 0;
1499 GameMode = ED_MODE_MAP_JUMP;
1500 EdStopSoundSrc();
1501 EdSetAmbientVol(0.3f);
1502 SndStep();
1503 EdBeforeInBgmNo = SndGetBgmNo();
1504
1505 if (old_main_mode == 5) {
1506 EdBeforeInBgmNo = 0;
1507 }
1508
1509 bgm_vol >>= 1;
1510
1511 if (bgm_vol <= 0) {
1512 bgm_vol = 1;
1513 }
1514
1515 if (EdEventInfo.map_jump_bgm_stop != 0) {
1516 SndBgmFadeOutStop();
1517 }
1518
1519 SndStep();
1520
1521 MGFillBox(CRect_i_(0, 0, 0x2800, SCREEN_HALF_HEIGHT * 16), 0, 0, 0, 0x80);
1522 MGEndFrame();
1523
1524 for (int i = 0; i < 10; i++) {
1525 TexManager.DeleteTextureBlock(i + 0x36);
1526 }
1527
1528 TexManager.CleanUpBuffer();
1529
1530 while (ReadBGSync() != 0) {
1531 }
1532
1533 sceGsSyncV(0);
1534 EdSelectVillager(EdVillagerInfo, NowTime, EditMapInfo);
1535 EditInInit(NowTime, interior_map_name);
1536 MGBeginFrame();
1537
1538 MGFillBox(CRect_i_(0, 0, 0x2800, SCREEN_HALF_HEIGHT * 16), 0, 0, 0, 0x80);
1539 ItemVolumeStep.CheckItemVolume();
1540 return 0;
1541 }
1542
1543 break;
1544 case ED_MODE_GEORAMA_MENU:
1545 if (EditMenuLoop() != 0) {
1546 GameMode = ED_MODE_GEORAMA;
1547 NowSelectParts = -1;
1548
1549 switch (EditMenuStatus.mode) {
1550 case EDIT_MENU_MODE_PLACE:
1551 NowSelectParts = EditMenuStatus.parts;
1552 break;
1553 case EDIT_MENU_MODE_MOVE:
1554 NowSelectParts = -1;
1555 break;
1556 case EDIT_MENU_MODE_EVENT:
1557 FadeOutToEvent(EditMenuStatus.event_no + 0xC8, 0);
1558 break;
1559 }
1560
1561 EdExitMenu();
1562 return 0;
1563 }
1564
1565 break;
1566 case ED_MODE_MENU:
1567 TexManager.ReloadTexture(GetVif1Packet(), 0x10);
1568 MenuMapJumpMode = -1;
1569 EditPartsObjectOnOff();
1570
1571 if (EdMenuMode() != 0) {
1572 GameMode = ED_MODE_WALK;
1573 EdExitMenu();
1574
1575 if (MenuMapJumpMode >= 0) {
1576 MapJump(MenuMapJumpMode, -1);
1577 EdEventInfo.integer_arguments[0] = MenuMapJumpMode;
1578 RunSystemEvent(2, NowCamera);
1579 MenuMapJumpMode = -1;
1580 }
1581
1582 EdInitVillagerOnOff(EdVillager, EdVillagerInfo, pEditGround);
1583 return 0;
1584 }
1585
1586 break;
1587 case ED_MODE_TIME_CHANGE:
1588 if (chg_time_cnt < 0x8C) {
1589 ReadBG();
1590 }
1591
1592 for (int i = 0; i < 10; i++) {
1593 if (EdVillager[i].CheckDraw() != 0) {
1594 EdVillager[i].Step();
1595 } else {
1596 EdVillager[i].initialized = false;
1597 }
1598 }
1599
1600 if (chg_time_cnt == 0x8C) {
1601 EdVillagerBuffer.used = 0;
1602 StartReadBG();
1603 EdSelectVillager(EdVillagerInfo, NowTime, EditMapInfo);
1604 EdInitVilager(EdVillagerInfo, pEditGround, EdNPCReadBuffer);
1605 }
1606
1607 NowCamera = (CCamera *) &MainCamera;
1608 Chara->GetVelocity()->y = 0.0f;
1609
1610 CCharacter *chara;
1611 chara = Chara;
1612
1613 chara->motion_no = 0;
1614 chara->motion_flags = 0;
1615 chara->motion_speed = -1.0f;
1616 Chara->Step();
1617 Chara->ClothStep(0);
1618 Chara->ShadowStep();
1619 MainEditMode();
1620 chg_time_cnt--;
1621 NowCamera->Step(1);
1622
1623 if (chg_time_cnt < 0) {
1624 while (ReadBGSync() != 0) {
1625 }
1626
1627 for (int i = 0x36; i < 0x40; i++) {
1628 TexManager.DeleteTextureBlock(i);
1629 }
1630
1631 TexManager.CleanUpBuffer();
1632
1633 for (int i = 0; i < 10; i++) {
1634 BG_READ_INFO *file = GetReadBGFile(i);
1635
1636 if (file != NULL) {
1637 u_int *pack = (u_int *) file->buffer;
1638
1639 EdLoadVillager(pack, EdVillager[i].resource_name, &EdVillager[i], &EdVillagerBuffer);
1640 }
1641 }
1642
1643 EdInitVilagerPosition(EdVillager, EdVillagerInfo, pEditGround, NULL);
1644 chg_time_cnt = 0;
1645 GameMode = ED_MODE_WALK;
1646 EdFadeIn(0x40, 0.0f, 0.0f, 0.0f);
1647 }
1648
1649 break;
1650 case ED_MODE_GEORAMA_MENU_INIT:
1651 case ED_MODE_MENU_INIT:
1652 draw_clock = 0;
1653 MGFlipWaitVSync(1);
1654 pEditGround->EditAreaClip(NowCamera, -1.0f);
1655 break;
1656 case ED_MODE_UNK_0:
1657 case ED_MODE_RETURN_MENU_WALK:
1658 case ED_MODE_RETURN_MENU_GEORAMA:
1659 case ED_MODE_MAP_JUMP:
1660 case ED_MODE_UNK_D:
1661 case ED_MODE_UNK_F:
1662 break;
1663 }
1664
1665 sceVu0FMATRIX view;
1666 sceVu0FVECTOR eye;
1667
1668 NowCamera->GetCameraMatrix(view);
1669 NowCamera->GetPos(eye);
1670 MGSetViewMatrix(view, eye);
1671
1672 if (GameMode != ED_MODE_GEORAMA && GameMode != ED_MODE_GEORAMA_MENU_INIT && GameMode != ED_MODE_RETURN_MENU_GEORAMA) {
1673 if (move_count > 0) {
1674 pEditGround->EditAreaClip(NowCamera, -1.0f);
1675 } else {
1676 pEditGround->EditAreaClip(NowCamera, 20000.0f);
1677 }
1678 }
1679
1680 switch (GameMode) {
1681 case ED_MODE_GEORAMA:
1682 depth_of_field = 0;
1683 edit_mode_lighting = 1;
1684 draw_sky = 0;
1685 edit_mode_draw = 1;
1686 edit_mode_grd_draw = 1;
1687 MainDraw();
1688 break;
1689 case ED_MODE_UNK_0:
1690 case ED_MODE_WALK:
1691 case ED_MODE_TALK:
1692 case ED_MODE_EVENT:
1693 case ED_MODE_FISHING:
1694 depth_of_field = 1;
1695 edit_mode_lighting = 0;
1696 draw_sky = 1;
1697 edit_mode_draw = 0;
1698
1699 if (move_count <= 10) {
1700 edit_mode_grd_draw = 0;
1701 }
1702 /* fallthrough */
1703 case ED_MODE_TIME_CHANGE:
1704 case ED_MODE_GEORAMA_MENU_INIT:
1705 case ED_MODE_MENU_INIT:
1706 case ED_MODE_RETURN_MENU_WALK:
1707 case ED_MODE_RETURN_MENU_GEORAMA:
1708 case ED_MODE_DOOR_OPEN:
1709 MainDraw();
1710 break;
1711 case ED_MODE_GEORAMA_MENU:
1712 case ED_MODE_MENU:
1713 EditNameMes.MakeMesWin(-1);
1714 EdFadeInOut();
1715 break;
1716 }
1717
1718 CheckKeyLock();
1719
1720 sceVu0FVECTOR focus_pos;
1721
1722 if (GameMode == ED_MODE_WALK) {
1723 Chara->GetPosition(focus_pos);
1724 } else {
1725 sceVu0CopyVector(focus_pos, ECursorFrame->position);
1726 }
1727
1728 if ((EdDebugMoveFlag > 0 || MapNo < TOWN_COUNT) && EdPadDown(0x100, 2) != 0 && EdCheckViewMode() == 0 && change_time_event == 0) {
1729 sceVu0FVECTOR at;
1730
1731 if (GameMode == ED_MODE_WALK) {
1732 move_count = 30;
1733 GameMode = ED_MODE_GEORAMA;
1734 EditCamera.SetAngleSoon(MainCamera.GetAngle());
1735 MainCamera.GetPos(at);
1736 EditCamera.SetPos(at);
1737 MainCamera.GetRef(at);
1738 EditCamera.SetRef(at);
1739 Chara->GetPosition(at);
1740 NowSelectAngle = 0;
1741 OldSelectAngle = 0;
1742 NowCursorRotY = 0.0f;
1743 Chara->GetPosition(at);
1744 ECursorFrame->SetPosition(at);
1745 sceVu0CopyVector(NowPartsCursorPos, ECursorFrame->position);
1746 sceVu0CopyVector(NowCursorPos, ECursorFrame->position);
1747 sceVu0CopyVector(NextCursorPos, ECursorFrame->position);
1748 NowFocusParts = NULL;
1749 OldFocusParts = NULL;
1750 PartsNameNum = -1;
1751 DrawPartsNameCount = 30;
1752 EditMenuStatus.mode = EDIT_MENU_MODE_CLOSED;
1753 EditMenuStatus.parts = -1;
1754 NowSelectParts = -1;
1755 } else if (GameMode == ED_MODE_GEORAMA && pEditGround->CheckEffect() == 0) {
1756 move_count = 30;
1757 GamePad.AutoRepeatOff();
1758
1759 if (CheckEditToWalk(at) != 0) {
1760 GameMode = ED_MODE_WALK;
1761 Chara->SetPosition(at);
1762 MainCamera.SetAngleSoon(EditCamera.GetAngle());
1763 EditCamera.GetPos(at);
1764 MainCamera.SetPos(at);
1765 EditCamera.GetRef(at);
1766 MainCamera.SetRef(at);
1767
1768 int requested_count = 0;
1769 ED_GRD_DATA *ground_data = (ED_GRD_DATA *) SaveData->GetGrdData(MapNo);
1770
1771 if (ground_data != NULL && ground_data->complete_event_seen == 0) {
1772 for (int i = 0; i < 24; i++) {
1773 if (EditPartsInfo.request[i] != 0) {
1774 requested_count++;
1775 }
1776 }
1777
1778 if (requested_count == EditPartsInfo.parts_max) {
1779 FadeOutToEvent(0x83, 9);
1780 }
1781 }
1782
1783 if (MapNo == TOWN_MATATAKI && SaveData->GetGameFlag(0x14) == 0 && EditPartsInfo.request[16] != 0) {
1784 FadeOutToEvent(0xB, 0xA);
1785 }
1786 }
1787
1788 EdInitVilagerPosition(EdVillager, EdVillagerInfo, pEditGround, &at);
1789 }
1790 }
1791
1792 if (move_count > 0) {
1793 EditCamera.SetSpeed(10.0f);
1794 } else {
1795 EditCamera.SetSpeed(8.0f);
1796 }
1797
1798 if (move_count < 0) {
1799 move_count = 0;
1800 }
1801
1802 move_count--;
1803
1804 if (GameMode == ED_MODE_GEORAMA_MENU_INIT || GameMode == ED_MODE_MENU_INIT) {
1805 int next_mode = EdInitModeFinish(NowCamera, TexManager.GetTexture("frame_image", -1));
1806
1807 if (next_mode != 0) {
1808 GameMode = next_mode;
1809 }
1810 }
1811
1812 EdSaveFrameImageTask();
1813
1814 if (GameMode == ED_MODE_GEORAMA) {
1815 EdStopSoundSrc();
1816
1817 if ((EdPadDown(0x10, 2) != 0 || EdPadDown(0x20, 2) != 0) && EdInitMenu(ED_MENU_EDIT) != 0) {
1818 NowSelectParts = -1;
1819 GameMode = ED_MODE_GEORAMA_MENU_INIT;
1820 SndSePlay(MENU_SOUND_CONFIRM, -1, 0);
1821 }
1822 }
1823
1824 if (GameMode == ED_MODE_WALK && (EdPadDown(0x10, 1) != 0 || goto_menu != 0 || (SystemMesCheck() == 0 && EdCheckItemOver() != 0))) {
1825 int menu_no = ED_MENU_BATTLE;
1826
1827 if (goto_menu != 0) {
1828 menu_no = goto_menu;
1829 goto_menu = 0;
1830 }
1831
1832 if (EdInitMenu(menu_no) != 0) {
1833 if (EdCheckItemOver() != 0) {
1834 if (loop_counter > 10) {
1835 SndSePlay(MENU_SOUND_CONFIRM, -1, 0);
1836 }
1837 } else {
1838 SndSePlay(MENU_SOUND_CONFIRM, -1, 0);
1839 }
1840
1841 GameMode = ED_MODE_MENU_INIT;
1842 }
1843 }
1844
1845 static int debug_flag = 0;
1846
1847#ifdef PAL
1848 // Debug builds draw the editor debug overlay and open the debug menu from the pad.
1849 if (DebugMode != 0) {
1850 if (GamePad.Down(PAD_L3) != 0) {
1851 debug_flag = !debug_flag;
1852 }
1853
1854 EdDDebug(debug_flag);
1855
1856 if (debug_menu_mode != 0) {
1857 GamePad.KeyLock(0);
1858 EdDebugMenu();
1859
1860 if (GamePad.Down(PAD_R3) != 0 || EdDebugRunEventNo > 0) {
1861 debug_menu_mode = 0;
1862 GamePad.AutoRepeatOff();
1863 RunEvent(EdDebugRunEventNo, NowCamera);
1864 } else {
1865 GamePad.KeyLock(1);
1866 }
1867 } else {
1868 if (GameMode != ED_MODE_EVENT && GamePad.Down(PAD_R3) != 0) {
1869 GamePad.SetAutoRepeat(PAD_DPAD, 0x19, 3);
1870 GamePad.SetAutoRepeat(PAD_L1 | PAD_R1, 0x19, 3);
1871 debug_menu_mode = 1;
1872 debug_flag = 0;
1873 }
1874
1875 if (GameMode == ED_MODE_GEORAMA) {
1876 sceVu0FVECTOR cursor_pos;
1877 char text[128];
1878
1879 sceVu0CopyVector(cursor_pos, ECursorFrame->position);
1880 EdDPrintVector("pos = ", cursor_pos);
1881 int area = pEditGround->GetAreaCode(cursor_pos[0], cursor_pos[1], cursor_pos[2]);
1882 sprintf(text, "area = %d\n", area);
1883 EdDPrint(text);
1884
1885 if (area >= 0) {
1886 CVector3_i_ grid;
1887
1888 pEditGround->areas[area]->GetPos(&grid, cursor_pos[0], cursor_pos[1], cursor_pos[2]);
1889 sprintf(text, "pos(grid) = (%d,%d)\n", grid.x, grid.z);
1890 EdDPrint(text);
1891 sprintf(text, "id = %d\n", pEditGround->areas[area]->GetPartsID(grid.x, grid.z));
1892 EdDPrint(text);
1893 }
1894 } else {
1895 EdDPrintChara((CMainChara *) Chara);
1896 }
1897
1898 EdDPrintCamera(NowCamera);
1899 EdDDrawFont();
1900 }
1901 }
1902
1903#endif
1904 if (GameMode != ED_MODE_GEORAMA_MENU && GameMode != ED_MODE_GEORAMA && loop_counter > 10) {
1905 sceVu0FVECTOR eye_pos;
1906 sceVu0FVECTOR eye_dir;
1907 CBoxVu0 box;
1908 CMapParts *nearby[128];
1909
1910 NowCamera->GetPos(eye_pos);
1911 NowCamera->GetDir(eye_dir);
1912
1913 float reach = 550;
1914
1915 box.min[0] = eye_pos[0] - reach;
1916 box.min[1] = eye_pos[1] - reach;
1917 box.min[2] = eye_pos[2] - reach;
1918 box.min[3] = 1.0f;
1919 box.max[0] = reach + eye_pos[0];
1920 box.max[1] = reach + eye_pos[1];
1921 box.max[2] = reach + eye_pos[2];
1922 box.max[3] = 1.0f;
1923
1924 int near_count = pEditGround->GetNearParts(nearby, 64, &box, NULL);
1925
1926 for (int i = 0; i < near_count; i++) {
1927 if (nearby[i]->subtype == MAP_PARTS_SUBTYPE_RIVER && pEditGround->suppress_water != 0) {
1928 nearby[i] = NULL;
1929 }
1930 }
1931
1932 if (sound_off_cnt <= 0) {
1933 EdSetSoundSrcVol(NowTime, nearby, near_count, eye_pos, eye_dir);
1934 }
1935 }
1936
1937 if (change_time_event != 0 && move_count <= 0 && RunEvent(0x84, NowCamera) != 0) {
1938 change_time_event = 0;
1939 }
1940
1941 static int event_next = 0;
1942
1943 if (GamePad.Down2(PAD_SQUARE) != 0) {
1944 event_next = 4;
1945 EdEventAllClear();
1946 simple_event = 0;
1947 }
1948
1949 event_next--;
1950
1951 if (event_next < 0) {
1952 event_next = 0;
1953 }
1954
1955 if (event_next == 1) {
1956 start_event_no = 0x96;
1957 }
1958
1959 if (GameMode != ED_MODE_EVENT) {
1960 if (((CMainChara *) Chara)->move_info.landed != 0 && loop_counter > 10) {
1961 if (((CMainChara *) Chara)->move_info.ground_poly.attr.ground_kind > 0) {
1962 RunEvent(((CMainChara *) Chara)->move_info.ground_poly.attr.ground_kind, NowCamera);
1963 ((CMainChara *) Chara)->move_info.ground_poly.attr.ground_kind = 0;
1964 }
1965 }
1966 }
1967
1968 if (EdDebugEventEnable != 0 && (start_event_no > 0 || start_system_event > 0)) {
1969 sceVu0FVECTOR camera_pos;
1970 sceVu0FVECTOR camera_ref;
1971
1972 NowCamera->GetPos(camera_pos);
1973 NowCamera->GetRef(camera_ref);
1974 EventCamera.FollowOff();
1975 EventCamera.SetPos(camera_pos);
1976 EventCamera.SetRef(camera_ref);
1977 EventCamera.Step(-1);
1978
1979 if (start_system_event > 0) {
1980 if (EdEventInit(start_system_event, &EdWorkBuffer, (char *) EdSystemEventData) != 0) {
1981 EdInitMesParam();
1982 GameMode = ED_MODE_EVENT;
1983 }
1984 } else {
1985 if (EdEventInit(start_event_no, &EdWorkBuffer, (char *) EdEventData) != 0) {
1986 EdInitMesParam();
1987 GameMode = ED_MODE_EVENT;
1988 ItemVolumeStep.CheckItemVolume();
1989 }
1990
1991 if (EdEventInfo.return_code == ED_EVENT_RETURN_TALK) {
1992 EdInitMesParam();
1993 GameMode = ED_MODE_TALK;
1994 simple_event = 0;
1995 ItemVolumeStep.CheckItemVolume();
1996 }
1997 }
1998
1999 start_event_no = -1;
2000 start_system_event = -1;
2001 } else {
2002 simple_event = 0;
2003 }
2004
2005 PauseOffCheck();
2006 static int old_mode;
2007
2008 if ((unsigned int) (GameMode - 9) < 2U && EdPadDown(0x800, 0xFFFF) != 0) {
2009 GameMode = old_mode;
2010 EdSePlay((ED_SOUND_ID) 2, -1);
2011 PlayTimeCountFlag(1);
2012 } else if (goto_return_menu != 0) {
2013 if (GameMode == ED_MODE_WALK || GameMode == ED_MODE_FISHING) {
2014 old_mode = GameMode;
2015 oldGameMode = GameMode;
2016 GameMode = ED_MODE_RETURN_MENU_WALK;
2017 EdSePlay((ED_SOUND_ID) 1, -1);
2018 PlayTimeCountFlag(0);
2019 } else if (GameMode == ED_MODE_GEORAMA) {
2020 old_mode = GameMode;
2021 GameMode = ED_MODE_RETURN_MENU_GEORAMA;
2022 EdSePlay((ED_SOUND_ID) 1, -1);
2023 PlayTimeCountFlag(0);
2024 }
2025 }
2026
2027 goto_return_menu = 0;
2028 static int end_code = 0;
2029
2030 if (goto_dungeon != 0 && end_counter == 0) {
2031 main_select_menu_no = NowEditMap;
2032 MapJump(NowEditMap + 0xC8, -1);
2033 end_counter = 1;
2034 end_code = 1;
2035 }
2036
2037 key_counter = 0;
2038
2039#ifdef PAL
2040 // Debug builds leave the editor through a fade on a two-button chord.
2041 if (DebugMode != 0 && GamePad.On(PAD_SELECT) != 0 && GamePad.On(PAD_START) != 0 && end_counter == 0) {
2042 end_counter = 100;
2043 EdFadeOut(0x40, 0.0f, 0.0f, 0.0f);
2044 end_code = 1;
2045 }
2046
2047#endif
2048 if (exit_loop != 0) {
2049 EditExit();
2050 return 1;
2051 }
2052
2053 if (end_counter == 1) {
2054 EditExit();
2055 return end_code;
2056 }
2057
2058 end_counter--;
2059
2060 if (end_counter < 0) {
2061 end_counter = 0;
2062 }
2063
2064 SndStep();
2065 loop_counter++;
2066 key_counter++;
2067 sound_off_cnt--;
2068
2069 if (sound_off_cnt < 0) {
2070 sound_off_cnt = 0;
2071 }
2072
2073 DebugFont__3.length = 0;
2074
2075 if (GamePad.On(PAD_CIRCLE) != 0) {
2076 cat_end();
2077 }
2078
2079 return 0;
2080}
2081
2089void MainDraw() {
2090 ED_EVENT_INFO *event;
2091 int shadow_on;
2092 int detail;
2093 int *marks;
2094 int i;
2095
2096 if (EdDrawOffFlag == 0) {
2097 if (EdPauseFlag != 0 || (unsigned int) (GameMode - 9) < 2U) {
2099 } else {
2101
2102 if (EdThunderEffectFlag != 0) {
2103 EdThunderEffect(MapNo, pEditGround);
2104 }
2105 }
2106
2107 EdDrawOffMap = EdEventInfo.suppress_background;
2108 EdDrawOffMapShadow = EdEventInfo.suppress_shadows;
2109
2110 if (EdDrawOffMap == 0) {
2111 if (draw_sky != 0) {
2112 EdDrawSky(NowTime, SkyFrame, SunFrame, SkyBackFrame, NowCamera, EditMapInfo->sky_follow);
2113 }
2114
2115 TexManager.ReloadTexture(Vif1Packet, 1);
2116 TexAnime.TexAnime(1);
2117 pEditGround->DrawBaseGround();
2118
2119 float lod[4] = {50.0f, 350.0f, 600.0f, 1000.0f};
2120 float far_lod;
2121 float near_lod = 2.0f;
2122 far_lod = 0.0f;
2123 float mid_lod = 0.0f;
2124
2125 if (edit_mode_draw != 0) {
2126 near_lod = 3.0f;
2127 far_lod = 3.0f;
2128 mid_lod = 3.0f;
2129 }
2130
2131 pEditGround->Draw(NowTime, 1, (int) far_lod, (int) near_lod, (int) mid_lod, (int) near_lod);
2132
2133 if (edit_mode_draw != 0) {
2134 sceVu0FVECTOR at;
2135 sceVu0FVECTOR colour = {0.0f, 0.0f, 0.0f, 0.0f};
2136
2137 sceVu0CopyVector(at, ECursorFrame->position);
2138 colour[1] = NowCursorRotY;
2139 at[1] = pEditGround->GetAlt(at[0], at[1], at[2]);
2140 pEditGround->DrawPartsCursor(NowSelectParts, at, NowPartsCursorPos, NowSelectAngle, colour, 1);
2141 }
2142
2143 TexManager.ReloadTexture(Vif1Packet, 2);
2144 TexAnime.TexAnime(2);
2145 pEditGround->Draw(NowTime, 2, (int) far_lod, (int) near_lod, 0, 3);
2146
2147 if (edit_mode_draw != 0) {
2148 sceVu0FVECTOR at2;
2149 sceVu0FVECTOR colour2 = {0.0f, 0.0f, 0.0f, 0.0f};
2150
2151 sceVu0CopyVector(at2, ECursorFrame->position);
2152 colour2[1] = NowCursorRotY;
2153 at2[1] = pEditGround->GetAlt(at2[0], at2[1], at2[2]);
2154 pEditGround->DrawPartsCursor(NowSelectParts, at2, NowPartsCursorPos, NowSelectAngle, colour2, 2);
2155 }
2156
2157 if (FishingDrawCheck() != 0) {
2158 FishingDrawFish();
2159 FishLineDraw(0);
2160 }
2161
2162 TexManager.ReloadTexture(Vif1Packet, 0x15);
2163 TexAnime.TexAnime(0x15);
2164 pEditGround->DrawWater(0x15);
2165
2166 switch (GameMode) {
2167 case ED_MODE_WALK:
2168 case ED_MODE_FISHING:
2169 case ED_MODE_GEORAMA:
2170 case ED_MODE_TALK:
2171 case ED_MODE_EVENT:
2172 case ED_MODE_TIME_CHANGE:
2173 case ED_MODE_UNK_0:
2174 case ED_MODE_RETURN_MENU_WALK:
2175 case ED_MODE_MENU_INIT:
2176 case ED_MODE_GEORAMA_MENU_INIT:
2177 case ED_MODE_RETURN_MENU_GEORAMA: {
2178 sceGsTex0 frame;
2179 CRect_i_ screen;
2180 sceGsTex0 water;
2181 float ref[4];
2182 sceGsZbuf zbuf;
2183
2184 MGGetFBuffTex(&frame);
2185 screen.x = 0;
2186 screen.y = 0;
2187 screen.width = 0x280;
2188 screen.height = SCREEN_HALF_HEIGHT;
2189 water = *(sceGsTex0 *) &TexManager.GetTexture("water_buff", -1)->tex0;
2190 MGMoveImage(&frame, screen, &water, 0, 0, 0);
2191 MainCamera.GetRef(ref);
2192 zbuf = mgZBuffer;
2193 zbuf.bits.zmsk = 1;
2194 MGSetGsZBUF(&zbuf);
2195 pEditGround->DrawWaterSurface(NowCamera);
2196 MGSetGsZBUF(&mgZBuffer);
2197 break;
2198 }
2199 }
2200
2201 pEditGround->DrawRipple(0x15);
2202
2203 float dof_range[2] = {400.0f, 1000.0f};
2204
2205 if (depth_of_field != 0) {
2206 int dof_level = 2;
2207
2208 if (((int *) SaveData->GetConfigData())[6] != 0) {
2209 dof_level = 1;
2210 }
2211
2212 EdDrawDOF(dof_level);
2213 }
2214 }
2215
2216 if (FishingDrawCheck() != 0) {
2217 FishLineDraw(1);
2218 }
2219
2220 if (GameMode == ED_MODE_EVENT) {
2221 EdEventBackSpriteDraw();
2222 }
2223
2224 PolyCount = 0;
2225
2226 if (GameMode == ED_MODE_EVENT) {
2227 EdDrawItem();
2228 }
2229
2230 switch (GameMode) {
2231 case ED_MODE_RETURN_MENU_WALK:
2232 case ED_MODE_MENU_INIT:
2234 Chara->Step();
2235 Chara->ShadowStep();
2236
2237 for (i = 0; i < 10; i++) {
2238 CNPCharacter *villager = &EdVillager[i];
2239 unsigned char drawable = villager->initialized != 0;
2240
2241 if (drawable != 0) {
2242 drawable = villager->draw_enabled != 0;
2243 }
2244
2245 if (drawable != 0) {
2246 int saved_sequence = villager->sequence_enabled;
2247
2248 villager->sequence_enabled = 0;
2249 villager->Step();
2250 villager->ShadowStep();
2251 villager->sequence_enabled = saved_sequence;
2252 }
2253 }
2254
2256 /* fallthrough */
2257 case ED_MODE_WALK:
2258 case ED_MODE_FISHING:
2259 case ED_MODE_TALK:
2260 case ED_MODE_EVENT:
2261 case ED_MODE_TIME_CHANGE:
2262 case ED_MODE_DOOR_OPEN: {
2263 event = NULL;
2264 shadow_on = 1;
2265 detail = 3;
2266 int marks_store[10];
2267 marks = marks_store;
2268 float chara_pos[4];
2269 CBoxVu0 box;
2270 CMapParts *near_parts[0x40];
2271
2272 if (GameMode == ED_MODE_TALK || EdSystemMesCheck() != 0) {
2273 shadow_on = 0;
2274 }
2275
2276 if (EdCheckViewMode() != 0) {
2277 detail = 0;
2278 }
2279
2280 if (GameMode == ED_MODE_DOOR_OPEN) {
2281 marks = NULL;
2282 } else {
2283 for (i = 0; i < 10; i++) {
2284 marks_store[i] = 3;
2285 }
2286 }
2287
2288 if (GameMode == ED_MODE_EVENT) {
2289 event = &EdEventInfo;
2290 }
2291
2292 Chara->GetPosition(chara_pos);
2293 chara_pos[1] += 10.0f;
2294 box.min[0] = chara_pos[0] - 100.0f;
2295 box.min[1] = chara_pos[1] - 100.0f;
2296 box.min[2] = chara_pos[2] - 100.0f;
2297 box.min[3] = 1.0f;
2298 box.max[0] = 100.0f + chara_pos[0];
2299 box.max[1] = 100.0f + chara_pos[1];
2300 box.max[2] = 100.0f + chara_pos[2];
2301 box.max[3] = 1.0f;
2302
2303 int found = pEditGround->GetNearParts(near_parts, 0x40, &box, NULL);
2304
2305 Chara->ClearPointLight();
2306
2307 for (i = 0; i < found; i++) {
2308 CMapParts *parts = near_parts[i];
2309 CFrame *frame = (CFrame *) parts->frame[0];
2310
2311 if (frame != NULL) {
2312 float transform[4];
2313
2314 parts->GetPosition(transform);
2315 frame->SetPosition(transform);
2316 near_parts[i]->GetRotation(transform);
2317 frame->SetRotation(transform[0], transform[1], transform[2]);
2318
2319 for (int j = 0; j < 0x18; j++) {
2320 EDIT_EFFECT_INFO *effect = near_parts[i]->effect[j];
2321
2322 if (near_parts[i]->effect_on[j] != 0 && effect != NULL && (effect->kind == EDIT_EFFECT_FIRE_LARGE || effect->kind == EDIT_EFFECT_FIRE_MEDIUM || effect->kind == EDIT_EFFECT_FIRE_SMALL) && effect->frame != NULL && CheckEditEffect(effect, NowTime) != 0) {
2323 float light_pos[4];
2324
2325 effect->frame->GetWorldPosition(light_pos, effect->offset);
2326
2327 float distance = DistVector(chara_pos, light_pos);
2328
2329 if (distance <= 40.0f) {
2330 float brightness = 80.0f + (float) (rand() % 48);
2331
2332 light_pos[3] = distance;
2333 Chara->SetPointLight(light_pos, 5.0f, 40.0f, brightness, brightness, brightness, 128.0f);
2334 }
2335 }
2336 }
2337 }
2338 }
2339
2340 EdDrawCharacter(Chara, detail, 0xA, EdVillager, marks, shadow_on, event);
2341 break;
2342 }
2343 }
2344
2345 if (EdDrawOffMapShadow == 0 && EdDrawOffMap == 0) {
2346 float saved_light[4][4];
2347 float shadow_light[4][4];
2348 float light_colour[4][4];
2349
2350 MGGetPLight(saved_light, light_colour);
2351 sceVu0CopyMatrix(shadow_light, saved_light);
2352 EdLimitShadowLight(shadow_light, 3.0f);
2353 MGSetPLight(shadow_light, light_colour);
2354 TexManager.ReloadTexture(Vif1Packet, 0x16);
2355
2356 float shadow_range[4] = {-100.0f, EditMapInfo->shadow_near, EditMapInfo->shadow_far, 0.0f};
2357
2358 if (edit_mode_draw != 0) {
2359 MGBeginDrawShadow(*(sceGsTex0 *) &TexManager.GetTexture("shadow_buff", -1)->tex0);
2360 pEditGround->DrawShadow(1, 0.0f, 100000.0f);
2361 MGEndDrawShadow(0x20);
2362 } else {
2363 if (EditMapInfo->shadow_level > 0) {
2364 MGBeginDrawShadow(*(sceGsTex0 *) &TexManager.GetTexture("shadow_buff", -1)->tex0);
2365 pEditGround->DrawShadow(0, shadow_range[0], shadow_range[1]);
2366 MGEndDrawShadow(EditMapInfo->shadow_mode);
2367 }
2368
2369 if (EditMapInfo->shadow_level >= 2) {
2370 MGBeginDrawShadow(*(sceGsTex0 *) &TexManager.GetTexture("shadow_buff", -1)->tex0);
2371 pEditGround->DrawShadow(0, shadow_range[1], shadow_range[2]);
2372 MGEndDrawShadow(EditMapInfo->shadow_mode_2);
2373 }
2374 }
2375
2376 MGSetPLight(saved_light, light_colour);
2377 }
2378
2379 for (i = 0; i < 4; i++) {
2380 TexManager.ReloadTexture(Vif1Packet, i + 0x1B);
2381 MotionParts[i].TextureAnime(i + 0x1B);
2382 MotionParts[i].Draw();
2383 }
2384
2385 if (EdDrawOffMap == 0) {
2386 TexManager.ReloadTexture(Vif1Packet, 0x18);
2387 RunEffect.Lighting(1);
2388 RunEffect.Draw();
2389
2390 switch (GameMode) {
2391 case ED_MODE_UNK_0:
2392 case ED_MODE_WALK:
2393 case ED_MODE_TALK:
2394 case ED_MODE_TIME_CHANGE:
2395 case ED_MODE_GEORAMA:
2396 case ED_MODE_GEORAMA_MENU_INIT:
2397 case ED_MODE_MENU_INIT:
2398 case ED_MODE_DOOR_OPEN:
2399 case ED_MODE_EVENT:
2400 case ED_MODE_FISHING:
2401 if (EdPauseFlag == 0) {
2402 float wind[4];
2403
2404 EditEffectStep();
2405 EdWind.GetWind(wind);
2406 EffectMacroStep(wind);
2407 RunEffect.Step();
2408 EdEffectGroup.Step(1);
2409
2410 if (NowEditMap == TOWN_MATATAKI) {
2411 sceVu0FVECTOR spray = {800.0f, -20.0f, 1300.0f, 1.0f};
2412 sceVu0FVECTOR size = {10.0f, 7.0f, 10.0f, 1.0f};
2413
2414 for (int i = 0; i < 5; i++) {
2415 EffectWaterSpray(&EdEffectGroup, spray, size, 0xA, i);
2416 spray[0] += 20.0f;
2417 }
2418 }
2419 }
2420 /* fallthrough */
2421 case ED_MODE_RETURN_MENU_WALK:
2422 case ED_MODE_RETURN_MENU_GEORAMA:
2423 EditEffectStep2();
2424 CEditGround *ground = pEditGround;
2425
2426 ground->DrawEffect((CCameraFollow *) NowCamera, NowTime, &EdEffectGroup);
2427 EdEffectGroup.Draw();
2428 break;
2429 }
2430
2431 if (edit_mode_draw == 0) {
2432 EdDrawLensFlare(NowTime, SunFrame);
2433 }
2434 }
2435
2436 if (GameMode == ED_MODE_EVENT) {
2437 EdEventSpriteDraw();
2438 EBDraw();
2439
2440 if (EdEventInfo.screen_filter != 0) {
2441 float fade[4];
2442 CRect_i_ screen;
2443
2444 sceVu0CopyVector(fade, EdEventInfo.screen_filter_color);
2445 screen.x = 0;
2446 screen.y = 0;
2447 screen.width = 0x2800;
2448 screen.height = SCREEN_HALF_HEIGHT * 16;
2449 MGFillBox(screen, (int) fade[0] & 0xFF, (int) fade[1] & 0xFF, (int) fade[2] & 0xFF, (int) fade[3] & 0xFF);
2450 }
2451 }
2452
2453 if (GameMode != ED_MODE_TALK) {
2454 DrawSysGra();
2455 }
2456
2457 if (GameMode == ED_MODE_GEORAMA) {
2458 ParamDraw();
2459 TexManager.ReloadTexture(Vif1Packet, EditMes1.tex_block);
2460 EditNameMes.Step();
2461 EditNameMes.DrawMesWin();
2462 }
2463
2464 int mes_mode = GameMode;
2465
2466 if (mes_mode == ED_MODE_TALK || mes_mode == ED_MODE_FISHING || mes_mode == ED_MODE_EVENT || mes_mode == ED_MODE_GEORAMA) {
2467 TexManager.ReloadTexture(Vif1Packet, EditMes1.tex_block);
2468 EditMes1.DrawMesWin();
2469
2470 if (GameMode == ED_MODE_EVENT) {
2471 EditEventMes1.DrawMesWin();
2472 EditSystemMes.DrawMesWin();
2473 }
2474 }
2475
2476 if (GameMode == ED_MODE_WALK) {
2477 MonsterNameDraw();
2478 } else {
2479 MonsterNameMake(-1);
2480 }
2481
2482 EdSystemMesStep();
2483 EdSystemMesDraw();
2484
2485 if (GameMode == ED_MODE_GEORAMA && (EditMenuStatus.mode == EDIT_MENU_MODE_PLACE || EditMenuStatus.mode == EDIT_MENU_MODE_REPLACE)) {
2486 EDITPARTS_INFO *info = EditPartsInfo.GetPartsInfo(NowSelectParts);
2487
2488 if (info != NULL) {
2489 int stock = info->stock;
2490 int percent = (stock - info->placed) * 100 / stock;
2491 CRect_i_ back;
2492 CRect_i_ bar;
2493 CRect_i_ fill;
2494
2495#ifdef PAL
2496 back.x = 0x1F20;
2497#else
2498 back.x = 0x1CA0;
2499#endif
2500 back.y = 0xBF8;
2501 back.width = 0x680;
2502 back.height = 0x70;
2503 MGFillBox(back, 0x14, 0x14, 0x14, 0x80);
2504#ifdef PAL
2505 bar.x = 0x1F40;
2506#else
2507 bar.x = 0x1CC0;
2508#endif
2509 bar.y = 0xC08;
2510 bar.width = 0x640;
2511 bar.height = 0x50;
2512 MGFillBox(bar, 0x64, 0x64, 0x64, 0x80);
2513#ifdef PAL
2514 fill.x = 0x1F40;
2515#else
2516 fill.x = 0x1CC0;
2517#endif
2518 fill.y = 0xC08;
2519 fill.width = percent * 0x10;
2520 fill.height = 0x50;
2521 MGFillBox(fill, 0xB4, 0x64, 0x28, 0x80);
2522#ifdef PAL
2523 DrawAtraBuildNum(info, 0x1F4, 0x181, 0x80);
2524#else
2525 DrawAtraBuildNum(info, 0x1CC, 0x181, 0x80);
2526#endif
2527 }
2528 }
2529
2530 EdFadeInOut();
2531
2532 if (clear_screen != 0) {
2533 CRect_i_ screen;
2534
2535 screen.x = 0;
2536 screen.y = 0;
2537 screen.width = 0x2800;
2538 screen.height = SCREEN_HALF_HEIGHT * 16;
2539 MGFillBox(screen, 0, 0, 0, 0x80);
2540 }
2541
2542 clear_screen = 0;
2543 }
2544}
2545
2549void ParamDraw() {
2550 sceVu0IVECTOR screen;
2551
2552 if (EdDebugParamDrawOff != 0) {
2553 return;
2554 }
2555
2556 TexManager.ReloadTexture(Vif1Packet, 20);
2557 VectorInterpolate(NowCursorPos, NowCursorPos, NextCursorPos, 4.0f, INTERPOLATE_FRACTION);
2558 NowCursorPos[3] = 1.0f;
2559 MGRotTransPers2D(screen, NowCursorPos, 0);
2560 CRect_i_ cursor(screen[0] - 10, screen[1] - 32, 32, 32);
2561 set2DSprite(Vif1Packet, TexManager.GetTexture("syst08", -1), cursor, 0, 0);
2562 screen[0] = 320;
2563 screen[1] = SCREEN_HALF_HEIGHT;
2564
2565 if (NowFocusParts != NULL && DrawPartsNameCount == 0) {
2566 int name_count = PartsNameNum;
2567
2568 if (name_count > 0) {
2569 int top;
2570 int step;
2571 int few = 6;
2572 int many = 9;
2573 step = 20;
2574 top = 0;
2575
2576 if (LanguageCode > LANG_JAPANESE) {
2577 few = 12;
2578 many = 18;
2579 step = 10;
2580 }
2581
2582 if (name_count < 7) {
2583 top += 48;
2584 step = step + ((step * (few - name_count)) >> 1);
2585 } else {
2586 step = step + ((step * (many - name_count)) >> 1);
2587 }
2588
2589 setbilinear(0);
2590 CRect_i_ plate;
2591 CRect_i_ source;
2592 int plate_y = screen[1];
2593 int text_y = plate_y + 14;
2594 EditNameMes.line_pos[0].x = screen[0] + step;
2595 EditNameMes.line_pos[0].y = text_y;
2596 source.x = 0;
2597 source.y = top;
2598 source.width = 220;
2599 source.height = 48;
2600 plate.x = screen[0];
2601 plate.y = screen[1];
2602 plate.width = 220;
2603 plate.height = 48;
2604 set2DSprite(Vif1Packet, TexManager.GetTexture("pnplate", -1), plate, source, 0x60);
2605 }
2606 }
2607}
2608
2612void EdSetCharaCursor(int on) {
2613 draw_npc_cursor = on;
2614}
2615
2619void EdDrawSysCursor(ED_EVENT_POINT *points, int count) {
2620 if (EdDebugParamDrawOff != 0) {
2621 return;
2622 }
2623
2624 static float offset = 2.5f;
2625 offset -= 0.1f;
2626
2627 if (offset < 0.0f) {
2628 offset = 2.5f;
2629 }
2630
2631 SetMonsterNameDrawFlag(0);
2632
2633 for (int i = 0; i < 10 && draw_npc_cursor != 0; i++) {
2634 int shown = EdVillager[i].initialized != 0 && EdVillager[i].draw_enabled != 0;
2635
2636 if (shown) {
2637 sceVu0FVECTOR position;
2638 sceVu0CopyVector(position, EdVillager[i].pos);
2639 position[1] += 2.0f + EdVillager[i].body_height;
2640
2641 if (EdInteriorFlag == 0 && EdVillager[i].CheckDraw() == 0 && EdVillager[i].talk_target == 0) {
2642 if (MapNo != TOWN_MUSKA_LACKA || EdVillager[i].villager_id != 8) {
2643 position[1] += offset;
2644 CharaCursor1->SetPosition(position);
2645 float yaw = 0.0f;
2646 CharaCursor1->SetRotation(0.0f, yaw, 0.0f);
2647 MGDraw(CharaCursor1);
2648 }
2649 } else if (EdVillager[i].CheckDraw() != 0 && EdVillager[i].talk_target != 0 && EdCheckViewMode() == 0) {
2650 CharaCursor0->SetPosition(position);
2651 MGDraw(CharaCursor0);
2652 position[3] = 1.0f;
2653 sceVu0IVECTOR screen;
2654
2655 if (MGRotTransPers2D(screen, position, 0) != 0) {
2656 MonsterNameMake(MapNo * 100 - 2000 + EdVillager[i].villager_id);
2657 MonsterNamePosSet(screen[0], screen[1] - 70);
2658 SetMonsterNameDrawFlag(1);
2659 }
2660 }
2661 }
2662 }
2663
2664 if (EdEventInfo.draw_exclamation_mark != 0) {
2665 if (CharaCursor2 != NULL) {
2666 sceVu0FVECTOR position;
2667 Chara->GetPosition(position);
2668 static float a = 0.0f;
2669 position[1] += 3.0f + Chara->body_height + 0.5f * sinf(a);
2670 a += 0.1f;
2671
2672 if (!(a <= PI_SHORT)) {
2673 a -= TWO_PI;
2674 }
2675
2676 CharaCursor2->SetPosition(position);
2677 CFrame *marker = CharaCursor2;
2678 marker->attr.billboard = 2;
2679 MGDraw(CharaCursor2);
2680 }
2681
2682 EdEventInfo.draw_exclamation_mark = false;
2683 }
2684
2685 EdEventPointDraw(points, count, NowTime);
2686 EdDrawOpenItemBox();
2687}
2688
2689float draw_day_cnt;
2690int draw_day_flag;
2691
2695void EdStartDrawDay() {
2696 draw_day_cnt = 5.0f;
2697 draw_day_flag = 1;
2698}
2699
2703void EdInitDrawDay() {
2704 draw_day_cnt = 0.0f;
2705 draw_day_flag = 0;
2706}
2707
2715class CRectZero : public CRect_i_ {
2716public:
2717 CRectZero() {
2718 height = 0;
2719 width = 0;
2720 y = 0;
2721 x = 0;
2722 }
2723
2724 CRectZero(s32 x, s32 y, s32 width, s32 height) {
2725 this->x = x;
2726 this->y = y;
2727 this->width = width;
2728 this->height = height;
2729 }
2730};
2731
2732#ifdef PAL
2733void DrawDay() {
2734 if (draw_day_flag != 0) {
2735 int week;
2736 int x;
2737 int width;
2738 int alpha;
2739 int day;
2740 int digit[4];
2741 CTexture *texture;
2742 int count;
2743 int drawn;
2744 int remain;
2745 int value;
2746
2747 draw_day_cnt -= 0.02f;
2748
2749 if (draw_day_cnt < 0.0f) {
2750 draw_day_cnt = 0.0f;
2751 draw_day_flag = 0;
2752 }
2753
2754 day = SaveData->GetDay() + 1;
2755 week = EdGetTime(NowTime);
2756 week++;
2757
2758 if (week > 3) {
2759 week = 0;
2760 }
2761
2762 x = 0x140;
2763
2764 if (draw_day_cnt > 4.0f) {
2765 alpha = (int) (128.0f * (5.0f - draw_day_cnt));
2766 } else if (draw_day_cnt > 1.0f) {
2767 alpha = 0x80;
2768 } else {
2769 alpha = (int) (128.0f * draw_day_cnt);
2770 }
2771
2772 count = 1;
2773 digit[3] = day / 1000;
2774 digit[2] = day % 1000 / 100;
2775 digit[1] = day % 100 / 10;
2776 digit[0] = day % 10;
2777 width = 0xA8;
2778
2779 if (day >= 10) {
2780 width += 0x18;
2781 count++;
2782 }
2783
2784 if (day >= 100) {
2785 width += 0x18;
2786 count++;
2787 }
2788
2789 if (day >= 1000) {
2790 width += 0x18;
2791 count++;
2792 }
2793
2794 x -= width >> 1;
2795 setbilinear(0);
2796 texture = TexManager.GetTexture("whatsday", -1);
2797
2798 CRect_i_ title(0x30, 0x58, 0x30, 0x18);
2799 CRect_i_ nichi(0x64, 0x40, 0x10, 0x18);
2800 CRect_i_ weekday(0, 0x40, 0x18, 0x18);
2801 CRect_i_ dai(0, 0x58, 0x30, 0x18);
2802 CRect_i_ bar_left(0, 0x70, 0x10, 0x10);
2803 CRect_i_ bar_middle(0x10, 0x70, 0x10, 0x10);
2804 CRect_i_ bar_right(0x20, 0x70, 0x10, 0x10);
2805 CRect_i_ word(0x78, 0x62, 0x65, 0x20);
2806 CRect_i_ word_end(0xDD, 0x62, 0x22, 0x20);
2807 CRectZero week_name[4];
2808
2809 switch (LanguageCode) {
2810 case LANG_ENGLISH_US:
2811 case LANG_ENGLISH_UK:
2812 week_name[0].x = 0x78;
2813 week_name[0].y = 2;
2814 week_name[0].width = 0x50;
2815 week_name[0].height = 0x20;
2816 week_name[1].x = 0x78;
2817 week_name[1].y = 0x22;
2818 week_name[1].width = 0x68;
2819 week_name[1].height = 0x20;
2820 week_name[2].x = 0x78;
2821 week_name[2].y = 0x42;
2822 week_name[2].width = 0x38;
2823 week_name[2].height = 0x20;
2824 week_name[3].x = 0xC8;
2825 week_name[3].y = 0x42;
2826 week_name[3].width = 0x38;
2827 week_name[3].height = 0x20;
2828 break;
2829 case LANG_GERMAN:
2830 word.x = 0x78;
2831 word.y = 0x62;
2832 word.width = 0x88;
2833 word.height = 0x20;
2834 word_end.x = 0;
2835 word_end.y = 0;
2836 word_end.width = 0;
2837 word_end.height = 0;
2838 week_name[0].x = 0x78;
2839 week_name[0].y = 2;
2840 week_name[0].width = 0x50;
2841 week_name[0].height = 0x20;
2842 week_name[1].x = 0x78;
2843 week_name[1].y = 0x22;
2844 week_name[1].width = 0x76;
2845 week_name[1].height = 0x20;
2846 week_name[2].x = 0x78;
2847 week_name[2].y = 0x42;
2848 week_name[2].width = 0x46;
2849 week_name[2].height = 0x20;
2850 week_name[3].x = 0xC4;
2851 week_name[3].y = 0x42;
2852 week_name[3].width = 0x40;
2853 week_name[3].height = 0x20;
2854 break;
2855 case LANG_SPANISH:
2856 word.x = 0x78;
2857 word.y = 0x62;
2858 word.width = 0x88;
2859 word.height = 0x20;
2860 word_end.x = 0;
2861 word_end.y = 0;
2862 word_end.width = 0;
2863 word_end.height = 0;
2864 week_name[0].x = 0x78;
2865 week_name[0].y = 2;
2866 week_name[0].width = 0x50;
2867 week_name[0].height = 0x20;
2868 week_name[1].x = 0x78;
2869 week_name[1].y = 0x22;
2870 week_name[1].width = 0x3E;
2871 week_name[1].height = 0x20;
2872 week_name[2].x = 0x78;
2873 week_name[2].y = 0x42;
2874 week_name[2].width = 0x46;
2875 week_name[2].height = 0x20;
2876 week_name[3].x = 0x78;
2877 week_name[3].y = 0x42;
2878 week_name[3].width = 0x46;
2879 week_name[3].height = 0x20;
2880 break;
2881 case LANG_FRENCH:
2882 word.x = 0x78;
2883 word.y = 0x62;
2884 word.width = 0x60;
2885 word.height = 0x20;
2886 word_end.x = 0;
2887 word_end.y = 0;
2888 word_end.width = 0;
2889 word_end.height = 0;
2890 week_name[0].x = 0x78;
2891 week_name[0].y = 2;
2892 week_name[0].width = 0x40;
2893 week_name[0].height = 0x20;
2894 week_name[1].x = 0x78;
2895 week_name[1].y = 0x22;
2896 week_name[1].width = 0x8C;
2897 week_name[1].height = 0x20;
2898 week_name[2].x = 0x78;
2899 week_name[2].y = 0x42;
2900 week_name[2].width = 0x32;
2901 week_name[2].height = 0x20;
2902 week_name[3].x = 0xAA;
2903 week_name[3].y = 0x42;
2904 week_name[3].width = 0x34;
2905 week_name[3].height = 0x20;
2906 break;
2907 case LANG_ITALIAN:
2908 word.x = 0x78;
2909 word.y = 0x62;
2910 word.width = 0x44;
2911 word.height = 0x20;
2912 word_end.x = 0;
2913 word_end.y = 0;
2914 word_end.width = 0;
2915 word_end.height = 0;
2916 week_name[0].x = 0x78;
2917 week_name[0].y = 2;
2918 week_name[0].width = 0x50;
2919 week_name[0].height = 0x20;
2920 week_name[1].x = 0x78;
2921 week_name[1].y = 0x22;
2922 week_name[1].width = 0x76;
2923 week_name[1].height = 0x20;
2924 week_name[2].x = 0x76;
2925 week_name[2].y = 0x42;
2926 week_name[2].width = 0x32;
2927 week_name[2].height = 0x20;
2928 week_name[3].x = 0xA4;
2929 week_name[3].y = 0x42;
2930 week_name[3].width = 0x38;
2931 week_name[3].height = 0x20;
2932 break;
2933 }
2934
2935 CRectZero week_word;
2936 week_word = week_name[week];
2937 CRectZero cell(0, 0, 0x18, 0x20);
2938 CRectZero number;
2939
2940 if (texture != NULL) {
2941 switch (LanguageCode) {
2942 case LANG_JAPANESE:
2943 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xE4, title.width, title.height), title, alpha);
2944 x += 0x30;
2945 break;
2946 case LANG_ENGLISH_US:
2947 case LANG_ENGLISH_UK:
2948 width = week_word.width + (word_end.width + (word.width + ((count - 1) * 32)) + 0x48);
2949 x = 0x140 - (int) (width >> 1);
2950 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xE4, word.width, word.height), word, alpha);
2951 x += word.width + 0xC;
2952 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xE4, word_end.width, word_end.height), word_end, alpha);
2953 x += word_end.width + 0xC;
2954 break;
2955 case LANG_FRENCH:
2956 case LANG_GERMAN:
2957 case LANG_ITALIAN:
2958 case LANG_SPANISH:
2959 width = week_word.width + (word_end.width + (word.width + ((count - 1) * 32)) + 0x38);
2960 x = 0x140 - (int) (width >> 1);
2961 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xE4, word.width, word.height), word, alpha);
2962 x += word.width + 0xC;
2963 break;
2964 }
2965
2966 int n;
2967
2968 for (n = count; n > 0; n--) {
2969 number = cell;
2970 value = digit[n - 1];
2971
2972 number.x += number.width * (value % 5);
2973 number.y += number.height * (value / 5);
2974 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xE2, number.width, number.height), number, alpha);
2975 x += number.width;
2976 }
2977
2978 switch (LanguageCode) {
2979 case LANG_JAPANESE:
2980 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xE4, dai.width, dai.height), dai, alpha);
2981 x += dai.width;
2982 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xE4, nichi.width, nichi.height), nichi, alpha);
2983 x += nichi.width;
2984 weekday.x += week * 0x18;
2985 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xE4, weekday.width, weekday.height), weekday, alpha);
2986 break;
2987 case LANG_ENGLISH_US:
2988 case LANG_ENGLISH_UK:
2989 case LANG_FRENCH:
2990 case LANG_GERMAN:
2991 case LANG_ITALIAN:
2992 case LANG_SPANISH:
2993 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xE4, nichi.width, nichi.height), nichi, alpha);
2994 x += nichi.width;
2995 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xE4, week_word.width, week_word.height), week_word, alpha);
2996 break;
2997 }
2998
2999 drawn = 0;
3000 x = 0x134 - (int) (width >> 1);
3001 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xFC, bar_left.width, bar_left.height), bar_left, alpha);
3002 drawn += bar_left.width;
3003 x += bar_left.width;
3004 remain = width - (bar_right.width >> 2);
3005
3006 while (drawn < width - bar_right.width) {
3007 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xFC, bar_middle.width, bar_middle.height), bar_middle, alpha);
3008 x += bar_middle.width;
3009 remain -= bar_middle.width;
3010 drawn += bar_middle.width;
3011 }
3012
3013 bar_right.x += bar_right.width - remain;
3014 bar_right.width = remain;
3015 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xFC, bar_right.width, bar_right.height), bar_right, alpha);
3016 }
3017 }
3018}
3019#else
3020void DrawDay() {
3021 if (draw_day_flag != 0) {
3022 int week;
3023 int x;
3024 int width;
3025 int alpha;
3026 int day;
3027 int digit[4];
3028 CTexture *texture;
3029 int count;
3030 int drawn;
3031 int remain;
3032 int value;
3033
3034 draw_day_cnt -= 0.02f;
3035
3036 if (draw_day_cnt < 0.0f) {
3037 draw_day_cnt = 0.0f;
3038 draw_day_flag = 0;
3039 }
3040
3041 day = SaveData->GetDay() + 1;
3042 week = EdGetTime(NowTime);
3043 week++;
3044
3045 if (week > 3) {
3046 week = 0;
3047 }
3048
3049 x = 0x140;
3050
3051 if (draw_day_cnt > 4.0f) {
3052 alpha = (int) (128.0f * (5.0f - draw_day_cnt));
3053 } else if (draw_day_cnt > 1.0f) {
3054 alpha = 0x80;
3055 } else {
3056 alpha = (int) (128.0f * draw_day_cnt);
3057 }
3058
3059 count = 1;
3060 digit[3] = day / 1000;
3061 digit[2] = day % 1000 / 100;
3062 digit[1] = day % 100 / 10;
3063 digit[0] = day % 10;
3064 width = 0xA8;
3065
3066 if (day >= 10) {
3067 width += 0x18;
3068 count++;
3069 }
3070
3071 if (day >= 100) {
3072 width += 0x18;
3073 count++;
3074 }
3075
3076 if (day >= 1000) {
3077 width += 0x18;
3078 count++;
3079 }
3080
3081 x -= width >> 1;
3082 setbilinear(0);
3083 texture = TexManager.GetTexture("whatsday", -1);
3084
3085 CRect_i_ title(0x30, 0x58, 0x30, 0x18);
3086 CRect_i_ nichi(0x64, 0x40, 0x10, 0x18);
3087 CRect_i_ weekday(0, 0x40, 0x18, 0x18);
3088 CRect_i_ dai(0, 0x58, 0x30, 0x18);
3089 CRect_i_ bar_left(0, 0x70, 0x10, 0x10);
3090 CRect_i_ bar_middle(0x10, 0x70, 0x10, 0x10);
3091 CRect_i_ bar_right(0x20, 0x70, 0x10, 0x10);
3092 CRect_i_ word(0x78, 0x62, 0x65, 0x20);
3093 CRect_i_ word_end(0xDD, 0x62, 0x22, 0x20);
3094 CRectZero week_name[4];
3095 week_name[0].x = 0x78;
3096 week_name[0].y = 2;
3097 week_name[0].width = 0x50;
3098 week_name[0].height = 0x20;
3099 week_name[1].x = 0x78;
3100 week_name[1].y = 0x22;
3101 week_name[1].width = 0x68;
3102 week_name[1].height = 0x20;
3103 week_name[2].x = 0x78;
3104 week_name[2].y = 0x42;
3105 week_name[2].width = 0x38;
3106 week_name[2].height = 0x20;
3107 week_name[3].x = 0xC8;
3108 week_name[3].y = 0x42;
3109 week_name[3].width = 0x38;
3110 week_name[3].height = 0x20;
3111 CRectZero week_word;
3112 week_word = week_name[week];
3113 CRectZero cell(0, 0, 0x18, 0x20);
3114 CRectZero number;
3115
3116 if (texture != NULL) {
3117 switch (LanguageCode) {
3118 case LANG_JAPANESE:
3119 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xD4, title.width, title.height), title, alpha);
3120 x += 0x30;
3121 break;
3122 case LANG_ENGLISH_US:
3123 width = week_word.width + (word_end.width + (word.width + ((count - 1) * 32)) + 0x48);
3124 x = 0x140 - (int) (width >> 1);
3125 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xD4, word.width, word.height), word, alpha);
3126 x += word.width + 0xC;
3127 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xD4, word_end.width, word_end.height), word_end, alpha);
3128 x += word_end.width + 0xC;
3129 break;
3130 default:
3131 break;
3132 }
3133
3134 int n;
3135
3136 for (n = count; n > 0; n--) {
3137 number = cell;
3138 value = digit[n - 1];
3139
3140 number.x += number.width * (value % 5);
3141 number.y += number.height * (value / 5);
3142 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xD2, number.width, number.height), number, alpha);
3143 x += number.width;
3144 }
3145
3146 switch (LanguageCode) {
3147 case LANG_JAPANESE:
3148 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xD4, dai.width, dai.height), dai, alpha);
3149 x += dai.width;
3150 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xD4, nichi.width, nichi.height), nichi, alpha);
3151 x += nichi.width;
3152 weekday.x += week * 0x18;
3153 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xD4, weekday.width, weekday.height), weekday, alpha);
3154 break;
3155 case LANG_ENGLISH_US:
3156 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xD4, nichi.width, nichi.height), nichi, alpha);
3157 x += nichi.width;
3158 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xD4, week_word.width, week_word.height), week_word, alpha);
3159 break;
3160 }
3161
3162 drawn = 0;
3163 x = 0x13C - (int) (width >> 1);
3164 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xEC, bar_left.width, bar_left.height), bar_left, alpha);
3165 drawn += bar_left.width;
3166 x += bar_left.width;
3167 remain = width - bar_right.width;
3168
3169 while (drawn < width - bar_right.width) {
3170 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xEC, bar_middle.width, bar_middle.height), bar_middle, alpha);
3171 x += bar_middle.width;
3172 remain -= bar_middle.width;
3173 drawn += bar_middle.width;
3174 }
3175
3176 bar_right.x += bar_right.width - remain;
3177 bar_right.width = remain;
3178 set2DSprite(GetVif1Packet(), texture, CRect_i_(x, 0xEC, bar_right.width, bar_right.height), bar_right, alpha);
3179 }
3180 }
3181}
3182#endif
3183
3187void DrawSysGra() {
3188 if (EdDebugParamDrawOff == 0) {
3189 TexManager.ReloadTexture(Vif1Packet, 20);
3190 EdDrawSysCursor(EditMapInfo->work.events.points, 256);
3191
3192 if (FishingDrawCheck() == 0) {
3193 EdDrawClock(0, 0);
3194 }
3195
3196 DrawDay();
3197
3198 char pause_texture[] = "pause";
3199
3200 if ((unsigned int) (GameMode - 9) <= 1 || EdPauseFlag != 0) {
3201 CRect_i_ fade;
3202 fade.x = 0;
3203 fade.y = 0;
3204 fade.width = 0x2800;
3205 fade.height = (SCREEN_HALF_HEIGHT << 4);
3206 MGFillBox(fade, 0, 0, 0, 0x40);
3207 setbilinear(0);
3208
3209 CRect_i_ screen;
3210 CRect_i_ texel;
3211 texel.x = 0;
3212 texel.y = 0;
3213 texel.width = 0x80;
3214 texel.height = 0x28;
3215 screen.x = 0x100;
3216#ifdef PAL
3217 screen.y = 0xdc;
3218#else
3219 screen.y = 0xcc;
3220#endif
3221 screen.width = 0x80;
3222 screen.height = 0x28;
3223 set2DSprite(GetVif1Packet(), TexManager.GetTexture(pause_texture, -1), screen, texel, 0x80);
3224 }
3225 }
3226}
3227
3231void EdDrawClock(int x, int y) {
3232 if (draw_clock != 0 && EditMapInfo->time_stop == 0) {
3233 TexManager.ReloadTexture(Vif1Packet, 20);
3234 setbilinear(0);
3235
3236 CRect_i_ clock_screen;
3237 CRect_i_ clock_texel;
3238 clock_texel.x = 0;
3239 clock_texel.y = 0;
3240 clock_texel.width = 88;
3241 clock_texel.height = 80;
3242 clock_screen.x = x + 520;
3243 clock_screen.y = y + 14;
3244 clock_screen.width = 88;
3245 clock_screen.height = 80;
3246 set2DSprite(GetVif1Packet(), TexManager.GetTexture("dayclock", -1), clock_screen, clock_texel, 128);
3247
3248 float scale = 2.0f * (NowTime / 12.0f);
3249 float pi = PI_SHORT;
3250 float angle = pi * scale;
3251 angle = SIXTH_PI_SHORT + (pi - angle);
3252 CRect_i_ hand_screen;
3253 CRect_i_ hand_texel;
3254 hand_texel.x = 88;
3255 hand_texel.y = 0;
3256 hand_texel.width = 22;
3257 hand_texel.height = 40;
3258 hand_screen.x = x + 564;
3259 hand_screen.y = y + 54;
3260 hand_screen.width = 22;
3261 hand_screen.height = 40;
3262 set2DSpriteRot(GetVif1Packet(), TexManager.GetTexture("dayclock", -1), hand_screen, hand_texel, 12, 40, angle, 128);
3263 }
3264}
3265
3269void MainMode() {
3270 Chara = &MainChara;
3271 MoveChara();
3272}
3273
3277int FrameOnOff(CFrame *root, char *name, int on) {
3278 if (root == NULL) {
3279 return 0;
3280 }
3281
3282 if (name == NULL) {
3283 return 0;
3284 }
3285
3286 CFrame *frame = root->SearchFrame(name);
3287
3288 if (frame == NULL) {
3289 return 0;
3290 }
3291
3292 frame->attr.draw_on = on;
3293 return 0;
3294}
3295
3299void EditPartsObjectOnOff() {
3300 int parts = EditPartsInfo.GetNextParts(-1);
3301
3302 while (parts >= 0) {
3303 EdPartsObjectOnOff(&ObjParts[parts], EditPartsInfo.GetPartsInfo(parts), 0);
3304 parts = EditPartsInfo.GetNextParts(parts);
3305 }
3306
3307 pEditGround->RequestCheck();
3308}
3309
3313void EditMode() {
3314 pEditGround->EffectTask();
3315 pEditGround->MakePartsBox();
3316 MoveEditCursor();
3317 EditPartsObjectOnOff();
3318}
3319
3327void MainEditMode() {
3328 if (EdEventInfo.lighting_override != 0) {
3329 MGSetPLight(EdEventInfo.light_direction, EdEventInfo.light_color);
3330 MGSetAmbient(EdEventInfo.ambient_color);
3331 } else {
3332 EdSetLightParam(NowTime, edit_mode_lighting, EditMapInfo, SkyBackFrame);
3333 }
3334
3335 pEditGround->StepWater();
3336
3337 sceVu0FVECTOR wind;
3338
3339 sceVu0CopyVector(wind, EditMapInfo->wind);
3340
3341 if (EdEventInfo.wind[3] > 0.0f) {
3342 sceVu0CopyVector(wind, EdEventInfo.wind);
3343 }
3344
3345 float left_x = GamePad.GetLXf2();
3346 float left_y = GamePad.GetLYf2();
3347 float camera_angle = MainCamera.GetAngle();
3348 sceVu0FVECTOR direction;
3349
3350 direction[0] = wind[0] + (left_x * cosf(camera_angle) + left_y * sinf(camera_angle));
3351 direction[2] = wind[2] + (left_y * cosf(camera_angle) - left_x * sinf(camera_angle));
3352 direction[1] = wind[1];
3353 direction[3] = 0.0f;
3354 EdWind.SetDir(direction);
3355 EdWind.SetVelocity(wind[3]);
3356 EdWind.Step();
3357 Chara->wind = (int) &EdWind;
3358
3359 for (int i = 0; i < 4; i++) {
3360 MotionParts[i].Step();
3361 }
3362
3363 for (int i = 0; i < EditMapInfo->obj_anime_count; i++) {
3364 OBJ_ANIME_SEQ *anime = &EditMapInfo->work.obj_anime[i];
3365
3366 if (anime->completion_flag <= 0 || EdGetMapFlag(anime->completion_flag) == 0) {
3367 ObjAnimePlay(anime);
3368 }
3369 }
3370
3371 float saved_time = SaveData->GetNowTime();
3372 int clock_kept = 1;
3373 int old_hour = EdGetTime(NowTime);
3374
3375 if (NowTime != SaveData->GetNowTime()) {
3376 clock_kept = 0;
3377 }
3378
3379 SaveData->SetNowTime(NowTime);
3380 static int time_flag = 1;
3381
3382 float time_step = 0.0011133334f;
3383
3384 if (((int *) SaveData->GetConfigData())[3] == 0) {
3385 time_step /= 2.0f;
3386 }
3387
3388 if (change_time_event != 0) {
3389 time_step = 0.0f;
3390 }
3391
3392 if (time_flag != 0 && GameMode == ED_MODE_WALK) {
3393 SaveData->AddNowTime(time_step);
3394 }
3395
3396 if (GamePad.Down2(PAD_DOWN) != 0) {
3397 time_flag = (u8) !time_flag;
3398 }
3399
3400 if (!(NowTime < 12.0f)) {
3401 NowTime = 0.0f;
3402 }
3403
3404 if (GamePad.On2(PAD_RIGHT) != 0) {
3405 SaveData->AddNowTime(0.021f);
3406 }
3407
3408 if (GamePad.On2(PAD_LEFT) != 0) {
3409 SaveData->AddNowTime(-0.02f);
3410 }
3411
3412 int hour_set = 0;
3413
3414 if (GamePad.Down2(PAD_UP) != 0) {
3415 NowTime = 1.0f + (float) (int) NowTime;
3416
3417 if (!(NowTime < 12.0f)) {
3418 NowTime = 0.0f;
3419 }
3420
3421 hour_set = 1;
3422 SaveData->SetNowTime(NowTime);
3423 }
3424
3425 NowTime = SaveData->GetNowTime();
3426
3427 if (EditMapInfo->time_stop != 0) {
3428 NowTime = 0.0f;
3429 SaveData->SetNowTime(saved_time);
3430 }
3431
3432 int new_hour = EdGetTime(NowTime);
3433
3434 if (clock_kept != 0 && time_flag != 0 && old_hour != new_hour && hour_set == 0) {
3435 if (MapNo < 4) {
3436 change_time_event = 1;
3437 } else {
3438 EdStartDrawDay();
3439 }
3440 }
3441
3442 if (GameMode == ED_MODE_WALK) {
3443 ItemVolumeStep.LoopStep(60);
3444
3445 if (sound_off_cnt <= 0) {
3446 if (EditMapInfo->time_stop == 0) {
3447 EdSetBgmVol(NowTime);
3448 } else {
3449 SndBgmPlay(0);
3450 }
3451
3452 PlayAmbient(NowTime);
3453 }
3454 }
3455
3456 int night = EdGetTime(NowTime) == ED_TIME_NIGHT;
3457
3458 static int parts = 0;
3459
3460 int level;
3461 int day_on = 1;
3462 int night_on = 2;
3463
3464 if (night != 0) {
3465 day_on = night_on;
3466 night_on = 1;
3467 }
3468
3469 char day_window[10] = "win1";
3470 char night_window[10] = "win2";
3471
3472 for (level = 0; level < 4; level++) {
3473 CMapParts *obj = &ObjParts[parts];
3474 CFrame *frame = obj->frame[level];
3475
3476 FrameOnOff(frame, day_window, day_on);
3477 FrameOnOff(frame, night_window, night_on);
3478 }
3479
3480 parts++;
3481
3482 if (!(parts < 24)) {
3483 parts = 0;
3484 }
3485
3486 static int now_obj = 0;
3487
3488 EDIT_OBJECT_TIMER *timers = EditMapInfo->work.object_timers.timers;
3489
3490 for (int i = 0; i < 2; i++, now_obj++) {
3491 if (!(now_obj < EditMapInfo->object_timer_count)) {
3492 now_obj = 0;
3493 }
3494
3495 EDIT_OBJECT_TIMER *timer = &timers[now_obj];
3496
3497 if (timer->name[0] != '\0') {
3498 int on = 1;
3499
3500 if (EdCheckTime(NowTime, timer->start_time, timer->end_time) == 0) {
3501 on = 2;
3502 }
3503
3504 if (timer->object != NULL) {
3505 timer->object->FrameObjectOnOff(timer->name, on);
3506 } else if (timer->frame != NULL) {
3507 CFrame *found = timer->frame->SearchFrame(timer->name);
3508
3509 if (found != NULL) {
3510 found->attr.draw_on = on;
3511 }
3512 }
3513 }
3514 }
3515}
3516
3521void OpenDoorMode() {
3522 Chara->SetVelocity(CVector3_f_(0.0f, 0.0f, 0.0f));
3523 Chara->Step();
3524 Chara->ShadowStep();
3525 Chara->ClothStep(0);
3526
3527 if (door_open) {
3528 Chara->SetPosition(fix_chara_pos);
3529 Chara->SetRotation(fix_chara_rot[0], fix_chara_rot[1], fix_chara_rot[2]);
3530 MainCamera.SetPos(fix_camera_pos);
3531 MainCamera.SetRef(fix_chara_pos[0], 14.0f + fix_chara_pos[1], fix_chara_pos[2]);
3532 }
3533}
3534
3539void TalkMode() {
3540 int i;
3541 int event_no;
3542
3543 if (talk_villager < 0 || talk_villager >= 10) {
3544 GameMode = ED_MODE_WALK;
3545 return;
3546 }
3547
3548 CCharacter *chara = Chara;
3549 chara->motion_no = 0;
3550 chara->motion_flags = 0;
3551 chara->motion_speed = -1.0f;
3552 Chara->SetVelocity(CVector3_f_(0.0f, 0.0f, 0.0f));
3553 Chara->Step();
3554 Chara->ShadowStep();
3555 Chara->ClothStep(0);
3556
3557 for (i = 0; i < 10; i++) {
3558 EdVillager[i].alpha_step_override = 128;
3559 EdVillager[i].near_camera = false;
3560 }
3561
3562 int result = EdTalkMode(Chara, &TalkCamera, 0, &event_no);
3563
3564 if (result != 0) {
3565 if (result == 2) {
3566 goto_menu = ED_MENU_SHOP;
3567 }
3568
3569 if (result == 3) {
3570 goto_menu = ED_MENU_UNK_4;
3571 }
3572
3573 if (result == 4 && event_no > 0) {
3574 RunEvent(event_no, NowCamera);
3575 }
3576
3577 GameMode = ED_MODE_WALK;
3578 NowCamera = &MainCamera;
3579 } else {
3580 for (i = 0; i < 10; i++) {
3581 EdVillager[i].Step();
3582 EdVillager[i].ClothStep(0);
3583 }
3584 }
3585}
3586
3591void EventMode() {
3592 sceVu0FVECTOR pos;
3593 sceVu0FVECTOR ref;
3594
3595 int result = EdEventMode(&EventCamera, 0);
3596
3597 if (result == ED_EVENT_RETURN_NONE) {
3598 return;
3599 }
3600
3601 switch (result) {
3603 GotoInterior(EdEventInfo.interior_name, EdEventInfo.interior_entrance, 0, NULL, EdEventInfo.interior_start_event);
3604 break;
3606 GotoDungeon();
3607 break;
3609 break;
3611 EdExitLoop();
3612 break;
3614 EdExitLoop();
3615 break;
3617 GameMode = ED_MODE_TALK;
3618 break;
3620 GameMode = ED_MODE_FISHING;
3621 break;
3622 default:
3623 GameMode = ED_MODE_WALK;
3624
3625 if (EdEventInfo.reset_camera_angle > 0) {
3626 Chara->GetPosition(pos);
3627 Chara->GetRotation(ref);
3628 MainCamera.FollowOn();
3629 float angle = ref[1] + EdEventInfo.reset_camera_yaw;
3630 angle = AngleLimit(angle);
3631 MainCamera.SetAngleSoon(angle);
3632 MainCamera.SetFollow(pos[0], pos[1] + Chara->body_height - 3.0f, pos[2]);
3633 EdInitCameraParam(&MainCamera);
3634 MainCamera.Step(-1);
3635 }
3636
3637 if (EdEventInfo.reset_camera_angle < 0) {
3638 EventCamera.GetPos(pos);
3639 EventCamera.GetRef(ref);
3640 MainCamera.FollowOff();
3641 MainCamera.SetPos(pos);
3642 MainCamera.SetRef(ref);
3643 MainCamera.Step(-1);
3644 MainCamera.Step(1);
3645 MainCamera.FollowOn();
3646 MainCamera.SetHeight(pos[1] - ref[1]);
3647 MainCamera.SetFollow(ref[0], ref[1], ref[2]);
3648 MainCamera.SetAngleSoon(atan2(pos[0] - ref[0], pos[2] - ref[2]));
3649 MainCamera.Step(-1);
3650 MainCamera.Step(1);
3651 }
3652
3653 if (EdEventInfo.fadeout_event_no >= 0) {
3654 FadeOutToEvent(EdEventInfo.fadeout_event_no, 0);
3655 }
3656
3657 CEditGround *ground = pEditGround;
3658 ground->clip_plane[3] = -1.0f;
3659 break;
3660 }
3661}
3662
3666int GotoDungeon() {
3667 return goto_dungeon = 1;
3668}
3669
3674void EdDeleteE05RoboParts() {
3675 int count;
3676
3677 for (int i = 0; i < 14; i++) {
3678 SV_EDIT_PARTS_INFO *plot = SaveData->GetEditPartsInfo(4, i);
3679
3680 if (plot != NULL) {
3681 plot->obtained = 0;
3682 plot->placed = false;
3683 plot->stock = 0;
3684 }
3685 }
3686
3687 s16 *elements = SaveData->GetElemData(4);
3688
3689 if (elements != NULL) {
3690 for (int i = 0; i < 128; i++) {
3691 *elements = -1;
3692 elements++;
3693 }
3694 }
3695
3696 SV_GRD_PART *parts = SaveData->GetParts(4, &count);
3697
3698 for (int i = 0; i < count; i++, parts++) {
3699 parts->part_id = -1;
3700 }
3701}
3702
3706int GotoInterior(char *name, int entrance, int direction, ED_EVENT_PARAM *param, int start_event) {
3707 char *suffix[5] = {"m", "e", "n", "m", ""};
3708 char path[0x40];
3709 ED_EVENT_PARAM entry;
3710 sceVu0FVECTOR position;
3711 sceVu0FVECTOR rotation;
3712
3713 int period = EdGetTime(NowTime);
3714 strcpy(EdInteriorName, name);
3715 sprintf(path, "%sin/%s/%s%s", EditDataDir, name, name, suffix[period]);
3716 sprintf(interior_map_name, "%s", path);
3717 EdInteriorPartsNo = entrance;
3718 EdNPCBuffer.used = 0;
3719
3720 if (param == NULL) {
3721 direction = 0;
3722 }
3723
3724 EdInteriorJumpID = 0;
3725
3726 if (param != NULL) {
3727 EdInteriorJumpID = param->point->map_no;
3728 }
3729
3730 door_open = direction;
3731 door_open_cnt = 160;
3732 GameMode = ED_MODE_DOOR_OPEN;
3733 EdInteriorDoorSound = -1;
3734
3735 if (direction != 0) {
3736 fix_pos_enble = 1;
3737 EdInteriorDoorSound = param->point->linked_value;
3738 int forward = direction > 0;
3739 Chara->SetMotion(EdGetDoorMotion(param->point->linked_value, forward), 6);
3740 sceVu0CopyVector(fix_chara_pos, param->position);
3741 sceVu0CopyVector(fix_chara_rot, param->rotation);
3742 Chara->SetPosition(fix_chara_pos);
3743 Chara->SetRotation(fix_chara_rot[0], fix_chara_rot[1], fix_chara_rot[2]);
3744 Chara->ClothStep(-1);
3745 sceVu0CopyVector(fix_camera_pos, param->camera_pos);
3746 MainCamera.SetPos(fix_camera_pos);
3747 MainCamera.SetRef(fix_chara_pos[0], 14.0f + fix_chara_pos[1], fix_chara_pos[2]);
3748 MainCamera.FollowOff();
3749 MainCamera.Step(10);
3750 MainCamera.Step(-1);
3751 } else {
3752 fix_pos_enble = 0;
3753 sound_off_cnt = 160;
3754
3755 if (EdSearchEvent(&entry, name, 0, NowTime) != 0) {
3756 sceVu0CopyVector(fix_chara_pos, entry.position);
3757 sceVu0CopyVector(fix_chara_rot, entry.rotation);
3758 Chara->SetPosition(fix_chara_pos);
3759 Chara->SetRotation(fix_chara_rot[0], fix_chara_rot[1], fix_chara_rot[2]);
3760 sceVu0CopyVector(fix_camera_pos, entry.camera_pos);
3761 MainCamera.SetPos(fix_camera_pos);
3762 MainCamera.SetRef(fix_chara_pos[0], 14.0f + fix_chara_pos[1], fix_chara_pos[2]);
3763 } else {
3764 Chara->GetPosition(position);
3765 Chara->GetRotation(rotation);
3766 sceVu0CopyVector(fix_chara_pos, position);
3767 sceVu0CopyVector(fix_chara_rot, rotation);
3768 MainCamera.GetPos(position);
3769 MainCamera.GetRef(rotation);
3770 sceVu0CopyVector(fix_camera_pos, position);
3771 MainCamera.SetRef(fix_chara_pos[0], 14.0f + fix_chara_pos[1], fix_chara_pos[2]);
3772 }
3773 }
3774
3775 EdFadeOut(100, 0.0f, 0.0f, 0.0f);
3776
3777 for (int i = 0; i < 10; i++) {
3778 EdVillager[i].near_camera = false;
3779 }
3780
3781 EdInteriorStartEvent = start_event;
3782
3783 if (start_event < 0) {
3784 EdInteriorStartEvent = 128;
3785 }
3786
3787 return 1;
3788}
3789
3793void MoveCamera(CCameraFollow *camera) {
3794 float horizontal = GamePad.GetRXf();
3795 camera->AddHeight(-GamePad.GetRYf());
3796
3797 if (EdDebugCameraFlag == 0 && !(camera->GetHeight() <= 30.0f)) {
3798 camera->SetHeight(30.0f);
3799 }
3800
3801 camera->AddAngle(0.03f * -horizontal);
3802
3803 if (horizontal == 0.0f) {
3804 if (GamePad.On(PAD_R1) != 0) {
3805 camera->AddAngle(-DEG_TO_RAD);
3806 }
3807
3808 if (GamePad.On(PAD_L1) != 0) {
3809 camera->AddAngle(DEG_TO_RAD);
3810 }
3811 }
3812}
3813
3817int GetCollision(CCPoly *poly, CBoxVu0 *box) {
3818 sceVu0FVECTOR centre;
3819 sceVu0AddVector(centre, box->max, box->min);
3820 sceVu0ScaleVector(centre, centre, 0.5f);
3821 return pEditGround->PickUpPoly(poly, centre[0], centre[1], centre[2]);
3822}
3823
3827void MoveChara() {
3828 sceVu0FVECTOR pos;
3829 sceVu0FVECTOR part_rot;
3830 sceVu0FVECTOR part_pos;
3831 sceVu0FMATRIX world;
3832 sceVu0FMATRIX inverse;
3833 sceVu0FVECTOR run_pos;
3834 sceVu0FVECTOR splash_pos;
3835
3836 EdMoveCharaInfo.time = NowTime;
3837 EdMoveCharaInfo.camera = &MainCamera;
3838 ViewCamera.FollowOff();
3839 EdMoveCharaInfo.view_camera = &ViewCamera;
3840 EdMoveCharaInfo.key_lock = key_lock;
3841 EdMoveCharaInfo.chara = Chara;
3842 EdMoveCharaInfo.interior = false;
3843 EdMoveCharaInfo.ground = pEditGround;
3844 EDIT_MAP_INFO *info = EditMapInfo;
3845 EdMoveCharaInfo.points = info->work.events.points;
3846 EdMoveCharaInfo.point_count = info->event_count;
3847 EdMoveCharaInfo.fishing = (GameMode == ED_MODE_FISHING);
3848 EdMoveChara();
3849
3850 if (EdMoveCharaInfo.system_event_no > 0) {
3851 RunSystemEvent(EdMoveCharaInfo.system_event_no, &MainCamera);
3852 } else if (EdMoveCharaInfo.event_no > 0) {
3853 RunEvent(EdMoveCharaInfo.event_no, &MainCamera);
3854 } else if (EdMoveCharaInfo.event_ready != 0) {
3855 ED_EVENT_PARAM *param = &EdMoveCharaInfo.param;
3856
3857 if (param->kind == ED_EVENT_POINT_DOOR) {
3858 if (strcmp(param->point->destination, "dungeon") == 0) {
3859 RunEvent(130, &MainCamera);
3860 } else if (EdPadDown(0x40, 1) != 0 && EdCheckViewMode() == 0 && key_lock == 0) {
3861 ED_EVENT_POINT *point = param->point;
3862
3863 if (point->minimum_progress > 0) {
3864 RunEvent(EdInitGotoInterior(&EdEventInfo, param), NowCamera);
3865 } else {
3866 GotoInterior(point->destination, param->parts_no, point->side, param, -1);
3867 }
3868 }
3869 }
3870 } else {
3871 if (loop_counter > 60) {
3872 Chara->GetPosition(pos);
3873 CMapParts *parts = pEditGround->GetParts(pos[0], pos[1], pos[2]);
3874
3875 if (parts != NULL) {
3876 int plot = parts->parts_no;
3877 EDITPARTS_INFO *plot_info = EditPartsInfo.GetPartsInfo(plot);
3878
3879 if (plot_info != NULL && plot_info->kind == 2 && !(plot_info->completion_flags & 1) && EditPartsInfo.CheckComplete(plot) != 0) {
3880 FadeOutToEvent(plot + 200, 0);
3881 }
3882 }
3883 }
3884
3885 if (GamePad.Down(PAD_CROSS) != 0) {
3886 Chara->GetPosition(pos);
3887 CMapParts *parts = pEditGround->GetParts(pos[0], pos[1], pos[2]);
3888
3889 if (parts != NULL) {
3890 parts->GetPosition(part_pos);
3891 parts->GetRotation(part_rot);
3892 sceVu0UnitMatrix(world);
3893 sceVu0RotMatrixY(world, world, part_rot[1]);
3894 sceVu0CopyVector(world[3], part_pos);
3895 world[3][3] = 1.0f;
3896 sceVu0InversMatrix(inverse, world);
3897 pos[3] = 1.0f;
3898 sceVu0ApplyMatrix(pos, inverse, pos);
3899 Chara->GetRotation(pos);
3900 pos[1] = pos[1] - part_rot[1];
3901
3902 if (!(pos[1] <= PI_SHORT)) {
3903 pos[1] -= TWO_PI_SHORT;
3904 }
3905
3906 if (pos[1] < -PI_SHORT) {
3907 pos[1] += TWO_PI_SHORT;
3908 }
3909 } else {
3910 Chara->GetRotation(pos);
3911 }
3912 }
3913 }
3914
3915 if (CheckMotionTime(EdMoveCharaInfo.motion_time_before, EdMoveCharaInfo.motion_time_after, 74.0f) != 0) {
3916 Chara->GetPosition(run_pos);
3917 RunEffect.Set(run_pos);
3918 }
3919
3920 if (CheckMotionTime(EdMoveCharaInfo.motion_time_before, EdMoveCharaInfo.motion_time_after, 84.0f) != 0) {
3921 Chara->GetPosition(splash_pos);
3922 RunEffect.Set(splash_pos);
3923 }
3924
3925 if (GameMode == ED_MODE_WALK) {
3926 if (MapNo < 10) {
3927 EdMoveVillager(EdVillagerInfo);
3928 } else {
3929 EdMoveVillagerSubMap(EdVillagerInfo);
3930 }
3931 }
3932}
3933
3938void VillagerCollision() {
3939 sceVu0FVECTOR pos;
3940 CBoxVu0 box;
3941 sceVu0FVECTOR foot_pos;
3942 CCPoly poly;
3943
3944 for (int i = -1; i < 10; i++) {
3945 int snap_to_ground;
3946 CCharacter *chara;
3947 CNPCharacter *villager = NULL;
3948 int foot_sound;
3949
3950 if (i >= 0) {
3951 villager = &EdVillager[i];
3952 snap_to_ground = EdEventInfo.npc_collision[i];
3953
3954 if (villager->CheckDraw() == 0) {
3955 continue;
3956 }
3957
3958 villager->GetPosition(pos);
3959 foot_sound = EdEventInfo.npc_foot_sound[i];
3960 } else {
3961 snap_to_ground = EdEventInfo.player_collision;
3962 Chara->GetPosition(pos);
3963 foot_sound = EdEventInfo.player_foot_sound;
3964 }
3965
3966 WorkBuffer__2->used = 0;
3967 CCPoly *polys = (CCPoly *) WorkBuffer__2->Alloc(2000);
3968 box.max[0] = 1.0f + pos[0];
3969 box.min[0] = pos[0] - 1.0f;
3970 box.max[2] = 1.0f + pos[2];
3971 box.min[2] = pos[2] - 1.0f;
3972 float height = pos[1];
3973 float top = 1000.0f + height;
3974 box.max[1] = 10.0f + top;
3975 box.min[1] = 10.0f + (height - 1000.0f);
3976
3977 if (i >= 0) {
3978 chara = villager;
3979 } else {
3980 chara = Chara;
3981 }
3982
3983 if (foot_sound == 1) {
3984 chara->FootSoundEnable(0);
3985 }
3986
3987 int poly_count = GetCollision(polys, &box);
3988
3989 if (poly_count > 200) {
3990 printf("cpoly over!!!! %d\n", poly_count);
3991 }
3992
3993 if (poly_count > 0) {
3994 pos[1] += 20.0f;
3995
3996 if (GetFootPoly(pos, 1000.0f, &poly, foot_pos, polys, poly_count, 0) != 0) {
3997 sceVu0CopyVector(pos, foot_pos);
3998 chara->FootSoundEnable(foot_sound);
3999
4000 if (foot_sound == 1) {
4001 chara->SetFootSoundID(poly.attr.foot_sound);
4002 }
4003
4004 sceVu0CopyVector(chara->ground_ambient[0], EditMapInfo->character_ambient[0]);
4005 sceVu0CopyVector(chara->ground_ambient[1], EditMapInfo->character_ambient[1]);
4006 chara->ground_ambient_no = -1;
4007 chara->fade_out = 0;
4008
4009 switch (poly.attr.area_kind) {
4010 case AREA_KIND_FADE_OUT:
4011 chara->fade_out = 1;
4012 break;
4013 case AREA_KIND_AMBIENT_0:
4014 case AREA_KIND_AMBIENT_1:
4015 chara->ground_ambient_no = poly.attr.area_kind - 3;
4016 break;
4017 }
4018 } else {
4019 pos[1] = 0.0f;
4020 }
4021 } else {
4022 pos[1] = 0.0f;
4023 }
4024
4025 if (snap_to_ground != 0) {
4026 if (i >= 0) {
4027 villager->SetPosition(pos);
4028 } else {
4029 Chara->SetPosition(pos);
4030 }
4031 }
4032 }
4033}
4034
4039int CheckEditToWalk(float *position) {
4040 sceVu0FVECTOR pos;
4041 CBoxVu0 box;
4042 sceVu0FVECTOR hit;
4043 sceVu0FVECTOR from;
4044 sceVu0FVECTOR to;
4045
4046 sceVu0CopyVector(pos, ECursorFrame->position);
4047 pos[3] = 1.0f;
4048 WorkBuffer__2->used = 0;
4049 CCPoly *polys = (CCPoly *) WorkBuffer__2->Alloc(1024);
4050 box.max[0] = 100.0f + pos[0];
4051 box.min[0] = pos[0] - 100.0f;
4052 float z = pos[2];
4053 box.max[2] = 100.0f + z;
4054 box.min[2] = z - 100.0f;
4055 box.max[1] = 20000.0f;
4056 box.min[1] = -20000.0f;
4057 pos[1] += 500.0f;
4058 int poly_count = pEditGround->PickUpPoly(polys, box, 0);
4059 int walkable = 1;
4060
4061 for (int i = 0; i < 4; i++) {
4062 sceVu0CopyVector(from, pos);
4063
4064 if (i == 1) {
4065 from[0] += 0.10000000149011612f;
4066 }
4067
4068 if (i == 1) {
4069 from[2] += 0.597599983215332f;
4070 }
4071
4072 if (i == 2) {
4073 from[0] -= 0.5809999704360962f;
4074 }
4075
4076 if (i == 2) {
4077 from[2] -= 0.29760000109672546f;
4078 }
4079
4080 if (i == 3) {
4081 from[0] += 0.35100001096725464f;
4082 }
4083
4084 if (i == 3) {
4085 from[2] -= 2.6775999069213867f;
4086 }
4087
4088 sceVu0CopyVector(to, from);
4089 to[1] -= 1000.0f;
4090
4091 if (CheckHit(polys, poly_count, from, to, hit, 1, 0) >= 0) {
4092 if (EdDebugMoveFlag <= 0) {
4093 float alt = pEditGround->GetAlt(from[0], from[1], from[2]);
4094 int area = pEditGround->GetAreaCode(from[0], from[1], from[2]);
4095 float drop;
4096 drop = hit[1] - alt;
4097 drop = drop < 0.0f ? -drop : drop;
4098
4099 if (drop < 0.10000000149011612f && area >= 0) {
4100 pos[1] = 1.0f + hit[1];
4101 } else {
4102 walkable = 0;
4103 }
4104
4105 CMapParts *parts = pEditGround->GetParts(pos[0], pos[1], pos[2]);
4106
4107 if (parts != NULL && parts->subtype == MAP_PARTS_SUBTYPE_ROAD) {
4108 pos[1] = 1.0f + hit[1];
4109 walkable = 1;
4110 }
4111 } else {
4112 pos[1] = 1.0f + hit[1];
4113 walkable = 1;
4114 }
4115 } else {
4116 walkable = 0;
4117 }
4118 }
4119
4120 sceVu0CopyVector(position, pos);
4121 return walkable;
4122}
4123
4131void MoveEditCursor() {
4132 float pos[4];
4133 float camera_distance[3] = {1000.0f, 2000.0f, 4000.0f};
4134 float camera_height[3] = {1000.0f, 1400.0f, 2000.0f};
4135
4136 static int camera_dist_mode = 0;
4137
4138 float cursor_scale[3] = {1.0f, 1.2f, 1.5f};
4139
4140 if (MapNo == TOWN_YELLOW_DROPS) {
4141 cursor_scale[0] *= 0.6f;
4142 }
4143
4144 float step_z;
4145 float camera_angle;
4146 float step_x;
4147 float forward;
4148 float right;
4149
4150 camera_angle = EditCamera.GetAngle();
4151 right = EdGetLXf(2);
4152 forward = EdGetLYf(2);
4153
4154 sceVu0CopyVector(pos, ECursorFrame->position);
4155
4156 int area_code = pEditGround->GetAreaCode(pos[0], pos[1], pos[2]);
4157 CEditArea *area = NULL;
4158
4159 if (EdPadDown(0xF000, 2) != 0) {
4160 if (area_code >= 0) {
4161 area = pEditGround->areas[area_code];
4162 }
4163
4164 if (area != NULL) {
4165 float unit = area->GetUnitSize();
4166
4167 if (EdPadDown(0x1000, 2) != 0) {
4168 forward = -unit;
4169 }
4170
4171 if (EdPadDown(0x4000, 2) != 0) {
4172 forward = unit;
4173 }
4174
4175 if (EdPadDown(0x2000, 2) != 0) {
4176 right = unit;
4177 }
4178
4179 if (EdPadDown(0x8000, 2) != 0) {
4180 right = -unit;
4181 }
4182 }
4183 }
4184
4185 step_x = right * cosf(camera_angle) + forward * sinf(camera_angle);
4186 step_z = forward * cosf(camera_angle) - right * sinf(camera_angle);
4187
4188 sceVu0CopyVector(pos, ECursorFrame->position);
4189
4190 if (area != NULL) {
4191 if (pEditGround->GetAreaCode(pos[0] + step_x, pos[1], pos[2] + step_z) < 0) {
4192 step_x = 0.0f;
4193 step_z = 0.0f;
4194 }
4195 } else {
4196 float scale = cursor_scale[camera_dist_mode];
4197
4198 step_x = 10.0f * step_x * scale;
4199 step_z = 10.0f * step_z * scale;
4200 }
4201
4202 float move[4] = {step_x, 0.0f, step_z, 0.0f};
4203
4204 LimitEditCursorPos(pos, move);
4205
4206 if (move[0] != 0.0f || move[2] != 0.0f) {
4207 DrawPartsNameCount = 0;
4208 }
4209
4210 if (area != NULL) {
4211 CVector3_f_ grid;
4212
4213 area->GetGrid(&grid, pos[0], pos[1], pos[2]);
4214
4215 float half = area->GetUnitSize() / 2.0f;
4216
4217 pos[0] = grid.x + half;
4218 pos[2] = grid.z + half;
4219 ECursorFrame->SetPosition(pos);
4220 }
4221
4222 MoveCamera(&EditCamera);
4223 EditCamera.SetDistance(camera_distance[camera_dist_mode]);
4224 EditCamera.SetHeight(camera_height[camera_dist_mode]);
4225
4226 if (MapNo == TOWN_YELLOW_DROPS) {
4227 EditCamera.SetDistance(0.2f * camera_distance[camera_dist_mode]);
4228 EditCamera.SetHeight(0.6f * camera_height[camera_dist_mode]);
4229 cursor_scale[0] *= 0.6f;
4230 }
4231
4232 float scale = cursor_scale[camera_dist_mode];
4233
4234 ECursorFrame->SetScale(scale, scale, scale);
4235
4236 if (!(camera_dist_mode < 2)) {
4237 camera_dist_mode = 0;
4238 }
4239
4240 ECursorFrame->SetPosition(pos[0], pos[1], pos[2]);
4241 float parts_pos[4];
4242
4243 sceVu0CopyVector(parts_pos, ECursorFrame->position);
4244
4245 if (PI_SHORT * (float) NowSelectAngle / 2.0f == NowCursorRotY) {
4246 if (EdPadDown(2, 2) != 0) {
4247 OldSelectAngle = NowSelectAngle;
4248 NowSelectAngle = NowSelectAngle - 1;
4249 } else if (EdPadDown(1, 2) != 0) {
4250 OldSelectAngle = NowSelectAngle;
4251 NowSelectAngle = NowSelectAngle + 1;
4252 }
4253 }
4254
4255 if (NowSelectAngle > 2) {
4256 NowSelectAngle = -1;
4257 }
4258
4259 if (NowSelectAngle < -1) {
4260 NowSelectAngle = 2;
4261 }
4262
4263 NowCursorRotY = AngleInterpolate(NowCursorRotY, PI_SHORT * (float) NowSelectAngle / 2.0f, 0.1f, INTERPOLATE_STEP);
4264
4265 int menu_mode = EditMenuStatus.mode;
4266
4267 OldFocusParts = NowFocusParts;
4268 NowFocusParts = pEditGround->GetParts(pos[0], pos[1], pos[2]);
4269 static int parts_no = 0;
4270
4271 if ((u_int) EditMenuStatus.mode < 2 && EdPadDown(0x40, 2) != 0) {
4272 int sound_id = 13;
4273
4274 if (MapNo == TOWN_YELLOW_DROPS) {
4275 sound_id = 333;
4276 }
4277
4278 int plot = pEditGround->SetMapParts(NowSelectParts, parts_pos[0], parts_pos[1], parts_pos[2], NowSelectAngle);
4279
4280 if (plot >= 0) {
4281 pEditGround->SetBuildEffect(plot);
4282 SndSePlay(sound_id, -1, 0);
4283
4284 EDITPARTS_INFO *info = EditPartsInfo.GetPartsInfo(NowSelectParts);
4285
4286 if (EditMenuStatus.mode == EDIT_MENU_MODE_REPLACE || (info != NULL && info->stock > 0 && info->placed == info->stock)) {
4287 menu_mode = EDIT_MENU_MODE_MOVE;
4288 NowSelectParts = -1;
4289 NowSelectAngle = 0;
4290 OldSelectAngle = 0;
4291 }
4292 }
4293 }
4294
4295 if (EditMenuStatus.mode == EDIT_MENU_MODE_MOVE) {
4296 int deleted_parts;
4297 int deleted_angle;
4298
4299 if (EdPadDown(0x80, 2) != 0 && pEditGround->DeleteMapParts(&deleted_parts, &deleted_angle, parts_pos[0], parts_pos[1], parts_pos[2]) >= 0) {
4300 EdSePlay((ED_SOUND_ID) 0xE, -1);
4301 }
4302
4303 pEditGround->SetFocusParts(parts_pos[0], parts_pos[1], parts_pos[2]);
4304
4305 if (EdPadDown(0x40, 2) != 0) {
4306 int taken_parts;
4307 int taken_angle;
4308
4309 if (NowFocusParts != NULL) {
4310 int width = NowFocusParts->GetWidth();
4311
4312 if (width * NowFocusParts->GetHeight() > 0) {
4313 NowFocusParts->GetPosition(NowCursorPos);
4314 NowFocusParts->GetPosition(NowPartsCursorPos);
4315 NowPartsCursorPos[1] = pEditGround->GetAlt(pos[0], pos[1], pos[2]);
4316
4317 float alt = pos[1];
4318
4319 NowFocusParts->GetPosition(pos);
4320 pos[1] = alt;
4321 NowCursorPos[1] = alt;
4322 }
4323 }
4324
4325 if (pEditGround->DeleteMapParts(&taken_parts, &taken_angle, parts_pos[0], parts_pos[1], parts_pos[2]) >= 0) {
4326 menu_mode = EDIT_MENU_MODE_REPLACE;
4327 NowSelectParts = taken_parts;
4328 NowSelectAngle = taken_angle;
4329 NowCursorRotY = PI_SHORT * (float) taken_angle / 2.0f;
4330 OldSelectAngle = taken_angle;
4331 EditMenuStatus.parts = taken_parts;
4332 }
4333 }
4334 }
4335
4336 EditMenuStatus.mode = menu_mode;
4337
4338 if (GamePad.Down2(PAD_CROSS) != 0) {
4339 pEditGround->Clear();
4340 }
4341
4342 if (GamePad.Down2(PAD_CIRCLE) != 0) {
4343 pEditGround->Save(NULL);
4344 }
4345
4346 if (GamePad.Down2(PAD_TRIANGLE) != 0) {
4347 pEditGround->Load(NULL);
4348 }
4349
4350 if (pEditGround->GetAreaCode(pos[0], pos[1], pos[2]) >= 0) {
4351 if (pos[1] < pEditGround->GetAlt(pos[0], pos[1], pos[2])) {
4352 pos[1] = pEditGround->GetAlt(pos[0], pos[1], pos[2]);
4353 }
4354 }
4355
4356 ECursorFrame->SetPosition(pos[0], pos[1], pos[2]);
4357 sceVu0CopyVector(NextCursorPos, pos);
4358
4359 if (NowFocusParts != NULL) {
4360 if (NowFocusParts->GetWidth() > 1) {
4361 NowFocusParts->GetHeight();
4362 }
4363
4364 EditNameMes.mes_no[0] = GetAtraMsgNo(MapNo, NowFocusParts->parts_no);
4365
4366 if (OldFocusParts != NowFocusParts) {
4367 EditNameMes.MakeMesWin(-1);
4368 }
4369
4370 if (DrawPartsNameCount > 0) {
4371 EditNameMes.MakeMesWin(-1);
4372 PartsNameNum = -1;
4373 } else {
4374 EditNameMes.MakeMesWin(1);
4375 PartsNameNum = EditNameMes.text_columns;
4376 }
4377 } else {
4378 EditNameMes.MakeMesWin(-1);
4379 }
4380
4381 DrawPartsNameCount--;
4382
4383 if (DrawPartsNameCount < 0) {
4384 DrawPartsNameCount = 0;
4385 }
4386
4387 EditCamera.FollowOn();
4388 EditCamera.SetFollow(pos[0], pos[1], pos[2]);
4389
4390 if (EditMenuStatus.mode == EDIT_MENU_MODE_CLOSED) {
4391 float walk[4];
4392
4393 EdEditMainHelpMes(CheckEditToWalk(walk));
4394 }
4395
4396 if ((u_int) EditMenuStatus.mode < 2) {
4397 EdEditBuildHelpMes(NowSelectParts);
4398 }
4399
4400 if (EditMenuStatus.mode == EDIT_MENU_MODE_MOVE) {
4401 EdEditMoveHelpMes();
4402 }
4403}
4404
4405u_int *scn_data;
4406u_int *parts_read_buffer;
4407
4415#ifdef PAL
4416int LoadTexture() {
4417 int entered;
4418 int image;
4419 u_long128 *buffer = (u_long128 *) (DataBuffer__2.base + DataBuffer__2.used * 16);
4420
4421 TexManager.Initialize(0x3FE0);
4422 TexManager.SetBuffer(buffer, 0x4E200);
4423
4424 LOADTEXTURE_INFO2 mes_blocks[8] = {
4425 {"#mes_frame_buff#640#" SCREEN_HEIGHT_STR "#4", 0x1A, 0},
4426 {"#fukidashibase#640#224#4", 0x1A, 0},
4427 {"#fontbase#512#256#1", 0x1A, 0},
4428 {"meswin/gaiji.img", 0x1A, 0},
4429 {"meswin/fuki256.img", 0x1A, 0},
4430 {"meswin/syst04.img", 0x1A, 0},
4431 };
4432 char mes_path[64] = "meswin/mes_tex.pak";
4433
4434 if (LanguageCode > LANG_JAPANESE) {
4435 sprintf(mes_path, "meswin/mes_tex_%d.pak", LanguageCode);
4436 }
4437
4438 LoadFile(mes_path, read_buffer, NULL);
4439 wait_now_loading_vsync();
4440 mes_blocks[3].name = (char *) GetPackFile(read_buffer, "gaiji.img", NULL);
4441 mes_blocks[4].name = (char *) GetPackFile(read_buffer, "fuki256.img", NULL);
4442 mes_blocks[5].name = (char *) GetPackFile(read_buffer, "syst04.img", NULL);
4443 TexManager.LoadTextureBlock(-1, mes_blocks);
4444
4445 int common_size;
4446
4447 LoadFile("gedit/system/esys_cmn.pak", read_buffer, &common_size);
4448 wait_now_loading_vsync();
4449
4450 // The language's system image is read into the 1 KiB-aligned space after the common pack.
4451 u_int *system_image = read_buffer + ((common_size >> 6) + 1) * 64;
4452 char system_path[64] = "gedit/system/sys.img";
4453
4454 if (LanguageCode > LANG_JAPANESE) {
4455 sprintf(system_path, "gedit/system/sys_%d.img", LanguageCode);
4456 }
4457
4458 LoadFile(system_path, system_image, NULL);
4459 wait_now_loading_vsync();
4460 TexManager.EnterIMGFile((u_char *) GetPackFile(read_buffer, "cursor.img", NULL), -1, 0, 0);
4461 TexManager.EnterIMGFile((u_char *) GetPackFile(read_buffer, "e01t02.img", NULL), -1, 0, 0);
4462
4463 LOADTEXTURE_INFO2 blocks[64] = {
4464 {"#water_buff#640#" HALF_BUFFER_HEIGHT_STR "#4", 0x15, 0},
4465 {"#shadow_buff#640#" HALF_BUFFER_HEIGHT_STR "#4", 0x16, 0},
4466 {"#blender#640#" HALF_BUFFER_HEIGHT_STR "#4", 0x18, 0},
4467 {"#font_buff#640#" HALF_BUFFER_HEIGHT_STR "#4", 0x1F, 0},
4468 {"img/system.img", 0x14, 0},
4469 {"", 0x14, 0},
4470 {"s_eff.img", 0x14, 0},
4471 {"img/ankfont.img", 0x1F, 0},
4472 {"#frame_image#640#" SCREEN_HEIGHT_STR "#4", 0x13, 0},
4473 };
4474
4475 blocks[4].name = (char *) GetPackFile(read_buffer, "sys_cmn.img", NULL);
4476 blocks[5].name = (char *) system_image;
4477 blocks[6].name = (char *) GetPackFile(read_buffer, "s_eff.img", NULL);
4478 blocks[7].name = (char *) GetPackFile(read_buffer, "ankfont.img", NULL);
4479 TexManager.LoadTextureBlock(-1, blocks);
4480 wait_now_loading_vsync();
4481
4482 CFrameAttr cursor_attr;
4483
4484 cursor_attr.use_color = true;
4485 CharaCursor0 = LoadMDSFile(GetPackFile(read_buffer, "cursor01.mds", NULL), &EtcDataBuffer, 0, NULL, NULL);
4486 CharaCursor0->SetAttr(cursor_attr, 1, 0x200);
4487 CharaCursor1 = LoadMDSFile(GetPackFile(read_buffer, "cursor02.mds", NULL), &EtcDataBuffer, 0, NULL, NULL);
4488 CharaCursor1->SetAttr(cursor_attr, 1, 0x200);
4489
4490 CharaCursor1->SetScale(2.5f, 2.5f, 2.5f);
4491 CharaCursor2 = LoadMDSFile(GetPackFile(read_buffer, "bic.mds", NULL), &EtcDataBuffer, 0, NULL, NULL);
4492 CharaCursor2->SetAttr(cursor_attr, 1, 0x200);
4493 TreasureCursor = LoadMDSFile(GetPackFile(read_buffer, "ibox_0.mds", NULL), &EtcDataBuffer, 0, NULL, NULL);
4494 TreasureCursorOpen = LoadMDSFile(GetPackFile(read_buffer, "ibox_1.mds", NULL), &EtcDataBuffer, 0, NULL, NULL);
4495
4496 CFrameAttr box_attr;
4497
4498 box_attr.clip_enable = false;
4499 box_attr.fog_enable = true;
4500
4501 if (TreasureCursor != NULL) {
4502 TreasureCursor->SetAttr(box_attr, 1, 0x44);
4503 }
4504
4505 if (TreasureCursorOpen != NULL) {
4506 TreasureCursorOpen->SetAttr(box_attr, 1, 0x44);
4507 }
4508
4509 SystemEffect[0].texture = TexManager.GetTexture("s_ef01", -1);
4510
4511 char stay_path[128];
4512 LOADTEXTURE_INFO map_blocks[64];
4513 CRect_i_ effect_rect;
4514
4515 effect_rect.x = 0;
4516 effect_rect.y = 0;
4517 effect_rect.width = 0x20;
4518 effect_rect.height = 0x20;
4519 SystemEffect[0].texel = effect_rect;
4520 SystemEffect[0].alpha_blend = true;
4521 SystemEffect[0].disable_z_write = true;
4522
4523 GetEditDataDir(stay_path);
4524 strcat(stay_path, "img.pak");
4525
4526 u_int *menu_data = (u_int *) (EdNPCBuffer.base + EdNPCBuffer.used * 16);
4527
4528 LoadFileMenuData("stayframe.img", menu_data);
4529 wait_now_loading_vsync();
4530 TexManager.EnterFixTextureZ((u_char *) menu_data);
4531 StayTexture = TexManager.GetTexture("stayframe", -1);
4532
4533 if (LoadFile2(stay_path, menu_data, NULL, 0) != 0) {
4534 wait_now_loading_vsync();
4535
4536 entered = 0;
4537 image = 0;
4538
4539 while (EditMapInfo->images[image].name[0] != '\0') {
4540 blocks[entered].name = (char *) GetPackFile(menu_data, EditMapInfo->images[image].name, NULL);
4541 blocks[entered].block_no = EditMapInfo->images[image].type;
4542 blocks[entered].mipmap = EditMapInfo->images[image].number;
4543 entered++;
4544 image++;
4545 }
4546
4547 blocks[entered].name = NULL;
4548 blocks[entered].block_no = 0;
4549 blocks[entered].mipmap = false;
4550 TexManager.LoadTextureBlock(-1, blocks);
4551 TexAnime.Initialize(TexAnimeData, 0x40);
4552
4553 int anime_size;
4554 char *anime_cfg = (char *) GetPackFile(menu_data, "texanime.cfg", &anime_size);
4555
4556 if (anime_cfg != NULL) {
4557 for (int i = 0; i < 64; i++) {
4558 TexAnimeData[i].Initialize();
4559 }
4560
4561 TexAnime.LoadCFGFile(anime_cfg, anime_size);
4562 }
4563 } else {
4564 TexAnime.Initialize(NULL, 0);
4565
4566 entered = 0;
4567 image = 0;
4568
4569 while (EditMapInfo->images[image].name[0] != '\0') {
4570 map_blocks[entered].name = EditMapInfo->images[image].name;
4571 map_blocks[entered].block_no = EditMapInfo->images[image].type;
4572 map_blocks[entered].mipmap = EditMapInfo->images[image].number;
4573 image++;
4574 entered++;
4575 }
4576
4577 map_blocks[entered].name = EditMapInfo->images[image].name;
4578 map_blocks[entered].block_no = EditMapInfo->images[image].type;
4579 map_blocks[entered].mipmap = EditMapInfo->images[image].number;
4580 TexManager.LoadTextureBlock(-1, map_blocks, read_buffer);
4581 }
4582
4583 TexManager.buffer_size = TexManager.buffer_used;
4584 DataBuffer__2.Alloc((int) (TexManager.buffer + TexManager.buffer_size - buffer) + 16);
4585 DataBuffer__2.Align64();
4586 return 0;
4587}
4588#else
4589int LoadTexture() {
4590 int entered;
4591 int image;
4592 u_long128 *buffer = (u_long128 *) (DataBuffer__2.base + DataBuffer__2.used * 16);
4593
4594 TexManager.Initialize(0x3FE0);
4595 TexManager.SetBuffer(buffer, 0x4E200);
4596
4597 LOADTEXTURE_INFO2 mes_blocks[8] = {
4598 {"#mes_frame_buff#640#448#4", 0x1A, 0},
4599 {"#fukidashibase#640#224#4", 0x1A, 0},
4600 {"#fontbase#512#256#1", 0x1A, 0},
4601 {"meswin/gaiji.img", 0x1A, 0},
4602 {"meswin/fuki256.img", 0x1A, 0},
4603 {"meswin/syst04.img", 0x1A, 0},
4604 };
4605
4606 LoadFile("meswin/mes_tex.pak", read_buffer, NULL);
4607 wait_now_loading_vsync();
4608 mes_blocks[3].name = (char *) GetPackFile(read_buffer, "gaiji.img", NULL);
4609 mes_blocks[4].name = (char *) GetPackFile(read_buffer, "fuki256.img", NULL);
4610 mes_blocks[5].name = (char *) GetPackFile(read_buffer, "syst04.img", NULL);
4611 TexManager.LoadTextureBlock(-1, mes_blocks);
4612
4613 char system_path[64] = "gedit/system/esys.pak";
4614
4615 if (LanguageCode > LANG_JAPANESE) {
4616 sprintf(system_path, "gedit/system/esys_%d.pak", LanguageCode);
4617 }
4618
4619 LoadFile(system_path, read_buffer, NULL);
4620 wait_now_loading_vsync();
4621 TexManager.EnterIMGFile((u_char *) GetPackFile(read_buffer, "e01t02.img", NULL), -1, 0, 0);
4622 TexManager.EnterIMGFile((u_char *) GetPackFile(read_buffer, "cursor.img", NULL), -1, 0, 0);
4623
4624 LOADTEXTURE_INFO2 blocks[64] = {
4625 {"#water_buff#640#224#4", 0x15, 0},
4626 {"#shadow_buff#640#224#4", 0x16, 0},
4627 {"#blender#640#224#4", 0x18, 0},
4628 {"#font_buff#640#224#4", 0x1F, 0},
4629 {"img/system.img", 0x14, 0},
4630 {"img/pause.img", 0x14, 0},
4631 {"s_eff.img", 0x14, 0},
4632 {"whatsday.img", 0x14, 0},
4633 {"img/ankfont.img", 0x1F, 0},
4634 {"#frame_image#640#448#4", 0x13, 0},
4635 };
4636
4637 blocks[4].name = (char *) GetPackFile(read_buffer, "system.img", NULL);
4638 blocks[5].name = (char *) GetPackFile(read_buffer, "pause.img", NULL);
4639 blocks[6].name = (char *) GetPackFile(read_buffer, "s_eff.img", NULL);
4640 blocks[7].name = (char *) GetPackFile(read_buffer, "whatsday.img", NULL);
4641 blocks[8].name = (char *) GetPackFile(read_buffer, "ankfont.img", NULL);
4642 TexManager.LoadTextureBlock(-1, blocks);
4643 wait_now_loading_vsync();
4644
4645 CFrameAttr cursor_attr;
4646
4647 cursor_attr.use_color = true;
4648 CharaCursor0 = LoadMDSFile(GetPackFile(read_buffer, "cursor01.mds", NULL), &EtcDataBuffer, 0, NULL, NULL);
4649 CharaCursor0->SetAttr(cursor_attr, 1, 0x200);
4650 CharaCursor1 = LoadMDSFile(GetPackFile(read_buffer, "cursor02.mds", NULL), &EtcDataBuffer, 0, NULL, NULL);
4651 CharaCursor1->SetAttr(cursor_attr, 1, 0x200);
4652
4653 CharaCursor1->SetScale(2.5f, 2.5f, 2.5f);
4654 CharaCursor2 = LoadMDSFile(GetPackFile(read_buffer, "bic.mds", NULL), &EtcDataBuffer, 0, NULL, NULL);
4655 CharaCursor2->SetAttr(cursor_attr, 1, 0x200);
4656 TreasureCursor = LoadMDSFile(GetPackFile(read_buffer, "ibox_0.mds", NULL), &EtcDataBuffer, 0, NULL, NULL);
4657 TreasureCursorOpen = LoadMDSFile(GetPackFile(read_buffer, "ibox_1.mds", NULL), &EtcDataBuffer, 0, NULL, NULL);
4658
4659 CFrameAttr box_attr;
4660
4661 box_attr.clip_enable = false;
4662 box_attr.fog_enable = true;
4663
4664 if (TreasureCursor != NULL) {
4665 TreasureCursor->SetAttr(box_attr, 1, 0x44);
4666 }
4667
4668 if (TreasureCursorOpen != NULL) {
4669 TreasureCursorOpen->SetAttr(box_attr, 1, 0x44);
4670 }
4671
4672 SystemEffect[0].texture = TexManager.GetTexture("s_ef01", -1);
4673
4674 char stay_path[128];
4675 LOADTEXTURE_INFO map_blocks[64];
4676 CRect_i_ effect_rect;
4677
4678 effect_rect.x = 0;
4679 effect_rect.y = 0;
4680 effect_rect.width = 0x20;
4681 effect_rect.height = 0x20;
4682 SystemEffect[0].texel = effect_rect;
4683 SystemEffect[0].alpha_blend = true;
4684 SystemEffect[0].disable_z_write = true;
4685
4686 GetEditDataDir(stay_path);
4687 strcat(stay_path, "img.pak");
4688
4689 u_int *menu_data = (u_int *) (EdNPCBuffer.base + EdNPCBuffer.used * 16);
4690
4691 LoadFileMenuData("stayframe.img", menu_data);
4692 wait_now_loading_vsync();
4693 TexManager.EnterFixTextureZ((u_char *) menu_data);
4694 StayTexture = TexManager.GetTexture("stayframe", -1);
4695
4696 if (LoadFile2(stay_path, menu_data, NULL, 0) != 0) {
4697 wait_now_loading_vsync();
4698
4699 entered = 0;
4700 image = 0;
4701
4702 while (EditMapInfo->images[image].name[0] != '\0') {
4703 blocks[entered].name = (char *) GetPackFile(menu_data, EditMapInfo->images[image].name, NULL);
4704 blocks[entered].block_no = EditMapInfo->images[image].type;
4705 blocks[entered].mipmap = EditMapInfo->images[image].number;
4706 entered++;
4707 image++;
4708 }
4709
4710 blocks[entered].name = NULL;
4711 blocks[entered].block_no = 0;
4712 blocks[entered].mipmap = false;
4713 TexManager.LoadTextureBlock(-1, blocks);
4714 TexAnime.Initialize(TexAnimeData, 0x40);
4715
4716 int anime_size;
4717 char *anime_cfg = (char *) GetPackFile(menu_data, "texanime.cfg", &anime_size);
4718
4719 if (anime_cfg != NULL) {
4720 for (int i = 0; i < 64; i++) {
4721 TexAnimeData[i].Initialize();
4722 }
4723
4724 TexAnime.LoadCFGFile(anime_cfg, anime_size);
4725 }
4726 } else {
4727 TexAnime.Initialize(NULL, 0);
4728
4729 entered = 0;
4730 image = 0;
4731
4732 while (EditMapInfo->images[image].name[0] != '\0') {
4733 map_blocks[entered].name = EditMapInfo->images[image].name;
4734 map_blocks[entered].block_no = EditMapInfo->images[image].type;
4735 map_blocks[entered].mipmap = EditMapInfo->images[image].number;
4736 image++;
4737 entered++;
4738 }
4739
4740 map_blocks[entered].name = EditMapInfo->images[image].name;
4741 map_blocks[entered].block_no = EditMapInfo->images[image].type;
4742 map_blocks[entered].mipmap = EditMapInfo->images[image].number;
4743 TexManager.LoadTextureBlock(-1, map_blocks, read_buffer);
4744 }
4745
4746 TexManager.buffer_size = TexManager.buffer_used;
4747 DataBuffer__2.Alloc((int) (TexManager.buffer + TexManager.buffer_size - buffer) + 16);
4748 DataBuffer__2.Align64();
4749 return 0;
4750}
4751#endif
4752
4757void EdLoadMainChara(char *pack_path, char *info_name, CDataAlloc2<1> *arena) {
4758 int i;
4759
4760 if (arena == NULL) {
4761 arena = &CharaBuffer;
4762 CharaBuffer.used = 0;
4763 }
4764
4765 LoadFile(pack_path, read_buffer, NULL);
4766 MainChara.Initialize();
4767
4768 for (i = 0; i < 128; i++) {
4769 CharaTexAnimeData[i].Initialize();
4770 }
4771
4772 MainChara.InitializeTexAnime(CharaTexAnimeData, 128);
4773 MainChara.LoadPackData2(read_buffer, info_name, arena, 8, arena, 0);
4774 CFrameAttr attr;
4775 attr.clip_enable = false;
4776 attr.fog_enable = true;
4777 MainChara.frame->SetAttr(attr, 1, 4);
4778#ifdef PAL
4779 MainChara.SetPosition(0.0f, 0.0f, 0.0f);
4780#else
4781 float origin = 0.0f;
4782 MainChara.SetPosition(origin, origin, origin);
4783#endif
4784 Chara = &MainChara;
4785}
4786
4794void LoadGroundData() {
4795 parts_read_buffer = read_buffer;
4796
4797 char pack_path[64];
4798
4799 GetEditDataDir(pack_path);
4800 strcat(pack_path, "mds.pak");
4801 LoadPackFile(pack_path, parts_read_buffer, NULL);
4802 wait_now_loading_vsync();
4803
4804 u_int *data;
4805 OBJ_ANIME_SEQ *anime = EditMapInfo->work.obj_anime;
4806 EDIT_EFFECT_INFO *effects = EditMapInfo->work.effects.first;
4807 EDIT_OBJECT_TIMER *timers = EditMapInfo->work.object_timers.timers;
4808 ED_EVENT_POINT *points = EditMapInfo->work.events.points;
4809
4810 pEditGround->Initialize();
4811 pEditGround->map_no = NowEditMap;
4812
4813 char *sun_names[4] = {"sun1", "sun2", "sun3", "moon"};
4814
4815 for (int i = 0; i < 4; i++) {
4816 SkyFrame[i] = NULL;
4817
4818 CFrameAttr layer_attr;
4819
4820 layer_attr.depth_write = false;
4821
4822 if (EditMapInfo->sky_layers[i].name[0] != '\0') {
4823 data = (u_int *) EdLoadFile(EditMapInfo->sky_layers[i].name);
4824
4825 SkyFrame[i] = LoadMDSFile(data, &DataBuffer__2, 0, NULL, NULL);
4826 SkyFrame[i]->SetAttr(layer_attr, 1, 0x1000);
4827
4828 for (int j = 0; j < 8; j++) {
4829 short no = EditMapInfo->sky_layers[i].obj_anime[j];
4830
4831 if (no > 0) {
4832 InitObjAnime(SkyFrame[i], &anime[no]);
4833 }
4834 }
4835 }
4836
4837 SunFrame[i] = NULL;
4838
4839 if (EditMapInfo->sun_layers[i].name[0] != '\0') {
4840 data = (u_int *) EdLoadFile(EditMapInfo->sun_layers[i].name);
4841
4842 SunFrame[i] = LoadMDSFile(data, &DataBuffer__2, 0, NULL, NULL);
4843 SunFrame[i]->SetAttr(layer_attr, 1, 0x1000);
4844 }
4845
4846 if (SunFrame[i] != NULL) {
4847 sceVu0FMATRIX world;
4848
4849 sceVu0UnitMatrix(world);
4850 SunFrame[i]->SetTransMatrix(world);
4851 SunFrame[i]->SetRotation(0.5f, 0.0f, 0.0f);
4852 SunFrame[i] = SunFrame[i]->SearchFrame(sun_names[i]);
4853 }
4854 }
4855
4856 SkyBackFrame = NULL;
4857
4858 if (EditMapInfo->sky_layers[4].name[0] != '\0') {
4859 data = (u_int *) EdLoadFile(EditMapInfo->sky_layers[4].name);
4860
4861 CFrameAttr back_attr;
4862
4863 back_attr.depth_write = false;
4864 back_attr.use_color = true;
4865 SkyBackFrame = LoadMDSFile(data, &DataBuffer__2, 6, NULL, NULL);
4866 SkyBackFrame->SetAttr(back_attr, 1, 0x1200);
4867 }
4868
4869 for (int i = 0; i < 4; i++) {
4870 EDIT_AREA_INFO *info = &EditMapInfo->parts_work.edit_areas[i];
4871
4872 pEditGround->areas[i] = NULL;
4873
4874 if (info->name[0] != '\0') {
4875 data = (u_int *) EdLoadFile(info->name);
4876 EditArea[i].SetMapInfo(NowEditMap, i);
4877 EditArea[i].SetSize(info->width, info->height, info->unit_size, info->unit_alt);
4878 EditArea[i].SetOffset(info->origin_x - 0.01f * (float) info->width, info->origin_y, info->origin_z - 0.01f * (float) info->height);
4879 EditArea[i].SetGridFrame(LoadMDSFile(data, &DataBuffer__2, 6, NULL, NULL));
4880
4881 CFrameAttr grid_attr;
4882
4883 grid_attr.fog_enable = true;
4884 EditArea[i].GetGridFrame()->SetAttr(grid_attr, 1, 0x40);
4885 pEditGround->areas[i] = &EditArea[i];
4886 }
4887 }
4888
4889 if (MapNo < 6) {
4890 data = (u_int *) EdLoadFile("gedit/e01/mds/e01a03_0.mds");
4891
4892 pEditGround->cursor.pieces[0] = LoadMDSFile(data, &DataBuffer__2, 0, NULL, NULL);
4893
4894 data = (u_int *) EdLoadFile("gedit/e01/mds/e01a04_0.mds");
4895
4896 pEditGround->cursor.pieces[1] = LoadMDSFile(data, &DataBuffer__2, 0, NULL, NULL);
4897
4898 data = (u_int *) EdLoadFile("gedit/e01/mds/e01a05_0.mds");
4899
4900 pEditGround->cursor.pieces[2] = LoadMDSFile(data, &DataBuffer__2, 0, NULL, NULL);
4901 pEditGround->cursor.area = 2;
4902 } else {
4903 pEditGround->cursor.pieces[0] = NULL;
4904 pEditGround->cursor.pieces[1] = NULL;
4905 pEditGround->cursor.pieces[2] = NULL;
4906 }
4907
4908 wait_now_loading_vsync();
4909
4910 for (int i = 0; i < 4; i++) {
4911 EDIT_MOTION_PARTS_INFO *info = &EditMapInfo->motion_parts[i];
4912
4913 MotionParts[i].Initialize();
4914
4915 if (info->name[0] != '\0') {
4916 data = (u_int *) EdLoadFile(info->name);
4917 MotionParts[i].InitializeTexAnime(TexAnimeData, 64);
4918 MotionParts[i].LoadPackData2(data, "info.cfg", &DataBuffer__2, i + 0x1B, &DataBuffer__2, 0);
4919 MotionParts[i].SetPosition(info->values[0], info->values[1], info->values[2]);
4920 MotionParts[i].SetRotation(info->values[3], info->values[4], info->values[5]);
4921 }
4922 }
4923
4924 scn_data = (u_int *) (EdNPCBuffer.base + EdNPCBuffer.used * 16);
4925
4926 char scene_path[64];
4927 int scene_size;
4928
4929 GetEditDataDir(scene_path);
4930 strcat(scene_path, EditMapInfo->scene_name);
4931
4932 if (LoadFile2(scene_path, (void *) scn_data, &scene_size, 0) == 0) {
4933 scn_data = NULL;
4934 scene_size = 0;
4935 }
4936
4937 if (scn_data != NULL) {
4938 parts_read_buffer = (u_int *) ((char *) scn_data + (((scene_size >> 6) + 1) << 6));
4939 } else {
4940 parts_read_buffer = read_buffer;
4941 }
4942
4943 while (check_now_loading() == 0) {
4944 }
4945
4946 EditPartsInfo.Initialize(NowEditMap);
4947 LoadObjectParts();
4948 pEditGround->plot_parts = ObjParts;
4949 pEditGround->river_parts = RiverParts;
4950 pEditGround->road_parts = RoadParts;
4951 pEditGround->parts_info = &EditPartsInfo;
4952 ObjParts[12].draw_distance = 490.0f;
4953
4957 struct LOADED_PARTS {
4958 char name[0x20];
4959 CMapParts *parts;
4960 } built[64];
4961
4962 int i;
4963
4964 for (i = 0; i < 64; i++) {
4965 built[i].name[0] = '\0';
4966 }
4967
4968 int built_count = 0;
4969
4970 for (i = 0;; i++) {
4971 MAP_PARTS_INFO *info = &EditMapInfo->map_objects[i];
4972
4973 if (info->name[0][0] == '\0' && info->name[1][0] == '\0' && info->name[2][0] == '\0' && info->name[3][0] == '\0') {
4974 break;
4975 }
4976
4977 CMapParts *parts = &pEditGround->fixed_parts[i];
4978
4979 parts->Initialize();
4980
4981 u_int *pts = SearchPTS(scn_data, info->name[0]);
4982
4983 if (pts != NULL) {
4984 CMapParts *shared = NULL;
4985
4986 for (int j = 0; j < built_count; j++) {
4987 if (strcmp(info->name[0], built[j].name) == 0) {
4988 shared = built[j].parts;
4989 break;
4990 }
4991 }
4992
4993 LoadPTS(parts, pts, info, anime, effects, timers, points, shared);
4994
4995 char *c = info->name[0];
4996 char *base = c;
4997 char letter;
4998
4999 for (; (letter = *c) != '\0'; c++) {
5000 if (letter == '/') {
5001 base = c + 1;
5002 }
5003 }
5004
5005 if (strcmp(base, "e02c13") == 0) {
5006 CFrameAttr door_attr;
5007
5008 door_attr.fog_enable = true;
5009
5010 CFrame *door = parts->ripple_frame;
5011
5012 if (door != NULL) {
5013 door = door->SearchFrame("cube1");
5014 }
5015
5016 if (door != NULL) {
5017 door->SetAttr(door_attr, 1, 0x40);
5018 }
5019 }
5020
5021 sceVu0FVECTOR position = {info->position[0], info->position[1], info->position[2],
5022 1.0f};
5023
5024 parts->SetPosition(position);
5025 parts->SetRotation(info->rotation[0], info->rotation[1], info->rotation[2]);
5026
5027 if (shared == NULL) {
5028 strcpy(built[built_count].name, info->name[0]);
5029 built[built_count].parts = parts;
5030 built_count++;
5031 }
5032 } else {
5033 LoadPTS(parts, info, anime, effects, timers, points);
5034
5035 sceVu0FVECTOR position = {info->position[0], info->position[1], info->position[2],
5036 1.0f};
5037
5038 parts->SetPosition(position);
5039 parts->SetRotation(info->rotation[0], info->rotation[1], info->rotation[2]);
5040 }
5041
5042 int kind = info->kind;
5043
5044 parts->handle = i;
5045 parts->category_no = kind;
5046 }
5047
5048 for (i = 0; i < 4; i++) {
5049 EDIT_WATER_INFO *info = &EditMapInfo->water_surfaces[i];
5050
5051 if (info->grid_rows <= 0) {
5052 break;
5053 }
5054
5055 CGroundWater *surface = &pEditGround->water_surfaces[i];
5056 CWater *water = &pEditGround->water_surfaces[i].water;
5057 sceVu0FVECTOR near_left = {info->corner_a[0], info->corner_a[1], info->corner_a[2],
5058 1.0f};
5059 sceVu0FVECTOR near_right = {info->corner_b[0], info->corner_a[1], info->corner_a[2],
5060 1.0f};
5061 sceVu0FVECTOR far_left = {info->corner_a[0], info->corner_a[1], info->corner_b[2],
5062 1.0f};
5063 sceVu0FVECTOR far_right = {info->corner_b[0], info->corner_a[1], info->corner_b[2],
5064 1.0f};
5065
5066 surface->draw = true;
5067 strcpy(surface->name, info->name);
5068 surface->parts_no = info->parts_no;
5069 sceVu0CopyVector(surface->offset, info->corner_c);
5070
5071 for (int j = 0; j < 3; j++) {
5072 surface->follow[j] = info->follow[j];
5073 }
5074
5075 for (int j = 0; j < 4; j++) {
5076 sceVu0CopyVector(&surface->ripples[j].row, &info->wave[j].row);
5077 }
5078
5079 water->SetVertex(near_left, near_right, far_left, far_right);
5080 water->frame.SetPosition(info->corner_c);
5081 water->SetSize(info->grid_rows, info->grid_columns, &DataBuffer__2);
5082 water->SetParam(info->ripple_params[0], info->ripple_params[1], info->ripple_params[2], info->ripple_params[3]);
5083 water->SetColor(info->red, info->green, info->blue, 0x80);
5084 }
5085}
5086
5092void LoadObjectParts() {
5093 char name_buffer[7][0x40];
5094 char *names[7];
5095
5099 struct LOADED_PARTS {
5100 char name[0x20];
5101 CMapParts *parts;
5102 } loaded[64];
5103
5104 OBJ_ANIME_SEQ *anime = EditMapInfo->work.obj_anime;
5105 EDIT_EFFECT_INFO *effects = EditMapInfo->work.effects.second;
5106 EDIT_OBJECT_TIMER *timers = EditMapInfo->work.object_timers.timers;
5107 ED_EVENT_POINT *points = EditMapInfo->work.events.points;
5108
5109 for (int i = 0; i < 7; i++) {
5110 names[i] = name_buffer[i];
5111 *names[i] = '\0';
5112 }
5113
5114 int i;
5115 int river = 0;
5116 int road = 0;
5117
5118 for (i = 0; i < 64; i++) {
5119 loaded[i].name[0] = '\0';
5120 }
5121
5122 int loaded_count = 0;
5123
5124 for (i = 0; i < 46; i++) {
5125 CMapParts *shared = NULL;
5126 int has_archive = 0;
5127 CMapParts *parts;
5128 MAP_PARTS_INFO *info = &EditMapInfo->parts_work.general.parts[i];
5129 EDITPARTS_INFO *plot = NULL;
5130 int index = i;
5131 int slot;
5132
5133 if (i >= 24) {
5134 info = &EditMapInfo->parts_work.roads.parts[road];
5135
5136 if (i >= 30) {
5137 info = &EditMapInfo->parts_work.rivers.parts[river];
5138 }
5139
5140 switch (info->subtype) {
5143 parts = &RiverParts[river];
5144 slot = river;
5145 river++;
5146 break;
5148 parts = &RoadParts[road];
5149 slot = road;
5150 road++;
5151 break;
5152 default:
5153 continue;
5154 }
5155 } else {
5156 parts = &ObjParts[i];
5157 plot = EditPartsInfo.GetPartsInfo(i);
5158 slot = i;
5159 }
5160
5161 for (int j = 0; j < loaded_count; j++) {
5162 if (strcmp(info->name[0], loaded[j].name) == 0) {
5163 shared = loaded[j].parts;
5164 break;
5165 }
5166 }
5167
5168 u_int *archive = SearchPTS(scn_data, info->name[0]);
5169
5170 if (archive != NULL) {
5171 has_archive = 1;
5172 }
5173
5174 parts->Initialize();
5175
5176 if (plot == NULL) {
5177 for (int j = 0; j < 24; j++) {
5178 if (info->subtype == ObjParts[j].subtype) {
5179 index = j;
5180 break;
5181 }
5182 }
5183 }
5184
5185 int kind = info->kind;
5186 parts->handle = slot;
5187 parts->category_no = kind;
5188 parts->parts_no = index;
5189 parts->subtype = info->subtype;
5190 parts->lift = info->lift;
5191 parts->def_parts_no = info->parts_no;
5192
5193 EPARTS_INFO_HEADER *header;
5194
5195 if (has_archive != 0) {
5196 header = LoadPTS(parts, archive, info, anime, effects, timers, points, shared);
5197 } else {
5198 if (plot != NULL) {
5199 header = (EPARTS_INFO_HEADER *) (EPartsInfoBuff.base + EPartsInfoBuff.used * 16);
5200 EPartsInfoBuff.Alloc((EdInitToEPInfo((INIT_PARTSINFO *) &EditMapInfo->parts_work.parts_defs.defs[i], header) >> 4) + 1);
5201 }
5202
5203 LoadPTS(parts, info, anime, effects, timers, points);
5204 }
5205
5206 if (plot != NULL) {
5207 EditPartsInfo.Initialize(i, header);
5208 }
5209
5210 parts->info = EditPartsInfo.GetPartsInfo(index);
5211
5212 if (parts->frame[3] != NULL) {
5213 parts->preview_frame = (int) parts->frame[3];
5214 } else if (parts->frame[2] != NULL) {
5215 parts->preview_frame = (int) parts->frame[2];
5216 } else if (parts->frame[1] != NULL) {
5217 parts->preview_frame = (int) parts->frame[1];
5218 } else if (parts->frame[0] != NULL) {
5219 parts->preview_frame = (int) parts->frame[0];
5220 }
5221
5222 if (shared == NULL) {
5223 strcpy(loaded[loaded_count].name, info->name[0]);
5224 loaded[loaded_count].parts = parts;
5225 loaded_count++;
5226 }
5227 }
5228}
5229
5233static inline CFrame *GetCameraFrame(CMapParts *parts) {
5234 if (parts->camera_frame == NULL) {
5235 return NULL;
5236 }
5237
5238 parts->camera_frame->SetPosition(parts->pos[0], parts->pos[1], parts->pos[2]);
5239 parts->camera_frame->SetRotation(parts->rotation.x, parts->rotation.y, parts->rotation.z);
5240 return parts->camera_frame;
5241}
5242
5251EPARTS_INFO_HEADER *LoadPTS(CMapParts *parts, unsigned int *archive, MAP_PARTS_INFO *info, OBJ_ANIME_SEQ *anime, EDIT_EFFECT_INFO *effects, EDIT_OBJECT_TIMER *timers, ED_EVENT_POINT *points, CMapParts *shared) {
5252 EPARTS_INFO_HEADER *source;
5253 EPARTS_ARCHIVE *record = (EPARTS_ARCHIVE *) archive;
5254 int i;
5255 EPARTS_INFO_HEADER *header;
5256 CFrame *frame;
5257
5258 source = (EPARTS_INFO_HEADER *) ((char *) record + record->info_offset);
5259 header = (EPARTS_INFO_HEADER *) EPartsInfoBuff.Alloc((source->data_size >> 4) + 1);
5260 memcpy(header, source, source->data_size);
5261 header->cell = (u8 *) header + (int) source->cell;
5262
5263 for (i = 0; i < 6; i++) {
5264 if (header->element_name[i] != NULL) {
5265 header->element_name[i] = (char *) header + (int) source->element_name[i];
5266 }
5267 }
5268
5269 header->func = (EPARTS_FUNC_DATA *) ((char *) header + (int) source->func);
5270
5271 EPARTS_FUNC_DATA *walk = header->func;
5272
5273 for (i = 0; i < header->func_count; i++) {
5274 walk++;
5275 }
5276
5277 parts->func_count = header->func_count;
5278 parts->func_data = (int) header->func;
5279
5280 if (shared != NULL) {
5281 CopyCMapParts(parts, shared, &DataBuffer__2);
5282 } else {
5283 char *names[9] = {NULL};
5284
5285 if (record->lod0_size > 0) {
5286 names[0] = (char *) record + record->lod0_offset;
5287 } else {
5288 return header;
5289 }
5290
5291 if (record->lod1_size > 0) {
5292 names[1] = (char *) record + record->lod1_offset;
5293 }
5294
5295 if (record->lod2_size > 0) {
5296 names[2] = (char *) record + record->lod2_offset;
5297 }
5298
5299 if (record->lod3_size > 0) {
5300 names[3] = (char *) record + record->lod3_offset;
5301 }
5302
5303 if (record->shadow_size > 0) {
5304 names[4] = (char *) record + record->shadow_offset;
5305 }
5306
5307 if (record->collision_size > 0) {
5308 names[5] = (char *) record + record->collision_offset;
5309 }
5310
5311 if (record->shade_size > 0) {
5312 names[6] = (char *) record + record->shade_offset;
5313 }
5314
5315 if (record->extra_size > 0) {
5316 names[7] = (char *) record + record->extra_offset;
5317 }
5318
5319 if (record->camera_size > 0) {
5320 names[8] = (char *) record + record->camera_offset;
5321 }
5322
5323 LoadMapObject(parts, (u_int **) names, &DataBuffer__2);
5324 }
5325
5326 CFrame *frames[9];
5327 CBoxVu0 bound;
5328 CBoxVu0 part_bound;
5329
5330 for (int k = 0; k < 9; k++) {
5331 frames[k] = NULL;
5332 }
5333
5334 for (int k = 0; k < 4; k++) {
5335 CFrame *level = parts->frame[k];
5336
5337 frames[k] = level;
5338 }
5339
5340 frames[4] = parts->shadow_frame;
5341 frames[5] = parts->GetCollisionFrame();
5342 frames[6] = parts->shade_frame;
5343 frames[7] = parts->ripple_frame;
5344 frames[8] = GetCameraFrame(parts);
5345
5346 if (frames[0] == NULL) {
5347 return NULL;
5348 }
5349
5350 frames[0]->GetBoundBox(&bound, 1);
5351 frame = parts->GetCollisionFrame();
5352
5353 if (frame != NULL) {
5354 frame->GetBoundBox(&part_bound, 1);
5355 VectorMaxMin(bound.max, bound.min, bound.max, bound.min, part_bound.max, part_bound.min);
5356 }
5357
5358 frame = GetCameraFrame(parts);
5359
5360 if (frame != NULL) {
5361 frame->GetBoundBox(&part_bound, 1);
5362 VectorMaxMin(bound.max, bound.min, bound.max, bound.min, part_bound.max, part_bound.min);
5363 }
5364
5365 memcpy(&parts->bound, &bound, sizeof(CBoxVu0));
5366
5367 for (int k = 0; k < 8; k++) {
5368 int anime_no = info->anime[k];
5369
5370 if (anime_no > 0) {
5371 InitObjAnime(frames, &anime[anime_no]);
5372 }
5373 }
5374
5375 EPARTS_FUNC_DATA *funcs = header->func;
5376
5377 EditMapInfo->event_count += EdInitEventPoint(parts, info->events, funcs, header->func_count, points, 0x100);
5378
5379 EPARTS_FUNC_DATA *func = header->func;
5380
5381 for (i = 0; i < header->func_count; i++, func++) {
5382 if (func->completion_flag > 0 && SaveData->GetMapInitFlag(MapNo, func->completion_flag) == 0) {
5383 SaveData->SetMapInitFlag(MapNo, func->completion_flag, 1);
5384 SaveData->SetMapFlag(MapNo, func->completion_flag, !(char) func->unk_28[0]);
5385 }
5386
5387 EnterPartsEffect(parts, func, effects, 0x40);
5388
5389 if (EditMapInfo->obj_anime_count < 128 && InitObjAnime(frames, 9, func, &anime[EditMapInfo->obj_anime_count]) != 0) {
5390 EditMapInfo->obj_anime_count++;
5391 }
5392
5393 if (func->kind == EPARTS_FUNC_OBJ_TIMER) {
5394 EDIT_OBJECT_TIMER *timer = &timers[EditMapInfo->object_timer_count++];
5395
5396 if (EditMapInfo->object_timer_count > 128) {
5397 continue;
5398 }
5399
5400 strcpy(timer->name, (char *) func->frame_name);
5401 timer->start_time = ConvertTime(func->start_time);
5402 timer->end_time = ConvertTime(func->end_time);
5403 timer->object = parts;
5404 }
5405
5406 if (func->kind == EPARTS_FUNC_VILLAGER) {
5407 pEditGround->people[pEditGround->people_count++] = func;
5408 func->parts = parts;
5409 }
5410 }
5411
5412 sceVu0FVECTOR position = {0.0f, 0.0f, 0.0f, 1.0f};
5413
5414 position[0] = source->position[0];
5415 position[1] = source->position[1];
5416 position[2] = source->position[2];
5417 parts->SetPosition(position);
5418 parts->SetRotation(source->rotation[0], source->rotation[1], source->rotation[2]);
5419 return header;
5420}
5421
5426void LoadPTS(CMapParts *parts, MAP_PARTS_INFO *info, OBJ_ANIME_SEQ *anime, EDIT_EFFECT_INFO *effects, EDIT_OBJECT_TIMER *timers, ED_EVENT_POINT *points) {
5427 char *names[9];
5428 CFrameVu1 *frames[4];
5429 CBoxVu0 bound;
5430 CBoxVu0 part_bound;
5431
5432 if (info == NULL || info->name[0][0] == '\0') {
5433 return;
5434 }
5435
5436 for (int i = 0; i < 9; i++) {
5437 names[i] = info->name[i];
5438 }
5439
5440 LoadMapObject(parts, names);
5441
5442 for (int i = 0; i < 4; i++) {
5443 CFrameVu1 *frame = parts->frame[i];
5444 frames[i] = frame;
5445 }
5446
5447 if (frames[0] != NULL) {
5448 frames[0]->GetBoundBox(&bound, 1);
5449 CFrame *collision = parts->GetCollisionFrame();
5450
5451 if (collision != NULL) {
5452 collision->GetBoundBox(&part_bound, 1);
5453 VectorMaxMin(bound.max, bound.min, bound.max, bound.min, part_bound.max, part_bound.min);
5454 }
5455
5456 CFrame *camera_frame = parts->camera_frame;
5457
5458 if (camera_frame == NULL) {
5459 camera_frame = NULL;
5460 } else {
5461 camera_frame->SetPosition(parts->pos[0], parts->pos[1], parts->pos[2]);
5462 parts->camera_frame->SetRotation(parts->rotation.x, parts->rotation.y, parts->rotation.z);
5463 camera_frame = parts->camera_frame;
5464 }
5465
5466 if (camera_frame != NULL) {
5467 camera_frame->GetBoundBox(&part_bound, 1);
5468 VectorMaxMin(bound.max, bound.min, bound.max, bound.min, part_bound.max, part_bound.min);
5469 }
5470
5471 parts->bound = bound;
5472 }
5473}
5474
5478void LoadMapObject(CMapParts *map_parts, char **script) {
5479}
5480
5484void set2DSpriteRot(sceVif1Packet *packet, CTexture *texture, const CRect_i_ &screen, const CRect_i_ &texel, int pivot_x, int pivot_y, float angle, unsigned char alpha) {
5485 float x[4];
5486 float y[4];
5487 sceGsTest test;
5488 sceGsZbuf zbuf;
5489 float q;
5490 int i;
5491
5492 q = 1.0f;
5493 sceVif1PkCnt(packet, 0);
5494 sceVif1PkOpenDirectCode(packet, 0);
5495 sceVif1PkOpenGifTag(packet, *(u_long128 *) &GiftagAD);
5496 sceVif1PkAddGsAD(packet, SCE_GS_TEX1_1, 0x41);
5497 sceVif1PkAddGsAD(packet, SCE_GS_PRIM, SCE_GS_SET_PRIM(4, 0, 1, 0, 1, 1, 1, 0, 0));
5498 test = mgPixelTest;
5499 test.bits.ate = 0;
5500 test.bits.aref = 0;
5501 test.bits.atst = SCE_GS_ALWAYS;
5502 test.bits.zte = 1;
5503 test.bits.ztst = SCE_GS_ALWAYS;
5504 sceVif1PkAddGsAD(packet, SCE_GS_TEST_1, *(u_long *) &test);
5505 zbuf = mgZBuffer;
5506 zbuf.bits.zmsk = 1;
5507
5508 x[0] = x[2] = pivot_x * -16;
5509 x[1] = x[3] = ((screen.width - pivot_x) << 4) - 1;
5510 y[0] = y[1] = pivot_y * -16;
5511 y[2] = y[3] = ((screen.height - pivot_y) << 4) - 1;
5512
5513 for (i = 0; i < 4; i++) {
5514 float turned_x = y[i] * cosf(angle) + x[i] * sinf(angle);
5515 float turned_y = x[i] * cosf(angle) - y[i] * sinf(angle);
5516
5517 x[i] = (int) turned_x + (screen.x << 4) + 27648;
5518 y[i] = (int) (0.5f * turned_y) + (screen.y << 3) + GS_Y_OFFSET;
5519 }
5520
5521 sceVif1PkAddGsAD(packet, SCE_GS_ZBUF_1, *(u_long *) &zbuf);
5522 sceVif1PkAddGsAD(packet, SCE_GS_RGBAQ, SCE_GS_SET_RGBAQ(0x80, 0x80, 0x80, alpha, *(u_int *) &q));
5523 sceVif1PkAddGsAD(packet, SCE_GS_TEX0_1, texture->tex0);
5524 sceVif1PkAddGsAD(packet, SCE_GS_UV, SCE_GS_SET_UV(texel.x << 4, texel.y << 4));
5525 sceVif1PkAddGsAD(packet, SCE_GS_XYZF2, SCE_GS_SET_XYZF2(x[0], y[0], 0, 0));
5526 sceVif1PkAddGsAD(packet, SCE_GS_UV, SCE_GS_SET_UV((texel.x + screen.width) << 4, texel.y << 4));
5527 sceVif1PkAddGsAD(packet, SCE_GS_XYZF2, SCE_GS_SET_XYZF2(x[1], y[1], 0, 0));
5528 sceVif1PkAddGsAD(packet, SCE_GS_UV, SCE_GS_SET_UV(texel.x << 4, (texel.y + texel.height) << 4));
5529 sceVif1PkAddGsAD(packet, SCE_GS_XYZF2, SCE_GS_SET_XYZF2(x[2], y[2], 0, 0));
5530 sceVif1PkAddGsAD(packet, SCE_GS_UV, SCE_GS_SET_UV((texel.x + texel.width) << 4, (texel.y + texel.height) << 4));
5531 sceVif1PkAddGsAD(packet, SCE_GS_XYZF2, SCE_GS_SET_XYZF2(x[3], y[3], 0, 0));
5532 sceVif1PkAddGsAD(packet, SCE_GS_TEST_1, *(u_long *) &mgPixelTest);
5533 sceVif1PkAddGsAD(packet, SCE_GS_ZBUF_1, *(u_long *) &mgZBuffer);
5534 sceVif1PkCloseGifTag(packet);
5535 sceVif1PkCloseDirectCode(packet);
5536}
5537
5542
5546void CopyCMapParts(CMapParts *to, CMapParts *from, CDataAlloc2<1> *arena) {
5547 for (int i = 0; i < 4; i++) {
5548 to->SetFrame(CopyFrameVu1(from->frame[i], arena), i);
5549 }
5550
5551 to->collision_frame = CopyFrame(from->GetCollisionFrame(), arena);
5552 to->shadow_frame = (CFrame *) CopyFrameVu1((CFrameVu1 *) from->shadow_frame, arena);
5553 to->shade_frame = (CFrame *) CopyFrameVu1((CFrameVu1 *) from->shade_frame, arena);
5554 CFrame *camera_frame = from->camera_frame;
5555
5556 if (camera_frame == NULL) {
5557 camera_frame = NULL;
5558 } else {
5559 camera_frame->SetPosition(from->pos[0], from->pos[1], from->pos[2]);
5560 from->camera_frame->SetRotation(from->rotation.x, from->rotation.y, from->rotation.z);
5561 camera_frame = from->camera_frame;
5562 }
5563
5564 to->camera_frame = CopyFrame(camera_frame, arena);
5565 to->ripple_frame = (CFrame *) CopyFrameVu1((CFrameVu1 *) from->ripple_frame, arena);
5566}
5567
5571int GetPosRot(CMapObject *object, float *position, float *rotation) {
5572 if (object == NULL) {
5573 return 0;
5574 }
5575
5576 CFrame *frame = object->frame[0];
5577
5578 if (frame == NULL) {
5579 return 0;
5580 }
5581
5582 sceVu0FVECTOR local_position;
5583 sceVu0CopyVector(local_position, object->pos);
5584 frame->SetPosition(local_position);
5585 position[3] = 1.0f;
5586 frame->GetWorldPosition(position, position);
5587 sceVu0FVECTOR frame_rotation;
5588 frame->GetRotation(frame_rotation);
5589 rotation[0] = 0.0f;
5590 rotation[1] = frame_rotation[1] + rotation[1];
5591 rotation[2] = 0.0f;
5592
5593 if (!(rotation[1] <= PI_SHORT)) {
5594 rotation[1] -= TWO_PI_SHORT;
5595 }
5596
5597 if (rotation[1] < -PI_SHORT) {
5598 rotation[1] += TWO_PI_SHORT;
5599 }
5600
5601 return 1;
5602}
5603
5607ED_EVENT_POINT *GetNewEventPoint(ED_EVENT_POINT *points, int count) {
5608 for (int i = 1; i < count; i++) {
5609 if (points[i].event_type == ED_EVENT_POINT_NONE) {
5610 return &points[i];
5611 }
5612 }
5613
5614 return NULL;
5615}
5616
5620int CheckEventPoint(ED_EVENT_POINT *point, float time) {
5621 if (point == NULL) {
5622 return 0;
5623 }
5624
5625 if (point->enabled == 0) {
5626 return 0;
5627 }
5628
5629 if (point->event_type <= ED_EVENT_POINT_NONE) {
5630 return 0;
5631 }
5632
5633 int flag = point->completion_flag;
5634
5635 if (flag > 0 && EdGetMapFlag(flag) != 0) {
5636 return 0;
5637 }
5638
5639 CFrame *frame = point->frame;
5640
5641 if (frame != NULL && !(frame->attr.draw_on & 1)) {
5642 return 0;
5643 }
5644
5645 if (EdCheckTime(time, point->start_time, point->end_time) == 0) {
5646 return 0;
5647 }
5648
5649 if (point->event_type == ED_EVENT_POINT_ITEM_BOX) {
5650 int dungeon = MapNo;
5651
5652 if (dungeon == 11) {
5653 dungeon = 1;
5654 }
5655
5656 if (dungeon == 13) {
5657 dungeon = 1;
5658 }
5659
5660 if (dungeon == 33) {
5661 dungeon = 1;
5662 }
5663
5664 if (dungeon == 19) {
5665 dungeon = 2;
5666 }
5667
5668 if (dungeon == 42) {
5669 dungeon = 3;
5670 }
5671
5672 if (dungeon == 23) {
5673 dungeon = 4;
5674 }
5675
5676 if (dungeon == 38) {
5677 dungeon = 5;
5678 }
5679
5680 if (dungeon == 40) {
5681 dungeon = 5;
5682 }
5683
5684 if (dungeon < 5) {
5685 CDngStatusData *status = SaveData->GetDngStatus();
5686 int reached = status->floor_reached[dungeon] + 1;
5687 int wanted = point->minimum_progress;
5688
5689 if (wanted > 0 && reached < wanted) {
5690 return 0;
5691 }
5692 }
5693 }
5694
5695 return 1;
5696}
5697
5698/* The order the static initialiser materialises each camera's float arguments in. */
5699#ifdef PAL
5700#pragma argument_flag 0
5701#pragma argument_flag_ones 1754, 1762, 1770, 1778, 1795, 1801, 1909, 1939, 1941, 1942
5702#pragma argument_flag_ones 1944, 1949, 1951, 1952, 1954, 1959, 1961, 1962, 1964, 1969
5703#pragma argument_flag_ones 1971, 1972, 1974, 1979, 1981, 1982, 1984, 1989, 1991, 1992
5704#pragma argument_flag_ones 1994
5705#else
5706#pragma argument_flag 0
5707#pragma argument_flag_ones 3504, 3512, 3520, 3528, 3545, 3551, 3659, 3689, 3691, 3692
5708#pragma argument_flag_ones 3694, 3699, 3701, 3702, 3704, 3709, 3711, 3712, 3714, 3719
5709#pragma argument_flag_ones 3721, 3722, 3724, 3729, 3731, 3732, 3734, 3739, 3741, 3742
5710#pragma argument_flag_ones 3744
5711#endif
CRect_i_ texel
Definition effect.hpp:170
void Initialize()
Definition effect.cpp:54
int disable_z_write
Definition effect.hpp:173
int alpha_blend
Definition effect.hpp:172
CTexture * texture
Definition effect.hpp:168
sceVu0FVECTOR min
Definition collision.hpp:29
sceVu0FVECTOR max
Definition collision.hpp:28
s16 foot_sound
Definition collision.hpp:56
s16 area_kind
Definition collision.hpp:57
void SetHeight(float height)
void SetFollow(float x, float y, float z)
void SetAngleSoon(float angle)
void AddAngle(float delta)
void SetDistance(float distance)
virtual void Step(int steps)
void AddHeight(float delta)
virtual void Step(int steps)
Definition camera.cpp:13
void GetCameraMatrix(float(*matrix)[4])
Definition camera.cpp:153
float snap_range
Definition camera.hpp:29
void GetRef(float *ref)
Definition camera.cpp:234
void SetRef(CFrame *parent, float x, float y, float z)
Definition camera.cpp:124
float GetAngleH()
Definition camera.cpp:238
void SetPos(CFrame *parent, float x, float y, float z)
Definition camera.cpp:103
void SetSpeed(float speed)
Definition camera.cpp:222
void GetPos(float *pos)
Definition camera.cpp:230
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)
CFrame * frame
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)
void ClearPointLight()
void InitializeTexAnime(CTexAnimeData *data, int count)
void SetFootSoundID(int id)
virtual void Step()
sceVu0FVECTOR ground_ambient[2]
virtual void ShadowStep()
static s32 MotionStopFlag
virtual void SetRotation(float x, float y, float z)
void FootSoundEnable(int on)
void TextureAnime(int step)
s32 ground_ambient_no
virtual void Initialize()
float body_height
float motion_speed
virtual void Draw()
virtual void SetPosition(float x, float y, float z)
int SetPointLight(float *pos, float inner_range, float outer_range, float red, float green, float blue, float alpha)
virtual void ClothStep(int step)
void Draw()
Definition dispctrl.cpp:60
char * texture_name
Definition gameloop.cpp:164
char text[0x200]
Definition gameloop.cpp:167
void SetMapInfo(int map_no, int area_id)
void SetOffset(float x, float y, float z)
void SetGridFrame(CFrameVu1 *frame)
CFrameVu1 * GetGridFrame()
void SetSize(int width, int height, float unit_size, float unit_alt)
Definition editarea.cpp:54
float GetUnitSize()
int GetPartsID(int x, int y)
Definition editarea.cpp:126
void GetPos(CVector3_i_ *position, float x, float y, float z)
Definition editarea.cpp:61
void GetGrid(CVector3_f_ *snapped, float x, float y, float z)
Definition editarea.cpp:598
void SetBuildEffect(int parts_id)
void DrawPartsCursor(int plot, float *position, float *model_pos, int rot_y, float *rotation, int area_no)
void DrawRipple(int pass)
CMapParts * river_parts
int SetMapParts(int parts_no, float x, float y, float z, int rot_y)
void Draw(float time, int pass, int lowest, int highest, int fixed_lowest, int fixed_highest)
void RequestCheck()
float GetAlt(float x, float y, float z)
CMapParts * road_parts
CEditArea * areas[4]
int GetAreaCode(float x, float y, float z)
CMapParts * GetParts(float x, float y, float z)
void DrawWaterSurface(CCamera *camera)
void EditAreaClip(CCamera *camera, float range)
void DrawBaseGround()
int CheckEffect()
void EffectTask()
EPARTS_FUNC_DATA * people[128]
void Initialize()
int SetFocusParts(float x, float y, float z)
void Save(char *path)
CMapParts * plot_parts
sceVu0FVECTOR clip_plane
int PickUpPoly(CCPoly *polygons, float x, float y, float z)
void Load(char *data)
void DrawWater(int pass)
CGroundWater water_surfaces[4]
CEditPartsInfo * parts_info
CMapParts fixed_parts[64]
void DrawEffect(CCameraFollow *camera, float time, CEffectGroup *effects)
void DrawShadow(int pass, float near_distance, float far_distance)
CPartsCursor cursor
void MakePartsBox()
int GetNearParts(CMapParts **out_parts, int limit, CBoxVu0 *box, CBoxVu0 *fixed_box)
int DeleteMapParts(int *out_parts_no, int *out_rot_y, float x, float y, float z)
void RemakeGrid()
void Initialize(int georama_no)
void Save(int georama_no, CSaveData *save_data)
int GetNextParts(int index)
int CheckComplete(int index)
EDITPARTS_INFO * GetPartsInfo(int index)
EDITPARTS_INFO parts[24]
void Load(int georama_no, CSaveData *save_data, int load_requests)
short draw_on
Definition frame.hpp:27
char clip_enable
Definition frame.hpp:29
short billboard
Definition frame.hpp:48
char use_color
Definition frame.hpp:38
char depth_write
Definition frame.hpp:45
char fog_enable
Definition frame.hpp:33
CFrameAttr attr
Definition frame.hpp:65
sceVu0FVECTOR position
Definition frame.hpp:76
float GetLXf2()
Definition gamepad.cpp:549
float GetLYf2()
Definition gamepad.cpp:553
int On(int mask)
Definition gamepad.cpp:557
void KeyLock(int mask)
Definition gamepad.cpp:501
int On2(int mask)
Definition gamepad.cpp:575
int Down2(int mask)
Definition gamepad.cpp:601
float GetRYf()
Definition gamepad.cpp:537
int Down(int mask)
Definition gamepad.cpp:583
void MenuModeOff()
Definition gamepad.cpp:617
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
virtual void Initialize()
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 FrameObjectOnOff(char *name, int on)
Definition mapobject.cpp:27
s32 parts_no
Definition mapparts.hpp:51
s32 func_count
Definition mapparts.hpp:58
virtual void SetPosition(float *position)
Definition mapparts.cpp:20
int GetHeight()
Definition mapparts.cpp:111
float lift
Definition mapparts.hpp:62
s32 func_data
Definition mapparts.hpp:59
CFrame * ripple_frame
Definition mapparts.hpp:56
s32 def_parts_no
Definition mapparts.hpp:60
s32 subtype
Definition mapparts.hpp:61
void Initialize()
Definition mapparts.cpp:50
int GetWidth()
Definition mapparts.cpp:94
virtual void SetRotation(float x, float y, float z)
Definition mapparts.cpp:30
CBoxVu0 bound
Definition mapparts.hpp:67
s32 preview_frame
Definition mapparts.hpp:54
void GetPosition(float *out_position)
Definition mapparts.cpp:16
float draw_distance
Definition mapparts.hpp:63
EDIT_EFFECT_INFO * effect[MAP_PARTS_EFFECT_MAX]
Definition mapparts.hpp:73
EDITPARTS_INFO * info
Definition mapparts.hpp:57
void CheckItemVolume()
void LoopStep(int interval)
virtual void Step()
s32 alpha_step_override
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
virtual void SetVelocity(CVector3_f_ velocity)
Definition object.cpp:50
virtual void GetVelocity(CVector3_f_ *out_velocity)
Definition object.cpp:100
float pos[4]
Definition object.hpp:18
CFrame * pieces[3]
s32 x
Definition rect.hpp:18
s32 width
Definition rect.hpp:20
s32 height
Definition rect.hpp:21
s32 y
Definition rect.hpp:19
void Lighting(int on)
void Step()
void Set(float *position)
void Draw()
float GetNowTime()
Definition savedata.cpp:61
CDngStatusData * GetDngStatus()
Definition savedata.cpp:250
SV_GRD_PART * GetParts(int georama_no, int *out_count)
Definition savedata.cpp:195
void SetNowTime(float time)
Definition savedata.cpp:57
int GetMapInitFlag(int map_no, int flag_no)
Definition savedata.cpp:391
int GetGameFlag(int flag_no)
Definition savedata.cpp:258
int SetMapFlag(int map_no, int flag_no, int value)
Definition savedata.cpp:356
s16 * GetElemData(int georama_no)
Definition savedata.cpp:242
void * GetConfigData()
Definition savedata.cpp:33
int SetMapInitFlag(int map_no, int flag_no, int value)
Definition savedata.cpp:420
int GetDay()
Definition savedata.cpp:96
int VisitMap(int map_no, int add)
Definition savedata.cpp:521
void AddNowTime(float add)
Definition savedata.cpp:65
SV_GEORAMA_DATA * GetGrdData(int georama_no)
Definition savedata.cpp:175
int GetMapFlag(int map_no, int flag_no)
Definition savedata.cpp:327
SV_EDIT_PARTS_INFO * GetEditPartsInfo(int georama_no, int plot_no)
Definition savedata.cpp:183
void Initialize(CTexAnimeData *records, int count)
void TexAnime(int texture_block)
void LoadCFGFile(char *script, int script_size)
static s32 stop_anime
u_long128 * buffer
Definition texture.hpp:101
u_long tex0
Definition texture.hpp:57
s8 floor_reached[7]
CFrameVu1 frame
Definition op_c.cpp:151
Definition wind.hpp:12
void SetVelocity(float speed)
Definition wind.cpp:9
void SetDir(float *direction)
Definition wind.cpp:5
void GetWind(float *out)
Definition wind.cpp:13
void Step()
Definition wind.cpp:21
float text_rate_set
Definition clsmes.hpp:193
void DrawMesWin()
Definition clsmes.cpp:2619
void Step()
Definition clsmes.cpp:575
s32 mes_no[10]
Definition clsmes.hpp:216
s32 page_arrow
Definition clsmes.hpp:209
float fade_speed
Definition clsmes.hpp:186
s32 fukidashi
Definition clsmes.hpp:164
s32 text_columns
Definition clsmes.hpp:157
s32 centre_rows
Definition clsmes.hpp:211
void * tex_buff
Definition clsmes.hpp:233
void SetBuff(short *buff)
Definition clsmes.cpp:456
s32 columns
Definition clsmes.hpp:155
s32 style
Definition clsmes.hpp:208
s32 tex_block
Definition clsmes.hpp:227
float text_rate
Definition clsmes.hpp:192
s32 stay_frame
Definition clsmes.hpp:189
MES_LINE_POS line_pos[10]
Definition clsmes.hpp:228
int MakeMesWin(int mes_no)
Definition clsmes.cpp:1669
void SetBuff_system(short *buff)
Definition clsmes.cpp:462
void Preset(int style)
Definition clsmes.cpp:468
s32 rows
Definition clsmes.hpp:156
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_CONTINUE
Definition edit.hpp:16
@ ED_EVENT_RETURN_EXIT
Definition edit.hpp:20
@ ED_EVENT_RETURN_FISHING
Definition edit.hpp:21
@ ED_EVENT_RETURN_NONE
Definition edit.hpp:13
@ ED_EVENT_RETURN_MAP_JUMP
Definition edit.hpp:18
@ ED_EVENT_RETURN_INTERIOR
Definition edit.hpp:14
@ ED_EVENT_RETURN_DUNGEON
Definition edit.hpp:15
@ ED_EVENT_RETURN_TALK
Definition edit.hpp:19
@ ED_MENU_UNK_4
Definition edit.hpp:36
@ ED_MENU_EDIT
Definition edit.hpp:33
@ 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
@ MAP_PARTS_SUBTYPE_RIVER
Definition mapparts.hpp:20
@ MAP_PARTS_SUBTYPE_ROAD
Definition mapparts.hpp:19
@ MAP_PARTS_SUBTYPE_BRIDGE
Definition mapparts.hpp:21
@ INTERPOLATE_FRACTION
Definition mathutil.hpp:16
@ INTERPOLATE_STEP
Definition mathutil.hpp:15
u_long128 * buffer
Definition dataread.hpp:29
EDITPARTS_ELEMENT elements[6]
char name[0x40]
Definition editloop.hpp:73
sceVu0FVECTOR offset
Definition objanime.hpp:171
char name[0x40]
Definition editloop.hpp:51
EDIT_MOTION_PARTS_INFO motion_parts[4]
Definition editloop.hpp:331
int sky_follow[3]
Definition editloop.hpp:324
EDIT_MAP_WORK_INFO work
Definition editloop.hpp:355
MAP_PARTS_INFO map_objects[64]
Definition editloop.hpp:329
float character_ambient[4][4]
Definition editloop.hpp:322
int object_timer_count
Definition editloop.hpp:352
char scene_name[0x40]
Definition editloop.hpp:308
EDIT_IMAGE_INFO images[64]
Definition editloop.hpp:323
EDIT_MAP_PARTS_WORK parts_work
Definition editloop.hpp:330
float shadow_near
Definition editloop.hpp:341
EDIT_FOG_INFO fog[12]
Definition editloop.hpp:321
EDIT_SCENE_LAYER_INFO sun_layers[4]
Definition editloop.hpp:327
EDIT_SCENE_LAYER_INFO sky_layers[5]
Definition editloop.hpp:326
float wind[4]
Definition editloop.hpp:315
float dof_start_time
Definition editloop.hpp:334
VILLAGER_INFO villagers[16]
Definition editloop.hpp:346
EDIT_WATER_INFO water_surfaces[8]
Definition editloop.hpp:332
CFrame * frame
Definition edit.hpp:118
CMapObject * object
Definition edit.hpp:117
char name[16]
Definition edit.hpp:116
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
s32 outside_map_no
Definition edit.hpp:197
float current_time
Definition edit.hpp:179
s32 npc_foot_sound[16]
Definition edit.hpp:172
s32 interior_entrance
Definition edit.hpp:194
s32 fadeout_event_no
Definition edit.hpp:215
s32 integer_arguments[8]
Definition edit.hpp:213
sceVu0FMATRIX light_color
Definition edit.hpp:210
s32 npc_count
Definition edit.hpp:176
s32 edit_parts_count
Definition edit.hpp:185
s32 npc_collision[16]
Definition edit.hpp:169
CNPCharacter * npcs
Definition edit.hpp:162
s32 player_texture_block
Definition edit.hpp:168
ClsMes * messages[8]
Definition edit.hpp:178
s32 main_texture_animation_count
Definition edit.hpp:161
sceVu0FVECTOR screen_filter_color
Definition edit.hpp:206
sceVu0FVECTOR wind
Definition edit.hpp:181
CTexAnimeData * main_texture_animation
Definition edit.hpp:160
s32 suppress_shadows
Definition edit.hpp:200
s32 npc_texture_block
Definition edit.hpp:175
s32 world_coord_enable
Definition edit.hpp:150
s32 screen_filter
Definition edit.hpp:204
CMapParts * edit_parts
Definition edit.hpp:186
s32 player_collision
Definition edit.hpp:163
s32 player_foot_sound
Definition edit.hpp:166
float reset_camera_yaw
Definition edit.hpp:158
s32 lighting_override
Definition edit.hpp:207
s32 reset_camera_angle
Definition edit.hpp:157
s32 interior_start_event
Definition edit.hpp:196
s32 fixed_parts_count
Definition edit.hpp:183
char interior_name[0x20]
Definition edit.hpp:195
s32 map_jump_bgm_stop
Definition edit.hpp:152
CMapParts * fixed_parts
Definition edit.hpp:184
s32 draw_exclamation_mark
Definition edit.hpp:198
s32 suppress_background
Definition edit.hpp:199
CCharacter * main_character
Definition edit.hpp:159
VILLAGER_INFO * villagers
Definition edit.hpp:177
s32 return_code
Definition edit.hpp:217
sceVu0FMATRIX light_direction
Definition edit.hpp:209
CEditGround * edit_ground
Definition edit.hpp:182
sceVu0FVECTOR ambient_color
Definition edit.hpp:211
sceVu0FVECTOR position
Definition edit.hpp:72
sceVu0FVECTOR camera_pos
Definition edit.hpp:73
ED_EVENT_POINT * point
Definition edit.hpp:76
sceVu0FVECTOR rotation
Definition edit.hpp:74
char destination[0x10]
Definition editloop.hpp:253
CCamera * camera
Definition editloop3.hpp:42
C3DSprite * system_effect
Definition editloop3.hpp:41
CEditGround * ground
Definition editloop3.hpp:39
CFrame * event_marker
Definition editloop3.hpp:40
CCharacter * player
Definition editloop3.hpp:37
int complete_event_seen
Definition editloop.cpp:301
CCamera * view_camera
Definition edit.hpp:87
ED_EVENT_PARAM param
Definition edit.hpp:96
float motion_time_before
Definition edit.hpp:104
CCameraFollow * camera
Definition edit.hpp:86
float motion_time_after
Definition edit.hpp:103
CCharacter * chara
Definition edit.hpp:85
CEditGround * ground
Definition edit.hpp:91
ED_EVENT_POINT * points
Definition edit.hpp:97
CMapParts * parts
Definition objanime.hpp:100
char frame_name[0x10]
Definition objanime.hpp:106
EPARTS_FUNC_DATA * func
char name[9][0x40]
Definition editloop.hpp:95
float position[3]
Definition editloop.hpp:99
float rotation[3]
Definition editloop.hpp:100
MAP_PARTS_INFO parts[24]
Definition editloop.hpp:127
EDIT_AREA_INFO edit_areas[444]
Definition editloop.hpp:123
EDIT_PARTS_DEF defs[24]
Definition editloop.hpp:132
OBJ_ANIME_SEQ obj_anime[128]
Definition editloop.hpp:267
EDIT_EFFECT_INFO second[64]
Definition editloop.hpp:272
EDIT_EFFECT_INFO first[64]
Definition editloop.hpp:271
EDIT_OBJECT_TIMER timers[128]
Definition editloop.hpp:277
ED_EVENT_POINT points[256]
Definition editloop.hpp:282