From 61bc14560a0912f8f3f9a5ade82eaa35cbc0f068 Mon Sep 17 00:00:00 2001 From: MokhaLeee Date: Fri, 8 Dec 2023 19:35:02 +0000 Subject: [PATCH] event RenaisThroneCutscene done --- data/data_591AB4.s | 10 +- data/data_591F38.s | 6 +- data/data_59DB6C.s | 11 -- data/data_8B363C.s | 34 +++- data/data_9ED64C.s | 4 - include/bmmap.h | 20 ++- include/bmmind.h | 42 ++++- include/bmpatharrowdisp.h | 7 +- include/bmsave.h | 1 + include/bmunit.h | 1 - include/constants/characters.h | 9 + include/ea-stdlib.h | 109 ++++++++++++ include/event.h | 19 +- include/eventinfo.h | 13 +- include/eventscript-stdlib.h | 67 ------- include/eventscript.h | 51 +++++- include/types.h | 35 ---- include/variables.h | 6 +- ldscript.txt | 2 +- src/bm.c | 2 +- src/bmarena.c | 1 + src/bmbattle.c | 1 + src/bmidoten.c | 1 + src/bmio.c | 1 + src/bmitemuse.c | 2 +- src/bmmap.c | 1 + src/bmmenu.c | 2 +- src/bmmind.c | 12 +- src/bmpatharrowdisp.c | 127 ++++++++------ src/bmshop.c | 1 + src/bmtrade.c | 2 +- src/bmtrap.c | 2 +- src/bmunit.c | 1 + src/bmusemind.c | 2 +- src/classchg-handler.c | 1 + src/classchg-sel.c | 1 + src/convoymenu.c | 1 + src/cp_decide.c | 2 +- src/danceringfx.c | 1 + src/eventcall.c | 1 + src/eventinfo.c | 2 +- src/events/prologue-eventinfo.h | 6 +- src/events/prologue-eventscript.h | 168 +++++++++++++++++- src/events_info.c | 2 +- src/events_script.c | 2 +- src/evtscr.c | 279 ++++++++++++------------------ src/evtsub.c | 1 + src/mapanim_summon.c | 1 + src/msg.c | 1 + src/prep_itemsupply.c | 1 + src/uiarena.c | 1 + sym_ewram.txt | 8 +- 52 files changed, 673 insertions(+), 411 deletions(-) delete mode 100644 data/data_59DB6C.s create mode 100644 include/ea-stdlib.h delete mode 100644 include/eventscript-stdlib.h diff --git a/data/data_591AB4.s b/data/data_591AB4.s index d22e77c7..c018ee25 100644 --- a/data/data_591AB4.s +++ b/data/data_591AB4.s @@ -57,18 +57,18 @@ gEventLoCmdTable: @ 0x08591B28 .4byte Event04_CheckRandom, Event05_SetSlot, Event06_SlotOperation, Event07_SlotQueueOperations .4byte Event08_Label, Event09_Goto, Event0A_Call, Event0B_ .4byte Event0C_Branch, Event0D_AsmCall, Event0E_STAL, Event0F_ - .4byte Event10_ModifyEvBit, Event11_SetIgnoredKeys, Event12_, Event13_ - .4byte Event14_, Event15_BgmVolume, Event16_, Event17_ + .4byte Event10_ModifyEvBit, Event11_SetIgnoredKeys, Event12_StartBGM, Event12_BgmFadeIn + .4byte Event14_, Event15_BgmVolume, Event16_, Event17_Fade .4byte Event18_, Event19_, Event1A_TEXTSTART, Event1B_TEXTSHOW .4byte Event1C_TEXTCONT, Event1D_TEXTEND, Event1E_, Event1F_ - .4byte Event20_, Event21_, Event22_, Event23_DisaleMapDisp - .4byte Event24_, Event25_, Event26_CameraControlMaybe, Event27_MapChange + .4byte Event20_, Event21_, Event22_ClearScreen, Event23_DisaleMapDisp + .4byte Event24_EnableMapDisp, Event25_ChangeMap, Event26_CameraControl, Event27_MapChange .4byte Event28_ChangeWeather, Event29_SetFogVision, Event2A_MoveToChapter, Event2B_ .4byte Event2C_LoadUnits, Event2D_, Event2E_CheckAt, Event2F_MoveUnit .4byte Event30_ENUN, Event31_DisplayEffectRange, Event32_SpawnSingleUnit, Event33_CheckUnitVarious .4byte Event34_MessWithUnitState, Event35_UnitClassChanging, Event36_CheckInArea, Event37_GiveItem .4byte Event38_ChangeActiveUnit, Event39_ChangeAiScript, Event3A_DisplayPopup, Event3B_DisplayCursor - .4byte Event3C_, Event3D_, Event3E_PrepScreenCall, Event3F_ + .4byte Event3C_, Event3D_, Event3E_PrepScreenCall, Event3F_ScriptBattle .4byte Event40_, Event41_, Event42_, Event43_ .4byte Event44_BreakingSacredStone, Event45_ diff --git a/data/data_591F38.s b/data/data_591F38.s index f40683b1..6d8addfd 100644 --- a/data/data_591F38.s +++ b/data/data_591F38.s @@ -2,7 +2,11 @@ .global gUnknown_08591F38 gUnknown_08591F38: @ 0x08591F38 - .incbin "baserom.gba", 0x591F38, 0x50 + .incbin "baserom.gba", 0x591F38, 8 + + .global gEvent_RemoveBGIfNeeded +gEvent_RemoveBGIfNeeded: + .incbin "baserom.gba", 0x591F40, 0x48 .global gEvent_DisplayBattleQuote gEvent_DisplayBattleQuote: @ 0x08591F88 diff --git a/data/data_59DB6C.s b/data/data_59DB6C.s deleted file mode 100644 index 3f54b52a..00000000 --- a/data/data_59DB6C.s +++ /dev/null @@ -1,11 +0,0 @@ - .section .data - - .global gPathArrowOAMTable -gPathArrowOAMTable: @ 0x0859DB6C - .incbin "baserom.gba", 0x59DB6C, 0x34 - - .global gUnknown_0859DBA0 -gUnknown_0859DBA0: @ 0x0859DBA0 -@ replacing .incbin "baserom.gba", 0x0059dba0, 0x4 -.4byte gUnknown_0203A974 + 0x1c - diff --git a/data/data_8B363C.s b/data/data_8B363C.s index 0e951a46..6d2d24c3 100644 --- a/data/data_8B363C.s +++ b/data/data_8B363C.s @@ -307,9 +307,37 @@ gUnknown_088B39EC: @ 0x088B39EC gUnknown_088B3AD8: @ 0x088B3AD8 .incbin "baserom.gba", 0x8B3AD8, 0x8B3C14 - 0x8B3AD8 - .global UnitDef_Blue_Prologue -UnitDef_Blue_Prologue: - .incbin "baserom.gba", 0x8B3C14, 0x8D1F54 - 0x8B3C14 + .global UnitDef_Event_PrologueAlly +UnitDef_Event_PrologueAlly: + .incbin "baserom.gba", 0x8B3C14, 0x8B3D18 - 0x8B3C14 + + .global UnitDef_Event_PrologueThroneRoomUnits +UnitDef_Event_PrologueThroneRoomUnits: + .incbin "baserom.gba", 0x8B3D18, 0x8B3DCC - 0x8B3D18 + + .global UnitDef_Event_PrologueMessager +UnitDef_Event_PrologueMessager: + .incbin "baserom.gba", 0x8B3DCC, 0x8B3DF4 - 0x8B3DCC + + .global UnitDef_Event_PrologueGradoRoyals +UnitDef_Event_PrologueGradoRoyals: + .incbin "baserom.gba", 0x8B3DF4, 0x8B3E30 - 0x8B3DF4 + + .global UnitDef_Event_PrologueGradoShamans +UnitDef_Event_PrologueGradoShamans: + .incbin "baserom.gba", 0x8B3E30, 0x8B3E94 - 0x8B3E30 + + .global UnitDef_Event_PrologueGradoCavalry +UnitDef_Event_PrologueGradoCavalry: + .incbin "baserom.gba", 0x8B3E94, 0x8B3F68 - 0x8B3E94 + + .global UnitDef_Event_PrologueEscapees +UnitDef_Event_PrologueEscapees: + .incbin "baserom.gba", 0x8B3F68, 0x8B3FB8 - 0x8B3F68 + + .global UnitDef_Event_PrologueValterGroup +UnitDef_Event_PrologueValterGroup: + .incbin "baserom.gba", 0x8B3FB8, 0x8D1F54 - 0x8B3FB8 .global gUnitDefSumDK gUnitDefSumDK: @ 0x088D1F54 diff --git a/data/data_9ED64C.s b/data/data_9ED64C.s index c3e7039e..4b2c6137 100644 --- a/data/data_9ED64C.s +++ b/data/data_9ED64C.s @@ -1,9 +1,5 @@ .section .data - .global EventScr_Prologue_RenaisThroneCutscene -EventScr_Prologue_RenaisThroneCutscene: - .incbin "baserom.gba", 0x9EECBC, 0x9EF060 - 0x9EECBC - .global EventScr_Prologue_GiveRapier EventScr_Prologue_GiveRapier: .incbin "baserom.gba", 0x9EF060, 0x9EF0A4 - 0x9EF060 diff --git a/include/bmmap.h b/include/bmmap.h index 18825ebf..7189c722 100644 --- a/include/bmmap.h +++ b/include/bmmap.h @@ -1,6 +1,8 @@ #ifndef GUARD_BMMAP_H #define GUARD_BMMAP_H +#include "global.h" + void InitChapterMap(int chapterId); void InitMapForMinimap(int chapterId); void sub_8019624(void); @@ -27,16 +29,16 @@ void sub_801A278(void); void RevertMapChange(int id); extern struct Vec2 gBmMapSize; -extern u8** gBmMapUnit; -extern u8** gBmMapTerrain; -extern u8** gBmMapMovement; -extern u8** gBmMapRange; -extern u8** gBmMapFog; -extern u8** gBmMapHidden; -extern u8** gBmMapOther; +extern u8 ** gBmMapUnit; +extern u8 ** gBmMapTerrain; +extern u8 ** gBmMapMovement; +extern u8 ** gBmMapRange; +extern u8 ** gBmMapFog; +extern u8 ** gBmMapHidden; +extern u8 ** gBmMapOther; -extern u8* gTilesetTerrainLookup; -extern u16** gBmMapBaseTiles; +extern u8 * gTilesetTerrainLookup; +extern u16 ** gBmMapBaseTiles; enum { diff --git a/include/bmmind.h b/include/bmmind.h index fddc26c0..0fc21ed4 100644 --- a/include/bmmind.h +++ b/include/bmmind.h @@ -4,6 +4,46 @@ #include "global.h" #include "bmunit.h" #include "proc.h" +#include "bmbattle.h" + +struct ActionData +{ + // unknown stuff (sometimes RNs are pushed here) (maybe an union?) + /* 00 */ u16 _u00[3]; + /* 06 */ u16 item; + + /* 08 */ u16 unk08; + /* 0A */ u16 unk0A; + + /* 0C */ u8 subjectIndex; + /* 0D */ u8 targetIndex; + + /* 0E */ u8 xMove; + /* 0F */ u8 yMove; + + /* 10 */ u8 moveCount; + + /* 11 */ u8 unitActionType; + + // maybe from this onwards it's an union? + + /* 12 */ u8 itemSlotIndex; + + /* 13 */ u8 xOther; + /* 14 */ u8 yOther; + + /* 15 */ u8 trapType; + + /* 16 */ u8 suspendPointType; + + /* 18 */ struct BattleHit * scriptedBattleHits; + + /* 1C */ struct BattleHit script_hits[7]; /* equals to sizeof event-queue */ + + /* 38 */ +}; + +extern struct ActionData gActionData; struct AfterDropActionProc { /* 00 */ PROC_HEADER; @@ -70,7 +110,7 @@ void sub_80328B0(void); bool BATTLE_HandleItemDrop(struct CombatActionProc * proc); void sub_8032974(ProcPtr proc); void BATTLE_HandleArenaDeathsMaybe(ProcPtr proc); -u8 * sub_80329C0(u8 * r0); +struct BattleHit * sub_80329C0(struct BattleHit * r0); extern struct ProcCmd CONST_DATA sProcScr_CombatAction[]; extern struct ProcCmd CONST_DATA sProcScr_AfterDropAction[]; diff --git a/include/bmpatharrowdisp.h b/include/bmpatharrowdisp.h index 4b3a5868..c519f03c 100644 --- a/include/bmpatharrowdisp.h +++ b/include/bmpatharrowdisp.h @@ -14,10 +14,9 @@ struct PathArrowProc /* 0x41 */ s8 pathY[20]; /* 0x55 */ s8 pathCosts[20]; }; -struct Unknown_0859DBA0 { - struct PathArrowProc *proc; -}; -extern struct Unknown_0859DBA0 gUnknown_0859DBA0; + +extern struct PathArrowProc gPathArrowProc; +extern CONST_DATA struct PathArrowProc * gpPathArrowProc; extern u16 gPathArrowOAMTable[5][5]; diff --git a/include/bmsave.h b/include/bmsave.h index 837ee520..fe71216a 100755 --- a/include/bmsave.h +++ b/include/bmsave.h @@ -7,6 +7,7 @@ #include "bmtrick.h" #include "bmdifficulty.h" #include "bonusclaim.h" +#include "bmmind.h" enum { UNIT_SAVE_AMOUNT_BLUE = 51, diff --git a/include/bmunit.h b/include/bmunit.h index 0b2eb665..bad716ea 100644 --- a/include/bmunit.h +++ b/include/bmunit.h @@ -352,7 +352,6 @@ extern CONST_DATA struct CharacterData gCharacterData[]; // gCharacterData extern struct UnitDefinition gUnitDef1; extern struct UnitDefinition gUnitDef2; extern struct UnitDefinition gUnitDefEggHatching; -extern struct UnitDefinition UnitDef_Blue_Prologue[]; extern struct UnitDefinition gUnitDefSumDK[]; extern struct Unit gUnitArrayBlue[62]; extern struct Unit gUnitArrayRed[50]; diff --git a/include/constants/characters.h b/include/constants/characters.h index a20e8a1d..7f5b45e6 100644 --- a/include/constants/characters.h +++ b/include/constants/characters.h @@ -94,6 +94,15 @@ enum { CHARACTER_MONSTER_BA = 0xBA, CHARACTER_FOMORTIIS = 0xBE, + CHARACTER_FADO = 0xC5, + + CHARACTER_HAYDEN = 0xC7, + CHARACTER_MANSEL = 0xC8, + CHARACTER_KLIMT = 0xC9, + CHARACTER_DARA = 0xCA, + CHARACTER_ISMAIRE = 0xCB, + CHARACTER_MESSENGER = 0xCC, + CHARACTER_CITIZEN = 0xFC, CHARACTER_ARENA_OPPONENT = 0xFD, CHARACTER_WALL = 0xFE, diff --git a/include/ea-stdlib.h b/include/ea-stdlib.h new file mode 100644 index 00000000..4c134dc3 --- /dev/null +++ b/include/ea-stdlib.h @@ -0,0 +1,109 @@ +#pragma once + +/** + * port for: EA Standard Library + */ + +#include "eventscript.h" +#include "constants/event-flags.h" + +#define ENDA EvtReturn +#define ENDB EvtEndAll +#define EVBIT_F EvtClearEvBits +#define EVBIT_T EvtSetEvBits +#define ENUF EvtClearFlag +#define ENUT EvtSetFlag +#define SVAL EvtSetSlot +#define SENQUEUE EvtEnqueueFormSlot +#define SENQUEUE1 EvtEnqueueFormSlot1 +#define SDEQUEUE EvtDequeueToSlot +#define LABEL EvtLabel +#define CALL EvtCall +#define BNE EvtBNE +#define ASMC EvtAsmCall +#define STAL EvtSleep +#define STAL1 EvtSleepWithCancel +#define STAL2 EvtSleepWithGameCtrl +#define STAL3 EvtSleepWithCancelGameCtrl +#define MUSC EvtStartBgm +#define MUSCFAST EvtBgmFadeInFast +#define MUSCMID EvtBgmFadeInMiddleSpeed +#define MUSCSLOW EvtBgmFadeInSlowly +#define MUSI EvtSetVolumeDown +#define MUNO EvtUnsetVolumeDown +#define FADU EvtFadeOutBlack +#define FADI EvtFadeInBlack +#define FAWU EvtFadeOutWhite +#define FAWI EvtFadeInWhite +#define CHECK_TUTORIAL EvtCheckTutorial +#define TEXTSTART EvtTextStart +#define TEXTSHOW EvtTextShow +#define REMA EvtTextRemoveAll +#define TEXTEND EvtTextEnd +#define LOMA EvtLoadMap +#define CAMERA EvtMoveCameraTo +#define LOAD1 EvtLoadUnit1 +#define LOAD2 EvtLoadUnit2 +#define MOVE EvtMoveUnit +#define MOVEONTO EvtMoveUnitToTarget +#define MOVE_1STEP EvtMoveUnitOneStpe +#define MOVEFORCED EvtMoveUnitByQueue +#define _WARP EvtMoveUnitToValidTerrain /* This is an error on EA stdlib */ +#define ENUN EvtWaitUnitMoving +#define SET_HP EvtSetHpFormSlot1 +#define CLEA EvtHideAllAlliess +#define CLEN EvtRemoveAllNpcs +#define CLEE EvtRemoveAllEimies +#define DISA EvtRemoveUnit +#define BROWNBOXTEXT EvtDisplayPopupSilently +#define CURSOR_CHAR EvtDisplayCursorAtUnit +#define CURSOR_FLASHING_CHAR EvtDisplayFlashingCursorAtUnit +#define CURE EvtEndCursor +#define FIGHT EvtStartEventBattle +#define FIGHT_MAP EvtStartEventMapBattle +#define FIGHT_SCRIPT EvtStartScriptedBattle + +#define CUMO_CHAR CURSOR_CHAR + +#define END_MAIN EvtListEnd +#define TURN EvtListTurn +#define AFEV EvtListFlag + +/* Main Code Helpers */ +#define DefeatBoss(event_scr) AFEV(EVFLAG_WIN, (event_scr), EVFLAG_DEFEAT_BOSS) +#define CauseGameOverIfLordDies AFEV(0, gEvent_GameOver, EVFLAG_GAMEOVER) +#define NoFade EVBIT_T(0x7) + +/* Unit Helpers */ +#define FlashCursor(pid, time) \ + CUMO_CHAR(pid) \ + STAL(time) \ + CURE + +#define StartBattle SVAL(EVT_SLOT_D, 0) +#define NormalDamage(combatantNumber,damage) SVAL(EVT_SLOT_1, combatantNumber + damage * 0x100) SAVETOQUEUE +#define CriticalHit(combatantNumber,damage) SVAL(EVT_SLOT_1, combatantNumber + damage * 0x100 + 0x00010000) SAVETOQUEUE +#define MissedAttack(combatantNumber,damage) SVAL(EVT_SLOT_1, combatantNumber + damage * 0x100 + 0x00020000) SAVETOQUEUE +#define Silencer(combatantNumber,damage) SVAL(EVT_SLOT_1, combatantNumber + damage * 0x100 + 0x00080000) SAVETOQUEUE +#define SureShot(combatantNumber,damage) SVAL(EVT_SLOT_1, combatantNumber + damage * 0x100 + 0x00400000) SAVETOQUEUE +#define Poison(combatantNumber,damage) SVAL(EVT_SLOT_1, combatantNumber + damage * 0x100 + 0x00400000) SAVETOQUEUE +#define DevilReversal(combatantNumber,damage) SVAL(EVT_SLOT_1, combatantNumber + damage * 0x100 + 0x00800000) SAVETOQUEUE +#define Pierce(combatantNumber,damage) SVAL(EVT_SLOT_1, combatantNumber + damage * 0x100 + 0xC0000000) SAVETOQUEUE +#define EndAttack SVAL(EVT_SLOT_1, 0xFFFFFFFF) SAVETOQUEUE + +/* Convo Helpers */ +#define Text(msg) \ + TEXTSTART \ + TEXTSHOW(msg) \ + TEXTEND \ + REMA + +#define Text_BG(bg, msg) \ + EvtSetSlot(EVT_SLOT_2, (bg)) \ + EvtSetSlot(EVT_SLOT_3, (msg)) \ + EvtCall(Event_TextWithBG) + +/* Code Ailases */ +#define SLOTS_SETFROMQUEUE SDEQUEUE +#define SAVETOQUEUE SENQUEUE1 +#define STQFROMSLOT SENQUEUE1 diff --git a/include/event.h b/include/event.h index 0050a180..bfa6fad4 100644 --- a/include/event.h +++ b/include/event.h @@ -5,6 +5,8 @@ #include "bmunit.h" struct UnitDefinition; +typedef uintptr_t EventListScr; +typedef uintptr_t EventScr; struct EventEngineProc { @@ -194,6 +196,7 @@ extern struct ProcCmd gUnknown_08591EB0[]; extern struct ProcCmd CONST_DATA ProcScr_EventDisplayCursor[]; extern struct ProcCmd CONST_DATA ProcScr_ScriptBattleDeamon[]; extern struct ProcCmd CONST_DATA gUnknown_08591F28[]; +extern EventScr gEvent_RemoveBGIfNeeded[]; extern const u16 gEvent_DisplayBattleQuote[]; extern const u16 gEvent_TriggerQueuedTileChanges[]; extern const u16 gEvent_OpenChest[]; @@ -364,12 +367,12 @@ void sub_800BCDC(u16); // battle related // ??? Event0F_(???); // ??? Event10_ModifyEvBit(???); // ??? Event11_SetIgnoredKeys(???); -// ??? Event12_(???); -// ??? Event13_(???); +// ??? Event12_StartBGM(???); +// ??? Event12_BgmFadeIn(???); // ??? Event14_(???); // ??? Event15_BgmVolume(???); // ??? Event16_(???); -// ??? Event17_(???); +// ??? Event17_Fade(???); // ??? Event18_(???); // ??? Event19_(???); // ??? Event1A_TEXTSTART(???); @@ -394,11 +397,11 @@ void sub_800E640(struct EventEngineProc*); // ??? sub_800EE54(???); // ??? sub_800EEE8(???); // ??? sub_800EF48(???); -u8 Event22_(struct EventEngineProc *); // CLEAN +u8 Event22_ClearScreen(struct EventEngineProc *); // CLEAN u8 Event23_DisaleMapDisp(struct EventEngineProc *); // Lock Game Graphics -u8 Event24_(struct EventEngineProc *); // Resume Game Graphics -u8 Event25_(struct EventEngineProc *); -// ??? Event26_CameraControlMaybe(???); +u8 Event24_EnableMapDisp(struct EventEngineProc *); // Resume Game Graphics +u8 Event25_ChangeMap(struct EventEngineProc *); +// ??? Event26_CameraControl(???); // ??? Event27_MapChange(???); // ??? Event28_ChangeWeather(???); // ??? Event29_SetFogVision(???); @@ -435,7 +438,7 @@ unsigned ModifyMoveUnitFlag(struct EventEngineProc *, s8); // ??? Event3E_PrepScreenCall(???); // ??? sub_801098C(???); // ??? ScriptBattleDeamon(???); -// ??? Event3F_(???); +// ??? Event3F_ScriptBattle(???); // ??? sub_8010B48(???); // ??? Event40_(???); // ??? Event41_(???); diff --git a/include/eventinfo.h b/include/eventinfo.h index a8f59891..913b3b1e 100644 --- a/include/eventinfo.h +++ b/include/eventinfo.h @@ -3,6 +3,7 @@ #include "global.h" #include "event.h" +#include "bmunit.h" enum { EVENT_NOSCRIPT = 1 }; @@ -35,9 +36,6 @@ enum { TUTORIAL_EVT_TYPE_PLAYERPHASE = 6, }; -typedef uintptr_t EventListScr; -typedef uintptr_t EventScr; - struct EventInfo { /* 00 */ EventListScr * listScript; /* 04 */ u32 script; @@ -254,4 +252,13 @@ extern CONST_DATA EventListScr EventScr_Prologue_TutorialC[]; extern CONST_DATA EventListScr EventScr_Prologue_TutorialD[]; extern CONST_DATA EventListScr EventScr_Prologue_TutorialE[]; +extern struct UnitDefinition UnitDef_Event_PrologueAlly[]; +extern struct UnitDefinition UnitDef_Event_PrologueThroneRoomUnits[]; +extern struct UnitDefinition UnitDef_Event_PrologueMessager[]; +extern struct UnitDefinition UnitDef_Event_PrologueGradoRoyals[]; +extern struct UnitDefinition UnitDef_Event_PrologueGradoShamans[]; +extern struct UnitDefinition UnitDef_Event_PrologueGradoCavalry[]; +extern struct UnitDefinition UnitDef_Event_PrologueEscapees[]; +extern struct UnitDefinition UnitDef_Event_PrologueValterGroup[]; + #endif // GUARD_eventinfo_H diff --git a/include/eventscript-stdlib.h b/include/eventscript-stdlib.h deleted file mode 100644 index 1fcc2c42..00000000 --- a/include/eventscript-stdlib.h +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once - -/** - * port for: EA Standard Library - */ - -#include "eventscript.h" -#include "constants/event-flags.h" - -#define ENDA EvtReturn -#define ENDB EvtEndAll -#define EVBIT_F EvtClearEvBits -#define EVBIT_T EvtSetEvBits -#define ENUF EvtClearFlag -#define ENUT EvtSetFlag -#define SVAL EvtSetSlot -#define LABEL EvtLabel -#define CALL EvtCall -#define BNE EvtBNE -#define ASMC EvtAsmCall -#define STAL EvtSleep -#define STAL1 EvtSleepWithCancel -#define STAL2 EvtSleepWithGameCtrl -#define STAL3 EvtSleepWithCancelGameCtrl -#define MUSI EvtSetVolumeDown -#define MUNO EvtUnsetVolumeDown -#define CHECK_TUTORIAL EvtCheckTutorial -#define TEXTSTART EvtTextStart -#define TEXTSHOW EvtTextShow -#define REMA EvtTextRemoveAll -#define TEXTEND EvtTextEnd -#define LOAD1 EvtLoadUnit1 -#define MOVE EvtMoveUnit -#define _WARP EvtMoveUnitToValidTerrain /* This is an error on EA stdlib */ -#define ENUN EvtWaitUnitMoving -#define SET_HP EvtSetHpFormSlot1 -#define CURSOR_CHAR EvtDisplayCursorAtUnit -#define CURSOR_FLASHING_CHAR EvtDisplayFlashingCursorAtUnit -#define CURE EvtEndCursor -#define CUMO_CHAR CURSOR_CHAR - -#define END_MAIN EvtListEnd -#define TURN EvtListTurn -#define AFEV EvtListFlag - -/* Main Code Helpers */ -#define DefeatBoss(event_scr) AFEV(EVFLAG_WIN, (event_scr), EVFLAG_DEFEAT_BOSS) -#define CauseGameOverIfLordDies AFEV(0, gEvent_GameOver, EVFLAG_GAMEOVER) -#define NoFade EVBIT_T(0x7) - -/* Unit Helpers */ -#define FlashCursorCHAR(pid, time) \ - CUMO_CHAR(pid) \ - STAL(time) \ - CURE - -/* Convo Helpers */ -#define Text(msg) \ - TEXTSTART \ - TEXTSHOW(msg) \ - TEXTEND \ - REMA - -#define Text_BG(bg, msg) \ - EvtSetSlot(EVT_SLOT_2, (bg)) \ - EvtSetSlot(EVT_SLOT_3, (msg)) \ - EvtCall(Event_TextWithBG) diff --git a/include/eventscript.h b/include/eventscript.h index 399b1784..fe13ba67 100644 --- a/include/eventscript.h +++ b/include/eventscript.h @@ -67,7 +67,7 @@ enum event_cmd_idx { EV_CMD_3C = 0x3C, EV_CMD_3D = 0x3D, EV_CMD_PREPSCREEN = 0x3E, - EV_CMD_3F = 0x3F, + EV_CMD_SCRIPT_BATTLE = 0x3F, EV_CMD_40 = 0x40, EV_CMD_41 = 0x41, EV_CMD_42 = 0x42, @@ -106,7 +106,7 @@ enum event_sub_cmd_idx { /* EV_CMD_QUEUE_OPS */ EVSUBCMD_SENQUEUE = 0, - EVSUBCMD_SDEQUEUE_S1 = 1, + EVSUBCMD_SENQUEUE_S1 = 1, EVSUBCMD_SDEQUEUE = 2, /* EV_CMD_BRANCH */ @@ -123,10 +123,23 @@ enum event_sub_cmd_idx { EVSUBCMD_STAL2 = 2, EVSUBCMD_STAL3 = 3, + /* EV_CMD_BGMCHANGE_12 */ + + /* EV_CMD_BGMCHANGE_13 */ + EVSUBCMD_MUSCFAST = 2, + EVSUBCMD_MUSCMID = 4, + EVSUBCMD_MUSCSLOW = 6, + /* EV_CMD_BGMVOLUMECHANGE */ EVSUBCMD_MUSI = 0, EVSUBCMD_MUNO = 1, + /* EV_CMD_FADE */ + EVSUBCMD_FADU = 0, + EVSUBCMD_FADI = 1, + EVSUBCMD_FAWU = 2, + EVSUBCMD_FAWI = 3, + /* EV_CMD_CHECKVARIOUS */ EVSUBCMD_CHECK_MODE = 0, EVSUBCMD_CHECK_CHAPTER_NUMBER = 0x1, @@ -184,12 +197,21 @@ enum event_sub_cmd_idx { EVSUBCMD_DISA_IF = 0xE, EVSUBCMD_DISA = 0xF, + /* EV_CMD_DISPLAYPOPUP */ + EVSUBCMD_POPUP = 0, + EVSUBCMD_BROWNTEXTBOX = 1, + /* EV_CMD_DISPLAYCURSOR */ EVSUBCMD_CURSOR_AT = 0x0, EVSUBCMD_CURSOR_UNIT = 0x1, EVSUBCMD_CURE = 0x2, EVSUBCMD_CURSOR_FLASHING_AT = 0x4, EVSUBCMD_CURSOR_FLASHING_UNIT = 0x5, + + /* EV_CMD_SCRIPT_BATTLE */ + EVSUBCMD_FIGHT = 0, + EVSUBCMD_FIGHT_MAP = 1, + EVSUBCMD_FIGHT_SCRIPT = 2, }; #define _EvtParams2(x, y) ((((y) & 0xFFFF) << 16) + ((x) & 0xFFFF)) @@ -211,6 +233,9 @@ enum event_sub_cmd_idx { #define EvtClearFlag(flag) _EvtArg0(EV_CMD_EVSET, 2, EVSUBCMD_ENUF, (flag)), #define EvtSetFlag(flag) _EvtArg0(EV_CMD_EVSET, 2, EVSUBCMD_ENUT, (flag)), #define EvtSetSlot(slot, value) _EvtArg0(EV_CMD_SVAL, 4, 0, (slot)), (EventListScr)(value), +#define EvtEnqueueFormSlot(slot) _EvtArg0(EV_CMD_QUEUE_OPS, 2, EVSUBCMD_SENQUEUE, (slot)), +#define EvtEnqueueFormSlot1 _EvtArg0(EV_CMD_QUEUE_OPS, 2, EVSUBCMD_SENQUEUE_S1, 0), +#define EvtDequeueToSlot(slot) _EvtArg0(EV_CMD_QUEUE_OPS, 2, EVSUBCMD_SDEQUEUE, (slot)), #define EvtLabel(label) _EvtAutoCmdLen2(EV_CMD_LABEL), #define EvtCall(scr) _EvtAutoCmdLen4(EV_CMD_CALL), (EventListScr)(scr), #define EvtBNE(label, s1, s2) _EvtArg0(EV_CMD_BRANCH, 4, EVSUBCMD_BNE, (label)), _EvtParams2((s1), (s2)), @@ -219,21 +244,43 @@ enum event_sub_cmd_idx { #define EvtSleepWithCancel(time) _EvtArg0(EV_CMD_STALL, 2, EVSUBCMD_STAL1, (time)), #define EvtSleepWithGameCtrl(time) _EvtArg0(EV_CMD_STALL, 2, EVSUBCMD_STAL2, (time)), #define EvtSleepWithCancelGameCtrl(time) _EvtArg0(EV_CMD_STALL, 2, EVSUBCMD_STAL3, (time)), +#define EvtStartBgm(bgm) _EvtArg0(EV_CMD_BGMCHANGE_12, 2, 0, (bgm)), +#define EvtBgmFadeInFast(bgm) _EvtArg0(EV_CMD_BGMCHANGE_13, 2, EVSUBCMD_MUSCFAST, (bgm)), +#define EvtBgmFadeInMiddleSpeed(bgm) _EvtArg0(EV_CMD_BGMCHANGE_13, 2, EVSUBCMD_MUSCMID, (bgm)), +#define EvtBgmFadeInSlowly(bgm) _EvtArg0(EV_CMD_BGMCHANGE_13, 2, EVSUBCMD_MUSCSLOW, (bgm)), #define EvtSetVolumeDown _EvtArg0(EV_CMD_BGMVOLUMECHANGE, 2, EVSUBCMD_MUSI, 0), #define EvtUnsetVolumeDown _EvtArg0(EV_CMD_BGMVOLUMECHANGE, 2, EVSUBCMD_MUNO, 0), +#define EvtFadeOutBlack(speed) _EvtArg0(EV_CMD_FADE, 2, EVSUBCMD_FADU, (speed)), +#define EvtFadeInBlack(speed) _EvtArg0(EV_CMD_FADE, 2, EVSUBCMD_FADI, (speed)), +#define EvtFadeOutWhite(speed) _EvtArg0(EV_CMD_FADE, 2, EVSUBCMD_FAWU, (speed)), +#define EvtFadeInWhite(speed) _EvtArg0(EV_CMD_FADE, 2, EVSUBCMD_FAWI, (speed)), #define EvtCheckTutorial _EvtArg0(EV_CMD_CHECKVARIOUS, 2, EVSUBCMD_CHECK_TUTORIAL, 0), #define EvtTextStart _EvtArg0(EV_CMD_SETTEXTTYPE, 2, EVSUBCMD_TEXTSTART, 0), #define EvtTextShow(msg) _EvtArg0(EV_CMD_DISPLAYTEXT, 2, EVSUBCMD_TEXTSHOW, (msg)), #define EvtTextRemoveAll _EvtArg0(EV_CMD_DISPLAYTEXT, 2, EVSUBCMD_REMA, 0), #define EvtTextEnd _EvtAutoCmdLen2(EV_CMD_ENDTEXT), +#define EvtLoadMap(chapter) _EvtArg0(EV_CMD_LOMA, 2, 0, (chapter)), +#define EvtMoveCameraTo(x, y) _EvtArg0(EV_CMD_CAMERACONTROL, 2, 0, ((((y) & 0xFF) << 8) + ((x) & 0xFF))), #define EvtLoadUnit1(restriction, units) _EvtArg0(EV_CMD_LOADUNIT, 4, EVSUBCMD_LOAD1, (restriction)), (EventListScr)(units), +#define EvtLoadUnit2(restriction, units) _EvtArg0(EV_CMD_LOADUNIT, 4, EVSUBCMD_LOAD2, (restriction)), (EventListScr)(units), #define EvtMoveUnit(speed, pid, x, y) _EvtArg0(EV_CMD_MOVEUNIT, 4, EVSUBCMD_MOVE, (speed)), _EvtParams4(pid, 0, (x), (y)), +#define EvtMoveUnitToTarget(speed, pid, pid_target) _EvtArg0(EV_CMD_MOVEUNIT, 4, EVSUBCMD_MOVEONTO, (speed)), _EvtParams2((pid), (pid_target)), +#define EvtMoveUnitOneStpe(speed, pid, direction) _EvtArg0(EV_CMD_MOVEUNIT, 4, EVSUBCMD_MOVE_1STEP, (speed)), _EvtParams2((pid), (direction)), +#define EvtMoveUnitByQueue(pid) _EvtArg0(EV_CMD_MOVEUNIT, 4, EVSUBCMD_MOVEFORCED, 0), _EvtParams2((pid), 0), #define EvtMoveUnitToValidTerrain(speed, pid, x, y) _EvtArg0(EV_CMD_MOVEUNIT, 4, EVSUBCMD_MOVE_TO_CLOSE_IF_TERRAIN, (speed)), _EvtParams4(pid, 0, (x), (y)), #define EvtWaitUnitMoving _EvtAutoCmdLen2(EV_CMD_ENUN), #define EvtSetHpFormSlot1(pid) _EvtArg0(EV_CMD_CHANGESTATE, 2, EVSUBCMD_SET_HP, (pid)), +#define EvtHideAllAlliess _EvtArg0(EV_CMD_CHANGESTATE, 2, EVSUBCMD_CLEA, 0), +#define EvtRemoveAllNpcs _EvtArg0(EV_CMD_CHANGESTATE, 2, EVSUBCMD_CLEN, 0), +#define EvtRemoveAllEimies _EvtArg0(EV_CMD_CHANGESTATE, 2, EVSUBCMD_CLEE, 0), +#define EvtRemoveUnit(pid) _EvtArg0(EV_CMD_CHANGESTATE, 2, EVSUBCMD_DISA, (pid)), +#define EvtDisplayPopupSilently(msg, x, y) _EvtArg0(EV_CMD_DISPLAYPOPUP, 4, EVSUBCMD_BROWNTEXTBOX, (msg)), _EvtParams2((x), (y)), #define EvtDisplayCursorAtUnit(pid) _EvtArg0(EV_CMD_DISPLAYCURSOR, 2, EVSUBCMD_CURSOR_UNIT, (pid)), #define EvtEndCursor _EvtArg0(EV_CMD_DISPLAYCURSOR, 2, EVSUBCMD_CURE, 0), #define EvtDisplayFlashingCursorAtUnit(pid) _EvtArg0(EV_CMD_DISPLAYCURSOR, 2, EVSUBCMD_CURSOR_FLASHING_UNIT, (pid)), +#define EvtStartEventBattle(actor, target, weapon, ballista) _EvtArg0(EV_CMD_SCRIPT_BATTLE, 4, EVSUBCMD_FIGHT, (actor)), _EvtParams4((target), 0, (weapon), (ballista)), +#define EvtStartEventMapBattle(actor, target, weapon, ballista) _EvtArg0(EV_CMD_SCRIPT_BATTLE, 4, EVSUBCMD_FIGHT_MAP, (actor)), _EvtParams4((target), 0, (weapon), (ballista)), +#define EvtStartScriptedBattle(actor, target, weapon, ballista) _EvtArg0(EV_CMD_SCRIPT_BATTLE, 4, EVSUBCMD_FIGHT_SCRIPT, (actor)), _EvtParams4((target), 0, (weapon), (ballista)), enum event_trigger_types { EVT_LIST_CMD_END, diff --git a/include/types.h b/include/types.h index fac7f951..fde118a2 100644 --- a/include/types.h +++ b/include/types.h @@ -257,41 +257,6 @@ struct MsgBuffer u8 buffer5[0x100]; }; -struct ActionData -{ - // unknown stuff (sometimes RNs are pushed here) (maybe an union?) - /* 00 */ u16 _u00[3]; - /* 06 */ u16 item; - - /* 08 */ u16 unk08; - /* 0A */ u16 unk0A; - - /* 0C */ u8 subjectIndex; - /* 0D */ u8 targetIndex; - - /* 0E */ u8 xMove; - /* 0F */ u8 yMove; - - /* 10 */ u8 moveCount; - - /* 11 */ u8 unitActionType; - - // maybe from this onwards it's an union? - - /* 12 */ u8 itemSlotIndex; - - /* 13 */ u8 xOther; - /* 14 */ u8 yOther; - - /* 15 */ u8 trapType; - - /* 16 */ u8 suspendPointType; - - /* 18 */ struct BattleHit* scriptedBattleHits; - - /* 1C */ u8 _pad_1C[0x38 - 0x1C]; -}; - enum { FACING_LEFT = 0, diff --git a/include/variables.h b/include/variables.h index 7b30f889..6498640a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -89,13 +89,12 @@ extern struct BmSt gBmSt; extern struct PlaySt gPlaySt; extern u8 gActiveUnitId; extern struct Vec2 gActiveUnitMoveOrigin; -extern u8 gWorkingMovementScript[]; +extern u8 gWorkingMovementScript[0x40]; extern u16 gConvoyItemArray[]; extern struct Unit* sUnitStackBase; extern struct Unit* sUnitStackTop; extern u8 sUnitStackSize; -extern struct ActionData gActionData; -// extern ??? gUnknown_0203A974 + // extern ??? gUnknown_0203AA7F // extern ??? gUnknown_0203AA80 // extern ??? gUnknown_0203AA8A @@ -586,7 +585,6 @@ extern u16 CONST_DATA obj_0859AEC8[]; // extern ??? gUnknown_0859BD40 extern struct ProcCmd CONST_DATA gProcScr_UpdateTraps[]; // extern ??? gProc_MapTask -// extern ??? gUnknown_0859DBA0 extern u16 gGfx_MiscUiGraphics[]; extern u16 gPal_MiscUiGraphics[]; extern u8 gImg_UiCursorHandTop[]; diff --git a/ldscript.txt b/ldscript.txt index f39bc09a..b6af2503 100644 --- a/ldscript.txt +++ b/ldscript.txt @@ -603,7 +603,7 @@ SECTIONS . = ALIGN(4); src/bmio.o(.data); . = ALIGN(4); src/bmarena.o(.data); . = ALIGN(4); src/bmmind.o(.data); - . = ALIGN(4); data/data_59DB6C.o(.data); + . = ALIGN(4); src/bmpatharrowdisp.o(.data); . = ALIGN(4); src/prep_sallycursor.o(.data); . = ALIGN(4); src/unitinfowindow.o(.data); . = ALIGN(4); src/bb.o(.data); diff --git a/src/bm.c b/src/bm.c index 33d2c442..24069a58 100644 --- a/src/bm.c +++ b/src/bm.c @@ -10,7 +10,7 @@ #include "bmudisp.h" #include "playerphase.h" #include "cp_common.h" - +#include "bmmind.h" #include "bmtrick.h" #include "bmio.h" #include "fontgrp.h" diff --git a/src/bmarena.c b/src/bmarena.c index 8fcc85d3..232523ca 100644 --- a/src/bmarena.c +++ b/src/bmarena.c @@ -6,6 +6,7 @@ #include "bmbattle.h" #include "bmsave.h" #include "bmarena.h" +#include "bmmind.h" #include "constants/characters.h" #include "constants/classes.h" diff --git a/src/bmbattle.c b/src/bmbattle.c index 793a9376..9aaec647 100644 --- a/src/bmbattle.c +++ b/src/bmbattle.c @@ -9,6 +9,7 @@ #include "bmitem.h" #include "bmunit.h" #include "bmmap.h" +#include "bmmind.h" #include "bmreliance.h" #include "chapterdata.h" #include "bmtrick.h" diff --git a/src/bmidoten.c b/src/bmidoten.c index 09f15095..df6ca9af 100644 --- a/src/bmidoten.c +++ b/src/bmidoten.c @@ -10,6 +10,7 @@ #include "proc.h" #include "rng.h" #include "bmarch.h" +#include "bmmind.h" #include "bmidoten.h" diff --git a/src/bmio.c b/src/bmio.c index 44dc73ca..f9890a1b 100644 --- a/src/bmio.c +++ b/src/bmio.c @@ -26,6 +26,7 @@ #include "bmlib.h" #include "worldmap.h" #include "bmio.h" +#include "bmmind.h" // General Battle Map System Stuff, mostly low level hardware stuff but also more diff --git a/src/bmitemuse.c b/src/bmitemuse.c index fc6cd677..928b6ddf 100644 --- a/src/bmitemuse.c +++ b/src/bmitemuse.c @@ -25,7 +25,7 @@ #include "bmmenu.h" #include "menu_def.h" #include "menuitempanel.h" - +#include "bmmind.h" #include "constants/characters.h" #include "constants/items.h" #include "constants/terrains.h" diff --git a/src/bmmap.c b/src/bmmap.c index 57fdc443..8f07ab91 100644 --- a/src/bmmap.c +++ b/src/bmmap.c @@ -45,6 +45,7 @@ EWRAM_DATA static u8 sBmMapOtherPool[MAP_POOL_SIZE] = {}; EWRAM_DATA static u16 sTilesetConfig[0x1000 + 0x200] = {}; EWRAM_DATA static u16 sBmBaseTilesPool[MAP_POOL_SIZE] = {}; +EWRAM_DATA u8 gWorkingMovementScript[0x40] = {}; static u8** sInitializingMap; diff --git a/src/bmmenu.c b/src/bmmenu.c index c1886295..d808f548 100644 --- a/src/bmmenu.c +++ b/src/bmmenu.c @@ -40,7 +40,7 @@ #include "prepscreen.h" #include "bmguide.h" #include "menuitempanel.h" - +#include "bmmind.h" #include "constants/characters.h" #include "constants/classes.h" #include "constants/terrains.h" diff --git a/src/bmmind.c b/src/bmmind.c index 8c719a47..5e76adb3 100644 --- a/src/bmmind.c +++ b/src/bmmind.c @@ -28,6 +28,8 @@ #include "constants/items.h" #include "constants/terrains.h" +EWRAM_DATA struct ActionData gActionData = { 0 }; + struct ProcCmd CONST_DATA sProcScr_AfterDropAction[] = { PROC_SLEEP(0), @@ -684,10 +686,8 @@ void BATTLE_HandleArenaDeathsMaybe(ProcPtr proc) { return; } -extern u8 gUnknown_0203A974[]; - -//! FE8U = 0x080329C0 -u8* sub_80329C0(u8* r0) { - CpuFastCopy(r0, gUnknown_0203A974, 0x1C); - return gUnknown_0203A974; +struct BattleHit * sub_80329C0(struct BattleHit * r0) +{ + CpuFastCopy(r0, gActionData.script_hits, 0x1C); + return gActionData.script_hits; } diff --git a/src/bmpatharrowdisp.c b/src/bmpatharrowdisp.c index 7fbf7f61..3b491397 100644 --- a/src/bmpatharrowdisp.c +++ b/src/bmpatharrowdisp.c @@ -8,48 +8,61 @@ #include "hardware.h" #include "mu.h" #include "bmlib.h" +#include "bmmind.h" #include "variables.h" +EWRAM_DATA struct PathArrowProc gPathArrowProc = { 0 }; + +CONST_DATA u16 gPathArrowOAMTable[5][5] = { + {0x3AF0, 0x3B04, 0x3B06, 0x3B00, 0x3B02}, + {0x3AF0, 0x3AF0, 0x3AF8, 0x3B0C, 0x3AFC}, + {0x3AF2, 0x3AF8, 0x3AF2, 0x3AFA, 0x3B08}, + {0x3AF4, 0x3B0E, 0x3AFA, 0x3AF4, 0x3AFE}, + {0x3AF6, 0x3AFC, 0x3B0A, 0x3AFE, 0x3AF6}, +}; + +CONST_DATA struct PathArrowProc * gpPathArrowProc = &gPathArrowProc; + void SetLastCoords(u16 x, u16 y) { - gUnknown_0859DBA0.proc->lastX = x; - gUnknown_0859DBA0.proc->lastY = y; + gpPathArrowProc->lastX = x; + gpPathArrowProc->lastY = y; } #define TERRAIN_AT(x, y) gBmMapTerrain[y][x] // I could only get a match by inlining the whole loop body into one gross line. void CutOffPathLength(s8 newIndex) { - if (gUnknown_0859DBA0.proc->pathLen >= newIndex) { + if (gpPathArrowProc->pathLen >= newIndex) { s8 i; - gUnknown_0859DBA0.proc->pathLen = newIndex - 1; - gUnknown_0859DBA0.proc->pathCosts[gUnknown_0859DBA0.proc->pathLen] = - gUnknown_0859DBA0.proc->maxMov; - for (i = 1; i <= gUnknown_0859DBA0.proc->pathLen; i++) { + gpPathArrowProc->pathLen = newIndex - 1; + gpPathArrowProc->pathCosts[gpPathArrowProc->pathLen] = + gpPathArrowProc->maxMov; + for (i = 1; i <= gpPathArrowProc->pathLen; i++) { u8 *costs = GetWorkingMoveCosts(); - gUnknown_0859DBA0.proc->pathCosts[i] = - gUnknown_0859DBA0.proc->pathCosts[i - 1] - + gpPathArrowProc->pathCosts[i] = + gpPathArrowProc->pathCosts[i - 1] - costs[TERRAIN_AT( - gUnknown_0859DBA0.proc->pathX[i], - gUnknown_0859DBA0.proc->pathY[i])]; + gpPathArrowProc->pathX[i], + gpPathArrowProc->pathY[i])]; } } } void AddPointToPathArrowProc(s8 x, s8 y) { u8 * costs; - gUnknown_0859DBA0.proc->pathLen++; - gUnknown_0859DBA0.proc->pathX[gUnknown_0859DBA0.proc->pathLen] = x; - gUnknown_0859DBA0.proc->pathY[gUnknown_0859DBA0.proc->pathLen] = y; + gpPathArrowProc->pathLen++; + gpPathArrowProc->pathX[gpPathArrowProc->pathLen] = x; + gpPathArrowProc->pathY[gpPathArrowProc->pathLen] = y; costs = GetWorkingMoveCosts(); - gUnknown_0859DBA0.proc->pathCosts[gUnknown_0859DBA0.proc->pathLen] = - gUnknown_0859DBA0.proc->pathCosts[gUnknown_0859DBA0.proc->pathLen - 1] - + gpPathArrowProc->pathCosts[gpPathArrowProc->pathLen] = + gpPathArrowProc->pathCosts[gpPathArrowProc->pathLen - 1] - costs[gBmMapTerrain[y][x]]; } s32 GetPointAlongPath(s8 x, s8 y) { s8 i; - for (i = 0; i <= gUnknown_0859DBA0.proc->pathLen; i++) { - if (gUnknown_0859DBA0.proc->pathX[i] == x && gUnknown_0859DBA0.proc->pathY[i] == y) + for (i = 0; i <= gpPathArrowProc->pathLen; i++) { + if (gpPathArrowProc->pathX[i] == x && gpPathArrowProc->pathY[i] == y) return i; } return -1; @@ -77,23 +90,23 @@ void GetPathFromMovementScript(void) { continue; case MU_COMMAND_MOVE_LEFT + 1: AddPointToPathArrowProc( - gUnknown_0859DBA0.proc->pathX[gUnknown_0859DBA0.proc->pathLen] - 1, - gUnknown_0859DBA0.proc->pathY[gUnknown_0859DBA0.proc->pathLen]); + gpPathArrowProc->pathX[gpPathArrowProc->pathLen] - 1, + gpPathArrowProc->pathY[gpPathArrowProc->pathLen]); break; case MU_COMMAND_MOVE_RIGHT + 1: AddPointToPathArrowProc( - gUnknown_0859DBA0.proc->pathX[gUnknown_0859DBA0.proc->pathLen] + 1, - gUnknown_0859DBA0.proc->pathY[gUnknown_0859DBA0.proc->pathLen]); + gpPathArrowProc->pathX[gpPathArrowProc->pathLen] + 1, + gpPathArrowProc->pathY[gpPathArrowProc->pathLen]); break; case MU_COMMAND_MOVE_UP + 1: AddPointToPathArrowProc( - gUnknown_0859DBA0.proc->pathX[gUnknown_0859DBA0.proc->pathLen], - gUnknown_0859DBA0.proc->pathY[gUnknown_0859DBA0.proc->pathLen] - 1); + gpPathArrowProc->pathX[gpPathArrowProc->pathLen], + gpPathArrowProc->pathY[gpPathArrowProc->pathLen] - 1); break; case MU_COMMAND_MOVE_DOWN + 1: AddPointToPathArrowProc( - gUnknown_0859DBA0.proc->pathX[gUnknown_0859DBA0.proc->pathLen], - gUnknown_0859DBA0.proc->pathY[gUnknown_0859DBA0.proc->pathLen] + 1); + gpPathArrowProc->pathX[gpPathArrowProc->pathLen], + gpPathArrowProc->pathY[gpPathArrowProc->pathLen] + 1); break; } } @@ -102,15 +115,15 @@ void GetPathFromMovementScript(void) { void GetMovementScriptFromPath(void) { s8 i; - for (i = 1; i <= gUnknown_0859DBA0.proc->pathLen; i++) + for (i = 1; i <= gpPathArrowProc->pathLen; i++) { s8 x, y; s8 newX, newY; u8 result; - newX = gUnknown_0859DBA0.proc->pathX[i]; - x = gUnknown_0859DBA0.proc->pathX[i - 1]; + newX = gpPathArrowProc->pathX[i]; + x = gpPathArrowProc->pathX[i - 1]; if (newX < x) { gWorkingMovementScript[i - 1] = MU_COMMAND_MOVE_LEFT; } @@ -118,7 +131,7 @@ void GetMovementScriptFromPath(void) { gWorkingMovementScript[i - 1] = MU_COMMAND_MOVE_RIGHT; } - else if (gUnknown_0859DBA0.proc->pathY[i] < gUnknown_0859DBA0.proc->pathY[i - 1]) { + else if (gpPathArrowProc->pathY[i] < gpPathArrowProc->pathY[i - 1]) { gWorkingMovementScript[i - 1] = MU_COMMAND_MOVE_UP; } else { @@ -131,9 +144,9 @@ void GetMovementScriptFromPath(void) { void GenerateMovementMapForActiveUnit(void) { GenerateMovementMapOnWorkingMap( gActiveUnit, - gUnknown_0859DBA0.proc->pathX[gUnknown_0859DBA0.proc->pathLen], - gUnknown_0859DBA0.proc->pathY[gUnknown_0859DBA0.proc->pathLen], - gUnknown_0859DBA0.proc->pathCosts[gUnknown_0859DBA0.proc->pathLen]); + gpPathArrowProc->pathX[gpPathArrowProc->pathLen], + gpPathArrowProc->pathY[gpPathArrowProc->pathLen], + gpPathArrowProc->pathCosts[gpPathArrowProc->pathLen]); } void ResetPathArrow(void) { @@ -148,10 +161,10 @@ void ResetPathArrow(void) { bool8 PathContainsNoCycle(void) { s8 i, j; - for (i = gUnknown_0859DBA0.proc->pathLen; i > 0; --i) { + for (i = gpPathArrowProc->pathLen; i > 0; --i) { for (j = i - 1; j >= 0; --j) { - if (gUnknown_0859DBA0.proc->pathX[i] == gUnknown_0859DBA0.proc->pathX[j] && - gUnknown_0859DBA0.proc->pathY[i] == gUnknown_0859DBA0.proc->pathY[j]) + if (gpPathArrowProc->pathX[i] == gpPathArrowProc->pathX[j] && + gpPathArrowProc->pathY[i] == gpPathArrowProc->pathY[j]) { return 0; } @@ -165,11 +178,11 @@ void PathArrowDisp_Init(u8 a) { Decompress(gUnknown_08A03054, (void *) OBJ_VRAM0 + 0x5E00); ApplyPalette(gUnknown_08A0328C, 0x13); if (a == 0) { - gUnknown_0859DBA0.proc->maxMov = + gpPathArrowProc->maxMov = gActiveUnit->movBonus + gActiveUnit->pClassData->baseMov - gActionData.moveCount; CutOffPathLength(0); AddPointToPathArrowProc(gActiveUnit->xPos, gActiveUnit->yPos); - gUnknown_0859DBA0.proc->pathCosts[0] = gUnknown_0859DBA0.proc->maxMov; + gpPathArrowProc->pathCosts[0] = gpPathArrowProc->maxMov; // This seems strange. But passing -1 to a signed argument doesn't seem to match SetLastCoords(0xFFFF, 0xFFFF); UpdatePathArrowWithCursor(); @@ -184,8 +197,8 @@ static inline u8 GetTerrainAtCursor() { return TERRAIN_AT(gBmSt.playerCursor.x, gBmSt.playerCursor.y); } -#define LAST_X_POINT gUnknown_0859DBA0.proc->pathX[gUnknown_0859DBA0.proc->pathLen] -#define LAST_Y_POINT gUnknown_0859DBA0.proc->pathY[gUnknown_0859DBA0.proc->pathLen] +#define LAST_X_POINT gpPathArrowProc->pathX[gpPathArrowProc->pathLen] +#define LAST_Y_POINT gpPathArrowProc->pathY[gpPathArrowProc->pathLen] #define abs(n) (((n) >= 0) ? (n) : -(n)) @@ -193,8 +206,8 @@ void UpdatePathArrowWithCursor(void) { s8 point; s32 pointAlias; - if (gUnknown_0859DBA0.proc->lastX == gBmSt.playerCursor.x && - gUnknown_0859DBA0.proc->lastY == gBmSt.playerCursor.y) + if (gpPathArrowProc->lastX == gBmSt.playerCursor.x && + gpPathArrowProc->lastY == gBmSt.playerCursor.y) { return; } @@ -209,7 +222,7 @@ void UpdatePathArrowWithCursor(void) { CutOffPathLength(point); return; } - if (gUnknown_0859DBA0.proc->pathCosts[gUnknown_0859DBA0.proc->pathLen] >= + if (gpPathArrowProc->pathCosts[gpPathArrowProc->pathLen] >= GetWorkingMoveCosts()[GetTerrainAtCursor()]) { if (abs(LAST_X_POINT - gBmSt.playerCursor.x) + @@ -220,7 +233,7 @@ void UpdatePathArrowWithCursor(void) { return; } } - if (gUnknown_0859DBA0.proc->pathCosts[gUnknown_0859DBA0.proc->pathLen] == 0) + if (gpPathArrowProc->pathCosts[gpPathArrowProc->pathLen] == 0) CutOffPathLength(1); SetWorkingBmMap(gBmMapOther); GenerateMovementMapForActiveUnit(); @@ -240,26 +253,26 @@ void UpdatePathArrowWithCursor(void) { u8 GetDirectionOfPathBeforeIndex(u8 i) { if (i == 0) return 0; - if (gUnknown_0859DBA0.proc->pathX[i - 1] < gUnknown_0859DBA0.proc->pathX[i]) + if (gpPathArrowProc->pathX[i - 1] < gpPathArrowProc->pathX[i]) return 3; - if (gUnknown_0859DBA0.proc->pathX[i - 1] > gUnknown_0859DBA0.proc->pathX[i]) + if (gpPathArrowProc->pathX[i - 1] > gpPathArrowProc->pathX[i]) return 1; - if (gUnknown_0859DBA0.proc->pathY[i - 1] < gUnknown_0859DBA0.proc->pathY[i]) + if (gpPathArrowProc->pathY[i - 1] < gpPathArrowProc->pathY[i]) return 4; - if (gUnknown_0859DBA0.proc->pathY[i - 1] > gUnknown_0859DBA0.proc->pathY[i]) + if (gpPathArrowProc->pathY[i - 1] > gpPathArrowProc->pathY[i]) return 2; } u8 GetDirectionOfPathAfterIndex(u8 i) { - if (i == gUnknown_0859DBA0.proc->pathLen) + if (i == gpPathArrowProc->pathLen) return 0; - if (gUnknown_0859DBA0.proc->pathX[i] < gUnknown_0859DBA0.proc->pathX[i + 1]) + if (gpPathArrowProc->pathX[i] < gpPathArrowProc->pathX[i + 1]) return 1; - if (gUnknown_0859DBA0.proc->pathX[i] > gUnknown_0859DBA0.proc->pathX[i + 1]) + if (gpPathArrowProc->pathX[i] > gpPathArrowProc->pathX[i + 1]) return 3; - if (gUnknown_0859DBA0.proc->pathY[i] < gUnknown_0859DBA0.proc->pathY[i + 1]) + if (gpPathArrowProc->pathY[i] < gpPathArrowProc->pathY[i + 1]) return 2; - if (gUnknown_0859DBA0.proc->pathY[i] > gUnknown_0859DBA0.proc->pathY[i + 1]) + if (gpPathArrowProc->pathY[i] > gpPathArrowProc->pathY[i + 1]) return 4; } @@ -278,11 +291,11 @@ u8 PointInCameraBounds(s16 x, s16 y, u8 xBound, u8 yBound) { void DrawPathArrow(void) { s8 i; - if (gUnknown_0859DBA0.proc->pathLen == 0) + if (gpPathArrowProc->pathLen == 0) return; - for (i = gUnknown_0859DBA0.proc->pathLen; i >= 0; i--) { - s16 xp = 16 * gUnknown_0859DBA0.proc->pathX[i]; - s16 yp = 16 * gUnknown_0859DBA0.proc->pathY[i]; + for (i = gpPathArrowProc->pathLen; i >= 0; i--) { + s16 xp = 16 * gpPathArrowProc->pathX[i]; + s16 yp = 16 * gpPathArrowProc->pathY[i]; if (PointInCameraBounds(xp, yp, 16, 16)) { u16 oam2 = PATH_ARROW_OAM_AT( GetDirectionOfPathAfterIndex(i), diff --git a/src/bmshop.c b/src/bmshop.c index 62ed58d2..2dd409b3 100644 --- a/src/bmshop.c +++ b/src/bmshop.c @@ -16,6 +16,7 @@ #include "bmio.h" #include "face.h" #include "bm.h" +#include "bmmind.h" #include "scene.h" #include "prepscreen.h" #include "bmshop.h" diff --git a/src/bmtrade.c b/src/bmtrade.c index b30757bf..3734fadd 100644 --- a/src/bmtrade.c +++ b/src/bmtrade.c @@ -14,7 +14,7 @@ #include "bmitem.h" #include "bmtrade.h" #include "bmunit.h" - +#include "bmmind.h" #include "m4a.h" #include "soundwrapper.h" #include "event.h" diff --git a/src/bmtrap.c b/src/bmtrap.c index b424b93b..ca7d8c38 100644 --- a/src/bmtrap.c +++ b/src/bmtrap.c @@ -18,7 +18,7 @@ #include "bmudisp.h" #include "bmsave.h" #include "eventinfo.h" - +#include "bmmind.h" #include "bmtrap.h" // trapfx.s diff --git a/src/bmunit.c b/src/bmunit.c index b279b1bb..148f0638 100644 --- a/src/bmunit.c +++ b/src/bmunit.c @@ -22,6 +22,7 @@ #include "bmudisp.h" #include "bmsave.h" #include "muctrl.h" +#include "bmmind.h" #include "eventcall.h" EWRAM_DATA u8 gActiveUnitId = 0; diff --git a/src/bmusemind.c b/src/bmusemind.c index 8388161b..c3ef4380 100644 --- a/src/bmusemind.c +++ b/src/bmusemind.c @@ -22,7 +22,7 @@ #include "bmudisp.h" #include "classchg.h" #include "eventinfo.h" - +#include "bmmind.h" #include "bmusemind.h" s8 CanUnitCrossTerrain(struct Unit* unit, int terrain); diff --git a/src/classchg-handler.c b/src/classchg-handler.c index f2c26558..5fa4a742 100644 --- a/src/classchg-handler.c +++ b/src/classchg-handler.c @@ -5,6 +5,7 @@ #include "constants/classes.h" #include "bmio.h" #include "bmmap.h" +#include "bmmind.h" #include "bmitem.h" #include "mu.h" diff --git a/src/classchg-sel.c b/src/classchg-sel.c index 7c669667..1bee5df1 100644 --- a/src/classchg-sel.c +++ b/src/classchg-sel.c @@ -14,6 +14,7 @@ #include "efxbattle.h" #include "bmsave.h" #include "bm.h" +#include "bmmind.h" #include "bmio.h" #include "bmmap.h" #include "mu.h" diff --git a/src/convoymenu.c b/src/convoymenu.c index 78cbedfb..702f0fe1 100755 --- a/src/convoymenu.c +++ b/src/convoymenu.c @@ -11,6 +11,7 @@ #include "bmmenu.h" #include "bmitem.h" #include "hardware.h" +#include "bmmind.h" #include "popup.h" #include "face.h" #include "scene.h" diff --git a/src/cp_decide.c b/src/cp_decide.c index d9f85385..9351c085 100644 --- a/src/cp_decide.c +++ b/src/cp_decide.c @@ -10,7 +10,7 @@ #include "cp_utility.h" #include "cp_script.h" #include "bmsave.h" - +#include "bmmind.h" #include "constants/classes.h" #include "cp_common.h" diff --git a/src/danceringfx.c b/src/danceringfx.c index 389c71fe..65a8e051 100644 --- a/src/danceringfx.c +++ b/src/danceringfx.c @@ -7,6 +7,7 @@ #include "bmunit.h" #include "bmbattle.h" #include "bmfx.h" +#include "bmmind.h" #include "bmlib.h" /** diff --git a/src/eventcall.c b/src/eventcall.c index d0323b0f..e5ec0f68 100644 --- a/src/eventcall.c +++ b/src/eventcall.c @@ -26,6 +26,7 @@ #include "ctc.h" #include "fontgrp.h" #include "uimenu.h" +#include "bmmind.h" #include "uiutils.h" #include "bmbattle.h" #include "bmitem.h" diff --git a/src/eventinfo.c b/src/eventinfo.c index 68953968..cf43a3d7 100644 --- a/src/eventinfo.c +++ b/src/eventinfo.c @@ -13,7 +13,7 @@ #include "bmshop.h" #include "bmbattle.h" #include "worldmap.h" - +#include "bmmind.h" #include "eventinfo.h" #include "eventscript.h" diff --git a/src/events/prologue-eventinfo.h b/src/events/prologue-eventinfo.h index a640dace..21b63532 100644 --- a/src/events/prologue-eventinfo.h +++ b/src/events/prologue-eventinfo.h @@ -5,7 +5,7 @@ #include "bmunit.h" #include "chapterdata.h" #include "eventinfo.h" -#include "eventscript-stdlib.h" +#include "ea-stdlib.h" #include "constants/event-flags.h" CONST_DATA EventListScr EventListScr_Prologue_Turn[] = { @@ -75,8 +75,8 @@ CONST_DATA struct ChapterEventGroup PrologueEvents = { .traps = TrapData_Event_Prologue, .extraTrapsInHard = TrapData_Event_PrologueHard, - .playerUnitsInNormal = UnitDef_Blue_Prologue, - .playerUnitsInHard = UnitDef_Blue_Prologue, + .playerUnitsInNormal = UnitDef_Event_PrologueAlly, + .playerUnitsInHard = UnitDef_Event_PrologueAlly, .playerUnitsChoice1InEncounter = NULL, .playerUnitsChoice2InEncounter = NULL, diff --git a/src/events/prologue-eventscript.h b/src/events/prologue-eventscript.h index a7dc62fe..3ad104b3 100644 --- a/src/events/prologue-eventscript.h +++ b/src/events/prologue-eventscript.h @@ -5,7 +5,7 @@ #include "bmunit.h" #include "event.h" #include "eventinfo.h" -#include "eventscript-stdlib.h" +#include "ea-stdlib.h" #include "constants/characters.h" CONST_DATA EventListScr EventScr_Prologue_BeginingScene[] = { @@ -18,17 +18,17 @@ CONST_DATA EventListScr EventScr_Prologue_BeginingScene[] = { LABEL(0x0) ENUT(0x8) - LOAD1(1, UnitDef_Blue_Prologue) + LOAD1(1, UnitDef_Event_PrologueAlly) ENUN SVAL(EVT_SLOT_1, 13) SET_HP(CHARACTER_SETH) - FlashCursorCHAR(CHARACTER_EIRIKA, 60) + FlashCursor(CHARACTER_EIRIKA, 60) MUSI Text_BG(0x1D, 0x90D) MUNO MOVE(0x18, CHARACTER_SETH, 4, 4) ENUN - FlashCursorCHAR(CHARACTER_SETH, 60) + FlashCursor(CHARACTER_SETH, 60) Text(0x90E) SVAL(EVT_SLOT_2, EventScr_Prologue_9EF27C) CALL(EventScr_RunTutIfEasyMode) @@ -39,3 +39,163 @@ LABEL(0x0) NoFade ENDA }; + +CONST_DATA EventListScr EventScr_Prologue_RenaisThroneCutscene[] = { + SVAL(EVT_SLOT_B, 0x000A000E) + LOMA(0x10) /* todo: chapter index */ + LOAD2(1, UnitDef_Event_PrologueThroneRoomUnits) + ENUN + FADU(16) + MUSC(0x26) /* todo: BGM index */ + BROWNBOXTEXT(0x664, 8, 8) + + /* WTF we load Ephraim as the messager... */ + LOAD1(1, UnitDef_Event_PrologueMessager) + ENUN + CAMERA(0xE, 0x0) + FlashCursor(CHARACTER_EPHRAIM, 60) + Text(0x903) + MOVE(0, CHARACTER_EPHRAIM, 0xD, 0xB) + ENUN + DISA(CHARACTER_EPHRAIM) + + MOVE_1STEP(0, CHARACTER_EIRIKA, FACING_LEFT) + ENUN + FlashCursor(CHARACTER_EIRIKA, 60) + Text(0x904) + + /* Seth pick Eirika and run */ + MOVEONTO(0, CHARACTER_SETH, CHARACTER_EIRIKA) + ENUN + DISA(CHARACTER_EIRIKA) + FlashCursor(CHARACTER_SETH, 60) + Text(0x905) + MOVE(0, CHARACTER_SETH, 0xD, 0xB) + + /* sD is used as queue length */ + SVAL(EVT_SLOT_D, 0) + SVAL(EVT_SLOT_1, 0x010C) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x0) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x2CC) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x0) + SAVETOQUEUE + MOVEFORCED(CHARACTER_FRANZ) + ENUN + + DISA(CHARACTER_SETH) + DISA(CHARACTER_FRANZ) + + /* generals move in to protect the king */ + MOVE(0, CHARACTER_MOULDER, 11, 4) + MOVE(0, CHARACTER_VANESSA, 15, 4) + ENUN + MOVE_1STEP(0, CHARACTER_MOULDER, FACING_RIGHT) + MOVE_1STEP(0, CHARACTER_VANESSA, FACING_LEFT) + ENUN + + LOAD1(1, UnitDef_Event_PrologueGradoShamans) + ENUN + LOAD1(1, UnitDef_Event_PrologueGradoCavalry) + ENUN + LOAD1(1, UnitDef_Event_PrologueGradoRoyals) + ENUN + + FlashCursor(CHARACTER_FADO, 60) + TEXTSTART + TEXTSHOW(0x906) /* Ephraim, Eirika...You must survive. */ + TEXTEND + FADI(2) + REMA + + /* Load to new map */ + EVBIT_F(0x2) + CLEA CLEE CLEN + SVAL(EVT_SLOT_B, 0x00000000) + LOMA(0x40) + FADU(16) + + LOAD2(1, UnitDef_Event_PrologueEscapees) + ENUN + FlashCursor(CHARACTER_SETH, 60) + Text_BG(0x1D, 0x907) + + /* Franz run */ + SVAL(EVT_SLOT_D, 0) + SVAL(EVT_SLOT_1, 0x104) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x0) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x84) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x0) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x80) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x0) + SAVETOQUEUE + MOVEFORCED(CHARACTER_FRANZ) + ENUN + DISA(CHARACTER_FRANZ) + + FlashCursor(CHARACTER_SETH, 60) + Text_BG(0x1D, 0x908) /* behind me */ + + LOAD1(1, UnitDef_Event_PrologueValterGroup) + ENUN + MOVE_1STEP(0, CHARACTER_SETH, FACING_RIGHT) + ENUN + MOVE_1STEP(0, CHARACTER_EIRIKA, FACING_LEFT) + ENUN + + FlashCursor(CHARACTER_VALTER_PROLOGUE, 60) + Text_BG(0x1D, 0x909) + MOVE_1STEP(0, CHARACTER_VALTER_PROLOGUE, FACING_LEFT) + ENUN + + StartBattle + MissedAttack(0, 0) + NormalDamage(1, 0) + EndAttack + FIGHT(CHARACTER_SETH, CHARACTER_VALTER_PROLOGUE, 0, false) + + FlashCursor(CHARACTER_SETH, 60) + Text(0x90B) + + /* Seth 'rescues' Eirika */ + MOVE_1STEP(8, CHARACTER_SETH, FACING_LEFT) + ENUN + DISA(CHARACTER_EIRIKA) + + SVAL(EVT_SLOT_D, 0) + SVAL(EVT_SLOT_1, 0x18104) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x0) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x18084) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x0) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x18080) + SAVETOQUEUE + SVAL(EVT_SLOT_1, 0x0) + SAVETOQUEUE + MOVEFORCED(CHARACTER_SETH) + ENUN + DISA(CHARACTER_SETH) + + FlashCursor(CHARACTER_VALTER_PROLOGUE, 60) + Text(0x90C) + + /* Load to new map */ + FADI(16) + EVBIT_F(0x2) + CLEA CLEE CLEN + SVAL(EVT_SLOT_B, 0x00000000) + LOMA(0x0) + FADU(16) + + ENDA +}; diff --git a/src/events_info.c b/src/events_info.c index 87a284a2..d2230ac9 100644 --- a/src/events_info.c +++ b/src/events_info.c @@ -2,7 +2,7 @@ #include "event.h" #include "eventinfo.h" #include "eventscript.h" -#include "eventscript-stdlib.h" +#include "ea-stdlib.h" #include "chapterdata.h" #include "constants/event-flags.h" #include "bmunit.h" diff --git a/src/events_script.c b/src/events_script.c index 9bf80264..a0c72e5e 100644 --- a/src/events_script.c +++ b/src/events_script.c @@ -2,7 +2,7 @@ #include "event.h" #include "eventinfo.h" #include "eventscript.h" -#include "eventscript-stdlib.h" +#include "ea-stdlib.h" #include "chapterdata.h" #include "constants/event-flags.h" #include "bmunit.h" diff --git a/src/evtscr.c b/src/evtscr.c index b758ce6e..6045e166 100644 --- a/src/evtscr.c +++ b/src/evtscr.c @@ -28,7 +28,7 @@ #include "mapanim.h" #include "worldmap.h" #include "cgtext.h" - +#include "bmmind.h" #include "eventinfo.h" #include "event.h" #include "eventscript.h" @@ -249,23 +249,21 @@ u8 Event07_SlotQueueOperations(struct EventEngineProc * proc) u8 sub_cmd = EVT_SUB_CMD(scr); s16 slot; - switch (sub_cmd) - { - case EVSUBCMD_SENQUEUE: - slot = EVT_CMD_ARGV(scr)[0]; - SlotQueuePush(gEventSlots[slot]); - break; + switch (sub_cmd) { + case EVSUBCMD_SENQUEUE: + slot = EVT_CMD_ARGV(scr)[0]; + SlotQueuePush(gEventSlots[slot]); + break; - case EVSUBCMD_SDEQUEUE_S1: - SlotQueuePush(gEventSlots[0x1]); - break; + case EVSUBCMD_SENQUEUE_S1: + SlotQueuePush(gEventSlots[0x1]); + break; - case EVSUBCMD_SDEQUEUE: - slot = EVT_CMD_ARGV(scr)[0]; - gEventSlots[slot] = SlotQueuePop(); - break; + case EVSUBCMD_SDEQUEUE: + slot = EVT_CMD_ARGV(scr)[0]; + gEventSlots[slot] = SlotQueuePop(); + break; } - return EVC_ADVANCE_CONTINUE; } @@ -588,10 +586,7 @@ u8 Event11_SetIgnoredKeys(struct EventEngineProc * proc) return EVC_ADVANCE_CONTINUE; } -// SOUND EVENT CODES - -//! FE8U = 0x0800DD74 -u8 Event12_(struct EventEngineProc * proc) +u8 Event12_StartBGM(struct EventEngineProc * proc) { s16 evArgument; @@ -607,8 +602,7 @@ u8 Event12_(struct EventEngineProc * proc) return EVC_ADVANCE_YIELD; } -//! FE8U = 0x0800DDB0 -u8 Event13_(struct EventEngineProc * proc) +u8 Event12_BgmFadeIn(struct EventEngineProc * proc) { u8 subcode = EVT_SUB_CMD(proc->pEventCurrent); s16 evArgument = EVT_CMD_ARGV(proc->pEventCurrent)[0]; @@ -711,9 +705,7 @@ u8 Event16_(struct EventEngineProc * proc) return EVC_ADVANCE_CONTINUE; } -// Fade -//! FE8U = 0x0800DF20 -u8 Event17_(struct EventEngineProc * proc) +u8 Event17_Fade(struct EventEngineProc * proc) { u8 subcode; u16 evArgument; @@ -724,43 +716,31 @@ u8 Event17_(struct EventEngineProc * proc) subcode = EVT_SUB_CMD(proc->pEventCurrent); evArgument = EVT_CMD_ARGV(proc->pEventCurrent)[0]; - switch (subcode) - { - case 0: // FADU - StartLockingFadeFromBlack(evArgument, proc); + switch (subcode) { + case 0: // FADU + StartLockingFadeFromBlack(evArgument, proc); + proc->evStateBits &= ~EV_STATE_FADEDIN; + SetDispEnable(TRUE, TRUE, TRUE, TRUE, TRUE); + return EVC_ADVANCE_YIELD; - proc->evStateBits &= ~EV_STATE_FADEDIN; + case 1: // FADI + StartLockingFadeToBlack(evArgument, proc); + proc->evStateBits |= EV_STATE_FADEDIN; + return EVC_ADVANCE_YIELD; - SetDispEnable(TRUE, TRUE, TRUE, TRUE, TRUE); + case 2: // FAWU + StartLockingFadeFromWhite(evArgument, proc); + proc->evStateBits &= ~EV_STATE_FADEDIN; + SetDispEnable(TRUE, TRUE, TRUE, TRUE, TRUE); + return EVC_ADVANCE_YIELD; - return EVC_ADVANCE_YIELD; - - case 1: // FADI - StartLockingFadeToBlack(evArgument, proc); - - proc->evStateBits |= EV_STATE_FADEDIN; - - return EVC_ADVANCE_YIELD; - - case 2: // FAWU - StartLockingFadeFromWhite(evArgument, proc); - - proc->evStateBits &= ~EV_STATE_FADEDIN; - - SetDispEnable(TRUE, TRUE, TRUE, TRUE, TRUE); - - return EVC_ADVANCE_YIELD; - - case 3: // FAWI - StartLockingFadeToWhite(evArgument, proc); - - proc->evStateBits |= EV_STATE_FADEDIN; - - return EVC_ADVANCE_YIELD; - - default: - return EVC_ERROR; + case 3: // FAWI + StartLockingFadeToWhite(evArgument, proc); + proc->evStateBits |= EV_STATE_FADEDIN; + return EVC_ADVANCE_YIELD; + default: + return EVC_ERROR; } // switch (subcode) } @@ -1246,7 +1226,6 @@ void _WhileFace6CExists(struct Proc * proc) Proc_Break(proc); } -// clang-format off struct ProcCmd CONST_DATA gUnknown_08591DE8[] = { @@ -1256,8 +1235,6 @@ struct ProcCmd CONST_DATA gUnknown_08591DE8[] = PROC_END, }; -// clang-format on - //! FE8U = 0x0800E6B4 u8 Event1E_(struct EventEngineProc * proc) { @@ -1469,7 +1446,7 @@ u8 Event21_(struct EventEngineProc * proc) case 4: case 5: if (EVENT_IS_SKIPPING(proc)) - return Event22_(proc); // CLEAN + return Event22_ClearScreen(proc); // CLEAN otherProc = Proc_StartBlocking(gUnknown_08591EB0, proc); otherProc->fadeType = 2; @@ -1737,7 +1714,7 @@ void sub_800EE54(struct ConvoBackgroundFadeProc * proc) sub_800BCDC(proc->pEventEngine->mapSpritePalIdOverride); ForceSyncUnitSpriteSheet(); - Event24_(proc->pEventEngine); + Event24_EnableMapDisp(proc->pEventEngine); break; case 1: @@ -1822,7 +1799,6 @@ void sub_800EF48(struct ConvoBackgroundFadeProc * proc) CpuFastFill(0, (void *)(VRAM + GetBackgroundTileDataOffset(2)), 0x20); } -// clang-format off struct ProcCmd CONST_DATA gUnknown_08591E00[] = { @@ -1843,18 +1819,12 @@ struct ProcCmd CONST_DATA gUnknown_08591E00[] = PROC_END, }; -// clang-format on - -// clang-format off struct ProcCmd CONST_DATA gUnknown_08591E50[] = { PROC_END, }; -// clang-format on - -// clang-format off struct ProcCmd CONST_DATA gUnknown_08591E58[] = { @@ -1877,10 +1847,6 @@ struct ProcCmd CONST_DATA gUnknown_08591E58[] = PROC_END, }; -// clang-format on - -// clang-format off - struct ProcCmd CONST_DATA gUnknown_08591EB0[] = { PROC_YIELD, @@ -1900,10 +1866,7 @@ struct ProcCmd CONST_DATA gUnknown_08591EB0[] = PROC_END, }; -// clang-format on - -//! FE8U = 0x0800F0C8 -u8 Event22_(struct EventEngineProc * proc) +u8 Event22_ClearScreen(struct EventEngineProc * proc) { RefreshBMapGraphics(); sub_800BCDC(proc->mapSpritePalIdOverride); @@ -1921,7 +1884,7 @@ u8 Event22_(struct EventEngineProc * proc) ClearTalkFaceRefs(); - return Event24_(proc); + return Event24_EnableMapDisp(proc); } //! FE8U = 0x0800F124 @@ -1938,7 +1901,7 @@ u8 Event23_DisaleMapDisp(struct EventEngineProc * proc) } //! FE8U = 0x0800F150 -u8 Event24_(struct EventEngineProc * proc) +u8 Event24_EnableMapDisp(struct EventEngineProc * proc) { if (proc->evStateBits & EV_STATE_GFXLOCKED) { @@ -1951,7 +1914,7 @@ u8 Event24_(struct EventEngineProc * proc) } //! FE8U = 0x0800F17C -u8 Event25_(struct EventEngineProc * proc) +u8 Event25_ChangeMap(struct EventEngineProc * proc) { u8 x, y; short chIndex; @@ -1970,7 +1933,7 @@ u8 Event25_(struct EventEngineProc * proc) chIndex = gEventSlots[2]; // ensure gfx are unlocked - Event24_(proc); + Event24_EnableMapDisp(proc); gPlaySt.chapterIndex = chIndex; @@ -1995,43 +1958,36 @@ u8 Event25_(struct EventEngineProc * proc) return EVC_ADVANCE_YIELD; } -//! FE8U = 0x0800F20C -u8 Event26_CameraControlMaybe(struct EventEngineProc * proc) +u8 Event26_CameraControl(struct EventEngineProc * proc) { - s8 x; - s8 y; + s8 x, y; + struct Unit * unit; u8 subcode = EVT_SUB_CMD_LO(proc->pEventCurrent); u8 sc2 = EVT_SUB_CMD_HI(proc->pEventCurrent); - switch (subcode) - { + switch (subcode) { + case 0: // position + x = EVT_CMD_ARGV(proc->pEventCurrent)[0]; + y = EVT_CMD_ARGV(proc->pEventCurrent)[0] >> 8; - case 0: // position - x = EVT_CMD_ARGV(proc->pEventCurrent)[0]; - y = EVT_CMD_ARGV(proc->pEventCurrent)[0] >> 8; - - if (x < 0 || y < 0) - { - x = ((u16 *)(gEventSlots + 0xB))[0]; - y = ((u16 *)(gEventSlots + 0xB))[1]; - } - - break; - - case 1: - { // unit - struct Unit * unit = GetUnitStructFromEventParameter(proc->pEventCurrent[1]); - - if (!unit) - return EVC_ERROR; - - x = unit->xPos; - y = unit->yPos; - - break; + if (x < 0 || y < 0) + { + x = ((u16 *)(gEventSlots + 0xB))[0]; + y = ((u16 *)(gEventSlots + 0xB))[1]; } + break; + + case 1: + unit = GetUnitStructFromEventParameter(proc->pEventCurrent[1]); + if (!unit) + return EVC_ERROR; + + x = unit->xPos; + y = unit->yPos; + + break; } // switch (subcode) if (EVENT_IS_SKIPPING(proc) || (proc->evStateBits & EV_STATE_FADEDIN)) @@ -3795,24 +3751,22 @@ u8 Event3A_DisplayPopup(struct EventEngineProc * proc) textId = gEventSlots[2]; } - switch (subcmd) + switch (subcmd) { + case 0: { - case 0: - { - u16 songId = EVT_CMD_ARGV(proc->pEventCurrent)[1]; - NewPopup_VerySimple(textId, songId, proc); - break; - } - - case 1: - { - s8 x = EVT_CMD_ARGV(proc->pEventCurrent)[2]; - s8 y = EVT_CMD_ARGV(proc->pEventCurrent)[2] >> 8; - StartBrownTextBox(textId, x, y, proc); - break; - } + u16 songId = EVT_CMD_ARGV(proc->pEventCurrent)[1]; + NewPopup_VerySimple(textId, songId, proc); + break; } + case 1: + { + s8 x = EVT_CMD_ARGV(proc->pEventCurrent)[2]; + s8 y = EVT_CMD_ARGV(proc->pEventCurrent)[2] >> 8; + StartBrownTextBox(textId, x, y, proc); + break; + } + } return EVC_ADVANCE_YIELD; } @@ -4019,15 +3973,13 @@ u8 Event3E_PrepScreenCall(struct EventEngineProc * proc) return EVC_ADVANCE_YIELD; } -extern struct BattleHit gUnknown_0203A974[]; - //! FE8U = 0x0801098C struct BattleHit * sub_801098C(void) { u8 i; u32 * queueIt = gEventSlotQueue; - struct BattleHit * bhIt = gUnknown_0203A974; + struct BattleHit * bhIt = gActionData.script_hits; for (i = 0; i < gEventSlots[0xd] && ((u8 *)(queueIt))[0] != 0xff; bhIt++, queueIt++, i++) { @@ -4050,7 +4002,7 @@ struct BattleHit * sub_801098C(void) bhIt->info = BATTLE_HIT_INFO_END; - return gUnknown_0203A974; + return gActionData.script_hits; } //! FE8U = 0x08010A28 @@ -4064,7 +4016,6 @@ void ScriptBattleDeamon(struct ScriptedBattleProc * proc) } } -// clang-format off struct ProcCmd CONST_DATA ProcScr_ScriptBattleDeamon[] = { @@ -4072,10 +4023,8 @@ struct ProcCmd CONST_DATA ProcScr_ScriptBattleDeamon[] = PROC_END, }; -// clang-format on - /* Script battle */ -u8 Event3F_(struct EventEngineProc * proc) +u8 Event3F_ScriptBattle(struct EventEngineProc * proc) { struct BattleHit * hits; struct ScriptedBattleProc * childProc; @@ -4099,43 +4048,42 @@ u8 Event3F_(struct EventEngineProc * proc) hits = sub_801098C(); } - switch (subcmd) - { - case 0: - case 1: - if (charIdA < 0) - { - charIdA = -2; - } + switch (subcmd) { + case EVSUBCMD_FIGHT: + case EVSUBCMD_FIGHT_MAP: + if (charIdA < 0) + { + charIdA = -2; + } - if (charIdB < 0) - { - charIdB = -2; - } + if (charIdB < 0) + { + charIdB = -2; + } - unitA = GetUnitStructFromEventParameter(charIdA); - unitB = GetUnitStructFromEventParameter(charIdB); + unitA = GetUnitStructFromEventParameter(charIdA); + unitB = GetUnitStructFromEventParameter(charIdB); - if (EVENT_IS_SKIPPING(proc) || (proc->evStateBits & EV_STATE_FADEDIN)) - { - scriptted = 0; - } - else - { - scriptted = 1; - childProc = Proc_StartBlocking(ProcScr_ScriptBattleDeamon, proc); - childProc->evtproc = proc; - childProc->lock = GetGameLock(); - Proc_SetMark(proc, PROC_MARK_7); - } + if (EVENT_IS_SKIPPING(proc) || (proc->evStateBits & EV_STATE_FADEDIN)) + { + scriptted = 0; + } + else + { + scriptted = 1; + childProc = Proc_StartBlocking(ProcScr_ScriptBattleDeamon, proc); + childProc->evtproc = proc; + childProc->lock = GetGameLock(); + Proc_SetMark(proc, PROC_MARK_7); + } - StartEventBattle(unitA, unitB, isBallista, scriptted, weaponId, hits, -subcmd || subcmd); + StartEventBattle(unitA, unitB, isBallista, scriptted, weaponId, hits, -subcmd || subcmd); - return EVC_ADVANCE_YIELD; + return EVC_ADVANCE_YIELD; - case 2: - SetScriptedBattle(hits); - return EVC_ADVANCE_CONTINUE; + case EVSUBCMD_FIGHT_SCRIPT: + SetScriptedBattle(hits); + return EVC_ADVANCE_CONTINUE; } return EVC_ERROR; @@ -4165,7 +4113,6 @@ void sub_8010B48(struct Event40Proc * proc) return; } -// clang-format off struct ProcCmd CONST_DATA gUnknown_08591F28[] = { @@ -4173,8 +4120,6 @@ struct ProcCmd CONST_DATA gUnknown_08591F28[] = PROC_END, }; -// clang-format on - //! FE8U = 0x08010B78 u8 Event40_(struct EventEngineProc * proc) { diff --git a/src/evtsub.c b/src/evtsub.c index d8123dbd..e790c493 100644 --- a/src/evtsub.c +++ b/src/evtsub.c @@ -13,6 +13,7 @@ #include "bmudisp.h" #include "bmmap.h" #include "bmitem.h" +#include "bmmind.h" #include "bmbattle.h" #include "mu.h" #include "ekrbattle.h" diff --git a/src/mapanim_summon.c b/src/mapanim_summon.c index 08fe1b62..d6eda926 100644 --- a/src/mapanim_summon.c +++ b/src/mapanim_summon.c @@ -10,6 +10,7 @@ #include "proc.h" #include "soundwrapper.h" #include "rng.h" +#include "bmmind.h" #include "constants/classes.h" #include "constants/characters.h" #include "constants/items.h" diff --git a/src/msg.c b/src/msg.c index 42cbc0fb..e33bdac9 100644 --- a/src/msg.c +++ b/src/msg.c @@ -5,6 +5,7 @@ #include "bmitem.h" #include "bmunit.h" #include "bmlib.h" +#include "bmmind.h" #include "scene.h" EWRAM_DATA struct MsgBuffer sMsgString = {0}; diff --git a/src/prep_itemsupply.c b/src/prep_itemsupply.c index e90df33c..5dcab143 100644 --- a/src/prep_itemsupply.c +++ b/src/prep_itemsupply.c @@ -15,6 +15,7 @@ #include "bmcontainer.h" #include "mu.h" #include "bmudisp.h" +#include "bmmind.h" #include "bmio.h" #include "sysutil.h" #include "constants/faces.h" diff --git a/src/uiarena.c b/src/uiarena.c index 2ef2533f..0ecbdfd7 100644 --- a/src/uiarena.c +++ b/src/uiarena.c @@ -15,6 +15,7 @@ #include "event.h" #include "bm.h" #include "bmio.h" +#include "bmmind.h" #include "bmsave.h" #include "bmlib.h" #include "scene.h" diff --git a/sym_ewram.txt b/sym_ewram.txt index 2cad1969..2ff01c09 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -248,8 +248,7 @@ . = ALIGN(4); src/bm.o(ewram_data); . = ALIGN(4); src/bmunit.o(ewram_data); . = ALIGN(4); src/bmmap.o(ewram_data); -. = 0x033EFC; gWorkingMovementScript = .; -. = 0x033F3C; src/bmtarget.o(ewram_data); +. = ALIGN(4); src/bmtarget.o(ewram_data); . = ALIGN(4); src/bmudisp.o(ewram_data); . = ALIGN(4); src/bmbattle.o(ewram_data); . = ALIGN(4); src/bmtrade.o(ewram_data); @@ -257,9 +256,8 @@ . = ALIGN(4); src/bmcontainer.o(ewram_data); . = ALIGN(4); src/bmusort.o(ewram_data); . = ALIGN(4); src/bmarena.o(ewram_data); -. = 0x03A958; gActionData = .; -. = 0x03A974; gUnknown_0203A974 = .; -. = 0x03A9FC; +. = ALIGN(4); src/bmmind.o(ewram_data); +. = ALIGN(4); src/bmpatharrowdisp.o(ewram_data); . = ALIGN(4); src/unitinfowindow.o(ewram_data); . = 0x03AA04; gAiState = .; . = 0x03AA7F; gUnknown_0203AA7F = .;