PR suggestions, game status macro

This commit is contained in:
Ethan Roseman 2020-09-13 19:03:22 -04:00
parent ddb9f77fc1
commit 44ffd33004
9 changed files with 30 additions and 28 deletions

View File

@ -879,7 +879,7 @@ typedef struct GameStatus {
/* 0x0BA */ s16 bootGreen; /* 0x0BA */ s16 bootGreen;
/* 0x0BC */ s16 bootRed; /* 0x0BC */ s16 bootRed;
/* 0x0BE */ char unk_BE[106]; /* 0x0BE */ char unk_BE[106];
/* 0x128 */ f32 playerTraceNormal[3]; /* 0x128 */ Vec3f playerTraceNormal;
/* 0x134 */ u16 frameCounter; /* 0x134 */ u16 frameCounter;
/* 0x136 */ char unk_136[2]; /* 0x136 */ char unk_136[2];
/* 0x138 */ s32 nextRNG; /* 0x138 */ s32 nextRNG;

View File

@ -9,6 +9,8 @@
#define ASSERT(condition) if (!(condition)) { while (1) {} } #define ASSERT(condition) if (!(condition)) { while (1) {} }
#define GAME_STATUS (*gGameStatusPtr)
#define SQ(x) (x*x) #define SQ(x) (x*x)
#endif #endif

View File

@ -12,7 +12,7 @@ extern ActionState gPlayerActionState;
extern PlayerAnim gPlayerAnimation; extern PlayerAnim gPlayerAnimation;
extern PlayerStatus gPlayerStatus; extern PlayerStatus gPlayerStatus;
extern GameStatus* gGameStatusPtr[1]; extern GameStatus* gGameStatusPtr[1];
extern s32 D_80074410; extern s32 gRandSeed;
extern StaticItem gItemTable[364]; extern StaticItem gItemTable[364];
extern s16 gMainGameState; /* 0 = battle, 1 = pause, 2 = world */ extern s16 gMainGameState; /* 0 = battle, 1 = pause, 2 = world */
extern UNK_FUN_PTR(gCurrentUpdateFunction); extern UNK_FUN_PTR(gCurrentUpdateFunction);

View File

@ -29,12 +29,12 @@ INCLUDE_ASM("code_42e0_len_1f60", _heap_realloc);
INCLUDE_API_ASM("code_42e0_len_1f60", cosine); INCLUDE_API_ASM("code_42e0_len_1f60", cosine);
s32 sign(s32 val) { s32 sign(s32 val) {
s32 ret = -1; s32 sign = -1;
if (val >= 0) { if (val >= 0) {
ret = val > 0; sign = val > 0;
} }
return ret; return sign;
} }
INCLUDE_ASM("code_42e0_len_1f60", int_to_string); INCLUDE_ASM("code_42e0_len_1f60", int_to_string);
@ -58,7 +58,7 @@ INCLUDE_ASM("code_42e0_len_1f60", dma_copy);
INCLUDE_ASM("code_42e0_len_1f60", func_80029860); INCLUDE_ASM("code_42e0_len_1f60", func_80029860);
s32 _advance_rng(void) { s32 _advance_rng(void) {
s32* rngVal = &D_80074410; s32* rngVal = &gRandSeed;
(*gGameStatusPtr)->nextRNG = *rngVal = (*rngVal * 0x5D588B65) + 1; (*gGameStatusPtr)->nextRNG = *rngVal = (*rngVal * 0x5D588B65) + 1;
@ -72,18 +72,18 @@ INCLUDE_ASM("code_42e0_len_1f60", func_80029994);
s32 INCLUDE_ASM("code_42e0_len_1f60", rand_int, s32 arg0); s32 INCLUDE_ASM("code_42e0_len_1f60", rand_int, s32 arg0);
f32 signF(f32 val) { f32 signF(f32 val) {
f32 ret; f32 sign;
if (!(val > 0.0f)) { if (!(val > 0.0f)) {
ret = -1.0f; sign = -1.0f;
if (!(val < 0.0f)) { if (!(val < 0.0f)) {
ret = 0.0f; sign = 0.0f;
} }
} else { } else {
ret = 1.0f; sign = 1.0f;
} }
return ret; return sign;
} }
INCLUDE_API_ASM("code_42e0_len_1f60", round); INCLUDE_API_ASM("code_42e0_len_1f60", round);
@ -104,7 +104,7 @@ f32 get_clamped_angle_diff(f32 a, f32 b) {
f32 INCLUDE_ASM("code_42e0_len_1f60", atan2, f32 startX, f32 startZ, f32 endX, f32 endZ); f32 INCLUDE_ASM("code_42e0_len_1f60", atan2, f32 startX, f32 startZ, f32 endX, f32 endZ);
f32 get_player_normal_yaw(void) { f32 get_player_normal_yaw(void) {
return atan2(0, 0, (*gGameStatusPtr)->playerTraceNormal[0], (*gGameStatusPtr)->playerTraceNormal[2]); return atan2(0, 0, (*gGameStatusPtr)->playerTraceNormal.x, (*gGameStatusPtr)->playerTraceNormal.z);
} }
INCLUDE_ASM("code_42e0_len_1f60", get_player_normal_pitch); INCLUDE_ASM("code_42e0_len_1f60", get_player_normal_pitch);

View File

@ -33,7 +33,7 @@ s32 func_8002ACDC(void) {
} }
s32 heap_malloc(s32 size) { s32 heap_malloc(s32 size) {
if ((*gGameStatusPtr)->isBattle == 0) { if (GAME_STATUS->isBattle == 0) {
return general_heap_malloc(size); return general_heap_malloc(size);
} else { } else {
return _heap_malloc(&D_803DA800, size); return _heap_malloc(&D_803DA800, size);
@ -41,7 +41,7 @@ s32 heap_malloc(s32 size) {
} }
s32 heap_free(s32 size) { s32 heap_free(s32 size) {
if ((*gGameStatusPtr)->isBattle != 0) { if (GAME_STATUS->isBattle != 0) {
return _heap_free(&D_803DA800, size); return _heap_free(&D_803DA800, size);
} else { } else {
return general_heap_free(size); return general_heap_free(size);
@ -56,7 +56,7 @@ s32 collision_heap_create(void) {
} }
s32 collision_heap_malloc(s32 size) { s32 collision_heap_malloc(s32 size) {
if (!(*gGameStatusPtr)->isBattle) { if (!GAME_STATUS->isBattle) {
return _heap_malloc(&D_80268000, size); return _heap_malloc(&D_80268000, size);
} else { } else {
return _heap_malloc(&D_803DA800, size); return _heap_malloc(&D_803DA800, size);
@ -64,7 +64,7 @@ s32 collision_heap_malloc(s32 size) {
} }
s32 collision_heap_free(void* data) { s32 collision_heap_free(void* data) {
if ((*gGameStatusPtr)->isBattle) { if (GAME_STATUS->isBattle) {
return _heap_free(&D_803DA800, data); return _heap_free(&D_803DA800, data);
} else { } else {
return _heap_free(&D_80268000, data); return _heap_free(&D_80268000, data);

View File

@ -2,7 +2,7 @@
void func_80033540(void) { void func_80033540(void) {
D_8009A650[0] |= 8; D_8009A650[0] |= 8;
(*gGameStatusPtr)->loadMenuState = 3; GAME_STATUS->loadMenuState = 3;
} }
INCLUDE_ASM("code_e940_len_290", func_80033568); INCLUDE_ASM("code_e940_len_290", func_80033568);

View File

@ -43,8 +43,8 @@ s16 func_80033830(add_val) {
} }
void func_80033874(void) { void func_80033874(void) {
func_80137D88(0, (*gGameStatusPtr)->bootAlpha); func_80137D88(0, GAME_STATUS->bootAlpha);
func_80137E10(0, (*gGameStatusPtr)->bootBlue, (*gGameStatusPtr)->bootGreen, (*gGameStatusPtr)->bootRed); func_80137E10(0, GAME_STATUS->bootBlue, GAME_STATUS->bootGreen, GAME_STATUS->bootRed);
} }
void start_battle_countdown(void) { void start_battle_countdown(void) {

View File

@ -12,22 +12,22 @@ ApiStatus EnableSpriteShading(ScriptInstance* script, s32 isInitialCall) {
} }
s32 getDemoState(ScriptInstance* script) { s32 getDemoState(ScriptInstance* script) {
set_variable(script, *script->ptrReadPos, (*gGameStatusPtr)->demoState); set_variable(script, *script->ptrReadPos, GAME_STATUS->demoState);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus DemoPressButton(ScriptInstance* script, s32 isInitialCall) { ApiStatus DemoPressButton(ScriptInstance* script, s32 isInitialCall) {
(*gGameStatusPtr)->demoButtonInput |= get_variable(script, *script->ptrReadPos); GAME_STATUS->demoButtonInput |= get_variable(script, *script->ptrReadPos);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus DemoReleaseButton(ScriptInstance* script, s32 isInitialCall) { ApiStatus DemoReleaseButton(ScriptInstance* script, s32 isInitialCall) {
(*gGameStatusPtr)->demoButtonInput &= ~get_variable(script, *script->ptrReadPos); GAME_STATUS->demoButtonInput &= ~get_variable(script, *script->ptrReadPos);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus DemoSetButtons(ScriptInstance* script, s32 isInitialCall) { ApiStatus DemoSetButtons(ScriptInstance* script, s32 isInitialCall) {
(*gGameStatusPtr)->demoButtonInput = get_variable(script, *script->ptrReadPos); GAME_STATUS->demoButtonInput = get_variable(script, *script->ptrReadPos);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
@ -39,8 +39,8 @@ ApiStatus DemoJoystickRadial(ScriptInstance* script, s32 isInitialCall) {
a = get_float_variable(script, *thisPos++); a = get_float_variable(script, *thisPos++);
b = get_float_variable(script, *thisPos++); b = get_float_variable(script, *thisPos++);
(*gGameStatusPtr)->demoStickX = a * sin_deg(b); GAME_STATUS->demoStickX = a * sin_deg(b);
(*gGameStatusPtr)->demoStickY = a * cos_deg(b); GAME_STATUS->demoStickY = a * cos_deg(b);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
@ -53,8 +53,8 @@ ApiStatus DemoJoystickXY(ScriptInstance* script, s32 isInitialCall) {
x = get_float_variable(script, *thisPos++); x = get_float_variable(script, *thisPos++);
y = get_float_variable(script, *thisPos++); y = get_float_variable(script, *thisPos++);
(*gGameStatusPtr)->demoStickX = x; GAME_STATUS->demoStickX = x;
(*gGameStatusPtr)->demoStickY = y; GAME_STATUS->demoStickY = y;
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }

View File

@ -1,5 +1,5 @@
gGameStatusPtr = 0x8007419C; gGameStatusPtr = 0x8007419C;
D_80074410 = 0x80074410; gRandSeed = 0x80074410;
gUIStatus = 0x8010EF58; gUIStatus = 0x8010EF58;
gPlayerData = 0x8010F290; gPlayerData = 0x8010F290;
gPlayerActionState = 0x8010F07C; gPlayerActionState = 0x8010F07C;