diff --git a/asm/nonmatchings/code_1b40_len_20b0/step_game_loop.s b/asm/nonmatchings/code_1b40_len_20b0/step_game_loop.s index ac3dae2a0d..051aef8eee 100644 --- a/asm/nonmatchings/code_1b40_len_20b0/step_game_loop.s +++ b/asm/nonmatchings/code_1b40_len_20b0/step_game_loop.s @@ -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 diff --git a/asm/nonmatchings/code_ebd0_len_6a0/func_80033B54.s b/asm/nonmatchings/code_ebd0_len_6a0/func_80033B54.s index 4e9275d836..ed282abd3e 100644 --- a/asm/nonmatchings/code_ebd0_len_6a0/func_80033B54.s +++ b/asm/nonmatchings/code_ebd0_len_6a0/func_80033B54.s @@ -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 \ No newline at end of file +/* 00EF84 80033B84 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_ebd0_len_6a0/func_80033B88.s b/asm/nonmatchings/code_ebd0_len_6a0/func_80033B88.s index ae57c0d01d..1e7b4ef223 100644 --- a/asm/nonmatchings/code_ebd0_len_6a0/func_80033B88.s +++ b/asm/nonmatchings/code_ebd0_len_6a0/func_80033B88.s @@ -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 \ No newline at end of file +/* 00EFBC 80033BBC 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_ebd0_len_6a0/func_80033BC0.s b/asm/nonmatchings/code_ebd0_len_6a0/func_80033BC0.s index 49825ee7d8..fb3c34c04f 100644 --- a/asm/nonmatchings/code_ebd0_len_6a0/func_80033BC0.s +++ b/asm/nonmatchings/code_ebd0_len_6a0/func_80033BC0.s @@ -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 \ No newline at end of file +/* 00F260 80033E60 27BD0030 */ addiu $sp, $sp, 0x30 diff --git a/asm/nonmatchings/code_ebd0_len_6a0/func_80033E64.s b/asm/nonmatchings/code_ebd0_len_6a0/func_80033E64.s index cefe54b3d1..486722bfbb 100644 --- a/asm/nonmatchings/code_ebd0_len_6a0/func_80033E64.s +++ b/asm/nonmatchings/code_ebd0_len_6a0/func_80033E64.s @@ -5,4 +5,4 @@ glabel func_80033E64 /* 00F264 80033E64 03E00008 */ jr $ra /* 00F268 80033E68 00000000 */ nop -/* 00F26C 80033E6C 00000000 */ nop \ No newline at end of file +/* 00F26C 80033E6C 00000000 */ nop diff --git a/asm/nonmatchings/code_ebd0_len_6a0/step_battle.s b/asm/nonmatchings/code_ebd0_len_6a0/step_battle.s index 4b93670c46..315528a628 100644 --- a/asm/nonmatchings/code_ebd0_len_6a0/step_battle.s +++ b/asm/nonmatchings/code_ebd0_len_6a0/step_battle.s @@ -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 \ No newline at end of file +/* 00EF50 80033B50 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/include/common_structs.h b/include/common_structs.h index 4d20d4f0ab..9d14cb123e 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -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 diff --git a/include/variables.h b/include/variables.h index 1c2fa1a962..49b4c7fa7e 100644 --- a/include/variables.h +++ b/include/variables.h @@ -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; diff --git a/src/code_dbd70_len_700.c b/src/code_dbd70_len_700.c index ad04894c08..7925f5f8b3 100644 --- a/src/code_dbd70_len_700.c +++ b/src/code_dbd70_len_700.c @@ -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); diff --git a/src/code_dd930_len_1c0.c b/src/code_dd930_len_1c0.c index 04de781b40..f69c288ec2 100644 --- a/src/code_dd930_len_1c0.c +++ b/src/code_dd930_len_1c0.c @@ -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) { diff --git a/src/code_ebd0_len_6a0.c b/src/code_ebd0_len_6a0.c index 064fc7efea..3623c77424 100644 --- a/src/code_ebd0_len_6a0.c +++ b/src/code_ebd0_len_6a0.c @@ -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); diff --git a/src/code_fa4c0_len_3bf0.c b/src/code_fa4c0_len_3bf0.c index 89201e5470..0a1fc119fd 100644 --- a/src/code_fa4c0_len_3bf0.c +++ b/src/code_fa4c0_len_3bf0.c @@ -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; } diff --git a/src/code_fe0b0_len_5a0.c b/src/code_fe0b0_len_5a0.c index ed39f1f1a8..64ced8f3ca 100644 --- a/src/code_fe0b0_len_5a0.c +++ b/src/code_fe0b0_len_5a0.c @@ -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; } diff --git a/tools/n64split.yaml b/tools/n64split.yaml index 4a2dc8eead..58f707970e 100644 --- a/tools/n64split.yaml +++ b/tools/n64split.yaml @@ -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"] diff --git a/undefined_syms.txt b/undefined_syms.txt index 1e0c9eb5bc..f5e600a199 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -61,6 +61,11 @@ D_80151328 = 0x80151328; gCurrentDoorSoundsSet = 0x80151340; +gTriggerCount = 0x80151334; +gTriggerList1 = 0x80159190; +gTriggerList2 = 0x80159290; +gCurrentTriggerListPtr = 0x80159390; + D_801595A0 = 0x801595A0; D_8015C7C0 = 0x8015C7C0;