diff --git a/asm/include/main_0203C774.inc b/asm/include/main_0203C774.inc index f8c6bfe2..9da28df1 100644 --- a/asm/include/main_0203C774.inc +++ b/asm/include/main_0203C774.inc @@ -462,7 +462,7 @@ .public sub_0203909C .public sub_02039218 .public sub_0203931C -.public sub_0204B028 +.public DebugPrintEventFlagSize .public SetSpecialEpisodeOpenOld .public sub_0204CDB8 .public sub_0204E154 diff --git a/asm/include/main_0204B018.inc b/asm/include/main_0204B018.inc deleted file mode 100644 index 87bc7426..00000000 --- a/asm/include/main_0204B018.inc +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -.public EVENT_FLAG_SIZE_DEBUG_MSG -.public _0209DF70 -.public Debug_Print0 -.public GAME_MODE -.public InitDungeonListScriptVars -.public InitScenarioProgressScriptVars -.public InitWorldMapScriptVars -.public SaveScriptVariableValue -.public SaveScriptVariableValueAtIndex -.public SCRIPT_VARS -.public SCRIPT_VARS_LOCALS -.public SCRIPT_VARS_VALUES -.public ZeroInitScriptVariable -.public DefaultInitScriptVariable -.public InitEventFlagScriptVars diff --git a/asm/include/main_02058F24.inc b/asm/include/main_02058F24.inc index de0e6e13..bc09f491 100644 --- a/asm/include/main_02058F24.inc +++ b/asm/include/main_02058F24.inc @@ -482,7 +482,7 @@ .public sub_0204A1A4 .public sub_0204AB18 .public sub_0204AF98 -.public sub_0204B018 +.public SetGameMode .public sub_0204D018 .public sub_0204E210 .public sub_0204E6FC diff --git a/asm/main_0203C774.s b/asm/main_0203C774.s index 794522dd..fb8956bb 100644 --- a/asm/main_0203C774.s +++ b/asm/main_0203C774.s @@ -14526,7 +14526,7 @@ _0204841C: .word _020AFEF4 arm_func_start sub_02048420 sub_02048420: ; 0x02048420 stmdb sp!, {r3, lr} - bl sub_0204B028 + bl DebugPrintEventFlagSize bl sub_02048B74 ldmia sp!, {r3, pc} arm_func_end sub_02048420 @@ -18067,18 +18067,3 @@ GetGameMode: ; 0x0204AFC0 .align 2, 0 _0204AFCC: .word GAME_MODE arm_func_end GetGameMode - - arm_func_start sub_0204AFD0 -sub_0204AFD0: ; 0x0204AFD0 - ldr r0, _0204AFF4 ; =GAME_MODE - ldrb r0, [r0] - add r0, r0, #0xfe - and r0, r0, #0xff - cmp r0, #1 - movls r0, #1 - movhi r0, #0 - and r0, r0, #0xff - bx lr - .align 2, 0 -_0204AFF4: .word GAME_MODE - arm_func_end sub_0204AFD0 diff --git a/asm/main_0204B018.s b/asm/main_0204B018.s deleted file mode 100644 index 1bae30e5..00000000 --- a/asm/main_0204B018.s +++ /dev/null @@ -1,27 +0,0 @@ - .include "asm/macros.inc" - .include "main_0204B018.inc" - - .text - - arm_func_start sub_0204B018 -sub_0204B018: ; 0x0204B018 - ldr r1, _0204B024 ; =GAME_MODE - strb r0, [r1] - bx lr - .align 2, 0 -_0204B024: .word GAME_MODE - arm_func_end sub_0204B018 - - arm_func_start sub_0204B028 -sub_0204B028: ; 0x0204B028 - ldr r1, _0204B040 ; =_0209DF70 - ldr ip, _0204B044 ; =Debug_Print0 - ldr r0, _0204B048 ; =EVENT_FLAG_SIZE_DEBUG_MSG - ldrsh r1, [r1, #0x24] - mov r2, #0x400 - bx ip - .align 2, 0 -_0204B040: .word _0209DF70 -_0204B044: .word Debug_Print0 -_0204B048: .word EVENT_FLAG_SIZE_DEBUG_MSG - arm_func_end sub_0204B028 diff --git a/asm/main_02058F24.s b/asm/main_02058F24.s index d3662cbc..5a13173f 100644 --- a/asm/main_02058F24.s +++ b/asm/main_02058F24.s @@ -15838,7 +15838,7 @@ MainLoop: ; 0x02065D1C bl sub_02026E78 bl sub_020346C0 mov r0, #0 - bl sub_0204B018 + bl SetGameMode mov r0, #2 bl SetBothScreensWindowsColor bl sub_0204A1A4 @@ -15956,7 +15956,7 @@ _02065EE0: mov r6, #0 _02065F20: mov r0, r6 - bl sub_0204B018 + bl SetGameMode bl sub_02048624 cmp r8, #0 beq _02065FE0 @@ -16084,7 +16084,7 @@ _020660B0: movne r7, #0 _020660C8: mov r0, #0 - bl sub_0204B018 + bl SetGameMode mov r0, #1 bl LoadOverlay mov r0, #4 @@ -16133,7 +16133,7 @@ _02066154: ; jump table b _02066330 ; case 9 _0206617C: mov r0, #2 - bl sub_0204B018 + bl SetGameMode bl sub_020484C0 bl sub_02048644 mov r0, #2 @@ -16149,7 +16149,7 @@ _020661B0: bl GetDebugSpecialEpisodeNumber bl SetSpecialEpisodeType mov r0, #3 - bl sub_0204B018 + bl SetGameMode bl sub_02048644 bl InitSpecialEpisodeHero mov r0, #2 @@ -16167,7 +16167,7 @@ _020661B0: b _02065F20 _020661FC: mov r0, #2 - bl sub_0204B018 + bl SetGameMode bl sub_02048644 mov r0, #2 bl LoadOverlay @@ -16180,7 +16180,7 @@ _020661FC: b _02065F20 _0206622C: mov r0, #3 - bl sub_0204B018 + bl SetGameMode bl sub_02048644 mov r0, #2 bl LoadOverlay @@ -16193,7 +16193,7 @@ _0206622C: b _02065F20 _0206625C: mov r0, #2 - bl sub_0204B018 + bl SetGameMode bl sub_02048644 mov r0, #2 bl LoadOverlay @@ -16206,7 +16206,7 @@ _0206625C: b _02065F20 _0206628C: mov r0, #2 - bl sub_0204B018 + bl SetGameMode bl sub_02048644 mov r0, #2 bl LoadOverlay @@ -16219,7 +16219,7 @@ _0206628C: b _02065F20 _020662BC: mov r0, #4 - bl sub_0204B018 + bl SetGameMode bl sub_02048644 bl sub_020485C4 mov r0, #2 @@ -16237,7 +16237,7 @@ _020662BC: b _02065F20 _02066300: mov r0, #4 - bl sub_0204B018 + bl SetGameMode bl sub_02048644 mov r0, #2 bl LoadOverlay @@ -16250,7 +16250,7 @@ _02066300: b _02065F20 _02066330: mov r0, #5 - bl sub_0204B018 + bl SetGameMode bl sub_02048644 bl sub_020485D8 mov r0, #2 diff --git a/include/game_mode.h b/include/game_mode.h new file mode 100644 index 00000000..2122c135 --- /dev/null +++ b/include/game_mode.h @@ -0,0 +1,11 @@ +#ifndef PMDSKY_GAME_MODE +#define PMDSKY_GAME_MODE + +#include "enums.h" +#include "util.h" + +bool8 sub_0204AFD0(); +bool8 IsGameModeRescue(); +void SetGameMode(enum game_mode new_game_mode); + +#endif //PMDSKY_GAME_MODE diff --git a/include/main_0204AFF8.h b/include/main_0204AFF8.h deleted file mode 100644 index 880ba1bf..00000000 --- a/include/main_0204AFF8.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef PMDSKY_MAIN_0204AFF8_H -#define PMDSKY_MAIN_0204AFF8_H - -#include "util.h" - -bool8 IsGameModeRescue(); - -#endif //PMDSKY_MAIN_0204AFF8_H diff --git a/include/script_variable.h b/include/script_variable.h index abee13ff..8f51c8d7 100644 --- a/include/script_variable.h +++ b/include/script_variable.h @@ -30,7 +30,7 @@ struct script_var_raw { }; // See enum script_var_id for the sv_id parameters. - +void DebugPrintEventFlagSize(); void InitScriptVariableValues(); void InitEventFlagScriptVars(); void DefaultInitScriptVariable(union script_var_value sv_locals[], s16 sv_id); diff --git a/main.lsf b/main.lsf index f3979c57..63bb902a 100644 --- a/main.lsf +++ b/main.lsf @@ -78,8 +78,7 @@ Static main Object asm/main_02034974.o Object src/main_0203C760.o Object asm/main_0203C774.o - Object src/main_0204AFF8.o - Object asm/main_0204B018.o + Object src/game_mode.o Object src/script_variable.o Object asm/main_rodata_0209CECC.o Object src/dungeon_parameters_3.o diff --git a/src/game_mode.c b/src/game_mode.c new file mode 100644 index 00000000..1da0177e --- /dev/null +++ b/src/game_mode.c @@ -0,0 +1,21 @@ +#include "game_mode.h" +#include "enums.h" + +extern enum game_mode GAME_MODE; + +u8 sub_0204AFD0() { + if ((u8)(GAME_MODE + 0xFE) <= 1) { + return TRUE; + } else { + return FALSE; + } +} + +bool8 IsGameModeRescue() +{ + return GAME_MODE == GAME_MODE_RESCUE; +} + +void SetGameMode(enum game_mode new_game_mode) { + GAME_MODE = new_game_mode; +} diff --git a/src/main_0204AFF8.c b/src/main_0204AFF8.c deleted file mode 100644 index 19375ff9..00000000 --- a/src/main_0204AFF8.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "main_0204AFF8.h" -#include "enums.h" - -extern enum game_mode GAME_MODE; - -bool8 IsGameModeRescue() -{ - return GAME_MODE == GAME_MODE_RESCUE; -} diff --git a/src/overlay_29_0234BBE8.c b/src/overlay_29_0234BBE8.c index a413bab5..5493cabf 100644 --- a/src/overlay_29_0234BBE8.c +++ b/src/overlay_29_0234BBE8.c @@ -1,5 +1,5 @@ #include "overlay_29_0234BBE8.h" -#include "main_0204AFF8.h" +#include "game_mode.h" #include "overlay_29_022DC61C.h" #include "overlay_29_0234CA68.h" #include "util.h" diff --git a/src/script_variable.c b/src/script_variable.c index 320be9b6..1beac63b 100644 --- a/src/script_variable.c +++ b/src/script_variable.c @@ -29,15 +29,8 @@ extern u8 EVENT_FLAG_EXPANSION_ERROR; extern u8 EVENT_FLAG_COMPARE_SCRIPT_VARIABLES_ERROR; extern const u8 EVENT_FLAG_GAME_MODE_DEBUG_MSG; extern const u8 EVENT_FLAG_BACKUP_DEBUG_MSG; -const u8 EVENT_FLAG_FILE_NAME[] = "event_flag.c"; -const struct prog_pos_info EVENT_FLAG_PROG_POS_INFO_CALC_SCRIPT_VARIABLES = { - (u8*) EVENT_FLAG_FILE_NAME, - 1001 -}; -const struct prog_pos_info EVENT_FLAG_PROG_POS_INFO_COMPARE_SCRIPT_VARIABLES = { - (u8*) EVENT_FLAG_FILE_NAME, - 1044 -}; +extern u8 EVENT_FLAG_SIZE_DEBUG_MSG; +extern s16 _0209DF70[18]; extern s32 GetPartyMembers(s32 param1); extern s32 GetMoneyStored(); @@ -50,6 +43,20 @@ extern s32 SetMoneyStored(s32 arg0); extern s32 SetNotifyNote(s32 arg0); extern void InitDungeonListScriptVars(); +const u8 EVENT_FLAG_FILE_NAME[] = "event_flag.c"; +const struct prog_pos_info EVENT_FLAG_PROG_POS_INFO_CALC_SCRIPT_VARIABLES = { + (u8*) EVENT_FLAG_FILE_NAME, + 1001 +}; +const struct prog_pos_info EVENT_FLAG_PROG_POS_INFO_COMPARE_SCRIPT_VARIABLES = { + (u8*) EVENT_FLAG_FILE_NAME, + 1044 +}; + +void DebugPrintEventFlagSize() { + Debug_Print0(&EVENT_FLAG_SIZE_DEBUG_MSG, _0209DF70[18], 0x400); +} + void InitScriptVariableValues() { for(s32 sv_id = 0; sv_id < LOCAL_SCRIPT_VAR_OFFSET; sv_id++) { SCRIPT_VARS_VALUES[sv_id] = 0;