rename gGameStatus and add INCLUDE_ASM macro

This commit is contained in:
dark-samus 2020-07-19 00:15:50 -04:00
parent dd36e2bf12
commit 9d777793c7
6 changed files with 25 additions and 29 deletions

View File

@ -5,5 +5,6 @@
#include "common_structs.h" #include "common_structs.h"
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include "macros.h"
#endif #endif

View File

@ -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

View File

@ -4,7 +4,7 @@
#include "ultra64.h" #include "ultra64.h"
#include "common_structs.h" #include "common_structs.h"
extern game_status* gGameStatus[1]; extern game_status* gGameStatusPtr[1];
extern s16* D_80151328; extern s16* D_80151328;
#endif #endif

View File

@ -14,14 +14,6 @@ void func_80147230(void) {
D_8015C7C0 = D_8014F140; D_8015C7C0 = D_8014F140;
} }
void __attribute__((naked)) UpdateMusicPlayers(void) { INCLUDE_ASM(code_dd930_len_1c0, UpdateMusicPlayers);
__asm__(
".include \"asm/code_dd930_len_1c0/UpdateMusicPlayers.s\"\n"
);
}
void __attribute__((naked)) play_ambient_sounds(void) { INCLUDE_ASM(code_dd930_len_1c0, play_ambient_sounds);
__asm__(
".include \"asm/code_dd930_len_1c0/play_ambient_sounds.s\"\n"
);
}

View File

@ -1,10 +1,6 @@
#include "common.h" #include "common.h"
void __attribute__((naked)) SetSpriteShading(void) { INCLUDE_ASM(code_fe0b0_len_5a0, SetSpriteShading);
__asm__(
".include \"asm/code_fe0b0_len_5a0/SetSpriteShading.s\"\n"
);
}
s32 EnableSpriteShading(ScriptContext* script) { s32 EnableSpriteShading(ScriptContext* script) {
if (get_variable(script, *script->ptrReadPos) != 0) { if (get_variable(script, *script->ptrReadPos) != 0) {
@ -16,49 +12,49 @@ s32 EnableSpriteShading(ScriptContext* script) {
} }
s32 getDemoState(ScriptContext* script) { s32 getDemoState(ScriptContext* script) {
set_variable(script, *script->ptrReadPos, (*gGameStatus)->demoState); set_variable(script, *script->ptrReadPos, (*gGameStatusPtr)->demoState);
return 2; return 2;
} }
s32 DemoPressButton(ScriptContext* script) { s32 DemoPressButton(ScriptContext* script) {
(*gGameStatus)->demoButtonInput |= get_variable(script, *script->ptrReadPos); (*gGameStatusPtr)->demoButtonInput |= get_variable(script, *script->ptrReadPos);
return 2; return 2;
} }
s32 DemoReleaseButton(ScriptContext* script) { s32 DemoReleaseButton(ScriptContext* script) {
(*gGameStatus)->demoButtonInput &= ~get_variable(script, *script->ptrReadPos); (*gGameStatusPtr)->demoButtonInput &= ~get_variable(script, *script->ptrReadPos);
return 2; return 2;
} }
s32 DemoSetButtons(ScriptContext* script) { s32 DemoSetButtons(ScriptContext* script) {
(*gGameStatus)->demoButtonInput = get_variable(script, *script->ptrReadPos); (*gGameStatusPtr)->demoButtonInput = get_variable(script, *script->ptrReadPos);
return 2; return 2;
} }
s32 DemoJoystickRadial(ScriptContext* script) { s32 DemoJoystickRadial(ScriptContext* script) {
float a; f32 a;
float b; f32 b;
s32* thisPos = script->ptrReadPos; s32* thisPos = script->ptrReadPos;
a = get_float_variable(script, *thisPos++); a = get_float_variable(script, *thisPos++);
b = get_float_variable(script, *thisPos++); b = get_float_variable(script, *thisPos++);
(*gGameStatus)->demoStickX = a * sin_deg(b); (*gGameStatusPtr)->demoStickX = a * sin_deg(b);
(*gGameStatus)->demoStickY = a * cos_deg(b); (*gGameStatusPtr)->demoStickY = a * cos_deg(b);
return 2; return 2;
} }
s32 DemoJoystickXY(ScriptContext* script) { s32 DemoJoystickXY(ScriptContext* script) {
float a; f32 a;
float b; f32 b;
s32* thisPos = script->ptrReadPos; s32* thisPos = script->ptrReadPos;
a = get_float_variable(script, *thisPos++); a = get_float_variable(script, *thisPos++);
b = get_float_variable(script, *thisPos++); b = get_float_variable(script, *thisPos++);
(*gGameStatus)->demoStickX = a; (*gGameStatusPtr)->demoStickX = a;
(*gGameStatus)->demoStickY = b; (*gGameStatusPtr)->demoStickY = b;
return 2; return 2;
} }

View File

@ -4,7 +4,7 @@ D_00316C00 = 0x00316C00;
D_00316D90 = 0x00316D90; D_00316D90 = 0x00316D90;
D_00316F30 = 0x00316F30; D_00316F30 = 0x00316F30;
gGameStatus = 0x8007419C; gGameStatusPtr = 0x8007419C;
D_8014F140 = 0x8014F140; D_8014F140 = 0x8014F140;
D_80151328 = 0x80151328; D_80151328 = 0x80151328;