From 7002063af6893a1dd425851205455a3f073b1e53 Mon Sep 17 00:00:00 2001 From: MokhaLeee Date: Sat, 9 Dec 2023 06:05:17 +0000 Subject: [PATCH] prologue decomp update to ending scene --- data/data_591AB4.s | 2 +- data/data_591F38.s | 4 +- data/data_8B363C.s | 6 +- data/data_9ED64C.s | 26 +-- data/data_eventscr_9EE0C0.s | 3 + include/constants/event-flags.h | 1 + include/ea-stdlib.h | 29 ++- include/event.h | 5 +- include/eventinfo.h | 3 + include/eventscript.h | 50 ++++- src/events/prologue-eventinfo.h | 2 +- src/events/prologue-eventscript.h | 91 ++++++++ src/evtscr.c | 334 ++++++++++++++---------------- 13 files changed, 349 insertions(+), 207 deletions(-) diff --git a/data/data_591AB4.s b/data/data_591AB4.s index c018ee25..6e8e06ae 100644 --- a/data/data_591AB4.s +++ b/data/data_591AB4.s @@ -59,7 +59,7 @@ gEventLoCmdTable: @ 0x08591B28 .4byte Event0C_Branch, Event0D_AsmCall, Event0E_STAL, Event0F_ .4byte Event10_ModifyEvBit, Event11_SetIgnoredKeys, Event12_StartBGM, Event12_BgmFadeIn .4byte Event14_, Event15_BgmVolume, Event16_, Event17_Fade - .4byte Event18_, Event19_, Event1A_TEXTSTART, Event1B_TEXTSHOW + .4byte Event18_, Event19_Checks, Event1A_TEXTSTART, Event1B_TEXTSHOW .4byte Event1C_TEXTCONT, Event1D_TEXTEND, Event1E_, Event1F_ .4byte Event20_, Event21_, Event22_ClearScreen, Event23_DisaleMapDisp .4byte Event24_EnableMapDisp, Event25_ChangeMap, Event26_CameraControl, Event27_MapChange diff --git a/data/data_591F38.s b/data/data_591F38.s index 6d8addfd..6631abb1 100644 --- a/data/data_591F38.s +++ b/data/data_591F38.s @@ -4,8 +4,8 @@ gUnknown_08591F38: @ 0x08591F38 .incbin "baserom.gba", 0x591F38, 8 - .global gEvent_RemoveBGIfNeeded -gEvent_RemoveBGIfNeeded: + .global EventScr_RemoveBGIfNeeded +EventScr_RemoveBGIfNeeded: .incbin "baserom.gba", 0x591F40, 0x48 .global gEvent_DisplayBattleQuote diff --git a/data/data_8B363C.s b/data/data_8B363C.s index 6d2d24c3..d0b3b36f 100644 --- a/data/data_8B363C.s +++ b/data/data_8B363C.s @@ -309,7 +309,11 @@ gUnknown_088B3AD8: @ 0x088B3AD8 .global UnitDef_Event_PrologueAlly UnitDef_Event_PrologueAlly: - .incbin "baserom.gba", 0x8B3C14, 0x8B3D18 - 0x8B3C14 + .incbin "baserom.gba", 0x8B3C14, 0x8B3C50 - 0x8B3C14 + + .global UnitDef_Event_PrologueEnemy +UnitDef_Event_PrologueEnemy: + .incbin "baserom.gba", 0x8B3C50, 0x8B3D18 - 0x8B3C50 .global UnitDef_Event_PrologueThroneRoomUnits UnitDef_Event_PrologueThroneRoomUnits: diff --git a/data/data_9ED64C.s b/data/data_9ED64C.s index 4b2c6137..1a7c6599 100644 --- a/data/data_9ED64C.s +++ b/data/data_9ED64C.s @@ -1,25 +1,5 @@ .section .data - .global EventScr_Prologue_GiveRapier -EventScr_Prologue_GiveRapier: - .incbin "baserom.gba", 0x9EF060, 0x9EF0A4 - 0x9EF060 - - .global EventScr_Prologue_ONeillSpawn -EventScr_Prologue_ONeillSpawn: - .incbin "baserom.gba", 0x9EF0A4, 0x9EF0D8 - 0x9EF0A4 - - .global EventScr_Prologue_OneEmimyLeft -EventScr_Prologue_OneEmimyLeft: - .incbin "baserom.gba", 0x9EF0D8, 0x9EF12C - 0x9EF0D8 - - .global EventScr_Prologue_ONeillAttack -EventScr_Prologue_ONeillAttack: - .incbin "baserom.gba", 0x9EF12C, 0x9EF164 - 0x9EF12C - - .global EventScr_Prologue_EndingScene -EventScr_Prologue_EndingScene: - .incbin "baserom.gba", 0x9EF164, 0x9EF1BC - 0x9EF164 - .global EventScr_Prologue_9EF1BC EventScr_Prologue_9EF1BC: .incbin "baserom.gba", 0x9EF1BC, 0x9EF214 - 0x9EF1BC @@ -98,7 +78,11 @@ EventScr_Prologue_TutorialD: .global EventScr_Prologue_TutorialE EventScr_Prologue_TutorialE: - .incbin "baserom.gba", 0x9EF7FC, 0x9F36A0 - 0x9EF7FC + .incbin "baserom.gba", 0x9EF7FC, 0x9EF828 - 0x9EF7FC + + .global EventScr_Prologue_9EF828 +EventScr_Prologue_9EF828: + .incbin "baserom.gba", 0x9EF828, 0x9F36A0 - 0x9EF828 .global gUnknown_089F36A0 gUnknown_089F36A0: @ 0x089F36A0 diff --git a/data/data_eventscr_9EE0C0.s b/data/data_eventscr_9EE0C0.s index f707e34a..9ee5ab34 100644 --- a/data/data_eventscr_9EE0C0.s +++ b/data/data_eventscr_9EE0C0.s @@ -140,6 +140,9 @@ EventScr_RunTutIfEasyMode: @ 9EE0C0 .4byte 0x00002220 .4byte 0x00101720 .4byte 0x00000120 + +.global EventScr_SetBackground +EventScr_SetBackground: .4byte 0x00080320 .4byte 0x80d20c41 .4byte 0x0000000c diff --git a/include/constants/event-flags.h b/include/constants/event-flags.h index 9cf1b416..005568ce 100644 --- a/include/constants/event-flags.h +++ b/include/constants/event-flags.h @@ -11,6 +11,7 @@ enum event_flag_idx { /* Flag 7 - 40 is free */ EVFLAG_TMP_7 = 7, + EVFLAG_TMP_8 = 8, EVFLAG_GAMEOVER = 101, EVFLAG_OBJWINDOW_DISABLE = 102, diff --git a/include/ea-stdlib.h b/include/ea-stdlib.h index 4c134dc3..982f64a5 100644 --- a/include/ea-stdlib.h +++ b/include/ea-stdlib.h @@ -12,12 +12,15 @@ #define EVBIT_F EvtClearEvBits #define EVBIT_T EvtSetEvBits #define ENUF EvtClearFlag +#define ENUF_SLOT2 EvtClearFlagAtSlot2 #define ENUT EvtSetFlag #define SVAL EvtSetSlot +#define SADD EvtSlotAdd #define SENQUEUE EvtEnqueueFormSlot #define SENQUEUE1 EvtEnqueueFormSlot1 #define SDEQUEUE EvtDequeueToSlot #define LABEL EvtLabel +#define GOTO EvtGoto #define CALL EvtCall #define BNE EvtBNE #define ASMC EvtAsmCall @@ -35,13 +38,28 @@ #define FADI EvtFadeInBlack #define FAWU EvtFadeOutWhite #define FAWI EvtFadeInWhite -#define CHECK_TUTORIAL EvtCheckTutorial +#define CHECK_MODE EvtGetMode +#define CHECK_CHAPTER_NUMBER EvtGetChapterIndex +#define CHECK_HARD EvtGetIsHard +#define CHECK_TURNS EvtGetCurrentTurn +#define CHECK_ENEMIES EvtGetEnemyAmount +#define CHECK_OTHERS EvtGetNpcAmount +#define CHECK_SKIRMISH EvtGetSkirmishType +#define CHECK_TUTORIAL EvtGetIsTutorial +#define CHECK_MONEY EvtGetMoney +#define CHECK_EVENTID EvtGetTriggeredEid +#define CHECK_POSTGAME EvtGetIsGameCompleted #define TEXTSTART EvtTextStart #define TEXTSHOW EvtTextShow #define REMA EvtTextRemoveAll #define TEXTEND EvtTextEnd #define LOMA EvtLoadMap #define CAMERA EvtMoveCameraTo +#define MNTS EvtBackToTitle +#define MNCH EvtChangeChapterWM +#define MNC2 EvtChangeChapterBM +#define MNC3 EvtChangeChapterNoSave +#define MNC4 EvtMoveToGameEnding #define LOAD1 EvtLoadUnit1 #define LOAD2 EvtLoadUnit2 #define MOVE EvtMoveUnit @@ -55,6 +73,11 @@ #define CLEN EvtRemoveAllNpcs #define CLEE EvtRemoveAllEimies #define DISA EvtRemoveUnit +#define GIVEITEMTO EvtGiveItemAtSlot3 +#define GIVEITEMTOMAIN EvtGiveMoneymAtSlot3 /* what */ +#define GIVETOSLOT3 EvtGiveMoneymAtSlot3NoPopup /* tf */ +#define CHAI EvtChangeAI +#define CHAI_AT EvtChangeAIat #define BROWNBOXTEXT EvtDisplayPopupSilently #define CURSOR_CHAR EvtDisplayCursorAtUnit #define CURSOR_FLASHING_CHAR EvtDisplayFlashingCursorAtUnit @@ -103,6 +126,10 @@ EvtSetSlot(EVT_SLOT_3, (msg)) \ EvtCall(Event_TextWithBG) +#define SetBackground(bg) \ + SVAL(EVT_SLOT_2, bg) \ + CALL(EventScr_SetBackground) + /* Code Ailases */ #define SLOTS_SETFROMQUEUE SDEQUEUE #define SAVETOQUEUE SENQUEUE1 diff --git a/include/event.h b/include/event.h index bfa6fad4..8d93838a 100644 --- a/include/event.h +++ b/include/event.h @@ -4,7 +4,6 @@ #include "global.h" #include "bmunit.h" -struct UnitDefinition; typedef uintptr_t EventListScr; typedef uintptr_t EventScr; @@ -196,7 +195,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 EventScr EventScr_RemoveBGIfNeeded[]; extern const u16 gEvent_DisplayBattleQuote[]; extern const u16 gEvent_TriggerQueuedTileChanges[]; extern const u16 gEvent_OpenChest[]; @@ -374,7 +373,7 @@ void sub_800BCDC(u16); // battle related // ??? Event16_(???); // ??? Event17_Fade(???); // ??? Event18_(???); -// ??? Event19_(???); +// ??? Event19_Checks(???); // ??? Event1A_TEXTSTART(???); // ??? sub_800E210(???); // ??? sub_800E290(???); diff --git a/include/eventinfo.h b/include/eventinfo.h index 913b3b1e..a92a15c6 100644 --- a/include/eventinfo.h +++ b/include/eventinfo.h @@ -222,6 +222,7 @@ extern struct ForceDeploymentEnt gForceDeploymentList[]; extern u8 gPidList_SethLArachelMyrrhInnes[]; extern CONST_DATA EventListScr EventScr_RunTutIfEasyMode[]; +extern CONST_DATA EventListScr EventScr_SetBackground[]; extern CONST_DATA EventListScr Event_TextWithBG[]; extern CONST_DATA EventListScr EventScr_Prologue_BeginingScene[]; @@ -251,8 +252,10 @@ extern CONST_DATA EventListScr EventScr_Prologue_TutorialB[]; extern CONST_DATA EventListScr EventScr_Prologue_TutorialC[]; extern CONST_DATA EventListScr EventScr_Prologue_TutorialD[]; extern CONST_DATA EventListScr EventScr_Prologue_TutorialE[]; +extern CONST_DATA EventListScr EventScr_Prologue_9EF828[]; extern struct UnitDefinition UnitDef_Event_PrologueAlly[]; +extern struct UnitDefinition UnitDef_Event_PrologueEnemy[]; extern struct UnitDefinition UnitDef_Event_PrologueThroneRoomUnits[]; extern struct UnitDefinition UnitDef_Event_PrologueMessager[]; extern struct UnitDefinition UnitDef_Event_PrologueGradoRoyals[]; diff --git a/include/eventscript.h b/include/eventscript.h index fe13ba67..f22c3c16 100644 --- a/include/eventscript.h +++ b/include/eventscript.h @@ -166,6 +166,13 @@ enum event_sub_cmd_idx { EVSUBCMD_TEXTSHOW2 = 1, EVSUBCMD_REMA = 2, + /* EV_CMD_CHANGECHAPTER */ + EVSUBCMD_MNTS = 0, + EVSUBCMD_MNCH = 1, + EVSUBCMD_MNC2 = 2, + EVSUBCMD_MNC3 = 3, + EVSUBCMD_MNC4 = 4, + /* EV_CMD_LOADUNIT */ EVSUBCMD_LOAD1 = 0x0, EVSUBCMD_LOAD2 = 0x1, @@ -197,6 +204,15 @@ enum event_sub_cmd_idx { EVSUBCMD_DISA_IF = 0xE, EVSUBCMD_DISA = 0xF, + /* EV_CMD_GIVEITEM */ + EVSUBCMD_GIVEITEMTO = 0, + EVSUBCMD_GIVEITEMTOMAIN = 1, + EVSUBCMD_GIVETOSLOT3 = 2, + + /* EV_CMD_CHANGEAI */ + EVTSUBCMD_CHAI = 0, + EVTSUBCMD_CHAI_AT = 1, + /* EV_CMD_DISPLAYPOPUP */ EVSUBCMD_POPUP = 0, EVSUBCMD_BROWNTEXTBOX = 1, @@ -214,6 +230,11 @@ enum event_sub_cmd_idx { EVSUBCMD_FIGHT_SCRIPT = 2, }; +#define _EvtSubParam16u8(u8a, u8b) \ + (((u8a) & 0xFF) + ((u8b & 0xFF) << 8)) +#define _EvtSubParam16u4(u4a, u4b, u4c, u4d) \ + (((u4a) & 0xF) + ((u4b & 0xF) << 4) + ((u4c & 0xF) << 8) + ((u4d & 0xF) << 12)) + #define _EvtParams2(x, y) ((((y) & 0xFFFF) << 16) + ((x) & 0xFFFF)) #define _EvtParams4(a, b, c, d) ((((d) & 0xFF) << 24) + (((c) & 0xFF) << 16) + (((b) & 0xFF) << 8) + ((a) & 0xFF)) #define _EvtCmd(cmd, len, sub) \ @@ -231,12 +252,15 @@ enum event_sub_cmd_idx { #define EvtClearEvBits(flag) _EvtArg0(EV_CMD_EVSET, 2, EVSUBCMD_EVBIT_F, (flag)), #define EvtSetEvBits(flag) _EvtArg0(EV_CMD_EVSET, 2, EVSUBCMD_EVBIT_T, (flag)), #define EvtClearFlag(flag) _EvtArg0(EV_CMD_EVSET, 2, EVSUBCMD_ENUF, (flag)), +#define EvtClearFlagAtSlot2 EvtClearFlag(-1) #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 EvtSlotAdd(to, a, b) _EvtArg0(EV_CMD_SLOT_OPS, 2, EVSUBCMD_SADD, _EvtSubParam16u4(to, a, b, 0)), #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 EvtLabel(label) _EvtArg0(EV_CMD_LABEL, 2, 0, (label)), +#define EvtGoto(label) _EvtArg0(EV_CMD_GOTO, 2, 0, (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)), #define EvtAsmCall(func) _EvtAutoCmdLen4(EV_CMD_ASMC), (EventListScr)(func), @@ -254,13 +278,28 @@ enum event_sub_cmd_idx { #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 EvtGetMode _EvtArg0(EV_CMD_CHECKVARIOUS, 2, EVSUBCMD_CHECK_MODE, 0), +#define EvtGetChapterIndex _EvtArg0(EV_CMD_CHECKVARIOUS, 2, EVSUBCMD_CHECK_CHAPTER_NUMBER, 0), +#define EvtGetIsHard _EvtArg0(EV_CMD_CHECKVARIOUS, 2, EVSUBCMD_CHECK_HARD, 0), +#define EvtGetCurrentTurn _EvtArg0(EV_CMD_CHECKVARIOUS, 2, EVSUBCMD_CHECK_TURNS, 0), +#define EvtGetEnemyAmount _EvtArg0(EV_CMD_CHECKVARIOUS, 2, EVSUBCMD_CHECK_ENEMIES, 0), +#define EvtGetNpcAmount _EvtArg0(EV_CMD_CHECKVARIOUS, 2, EVSUBCMD_CHECK_OTHERS, 0), +#define EvtGetSkirmishType _EvtArg0(EV_CMD_CHECKVARIOUS, 2, EVSUBCMD_CHECK_SKIRMISH, 0), +#define EvtGetIsTutorial _EvtArg0(EV_CMD_CHECKVARIOUS, 2, EVSUBCMD_CHECK_TUTORIAL, 0), +#define EvtGetMoney _EvtArg0(EV_CMD_CHECKVARIOUS, 2, EVSUBCMD_CHECK_MONEY, 0), +#define EvtGetTriggeredEid _EvtArg0(EV_CMD_CHECKVARIOUS, 2, EVSUBCMD_19CHECK_EVENTID, 0), +#define EvtGetIsGameCompleted _EvtArg0(EV_CMD_CHECKVARIOUS, 2, EVSUBCMD_CHECK_POSTGAME, 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 EvtMoveCameraTo(x, y) _EvtArg0(EV_CMD_CAMERACONTROL, 2, 0, _EvtSubParam16u8((x), (y))), +#define EvtBackToTitle(chapter) _EvtArg0(EV_CMD_CHANGECHAPTER, 2, EVSUBCMD_MNTS, (chapter)), +#define EvtChangeChapterWM(chapter) _EvtArg0(EV_CMD_CHANGECHAPTER, 2, EVSUBCMD_MNCH, (chapter)), +#define EvtChangeChapterBM(chapter) _EvtArg0(EV_CMD_CHANGECHAPTER, 2, EVSUBCMD_MNC2, (chapter)), +#define EvtChangeChapterNoSave(chapter) _EvtArg0(EV_CMD_CHANGECHAPTER, 2, EVSUBCMD_MNC3, (chapter)), +#define EvtMoveToGameEnding _EvtArg0(EV_CMD_CHANGECHAPTER, 2, EVSUBCMD_MNC4, 0), #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)), @@ -274,6 +313,11 @@ enum event_sub_cmd_idx { #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 EvtGiveItemAtSlot3(pid) _EvtArg0(EV_CMD_GIVEITEM, 2, EVSUBCMD_GIVEITEMTO, (pid)), +#define EvtGiveMoneymAtSlot3(pid) _EvtArg0(EV_CMD_GIVEITEM, 2, EVSUBCMD_GIVEITEMTOMAIN, (pid)), +#define EvtGiveMoneymAtSlot3NoPopup(pid) _EvtArg0(EV_CMD_GIVEITEM, 2, EVSUBCMD_GIVETOSLOT3, (pid)), +#define EvtChangeAI(pid) _EvtArg0(EV_CMD_CHANGEAI, 2, EVTSUBCMD_CHAI, (pid)), +#define EvtChangeAIat(x, y) _EvtArg0(EV_CMD_CHANGEAI, 2, EVTSUBCMD_CHAI_AT, _EvtSubParam16u8((x), (y))), #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), diff --git a/src/events/prologue-eventinfo.h b/src/events/prologue-eventinfo.h index 21b63532..d909e7df 100644 --- a/src/events/prologue-eventinfo.h +++ b/src/events/prologue-eventinfo.h @@ -12,7 +12,7 @@ CONST_DATA EventListScr EventListScr_Prologue_Turn[] = { TURN(0x0, EventScr_Prologue_Turn1, 1, 0, FACTION_RED) TURN(0x0, EventScr_Prologue_Turn2, 2, 0, FACTION_BLUE) TURN(0x0, EventScr_Prologue_Turn3, 3, 0, FACTION_BLUE) - TURN(0x8, EventScr_Prologue_ONeillAttack, 1, 255, FACTION_RED) + TURN(EVFLAG_TMP_8, EventScr_Prologue_ONeillAttack, 1, 255, FACTION_RED) END_MAIN }; diff --git a/src/events/prologue-eventscript.h b/src/events/prologue-eventscript.h index 3ad104b3..f8f28a6e 100644 --- a/src/events/prologue-eventscript.h +++ b/src/events/prologue-eventscript.h @@ -7,6 +7,7 @@ #include "eventinfo.h" #include "ea-stdlib.h" #include "constants/characters.h" +#include "constants/items.h" CONST_DATA EventListScr EventScr_Prologue_BeginingScene[] = { CALL(EventScr_Prologue_RenaisThroneCutscene) @@ -199,3 +200,93 @@ CONST_DATA EventListScr EventScr_Prologue_RenaisThroneCutscene[] = { ENDA }; + +CONST_DATA EventListScr EventScr_Prologue_GiveRapier[] = { + FlashCursor(CHARACTER_SETH, 60) + Text(0x90F) + CALL(EventScr_RemoveBGIfNeeded) + + /* Give item via slot3 */ + SVAL(EVT_SLOT_3, ITEM_SWORD_RAPIER) + GIVEITEMTO(CHARACTER_EIRIKA) + + SVAL(EVT_SLOT_2, EventScr_Prologue_9EF828) + CALL(EventScr_RunTutIfEasyMode) + ENDA +}; + +CONST_DATA EventListScr EventScr_Prologue_ONeillSpawn[] = { + LOAD1(1, UnitDef_Event_PrologueEnemy) + ENUN + FlashCursor(CHARACTER_ONEILL, 60) + MUSC(0x13) + Text(0x910) + ENUF(EVFLAG_BGM_CHANGE) + ENDA +}; + +CONST_DATA EventListScr EventScr_Prologue_OneEmimyLeft[] = { + CHECK_ENEMIES + SVAL(EVT_SLOT_7, 1) + BNE(0x0, EVT_SLOT_C, EVT_SLOT_7) + + CUMO_CHAR(CHARACTER_SETH) + STAL(60) + CURE + TEXTSTART + TEXTSHOW(0x913) + TEXTEND + REMA + /* this unsets the event ID so the next turn Oneill will agro (see TURN events) */ + ENUF(EVFLAG_TMP_8) + GOTO(0x1) + +LABEL(0x0) + CHECK_EVENTID + SADD(EVT_SLOT_2, EVT_SLOT_C, EVT_SLOT_0) + ENUF_SLOT2 + +LABEL(0x1) + NoFade + ENDA +}; + +CONST_DATA EventListScr EventScr_Prologue_ONeillAttack[] = { + MUSC(0x13) + Text(0x914) + CHECK_TUTORIAL + BNE(0x0, EVT_SLOT_C, EVT_SLOT_0) + + /* slot1 saves the (u8)( (AI1 << 8) | AI2 ) */ + SVAL(EVT_SLOT_1, 0x0) + CHAI(CHARACTER_ONEILL) + +LABEL(0x0) + NoFade + ENDA +}; + +CONST_DATA EventListScr EventScr_Prologue_EndingScene[] = { + MUSC(0x31) + SetBackground(0x1D) + TEXTSHOW(0x918) + TEXTEND + FADI(16) + REMA + + /* tons of permanent event IDs */ + ENUT(0xE0) + ENUT(0xE1) + ENUT(0xB7) + ENUT(0xB4) + ENUT(0xB5) + ENUT(0xDC) + ENUT(0xB9) + ENUT(0xC2) + ENUT(0xC3) + ENUT(0xE7) + ENUT(0xC9) + + MNC2(0x1) + ENDA +}; diff --git a/src/evtscr.c b/src/evtscr.c index 6045e166..c2a97f4e 100644 --- a/src/evtscr.c +++ b/src/evtscr.c @@ -195,50 +195,49 @@ u8 Event06_SlotOperation(struct EventEngineProc * proc) u8 slotSrc1 = (((u16)EVT_CMD_ARGV(proc->pEventCurrent)[0]) >> 4) & 0xF; u8 slotSrc2 = (((u16)EVT_CMD_ARGV(proc->pEventCurrent)[0]) >> 8) & 0xF; - switch (sub_cmd) - { - case EVSUBCMD_SADD: - gEventSlots[slotDest] = gEventSlots[slotSrc1] + gEventSlots[slotSrc2]; - return EVC_ADVANCE_CONTINUE; + switch (sub_cmd) { + case EVSUBCMD_SADD: + gEventSlots[slotDest] = gEventSlots[slotSrc1] + gEventSlots[slotSrc2]; + return EVC_ADVANCE_CONTINUE; - case EVSUBCMD_SSUB: - gEventSlots[slotDest] = gEventSlots[slotSrc1] - gEventSlots[slotSrc2]; - return EVC_ADVANCE_CONTINUE; + case EVSUBCMD_SSUB: + gEventSlots[slotDest] = gEventSlots[slotSrc1] - gEventSlots[slotSrc2]; + return EVC_ADVANCE_CONTINUE; - case EVSUBCMD_SMUL: - gEventSlots[slotDest] = gEventSlots[slotSrc1] * gEventSlots[slotSrc2]; - return EVC_ADVANCE_CONTINUE; + case EVSUBCMD_SMUL: + gEventSlots[slotDest] = gEventSlots[slotSrc1] * gEventSlots[slotSrc2]; + return EVC_ADVANCE_CONTINUE; - case EVSUBCMD_SDIV: - gEventSlots[slotDest] = gEventSlots[slotSrc1] / gEventSlots[slotSrc2]; - return EVC_ADVANCE_CONTINUE; + case EVSUBCMD_SDIV: + gEventSlots[slotDest] = gEventSlots[slotSrc1] / gEventSlots[slotSrc2]; + return EVC_ADVANCE_CONTINUE; - case EVSUBCMD_SMOD: - gEventSlots[slotDest] = gEventSlots[slotSrc1] % gEventSlots[slotSrc2]; - return EVC_ADVANCE_CONTINUE; + case EVSUBCMD_SMOD: + gEventSlots[slotDest] = gEventSlots[slotSrc1] % gEventSlots[slotSrc2]; + return EVC_ADVANCE_CONTINUE; - case EVSUBCMD_SAND: - gEventSlots[slotDest] = gEventSlots[slotSrc1] & gEventSlots[slotSrc2]; - return EVC_ADVANCE_CONTINUE; + case EVSUBCMD_SAND: + gEventSlots[slotDest] = gEventSlots[slotSrc1] & gEventSlots[slotSrc2]; + return EVC_ADVANCE_CONTINUE; - case EVSUBCMD_SORR: - gEventSlots[slotDest] = gEventSlots[slotSrc1] | gEventSlots[slotSrc2]; - return EVC_ADVANCE_CONTINUE; + case EVSUBCMD_SORR: + gEventSlots[slotDest] = gEventSlots[slotSrc1] | gEventSlots[slotSrc2]; + return EVC_ADVANCE_CONTINUE; - case EVSUBCMD_SXOR: - gEventSlots[slotDest] = gEventSlots[slotSrc1] ^ gEventSlots[slotSrc2]; - return EVC_ADVANCE_CONTINUE; + case EVSUBCMD_SXOR: + gEventSlots[slotDest] = gEventSlots[slotSrc1] ^ gEventSlots[slotSrc2]; + return EVC_ADVANCE_CONTINUE; - case EVSUBCMD_SLSL: - gEventSlots[slotDest] = gEventSlots[slotSrc1] << gEventSlots[slotSrc2]; - return EVC_ADVANCE_CONTINUE; + case EVSUBCMD_SLSL: + gEventSlots[slotDest] = gEventSlots[slotSrc1] << gEventSlots[slotSrc2]; + return EVC_ADVANCE_CONTINUE; - case EVSUBCMD_SLSR: - gEventSlots[slotDest] = gEventSlots[slotSrc1] >> gEventSlots[slotSrc2]; - return EVC_ADVANCE_CONTINUE; + case EVSUBCMD_SLSR: + gEventSlots[slotDest] = gEventSlots[slotSrc1] >> gEventSlots[slotSrc2]; + return EVC_ADVANCE_CONTINUE; - default: - return EVC_ERROR; + default: + return EVC_ERROR; } } @@ -798,73 +797,69 @@ u8 Event18_(struct EventEngineProc * proc) } // switch (subcode) } -// Various Checks -//! FE8U = 0x0800E070 -u8 Event19_(struct EventEngineProc * proc) + +u8 Event19_Checks(struct EventEngineProc * proc) { u8 subcode = EVT_SUB_CMD(proc->pEventCurrent); + switch (subcode) { + case EVSUBCMD_CHECK_MODE: // Check Mode + gEventSlots[0xC] = gPlaySt.chapterModeIndex; + break; - switch (subcode) - { - case EVSUBCMD_CHECK_MODE: // Check Mode - gEventSlots[0xC] = gPlaySt.chapterModeIndex; - break; + case EVSUBCMD_CHECK_CHAPTER_NUMBER: // Check (Next?) Chapter Index + gEventSlots[0xC] = proc->chapterIndex; + break; - case EVSUBCMD_CHECK_CHAPTER_NUMBER: // Check (Next?) Chapter Index - gEventSlots[0xC] = proc->chapterIndex; - break; + case EVSUBCMD_CHECK_HARD: // Check Difficult Mode + if (!(gPlaySt.chapterStateBits & PLAY_FLAG_HARD)) + gEventSlots[0xC] = FALSE; + else + gEventSlots[0xC] = TRUE; - case EVSUBCMD_CHECK_HARD: // Check Difficult Mode - if (!(gPlaySt.chapterStateBits & PLAY_FLAG_HARD)) - gEventSlots[0xC] = FALSE; - else - gEventSlots[0xC] = TRUE; + break; - break; + case EVSUBCMD_CHECK_TURNS: // Check Turn Number + gEventSlots[0xC] = gPlaySt.chapterTurnNumber; + break; - case EVSUBCMD_CHECK_TURNS: // Check Turn Number - gEventSlots[0xC] = gPlaySt.chapterTurnNumber; - break; + case EVSUBCMD_CHECK_ENEMIES: // Check Red Unit Count + gEventSlots[0xC] = CountRedUnits(); + break; - case EVSUBCMD_CHECK_ENEMIES: // Check Red Unit Count - gEventSlots[0xC] = CountRedUnits(); - break; + case EVSUBCMD_CHECK_OTHERS: // Check Green Unit Count + gEventSlots[0xC] = CountGreenUnits(); + break; - case EVSUBCMD_CHECK_OTHERS: // Check Green Unit Count - gEventSlots[0xC] = CountGreenUnits(); - break; + case EVSUBCMD_CHECK_SKIRMISH: // Check Chapter Type? + gEventSlots[0xC] = GetChapterThing(); + break; - case EVSUBCMD_CHECK_SKIRMISH: // Check Chapter Type? - gEventSlots[0xC] = GetChapterThing(); - break; + case EVSUBCMD_CHECK_TUTORIAL: // Check Some option or difficult mode + if (gPlaySt.config.controller || (gPlaySt.chapterStateBits & PLAY_FLAG_HARD)) + gEventSlots[0xC] = FALSE; + else + gEventSlots[0xC] = TRUE; - case EVSUBCMD_CHECK_TUTORIAL: // Check Some option or difficult mode - if (gPlaySt.config.controller || (gPlaySt.chapterStateBits & PLAY_FLAG_HARD)) - gEventSlots[0xC] = FALSE; - else - gEventSlots[0xC] = TRUE; + break; - break; + case EVSUBCMD_CHECK_MONEY: // Check gold + gEventSlots[0xC] = GetPartyGoldAmount(); + break; - case EVSUBCMD_CHECK_MONEY: // Check gold - gEventSlots[0xC] = GetPartyGoldAmount(); - break; + case EVSUBCMD_19CHECK_EVENTID: // Check Event Trigger ID + gEventSlots[0xC] = GetEventTriggerId(proc->pEventStart); + break; - case EVSUBCMD_19CHECK_EVENTID: // Check Event Trigger ID - gEventSlots[0xC] = GetEventTriggerId(proc->pEventStart); - break; + case EVSUBCMD_CHECK_POSTGAME: // Check Game Complete + if (gPlaySt.chapterStateBits & PLAY_FLAG_COMPLETE) + gEventSlots[0xC] = TRUE; + else + gEventSlots[0xC] = FALSE; - case EVSUBCMD_CHECK_POSTGAME: // Check Game Complete - if (gPlaySt.chapterStateBits & PLAY_FLAG_COMPLETE) - gEventSlots[0xC] = TRUE; - else - gEventSlots[0xC] = FALSE; - - break; - - default: - break; + break; + default: + break; } // switch (subcode) return EVC_ADVANCE_CONTINUE; @@ -2129,43 +2124,42 @@ u8 Event2A_MoveToChapter(struct EventEngineProc * proc) if (chIndex < 0) chIndex = gEventSlots[2]; - switch (subcode) - { - case 0: - SetNextGameActionId(GAME_ACTION_EVENT_RETURN); - proc->evStateBits |= EV_STATE_CHANGEGM; + switch (subcode) { + case EVSUBCMD_MNTS: + SetNextGameActionId(GAME_ACTION_EVENT_RETURN); + proc->evStateBits |= EV_STATE_CHANGEGM; - break; + break; - case 1: - SetNextChapterId(chIndex); + case EVSUBCMD_MNCH: + SetNextChapterId(chIndex); - gPlaySt.unk4A_2 = 1; + gPlaySt.unk4A_2 = 1; - SetNextGameActionId(GAME_ACTION_CLASS_REEL); - proc->evStateBits |= EV_STATE_CHANGEGM; + SetNextGameActionId(GAME_ACTION_CLASS_REEL); + proc->evStateBits |= EV_STATE_CHANGEGM; - break; + break; - case 2: - SetNextChapterId(chIndex); + case EVSUBCMD_MNC2: + SetNextChapterId(chIndex); - gPlaySt.unk4A_2 = 2; + gPlaySt.unk4A_2 = 2; - SetNextGameActionId(GAME_ACTION_USR_SKIPPED); - proc->evStateBits |= EV_STATE_CHANGEGM; + SetNextGameActionId(GAME_ACTION_USR_SKIPPED); + proc->evStateBits |= EV_STATE_CHANGEGM; - break; + break; - case 3: - GotoChapterWithoutSave(chIndex); - break; + case EVSUBCMD_MNC3: + GotoChapterWithoutSave(chIndex); + break; - case 4: - gPlaySt.unk4A_2 = 3; - SetNextGameActionId(GAME_ACTION_PLAYED_THROUGH); - proc->evStateBits |= EV_STATE_CHANGEGM; - break; + case EVSUBCMD_MNC4: + gPlaySt.unk4A_2 = 3; + SetNextGameActionId(GAME_ACTION_PLAYED_THROUGH); + proc->evStateBits |= EV_STATE_CHANGEGM; + break; } // switch (subcode) @@ -3623,40 +3617,34 @@ u8 Event36_CheckInArea(struct EventEngineProc * param_1) //! FE8U = 0x080105A4 u8 Event37_GiveItem(struct EventEngineProc * proc) { + s32 gold; u8 subcmd = EVT_SUB_CMD(proc->pEventCurrent); struct Unit * target = GetUnitStructFromEventParameter(proc->pEventCurrent[1]); if (!target) - { return EVC_ERROR; + + switch (subcmd) { + case EVSUBCMD_GIVEITEMTO: + NewPopup_ItemGot(proc, target, gEventSlots[3]); + + break; + + case EVSUBCMD_GIVEITEMTOMAIN: + NewPopup_GoldGot(proc, target, gEventSlots[3]); + + break; + + case EVSUBCMD_GIVETOSLOT3: + gold = GetPartyGoldAmount() - gEventSlots[3]; + if (gold < 0) + gold = 0; + + SetPartyGoldAmount(gold); + + break; } - - switch (subcmd) - { - case 0: - NewPopup_ItemGot(proc, target, gEventSlots[3]); - - break; - - case 1: - NewPopup_GoldGot(proc, target, gEventSlots[3]); - - break; - - case 2: - { - s32 gold = GetPartyGoldAmount() - gEventSlots[3]; - if (gold < 0) - { - gold = 0; - } - SetPartyGoldAmount(gold); - - break; - } - } - return EVC_ADVANCE_YIELD; } @@ -3685,47 +3673,45 @@ u8 Event39_ChangeAiScript(struct EventEngineProc * proc) u8 ai2 = (gEventSlots[1] >> 8); u8 unused = (gEventSlots[1] >> 16); - switch (subcmd) - { - case 0: + struct Unit * unit; + s8 x, y; + u16 pid; + + switch (subcmd) { + case EVTSUBCMD_CHAI: + pid = EVT_CMD_ARGV(proc->pEventCurrent)[0]; + if (EVT_CMD_ARGV(proc->pEventCurrent)[0] < 0) + pid = gEventSlots[2]; + + ChangeAiForCharacter(pid, ai1, ai2, unused); + + break; + + case EVTSUBCMD_CHAI_AT: + +#if !BUGFIX + /* I think this maybe a bug */ + x = EVT_CMD_ARGV(proc->pEventCurrent)[0]; + y = EVT_CMD_ARGV(proc->pEventCurrent)[0] >> 8; +#else + x = (EVT_CMD_ARGV(proc->pEventCurrent)[0] & 0x0F); + y = (EVT_CMD_ARGV(proc->pEventCurrent)[0] & 0xF0) >> 8; +#endif + + if (x < 0 || y < 0) { - u16 pid = EVT_CMD_ARGV(proc->pEventCurrent)[0]; - - if (EVT_CMD_ARGV(proc->pEventCurrent)[0] < 0) - { - pid = gEventSlots[2]; - } - - ChangeAiForCharacter(pid, ai1, ai2, unused); - - break; + x = ((u16 *)(gEventSlots + 0xB))[0]; + y = ((u16 *)(gEventSlots + 0xB))[1]; } - case 1: - { - struct Unit * unit; - s8 x = EVT_CMD_ARGV(proc->pEventCurrent)[0]; - s8 y = EVT_CMD_ARGV(proc->pEventCurrent)[0] >> 8; + if (gBmMapUnit[y][x] != 0) + unit = GetUnit(gBmMapUnit[y][x]); + else + unit = NULL; - if (x < 0 || y < 0) - { - x = ((u16 *)(gEventSlots + 0xB))[0]; - y = ((u16 *)(gEventSlots + 0xB))[1]; - } + ChangeUnitAi(unit, ai1, ai2, unused); - if (gBmMapUnit[y][x] != 0) - { - unit = GetUnit(gBmMapUnit[y][x]); - } - else - { - unit = NULL; - } - - ChangeUnitAi(unit, ai1, ai2, unused); - - break; - } + break; } return EVC_ADVANCE_CONTINUE;