Cleanup, starting trigger functions

This commit is contained in:
Ethan Roseman 2020-08-13 01:03:47 -04:00
parent d0c65a6e14
commit 7d5c31a6e6
15 changed files with 81 additions and 27 deletions

View File

@ -62,7 +62,7 @@ glabel step_game_loop
/* 001C18 80026818 00000000 */ nop
/* 001C1C 8002681C 0C052952 */ jal func_8014A548
/* 001C20 80026820 00000000 */ nop
/* 001C24 80026824 0C051C99 */ jal UpdateMusicPlayers
/* 001C24 80026824 0C051C99 */ jal update_music_players
/* 001C28 80026828 00000000 */ nop
/* 001C2C 8002682C 0C0525CD */ jal func_80149734
/* 001C30 80026830 00000000 */ nop

View File

@ -15,4 +15,4 @@ glabel func_80033B54
.L80033B7C:
/* 00EF7C 80033B7C 8FBF0010 */ lw $ra, 0x10($sp)
/* 00EF80 80033B80 03E00008 */ jr $ra
/* 00EF84 80033B84 27BD0018 */ addiu $sp, $sp, 0x18
/* 00EF84 80033B84 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -15,4 +15,4 @@ glabel func_80033B88
/* 00EFB0 80033BB0 3C01800A */ lui $at, 0x800a
/* 00EFB4 80033BB4 A0220900 */ sb $v0, 0x900($at)
/* 00EFB8 80033BB8 03E00008 */ jr $ra
/* 00EFBC 80033BBC 27BD0018 */ addiu $sp, $sp, 0x18
/* 00EFBC 80033BBC 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -180,4 +180,4 @@ glabel func_80033BC0
/* 00F254 80033E54 8FB1001C */ lw $s1, 0x1c($sp)
/* 00F258 80033E58 8FB00018 */ lw $s0, 0x18($sp)
/* 00F25C 80033E5C 03E00008 */ jr $ra
/* 00F260 80033E60 27BD0030 */ addiu $sp, $sp, 0x30
/* 00F260 80033E60 27BD0030 */ addiu $sp, $sp, 0x30

View File

@ -5,4 +5,4 @@ glabel func_80033E64
/* 00F264 80033E64 03E00008 */ jr $ra
/* 00F268 80033E68 00000000 */ nop
/* 00F26C 80033E6C 00000000 */ nop
/* 00F26C 80033E6C 00000000 */ nop

View File

@ -165,4 +165,4 @@ glabel step_battle
/* 00EF44 80033B44 8FBF0014 */ lw $ra, 0x14($sp)
/* 00EF48 80033B48 8FB00010 */ lw $s0, 0x10($sp)
/* 00EF4C 80033B4C 03E00008 */ jr $ra
/* 00EF50 80033B50 27BD0018 */ addiu $sp, $sp, 0x18
/* 00EF50 80033B50 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -491,4 +491,22 @@ typedef struct {
/* 0x0E */ u16 height;
} bg_header; // size = 0x10
typedef struct {
/* 0x00 */ s16 genericFlagIndex;
/* 0x02 */ s16 field_0x2;
/* 0x04 */ s16 crateFlagIndex;
/* 0x06 */ s16 panelFlagIndex;
/* 0x08 */ s32 colliderID;
/* 0x0C */ UNK_FUN_PTR(functionHandler);
/* 0x10 */ UNK_PTR scriptStart;
/* 0x14 */ script_context* runningScript;
/* 0x18 */ s32 priority;
/* 0x1C */ s32 scriptVars[3];
/* 0x28 */ s32 unk_28;
/* 0x2C */ s32 unk_2C;
/* 0x30 */ s8 unk_30;
/* 0x31 */ char unk_31[3];
/* 0x34 */ s32 runningScriptID;
} trigger; // size = 0x38
#endif

View File

@ -17,6 +17,12 @@ extern s16 D_8010CD12;
extern s32 D_801595A0;
extern s8 D_8014F12F;
// Triggers
/* 0x80151334 */ extern s16 gTriggerCount;
/* 0x80159190 */ extern trigger gTriggerList1[64];
/* 0x80159290 */ extern trigger gTriggerList2[64];
/* 0x80159390 */ extern trigger** gCurrentTriggerListPtr[64];
extern u16 gMapTransitionAlpha;
extern u16 D_800A0942;
extern s16 D_800A0944;
@ -30,8 +36,6 @@ extern s32 D_8009A650[1];
extern s16 gCurrentDoorSoundsSet;
extern UNK_TYPE D_800E92D8;
extern UNK_TYPE D_80147474;
extern UNK_TYPE D_80147574;

View File

@ -1,19 +1,48 @@
#include "common.h"
INCLUDE_ASM(code_dbd70_len_700, default_trigger_function_handler);
void default_trigger_function_handler(s32* arg0) {
arg0[0] |= 2;
}
INCLUDE_ASM(code_dbd70_len_700, clear_trigger_data);
INCLUDE_ASM(code_dbd70_len_700, init_trigger_list);
//INCLUDE_ASM(code_dbd70_len_700, init_trigger_list);
void init_trigger_list(void) {
if ((*gGameStatusPtr)->unk_70 == 0) {
*gCurrentTriggerListPtr = gTriggerList1;
} else {
*gCurrentTriggerListPtr = gTriggerList2;
}
gTriggerCount = 0;
}
INCLUDE_ASM(code_dbd70_len_700, create_trigger);
INCLUDE_ASM(code_dbd70_len_700, update_triggers);
INCLUDE_ASM(code_dbd70_len_700, delete_trigger);
void delete_trigger(trigger* toDelete) {
s32 i;
for (i = 0; i < ARRAY_COUNT(gCurrentTriggerListPtr); i++) {
if ((*gCurrentTriggerListPtr)[i] == toDelete) {
break;
}
}
if (i < ARRAY_COUNT(gCurrentTriggerListPtr)) {
heap_free((*gCurrentTriggerListPtr)[i]);
(*gCurrentTriggerListPtr)[i] = NULL;
}
}
INCLUDE_ASM(code_dbd70_len_700, is_trigger_bound);
INCLUDE_ASM(code_dbd70_len_700, get_trigger_by_id);
//INCLUDE_ASM(code_dbd70_len_700, get_trigger_by_id);
trigger* get_trigger_by_id(s32 triggerID) {
return (*gCurrentTriggerListPtr)[triggerID];
}
INCLUDE_ASM(code_dbd70_len_700, func_80145CE8);

View File

@ -15,7 +15,7 @@ void func_80147230(void) {
D_8015C7C0 = D_8014F140;
}
void UpdateMusicPlayers(void) {
void update_music_players(void) {
struct_80147230* temp = &D_8015C7C0;
switch (temp->unk2) {

View File

@ -33,7 +33,7 @@ s16 func_80033830(add_val) {
if (gameStatus->boot_alpha != 0xFF) {
gameStatus->boot_alpha += add_val;
if ((gameStatus->boot_alpha >= 0x100)) {
if ((gameStatus->boot_alpha > 0xFF)) {
gameStatus->boot_alpha = 0xFF;
}
} else {
@ -44,16 +44,14 @@ s16 func_80033830(add_val) {
void func_80033874(void) {
func_80137D88(0, (*gGameStatusPtr)->boot_alpha);
func_80137E10(0, (*gGameStatusPtr)->boot_blue, (*gGameStatusPtr)->boot_green, (*gGameStatusPtr)->boot_red);
}
s8 start_battle_countdown(void) {
void start_battle_countdown(void) {
D_800A0900 = 5;
}
INCLUDE_ASM(code_ebd0_len_6a0, step_battle);
INCLUDE_ASM(code_ebd0_len_6a0, func_80033B54);
INCLUDE_ASM(code_ebd0_len_6a0, func_80033B88);

View File

@ -119,7 +119,7 @@ s32 AddKeyItem(script_context* script, s32 initialCall) {
return 2;
}
for (i=0; i < ARRAY_COUNT(playerData->keyItems); i++) {
for (i = 0; i < ARRAY_COUNT(playerData->keyItems); i++) {
if (playerData->keyItems[i] == 0) {
break;
}
@ -146,7 +146,7 @@ s32 HasKeyItem(script_context* script, s32 initialCall) {
player_data* playerData = &gPlayerData;
s32 i;
for(i=0; i < ARRAY_COUNT(playerData->keyItems); i++) {
for(i = 0; i < ARRAY_COUNT(playerData->keyItems); i++) {
if (playerData->keyItems[i] == itemID) {
break;
}
@ -163,7 +163,7 @@ s32 FindKeyItem(script_context* script, s32 initialCall) {
s32 i;
s32 itemIndex;
for(i=0; i < ARRAY_COUNT(playerData->keyItems); i++) {
for(i = 0; i < ARRAY_COUNT(playerData->keyItems); i++) {
if (playerData->keyItems[i] == itemID) {
break;
}

View File

@ -46,15 +46,15 @@ s32 DemoJoystickRadial(script_context* script) {
}
s32 DemoJoystickXY(script_context* script) {
f32 a;
f32 b;
f32 x;
f32 y;
s32* thisPos = script->ptrReadPos;
a = get_float_variable(script, *thisPos++);
b = get_float_variable(script, *thisPos++);
x = get_float_variable(script, *thisPos++);
y = get_float_variable(script, *thisPos++);
(*gGameStatusPtr)->demoStickX = a;
(*gGameStatusPtr)->demoStickY = b;
(*gGameStatusPtr)->demoStickX = x;
(*gGameStatusPtr)->demoStickY = y;
return 2;
}

View File

@ -1411,7 +1411,7 @@ labels:
- [0x80145D70, "load_map_bg"]
- [0x80145E28, "read_background_size"]
- [0x80145E70, "set_background_size"]
- [0x80147264, "UpdateMusicPlayers"]
- [0x80147264, "update_music_players"]
- [0x80149AB8, "_play_sound"]
- [0x80149C6C, "stop_sound"]
- [0x80149CB4, "play_sound"]

View File

@ -61,6 +61,11 @@ D_80151328 = 0x80151328;
gCurrentDoorSoundsSet = 0x80151340;
gTriggerCount = 0x80151334;
gTriggerList1 = 0x80159190;
gTriggerList2 = 0x80159290;
gCurrentTriggerListPtr = 0x80159390;
D_801595A0 = 0x801595A0;
D_8015C7C0 = 0x8015C7C0;