diff --git a/papermario/include/common.h b/papermario/include/common.h index e79998eade..32247c2e4e 100644 --- a/papermario/include/common.h +++ b/papermario/include/common.h @@ -5,5 +5,6 @@ #include "common_structs.h" #include "functions.h" #include "variables.h" +#include "macros.h" #endif diff --git a/papermario/include/macros.h b/papermario/include/macros.h new file mode 100644 index 0000000000..cd12a6fcc9 --- /dev/null +++ b/papermario/include/macros.h @@ -0,0 +1,7 @@ +#ifndef _MACROS_H_ +#define _MACROS_H_ + +#define INCLUDE_ASM(FOLDER, NAME) \ + void __attribute__((naked)) NAME(void) { __asm__( ".include \"asm/"#FOLDER"/"#NAME".s\"\n"); } + +#endif \ No newline at end of file diff --git a/papermario/include/variables.h b/papermario/include/variables.h index feedcf7897..fbb7623a33 100644 --- a/papermario/include/variables.h +++ b/papermario/include/variables.h @@ -4,7 +4,7 @@ #include "ultra64.h" #include "common_structs.h" -extern game_status* gGameStatus[1]; +extern game_status* gGameStatusPtr[1]; extern s16* D_80151328; #endif diff --git a/papermario/src/code_dd930_len_1c0.c b/papermario/src/code_dd930_len_1c0.c index 8962b8d189..b274791efb 100644 --- a/papermario/src/code_dd930_len_1c0.c +++ b/papermario/src/code_dd930_len_1c0.c @@ -14,14 +14,6 @@ void func_80147230(void) { D_8015C7C0 = D_8014F140; } -void __attribute__((naked)) UpdateMusicPlayers(void) { - __asm__( - ".include \"asm/code_dd930_len_1c0/UpdateMusicPlayers.s\"\n" - ); -} +INCLUDE_ASM(code_dd930_len_1c0, UpdateMusicPlayers); -void __attribute__((naked)) play_ambient_sounds(void) { - __asm__( - ".include \"asm/code_dd930_len_1c0/play_ambient_sounds.s\"\n" - ); -} +INCLUDE_ASM(code_dd930_len_1c0, play_ambient_sounds); \ No newline at end of file diff --git a/papermario/src/code_fe0b0_len_5a0.c b/papermario/src/code_fe0b0_len_5a0.c index 6c638ff5db..8567a8c5ca 100644 --- a/papermario/src/code_fe0b0_len_5a0.c +++ b/papermario/src/code_fe0b0_len_5a0.c @@ -1,10 +1,6 @@ #include "common.h" -void __attribute__((naked)) SetSpriteShading(void) { - __asm__( -".include \"asm/code_fe0b0_len_5a0/SetSpriteShading.s\"\n" - ); -} +INCLUDE_ASM(code_fe0b0_len_5a0, SetSpriteShading); s32 EnableSpriteShading(ScriptContext* script) { if (get_variable(script, *script->ptrReadPos) != 0) { @@ -16,49 +12,49 @@ s32 EnableSpriteShading(ScriptContext* script) { } s32 getDemoState(ScriptContext* script) { - set_variable(script, *script->ptrReadPos, (*gGameStatus)->demoState); + set_variable(script, *script->ptrReadPos, (*gGameStatusPtr)->demoState); return 2; } s32 DemoPressButton(ScriptContext* script) { - (*gGameStatus)->demoButtonInput |= get_variable(script, *script->ptrReadPos); + (*gGameStatusPtr)->demoButtonInput |= get_variable(script, *script->ptrReadPos); return 2; } s32 DemoReleaseButton(ScriptContext* script) { - (*gGameStatus)->demoButtonInput &= ~get_variable(script, *script->ptrReadPos); + (*gGameStatusPtr)->demoButtonInput &= ~get_variable(script, *script->ptrReadPos); return 2; } s32 DemoSetButtons(ScriptContext* script) { - (*gGameStatus)->demoButtonInput = get_variable(script, *script->ptrReadPos); + (*gGameStatusPtr)->demoButtonInput = get_variable(script, *script->ptrReadPos); return 2; } s32 DemoJoystickRadial(ScriptContext* script) { - float a; - float b; + f32 a; + f32 b; s32* thisPos = script->ptrReadPos; a = get_float_variable(script, *thisPos++); b = get_float_variable(script, *thisPos++); - (*gGameStatus)->demoStickX = a * sin_deg(b); - (*gGameStatus)->demoStickY = a * cos_deg(b); + (*gGameStatusPtr)->demoStickX = a * sin_deg(b); + (*gGameStatusPtr)->demoStickY = a * cos_deg(b); return 2; } s32 DemoJoystickXY(ScriptContext* script) { - float a; - float b; + f32 a; + f32 b; s32* thisPos = script->ptrReadPos; a = get_float_variable(script, *thisPos++); b = get_float_variable(script, *thisPos++); - (*gGameStatus)->demoStickX = a; - (*gGameStatus)->demoStickY = b; + (*gGameStatusPtr)->demoStickX = a; + (*gGameStatusPtr)->demoStickY = b; return 2; } diff --git a/papermario/undefined_syms.txt b/papermario/undefined_syms.txt index 761f756401..734c2bba98 100644 --- a/papermario/undefined_syms.txt +++ b/papermario/undefined_syms.txt @@ -4,7 +4,7 @@ D_00316C00 = 0x00316C00; D_00316D90 = 0x00316D90; D_00316F30 = 0x00316F30; -gGameStatus = 0x8007419C; +gGameStatusPtr = 0x8007419C; D_8014F140 = 0x8014F140; D_80151328 = 0x80151328;