From a9311e94c9280cf9c61e45fe41bbaa93975b778b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 13 Nov 2021 14:49:57 +1100 Subject: [PATCH 01/17] Introduce bgms --- include/bgm.h | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/include/bgm.h b/include/bgm.h index 4cd19c957..1dc9acdc3 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,4 +3,133 @@ #define NA_BGM_STOP 0x100000FF +#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects +#define NA_BGM_NATURE_AMBIENCE 0x01 +#define NA_BGM_FIELD 0x02 // Termina Field +#define NA_BGM_CHASE 0x03 // Forest Chase +#define NA_BGM_STALKID 0x04 // Majora's Theme +#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower +#define NA_BGM_RUIN_DUNGEON_FRONT 0x06 // Stone Tower Temple +#define NA_BGM_RUIN_DUNGEON_REVERSE 0x07 // Stone Tower Temple Inverted +#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 +#define NA_BGM_FAILURE_1 0x09 // Title +#define NA_BGM_OMENYA 0x0A // Mask Salesman +#define NA_BGM_DEMO_CURE 0x0B // Song of Healing +#define NA_BGM_DAMP_AREA 0x0C // Southern Swamp +#define NA_BGM_UFO 0x0D // Ghost Attack +#define NA_BGM_JUNGLE_CREWS 0x0E // Mini Game +#define NA_BGM_SHARP 0x0F // Sharp's Curse +#define NA_BGM_SEA_AREA 0x10 // Great Bay Coast +#define NA_BGM_IKANA_AREA 0x11 // Ikana Valley +#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King +#define NA_BGM_SNOW_AREA 0x13 // Mountain Village +#define NA_BGM_PIRATE_AREA 0x14 // Pirates' Fortress +#define NA_BGM_DUMMY_21 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D +#define NA_BGM_DUMMY_22 0x16 // Clock Town Day 2 This song's filename is dummied out in MM3D +#define NA_BGM_DUMMY_23 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D +#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain +#define NA_BGM_EVENT_CLEAR 0x19 // Event Clear +#define NA_BGM_ENEMY 0x1A // Battle +#define NA_BGM_BOSS 0x1B // Boss Battle +#define NA_BGM_JUNGLE_DUNGEON 0x1C // Woodfall Temple +#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ +#define NA_BGM_OPENING 0x1E // Forest Ambush +#define NA_BGM_LINK_HOUSE 0x1F // House +#define NA_BGM_GAME_OVER 0x20 // Game Over +#define NA_BGM_BOSS_CLEAR 0x21 // Boss Clear +#define NA_BGM_ITEM_GET 0x22 // Item Catch +#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_HEART_GET 0x24 // Complete a Heart Piece +#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_GORON_RACE 0x26 // Goron Race +#define NA_BGM_ORGEL_HOUSE 0x27 // Music Box House +#define NA_BGM_GODESS 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_HIME 0x29 // Zelda's Lullaby +#define NA_BGM_SISTER_DANCER 0x2A // Rosa Sisters' Dance +#define NA_BGM_OPEN_TRE_BOX 0x2B // Open Chest +#define NA_BGM_DRUGSTORE 0x2C // Marine Research Laboratory +#define NA_BGM_KYOJIN_ROOM 0x2D // The Four Giants +#define NA_BGM_FUSHA 0x2E // Guru-Guru's Song +#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" +#define NA_BGM_GORON 0x30 // Goron Village +#define NA_BGM_MEETING 0x31 // Mayor Dotour +#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song +#define NA_BGM_OCA_SUN 0x33 // Ocarina Sun's Song +#define NA_BGM_OCA_TIME_NORMAL 0x34 // Ocarina Song of Time +#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms +#define NA_BGM_ZORA 0x36 // Zora Hall +#define NA_BGM_MASK_GET 0x37 // A New Mask +#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" +#define NA_BGM_S_ITEM_GET 0x39 // Small Item Catch +#define NA_BGM_TENMONDAI 0x3A // Astral Observatory +#define NA_BGM_NORMAL_DUNGEON 0x3B // Clock Town Cavern +#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte +#define NA_BGM_APPEAR 0x3D // Meet Zelda (OoT) +#define NA_BGM_MAYOIMORI 0x3E // Woods of Mystery +#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal +#define NA_BGM_HORSE 0x40 // Gorman Race +#define NA_BGM_HORSE_GOAL 0x41 // Race Finish +#define NA_BGM_INGO 0x42 // Gorman Bros. +#define NA_BGM_KOTAKE_KOUME 0x43 // Kotake's Potion Shop +#define NA_BGM_SHOP 0x44 // Store +#define NA_BGM_OWL 0x45 // Gaebora's Theme +#define NA_BGM_MINI_GAME 0x46 // Target Practice +#define NA_BGM_OCA_BIGWING 0x47 // Ocarina Song of Soaring +#define NA_BGM_OCA_CURE 0x48 // Ocarina Song of Healing +#define NA_BGM_TIME_SPEED 0x49 // Inverted Song of Time +#define NA_BGM_TIME_JUMP 0x4A // Song of Double Time +#define NA_BGM_DEMO_AWAKING 0x4B // Sonata of Awakening +#define NA_BGM_DEMO_LULLABY 0x4C // Goron Lullaby +#define NA_BGM_DEMO_TIDE 0x4D // New Wave Bossa Nova +#define NA_BGM_DEMO_SHELL 0x4E // Elegy of Emptiness +#define NA_BGM_DEMO_PLEDGE 0x4F // Oath to Order +#define NA_BGM_EXERCISE_HALL 0x50 // Sword Training +#define NA_BGM_DEMO_LULLABY_HALF 0x51 // Ocarina Goron Lullaby Intro +#define NA_BGM_OCA_YOUSEI 0x52 // New Song +#define NA_BGM_FACEMASK 0x53 // Bremen March +#define NA_BGM_QUARTET 0x54 // Ballad of the Wind Fish +#define NA_BGM_WING_WARP 0x55 // Song of Soaring +#define NA_BGM_MILK_BAR_DUMMY 0x56 // Milk Bar Latte Duplicate. +#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" +#define NA_BGM_MIKAU_LIFF 0x58 // Mikau's Tale +#define NA_BGM_MIKAU_FIN 0x59 // A single guitar chord. +#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song +#define NA_BGM_OCA_AWAKING 0x5B // Ocarina Sonata of Awakening +#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby +#define NA_BGM_OCA_TIDE 0x5D // Ocarina New Wave Bossa Nova +#define NA_BGM_OCA_SHELL 0x5E // Ocarina Elegy of Emptiness +#define NA_BGM_OCA_PLEDGE 0x5F // Ocarina Oath to Order +#define NA_BGM_LAST_DUNGEON 0x60 // +#define NA_BGM_OCA_LULLABY_HALF 0x61 // +#define NA_BGM_OCA_SESSION 0x62 // Bass and Guitar Session +#define NA_BGM_DEMO_SESSION 0x63 // Piano Solo +#define NA_BGM_ALLPART_SESSION 0x64 // The Indigo-Go's Rehearsal +#define NA_BGM_SILVER_DUNGEON 0x65 // Snowhead Temple +#define NA_BGM_DEEPBLUE_DUNGEON 0x66 // Great Bay Temple +#define NA_BGM_DEMO_TIDE_SAX 0x67 // +#define NA_BGM_DEMO_TIDE_VOCAL 0x68 // +#define NA_BGM_MUJURA_1 0x69 // Majora's Wrath +#define NA_BGM_MUJURA_2 0x6A // Majora's Incarnation +#define NA_BGM_MUJURA_3 0x6B // Majora's Mask Battle +#define NA_BGM_BASS_PLAY 0x6C // Bass Practice +#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice +#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice +#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle +#define NA_BGM_GATHERING 0x70 // Calling the Four Giants +#define NA_BGM_CAMARO_DANCE 0x71 // Kamaro's Dance +#define NA_BGM_DONKEY_CART 0x72 // Cremia's Carriage +#define NA_BGM_QUIZ 0x73 // Keaton +#define NA_BGM_END_DEMO 0x74 // The End/Credits I +#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. +#define NA_BGM_TITLE 0x76 // Title Screen +#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall +#define NA_BGM_PURIFICATION_0 0x78 // Woodfall Clear +#define NA_BGM_PURIFICATION_1 0x79 // Snowhead Clear +#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon +#define NA_BGM_GOODBYE_GIANT 0x7C // +#define NA_BGM_CHAT 0x7D // Tatl and Tael +#define NA_BGM_MOON_VANISH 0x7E // Moon's Destruction +#define NA_BGM_STAFFROLL2 0x7F // The End/Credits II +#define NA_BGM_DISABLED 0xFFFF + #endif From 85b280f68aacfcd8d5ec3f269eaf4fc0c2131c08 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 13 Nov 2021 15:03:26 +1100 Subject: [PATCH 02/17] Fill in bgm enums --- include/functions.h | 12 ++++++------ src/code/code_8019AF00.c | 2 +- src/code/z_game_over.c | 2 +- src/code/z_scene.c | 2 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 4 ++-- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 4 ++-- src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c | 4 ++-- src/overlays/actors/ovl_En_Elforg/z_en_elforg.c | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c | 4 ++-- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 6 +++--- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 2 +- src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 2 +- src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c | 2 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 8 ++++---- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 4 ++-- src/overlays/actors/ovl_En_Suttari/z_en_suttari.c | 2 +- .../actors/ovl_En_Syateki_Man/z_en_syateki_man.c | 2 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 6 +++--- tools/disasm/functions.txt | 2 +- tools/sizes/code_functions.csv | 2 +- 21 files changed, 38 insertions(+), 38 deletions(-) diff --git a/include/functions.h b/include/functions.h index 1102363d5..039303645 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3895,10 +3895,10 @@ void func_801A0204(UNK_TYPE); // void func_801A1904(void); // void func_801A1A10(void); // void func_801A1A8C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -void func_801A1D44(Vec3f* vec, UNK_TYPE arg1, f32 arg2); -void func_801A1DB8(Vec3f* vec, UNK_TYPE arg1, f32 arg2); +void func_801A1D44(Vec3f* vec, u8 seqId, f32 arg2); +void func_801A1DB8(Vec3f* vec, u8 seqId, f32 arg2); // void func_801A1E0C(void); -void func_801A1F00(s32 arg0, s32 arg1); +void func_801A1F00(u8 arg0, u16 seqId); void func_801A1F88(void); // void func_801A1FB4(void); // void func_801A2090(void); @@ -3916,15 +3916,15 @@ void func_801A2C20(void); // void func_801A2C44(void); // void func_801A2C88(void); // void func_801A2D54(void); -s32 func_801A2DE0(UNK_TYPE4 arg1); +s32 Audio_IsSequencePlaying(u8 seqId); void func_801A2E54(s32 param_1); void func_801A2ED8(void); // void func_801A2F88(void); // void func_801A3000(void); // void func_801A3038(void); -void func_801A3098(u16 arg0); +void func_801A3098(u16 seqId); // void func_801A312C(void); -void func_801A31EC(UNK_TYPE1 arg1, UNK_TYPE4 arg2, u8 arg3); +void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); // void func_801A3238(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); // void func_801A32CC(void); // void func_801A3590(void); diff --git a/src/code/code_8019AF00.c b/src/code/code_8019AF00.c index 8f0d129ad..32934a82c 100644 --- a/src/code/code_8019AF00.c +++ b/src/code/code_8019AF00.c @@ -296,7 +296,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2D54.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2DE0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2E54.s") diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index c510c1974..edbf79ed7 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -66,7 +66,7 @@ void GameOver_Update(GlobalContext* globalCtx) { gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND; break; case GAMEOVER_DEATH_FADE_OUT: - if (func_801A8A50(1) != 32) { + if (func_801A8A50(1) != NA_BGM_GAME_OVER) { func_80169F78(globalCtx); if (gSaveContext.respawnFlag != -7) { gSaveContext.respawnFlag = -6; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index dd158ac07..406685f85 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -449,7 +449,7 @@ void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->soundCtx.seqIndex = cmd->soundSettings.musicSeq; globalCtx->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX; - if (gSaveContext.seqIndex == 0xFF || func_801A8A50(0) == 0x57) { + if (gSaveContext.seqIndex == 0xFF || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { audio_setBGM(cmd->soundSettings.bgmId); } } diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 6b3c944f4..dc7f3639a 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1005,7 +1005,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { } if (spB0->unk_0144 >= 10) { - Audio_QueueSeqCmd(0x8021); + Audio_QueueSeqCmd(NA_BGM_BOSS_CLEAR | 0x8000); } Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); @@ -1342,7 +1342,7 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { if (D_809E0430 != 0) { D_809E0430--; if (D_809E0430 == 0) { - Audio_QueueSeqCmd(0x801B); + Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); } } } diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index 42ac8d510..b11647ddf 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -449,7 +449,7 @@ void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SpawnCutsceneStage7(EnBigpo* this) { this->idleTimer = 15; if (this->unkBool204 == false) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); this->unkBool204 = true; } this->actionFunc = EnBigpo_SpawnCutsceneStage8; @@ -535,7 +535,7 @@ void EnBigpo_WarpingIn(EnBigpo* this, GlobalContext* globalCtx) { if (this->idleTimer == 32) { this->mainColor.a = 255; // fully visible if (this->unkBool204 == false) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); this->unkBool204 = true; } EnBigpo_SetupIdleFlying(this); diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index a73f5423f..bf0f977b7 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -528,7 +528,7 @@ void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, 10.0f); this->unk_290++; if (this->unk_290 == 10) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); } sp28.x = this->actor.world.pos.x; @@ -547,7 +547,7 @@ void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { void func_8089B4A4(EnDinofos* this) { if (this->unk_290 < 10) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); } Animation_PlayOnce(&this->skelAnime, &D_0600C974); this->unk_2BC.x = (Math_SinS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.x; diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 644f2fedb..e1b71acb2 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -464,7 +464,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { gSaveContext.inventory.strayFairies[gSaveContext.unk_48C8]++; func_801518B0(globalCtx, 0x11, NULL); if (gSaveContext.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { - func_801A3098(0x922); + func_801A3098(NA_BGM_ITEM_GET | 0x900); } } } diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 550a54f62..7a0386183 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -804,7 +804,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { func_801A2C20(); gSaveContext.unk_3DE0[4] = 0; gSaveContext.unk_3DD0[4] = 5; - func_801A3098(0x922); + func_801A3098(NA_BGM_ITEM_GET | 0x900); func_8011B4E0(globalCtx, 1); this->unk_54A = 3; func_809632D0(this); diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index 71e0c8cd0..252b1e973 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -339,12 +339,12 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 2) { if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) { - func_801A1DB8(&this->actor.projectedPos, 0x2E, 540.0f); + func_801A1DB8(&this->actor.projectedPos, NA_BGM_FUSHA, 540.0f); } return; } if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 200.0f) { - func_801A1D44(&this->actor.projectedPos, 0x2E, 540.0f); + func_801A1D44(&this->actor.projectedPos, NA_BGM_FUSHA, 540.0f); } if (this->unusedTimer != 0) { this->unusedTimer--; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 42b9a6c91..15eed7e02 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1699,7 +1699,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { } else { func_80B454BC(this, globalCtx); func_80B452EC(this, globalCtx); - Audio_QueueSeqCmd(0x800D); + Audio_QueueSeqCmd(NA_BGM_UFO | 0x8000); func_80B46F88(this); } } else if (D_80B4E940 == 3) { @@ -1987,7 +1987,7 @@ void func_80B46EE8(EnInvadepoh* this, GlobalContext* globalCtx) { this->actionTimer--; if (this->actionTimer <= 0) { ActorCutscene_Stop(D_80B50404[0]); - Audio_QueueSeqCmd(0x800D); + Audio_QueueSeqCmd(NA_BGM_UFO | 0x8000); func_80B46F88(this); } } @@ -2036,7 +2036,7 @@ void func_80B470E0(EnInvadepoh* this) { void func_80B47108(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->actionTimer == 100) { - func_801A3098(0x19); + func_801A3098(NA_BGM_EVENT_CLEAR); } this->actionTimer--; if (this->actionTimer <= 0) { diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index eca46a8e8..92908ac6d 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -751,7 +751,7 @@ void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[0x8] &= (u8)~0x01; this->actionFunc = EnMa4_HorsebackGameEnd; Audio_QueueSeqCmd(NA_BGM_STOP); - Audio_QueueSeqCmd(0x8041); + Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); } void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 4c955f83f..d89ed4582 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -903,7 +903,7 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { if (gSaveContext.weekEventReg[0x34] & 1) { // if (ProtectedCremia) EnMaYto_SetFaceExpression(this, 3, 1); } else { - func_801A3098(9); + func_801A3098(NA_BGM_FAILURE_1); EnMaYto_SetFaceExpression(this, 5, 2); } this->actionFunc = EnMaYto_AfterMilkRunInit; diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 67c1d8659..9095d702b 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -462,7 +462,7 @@ void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, GlobalContext* globalCtx) { ActorCutscene_Start(this->actor.cutscene, &this->actor); this->actionFunc = EnMinifrog_SetupNextFrogChoir; this->timer = 5; - func_801A1F00(3, 0x5A); + func_801A1F00(3, NA_BGM_FROG_SONG); this->flags |= 0x100; globalCtx->setPlayerTalkAnim(globalCtx, &D_0400E2A8, 0); } else { diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index 446b4c100..514245a32 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -367,7 +367,7 @@ void func_8095AE60(EnOwl* this, GlobalContext* globalCtx) { void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_8095A978(this, globalCtx, 0x7D0, 360.0f, 200.0f)) { - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->actionFunc = func_8095AE60; } } @@ -396,7 +396,7 @@ void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx) { void func_8095AFEC(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_8095A978(this, globalCtx, 0xBF6, 200.0f, 100.0f)) { - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->actionFunc = func_8095AF2C; this->unk_406 = 0; this->actionFlags |= 0x40; @@ -511,7 +511,7 @@ void func_8095B574(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { this->actionFunc = func_8095BA84; - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->actionFlags |= 0x40; this->unk_406 = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { @@ -721,7 +721,7 @@ void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { this->actionFunc = func_8095BA84; - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->unk_406 = 1; this->actionFlags |= 0x40; } else if (this->actor.textId == 0xBF0) { diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index 12e234991..8acba6f8a 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -1054,7 +1054,7 @@ void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; if (SkelAnime_Update(&this->skelAnime) && (func_801690CC(globalCtx) == 0)) { if (!this->unk_2AE) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); this->unk_2AE = true; } EnPametfrog_SetupJumpToLink(this); @@ -1274,7 +1274,7 @@ void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, GlobalContext* g void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, GlobalContext* globalCtx) { if (this->actor.params == GEKKO_INIT_SNAPPER) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); EnPametfrog_SetupRunToSnapper(this); } } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 3a8db7839..546f029ff 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -1142,7 +1142,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { this->textId = 0x2A31; func_801518B0(globalCtx, this->textId, &this->actor); this->flags1 |= 0x4000; - Audio_QueueSeqCmd(0x8003); + Audio_QueueSeqCmd(NA_BGM_CHASE | 0x8000); this->actionFunc = func_80BAD380; } else { ActorCutscene_SetIntentToPlay(this->cutscenes[1]); diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 5018c640f..bd961b7ad 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -1160,7 +1160,7 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { func_801A2C20(); this->actionFunc = func_809C8BF0; if (this->unk_280 == 50) { - func_801A3098(0x922); + func_801A3098(NA_BGM_ITEM_GET | 0x900); func_8011B4E0(globalCtx, 1); } } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index ef3fdf7dc..f846a2399 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -612,7 +612,7 @@ s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA49A4(EnToto* this, GlobalContext* globalCtx) { func_800B7298(globalCtx, NULL, 0x44); - func_801A31EC(0x54, 4, this->unk2B3 ^ 0xF); + func_801A31EC(NA_BGM_QUARTET, 4, this->unk2B3 ^ 0xF); this->unk2B1 = 4; return 0; } @@ -621,8 +621,8 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { Actor* actor; if (DECR(this->unk2B1) == 0) { - if (!func_801A2DE0(0x54)) { - actor = (Actor*)GET_PLAYER(globalCtx); // Needed for regalloc, possible FAKE MATCH + if (!Audio_IsSequencePlaying(NA_BGM_QUARTET)) { + actor = &GET_PLAYER(globalCtx)->actor; actor = actor->next; while (actor != NULL) { Actor_MarkForDeath(actor); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b6ec70b65..c2c4b7b3f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3951,7 +3951,7 @@ 0x801A2C44:("func_801A2C44",), 0x801A2C88:("func_801A2C88",), 0x801A2D54:("func_801A2D54",), - 0x801A2DE0:("func_801A2DE0",), + 0x801A2DE0:("Audio_IsSequencePlaying",), 0x801A2E54:("func_801A2E54",), 0x801A2ED8:("func_801A2ED8",), 0x801A2F88:("func_801A2F88",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 9737ede4d..3a14ddbc3 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3469,7 +3469,7 @@ asm/non_matchings/code/code_8019AF00/func_801A2C20.s,func_801A2C20,0x801A2C20,0x asm/non_matchings/code/code_8019AF00/func_801A2C44.s,func_801A2C44,0x801A2C44,0x11 asm/non_matchings/code/code_8019AF00/func_801A2C88.s,func_801A2C88,0x801A2C88,0x33 asm/non_matchings/code/code_8019AF00/func_801A2D54.s,func_801A2D54,0x801A2D54,0x23 -asm/non_matchings/code/code_8019AF00/func_801A2DE0.s,func_801A2DE0,0x801A2DE0,0x1D +asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s,Audio_IsSequencePlaying,0x801A2DE0,0x1D asm/non_matchings/code/code_8019AF00/func_801A2E54.s,func_801A2E54,0x801A2E54,0x21 asm/non_matchings/code/code_8019AF00/func_801A2ED8.s,func_801A2ED8,0x801A2ED8,0x2C asm/non_matchings/code/code_8019AF00/func_801A2F88.s,func_801A2F88,0x801A2F88,0xF From ea906f4280afacbf6f278bdca28c0cbd54f34041 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 13 Nov 2021 16:04:58 +1100 Subject: [PATCH 03/17] Rename bgm to clearer names --- include/bgm.h | 254 +++++++++--------- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 2 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- .../actors/ovl_En_Guruguru/z_en_guruguru.c | 4 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 6 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 2 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 4 +- 8 files changed, 138 insertions(+), 138 deletions(-) diff --git a/include/bgm.h b/include/bgm.h index 1dc9acdc3..5038f66e0 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,133 +3,133 @@ #define NA_BGM_STOP 0x100000FF -#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects -#define NA_BGM_NATURE_AMBIENCE 0x01 -#define NA_BGM_FIELD 0x02 // Termina Field -#define NA_BGM_CHASE 0x03 // Forest Chase -#define NA_BGM_STALKID 0x04 // Majora's Theme -#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower -#define NA_BGM_RUIN_DUNGEON_FRONT 0x06 // Stone Tower Temple -#define NA_BGM_RUIN_DUNGEON_REVERSE 0x07 // Stone Tower Temple Inverted -#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 -#define NA_BGM_FAILURE_1 0x09 // Title -#define NA_BGM_OMENYA 0x0A // Mask Salesman -#define NA_BGM_DEMO_CURE 0x0B // Song of Healing -#define NA_BGM_DAMP_AREA 0x0C // Southern Swamp -#define NA_BGM_UFO 0x0D // Ghost Attack -#define NA_BGM_JUNGLE_CREWS 0x0E // Mini Game -#define NA_BGM_SHARP 0x0F // Sharp's Curse -#define NA_BGM_SEA_AREA 0x10 // Great Bay Coast -#define NA_BGM_IKANA_AREA 0x11 // Ikana Valley -#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King -#define NA_BGM_SNOW_AREA 0x13 // Mountain Village -#define NA_BGM_PIRATE_AREA 0x14 // Pirates' Fortress -#define NA_BGM_DUMMY_21 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D -#define NA_BGM_DUMMY_22 0x16 // Clock Town Day 2 This song's filename is dummied out in MM3D -#define NA_BGM_DUMMY_23 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D -#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain -#define NA_BGM_EVENT_CLEAR 0x19 // Event Clear -#define NA_BGM_ENEMY 0x1A // Battle -#define NA_BGM_BOSS 0x1B // Boss Battle -#define NA_BGM_JUNGLE_DUNGEON 0x1C // Woodfall Temple -#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ -#define NA_BGM_OPENING 0x1E // Forest Ambush -#define NA_BGM_LINK_HOUSE 0x1F // House -#define NA_BGM_GAME_OVER 0x20 // Game Over -#define NA_BGM_BOSS_CLEAR 0x21 // Boss Clear -#define NA_BGM_ITEM_GET 0x22 // Item Catch -#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT -#define NA_BGM_HEART_GET 0x24 // Complete a Heart Piece -#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame -#define NA_BGM_GORON_RACE 0x26 // Goron Race -#define NA_BGM_ORGEL_HOUSE 0x27 // Music Box House -#define NA_BGM_GODESS 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT -#define NA_BGM_HIME 0x29 // Zelda's Lullaby -#define NA_BGM_SISTER_DANCER 0x2A // Rosa Sisters' Dance -#define NA_BGM_OPEN_TRE_BOX 0x2B // Open Chest -#define NA_BGM_DRUGSTORE 0x2C // Marine Research Laboratory -#define NA_BGM_KYOJIN_ROOM 0x2D // The Four Giants -#define NA_BGM_FUSHA 0x2E // Guru-Guru's Song -#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" -#define NA_BGM_GORON 0x30 // Goron Village -#define NA_BGM_MEETING 0x31 // Mayor Dotour -#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song -#define NA_BGM_OCA_SUN 0x33 // Ocarina Sun's Song -#define NA_BGM_OCA_TIME_NORMAL 0x34 // Ocarina Song of Time -#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms -#define NA_BGM_ZORA 0x36 // Zora Hall -#define NA_BGM_MASK_GET 0x37 // A New Mask -#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" -#define NA_BGM_S_ITEM_GET 0x39 // Small Item Catch -#define NA_BGM_TENMONDAI 0x3A // Astral Observatory -#define NA_BGM_NORMAL_DUNGEON 0x3B // Clock Town Cavern -#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte -#define NA_BGM_APPEAR 0x3D // Meet Zelda (OoT) -#define NA_BGM_MAYOIMORI 0x3E // Woods of Mystery -#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal -#define NA_BGM_HORSE 0x40 // Gorman Race -#define NA_BGM_HORSE_GOAL 0x41 // Race Finish -#define NA_BGM_INGO 0x42 // Gorman Bros. -#define NA_BGM_KOTAKE_KOUME 0x43 // Kotake's Potion Shop -#define NA_BGM_SHOP 0x44 // Store -#define NA_BGM_OWL 0x45 // Gaebora's Theme -#define NA_BGM_MINI_GAME 0x46 // Target Practice -#define NA_BGM_OCA_BIGWING 0x47 // Ocarina Song of Soaring -#define NA_BGM_OCA_CURE 0x48 // Ocarina Song of Healing -#define NA_BGM_TIME_SPEED 0x49 // Inverted Song of Time -#define NA_BGM_TIME_JUMP 0x4A // Song of Double Time -#define NA_BGM_DEMO_AWAKING 0x4B // Sonata of Awakening -#define NA_BGM_DEMO_LULLABY 0x4C // Goron Lullaby -#define NA_BGM_DEMO_TIDE 0x4D // New Wave Bossa Nova -#define NA_BGM_DEMO_SHELL 0x4E // Elegy of Emptiness -#define NA_BGM_DEMO_PLEDGE 0x4F // Oath to Order -#define NA_BGM_EXERCISE_HALL 0x50 // Sword Training -#define NA_BGM_DEMO_LULLABY_HALF 0x51 // Ocarina Goron Lullaby Intro -#define NA_BGM_OCA_YOUSEI 0x52 // New Song -#define NA_BGM_FACEMASK 0x53 // Bremen March -#define NA_BGM_QUARTET 0x54 // Ballad of the Wind Fish -#define NA_BGM_WING_WARP 0x55 // Song of Soaring -#define NA_BGM_MILK_BAR_DUMMY 0x56 // Milk Bar Latte Duplicate. -#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" -#define NA_BGM_MIKAU_LIFF 0x58 // Mikau's Tale -#define NA_BGM_MIKAU_FIN 0x59 // A single guitar chord. -#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song -#define NA_BGM_OCA_AWAKING 0x5B // Ocarina Sonata of Awakening -#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby -#define NA_BGM_OCA_TIDE 0x5D // Ocarina New Wave Bossa Nova -#define NA_BGM_OCA_SHELL 0x5E // Ocarina Elegy of Emptiness -#define NA_BGM_OCA_PLEDGE 0x5F // Ocarina Oath to Order -#define NA_BGM_LAST_DUNGEON 0x60 // -#define NA_BGM_OCA_LULLABY_HALF 0x61 // -#define NA_BGM_OCA_SESSION 0x62 // Bass and Guitar Session -#define NA_BGM_DEMO_SESSION 0x63 // Piano Solo -#define NA_BGM_ALLPART_SESSION 0x64 // The Indigo-Go's Rehearsal -#define NA_BGM_SILVER_DUNGEON 0x65 // Snowhead Temple -#define NA_BGM_DEEPBLUE_DUNGEON 0x66 // Great Bay Temple -#define NA_BGM_DEMO_TIDE_SAX 0x67 // -#define NA_BGM_DEMO_TIDE_VOCAL 0x68 // -#define NA_BGM_MUJURA_1 0x69 // Majora's Wrath -#define NA_BGM_MUJURA_2 0x6A // Majora's Incarnation -#define NA_BGM_MUJURA_3 0x6B // Majora's Mask Battle -#define NA_BGM_BASS_PLAY 0x6C // Bass Practice -#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice -#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice -#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle -#define NA_BGM_GATHERING 0x70 // Calling the Four Giants -#define NA_BGM_CAMARO_DANCE 0x71 // Kamaro's Dance -#define NA_BGM_DONKEY_CART 0x72 // Cremia's Carriage -#define NA_BGM_QUIZ 0x73 // Keaton -#define NA_BGM_END_DEMO 0x74 // The End/Credits I -#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. -#define NA_BGM_TITLE 0x76 // Title Screen -#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall -#define NA_BGM_PURIFICATION_0 0x78 // Woodfall Clear -#define NA_BGM_PURIFICATION_1 0x79 // Snowhead Clear -#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon -#define NA_BGM_GOODBYE_GIANT 0x7C // -#define NA_BGM_CHAT 0x7D // Tatl and Tael -#define NA_BGM_MOON_VANISH 0x7E // Moon's Destruction -#define NA_BGM_STAFFROLL2 0x7F // The End/Credits II +#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects +#define NA_BGM_NATURE_BACKGROUND 0x01 // Ambient background noises +#define NA_BGM_TERMINA_FIELD 0x02 // Termina Field +#define NA_BGM_CHASE 0x03 // Forest Chase +#define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" +#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower +#define NA_BGM_STONE_TOWER_TEMPLE 0x06 // Stone Tower Temple +#define NA_BGM_INV_STONE_TOWER_TEMPLE 0x07 // Stone Tower Temple Inverted +#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 +#define NA_BGM_FAILURE_1 0x09 // Title +#define NA_BGM_HAPPY_MASK_SALESMAN 0x0A // Mask Salesman "OMENYA" +#define NA_BGM_SONG_OF_HEALING 0x0B // Song of Healing "DEMO_CURE" +#define NA_BGM_SWAMP_REGION 0x0C // Southern Swamp and Woodfall "DAMP_AREA" +#define NA_BGM_ALIEN_INVASION 0x0D // Ghost Attack "UFO" +#define NA_BGM_SWAMP_CRUISE 0x0E // Mini Game "JUNGLE_CREWS" +#define NA_BGM_SHARPS_CURSE 0x0F // Sharp's Curse +#define NA_BGM_GREAT_BAY_REGION 0x10 // Great Bay Coast "SEA_AREA" +#define NA_BGM_IKANA_REGION 0x11 // Ikana Valley +#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King +#define NA_BGM_MOUNTAIN_REGION 0x13 // Mountain Village "SNOW_AREA" +#define NA_BGM_PIRATES_FORTRESS 0x14 // Pirates' Fortress "PIRATE_AREA" +#define NA_BGM_CLOCK_TOWN_DAY_1 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D "DUMMY_21" +#define NA_BGM_CLOCK_TOWN_DAY_2 0x16 // Clock Town Day 2 his song's filename is dummied out in MM3D "DUMMY_22" +#define NA_BGM_CLOCK_TOWN_DAY_3 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D "DUMMY_23" +#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain +#define NA_BGM_CLEAR_EVENT 0x19 // Event Clear +#define NA_BGM_ENEMY 0x1A // Battle +#define NA_BGM_BOSS 0x1B // Boss Battle +#define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" +#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ +#define NA_BGM_OPENING 0x1E // Forest Ambush +#define NA_BGM_HOUSE 0x1F // House "LINK_HOUSE" +#define NA_BGM_GAME_OVER 0x20 // Game Over +#define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear +#define NA_BGM_GET_ITEM 0x22 // Item Catch +#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece +#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_GORON_RACE 0x26 // Goron Race +#define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" +#define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" +#define NA_BGM_ZELDAS_LULLABY 0x29 // Zelda's Lullaby "HIME" +#define NA_BGM_ROSA_SISTERS 0x2A // Rosa Sisters' Dance "SISTER_DANCER" +#define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" +#define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" +#define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" +#define NA_BGM_GURU_GURU 0x2E // Guru-Guru's Song "FUSHA" +#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" +#define NA_BGM_GORON_VILLAGE 0x30 // Goron Village +#define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" +#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song +#define NA_BGM_OCA_SUNS 0x33 // Ocarina Sun's Song +#define NA_BGM_OCA_TIME 0x34 // Ocarina Song of Time "TIME_NORMAL" +#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms +#define NA_BGM_ZORA_HALL 0x36 // Zora Hall +#define NA_BGM_GET_NEW_MASK 0x37 // A New Mask +#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" +#define NA_BGM_GET_SMALL_ITEM 0x39 // Small Item Catch "S_ITEM_GET" +#define NA_BGM_ASTRAL_OBSERVATORY 0x3A // Astral Observatory "TENMONDAI" +#define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" +#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte +#define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) +#define NA_BGM_WOODS_OF_MYSTERY 0x3E // Saria's Song from OoT "MAYOIMORI" +#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal +#define NA_BGM_HORSE 0x40 // Gorman Race +#define NA_BGM_HORSE_GOAL 0x41 // Race Finish +#define NA_BGM_INGO 0x42 // Gorman Bros. "INGO" +#define NA_BGM_KOTAKE_POTION_SHOP 0x43 // Kotake's Potion Shop "KOTAKE_KOUME" +#define NA_BGM_SHOP 0x44 // Store +#define NA_BGM_OWL 0x45 // Gaebora's Theme +#define NA_BGM_MINI_GAME 0x46 // Target Practice +#define NA_BGM_OCA_SOARING 0x47 // Ocarina Song of Soaring "OCA_BIGWING" +#define NA_BGM_OCA_HEALING 0x48 // Ocarina Song of Healing "OCA_CURE" +#define NA_BGM_INVERTED_SONG_OF_TIME 0x49 // Inverted Song of Time "_SPEED" +#define NA_BGM_SONG_OF_DOUBLE_TIME 0x4A // Song of Double Time "TIME_JUMP" +#define NA_BGM_SONATA_OF_AWAKENING 0x4B // Sonata of Awakening "DEMO_AWAKING" +#define NA_BGM_GORON_LULLABY 0x4C // Goron Lullaby "DEMO_LULLABY" +#define NA_BGM_NEW_WAVE_BOSSA_NOVA 0x4D // New Wave Bossa Nova "DEMO_TIDE" +#define NA_BGM_ELEGY_OF_EMPTINESS 0x4E // Elegy of Emptiness "DEMO_SHELL" +#define NA_BGM_OATH_TO_ORDER 0x4F // Oath to Order "DEMO_PLEDGE" +#define NA_BGM_SWORD_TRAINING_HALL 0x50 // Sword Training "EXERCISE_HALL" +#define NA_BGM_GORON_LULLABY_INTRO 0x51 // Ocarina Goron Lullaby Intro "DEMO_LULLABY_HALF" +#define NA_BGM_OCA_FAIRY 0x52 // New Song "OCA_YOUSEI" +#define NA_BGM_BREMEN_MARCH 0x53 // Bremen March "FACEMASK" +#define NA_BGM_BALLAD_OF_THE_WIND_FISH 0x54 // Quartet performed in on the milk bar stage "QUARTET" +#define NA_BGM_SONG_OF_SOARING 0x55 // Song of Soaring "WING_WARP" +#define NA_BGM_MILK_BAR_DUPLICATE 0x56 // Milk Bar Latte Duplicate. "MILK_BAR_DUMMY" +#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" +#define NA_BGM_MIKAU_RIFF 0x58 // Mikau's Tale "MIKAU_LIFF" +#define NA_BGM_MIKAU_FINALE 0x59 // A single guitar chord. "MIKAU_FIN" +#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song +#define NA_BGM_OCA_SONATA 0x5B // Ocarina Sonata of Awakening "OCA_AWAKING" +#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby "OCA_LULLABY" +#define NA_BGM_OCA_NEW_WAVE 0x5D // Ocarina New Wave Bossa Nova "OCA_TIDE" +#define NA_BGM_OCA_ELEGY 0x5E // Ocarina Elegy of Emptiness "OCA_SHELL" +#define NA_BGM_OCA_OATH 0x5F // Ocarina Oath to Order "OCA_PLEDGE" +#define NA_BGM_MAJORAS_LAIR 0x60 // "LAST_DUNGEON" +#define NA_BGM_OCA_LULLABY_INTRO 0x61 // "OCA_LULLABY_HALF" +#define NA_BGM_OCA_GUITAR_BASS_SESSION 0x62 // Bass and Guitar Session "OCA_SESSION" +#define NA_BGM_PIANO_SESSION 0x63 // Piano Solo "DEMO_SESSION" +#define NA_BGM_INDIGO_GO_SESSION 0x64 // The Indigo-Go's Rehearsal "ALLPART_SESSION" +#define NA_BGM_SNOWHEAD_TEMPLE 0x65 // Snowhead Temple "SILVER_DUNGEON" +#define NA_BGM_GREAT_BAY_TEMPLE 0x66 // Great Bay Temple "DEEPBLUE_DUNGEON" +#define NA_BGM_NEW_WAVE_SAXOPHONE 0x67 // "DEMO_TIDE_SAX" +#define NA_BGM_NEW_WAVE_VOCAL 0x68 // "DEMO_TIDE_VOCAL" +#define NA_BGM_MAJORAS_WRATH 0x69 // Majora's Wrath "MUJURA_1" +#define NA_BGM_MAJORAS_INCARNATION 0x6A // Majora's Incarnation "MUJURA_2" +#define NA_BGM_MAJORAS_MASK 0x6B // Majora's Mask Battle "MUJURA_3" +#define NA_BGM_BASS_PLAY 0x6C // Bass Practice "BASS_PLAY" +#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice "DRUMS_PLAY" +#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice "PIANO_PLAY" +#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle +#define NA_BGM_GATHERING_GIANTS 0x70 // Calling the Four Giants +#define NA_BGM_KAMARO_DANCE 0x71 // Kamaro's Dance "CAMARO_DANCE" +#define NA_BGM_CREMIA_CARRIAGE 0x72 // Cremia's Carriage "DONKEY_CART" +#define NA_BGM_KEATON_QUIZ 0x73 // Keaton "QUIZ" +#define NA_BGM_END_CREDITS_1 0x74 // The End/Credits I "END_DEMO" +#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. +#define NA_BGM_TITLE_THEME 0x76 // Title Screen +#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall +#define NA_BGM_WOODFALL_CLEAR 0x78 // Woodfall Clear "PURIFICATION_0" +#define NA_BGM_SNOWHEAD_CLEAR 0x79 // Snowhead Clear "PURIFICATION_1" +#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon +#define NA_BGM_GOODBYE_GIANT 0x7C // +#define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" +#define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" +#define NA_BGM_END_CREDITS_2 0x7F // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF #endif diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index dc7f3639a..498455011 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1005,7 +1005,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { } if (spB0->unk_0144 >= 10) { - Audio_QueueSeqCmd(NA_BGM_BOSS_CLEAR | 0x8000); + Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); } Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index e1b71acb2..1efecd257 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -464,7 +464,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { gSaveContext.inventory.strayFairies[gSaveContext.unk_48C8]++; func_801518B0(globalCtx, 0x11, NULL); if (gSaveContext.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { - func_801A3098(NA_BGM_ITEM_GET | 0x900); + func_801A3098(NA_BGM_GET_ITEM | 0x900); } } } diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 7a0386183..a278711b5 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -804,7 +804,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { func_801A2C20(); gSaveContext.unk_3DE0[4] = 0; gSaveContext.unk_3DD0[4] = 5; - func_801A3098(NA_BGM_ITEM_GET | 0x900); + func_801A3098(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(globalCtx, 1); this->unk_54A = 3; func_809632D0(this); diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index 252b1e973..edc0135a8 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -339,12 +339,12 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 2) { if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) { - func_801A1DB8(&this->actor.projectedPos, NA_BGM_FUSHA, 540.0f); + func_801A1DB8(&this->actor.projectedPos, NA_BGM_GURU_GURU, 540.0f); } return; } if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 200.0f) { - func_801A1D44(&this->actor.projectedPos, NA_BGM_FUSHA, 540.0f); + func_801A1D44(&this->actor.projectedPos, NA_BGM_GURU_GURU, 540.0f); } if (this->unusedTimer != 0) { this->unusedTimer--; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 15eed7e02..b10894b16 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1699,7 +1699,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { } else { func_80B454BC(this, globalCtx); func_80B452EC(this, globalCtx); - Audio_QueueSeqCmd(NA_BGM_UFO | 0x8000); + Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000); func_80B46F88(this); } } else if (D_80B4E940 == 3) { @@ -1987,7 +1987,7 @@ void func_80B46EE8(EnInvadepoh* this, GlobalContext* globalCtx) { this->actionTimer--; if (this->actionTimer <= 0) { ActorCutscene_Stop(D_80B50404[0]); - Audio_QueueSeqCmd(NA_BGM_UFO | 0x8000); + Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000); func_80B46F88(this); } } @@ -2036,7 +2036,7 @@ void func_80B470E0(EnInvadepoh* this) { void func_80B47108(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->actionTimer == 100) { - func_801A3098(NA_BGM_EVENT_CLEAR); + func_801A3098(NA_BGM_CLEAR_EVENT); } this->actionTimer--; if (this->actionTimer <= 0) { diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index bd961b7ad..1a038f5a7 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -1160,7 +1160,7 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { func_801A2C20(); this->actionFunc = func_809C8BF0; if (this->unk_280 == 50) { - func_801A3098(NA_BGM_ITEM_GET | 0x900); + func_801A3098(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(globalCtx, 1); } } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index f846a2399..0acdc0485 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -612,7 +612,7 @@ s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA49A4(EnToto* this, GlobalContext* globalCtx) { func_800B7298(globalCtx, NULL, 0x44); - func_801A31EC(NA_BGM_QUARTET, 4, this->unk2B3 ^ 0xF); + func_801A31EC(NA_BGM_BALLAD_OF_THE_WIND_FISH, 4, this->unk2B3 ^ 0xF); this->unk2B1 = 4; return 0; } @@ -621,7 +621,7 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { Actor* actor; if (DECR(this->unk2B1) == 0) { - if (!Audio_IsSequencePlaying(NA_BGM_QUARTET)) { + if (!Audio_IsSequencePlaying(NA_BGM_BALLAD_OF_THE_WIND_FISH)) { actor = &GET_PLAYER(globalCtx)->actor; actor = actor->next; while (actor != NULL) { From 0499934d02e1e6a34607236f635fe62ac85a5734 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 13 Nov 2021 16:07:55 +1100 Subject: [PATCH 04/17] Fix spacing --- include/bgm.h | 244 +++++++++++++++++++++++++------------------------- 1 file changed, 122 insertions(+), 122 deletions(-) diff --git a/include/bgm.h b/include/bgm.h index 5038f66e0..391881221 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,133 +3,133 @@ #define NA_BGM_STOP 0x100000FF -#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects -#define NA_BGM_NATURE_BACKGROUND 0x01 // Ambient background noises -#define NA_BGM_TERMINA_FIELD 0x02 // Termina Field -#define NA_BGM_CHASE 0x03 // Forest Chase -#define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" -#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower -#define NA_BGM_STONE_TOWER_TEMPLE 0x06 // Stone Tower Temple -#define NA_BGM_INV_STONE_TOWER_TEMPLE 0x07 // Stone Tower Temple Inverted -#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 -#define NA_BGM_FAILURE_1 0x09 // Title -#define NA_BGM_HAPPY_MASK_SALESMAN 0x0A // Mask Salesman "OMENYA" -#define NA_BGM_SONG_OF_HEALING 0x0B // Song of Healing "DEMO_CURE" -#define NA_BGM_SWAMP_REGION 0x0C // Southern Swamp and Woodfall "DAMP_AREA" -#define NA_BGM_ALIEN_INVASION 0x0D // Ghost Attack "UFO" -#define NA_BGM_SWAMP_CRUISE 0x0E // Mini Game "JUNGLE_CREWS" -#define NA_BGM_SHARPS_CURSE 0x0F // Sharp's Curse -#define NA_BGM_GREAT_BAY_REGION 0x10 // Great Bay Coast "SEA_AREA" -#define NA_BGM_IKANA_REGION 0x11 // Ikana Valley -#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King -#define NA_BGM_MOUNTAIN_REGION 0x13 // Mountain Village "SNOW_AREA" -#define NA_BGM_PIRATES_FORTRESS 0x14 // Pirates' Fortress "PIRATE_AREA" -#define NA_BGM_CLOCK_TOWN_DAY_1 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D "DUMMY_21" -#define NA_BGM_CLOCK_TOWN_DAY_2 0x16 // Clock Town Day 2 his song's filename is dummied out in MM3D "DUMMY_22" -#define NA_BGM_CLOCK_TOWN_DAY_3 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D "DUMMY_23" -#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain -#define NA_BGM_CLEAR_EVENT 0x19 // Event Clear -#define NA_BGM_ENEMY 0x1A // Battle -#define NA_BGM_BOSS 0x1B // Boss Battle -#define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" -#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ -#define NA_BGM_OPENING 0x1E // Forest Ambush -#define NA_BGM_HOUSE 0x1F // House "LINK_HOUSE" -#define NA_BGM_GAME_OVER 0x20 // Game Over -#define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear -#define NA_BGM_GET_ITEM 0x22 // Item Catch -#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT -#define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece -#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame -#define NA_BGM_GORON_RACE 0x26 // Goron Race -#define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" -#define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" -#define NA_BGM_ZELDAS_LULLABY 0x29 // Zelda's Lullaby "HIME" -#define NA_BGM_ROSA_SISTERS 0x2A // Rosa Sisters' Dance "SISTER_DANCER" -#define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" -#define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" -#define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" -#define NA_BGM_GURU_GURU 0x2E // Guru-Guru's Song "FUSHA" -#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" -#define NA_BGM_GORON_VILLAGE 0x30 // Goron Village -#define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" -#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song -#define NA_BGM_OCA_SUNS 0x33 // Ocarina Sun's Song -#define NA_BGM_OCA_TIME 0x34 // Ocarina Song of Time "TIME_NORMAL" -#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms -#define NA_BGM_ZORA_HALL 0x36 // Zora Hall -#define NA_BGM_GET_NEW_MASK 0x37 // A New Mask -#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" -#define NA_BGM_GET_SMALL_ITEM 0x39 // Small Item Catch "S_ITEM_GET" -#define NA_BGM_ASTRAL_OBSERVATORY 0x3A // Astral Observatory "TENMONDAI" -#define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" -#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte -#define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) -#define NA_BGM_WOODS_OF_MYSTERY 0x3E // Saria's Song from OoT "MAYOIMORI" -#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal -#define NA_BGM_HORSE 0x40 // Gorman Race -#define NA_BGM_HORSE_GOAL 0x41 // Race Finish -#define NA_BGM_INGO 0x42 // Gorman Bros. "INGO" -#define NA_BGM_KOTAKE_POTION_SHOP 0x43 // Kotake's Potion Shop "KOTAKE_KOUME" -#define NA_BGM_SHOP 0x44 // Store -#define NA_BGM_OWL 0x45 // Gaebora's Theme -#define NA_BGM_MINI_GAME 0x46 // Target Practice -#define NA_BGM_OCA_SOARING 0x47 // Ocarina Song of Soaring "OCA_BIGWING" -#define NA_BGM_OCA_HEALING 0x48 // Ocarina Song of Healing "OCA_CURE" -#define NA_BGM_INVERTED_SONG_OF_TIME 0x49 // Inverted Song of Time "_SPEED" -#define NA_BGM_SONG_OF_DOUBLE_TIME 0x4A // Song of Double Time "TIME_JUMP" -#define NA_BGM_SONATA_OF_AWAKENING 0x4B // Sonata of Awakening "DEMO_AWAKING" -#define NA_BGM_GORON_LULLABY 0x4C // Goron Lullaby "DEMO_LULLABY" -#define NA_BGM_NEW_WAVE_BOSSA_NOVA 0x4D // New Wave Bossa Nova "DEMO_TIDE" -#define NA_BGM_ELEGY_OF_EMPTINESS 0x4E // Elegy of Emptiness "DEMO_SHELL" -#define NA_BGM_OATH_TO_ORDER 0x4F // Oath to Order "DEMO_PLEDGE" -#define NA_BGM_SWORD_TRAINING_HALL 0x50 // Sword Training "EXERCISE_HALL" -#define NA_BGM_GORON_LULLABY_INTRO 0x51 // Ocarina Goron Lullaby Intro "DEMO_LULLABY_HALF" -#define NA_BGM_OCA_FAIRY 0x52 // New Song "OCA_YOUSEI" -#define NA_BGM_BREMEN_MARCH 0x53 // Bremen March "FACEMASK" -#define NA_BGM_BALLAD_OF_THE_WIND_FISH 0x54 // Quartet performed in on the milk bar stage "QUARTET" -#define NA_BGM_SONG_OF_SOARING 0x55 // Song of Soaring "WING_WARP" -#define NA_BGM_MILK_BAR_DUPLICATE 0x56 // Milk Bar Latte Duplicate. "MILK_BAR_DUMMY" -#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" -#define NA_BGM_MIKAU_RIFF 0x58 // Mikau's Tale "MIKAU_LIFF" -#define NA_BGM_MIKAU_FINALE 0x59 // A single guitar chord. "MIKAU_FIN" -#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song -#define NA_BGM_OCA_SONATA 0x5B // Ocarina Sonata of Awakening "OCA_AWAKING" -#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby "OCA_LULLABY" -#define NA_BGM_OCA_NEW_WAVE 0x5D // Ocarina New Wave Bossa Nova "OCA_TIDE" -#define NA_BGM_OCA_ELEGY 0x5E // Ocarina Elegy of Emptiness "OCA_SHELL" -#define NA_BGM_OCA_OATH 0x5F // Ocarina Oath to Order "OCA_PLEDGE" +#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects +#define NA_BGM_NATURE_BACKGROUND 0x01 // Ambient background noises +#define NA_BGM_TERMINA_FIELD 0x02 // Termina Field +#define NA_BGM_CHASE 0x03 // Forest Chase +#define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" +#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower +#define NA_BGM_STONE_TOWER_TEMPLE 0x06 // Stone Tower Temple +#define NA_BGM_INV_STONE_TOWER_TEMPLE 0x07 // Stone Tower Temple Inverted +#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 +#define NA_BGM_FAILURE_1 0x09 // Title +#define NA_BGM_HAPPY_MASK_SALESMAN 0x0A // Mask Salesman "OMENYA" +#define NA_BGM_SONG_OF_HEALING 0x0B // Song of Healing "DEMO_CURE" +#define NA_BGM_SWAMP_REGION 0x0C // Southern Swamp and Woodfall "DAMP_AREA" +#define NA_BGM_ALIEN_INVASION 0x0D // Ghost Attack "UFO" +#define NA_BGM_SWAMP_CRUISE 0x0E // Mini Game "JUNGLE_CREWS" +#define NA_BGM_SHARPS_CURSE 0x0F // Sharp's Curse +#define NA_BGM_GREAT_BAY_REGION 0x10 // Great Bay Coast "SEA_AREA" +#define NA_BGM_IKANA_REGION 0x11 // Ikana Valley +#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King +#define NA_BGM_MOUNTAIN_REGION 0x13 // Mountain Village "SNOW_AREA" +#define NA_BGM_PIRATES_FORTRESS 0x14 // Pirates' Fortress "PIRATE_AREA" +#define NA_BGM_CLOCK_TOWN_DAY_1 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D "DUMMY_21" +#define NA_BGM_CLOCK_TOWN_DAY_2 0x16 // Clock Town Day 2 his song's filename is dummied out in MM3D "DUMMY_22" +#define NA_BGM_CLOCK_TOWN_DAY_3 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D "DUMMY_23" +#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain +#define NA_BGM_CLEAR_EVENT 0x19 // Event Clear +#define NA_BGM_ENEMY 0x1A // Battle +#define NA_BGM_BOSS 0x1B // Boss Battle +#define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" +#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ +#define NA_BGM_OPENING 0x1E // Forest Ambush +#define NA_BGM_HOUSE 0x1F // House "LINK_HOUSE" +#define NA_BGM_GAME_OVER 0x20 // Game Over +#define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear +#define NA_BGM_GET_ITEM 0x22 // Item Catch +#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece +#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_GORON_RACE 0x26 // Goron Race +#define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" +#define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" +#define NA_BGM_ZELDAS_LULLABY 0x29 // Zelda's Lullaby "HIME" +#define NA_BGM_ROSA_SISTERS 0x2A // Rosa Sisters' Dance "SISTER_DANCER" +#define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" +#define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" +#define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" +#define NA_BGM_GURU_GURU 0x2E // Guru-Guru's Song "FUSHA" +#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" +#define NA_BGM_GORON_VILLAGE 0x30 // Goron Village +#define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" +#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song +#define NA_BGM_OCA_SUNS 0x33 // Ocarina Sun's Song +#define NA_BGM_OCA_TIME 0x34 // Ocarina Song of Time "TIME_NORMAL" +#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms +#define NA_BGM_ZORA_HALL 0x36 // Zora Hall +#define NA_BGM_GET_NEW_MASK 0x37 // A New Mask +#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" +#define NA_BGM_GET_SMALL_ITEM 0x39 // Small Item Catch "S_ITEM_GET" +#define NA_BGM_ASTRAL_OBSERVATORY 0x3A // Astral Observatory "TENMONDAI" +#define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" +#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte +#define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) +#define NA_BGM_WOODS_OF_MYSTERY 0x3E // Saria's Song from OoT "MAYOIMORI" +#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal +#define NA_BGM_HORSE 0x40 // Gorman Race +#define NA_BGM_HORSE_GOAL 0x41 // Race Finish +#define NA_BGM_INGO 0x42 // Gorman Bros. "INGO" +#define NA_BGM_KOTAKE_POTION_SHOP 0x43 // Kotake's Potion Shop "KOTAKE_KOUME" +#define NA_BGM_SHOP 0x44 // Store +#define NA_BGM_OWL 0x45 // Gaebora's Theme +#define NA_BGM_MINI_GAME 0x46 // Target Practice +#define NA_BGM_OCA_SOARING 0x47 // Ocarina Song of Soaring "OCA_BIGWING" +#define NA_BGM_OCA_HEALING 0x48 // Ocarina Song of Healing "OCA_CURE" +#define NA_BGM_INVERTED_SONG_OF_TIME 0x49 // Inverted Song of Time "_SPEED" +#define NA_BGM_SONG_OF_DOUBLE_TIME 0x4A // Song of Double Time "TIME_JUMP" +#define NA_BGM_SONATA_OF_AWAKENING 0x4B // Sonata of Awakening "DEMO_AWAKING" +#define NA_BGM_GORON_LULLABY 0x4C // Goron Lullaby "DEMO_LULLABY" +#define NA_BGM_NEW_WAVE_BOSSA_NOVA 0x4D // New Wave Bossa Nova "DEMO_TIDE" +#define NA_BGM_ELEGY_OF_EMPTINESS 0x4E // Elegy of Emptiness "DEMO_SHELL" +#define NA_BGM_OATH_TO_ORDER 0x4F // Oath to Order "DEMO_PLEDGE" +#define NA_BGM_SWORD_TRAINING_HALL 0x50 // Sword Training "EXERCISE_HALL" +#define NA_BGM_GORON_LULLABY_INTRO 0x51 // Ocarina Goron Lullaby Intro "DEMO_LULLABY_HALF" +#define NA_BGM_OCA_FAIRY 0x52 // New Song "OCA_YOUSEI" +#define NA_BGM_BREMEN_MARCH 0x53 // Bremen March "FACEMASK" +#define NA_BGM_BALLAD_OF_THE_WIND_FISH 0x54 // Quartet performed in on the milk bar stage "QUARTET" +#define NA_BGM_SONG_OF_SOARING 0x55 // Song of Soaring "WING_WARP" +#define NA_BGM_MILK_BAR_DUPLICATE 0x56 // Milk Bar Latte Duplicate. "MILK_BAR_DUMMY" +#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" +#define NA_BGM_MIKAU_RIFF 0x58 // Mikau's Tale "MIKAU_LIFF" +#define NA_BGM_MIKAU_FINALE 0x59 // A single guitar chord. "MIKAU_FIN" +#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song +#define NA_BGM_OCA_SONATA 0x5B // Ocarina Sonata of Awakening "OCA_AWAKING" +#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby "OCA_LULLABY" +#define NA_BGM_OCA_NEW_WAVE 0x5D // Ocarina New Wave Bossa Nova "OCA_TIDE" +#define NA_BGM_OCA_ELEGY 0x5E // Ocarina Elegy of Emptiness "OCA_SHELL" +#define NA_BGM_OCA_OATH 0x5F // Ocarina Oath to Order "OCA_PLEDGE" #define NA_BGM_MAJORAS_LAIR 0x60 // "LAST_DUNGEON" #define NA_BGM_OCA_LULLABY_INTRO 0x61 // "OCA_LULLABY_HALF" -#define NA_BGM_OCA_GUITAR_BASS_SESSION 0x62 // Bass and Guitar Session "OCA_SESSION" -#define NA_BGM_PIANO_SESSION 0x63 // Piano Solo "DEMO_SESSION" -#define NA_BGM_INDIGO_GO_SESSION 0x64 // The Indigo-Go's Rehearsal "ALLPART_SESSION" -#define NA_BGM_SNOWHEAD_TEMPLE 0x65 // Snowhead Temple "SILVER_DUNGEON" -#define NA_BGM_GREAT_BAY_TEMPLE 0x66 // Great Bay Temple "DEEPBLUE_DUNGEON" +#define NA_BGM_OCA_GUITAR_BASS_SESSION 0x62 // Bass and Guitar Session "OCA_SESSION" +#define NA_BGM_PIANO_SESSION 0x63 // Piano Solo "DEMO_SESSION" +#define NA_BGM_INDIGO_GO_SESSION 0x64 // The Indigo-Go's Rehearsal "ALLPART_SESSION" +#define NA_BGM_SNOWHEAD_TEMPLE 0x65 // Snowhead Temple "SILVER_DUNGEON" +#define NA_BGM_GREAT_BAY_TEMPLE 0x66 // Great Bay Temple "DEEPBLUE_DUNGEON" #define NA_BGM_NEW_WAVE_SAXOPHONE 0x67 // "DEMO_TIDE_SAX" #define NA_BGM_NEW_WAVE_VOCAL 0x68 // "DEMO_TIDE_VOCAL" -#define NA_BGM_MAJORAS_WRATH 0x69 // Majora's Wrath "MUJURA_1" -#define NA_BGM_MAJORAS_INCARNATION 0x6A // Majora's Incarnation "MUJURA_2" -#define NA_BGM_MAJORAS_MASK 0x6B // Majora's Mask Battle "MUJURA_3" -#define NA_BGM_BASS_PLAY 0x6C // Bass Practice "BASS_PLAY" -#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice "DRUMS_PLAY" -#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice "PIANO_PLAY" -#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle -#define NA_BGM_GATHERING_GIANTS 0x70 // Calling the Four Giants -#define NA_BGM_KAMARO_DANCE 0x71 // Kamaro's Dance "CAMARO_DANCE" -#define NA_BGM_CREMIA_CARRIAGE 0x72 // Cremia's Carriage "DONKEY_CART" -#define NA_BGM_KEATON_QUIZ 0x73 // Keaton "QUIZ" -#define NA_BGM_END_CREDITS_1 0x74 // The End/Credits I "END_DEMO" -#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. -#define NA_BGM_TITLE_THEME 0x76 // Title Screen -#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall -#define NA_BGM_WOODFALL_CLEAR 0x78 // Woodfall Clear "PURIFICATION_0" -#define NA_BGM_SNOWHEAD_CLEAR 0x79 // Snowhead Clear "PURIFICATION_1" -#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon +#define NA_BGM_MAJORAS_WRATH 0x69 // Majora's Wrath "MUJURA_1" +#define NA_BGM_MAJORAS_INCARNATION 0x6A // Majora's Incarnation "MUJURA_2" +#define NA_BGM_MAJORAS_MASK 0x6B // Majora's Mask Battle "MUJURA_3" +#define NA_BGM_BASS_PLAY 0x6C // Bass Practice "BASS_PLAY" +#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice "DRUMS_PLAY" +#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice "PIANO_PLAY" +#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle +#define NA_BGM_GATHERING_GIANTS 0x70 // Calling the Four Giants +#define NA_BGM_KAMARO_DANCE 0x71 // Kamaro's Dance "CAMARO_DANCE" +#define NA_BGM_CREMIA_CARRIAGE 0x72 // Cremia's Carriage "DONKEY_CART" +#define NA_BGM_KEATON_QUIZ 0x73 // Keaton "QUIZ" +#define NA_BGM_END_CREDITS_1 0x74 // The End/Credits I "END_DEMO" +#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. +#define NA_BGM_TITLE_THEME 0x76 // Title Screen +#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall +#define NA_BGM_WOODFALL_CLEAR 0x78 // Woodfall Clear "PURIFICATION_0" +#define NA_BGM_SNOWHEAD_CLEAR 0x79 // Snowhead Clear "PURIFICATION_1" +#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon #define NA_BGM_GOODBYE_GIANT 0x7C // -#define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" -#define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" -#define NA_BGM_END_CREDITS_2 0x7F // The End/Credits II "STAFFROLL2" +#define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" +#define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" +#define NA_BGM_END_CREDITS_2 0x7F // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF #endif From e85ef78e859e75967e56831544c4585370e6ce3b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 15 Nov 2021 14:30:32 +1100 Subject: [PATCH 05/17] Fix "No_Music" define --- include/bgm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/bgm.h b/include/bgm.h index 391881221..430be896e 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -129,7 +129,8 @@ #define NA_BGM_GOODBYE_GIANT 0x7C // #define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" #define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" -#define NA_BGM_END_CREDITS_2 0x7F // The End/Credits II "STAFFROLL2" +#define NA_BGM_NO_MUSIC 0x7F // The End/Credits II "STAFFROLL2" +#define NA_BGM_END_CREDITS_2 0x82 // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF #endif From f5f52dbaf0006e57b371ca77b87b4caa2863a549 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 15 Nov 2021 14:35:51 +1100 Subject: [PATCH 06/17] remove comment --- include/bgm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bgm.h b/include/bgm.h index 430be896e..a8ed3a5d8 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -129,7 +129,7 @@ #define NA_BGM_GOODBYE_GIANT 0x7C // #define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" #define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" -#define NA_BGM_NO_MUSIC 0x7F // The End/Credits II "STAFFROLL2" +#define NA_BGM_NO_MUSIC 0x7F // #define NA_BGM_END_CREDITS_2 0x82 // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF From f0ddf5a017c24540ca0923beb2c9584d0a58c325 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Nov 2021 02:58:40 +1100 Subject: [PATCH 07/17] Improve bgm names, found another seqId function --- include/bgm.h | 6 +++--- include/functions.h | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c | 4 ++-- src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/bgm.h b/include/bgm.h index a8ed3a5d8..9a5f547f3 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,8 +3,8 @@ #define NA_BGM_STOP 0x100000FF -#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects -#define NA_BGM_NATURE_BACKGROUND 0x01 // Ambient background noises +#define NA_BGM_GENERAL_SFX 0x00 // General Sound Effects +#define NA_BGM_NATURE_AMBIENCE 0x01 // Ambient background noises #define NA_BGM_TERMINA_FIELD 0x02 // Termina Field #define NA_BGM_CHASE 0x03 // Forest Chase #define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" @@ -49,7 +49,7 @@ #define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" #define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" #define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" -#define NA_BGM_GURU_GURU 0x2E // Guru-Guru's Song "FUSHA" +#define NA_BGM_SONG_OF_STORMS 0x2E // Guru-Guru's Song "FUSHA" #define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" #define NA_BGM_GORON_VILLAGE 0x30 // Goron Village #define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" diff --git a/include/functions.h b/include/functions.h index 578d0c1ec..254c050c0 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3911,7 +3911,7 @@ void func_801A246C(u8 param_1, u8 param_2); // void func_801A27E8(void); // void func_801A281C(void); void func_801A29D4(UNK_TYPE arg0, f32 arg1, UNK_TYPE arg2); -void func_801A2BB8(s32 arg0); +void func_801A2BB8(s32 seqId); void func_801A2C20(void); // void func_801A2C44(void); // void func_801A2C88(void); diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index c34f5cb82..a898ea7cc 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -543,7 +543,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; this->unk_53C = 0; func_800BDC5C(&this->skelAnime, sAnimations, 3); - func_801A2BB8(0x25); + func_801A2BB8(NA_BGM_MINI_GAME_2); if (this->unk_542 == 0) { if (this->unk_546 == 1) { func_80961EC8(globalCtx); diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index edc0135a8..14a2ac839 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -339,12 +339,12 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 2) { if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) { - func_801A1DB8(&this->actor.projectedPos, NA_BGM_GURU_GURU, 540.0f); + func_801A1DB8(&this->actor.projectedPos, NA_BGM_SONG_OF_STORMS, 540.0f); } return; } if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 200.0f) { - func_801A1D44(&this->actor.projectedPos, NA_BGM_GURU_GURU, 540.0f); + func_801A1D44(&this->actor.projectedPos, NA_BGM_SONG_OF_STORMS, 540.0f); } if (this->unusedTimer != 0) { this->unusedTimer--; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 1a038f5a7..513762805 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -337,7 +337,7 @@ void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { func_80123F2C(globalCtx, 80); this->unk_26A = 1; this->actionFunc = func_809C80C0; - func_801A2BB8(0x25); + func_801A2BB8(NA_BGM_MINI_GAME_2); break; case 0xA32: @@ -657,7 +657,7 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { func_80112AFC(globalCtx); func_80123F2C(globalCtx, 0x63); this->unk_26A = 1; - func_801A2BB8(0x25); + func_801A2BB8(NA_BGM_MINI_GAME_2); this->actionFunc = func_809C8808; break; From 43d5adebf656e251e84e5fd5f84ba8db8ca94ebe Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Nov 2021 03:16:22 +1100 Subject: [PATCH 08/17] Another seqId function --- include/functions.h | 2 +- src/overlays/actors/ovl_En_Pamera/z_en_pamera.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/functions.h b/include/functions.h index 254c050c0..e6c387cc0 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3874,7 +3874,7 @@ void func_8019FDC8(UNK_PTR arg0, u16 sfxId, UNK_TYPE arg2); void func_801A0124(Vec3f* pos, u8 arg1); // void func_801A0184(void); // void func_801A01C4(void); -void func_801A0204(UNK_TYPE); +void func_801A0204(s8 seqId); // void func_801A0238(void); // void func_801A026C(void); // void func_801A0318(void); diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index db3f66030..467b5493a 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -590,9 +590,9 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { func_80BD9904(this); } if (gSaveContext.weekEventReg[14] & 4) { - func_801A0204(0x27); + func_801A0204(NA_BGM_MUSIC_BOX_HOUSE); } else { - func_801A0204(0x1F); + func_801A0204(NA_BGM_HOUSE); } } From 7c51f64320545383e4cbe751efad1df48ce2f66d Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Nov 2021 03:39:21 +1100 Subject: [PATCH 09/17] Another name change --- include/bgm.h | 2 +- src/overlays/actors/ovl_En_Pamera/z_en_pamera.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/bgm.h b/include/bgm.h index 9a5f547f3..fd6b98e58 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -34,7 +34,7 @@ #define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" #define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ #define NA_BGM_OPENING 0x1E // Forest Ambush -#define NA_BGM_HOUSE 0x1F // House "LINK_HOUSE" +#define NA_BGM_INSIDE_A_HOUSE 0x1F // House "LINK_HOUSE" #define NA_BGM_GAME_OVER 0x20 // Game Over #define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear #define NA_BGM_GET_ITEM 0x22 // Item Catch diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 467b5493a..129b1c94d 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -592,7 +592,7 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[14] & 4) { func_801A0204(NA_BGM_MUSIC_BOX_HOUSE); } else { - func_801A0204(NA_BGM_HOUSE); + func_801A0204(NA_BGM_INSIDE_A_HOUSE); } } From a2056da3b286edfa66f986c323bce1fc7195b512 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Nov 2021 17:20:34 +1100 Subject: [PATCH 10/17] Woods of Mystery -> Sarias Song --- include/bgm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bgm.h b/include/bgm.h index fd6b98e58..c3ac3b1d1 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -65,7 +65,7 @@ #define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" #define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte #define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) -#define NA_BGM_WOODS_OF_MYSTERY 0x3E // Saria's Song from OoT "MAYOIMORI" +#define NA_BGM_SARIAS_SONG 0x3E // Saria's Theme Song from OoT "MAYOIMORI" #define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal #define NA_BGM_HORSE 0x40 // Gorman Race #define NA_BGM_HORSE_GOAL 0x41 // Race Finish From e84d8bc3f5b707baced6b7fd05ca81303483ba92 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 19 Nov 2021 18:53:37 +1100 Subject: [PATCH 11/17] add saria's song bgm to pierre --- src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 436386af9..631fc26e5 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -811,7 +811,7 @@ void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { if (currentDay == 3 && gSaveContext.isNight) { EnKakasi_SetupDigAway(this); } else { - func_801A2BB8(0x3E); + func_801A2BB8(NA_BGM_SARIAS_SONG); EnKakasi_SetupDanceNightAway(this); } } From a0882f3fd3c05dcc920629007ad63ffc391798b6 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 19 Nov 2021 22:36:18 +1100 Subject: [PATCH 12/17] Another bgm function found! --- include/functions.h | 2 +- src/code/z_common_data.c | 2 +- src/overlays/actors/ovl_En_In/z_en_in.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/functions.h b/include/functions.h index 39bfe916e..4b21e3d0f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1761,7 +1761,7 @@ void func_800FD654(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); // u32 get_days_elapsed(void); // void reset_days_elapsed(void); // u32 get_current_day(void); -void func_800FD750(UNK_TYPE arg0); +void func_800FD750(u16 seqId); // void func_800FD768(void); void func_800FD78C(GlobalContext* globalCtx); void func_800FD858(GlobalContext* globalCtx); diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 88fa3e103..89a161b45 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -7,7 +7,7 @@ void SaveContext_Init(void) { gSaveContext.playerForm = 0; gSaveContext.seqIndex = 0xFF; gSaveContext.nightSeqIndex = 0xFF; - gSaveContext.unk_3F46 = 0; + gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; gSaveContext.nextCutsceneIndex = 0xFFEF; gSaveContext.cutsceneTrigger = 0; gSaveContext.unk_3F4D = 0; diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 381dd693f..95fd85c5a 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -860,7 +860,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3475: SET_FLAGS_START_RACE; - func_800FD750(0x40); + func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; @@ -1107,7 +1107,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3475: SET_FLAGS_START_RACE; - func_800FD750(0x40); + func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; From 5cc0ff2d6413e56b3f4825c903c2b5a1a7b4e937 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 19 Nov 2021 22:45:36 +1100 Subject: [PATCH 13/17] Add bgm's to `gSaveContext.seqIndex` --- src/code/z_common_data.c | 2 +- src/code/z_game_over.c | 2 +- src/code/z_scene.c | 2 +- src/overlays/gamestates/ovl_select/z_select.c | 2 +- src/overlays/gamestates/ovl_title/z_title.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 89a161b45..26fd324a7 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -5,7 +5,7 @@ SaveContext gSaveContext; void SaveContext_Init(void) { bzero(&gSaveContext, sizeof(gSaveContext)); gSaveContext.playerForm = 0; - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; gSaveContext.nextCutsceneIndex = 0xFFEF; diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index edbf79ed7..979b28cba 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -45,7 +45,7 @@ void GameOver_Update(GlobalContext* globalCtx) { gSaveContext.unk_3DC0 = 2000; gSaveContext.naviTimer = 0; - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.eventInf[0] = 0; gSaveContext.eventInf[1] = 0; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 406685f85..293a9762d 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -449,7 +449,7 @@ void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->soundCtx.seqIndex = cmd->soundSettings.musicSeq; globalCtx->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX; - if (gSaveContext.seqIndex == 0xFF || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { + if (gSaveContext.seqIndex == (u8)NA_BGM_DISABLED || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { audio_setBGM(cmd->soundSettings.bgmId); } } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 550bbbc8e..1cae35a85 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -45,7 +45,7 @@ void Select_LoadGame(SelectContext* this, u32 entranceIndex, s32 opt) { } gSaveContext.respawn[0].entranceIndex = 0xFFFF; - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.showTitleCard = true; gSaveContext.respawnFlag = 0; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index ed732fc3d..62a85c863 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -127,7 +127,7 @@ void Title_Main(GameState* thisx) { Title_UpdateCounters(this); Title_Draw(&this->gameState); if (this->exit) { - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.gameMode = 1; From 9a424688b108104b3c0c34d9106c02fece7313c7 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 19 Nov 2021 07:52:32 -0800 Subject: [PATCH 14/17] Add ability to warnings script to just check building (not setup or disasm) (#414) * Add option to run warnings on just build * Rename all to full * Update tools/warnings_count/check_new_warnings.sh Remove testing code. Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> --- tools/warnings_count/check_new_warnings.sh | 41 ++++++++++++++-------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/tools/warnings_count/check_new_warnings.sh b/tools/warnings_count/check_new_warnings.sh index 7a196c28b..27cda1b25 100755 --- a/tools/warnings_count/check_new_warnings.sh +++ b/tools/warnings_count/check_new_warnings.sh @@ -32,18 +32,30 @@ Check for new warnings created. Optional arguments: -h Display this message and exit. + -f Run full build process -j N use N jobs (does not support plain -j because you shouldn't use it anyway) " } jobs=1 +full= +run="make clean + make uncompressed" -while getopts "hj:" opt + + +while getopts "hfj:" opt do case $opt in h) show_help exit 0 ;; + f) full="true" + run="make distclean + make setup + make disasm + make all" + ;; j) j_option_arg="$OPTARG" if [[ ! "${j_option_arg}" =~ ^[0-9]*$ ]] then @@ -61,10 +73,7 @@ shift $(($OPTIND - 1)) # Confirm run with -j jobs echo "This will run - make distclean - make setup - make disasm - make all + $run using $jobs threads. This may take some time." read -r -p "Is this okay? [Y/n]" response response=${response,,} # tolower @@ -90,16 +99,20 @@ make_warnings () { && rm tools/warnings_count/warnings_temp.txt } +if [[ $full ]]; then + make distclean + make_warnings setup setup + make_warnings disasm disasm + make_warnings all build +else + make clean + make_warnings uncompressed build +fi -make distclean -make_warnings setup setup -make_warnings disasm disasm -make_warnings all build -echo " -$(tput ${TPUTTERM} setaf 3)(lots of make output ${TPUTTERM} here...) -$RST" -$COMPARE_WARNINGS setup -$COMPARE_WARNINGS disasm +if [[ $full ]]; then + $COMPARE_WARNINGS setup + $COMPARE_WARNINGS disasm +fi $COMPARE_WARNINGS build From 2dd84d8a9f0ccd04a4f3f62c5bab997fbaed55ed Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sat, 20 Nov 2021 04:18:06 +1100 Subject: [PATCH 15/17] Import abi.h from OoT (#466) --- include/PR/abi.h | 354 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 247 insertions(+), 107 deletions(-) diff --git a/include/PR/abi.h b/include/PR/abi.h index 63d6b0f99..49d539762 100644 --- a/include/PR/abi.h +++ b/include/PR/abi.h @@ -1,7 +1,8 @@ -#ifndef _ABI_H_ -#define _ABI_H_ +#ifndef ULTRA64_ABI_H +#define ULTRA64_ABI_H /* Audio commands: */ +/* #define A_SPNOOP 0 #define A_ADPCM 1 #define A_CLEARBUFF 2 @@ -18,12 +19,37 @@ #define A_INTERLEAVE 13 #define A_POLEF 14 #define A_SETLOOP 15 +*/ +#define A_SPNOOP 0 +#define A_ADPCM 1 +#define A_CLEARBUFF 2 +#define A_UNK3 3 +#define A_ADDMIXER 4 +#define A_RESAMPLE 5 +#define A_RESAMPLE_ZOH 6 +#define A_FILTER 7 +#define A_SETBUFF 8 +#define A_DUPLICATE 9 +#define A_DMEMMOVE 10 +#define A_LOADADPCM 11 +#define A_MIXER 12 +#define A_INTERLEAVE 13 +#define A_HILOGAIN 14 +#define A_SETLOOP 15 +#define A_INTERL 17 +#define A_ENVSETUP1 18 +#define A_ENVMIXER 19 +#define A_LOADBUFF 20 +#define A_SAVEBUFF 21 +#define A_ENVSETUP2 22 +#define A_S8DEC 23 +#define A_UNK19 25 #define ACMD_SIZE 32 + /* * Audio flags */ - #define A_INIT 0x01 #define A_CONTINUE 0x00 #define A_LOOP 0x02 @@ -254,138 +280,252 @@ typedef short ENVMIX_STATE[40]; * Macros to assemble the audio command list */ -#define aADPCMdec(pkt, f, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(f, 16, 8); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aADPCMdec(pkt, f, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(f, 16, 8); \ + _a->words.w1 = (unsigned int)(s); \ +} -#define aPoleFilter(pkt, f, g, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(g, 0, 16)); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aPoleFilter(pkt, f, g, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(g, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define aHiLoGain(pkt, gain, count, dmem, a4) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_HILOGAIN, 24, 8) | \ + _SHIFTL(gain, 16, 8) | _SHIFTL(count, 0, 16)); \ + _a->words.w1 = _SHIFTL(dmem, 16, 16) | _SHIFTL(a4, 0, 16); \ +} + +#define aUnkCmd3(pkt, a1, a2, a3) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_UNK3, 24, 8) | _SHIFTL(a3, 0, 16); \ + _a->words.w1 = _SHIFTL(a1, 16, 16) | _SHIFTL(a2, 0, 16); \ +} + +#define aUnkCmd19(pkt, a1, a2, a3, a4) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_UNK19, 24, 8) | _SHIFTL(a1, 16, 8) | \ + _SHIFTL(a2, 0, 16)); \ + _a->words.w1 = _SHIFTL(a3, 16, 16) | _SHIFTL(a4, 0, 16); \ +} + +#define aS8Dec(pkt, a1, a2) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_S8DEC, 24, 8) | _SHIFTL(a1, 16, 8); \ + _a->words.w1 = (unsigned int)(a2); \ +} #define aClearBuffer(pkt, d, c) \ - { \ +{ \ Acmd *_a = (Acmd *)pkt; \ \ _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(d, 0, 24); \ _a->words.w1 = (unsigned int)(c); \ - } +} -#define aEnvMixer(pkt, f, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_ENVMIXER, 24, 8) | _SHIFTL(f, 16, 8); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aEnvMixer(pkt, dmemi, count, swapLR, x0, x1, x2, x3, m, bits) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (bits | _SHIFTL(dmemi >> 4, 16, 8) | \ + _SHIFTL(count, 8, 8) | _SHIFTL(swapLR, 4, 1) | \ + _SHIFTL(x0, 3, 1) | _SHIFTL(x1, 2, 1) | \ + _SHIFTL(x2, 1, 1) | _SHIFTL(x3, 0, 1)); \ + _a->words.w1 = (unsigned int)(m); \ +} -#define aInterleave(pkt, l, r) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8); \ - _a->words.w1 = _SHIFTL(l, 16, 16) | _SHIFTL(r, 0, 16); \ - } +#define aInterleave(pkt, o, l, r, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_INTERLEAVE, 24, 8) | \ + _SHIFTL(c >> 4, 16, 8) | _SHIFTL(o, 0, 16)); \ + _a->words.w1 = _SHIFTL(l, 16, 16) | _SHIFTL(r, 0, 16); \ +} -#define aLoadBuffer(pkt, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aInterl(pkt, dmemi, dmemo, count) \ +{ \ + Acmd *_a = (Acmd*)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_INTERL, 24, 8) | \ + _SHIFTL(count, 0, 16)); \ + _a->words.w1 = _SHIFTL(dmemi, 16, 16) | _SHIFTL(dmemo, 0, 16); \ +} -#define aMix(pkt, f, g, i, o) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_MIXER, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(g, 0, 16)); \ - _a->words.w1 = _SHIFTL(i, 16, 16) | _SHIFTL(o, 0, 16); \ - } +#define aLoadBuffer(pkt, s, d, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8) | \ + _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(d, 0, 16); \ + _a->words.w1 = (unsigned int)(s); \ +} -#define aPan(pkt, f, d, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_PAN, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(d, 0, 16)); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aMix(pkt, f, g, i, o) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_MIXER, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(g, 0, 16)); \ + _a->words.w1 = _SHIFTL(i, 16, 16) | _SHIFTL(o, 0, 16); \ +} -#define aResample(pkt, f, p, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(p, 0, 16)); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aPan(pkt, f, d, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_PAN, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(d, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ +} -#define aSaveBuffer(pkt, s) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8); \ - _a->words.w1 = (unsigned int)(s); \ - } +#define aResample(pkt, f, p, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | \ + _SHIFTL(f, 16, 8) | _SHIFTL(p, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ +} -#define aSegment(pkt, s, b) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SEGMENT, 24, 8); \ - _a->words.w1 = _SHIFTL(s, 24, 8) | _SHIFTL(b, 0, 24); \ - } +#define aSaveBuffer(pkt, s, d, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8) | \ + _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(s, 0, 16); \ + _a->words.w1 = (unsigned int)(d); \ +} + +#define aSegment(pkt, s, b) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_SEGMENT, 24, 8); \ + _a->words.w1 = _SHIFTL(s, 24, 8) | _SHIFTL(b, 0, 24); \ +} #define aSetBuffer(pkt, f, i, o, c) \ - { \ +{ \ Acmd *_a = (Acmd *)pkt; \ \ _a->words.w0 = (_SHIFTL(A_SETBUFF, 24, 8) | _SHIFTL(f, 16, 8) | \ _SHIFTL(i, 0, 16)); \ - _a->words.w1 = _SHIFTL(c, 0, 16) | _SHIFTL(o, 16, 16); \ - } + _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ +} -#define aSetVolume(pkt, f, v, t, r) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ - _SHIFTL(v, 0, 16)); \ - /* had to change this otherwise it doesn't want to match */ \ - _a->words.w1 = (unsigned int)(r); /*_SHIFTL(r, 0, 16)|_SHIFTL(t, 16, 16) ;*/ \ - } +#define aSetVolume(pkt, f, v, t, r) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ + _SHIFTL(v, 0, 16)); \ + _a->words.w1 = _SHIFTL(r, 0, 16) | _SHIFTL(t, 16, 16); \ +} -#define aSetLoop(pkt, a) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - _a->words.w0 = _SHIFTL(A_SETLOOP, 24, 8); \ - _a->words.w1 = (unsigned int)(a); \ - } +#define aSetVolume32(pkt, f, v, tr) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ + _SHIFTL(v, 0, 16)); \ + _a->words.w1 = (unsigned int)(tr); \ +} -#define aDMEMMove(pkt, i, o, c) \ - { \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(i, 0, 24); \ - _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ - } +#define aSetLoop(pkt, a) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_SETLOOP, 24, 8); \ + _a->words.w1 = (unsigned int)(a); \ +} + +#define aDMEMMove(pkt, i, o, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(i, 0, 24); \ + _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ +} #define aLoadADPCM(pkt, c, d) \ - { \ +{ \ Acmd *_a = (Acmd *)pkt; \ \ _a->words.w0 = _SHIFTL(A_LOADADPCM, 24, 8) | _SHIFTL(c, 0, 24); \ _a->words.w1 = (unsigned int)d; \ - } +} -#endif /* !_ABI_H_ */ + + +#define aEnvSetup1(pkt, a, b, c, d) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_ENVSETUP1, 24, 8) | \ + _SHIFTL(a, 16, 8) | _SHIFTL(b, 0, 16)); \ + _a->words.w1 = _SHIFTL(c, 16, 16) | _SHIFTL(d, 0, 16); \ +} + +#define aEnvSetup2(pkt, volLeft, volRight) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_ENVSETUP2, 24, 8); \ + _a->words.w1 = _SHIFTL(volLeft, 16, 16) | \ + _SHIFTL(volRight, 0, 16); \ +} + +#define aFilter(pkt, f, countOrBuf, addr) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_FILTER, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(countOrBuf, 0, 16); \ + _a->words.w1 = (unsigned int)(addr); \ +} + +#define aDuplicate(pkt, count, dmemi, dmemo, a4) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | \ + _SHIFTL(count, 16, 8) | _SHIFTL(dmemi, 0, 16)); \ + _a->words.w1 = _SHIFTL(dmemo, 16, 16) | _SHIFTL(a4, 0, 16); \ +} + +#define aAddMixer(pkt, count, dmemi, dmemo, a4) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_ADDMIXER, 24, 8) | \ + _SHIFTL(count >> 4, 16, 8) | _SHIFTL(a4, 0, 16)); \ + _a->words.w1 = _SHIFTL(dmemi, 16, 16) | _SHIFTL(dmemo, 0, 16); \ +} + +#define aResampleZoh(pkt, pitch, pitchAccu) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_RESAMPLE_ZOH, 24, 8) | \ + _SHIFTL(pitch, 0, 16)); \ + _a->words.w1 = _SHIFTL(pitchAccu, 0, 16); \ +} + +#endif /* ULTRA64_ABI_H */ From c8b0ff3f747e7c3651788b703cfa355fd9c28b8c Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sat, 20 Nov 2021 05:26:20 +1100 Subject: [PATCH 16/17] Introducing z64audio.h (#459) * Copy over z64audio.h from audio WIP * Cleanup z64audio.h * PR Suggestions * Improvements from Audio doc WIP * More cleanup * Remove a few structs, Introduce OcarinaSongId * More cleanup from audio docs WIP * Fix --- include/variables.h | 4 +- include/z64.h | 40 +- include/z64audio.h | 1186 ++++++++++++++++++++++++++++++++++++ tools/disasm/variables.txt | 4 +- 4 files changed, 1191 insertions(+), 43 deletions(-) create mode 100644 include/z64audio.h diff --git a/include/variables.h b/include/variables.h index 624940525..bc6cef1b4 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1867,7 +1867,7 @@ extern s8 D_801DB4B8; // extern UNK_TYPE1 D_801DB8B8; // extern UNK_TYPE1 D_801DB900; extern UNK_PTR D_801DB930; -extern s8018CFAC D_801DB958[21]; +extern AudioSpec D_801DB958[21]; // rodata extern f32 D_801DBDF0; @@ -3635,7 +3635,7 @@ extern OSMesg D_801FD034; // extern UNK_TYPE1 D_801FE4C0; // extern UNK_TYPE1 D_801FE640; // extern UNK_TYPE1 D_801FE6D0; -extern s801FE7C0 D_801FE7C0[1]; +extern SoundRequest D_801FE7C0[1]; // extern UNK_TYPE1 D_801FFBC0; // extern UNK_TYPE1 D_801FFBC8; // extern UNK_TYPE1 D_801FFBD0; diff --git a/include/z64.h b/include/z64.h index bf430d143..e1dda2fb5 100644 --- a/include/z64.h +++ b/include/z64.h @@ -24,6 +24,7 @@ #include "z64actor.h" #include "z64animation.h" +#include "z64audio.h" #include "z64bgcheck.h" #include "z64collision_check.h" #include "z64cutscene.h" @@ -440,29 +441,6 @@ typedef struct { /* 0x14 */ OSMesgQueue unk14; } s80185D40; // size = 0x2C -typedef struct { - /* 0x00 */ u32 unk0; - /* 0x04 */ u8 unk4; - /* 0x05 */ u8 unk5; - /* 0x06 */ u8 unk6; - /* 0x07 */ UNK_TYPE1 pad7[0x2]; - /* 0x09 */ u8 unk9; - /* 0x0A */ UNK_TYPE1 padA[0x2]; - /* 0x0C */ u32 unkC; - /* 0x10 */ u16 unk10; - /* 0x12 */ u16 unk12; - /* 0x14 */ u16 unk14; - /* 0x16 */ UNK_TYPE1 pad16[0x2]; - /* 0x18 */ u32 unk18; - /* 0x1C */ u32 unk1C; - /* 0x20 */ u32 unk20; - /* 0x24 */ u32 unk24; - /* 0x28 */ u32 unk28; - /* 0x2C */ u32 unk2C; - /* 0x30 */ u32 unk30; - /* 0x34 */ u32 unk34; -} s8018CFAC; // size = 0x38 - typedef struct { /* 0x0 */ u8 unk0; /* 0x1 */ u8 unk1; @@ -474,10 +452,6 @@ typedef struct { /* 0x7 */ u8 unk7; } s801AEC84; // size = 0x8 -typedef struct { - /* 0x00 */ UNK_TYPE1 pad0[0x14]; -} s801FE7C0; // size = 0x14 - typedef struct { /* 0x00 */ Vec3f unk0; /* 0x0C */ Vec3f unkC; @@ -608,12 +582,6 @@ typedef struct { typedef void(*fault_update_input_func)(Input* input); -typedef struct { - /* 0x00 */ u8 noteIdx; - /* 0x01 */ u8 state; - /* 0x02 */ u8 pos; -} OcarinaStaff; // size = 0x3; - typedef struct { /* 0x000 */ View view; /* 0x168 */ u8* iconItemSegment; @@ -1297,12 +1265,6 @@ typedef struct ActorListEntry { #define OS_SC_NMI_MSG 3 // name is made up, 3 is OS_SC_RDP_DONE_MSG in the original sched.c #define OS_SC_PRE_NMI_MSG 4 -typedef struct { - /* 0x0000 */ OSTask task; - /* 0x0040 */ OSMesgQueue* taskQueue; - /* 0x0044 */ char unk_44[0xC]; -} AudioTask; // size = 0x50 - typedef struct { /* 0x000 */ IrqMgr* irqMgr; /* 0x004 */ SchedContext* sched; diff --git a/include/z64audio.h b/include/z64audio.h new file mode 100644 index 000000000..bc6d81a71 --- /dev/null +++ b/include/z64audio.h @@ -0,0 +1,1186 @@ +#ifndef Z64_AUDIO_H +#define Z64_AUDIO_H + +#define MK_AUDIO_CMD(b0,b1,b2,b3) ((((b0) & 0xFF) << 0x18) | (((b1) & 0xFF) << 0x10) | (((b2) & 0xFF) << 0x8) | (((b3) & 0xFF) << 0)) + +#define NO_LAYER ((SequenceLayer*)(-1)) + +#define TATUMS_PER_BEAT 48 + +#define IS_SEQUENCE_CHANNEL_VALID(ptr) ((uintptr_t)(ptr) != (uintptr_t)&gAudioContext.sequenceChannelNone) + +#define MAX_CHANNELS_PER_BANK 3 + +#define ADSR_DISABLE 0 +#define ADSR_HANG -1 +#define ADSR_GOTO -2 +#define ADSR_RESTART -3 + +#define AIBUF_LEN 0x580 + +typedef enum { + /* 0 */ ADSR_STATE_DISABLED, + /* 1 */ ADSR_STATE_INITIAL, + /* 2 */ ADSR_STATE_START_LOOP, + /* 3 */ ADSR_STATE_LOOP, + /* 4 */ ADSR_STATE_FADE, + /* 5 */ ADSR_STATE_HANG, + /* 6 */ ADSR_STATE_DECAY, + /* 7 */ ADSR_STATE_RELEASE, + /* 8 */ ADSR_STATE_SUSTAIN +} AdsrStatus; + +typedef enum { + /* 0 */ MEDIUM_RAM, + /* 1 */ MEDIUM_UNK1, + /* 2 */ MEDIUM_CART, + /* 3 */ MEDIUM_DISK_DRIVE, + /* 4 */ MEDIUM_UNK4, + /* 5 */ MEDIUM_UNK5 +} SampleMedium; + +typedef enum { + /* 0 */ CODEC_ADPCM, + /* 1 */ CODEC_S8, + /* 2 */ CODEC_S16_INMEMORY, + /* 3 */ CODEC_SMALL_ADPCM, + /* 4 */ CODEC_REVERB, + /* 5 */ CODEC_S16 +} SampleCodec; + +typedef enum { + /* 0 */ SEQUENCE_TABLE, + /* 1 */ FONT_TABLE, + /* 2 */ SAMPLE_TABLE +} SampleBankTableType; + +typedef enum { + /* 0 */ CACHE_TEMPORARY, + /* 1 */ CACHE_PERSISTENT, + /* 2 */ CACHE_EITHER, + /* 3 */ CACHE_PERMANENT +} AudioCacheType; + +typedef enum { + /* 0 */ OCARINA_SONG_SONATA, + /* 1 */ OCARINA_SONG_GORON_LULLABY, + /* 2 */ OCARINA_SONG_NEW_WAVE, + /* 3 */ OCARINA_SONG_ELEGY, + /* 4 */ OCARINA_SONG_OATH, + /* 5 */ OCARINA_SONG_SARIAS, + /* 6 */ OCARINA_SONG_TIME, + /* 7 */ OCARINA_SONG_HEALING, + /* 8 */ OCARINA_SONG_EPONAS, + /* 9 */ OCARINA_SONG_SOARING, + /* 10 */ OCARINA_SONG_STORMS, + /* 11 */ OCARINA_SONG_SUNS, + /* 12 */ OCARINA_SONG_INVERTED_TIME, + /* 13 */ OCARINA_SONG_DOUBLE_TIME, + /* 14 */ OCARINA_SONG_GORON_LULLABY_INTRO, + /* 15 */ OCARINA_SONG_WIND_FISH_HUMAN, // "Ballad of the Wind Fish" + /* 16 */ OCARINA_SONG_WIND_FISH_GORON, + /* 17 */ OCARINA_SONG_WIND_FISH_ZORA, + /* 18 */ OCARINA_SONG_WIND_FISH_DEKU, + /* 19 */ OCARINA_SONG_EVAN_PART1, + /* 20 */ OCARINA_SONG_EVAN_PART2, + /* 21 */ OCARINA_SONG_ZELDAS_LULLABY, + /* 22 */ OCARINA_SONG_SCARECROW, + /* 23 */ OCARINA_SONG_TERMINA_WALL, + /* 24 */ OCARINA_SONG_MAX, +} OcarinaSongId; + +typedef enum { + /* 0 */ OCARINA_BTN_A, + /* 1 */ OCARINA_BTN_C_DOWN, + /* 2 */ OCARINA_BTN_C_RIGHT, + /* 3 */ OCARINA_BTN_C_LEFT, + /* 4 */ OCARINA_BTN_C_UP, + /* -1 */ OCARINA_BTN_INVALID = 0xFF +} OcarinaButtonIdx; + +typedef enum { + /* 0x0 */ NOTE_C4, + /* 0x1 */ NOTE_DFLAT4, + /* 0x2 */ NOTE_D4, + /* 0x3 */ NOTE_EFLAT4, + /* 0x4 */ NOTE_E4, + /* 0x5 */ NOTE_F4, + /* 0x6 */ NOTE_GFLAT4, + /* 0x7 */ NOTE_G4, + /* 0x8 */ NOTE_AFLAT4, + /* 0x9 */ NOTE_A4, + /* 0xA */ NOTE_BFLAT4, + /* 0xB */ NOTE_B4, + /* 0xC */ NOTE_C5, + /* 0xD */ NOTE_DFLAT5, + /* 0xE */ NOTE_D5, + /* 0xF */ NOTE_EFLAT5, + /* -1 */ NOTE_NONE = 0xFF +} OcarinaNoteIdx; + +typedef s32 (*DmaHandler)(OSPiHandle* handle, OSIoMesg* mb, s32 direction); + +struct Note; +struct NotePool; +struct SequenceChannel; +struct SequenceLayer; + +// A node in a circularly linked list. Each node is either a head or an item: +// - Items can be either detached (prev = NULL), or attached to a list. +// 'value' points to something of interest. +// - List heads are always attached; if a list is empty, its head points +// to itself. 'count' contains the size of the list. +// If the list holds notes, 'pool' points back to the pool where it lives. +// Otherwise, that member is NULL. +typedef struct AudioListItem { + /* 0x00 */ struct AudioListItem* prev; + /* 0x04 */ struct AudioListItem* next; + union { + /* 0x08 */ void* value; // either Note* or SequenceLayer* + /* 0x08 */ s32 count; + } u; + /* 0x0C */ struct NotePool* pool; +} AudioListItem; // size = 0x10 + +typedef struct NotePool { + /* 0x00 */ AudioListItem disabled; + /* 0x10 */ AudioListItem decaying; + /* 0x20 */ AudioListItem releasing; + /* 0x30 */ AudioListItem active; +} NotePool; // size = 0x40 + +// Pitch sliding by up to one octave in the positive direction. Negative +// direction is "supported" by setting extent to be negative. The code +// extrapolates exponentially in the wrong direction in that case, but that +// doesn't prevent seqplayer from doing it, AFAICT. +typedef struct { + /* 0x00 */ u8 mode; // bit 0x80 denotes something; the rest are an index 0-5 + /* 0x02 */ u16 cur; + /* 0x04 */ u16 speed; + /* 0x08 */ f32 extent; +} Portamento; // size = 0xC + +typedef struct { + /* 0x0 */ s16 delay; + /* 0x2 */ s16 arg; +} AdsrEnvelope; // size = 0x4 + +typedef struct { + /* 0x00 */ u32 start; + /* 0x04 */ u32 end; + /* 0x08 */ u32 count; + /* 0x0C */ u32 unk_0C; + /* 0x10 */ s16 state[16]; // only exists if count != 0. 8-byte aligned +} AdpcmLoop; // size = 0x30 (or 0x10) + +typedef struct { + /* 0x00 */ s32 order; + /* 0x04 */ s32 npredictors; + /* 0x08 */ s16 book[1]; // size 8 * order * npredictors. 8-byte aligned +} AdpcmBook; // size >= 0x8 + +typedef struct { + /* 0x00 */ u32 unk_0 : 1; + /* 0x00 */ u32 codec : 3; + /* 0x00 */ u32 medium : 2; + /* 0x00 */ u32 unk_bit26 : 1; + /* 0x00 */ u32 unk_bit25 : 1; + /* 0x01 */ u32 size : 24; + /* 0x04 */ u8* sampleAddr; + /* 0x08 */ AdpcmLoop* loop; + /* 0x0C */ AdpcmBook* book; +} SoundFontSample; // size = 0x10 + +typedef struct { + /* 0x00 */ SoundFontSample* sample; + /* 0x04 */ f32 tuning; // frequency scale factor +} SoundFontSound; // size = 0x8 + +typedef struct { + /* 0x00 */ s16 numSamplesAfterDownsampling; // never read + /* 0x02 */ s16 chunkLen; // never read + /* 0x04 */ s16* toDownsampleLeft; + /* 0x08 */ s16* toDownsampleRight; // data pointed to by left and right are adjacent in memory + /* 0x0C */ s32 startPos; // start pos in ring buffer + /* 0x10 */ s16 lengthA; // first length in ring buffer (from startPos, at most until end) + /* 0x12 */ s16 lengthB; // second length in ring buffer (from pos 0) + /* 0x14 */ u16 unk_14; + /* 0x16 */ u16 unk_16; + /* 0x18 */ u16 unk_18; +} ReverbRingBufferItem; // size = 0x1C + +typedef struct { + /* 0x000 */ u8 resampleFlags; + /* 0x001 */ u8 useReverb; + /* 0x002 */ u8 framesToIgnore; + /* 0x003 */ u8 curFrame; + /* 0x004 */ u8 downsampleRate; + /* 0x005 */ s8 unk_05; + /* 0x006 */ u16 windowSize; + /* 0x008 */ s16 unk_08; + /* 0x00A */ s16 unk_0A; + /* 0x00C */ u16 unk_0C; + /* 0x00E */ u16 unk_0E; + /* 0x010 */ s16 leakRtl; + /* 0x012 */ s16 leakLtr; + /* 0x014 */ u16 unk_14; + /* 0x016 */ s16 unk_16; + /* 0x018 */ u8 unk_18; + /* 0x019 */ s8 unk_19; + /* 0x01A */ u16 unk_1A; + /* 0x01C */ u16 unk_1C; + /* 0x01E */ u8 unk_1E; + /* 0x020 */ s32 nextRingBufPos; + /* 0x024 */ s32 unk_24; // May be bufSizePerChan + /* 0x028 */ s16* leftRingBuf; + /* 0x02C */ s16* rightRingBuf; + /* 0x030 */ void* unk_30; + /* 0x034 */ void* unk_34; + /* 0x038 */ void* unk_38; + /* 0x03C */ void* unk_3C; + /* 0x040 */ ReverbRingBufferItem items[2][5]; + /* 0x158 */ ReverbRingBufferItem items2[2][5]; + /* 0x270 */ s16* filterLeft; + /* 0x274 */ s16* filterRight; + /* 0x278 */ s16* unk_278; + /* 0x27C */ s16* unk_27C; + /* 0x280 */ s16* filterLeftState; + /* 0x284 */ s16* filterRightState; + /* 0x288 */ SoundFontSound sound; + /* 0x290 */ SoundFontSample sample; + /* 0x2A0 */ AdpcmLoop loop; +} SynthesisReverb; // size = 0x2D0 + +typedef struct { + /* 0x00 */ u8 loaded; + /* 0x01 */ u8 normalRangeLo; + /* 0x02 */ u8 normalRangeHi; + /* 0x03 */ u8 releaseRate; + /* 0x04 */ AdsrEnvelope* envelope; + /* 0x08 */ SoundFontSound lowNotesSound; + /* 0x10 */ SoundFontSound normalNotesSound; + /* 0x18 */ SoundFontSound highNotesSound; +} Instrument; // size = 0x20 + +typedef struct { + /* 0x00 */ u8 releaseRate; + /* 0x01 */ u8 pan; + /* 0x02 */ u8 loaded; + /* 0x04 */ SoundFontSound sound; + /* 0x14 */ AdsrEnvelope* envelope; +} Drum; // size = 0x18 + +typedef struct { + /* 0x00 */ u8 numInstruments; + /* 0x01 */ u8 numDrums; + /* 0x02 */ u8 sampleBankId1; + /* 0x03 */ u8 sampleBankId2; + /* 0x04 */ u16 numSfx; + /* 0x08 */ Instrument** instruments; + /* 0x0C */ Drum** drums; + /* 0x10 */ SoundFontSound* soundEffects; +} SoundFont; // size = 0x14 + +typedef struct { + /* 0x00 */ u8* pc; + /* 0x04 */ u8* stack[4]; + /* 0x14 */ u8 remLoopIters[4]; + /* 0x18 */ u8 depth; + /* 0x19 */ s8 value; +} SeqScriptState; // size = 0x1C + +// Also known as a Group, according to debug strings. +typedef struct { + /* 0x000 */ u8 enabled : 1; + /* 0x000 */ u8 finished : 1; + /* 0x000 */ u8 muted : 1; + /* 0x000 */ u8 seqDmaInProgress : 1; + /* 0x000 */ u8 fontDmaInProgress : 1; + /* 0x000 */ u8 recalculateVolume : 1; + /* 0x000 */ u8 stopScript : 1; + /* 0x000 */ u8 unk_0b1 : 1; + /* 0x001 */ u8 state; + /* 0x002 */ u8 noteAllocPolicy; + /* 0x003 */ u8 muteBehavior; + /* 0x004 */ u8 seqId; + /* 0x005 */ u8 defaultFont; + /* 0x006 */ u8 unk_06[1]; + /* 0x007 */ s8 playerIdx; + /* 0x008 */ u16 tempo; // tatums per minute + /* 0x00A */ u16 tempoAcc; + /* 0x00C */ s16 unk_0C; + /* 0x00E */ s16 transposition; + /* 0x010 */ u16 delay; + /* 0x012 */ u16 fadeTimer; + /* 0x014 */ u16 fadeTimerUnkEu; + /* 0x016 */ u16 unk_16; // New to MM + union { + /* 0x018 */ u8* seqData; + /* 0x018 */ u16* seqData16; + }; + /* 0x01C */ f32 fadeVolume; + /* 0x020 */ f32 fadeVelocity; + /* 0x024 */ f32 volume; + /* 0x028 */ f32 muteVolumeScale; + /* 0x02C */ f32 fadeVolumeScale; + /* 0x030 */ f32 appliedFadeVolume; + /* 0x034 */ f32 unk_34; + /* 0x038 */ struct SequenceChannel* channels[16]; + /* 0x078 */ SeqScriptState scriptState; + /* 0x094 */ u8* shortNoteVelocityTable; + /* 0x098 */ u8* shortNoteGateTimeTable; + /* 0x09C */ NotePool notePool; + /* 0x0DC */ s32 skipTicks; + /* 0x0E0 */ u32 scriptCounter; + /* 0x0E4 */ char unk_E4[0x74]; // unused struct members for sequence/sound font dma management, according to sm64 decomp + /* 0x158 */ s8 soundScriptIO[8]; +} SequencePlayer; // size = 0x160 + +typedef struct { + /* 0x0 */ u8 releaseRate; + /* 0x1 */ u8 sustain; + /* 0x4 */ AdsrEnvelope* envelope; +} AdsrSettings; // size = 0x8 + +typedef struct { + union { + struct { + /* 0x00 */ u8 unk_0b80 : 1; + /* 0x00 */ u8 hang : 1; + /* 0x00 */ u8 decay : 1; + /* 0x00 */ u8 release : 1; + /* 0x00 */ u8 state : 4; + } s; + /* 0x00 */ u8 asByte; + } action; + /* 0x01 */ u8 envIndex; + /* 0x02 */ s16 delay; + /* 0x04 */ f32 sustain; + /* 0x08 */ f32 velocity; + /* 0x0C */ f32 fadeOutVel; + /* 0x10 */ f32 current; + /* 0x14 */ f32 target; + /* 0x18 */ char unk_18[4]; + /* 0x1C */ AdsrEnvelope* envelope; +} AdsrState; // size = 0x20 + +typedef struct { + /* 0x0 */ u8 unused : 2; + /* 0x0 */ u8 bit2 : 2; + /* 0x0 */ u8 strongRight : 1; + /* 0x0 */ u8 strongLeft : 1; + /* 0x0 */ u8 stereoHeadsetEffects : 1; + /* 0x0 */ u8 usesHeadsetPanEffects : 1; +} StereoData; // size = 0x1 + +typedef union { + /* 0x0 */ StereoData s; + /* 0x0 */ u8 asByte; +} Stereo; // size = 0x1 + +typedef struct { + /* 0x00 */ u8 reverb; + /* 0x01 */ u8 unk_1; + /* 0x02 */ u8 pan; + /* 0x03 */ u8 unk_3; // Possibly part of stereo? + /* 0x04 */ Stereo stereo; + /* 0x05 */ u8 unk_4; + /* 0x06 */ u16 unk_6; + /* 0x08 */ f32 freqScale; + /* 0x0C */ f32 velocity; + /* 0x10 */ s16* filter; + /* 0x14 */ s16* filterBuf; +} NoteAttributes; // size = 0x18 + +typedef struct VibratoSubStruct { + /* 0x0 */ u16 vibratoRateStart; + /* 0x2 */ u16 vibratoExtentStart; + /* 0x4 */ u16 vibratoRateTarget; + /* 0x6 */ u16 vibratoExtentTarget; + /* 0x8 */ u16 vibratoRateChangeDelay; + /* 0xA */ u16 vibratoExtentChangeDelay; + /* 0xC */ u16 vibratoDelay; +} VibratoSubStruct; // size = 0xE + +typedef struct SequenceChannelSubStruct { + /* 0x0 */ u8 enabled : 1; + /* 0x0 */ u8 finished : 1; + /* 0x0 */ u8 stopScript : 1; + /* 0x0 */ u8 stopSomething2 : 1; // sets SequenceLayer.stopSomething + /* 0x0 */ u8 hasInstrument : 1; + /* 0x0 */ u8 stereoHeadsetEffects : 1; + /* 0x0 */ u8 largeNotes : 1; // notes specify duration and velocity + /* 0x0 */ u8 unused : 1; +} SequenceChannelSubStruct; // size = 0x1 + +// Also known as a SubTrack, according to sm64 debug strings. +typedef struct SequenceChannel { + /* 0x00 */ u8 enabled : 1; + /* 0x00 */ u8 finished : 1; + /* 0x00 */ u8 stopScript : 1; + /* 0x00 */ u8 stopSomething2 : 1; // sets SequenceLayer.stopSomething + /* 0x00 */ u8 hasInstrument : 1; + /* 0x00 */ u8 stereoHeadsetEffects : 1; + /* 0x00 */ u8 largeNotes : 1; // notes specify duration and velocity + /* 0x00 */ u8 unused : 1; + union { + struct { + /* 0x01 */ u8 freqScale : 1; + /* 0x01 */ u8 volume : 1; + /* 0x01 */ u8 pan : 1; + } s; + /* 0x01 */ u8 asByte; + } changes; + /* 0x02 */ u8 noteAllocPolicy; + /* 0x03 */ u8 muteBehavior; + /* 0x04 */ u8 reverb; // or dry/wet mix + /* 0x05 */ u8 notePriority; // 0-3 + /* 0x06 */ u8 someOtherPriority; + /* 0x07 */ u8 fontId; + /* 0x08 */ u8 reverbIndex; + /* 0x09 */ u8 bookOffset; + /* 0x0A */ u8 newPan; + /* 0x0B */ u8 panChannelWeight; // proportion of pan that comes from the channel (0..128) + /* 0x0C */ u8 unk_0C; + /* 0x0D */ u8 velocityRandomVariance; + /* 0x0E */ u8 gateTimeRandomVariance; + /* 0x0F */ u8 unk_0F; + /* 0x10 */ u8 unk_10; // New to MM + /* 0x11 */ u8 unk_11; // New to MM + /* 0x12 */ VibratoSubStruct vibrato; + /* 0x20 */ u16 delay; + /* 0x22 */ u16 unk_20; + /* 0x24 */ u16 unk_22; + /* 0x26 */ s16 instOrWave; // either 0 (none), instrument index + 1, or + // 0x80..0x83 for sawtooth/triangle/sine/square waves. + /* 0x28 */ s16 transposition; + /* 0x2C */ f32 volumeScale; + /* 0x30 */ f32 volume; + /* 0x34 */ s32 pan; + /* 0x38 */ f32 appliedVolume; + /* 0x3C */ f32 freqScale; + /* 0x40 */ u8 (*dynTable)[][2]; + /* 0x44 */ struct Note* noteUnused; + /* 0x48 */ struct SequenceLayer* layerUnused; + /* 0x4C */ Instrument* instrument; + /* 0x50 */ SequencePlayer* seqPlayer; + /* 0x54 */ struct SequenceLayer* layers[4]; + /* 0x64 */ SeqScriptState scriptState; + /* 0x80 */ AdsrSettings adsr; + /* 0x88 */ NotePool notePool; + /* 0xC8 */ s8 soundScriptIO[8]; // bridge between sound script and audio lib, "io ports" + /* 0xD0 */ u8* unk_D0; // New to MM + /* 0xD4 */ s16* filter; + /* 0xD8 */ Stereo stereo; + /* 0xDC */ s32 unk_DC; // New to MM + /* 0xE0 */ s32 unk_E0; // New to MM +} SequenceChannel; // size = 0xE4 + +// Might also be known as a Track, according to sm64 debug strings (?). +typedef struct SequenceLayer { + /* 0x00 */ u8 enabled : 1; + /* 0x00 */ u8 finished : 1; + /* 0x00 */ u8 stopSomething : 1; + /* 0x00 */ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound + /* 0x00 */ u8 bit3 : 1; // "loaded"? + /* 0x00 */ u8 ignoreDrumPan : 1; + /* 0x00 */ u8 bit1 : 1; // "has initialized continuous notes"? + /* 0x00 */ u8 notePropertiesNeedInit : 1; + /* 0x01 */ Stereo stereo; + /* 0x02 */ u8 instOrWave; + /* 0x03 */ u8 gateTime; + /* 0x04 */ u8 semitone; + /* 0x05 */ u8 portamentoTargetNote; + /* 0x06 */ u8 pan; // 0..128 + /* 0x07 */ u8 notePan; + /* 0x08 */ u8 unk_08; + /* 0x09 */ u8 unk_09; + union { + struct { + /* 0x0A */ u16 bit_0 : 1; + /* 0x0A */ u16 bit_1 : 1; + /* 0x0A */ u16 bit_2 : 1; + /* 0x0A */ u16 bit_3 : 1; + /* 0x0A */ u16 bit_4 : 1; + /* 0x0A */ u16 bit_5 : 1; + /* 0x0A */ u16 bit_6 : 1; + /* 0x0A */ u16 bit_7 : 1; + /* 0x0A */ u16 bit_8 : 1; + /* 0x0A */ u16 bit_9 : 1; + /* 0x0A */ u16 bit_A : 1; + /* 0x0A */ u16 bit_B : 1; + /* 0x0A */ u16 bit_C : 1; + /* 0x0A */ u16 bit_D : 1; + /* 0x0A */ u16 bit_E : 1; + /* 0x0A */ u16 bit_F : 1; + } s; + /* 0x0A */ u16 asByte; + } unk_0A; + /* 0x0C */ VibratoSubStruct vibrato; + /* 0x1A */ s16 delay; + /* 0x1C */ s16 gateDelay; + /* 0x1E */ s16 delay2; + /* 0x20 */ u16 portamentoTime; + /* 0x22 */ s16 transposition; // #semitones added to play commands + // (seq instruction encoding only allows referring to the limited range + // 0..0x3F; this makes 0x40..0x7F accessible as well) + /* 0x24 */ s16 shortNoteDefaultDelay; + /* 0x26 */ s16 lastDelay; + /* 0x28 */ AdsrSettings adsr; + /* 0x30 */ Portamento portamento; + /* 0x3C */ struct Note* note; + /* 0x40 */ f32 freqScale; + /* 0x44 */ f32 unk_34; + /* 0x48 */ f32 velocitySquare2; + /* 0x4C */ f32 velocitySquare; // not sure which one of those corresponds to the sm64 original + /* 0x50 */ f32 noteVelocity; + /* 0x54 */ f32 noteFreqScale; + /* 0x58 */ Instrument* instrument; + /* 0x5C */ SoundFontSound* sound; + /* 0x60 */ SequenceChannel* channel; // Not SequenceChannel? + /* 0x64 */ SeqScriptState scriptState; + /* 0x80 */ AudioListItem listItem; +} SequenceLayer; // size = 0x90 + +typedef struct { + /* 0x00 */ s16 adpcmdecState[0x10]; + /* 0x20 */ s16 finalResampleState[0x10]; + /* 0x40 */ s16 mixEnvelopeState[0x28]; + /* 0x90 */ s16 panResampleState[0x10]; + /* 0xB0 */ s16 panSamplesBuffer[0x20]; + /* 0xF0 */ s16 dummyResampleState[0x10]; +} NoteSynthesisBuffers; // size = 0x110 + +typedef struct { + /* 0x00 */ u8 restart_bit0 : 1; + /* 0x00 */ u8 restart_bit1 : 1; + /* 0x00 */ u8 restart_bit2 : 1; + /* 0x00 */ u8 restart_bit3 : 1; + /* 0x00 */ u8 restart_bit4 : 1; + /* 0x00 */ u8 restart_bit5 : 1; + /* 0x00 */ u8 restart_bit6 : 1; + /* 0x00 */ u8 restart_bit7 : 1; + /* 0x01 */ u8 sampleDmaIndex; + /* 0x02 */ u8 prevHeadsetPanRight; + /* 0x03 */ u8 prevHeadsetPanLeft; + /* 0x04 */ u8 reverbVol; + /* 0x05 */ u8 numParts; + /* 0x06 */ u16 samplePosFrac; + /* 0x08 */ u16 unk_08; // New to MM + /* 0x0C */ s32 samplePosInt; + /* 0x10 */ NoteSynthesisBuffers* synthesisBuffers; + /* 0x14 */ s16 curVolLeft; + /* 0x16 */ s16 curVolRight; + /* 0x18 */ u16 unk_14; + /* 0x1A */ u16 unk_16; + /* 0x1C */ u16 unk_18; + /* 0x1E */ u8 unk_1A; + /* 0x1F */ u8 unk_1F; + /* 0x20 */ u16 unk_1C; + /* 0x22 */ u16 unk_1E; +} NoteSynthesisState; // size = 0x24 + +typedef struct { + /* 0x00 */ struct VibratoSubStruct* vibSubStruct; // MM Something else? + /* 0x04 */ u32 time; + /* 0x08 */ s16* curve; + /* 0x0C */ f32 extent; + /* 0x10 */ f32 rate; + /* 0x14 */ u8 active; + /* 0x16 */ u16 rateChangeTimer; + /* 0x18 */ u16 extentChangeTimer; + /* 0x1A */ u16 delay; +} VibratoState; // size = 0x1C + +typedef struct { + /* 0x00 */ u8 priority; + /* 0x01 */ u8 waveId; + /* 0x02 */ u8 sampleCountIndex; + /* 0x03 */ u8 fontId; + /* 0x04 */ u8 unk_04; + /* 0x05 */ u8 stereoHeadsetEffects; + /* 0x06 */ s16 adsrVolScaleUnused; + /* 0x08 */ f32 portamentoFreqScale; + /* 0x0C */ f32 vibratoFreqScale; + /* 0x18 */ SequenceLayer* wantedParentLayer; + /* 0x14 */ SequenceLayer* parentLayer; + /* 0x10 */ SequenceLayer* prevParentLayer; + /* 0x1C */ NoteAttributes attributes; + /* 0x34 */ AdsrState adsr; + /* 0x54 */ Portamento portamento; + /* 0x60 */ VibratoState vibratoState; + /* 0x7C */ char unk_7C[0x8]; + /* 0x84 */ u32 unk_84; +} NotePlaybackState; // size = 0x88 + +typedef struct { + struct { + /* 0x00 */ volatile u8 enabled : 1; + /* 0x00 */ u8 needsInit : 1; + /* 0x00 */ u8 finished : 1; // ? + /* 0x00 */ u8 unused : 1; + /* 0x00 */ u8 stereoStrongRight : 1; + /* 0x00 */ u8 stereoStrongLeft : 1; + /* 0x00 */ u8 stereoHeadsetEffects : 1; + /* 0x00 */ u8 usesHeadsetPanEffects : 1; // ? + } bitField0; + struct { + /* 0x01 */ u8 reverbIndex : 3; + /* 0x01 */ u8 bookOffset : 2; + /* 0x01 */ u8 isSyntheticWave : 1; + /* 0x01 */ u8 hasTwoParts : 1; + /* 0x01 */ u8 usesHeadsetPanEffects2 : 1; + } bitField1; + /* 0x02 */ u8 unk_2; + /* 0x03 */ u8 headsetPanRight; + /* 0x04 */ u8 headsetPanLeft; + /* 0x05 */ u8 reverbVol; + /* 0x06 */ u8 unk_06; + /* 0x07 */ u8 unk_07; + /* 0x08 */ u16 targetVolLeft; + /* 0x0A */ u16 targetVolRight; + /* 0x0C */ u16 resamplingRateFixedPoint; + /* 0x0E */ u16 unk_0E; + union { + /* 0x10 */ SoundFontSound* soundFontSound; + /* 0x10 */ s16* samples; // used for synthetic waves + } sound; + /* 0x14 */ s16* filter; + /* 0x18 */ u8 unk_18; // New to MM + /* 0x19 */ u8 unk_19; // New to MM + /* 0x1A */ UNK_TYPE1 pad_1A[0x6]; +} NoteSubEu; // size = 0x20 + +typedef struct Note { + /* 0x00 */ AudioListItem listItem; + /* 0x10 */ NoteSynthesisState synthesisState; + /* 0x34 */ NotePlaybackState playbackState; + /* 0xBC */ char unk_BC[0x1C]; + /* 0xD8 */ NoteSubEu noteSubEu; +} Note; // size = 0xF8 + +typedef struct { + /* 0x00 */ u8 downsampleRate; + /* 0x02 */ u16 windowSize; + /* 0x04 */ u16 unk_4; + /* 0x06 */ u16 unk_6; + /* 0x08 */ u16 unk_8; + /* 0x0A */ u16 unk_A; + /* 0x0C */ u16 leakRtl; + /* 0x0E */ u16 leakLtr; + /* 0x10 */ s8 unk_10; + /* 0x12 */ u16 unk_12; + /* 0x14 */ s16 lowPassFilterCutoffLeft; + /* 0x16 */ s16 lowPassFilterCutoffRight; +} ReverbSettings; // size = 0x18 + +typedef struct { + /* 0x00 */ u32 frequency; + /* 0x04 */ u8 unk_04; + /* 0x05 */ u8 numNotes; + /* 0x06 */ u8 numSequencePlayers; + /* 0x07 */ u8 unk_07[0x2]; // unused, set to zero + /* 0x09 */ u8 numReverbs; + /* 0x0A */ u8 unk_0A[0x2]; + /* 0x0C */ ReverbSettings* reverbSettings; + /* 0x10 */ u16 sampleDmaBufSize1; + /* 0x12 */ u16 sampleDmaBufSize2; + /* 0x14 */ u16 unk_14; + /* 0x18 */ u32 persistentSeqMem; + /* 0x1C */ u32 persistentFontMem; + /* 0x20 */ u32 persistentSampleMem; + /* 0x24 */ u32 temporarySeqMem; + /* 0x28 */ u32 temporaryFontMem; + /* 0x2C */ u32 temporarySampleMem; + /* 0x30 */ s32 persistentSampleCacheMem; + /* 0x34 */ s32 temporarySampleCacheMem; +} AudioSpec; // size = 0x38 + +typedef struct { + /* 0x00 */ s16 specUnk4; + /* 0x02 */ u16 frequency; + /* 0x04 */ u16 aiFrequency; + /* 0x06 */ s16 samplesPerFrameTarget; + /* 0x08 */ s16 maxAiBufferLength; + /* 0x0A */ s16 minAiBufferLength; + /* 0x0C */ s16 updatesPerFrame; + /* 0x0E */ s16 samplesPerUpdate; + /* 0x10 */ s16 samplesPerUpdateMax; + /* 0x12 */ s16 samplesPerUpdateMin; + /* 0x14 */ s16 numSequencePlayers; + /* 0x18 */ f32 resampleRate; + /* 0x1C */ f32 updatesPerFrameInv; + /* 0x20 */ f32 unkUpdatesPerFrameScaled; + /* 0x24 */ f32 unk_24; +} AudioBufferParameters; // size = 0x28 + +typedef struct { + /* 0x0 */ u8* start; + /* 0x4 */ u8* cur; + /* 0x8 */ s32 size; + /* 0xC */ s32 count; +} AudioAllocPool; // size = 0x10 + +typedef struct { + /* 0x0 */ u8* ptr; + /* 0x4 */ u32 size; + /* 0x8 */ s16 tableType; + /* 0xA */ s16 id; +} AudioCacheEntry; // size = 0xC + +typedef struct { + /* 0x00 */ s8 inUse; + /* 0x01 */ s8 origMedium; + /* 0x02 */ u8 sampleBankId; + /* 0x03 */ char unk_03[0x5]; + /* 0x08 */ u8* allocatedAddr; + /* 0x0C */ void* sampleAddr; + /* 0x10 */ u32 size; +} SampleCacheEntry; // size = 0x14 + +typedef struct { + /* 0x000 */ AudioAllocPool pool; + /* 0x010 */ SampleCacheEntry entries[128]; + /* 0xA10 */ s32 size; +} AudioSampleCache; // size = 0xA14 + +typedef struct { + /* 0x00 */ u32 numEntries; + /* 0x04 */ AudioAllocPool pool; + /* 0x14 */ AudioCacheEntry entries[16]; +} AudioPersistentCache; // size = 0xD4 + +typedef struct { + /* 0x00 */ u32 nextSide; + /* 0x04 */ AudioAllocPool pool; + /* 0x14 */ AudioCacheEntry entries[2]; +} AudioTemporaryCache; // size = 0x3C + +typedef struct { + /* 0x000 */ AudioPersistentCache persistent; + /* 0x0D4 */ AudioTemporaryCache temporary; + /* 0x100 */ u8 unk_100[0x10]; +} AudioCache; // size = 0x110 + +typedef struct { + /* 0x0 */ u32 wantPersistent; + /* 0x4 */ u32 wantTemporary; +} AudioPoolSplit2; // size = 0x8 + +typedef struct { + /* 0x0 */ u32 wantSeq; + /* 0x4 */ u32 wantFont; + /* 0x8 */ u32 wantSample; +} AudioPoolSplit3; // size = 0xC + +typedef struct { + /* 0x0 */ u32 wantSeq; + /* 0x4 */ u32 wantFont; + /* 0x8 */ u32 wantSample; + /* 0xC */ u32 wantCustom; +} AudioPoolSplit4; // size = 0x10 + +typedef struct { + /* 0x00 */ u32 endAndMediumKey; + /* 0x04 */ SoundFontSample* sample; + /* 0x08 */ u8* ramAddr; + /* 0x0C */ u32 encodedInfo; + /* 0x10 */ s32 isFree; +} AudioPreloadReq; // size = 0x14 + +typedef struct { + union { + /* 0x0 */ u32 opArgs; + struct { + /* 0x0 */ u8 op; + /* 0x1 */ u8 arg0; + /* 0x2 */ u8 arg1; + /* 0x3 */ u8 arg2; + }; + }; + union { + /* 0x4 */ void* data; + /* 0x4 */ f32 asFloat; + /* 0x4 */ s32 asInt; + /* 0x4 */ u16 asUShort; + /* 0x4 */ s8 asSbyte; + /* 0x4 */ u8 asUbyte; + /* 0x4 */ u32 asUInt; + }; +} AudioCmd; // size = 0x8 + +typedef struct { + /* 0x00 */ s8 status; + /* 0x01 */ s8 delay; + /* 0x02 */ s8 medium; + /* 0x04 */ u8* ramAddr; + /* 0x08 */ u32 curDevAddr; + /* 0x0C */ u8* curRamAddr; + /* 0x10 */ u32 bytesRemaining; + /* 0x14 */ u32 chunkSize; + /* 0x18 */ s32 unkMediumParam; + /* 0x1C */ u32 retMsg; + /* 0x20 */ OSMesgQueue* retQueue; + /* 0x24 */ OSMesgQueue msgQueue; + /* 0x3C */ OSMesg msg; + /* 0x40 */ OSIoMesg ioMesg; +} AudioAsyncLoad; // size = 0x58 + +typedef struct { + /* 0x00 */ u8 medium; + /* 0x01 */ u8 seqOrFontId; + /* 0x02 */ u16 instId; + /* 0x04 */ s32 unkMediumParam; + /* 0x08 */ s32 curDevAddr; + /* 0x0C */ u8* curRamAddr; + /* 0x10 */ u8* ramAddr; + /* 0x14 */ s32 status; + /* 0x18 */ s32 bytesRemaining; + /* 0x1C */ s8* isDone; + /* 0x20 */ SoundFontSample sample; + /* 0x30 */ OSMesgQueue msgqueue; + /* 0x48 */ OSMesg msg; + /* 0x4C */ OSIoMesg ioMesg; +} AudioSlowLoad; // size = 0x64 + +typedef struct { + /* 0x00 */ u32 romAddr; + /* 0x04 */ u32 size; + /* 0x08 */ s8 medium; + /* 0x09 */ s8 cachePolicy; + /* 0x0A */ s16 shortData1; + /* 0x0C */ s16 shortData2; + /* 0x0E */ s16 shortData3; +} AudioTableEntry; // size = 0x10 + +typedef struct { + /* 0x00 */ s16 numEntries; + /* 0x02 */ s16 unkMediumParam; + /* 0x04 */ u32 romAddr; + /* 0x08 */ char pad[0x8]; + /* 0x10 */ AudioTableEntry entries[1]; // (dynamic size) +} AudioTable; // size >= 0x20 + +typedef struct { + /* 0x00 */ OSTask task; + /* 0x40 */ OSMesgQueue* taskQueue; + /* 0x44 */ void* unk_44; // probably a message that gets unused. + /* 0x48 */ char unk_48[0x8]; +} AudioTask; // size = 0x50 + +typedef struct { + /* 0x00 */ u8* ramAddr; + /* 0x04 */ u32 devAddr; + /* 0x08 */ u16 sizeUnused; + /* 0x0A */ u16 size; + /* 0x0C */ u8 unused; + /* 0x0D */ u8 reuseIndex; // position in sSampleDmaReuseQueue1/2, if ttl == 0 + /* 0x0E */ u8 ttl; // duration after which the DMA can be discarded +} SampleDma; // size = 0x10 + +typedef struct { + /* 0x0000 */ char unk_0000; + /* 0x0001 */ s8 numSynthesisReverbs; + /* 0x0002 */ u16 unk_2; + /* 0x0004 */ u16 unk_4; + /* 0x0006 */ char unk_0006[0xA]; + /* 0x0010 */ s16* curLoadedBook; + /* 0x0014 */ NoteSubEu* noteSubsEu; + /* 0x0018 */ SynthesisReverb synthesisReverbs[4]; + /* 0x0B58 */ char unk_0B58[0x30]; + /* 0x0B88 */ SoundFontSample* usedSamples[128]; + /* 0x0D88 */ AudioPreloadReq preloadSampleStack[128]; + /* 0x1788 */ s32 numUsedSamples; + /* 0x178C */ s32 preloadSampleStackTop; + /* 0x1790 */ AudioAsyncLoad asyncLoads[0x10]; + /* 0x1D10 */ OSMesgQueue asyncLoadUnkMediumQueue; + /* 0x1D28 */ char unk_1D08[0x40]; + /* 0x1D68 */ AudioAsyncLoad* curUnkMediumLoad; + /* 0x1D6C */ u32 slowLoadPos; + /* 0x1D70 */ AudioSlowLoad slowLoads[2]; + /* 0x1E38 */ OSPiHandle* cartHandle; + /* 0x1E2C */ OSPiHandle* driveHandle; + /* 0x1E40 */ OSMesgQueue externalLoadQueue; + /* 0x1E58 */ OSMesg externalLoadMesgBuf[0x10]; + /* 0x1E98 */ OSMesgQueue preloadSampleQueue; + /* 0x1EB0 */ OSMesg preloadSampleMesgBuf[0x10]; + /* 0x1EF0 */ OSMesgQueue currAudioFrameDmaQueue; + /* 0x1F08 */ OSMesg currAudioFrameDmaMesgBuf[0x40]; + /* 0x2008 */ OSIoMesg currAudioFrameDmaIoMesgBuf[0x40]; + /* 0x2608 */ OSMesgQueue syncDmaQueue; + /* 0x2620 */ OSMesg syncDmaMesg; + /* 0x2624 */ OSIoMesg syncDmaIoMesg; + /* 0x263C */ SampleDma* sampleDmas; + /* 0x2640 */ u32 sampleDmaCount; + /* 0x2644 */ u32 sampleDmaListSize1; + /* 0x2648 */ s32 unused2628; + /* 0x264C */ u8 sampleDmaReuseQueue1[0x100]; // read pos <= write pos, wrapping mod 256 + /* 0x274C */ u8 sampleDmaReuseQueue2[0x100]; + /* 0x284C */ u8 sampleDmaReuseQueue1RdPos; + /* 0x284D */ u8 sampleDmaReuseQueue2RdPos; + /* 0x284E */ u8 sampleDmaReuseQueue1WrPos; + /* 0x284F */ u8 sampleDmaReuseQueue2WrPos; + /* 0x2850 */ AudioTable* sequenceTable; + /* 0x2854 */ AudioTable* soundFontTable; + /* 0x2858 */ AudioTable* sampleBankTable; + /* 0x285C */ char unk_285C[0x4]; + /* 0x2860 */ u8* sequenceFontTable; + /* 0x2864 */ u16 numSequences; + /* 0x2868 */ SoundFont* soundFonts; + /* 0x286C */ AudioBufferParameters audioBufferParameters; + /* 0x2994 */ f32 unk_2870; + /* 0x2898 */ s32 sampleDmaBufSize1; + /* 0x289C */ s32 sampleDmaBufSize2; + /* 0x28A0 */ char unk_287C[0x10]; + /* 0x28B0 */ s32 sampleDmaBufSize; + /* 0x28B4 */ s32 maxAudioCmds; + /* 0x28B8 */ s32 numNotes; + /* 0x2898 */ s16 tempoInternalToExternal; + /* 0x28BE */ s8 soundMode; + /* 0x28C0 */ s32 totalTaskCnt; + /* 0x28C4 */ s32 curAudioFrameDmaCount; + /* 0x28C8 */ s32 rspTaskIdx; + /* 0x28CC */ s32 curAIBufIdx; + /* 0x28AC */ Acmd* abiCmdBufs[2]; + /* 0x28B4 */ Acmd* curAbiCmdBuf; + /* 0x28DC */ AudioTask* currTask; + /* 0x28C0 */ AudioTask rspTask[2]; + /* 0x2980 */ f32 unk_2960; + /* 0x2984*/ s32 refreshRate; + /* 0x2988 */ s16* aiBuffers[3]; + /* 0x2994 */ s16 aiBufLengths[3]; + /* 0x299C */ u32 audioRandom; + /* 0x29A0 */ s32 audioErrorFlags; + /* 0x29A4 */ volatile u32 resetTimer; + /* 0x29A8 */ u32 (*unk_29A8[4])(s8 value, SequenceChannel* channel); + /* 0x29B8 */ s8 unk_29B8; + /* 0x29BC */ s32 unk_29BC; // sMaxAbiCmdCnt + /* 0x29C0 */ AudioAllocPool audioSessionPool; + /* 0x29D0 */ AudioAllocPool externalPool; + /* 0x29E0 */ AudioAllocPool audioInitPool; + /* 0x29F0 */ AudioAllocPool notesAndBuffersPool; + /* 0x2A00 */ char unk_29D0[0x20]; // probably two unused pools + /* 0x2A20 */ AudioAllocPool cachePool; + /* 0x2A30 */ AudioAllocPool persistentCommonPool; + /* 0x2A40 */ AudioAllocPool temporaryCommonPool; + /* 0x2A50 */ AudioCache seqCache; + /* 0x2B60 */ AudioCache fontCache; + /* 0x2C70 */ AudioCache sampleBankCache; + /* 0x2D80 */ AudioAllocPool permanentPool; + /* 0x2D90 */ AudioCacheEntry permanentCache[32]; + /* 0x3690 */ AudioSampleCache persistentSampleCache; + /* 0x40A4 */ AudioSampleCache temporarySampleCache; + /* 0x4338 */ AudioPoolSplit4 sessionPoolSplit; + /* 0x4348 */ AudioPoolSplit2 cachePoolSplit; + /* 0x4350 */ AudioPoolSplit3 persistentCommonPoolSplit; + /* 0x435C */ AudioPoolSplit3 temporaryCommonPoolSplit; + /* 0x4368 */ u8 sampleFontLoadStatus[0x30]; + /* 0x4398 */ u8 fontLoadStatus[0x30]; + /* 0x43C8 */ u8 seqLoadStatus[0x80]; + /* 0x4448 */ volatile u8 resetStatus; + /* 0x4449 */ u8 audioResetSpecIdToLoad; + /* 0x444C */ s32 audioResetFadeOutFramesLeft; + /* 0x4450 */ f32* unk_3520; + /* 0x4454 */ u8* audioHeap; + /* 0x4458 */ u32 audioHeapSize; + /* 0x445C */ Note* notes; + /* 0x4460 */ SequencePlayer seqPlayers[5]; + /* 0x4B40 */ SequenceLayer sequenceLayers[80]; + /* 0x7840 */ SequenceChannel sequenceChannelNone; + /* 0x7924 */ s32 noteSubEuOffset; + /* 0x7928 */ AudioListItem layerFreeList; + /* 0x7938 */ NotePool noteFreeLists; + /* 0x7978 */ u8 cmdWrPos; + /* 0x7979 */ u8 cmdRdPos; + /* 0x797A */ u8 cmdQueueFinished; + /* 0x797C */ u16 unk_5BDC[4]; + /* 0x7984 */ char unk_7984[4]; + /* 0x7988 */ OSMesgQueue* audioResetQueueP; + /* 0x798C */ OSMesgQueue* taskStartQueueP; + /* 0x7990 */ OSMesgQueue* cmdProcQueueP; + /* 0x7994 */ OSMesgQueue taskStartQueue; + /* 0x79AC */ OSMesgQueue cmdProcQueue; + /* 0x79C4 */ OSMesgQueue audioResetQueue; + /* 0x79DC */ OSMesg taskStartMsgs[1]; + /* 0x79E0 */ OSMesg audioResetMesgs[1]; + /* 0x79E4 */ OSMesg cmdProcMsgs[4]; + /* 0x79F4 */ AudioCmd cmdBuf[0x100]; + /* 0x81F4 */ char unk_81F4[4]; +} AudioContext; // size = 0x81F8 + +typedef struct { + /* 0x00 */ u8 reverbVol; + /* 0x01 */ u8 unk_1; + /* 0x02 */ u8 pan; + /* 0x03 */ u8 unk_3; + /* 0x04 */ Stereo stereo; + /* 0x08 */ f32 frequency; + /* 0x0C */ f32 velocity; + /* 0x10 */ char unk_0C[0x4]; + /* 0x14 */ s16* filter; + /* 0x18 */ u8 unk_14; + /* 0x1A */ u16 unk_16; +} NoteSubAttributes; // size = 0x1A + +typedef struct { + /* 0x0 */ u32 heapSize; + /* 0x4 */ u32 initPoolSize; + /* 0x8 */ u32 permanentPoolSize; +} AudioContextInitSizes; // size = 0xC + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_10; + /* 0x10 */ f32 unk_14; + /* 0x14 */ f32 unk_18; + /* 0x18 */ u16 unk_0C; + /* 0x1A */ u16 unk_1C; +} unk_50_s; // size = 0x1C + +typedef struct { + /* 0x000 */ unk_50_s unk_50[0x10]; + /* 0x1C0 */ f32 volCur; + /* 0x1C4 */ f32 volTarget; + /* 0x1C8 */ f32 unk_08; + /* 0x1CC */ u32 unk_14; + /* 0x1D0 */ f32 unk_1C; + /* 0x1D4 */ f32 unk_20; + /* 0x1D8 */ f32 unk_24; + /* 0x1DC */ u32 unk_2C[8]; + /* 0x1FC */ u32 unk_25C; + /* 0x200 */ u16 unk_0C; + /* 0x202 */ u16 unk_18; + /* 0x204 */ u16 unk_28; + /* 0x206 */ u16 unk_250; + /* 0x208 */ u16 unk_252; + /* 0x20A */ u16 unk_254; + /* 0x20C */ u16 unk_256; + /* 0x20E */ u16 unk_258; + /* 0x210 */ u8 unk_260; + /* 0x211 */ u8 unk_261[0x1]; + /* 0x212 */ u8 volScales[0x4]; + /* 0x216 */ u8 volFadeTimer; + /* 0x217 */ u8 fadeVolUpdate; + /* 0x218 */ u8 unk_4C; + /* 0x219 */ u8 unk_4D; + /* 0x21A */ u8 unk_4E; + /* 0x21B */ u8 unk_21B; // New to MM +} unk_D_8016E750; // size = 0x21C + +typedef struct { + /* 0x0 */ u8 unk_0; + /* 0x1 */ u8 unk_1; // importance? +} Struct_8016E320; // size = 0x02 + +typedef enum { + /* 0 */ BANK_PLAYER, + /* 1 */ BANK_ITEM, + /* 2 */ BANK_ENV, + /* 3 */ BANK_ENEMY, + /* 4 */ BANK_SYSTEM, + /* 5 */ BANK_OCARINA, + /* 6 */ BANK_VOICE +} SoundBankTypes; + +typedef enum { + /* 0 */ SFX_STATE_EMPTY, + /* 1 */ SFX_STATE_QUEUED, + /* 2 */ SFX_STATE_READY, + /* 3 */ SFX_STATE_PLAYING_REFRESH, + /* 4 */ SFX_STATE_PLAYING_1, + /* 5 */ SFX_STATE_PLAYING_2 +} SfxState; + +typedef struct { + /* 0x00 */ f32* posX; + /* 0x04 */ f32* posY; + /* 0x08 */ f32* posZ; + /* 0x0C */ f32* freqScale; + /* 0x10 */ f32* vol; + /* 0x14 */ s8* reverbAdd; + /* 0x18 */ f32 dist; + /* 0x1C */ u32 priority; // lower is more prioritized + /* 0x20 */ u16 sfxParams; + /* 0x22 */ u16 sfxId; + /* 0x25 */ u8 sfxFlags; + /* 0x24 */ u8 sfxImportance; + /* 0x26 */ u8 state; // uses SfxState enum + /* 0x27 */ u8 freshness; + /* 0x28 */ u8 prev; + /* 0x29 */ u8 next; + /* 0x2A */ u8 channelIdx; + /* 0x2B */ u8 unk_2F; + /* 0x2C */ u8 token; +} SfxBankEntry; // size = 0x30 + +/* + * SFX IDs + * + * index 0000000111111111 observed in audio code + * & 200 0000001000000000 single bit + * & 400 0000010000000000 single bit + * & 800 0000100000000000 single bit, what we currently call SFX_FLAG + * & 600 0000011000000000 2 bits + * & A00 0000101000000000 2 bits + * & C00 0000110000000000 2 bits, observed in audio code + * & E00 0000111000000000 all 3 bits + * bank 1111000000000000 observed in audio code + */ + +#define SFX_BANK_SHIFT(sfxId) (((sfxId) >> 12) & 0xFF) + +#define SFX_BANK_MASK(sfxId) ((sfxId) & 0xF000) + +#define SFX_INDEX(sfxId) ((sfxId) & 0x03FF) +#define SFX_BANK(sfxId) SFX_BANK_SHIFT(SFX_BANK_MASK(sfxId)) + +typedef struct { + /* 0x0 */ u32 priority; // lower is more prioritized + /* 0x4 */ u8 entryIndex; +} ActiveSfx; // size = 0x08 + +typedef struct { + /* 0x0 */ u8 importance; + /* 0x1 */ u8 flags; + /* 0x2 */ u16 params; +} SfxParams; // size = 0x4 + +typedef struct { + /* 0x00 */ u16 sfxId; + /* 0x02 */ u8 token; + /* 0x04 */ s8* reverbAdd; + /* 0x08 */ Vec3f* pos; + /* 0x0C */ f32* freqScale; + /* 0x10 */ f32* vol; +} SoundRequest; // size = 0x14 + +/** + * Note: + * Flag for resolving C_RIGHT and C_LEFT only being two semitones apart + * 0x40 - BTN_Z is pressed to lower note by a semitone + * 0x80 - BTN_R is pressed to raise note by a semitone + */ + +typedef struct { + /* 0x0 */ u8 noteIdx; + /* 0x2 */ u16 length; // number of frames the note is sustained + /* 0x4 */ u8 volume; + /* 0x5 */ u8 vibrato; + /* 0x6 */ s8 bend; + /* 0x7 */ u8 BFlat4Flag; // BFlat4Flag See note above +} OcarinaNote; // size = 0x8 + +typedef struct { + /* 0x0 */ u8 numButtons; + /* 0x1 */ u8 buttonIdx[8]; +} OcarinaSongButtons; // size = 0x9 + +typedef struct { + /* 0x0 */ u8 buttonIdx; + /* 0x1 */ u8 state; + /* 0x2 */ u8 pos; +} OcarinaStaff; // size = 0x3 + +#endif diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 5dd49fdaa..d04d30b7f 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2478,7 +2478,7 @@ 0x801DB8B8:("D_801DB8B8","UNK_TYPE1","",0x1), 0x801DB900:("D_801DB900","UNK_TYPE1","",0x1), 0x801DB930:("D_801DB930","UNK_PTR","",0x4), - 0x801DB958:("D_801DB958","s8018CFAC","[21]",0x498), + 0x801DB958:("D_801DB958","AudioSpec","[21]",0x498), 0x801DBDF0:("D_801DBDF0","f32","",0x4), 0x801DBDF4:("jtbl_801DBDF4","UNK_PTR","",0x4), 0x801DBE68:("D_801DBE68","f32","",0x4), @@ -4431,7 +4431,7 @@ 0x801FE4C0:("D_801FE4C0","UNK_TYPE1","",0x1), 0x801FE640:("D_801FE640","UNK_TYPE1","",0x1), 0x801FE6D0:("D_801FE6D0","UNK_TYPE1","",0x1), - 0x801FE7C0:("D_801FE7C0","s801FE7C0","[1]",0x14), + 0x801FE7C0:("D_801FE7C0","SoundRequest","[1]",0x14), 0x801FFBC0:("D_801FFBC0","UNK_TYPE1","",0x1), 0x801FFBC8:("D_801FFBC8","UNK_TYPE1","",0x1), 0x801FFBD0:("D_801FFBD0","UNK_TYPE1","",0x1), From 2854294009725379c73e121671f7f3b0dadfed67 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Fri, 19 Nov 2021 17:34:45 -0300 Subject: [PATCH 17/17] `z_jpeg`, `jpegutils` and `jpegdecoder` OK (#322) * this is a disaster * two more * func_800F470C * split and rename jpegutils and jpegdecoder * match jpegutils * match jpegdecoder.c * audio_rodata * data split * Split rsp * Steal documentation from OoT * cleanup * Format * remove removed members in JpegContext * Update include/z64.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/jpegdecoder.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/jpegutils.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * review renames * true * Some type fixes * Update include/z64.h Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * add comment * Update src/code/z_jpeg.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * format * bss fix * decr * format * z64jpeg.h * Add stdbool * Rename audio_init_params * whoops * whoops++ * whoops# * remove extra dumb variables in variables.txt * fix Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> --- Makefile | 5 + include/functions.h | 23 +-- include/macros.h | 2 +- include/variables.h | 9 +- include/z64jpeg.h | 99 +++++++++++ spec | 10 +- src/code/code_8010C1B0.c | 2 +- src/code/code_801AA020.c | 9 - src/code/jpegdecoder.c | 193 +++++++++++++++++++++ src/code/jpegutils.c | 156 ++++++++++++++++- src/code/z_jpeg.c | 305 ++++++++++++++++++++++++++++++++- tools/disasm/files.txt | 9 +- tools/disasm/functions.txt | 36 ++-- tools/disasm/variables.txt | 28 +-- tools/sizes/code_functions.csv | 44 ++--- 15 files changed, 809 insertions(+), 121 deletions(-) create mode 100644 include/z64jpeg.h delete mode 100644 src/code/code_801AA020.c create mode 100644 src/code/jpegdecoder.c diff --git a/Makefile b/Makefile index 827f15c77..a65a8713d 100644 --- a/Makefile +++ b/Makefile @@ -162,6 +162,11 @@ build/src/code/audio/%.o: OPTFLAGS := -O2 build/src/boot_O2_g3/fault.o: CFLAGS += -trapuv build/src/boot_O2_g3/fault_drawer.o: CFLAGS += -trapuv +build/src/code/jpegutils.o: OPTFLAGS := -O2 +build/src/code/jpegdecoder.o: OPTFLAGS := -O2 +build/src/code/jpegutils.o: CC := $(CC_OLD) +build/src/code/jpegdecoder.o: CC := $(CC_OLD) + build/src/libultra/libc/ll.o: OPTFLAGS := -O1 build/src/libultra/libc/ll.o: MIPS_VERSION := -mips3 -32 build/src/libultra/libc/llcvt.o: OPTFLAGS := -O1 diff --git a/include/functions.h b/include/functions.h index ca04a6c47..f60c0326e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1696,11 +1696,7 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor); void func_800F40A0(GlobalContext* globalCtx, s32 param_2); // void func_800F415C(void); UNK_TYPE func_800F41E4(GlobalContext* globalCtx, ActorContext* actorCtx); -// void func_800F42A0(void); -// void func_800F43BC(void); -// void func_800F44F4(void); -// void func_800F4540(void); -// s32 func_800F470C(UNK_TYPE4 param_1, UNK_TYPE4 param_2, s32 param_3, u32 param_4); + void func_800F4A10(GlobalContext* globalCtx); void func_800F4C0C(GlobalContext* globalCtx); void func_800F4E20(GlobalContext* globalCtx); @@ -2067,7 +2063,7 @@ s32 func_8010BF58(Actor* actor, GlobalContext* globalCtx, s32* param_3, UNK_PTR void Nmi_Init(void); void Nmi_SetPrenmiStart(void); // s32 Nmi_GetPrenmiHasStarted(void); -// void func_8010C1B0(void); +void MsgEvent_SendNullTask(void); f32 OLib_Vec3fDist(Vec3f* a, Vec3f* b); f32 OLib_Vec3fDistOutDiff(Vec3f* a, Vec3f* b, Vec3f* dest); f32 OLib_Vec3fDistXZ(Vec3f* a, Vec3f* b); @@ -3413,10 +3409,12 @@ void func_8018219C(MtxF* pfParm1, Vec3s* psParm2, s32 iParm3); // void func_801822C4(void); void Matrix_InsertRotationAroundUnitVector_f(f32 rotation, Vec3f* vector, s32 appendToState); void Matrix_InsertRotationAroundUnitVector_s(s16 rotation, Vec3f* vector, s32 appendToState); + u64* SysUcode_GetUCodeBoot(void); u32 SysUcode_GetUCodeBootSize(void); u64* SysUcode_GetUCode(void); u64* SysUcode_GetUCodeData(void); + // void func_80182CE0(void); // void func_80183020(void); // void func_80183058(void); @@ -4025,18 +4023,7 @@ s32 func_801A8A50(s32 param1); // void func_801A982C(void); // void func_801A99B8(void); // void func_801A9A74(void); -// void func_801A9B10(void); -// void func_801A9B78(void); -// void func_801A9BFC(void); -// void func_801A9C68(void); -// void func_801A9D10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); -// void func_801A9DCC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); -// void func_801A9EA4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE1 param_6); -// void func_801A9F4C(void); -// void func_801AA020(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_801AA248(void); -// void func_801AA3E4(void); -// void func_801AA520(void); + void GameOver_Init(GlobalContext* globalCtx); void GameOver_FadeLights(GlobalContext* globalCtx); void GameOver_Update(GlobalContext* globalCtx); diff --git a/include/macros.h b/include/macros.h index 15adcc697..6dc1e5e4e 100644 --- a/include/macros.h +++ b/include/macros.h @@ -130,7 +130,7 @@ extern GraphicsContext* __gfxCtx; #define SQ(x) ((x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) #define ABS_ALT(x) ((x) < 0 ? -(x) : (x)) -#define DECR(x) ((x) == 0 ? 0 : ((x) -= 1)) +#define DECR(x) ((x) == 0 ? 0 : --(x)) #define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) #define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x)) diff --git a/include/variables.h b/include/variables.h index bc6cef1b4..af0f323d9 100644 --- a/include/variables.h +++ b/include/variables.h @@ -360,7 +360,7 @@ extern u16 viRetrace; extern DmaEntry dmadata[1568]; // extern UNK_TYPE1 D_80186028; // extern UNK_TYPE1 D_801AAAB0; -// extern UNK_TYPE1 D_801AD370; +extern u64 gJpegUCode[]; extern ActorInit En_A_Obj_InitVars; extern ColliderCylinderInit enAObjCylinderInit; extern InitChainEntry enAObjInitVar; @@ -3107,7 +3107,7 @@ extern UNK_PTR D_801E10B0; // extern UNK_TYPE1 D_801E1E80; // extern UNK_TYPE1 D_801E2160; // extern UNK_TYPE1 D_801E3790; -// extern UNK_TYPE1 D_801E3F40; +extern u64 gJpegUCodeData[]; // extern UNK_TYPE1 D_801E3FA0; // bss @@ -3789,11 +3789,6 @@ extern OSMesg D_80203290[1]; // extern UNK_TYPE4 D_80208E6C; // extern UNK_TYPE4 D_80208E70; // extern UNK_TYPE4 D_80208E74; -// extern UNK_TYPE1 D_80208E90; -// extern UNK_TYPE1 D_80208E94; -// extern UNK_TYPE1 D_80208E98; -// extern UNK_TYPE1 D_80208E99; -// extern UNK_TYPE1 D_80208E9C; // post-code buffers extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; diff --git a/include/z64jpeg.h b/include/z64jpeg.h new file mode 100644 index 000000000..38183bfa9 --- /dev/null +++ b/include/z64jpeg.h @@ -0,0 +1,99 @@ +#ifndef Z64_JPEG_H +#define Z64_JPEG_H + +#include "PR/ultratypes.h" +#include "ultra64/message.h" +#include "PR/sched.h" + +typedef struct { + /* 0x00 */ u16 table[8*8]; +} JpegQuantizationTable; // size = 0x80 + +typedef struct { + /* 0x00 */ u8 codeOffs[16]; + /* 0x10 */ u16 codesA[16]; + /* 0x30 */ u16 codesB[16]; + /* 0x50 */ u8* symbols; +} JpegHuffmanTable; // size = 0x54 + +// this struct might be inaccurate but it's not used outside jpegutils.c +typedef struct { + /* 0x000 */ u8 codeOffs[16]; + /* 0x010 */ u16 dcCodes[120]; + /* 0x100 */ u16 acCodes[256]; +} JpegHuffmanTableOld; // size = 0x300 + +typedef struct { + /* 0x00 */ void* address; + /* 0x04 */ u32 mbCount; + /* 0x08 */ u32 mode; + /* 0x0C */ void* qTableYPtr; + /* 0x10 */ void* qTableUPtr; + /* 0x14 */ void* qTableVPtr; + /* 0x18 */ char unk_18[0x8]; +} JpegTaskData; // size = 0x20 + +typedef struct { + /* 0x000 */ JpegTaskData taskData; + /* 0x020 */ char yieldData[0x200]; + /* 0x220 */ JpegQuantizationTable qTableY; + /* 0x2A0 */ JpegQuantizationTable qTableU; + /* 0x320 */ JpegQuantizationTable qTableV; + /* 0x3A0 */ u8 codesLengths[0x110]; + /* 0x4B0 */ u16 codes[0x108]; + /* 0x6C0 */ u16 data[4][0x180]; +} JpegWork; // size = 0x12C0 + +typedef struct { + /* 0x00 */ void* imageData; + /* 0x04 */ u8 mode; + /* 0x05 */ u8 unk_05; + /* 0x08 */ JpegHuffmanTable* hTablePtrs[4]; + /* 0x18 */ u8 unk_18; +} JpegDecoder; // size = 0x1C + +typedef struct { + /* 0x00 */ u8 dqtCount; + /* 0x04 */ u8* dqtPtr[3]; + /* 0x10 */ u8 dhtCount; + /* 0x14 */ u8* dhtPtr[4]; + /* 0x24 */ void* imageData; + /* 0x28 */ u8 mode; // 0 if Y V0 is 1 and 2 if Y V0 is 2 + /* 0x30 */ OSScTask scTask; + /* 0x98 */ OSMesgQueue mq; + /* 0xB0 */ OSMesg msg; + /* 0xB4 */ JpegWork* workBuf; +} JpegContext; // size = 0xB8 + +typedef struct { + /* 0x00 */ u32 byteIdx; + /* 0x04 */ u8 bitIdx; + /* 0x05 */ u8 dontSkip; + /* 0x08 */ u32 curWord; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s16 unk_0E; + /* 0x10 */ s16 unk_10; +} JpegDecoderState; // size = 0x14 + + +void Jpeg_ScheduleDecoderTask(JpegContext* jpegCtx); +void Jpeg_CopyToZbuffer(u16* src, u16* zbuffer, s32 x, s32 y); +u16 Jpeg_GetUnalignedU16(u8* ptr); +void Jpeg_ParseMarkers(u8* ptr, JpegContext* jpegCtx); +s32 Jpeg_Decode(void* data, void* zbuffer, void* work, u32 workSize); + +void JpegUtils_ProcessQuantizationTable(u8* dqt, JpegQuantizationTable* qt, u8 count); +s32 JpegUtils_ParseHuffmanCodesLengths(u8* ptr, u8* codesLengths); +s32 JpegUtils_GetHuffmanCodes(u8* codesLengths, u16* codes); +s32 JpegUtils_SetHuffmanTable(u8* data, JpegHuffmanTable* ht, u16* codes); +u32 JpegUtils_ProcessHuffmanTableImpl(u8* data, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 isAc); +u32 JpegUtils_ProcessHuffmanTable(u8* dht, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 count); +void JpegUtils_SetHuffmanTableOld(u8* data, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes, s16 count, u8 isAc); +u32 JpegUtils_ProcessHuffmanTableImplOld(u8* dht, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes); + +s32 JpegDecoder_Decode(JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollowing, JpegDecoderState* state); +s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1, u16* mcu, s16* unk); +s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, s8* outZeroCount); +u16 JpegDecoder_ReadBits(u8 len); + +#endif diff --git a/spec b/spec index b50573ebc..d8a68f89c 100644 --- a/spec +++ b/spec @@ -428,7 +428,7 @@ beginseg compress after "dmadata" include "build/src/code/z_en_a_keep.o" - include "build/data/code/z_en_a_keep.data.o" + include "build/data/code/rsp.data.o" include "build/data/code/code_801ADE60.data.o" include "build/data/code/code_801E3FA0.bss.o" include "build/src/code/z_en_item00.o" @@ -492,8 +492,8 @@ beginseg include "build/src/code/z_horse.o" include "build/data/code/z_horse.data.o" include "build/src/code/z_jpeg.o" - include "build/data/code/z_jpeg.data.o" include "build/src/code/z_kaleido_setup.o" + include "build/data/code/z_kaleido_setup.data.o" include "build/src/code/z_kanfont.o" include "build/src/code/z_kankyo.o" include "build/data/code/z_kankyo.data.o" @@ -679,11 +679,11 @@ beginseg include "build/data/code/code_801A7B10.bss.o" include "build/data/code/audio_init_params.rodata.o" include "build/src/code/jpegutils.o" - include "build/src/code/code_801AA020.o" - include "build/data/code/code_801AA020.bss.o" + include "build/src/code/jpegdecoder.o" include_readonly "build/src/code/z_game_over.o" include "build/src/code/z_construct.o" - include "build/data/code/code_801E1180.rodata.o" + include "build/data/code/audio_sound_params.data.o" + include "build/data/code/rsp.rodata.o" endseg beginseg diff --git a/src/code/code_8010C1B0.c b/src/code/code_8010C1B0.c index 12e0eadb4..2c1fd410f 100644 --- a/src/code/code_8010C1B0.c +++ b/src/code/code_8010C1B0.c @@ -1,7 +1,7 @@ #include "global.h" // Blocks the current thread until all currently queued scheduler tasks have been completed -void func_8010C1B0(void) { +void MsgEvent_SendNullTask(void) { OSScTask task; OSMesgQueue queue; OSMesg msg; diff --git a/src/code/code_801AA020.c b/src/code/code_801AA020.c deleted file mode 100644 index 6cefc66d9..000000000 --- a/src/code/code_801AA020.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801AA020/func_801AA020.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801AA020/func_801AA248.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801AA020/func_801AA3E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801AA020/func_801AA520.s") diff --git a/src/code/jpegdecoder.c b/src/code/jpegdecoder.c new file mode 100644 index 000000000..336e381f9 --- /dev/null +++ b/src/code/jpegdecoder.c @@ -0,0 +1,193 @@ +#include "z64jpeg.h" +#include "libc/stdbool.h" +#include "macros.h" + +u8* sJpegBitStreamPtr; +u32 sJpegBitStreamByteIdx; +u8 sJpegBitStreamBitIdx; +u8 sJpegBitStreamDontSkip; +u32 sJpegBitStreamCurWord; + +s32 JpegDecoder_Decode(JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollowing, JpegDecoderState* state) { + s16 pad; + s16 unk0; + s16 unk1; + s16 unk2; + u32 idx; + s32 inc; + u16 unkCount; + + JpegHuffmanTable* hTable0; + JpegHuffmanTable* hTable1; + JpegHuffmanTable* hTable2; + JpegHuffmanTable* hTable3; + + inc = 0; + sJpegBitStreamPtr = decoder->imageData; + if (decoder->mode == 0) { + unkCount = 2; + } else { + unkCount = 4; + if (decoder->unk_05 == 1) { + inc = 8 * 8 * 2; + } + } + + hTable0 = decoder->hTablePtrs[0]; + hTable1 = decoder->hTablePtrs[1]; + hTable2 = decoder->hTablePtrs[2]; + hTable3 = decoder->hTablePtrs[3]; + + if (!isFollowing) { + sJpegBitStreamByteIdx = 0; + sJpegBitStreamBitIdx = 32; + sJpegBitStreamCurWord = 0; + sJpegBitStreamDontSkip = 0; + unk0 = 0; + unk1 = 0; + unk2 = 0; + } else { + sJpegBitStreamByteIdx = state->byteIdx; + sJpegBitStreamBitIdx = state->bitIdx; + sJpegBitStreamCurWord = state->curWord; + sJpegBitStreamDontSkip = state->dontSkip; + unk0 = state->unk_0C; + unk1 = state->unk_0E; + unk2 = state->unk_10; + } + + while (count != 0) { + for (idx = 0; idx < unkCount; idx++) { + if (JpegDecoder_ProcessMcu(hTable0, hTable1, mcuBuff, &unk0)) { + return 2; + } + mcuBuff += 8 * 8; + } + + if (JpegDecoder_ProcessMcu(hTable2, hTable3, mcuBuff, &unk1)) { + return 2; + } + mcuBuff += 8 * 8; + + if (JpegDecoder_ProcessMcu(hTable2, hTable3, mcuBuff, &unk2)) { + return 2; + } + + count--; + mcuBuff += 8 * 8; + mcuBuff += inc; + } + + state->byteIdx = sJpegBitStreamByteIdx; + state->bitIdx = sJpegBitStreamBitIdx; + state->curWord = sJpegBitStreamCurWord; + state->dontSkip = sJpegBitStreamDontSkip; + state->unk_0C = unk0; + state->unk_0E = unk1; + state->unk_10 = unk2; + return 0; +} + +s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1, u16* mcu, s16* unk) { + s8 i = 0; + s8 zeroCount; + s16 coeff; + + if (JpegDecoder_ParseNextSymbol(hTable0, &coeff, &zeroCount)) { + return true; + } + + *unk += coeff; + mcu[i++] = *unk; + while (i < 8 * 8) { + if (JpegDecoder_ParseNextSymbol(hTable1, &coeff, &zeroCount)) { + return true; + } + + if (coeff == 0) { + if (zeroCount == 0xF) { + while (zeroCount-- >= 0) { + mcu[i++] = 0; + } + } else { + while (i < 8 * 8) { + mcu[i++] = 0; + } + break; + } + } else { + while (0 < zeroCount--) { + mcu[i++] = 0; + } + mcu[i++] = coeff; + } + } + + return false; +} + +s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, s8* outZeroCount) { + u8 codeIdx; + u8 sym; + u16 codeOff = 0; + u16 buff = JpegDecoder_ReadBits(16); + + for (codeIdx = 0; codeIdx < ARRAY_COUNT(hTable->codesB); codeIdx++) { + if (hTable->codesB[codeIdx] == 0xFFFF) { + continue; + } + + codeOff = buff >> (15 - codeIdx); + if (codeOff <= hTable->codesB[codeIdx]) { + break; + } + } + + if (codeIdx >= ARRAY_COUNT(hTable->codesB)) { + return true; + } + + sym = hTable->symbols[hTable->codeOffs[codeIdx] + codeOff - hTable->codesA[codeIdx]]; + *outZeroCount = sym >> 4; + sym &= 0xF; + + sJpegBitStreamBitIdx += codeIdx - 15; + *outCoeff = 0; + if (sym) { + *outCoeff = JpegDecoder_ReadBits(sym); + if (*outCoeff < (1 << (sym - 1))) { + *outCoeff += (-1 << sym) + 1; + } + } + + return false; +} + +u16 JpegDecoder_ReadBits(u8 len) { + u8 byteCount; + u8 data; + s32 ret; + u32 temp; + ret = 0; // this is required for some reason + + for (byteCount = sJpegBitStreamBitIdx >> 3; byteCount > 0; byteCount--) { + data = sJpegBitStreamPtr[sJpegBitStreamByteIdx++]; + if (sJpegBitStreamDontSkip) { + if (data == 0) { + data = sJpegBitStreamPtr[sJpegBitStreamByteIdx++]; + } + } + + sJpegBitStreamDontSkip = (data == 0xFF) ? true : false; + + sJpegBitStreamCurWord <<= 8; + sJpegBitStreamCurWord |= data; + sJpegBitStreamBitIdx -= 8; + } + + ret = (sJpegBitStreamCurWord << (sJpegBitStreamBitIdx)); + temp = ret; + ret = temp >> -len; + sJpegBitStreamBitIdx += len; + return ret; +} diff --git a/src/code/jpegutils.c b/src/code/jpegutils.c index 89ed4e97d..904643f46 100644 --- a/src/code/jpegutils.c +++ b/src/code/jpegutils.c @@ -1,17 +1,155 @@ -#include "global.h" +#include "z64jpeg.h" +#include "libc/stdbool.h" +#include "macros.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9B10.s") +void JpegUtils_ProcessQuantizationTable(u8* dqt, JpegQuantizationTable* qt, u8 count) { + u8 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9B78.s") + for (i = 0; i < count; i++) { + u8 j; -#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9BFC.s") + dqt++; + for (j = 0; j < ARRAY_COUNT(qt[i].table); j++) { + qt[i].table[j] = *dqt++; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9C68.s") +s32 JpegUtils_ParseHuffmanCodesLengths(u8* ptr, u8* codesLengths) { + u8 off = 1; + s16 count = 0; + s16 idx = 1; -#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9D10.s") + while (off <= 16) { + while (idx <= ptr[off - 1]) { + codesLengths[count++] = off; + idx++; + } + idx = 1; + off++; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9DCC.s") + codesLengths[count] = 0; + return count; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9EA4.s") +s32 JpegUtils_GetHuffmanCodes(u8* codesLengths, u16* codes) { + s16 idx = 0; + u16 code = 0; + u8 lastLen = codesLengths[0]; -#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9F4C.s") + while (true) { + while (true) { + codes[idx++] = code++; + + if (codesLengths[idx] != lastLen) { + break; + } + } + + if (codesLengths[idx] == 0) { + break; + } + + while (true) { + if (code <<= 1, codesLengths[idx] == ++lastLen) { + break; + } + } + } + + return idx; +} + +s32 JpegUtils_SetHuffmanTable(u8* data, JpegHuffmanTable* ht, u16* codes) { + u8 idx; + u16 codeOff = 0; + + for (idx = 0; idx < 16; idx++) { + if (data[idx]) { + ht->codeOffs[idx] = codeOff; + ht->codesA[idx] = codes[codeOff]; + codeOff += data[idx] - 1; + ht->codesB[idx] = codes[codeOff]; + codeOff++; + } else { + ht->codesB[idx] = 0xFFFF; + } + } + + return codeOff; +} + +u32 JpegUtils_ProcessHuffmanTableImpl(u8* data, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 isAc) { + s16 ret; + s32 count = JpegUtils_ParseHuffmanCodesLengths(data, codesLengths); + s32 temp; + + ret = count; + if (count == 0 || (isAc && count > 0x100) || (!isAc && count > 0x10)) { + return 0; + } + if (ret != JpegUtils_GetHuffmanCodes(codesLengths, codes)) { + return 0; + } + if (temp = JpegUtils_SetHuffmanTable(data, ht, codes), temp != ret) { + return 0; + } + + return ret; +} + +u32 JpegUtils_ProcessHuffmanTable(u8* dht, JpegHuffmanTable* ht, u8* codesLengths, u16* codes, u8 count) { + u8 idx; + u32 codeCount; + + for (idx = 0; idx < count; idx++) { + u32 ac = (*dht++ >> 4); + + codeCount = JpegUtils_ProcessHuffmanTableImpl(dht, &ht[idx], codesLengths, codes, ac); + if (codeCount == 0) { + return true; + } + + dht += 16; + ht[idx].symbols = dht; + dht += codeCount; + } + return false; +} + +void JpegUtils_SetHuffmanTableOld(u8* data, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes, s16 count, u8 isAc) { + s16 idx; + u8 a; + + for (idx = 0; idx < count; idx++) { + a = data[idx]; + if (isAc) { + ht->acCodes[a] = codes[idx]; + ht->codeOffs[a] = codesLengths[idx]; + } else { + ht->dcCodes[a] = codes[idx]; + ht->codeOffs[a] = codesLengths[idx]; + } + } +} + +u32 JpegUtils_ProcessHuffmanTableImplOld(u8* dht, JpegHuffmanTableOld* ht, u8* codesLengths, u16* codes) { + u8 isAc = *dht++ >> 4; + s16 count2; + s32 count; + + count2 = count = JpegUtils_ParseHuffmanCodesLengths(dht, codesLengths); + + if (count == 0 || (isAc && count > 0x100) || (!isAc && count > 0x10)) { + return true; + } + + if (JpegUtils_GetHuffmanCodes(codesLengths, codes) != count2) { + return true; + } + + JpegUtils_SetHuffmanTableOld(dht + 0x10, ht, codesLengths, codes, count2, isAc); + + return false; +} diff --git a/src/code/z_jpeg.c b/src/code/z_jpeg.c index 395a45835..c611ab1f8 100644 --- a/src/code/z_jpeg.c +++ b/src/code/z_jpeg.c @@ -1,11 +1,304 @@ -#include "global.h" +#include "z64jpeg.h" +#include "libc/stdbool.h" +#include "variables.h" +#include "functions.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_jpeg/func_800F42A0.s") +#define MARKER_ESCAPE 0x00 +#define MARKER_SOI 0xD8 +#define MARKER_SOF 0xC0 +#define MARKER_DHT 0xC4 +#define MARKER_DQT 0xDB +#define MARKER_DRI 0xDD +#define MARKER_SOS 0xDA +#define MARKER_APP0 0xE0 +#define MARKER_APP1 0xE1 +#define MARKER_APP2 0xE2 +#define MARKER_COM 0xFE +#define MARKER_EOI 0xD9 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_jpeg/func_800F43BC.s") +/** + * Configures and schedules a JPEG decoder task and waits for it to finish. + */ +void Jpeg_ScheduleDecoderTask(JpegContext* jpegCtx) { + static OSTask_t sJpegTask = { + M_NJPEGTASK, // type + 0, // flags + NULL, // ucode_boot + 0, // ucode_boot_size + gJpegUCode, // ucode + 0x1000, // ucode_size + gJpegUCodeData, // ucode_data + 0x800, // ucode_data_size + NULL, // dram_stack + 0, // dram_stack_size + NULL, // output_buff + NULL, // output_buff_size + NULL, // data_ptr + sizeof(JpegTaskData), // data_size + NULL, // yield_data_ptr + 0x200, // yield_data_size + }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_jpeg/func_800F44F4.s") + JpegWork* workBuf = jpegCtx->workBuf; + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_jpeg/func_800F4540.s") + workBuf->taskData.address = &workBuf->data; + workBuf->taskData.mode = jpegCtx->mode; + workBuf->taskData.mbCount = 4; + workBuf->taskData.qTableYPtr = &workBuf->qTableY; + workBuf->taskData.qTableUPtr = &workBuf->qTableU; + workBuf->taskData.qTableVPtr = &workBuf->qTableV; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_jpeg/func_800F470C.s") + sJpegTask.flags = 0; + sJpegTask.ucodeBoot = SysUcode_GetUCodeBoot(); + sJpegTask.ucodeBootSize = SysUcode_GetUCodeBootSize(); + sJpegTask.yieldDataPtr = (u64*)&workBuf->yieldData; + sJpegTask.dataPtr = (u64*)&workBuf->taskData; + + jpegCtx->scTask.next = NULL; + jpegCtx->scTask.flags = OS_SC_NEEDS_RSP; + jpegCtx->scTask.msgQ = &jpegCtx->mq; + jpegCtx->scTask.msg = NULL; + jpegCtx->scTask.framebuffer = NULL; + jpegCtx->scTask.list.t = sJpegTask; + + osSendMesg(&gSchedContext.cmdQ, (OSMesg)&jpegCtx->scTask, OS_MESG_BLOCK); + Sched_SendEntryMsg(&gSchedContext); // osScKickEntryMsg + osRecvMesg(&jpegCtx->mq, NULL, OS_MESG_BLOCK); +} + +/** + * Copies a 16x16 block of decoded image data to the Z-buffer. + */ +void Jpeg_CopyToZbuffer(u16* src, u16* zbuffer, s32 x, s32 y) { + u16* dst = zbuffer + (((y * SCREEN_WIDTH) + x) * 16); + s32 i; + + for (i = 0; i < 16; i++) { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; + dst[4] = src[4]; + dst[5] = src[5]; + dst[6] = src[6]; + dst[7] = src[7]; + dst[8] = src[8]; + dst[9] = src[9]; + dst[10] = src[10]; + dst[11] = src[11]; + dst[12] = src[12]; + dst[13] = src[13]; + dst[14] = src[14]; + dst[15] = src[15]; + + src += 16; + dst += SCREEN_WIDTH; + } +} + +/** + * Reads an u16 from a possibly unaligned address in memory. + * + * Replaces unaligned 16-bit reads with a pair of aligned reads, allowing for reading the possibly + * unaligned values in JPEG header files. + */ +u16 Jpeg_GetUnalignedU16(u8* ptr) { + if (((u32)ptr & 1) == 0) { + // Read the value normally if it's aligned to a 16-bit address. + return *(u16*)ptr; + } else { + // Read unaligned values using two separate aligned memory accesses when it's not. + return *(u16*)(ptr - 1) << 8 | (*(u16*)(ptr + 1) >> 8); + } +} + +/** + * Parses the markers in the JPEG file, storing information such as the pointer to the image data + * in `jpegCtx` for later processing. + */ +void Jpeg_ParseMarkers(u8* ptr, JpegContext* jpegCtx) { + u32 exit = false; + + jpegCtx->dqtCount = 0; + jpegCtx->dhtCount = 0; + + while (true) { + if (exit) { + break; + } + + // 0xFF indicates the start of a JPEG marker, so look for the next. + if (*ptr++ == 0xFF) { + switch (*ptr++) { + case MARKER_ESCAPE: { + // Compressed value 0xFF is stored as 0xFF00 to escape it, so ignore it. + break; + } + case MARKER_SOI: { + // Start of Image + break; + } + case MARKER_APP0: { + // Application marker for JFIF + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_APP1: { + // Application marker for EXIF + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_APP2: { + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_DQT: { + // Define Quantization Table, stored for later processing + jpegCtx->dqtPtr[jpegCtx->dqtCount++] = ptr + 2; + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_DHT: { + // Define Huffman Table, stored for later processing + jpegCtx->dhtPtr[jpegCtx->dhtCount++] = ptr + 2; + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_DRI: { + // Define Restart Interval + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_SOF: { + // Start of Frame, stores important metadata of the image. + // Only used for extracting the sampling factors (jpegCtx->mode). + + if (ptr[9] == 0x21) { + // component Y : V0 == 1 + jpegCtx->mode = 0; + } else if (ptr[9] == 0x22) { + // component Y : V0 == 2 + jpegCtx->mode = 2; + } + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + case MARKER_SOS: { + // Start of Scan marker, indicates the start of the image data. + ptr += Jpeg_GetUnalignedU16(ptr); + jpegCtx->imageData = ptr; + break; + } + case MARKER_EOI: { + // End of Image + exit = true; + break; + } + default: { + ptr += Jpeg_GetUnalignedU16(ptr); + break; + } + } + } + } +} + +s32 Jpeg_Decode(void* data, void* zbuffer, void* work, u32 workSize) { + s32 y; + s32 x; + s32 j; + s32 i; + JpegContext jpegCtx; + JpegHuffmanTable hTables[4]; + JpegDecoder decoder; + JpegDecoderState state; + JpegWork* workBuff = work; + + if (workSize < sizeof(JpegWork)) { + return -1; + } + + osCreateMesgQueue(&jpegCtx.mq, &jpegCtx.msg, 1); + MsgEvent_SendNullTask(); + + jpegCtx.workBuf = workBuff; + + Jpeg_ParseMarkers(data, &jpegCtx); + + switch (jpegCtx.dqtCount) { + case 1: + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[0], &workBuff->qTableY, 3); + break; + + case 2: + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[0], &workBuff->qTableY, 1); + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[1], &workBuff->qTableU, 1); + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[1], &workBuff->qTableV, 1); + break; + + case 3: + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[0], &workBuff->qTableY, 1); + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[1], &workBuff->qTableU, 1); + JpegUtils_ProcessQuantizationTable(jpegCtx.dqtPtr[2], &workBuff->qTableV, 1); + break; + + default: + return -1; + } + + switch (jpegCtx.dhtCount) { + case 1: + if (JpegUtils_ProcessHuffmanTable(jpegCtx.dhtPtr[0], &hTables[0], workBuff->codesLengths, workBuff->codes, + 4)) { + return -1; + } + break; + + case 4: + // This chained if-else has printfs inside it on debug + if (JpegUtils_ProcessHuffmanTable(jpegCtx.dhtPtr[0], &hTables[0], workBuff->codesLengths, workBuff->codes, + 1)) { + } else if (JpegUtils_ProcessHuffmanTable(jpegCtx.dhtPtr[1], &hTables[1], workBuff->codesLengths, + workBuff->codes, 1)) { + } else if (JpegUtils_ProcessHuffmanTable(jpegCtx.dhtPtr[2], &hTables[2], workBuff->codesLengths, + workBuff->codes, 1)) { + } else if (!JpegUtils_ProcessHuffmanTable(jpegCtx.dhtPtr[3], &hTables[3], workBuff->codesLengths, + workBuff->codes, 1)) { + break; + } + return -1; + + default: + return -1; + } + + decoder.imageData = jpegCtx.imageData; + decoder.mode = jpegCtx.mode; + decoder.unk_05 = 2; + + decoder.hTablePtrs[0] = &hTables[0]; + decoder.hTablePtrs[1] = &hTables[1]; + decoder.hTablePtrs[2] = &hTables[2]; + decoder.hTablePtrs[3] = &hTables[3]; + decoder.unk_18 = 0; + + x = y = 0; + for (i = 0; i < 300; i += 4) { + if (!JpegDecoder_Decode(&decoder, (u16*)workBuff->data, 4, (i != 0), &state)) { + Jpeg_ScheduleDecoderTask(&jpegCtx); + + for (j = 0; j < 4; j++) { + Jpeg_CopyToZbuffer(workBuff->data[j], zbuffer, x, y); + x++; + + if (x >= 20) { + x = 0; + y++; + } + } + } + } + + return 0; +} diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 2c22781ba..86f3f7f74 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -498,12 +498,12 @@ 0x801A5BD0 : "code_801A5BD0", 0x801A7B10 : "code_801A7B10", 0x801A9B10 : "jpegutils", - 0x801AA020 : "code_801AA020", + 0x801AA020 : "jpegdecoder", 0x801AA610 : "z_game_over", 0x801AAAA0 : "z_construct", # .data section - 0x801AAAB0 : "z_en_a_keep", + 0x801AAAB0 : "rsp", 0x801ADE60 : "", 0x801ADEC0 : "z_en_item00", 0x801AE240 : "z_eff_blure", @@ -530,6 +530,7 @@ 0x801BD910 : "", 0x801BDA70 : "z_horse", 0x801BDAC0 : "z_jpeg", + 0x801BDB00 : "z_kaleido_setup", 0x801BDB30 : "z_kanfont", 0x801BDB90 : "z_kankyo", 0x801BE960 : "z_lib", @@ -672,7 +673,7 @@ 0x801E1070 : "code_801A7B10", 0x801E1100 : "audio_init_params", 0x801E1110 : "z_game_over", - 0x801E1180 : "", + 0x801E1180 : "rsp", # .bss section 0x801E3FA0 : "code_801E3FA0", @@ -728,7 +729,7 @@ 0x801FD5A0 : "code_801A51F0", 0x801FD710 : "code_801A5BD0", 0x801FFD00 : "code_801A7B10", - 0x80208E90 : "code_801AA020", + 0x80208E90 : "jpegdecoder", 0x80208EA0 : "gfxbuffers", 0x8024A4C0 : "buffers", }, diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 43024464d..6eabbe56d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1693,11 +1693,11 @@ 0x800F40A0:("func_800F40A0",), 0x800F415C:("func_800F415C",), 0x800F41E4:("func_800F41E4",), - 0x800F42A0:("func_800F42A0",), - 0x800F43BC:("func_800F43BC",), - 0x800F44F4:("func_800F44F4",), - 0x800F4540:("func_800F4540",), - 0x800F470C:("func_800F470C",), + 0x800F42A0:("Jpeg_ScheduleDecoderTask",), + 0x800F43BC:("Jpeg_CopyToZbuffer",), + 0x800F44F4:("Jpeg_GetUnalignedU16",), + 0x800F4540:("Jpeg_ParseMarkers",), + 0x800F470C:("Jpeg_Decode",), 0x800F4A10:("func_800F4A10",), 0x800F4C0C:("func_800F4C0C",), 0x800F4E20:("func_800F4E20",), @@ -2064,7 +2064,7 @@ 0x8010C0C0:("Nmi_Init",), 0x8010C164:("Nmi_SetPrenmiStart",), 0x8010C19C:("Nmi_GetPrenmiHasStarted",), - 0x8010C1B0:("func_8010C1B0",), + 0x8010C1B0:("MsgEvent_SendNullTask",), 0x8010C230:("OLib_Vec3fDist",), 0x8010C274:("OLib_Vec3fDistOutDiff",), 0x8010C2D0:("OLib_Vec3fDistXZ",), @@ -4067,18 +4067,18 @@ 0x801A982C:("func_801A982C",), 0x801A99B8:("func_801A99B8",), 0x801A9A74:("func_801A9A74",), - 0x801A9B10:("func_801A9B10",), - 0x801A9B78:("func_801A9B78",), - 0x801A9BFC:("func_801A9BFC",), - 0x801A9C68:("func_801A9C68",), - 0x801A9D10:("func_801A9D10",), - 0x801A9DCC:("func_801A9DCC",), - 0x801A9EA4:("func_801A9EA4",), - 0x801A9F4C:("func_801A9F4C",), - 0x801AA020:("func_801AA020",), - 0x801AA248:("func_801AA248",), - 0x801AA3E4:("func_801AA3E4",), - 0x801AA520:("func_801AA520",), + 0x801A9B10:("JpegUtils_ProcessQuantizationTable",), + 0x801A9B78:("JpegUtils_ParseHuffmanCodesLengths",), + 0x801A9BFC:("JpegUtils_GetHuffmanCodes",), + 0x801A9C68:("JpegUtils_SetHuffmanTable",), + 0x801A9D10:("JpegUtils_ProcessHuffmanTableImpl",), + 0x801A9DCC:("JpegUtils_ProcessHuffmanTable",), + 0x801A9EA4:("JpegUtils_SetHuffmanTableOld",), + 0x801A9F4C:("JpegUtils_ProcessHuffmanTableImplOld",), + 0x801AA020:("JpegDecoder_Decode",), + 0x801AA248:("JpegDecoder_ProcessMcu",), + 0x801AA3E4:("JpegDecoder_ParseNextSymbol",), + 0x801AA520:("JpegDecoder_ReadBits",), 0x801AA610:("GameOver_Init",), 0x801AA624:("GameOver_FadeLights",), 0x801AA68C:("GameOver_Update",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index d04d30b7f..b633dd292 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -367,7 +367,7 @@ 0x80186028:("D_80186028","s16","[1316]",0xa48), 0x801AAAB0:("D_801AAAB0","UNK_TYPE1","",0x1), 0x801ABAB0:("D_801ABAB0","UNK_TYPE1","",0x1), - 0x801AD370:("D_801AD370","UNK_TYPE1","",0x1), + 0x801AD370:("gJpegUCode","UNK_TYPE1","",0x1), 0x801ADE60:("En_A_Obj_InitVars","ActorInit","",0x20), 0x801ADE80:("enAObjCylinderInit","ColliderCylinderInit","",0x2c), 0x801ADEAC:("enAObjInitVar","ActorInitVar","",0x4), @@ -3894,7 +3894,7 @@ 0x801E2160:("D_801E2160","UNK_TYPE1","",0x1), 0x801E3790:("D_801E3790","UNK_TYPE1","",0x1), 0x801E3BB0:("D_801E3BB0","UNK_TYPE1","",0x1), - 0x801E3F40:("D_801E3F40","UNK_TYPE1","",0x1), + 0x801E3F40:("gJpegUCodeData","UNK_TYPE1","",0x1), 0x801E3FA0:("D_801E3FA0","UNK_TYPE1","",0x1), 0x801E3FB0:("sEffTable","EffTables","",0x98e0), 0x801E4514:("D_801E4514","UNK_TYPE1","",0x1), @@ -4585,11 +4585,11 @@ 0x80208E6C:("D_80208E6C","UNK_TYPE4","",0x4), 0x80208E70:("D_80208E70","UNK_TYPE4","",0x4), 0x80208E74:("D_80208E74","UNK_TYPE4","",0x4), - 0x80208E90:("D_80208E90","UNK_TYPE1","",0x1), - 0x80208E94:("D_80208E94","UNK_TYPE1","",0x1), - 0x80208E98:("D_80208E98","UNK_TYPE1","",0x1), - 0x80208E99:("D_80208E99","UNK_TYPE1","",0x1), - 0x80208E9C:("D_80208E9C","UNK_TYPE1","",0x1), + 0x80208E90:("sJpegBitStreamPtr","UNK_TYPE1","",0x1), + 0x80208E94:("sJpegBitStreamByteIdx","UNK_TYPE1","",0x1), + 0x80208E98:("sJpegBitStreamBitIdx","UNK_TYPE1","",0x1), + 0x80208E99:("sJpegBitStreamDontSkip","UNK_TYPE1","",0x1), + 0x80208E9C:("sJpegBitStreamCurWord","UNK_TYPE1","",0x1), 0x80208EA0:("gGfxSPTaskYieldBuffer","u8","[OS_YIELD_DATA_SIZE]",0xC00), 0x80209AA0:("gGfxSPTaskStack","u8","[0x400]",0x400), 0x80209EA0:("gGfxPools","GfxPool","[2]",0x40620), @@ -7917,11 +7917,6 @@ 0x8090DC1C:("D_8090DC1C","f32","",0x4), 0x8090DC20:("D_8090DC20","f32","",0x4), 0x8090DC24:("D_8090DC24","f32","",0x4), - 0x8090DC30:("enFishingOverlayInfo","OverlayRelocationSection","",0x14), - 0x8090DC44:("enFishingOverlayRelocations","u32","[2393]",0x2564), - 0x809101AC:("enFishingOverlayInfoOffset","u32","",0x4), - 0x80910000:("D_80910000","UNK_TYPE1","",0x1), - 0x80910001:("D_80910001","UNK_TYPE1","",0x1), 0x809101B0:("D_809101B0","f32","",0x4), 0x809101B4:("D_809101B4","f32","",0x4), 0x809101B8:("D_809101B8","UNK_TYPE1","",0x1), @@ -10994,9 +10989,6 @@ 0x80A0C55C:("D_80A0C55C","f32","",0x4), 0x80A0C560:("D_80A0C560","f32","",0x4), 0x80A0C7C0:("En_Boj_05_InitVars","UNK_TYPE1","",0x1), - 0x80A0C7E0:("enBoj05OverlayInfo","OverlayRelocationSection","",0x14), - 0x80A0C7F4:("enBoj05OverlayRelocations","u32","[4]",0x10), - 0x80A0C80C:("enBoj05OverlayInfoOffset","u32","",0x4), 0x80A10860:("sAnimationsBombShopkeeper","UNK_PTR","",0x4), 0x80A10890:("En_Sob1_InitVars","UNK_TYPE1","",0x1), 0x80A108B0:("sObjectIds","UNK_TYPE2","",0x2), @@ -12656,9 +12648,6 @@ 0x80A8B440:("jtbl_D_80A8B440","UNK_PTR","",0x4), 0x80A8B478:("jtbl_D_80A8B478","UNK_PTR","",0x4), 0x80A8B48C:("jtbl_D_80A8B48C","UNK_PTR","",0x4), - 0x80A8B4A0:("enTruOverlayInfo","OverlayRelocationSection","",0x14), - 0x80A8B4B4:("enTruOverlayRelocations","u32","[174]",0x2b8), - 0x80A8B76C:("enTruOverlayInfoOffset","u32","",0x4), 0x80A8FE10:("sAnimations","UNK_TYPE1","",0x1), 0x80A8FEB0:("En_Trt_InitVars","UNK_TYPE1","",0x1), 0x80A8FED0:("sActorScale","UNK_TYPE4","",0x4), @@ -13140,9 +13129,6 @@ 0x80AC027C:("jtbl_80AC027C","UNK_PTR","",0x4), 0x80AC0300:("jtbl_80AC0300","UNK_PTR","",0x4), 0x80AC03E4:("jtbl_80AC03E4","UNK_PTR","",0x4), - 0x80AC0400:("enMa4OverlayInfo","OverlayRelocationSection","",0x14), - 0x80AC0414:("enMa4OverlayRelocations","u32","[262]",0x418), - 0x80AC082C:("enMa4OverlayInfoOffset","u32","",0x4), 0x80AC1090:("En_Twig_InitVars","UNK_TYPE1","",0x1), 0x80AC10B0:("D_80AC10B0","UNK_TYPE1","",0x1), 0x80AC10BC:("D_80AC10BC","UNK_TYPE2","",0x2), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 44250fc0c..681b1cd4e 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1207,11 +1207,11 @@ asm/non_matchings/code/z_horse/func_800F3ED4.s,func_800F3ED4,0x800F3ED4,0x73 asm/non_matchings/code/z_horse/func_800F40A0.s,func_800F40A0,0x800F40A0,0x2F asm/non_matchings/code/z_horse/func_800F415C.s,func_800F415C,0x800F415C,0x22 asm/non_matchings/code/z_horse/func_800F41E4.s,func_800F41E4,0x800F41E4,0x2F -asm/non_matchings/code/z_jpeg/func_800F42A0.s,func_800F42A0,0x800F42A0,0x47 -asm/non_matchings/code/z_jpeg/func_800F43BC.s,func_800F43BC,0x800F43BC,0x4E -asm/non_matchings/code/z_jpeg/func_800F44F4.s,func_800F44F4,0x800F44F4,0x13 -asm/non_matchings/code/z_jpeg/func_800F4540.s,func_800F4540,0x800F4540,0x73 -asm/non_matchings/code/z_jpeg/func_800F470C.s,func_800F470C,0x800F470C,0xC1 +asm/non_matchings/code/z_jpeg/Jpeg_ScheduleDecoderTask.s,Jpeg_ScheduleDecoderTask,0x800F42A0,0x47 +asm/non_matchings/code/z_jpeg/Jpeg_CopyToZbuffer.s,Jpeg_CopyToZbuffer,0x800F43BC,0x4E +asm/non_matchings/code/z_jpeg/Jpeg_GetUnalignedU16.s,Jpeg_GetUnalignedU16,0x800F44F4,0x13 +asm/non_matchings/code/z_jpeg/Jpeg_ParseMarkers.s,Jpeg_ParseMarkers,0x800F4540,0x73 +asm/non_matchings/code/z_jpeg/Jpeg_Decode.s,Jpeg_Decode,0x800F470C,0xC1 asm/non_matchings/code/z_kaleido_setup/func_800F4A10.s,func_800F4A10,0x800F4A10,0x7F asm/non_matchings/code/z_kaleido_setup/func_800F4C0C.s,func_800F4C0C,0x800F4C0C,0x85 asm/non_matchings/code/z_kaleido_setup/func_800F4E20.s,func_800F4E20,0x800F4E20,0x42 @@ -1578,7 +1578,7 @@ asm/non_matchings/code/z_msgevent/func_8010BF58.s,func_8010BF58,0x8010BF58,0x5A asm/non_matchings/code/z_nmi_buff/Nmi_Init.s,Nmi_Init,0x8010C0C0,0x29 asm/non_matchings/code/z_nmi_buff/Nmi_SetPrenmiStart.s,Nmi_SetPrenmiStart,0x8010C164,0xE asm/non_matchings/code/z_nmi_buff/Nmi_GetPrenmiHasStarted.s,Nmi_GetPrenmiHasStarted,0x8010C19C,0x5 -asm/non_matchings/code/z_nmi_buff/func_8010C1B0.s,func_8010C1B0,0x8010C1B0,0x20 +asm/non_matchings/code/z_nmi_buff/MsgEvent_SendNullTask.s,MsgEvent_SendNullTask,0x8010C1B0,0x20 asm/non_matchings/code/z_olib/OLib_Vec3fDist.s,OLib_Vec3fDist,0x8010C230,0x11 asm/non_matchings/code/z_olib/OLib_Vec3fDistOutDiff.s,OLib_Vec3fDistOutDiff,0x8010C274,0x17 asm/non_matchings/code/z_olib/OLib_Vec3fDistXZ.s,OLib_Vec3fDistXZ,0x8010C2D0,0xD @@ -2907,10 +2907,10 @@ asm/non_matchings/code/sys_matrix/func_8018219C.s,func_8018219C,0x8018219C,0x4A asm/non_matchings/code/sys_matrix/func_801822C4.s,func_801822C4,0x801822C4,0x4A asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s,Matrix_InsertRotationAroundUnitVector_f,0x801823EC,0x118 asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s,Matrix_InsertRotationAroundUnitVector_s,0x8018284C,0x111 -asm/non_matchings/code/sys_matrix/SysUcode_GetUCodeBoot.s,SysUcode_GetUCodeBoot,0x80182C90,0x4 -asm/non_matchings/code/sys_matrix/SysUcode_GetUCodeBootSize.s,SysUcode_GetUCodeBootSize,0x80182CA0,0x7 -asm/non_matchings/code/sys_matrix/SysUcode_GetUCode.s,SysUcode_GetUCode,0x80182CBC,0x4 -asm/non_matchings/code/sys_matrix/SysUcode_GetUCodeData.s,SysUcode_GetUCodeData,0x80182CCC,0x5 +asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBoot.s,SysUcode_GetUCodeBoot,0x80182C90,0x4 +asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBootSize.s,SysUcode_GetUCodeBootSize,0x80182CA0,0x7 +asm/non_matchings/code/sys_ucode/SysUcode_GetUCode.s,SysUcode_GetUCode,0x80182CBC,0x4 +asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeData.s,SysUcode_GetUCodeData,0x80182CCC,0x5 asm/non_matchings/code/sys_ucode/func_80182CE0.s,func_80182CE0,0x80182CE0,0xD0 asm/non_matchings/code/sys_ucode/func_80183020.s,func_80183020,0x80183020,0xE asm/non_matchings/code/sys_ucode/func_80183058.s,func_80183058,0x80183058,0x6 @@ -3585,18 +3585,18 @@ asm/non_matchings/code/code_801A7B10/func_801A9768.s,func_801A9768,0x801A9768,0x asm/non_matchings/code/code_801A7B10/func_801A982C.s,func_801A982C,0x801A982C,0x63 asm/non_matchings/code/code_801A7B10/func_801A99B8.s,func_801A99B8,0x801A99B8,0x2F asm/non_matchings/code/code_801A7B10/func_801A9A74.s,func_801A9A74,0x801A9A74,0x27 -asm/non_matchings/code/code_801A7B10/func_801A9B10.s,func_801A9B10,0x801A9B10,0x1A -asm/non_matchings/code/code_801A7B10/func_801A9B78.s,func_801A9B78,0x801A9B78,0x21 -asm/non_matchings/code/code_801A7B10/func_801A9BFC.s,func_801A9BFC,0x801A9BFC,0x1B -asm/non_matchings/code/code_801A7B10/func_801A9C68.s,func_801A9C68,0x801A9C68,0x2A -asm/non_matchings/code/code_801A7B10/func_801A9D10.s,func_801A9D10,0x801A9D10,0x2F -asm/non_matchings/code/code_801A7B10/func_801A9DCC.s,func_801A9DCC,0x801A9DCC,0x36 -asm/non_matchings/code/code_801A7B10/func_801A9EA4.s,func_801A9EA4,0x801A9EA4,0x2A -asm/non_matchings/code/code_801A7B10/func_801A9F4C.s,func_801A9F4C,0x801A9F4C,0x35 -asm/non_matchings/code/code_801AA020/func_801AA020.s,func_801AA020,0x801AA020,0x8A -asm/non_matchings/code/code_801AA020/func_801AA248.s,func_801AA248,0x801AA248,0x67 -asm/non_matchings/code/code_801AA020/func_801AA3E4.s,func_801AA3E4,0x801AA3E4,0x4F -asm/non_matchings/code/code_801AA020/func_801AA520.s,func_801AA520,0x801AA520,0x3C +asm/non_matchings/code/jpegutils/JpegUtils_ProcessQuantizationTable.s,JpegUtils_ProcessQuantizationTable,0x801A9B10,0x1A +asm/non_matchings/code/jpegutils/JpegUtils_ParseHuffmanCodesLengths.s,JpegUtils_ParseHuffmanCodesLengths,0x801A9B78,0x21 +asm/non_matchings/code/jpegutils/JpegUtils_GetHuffmanCodes.s,JpegUtils_GetHuffmanCodes,0x801A9BFC,0x1B +asm/non_matchings/code/jpegutils/JpegUtils_SetHuffmanTable.s,JpegUtils_SetHuffmanTable,0x801A9C68,0x2A +asm/non_matchings/code/jpegutils/JpegUtils_ProcessHuffmanTableImpl.s,JpegUtils_ProcessHuffmanTableImpl,0x801A9D10,0x2F +asm/non_matchings/code/jpegutils/JpegUtils_ProcessHuffmanTable.s,JpegUtils_ProcessHuffmanTable,0x801A9DCC,0x36 +asm/non_matchings/code/jpegutils/JpegUtils_SetHuffmanTableOld.s,JpegUtils_SetHuffmanTableOld,0x801A9EA4,0x2A +asm/non_matchings/code/jpegutils/JpegUtils_ProcessHuffmanTableImplOld.s,JpegUtils_ProcessHuffmanTableImplOld,0x801A9F4C,0x35 +asm/non_matchings/code/jpegdecoder/JpegDecoder_Decode.s,JpegDecoder_Decode,0x801AA020,0x8A +asm/non_matchings/code/jpegdecoder/JpegDecoder_ProcessMcu.s,JpegDecoder_ProcessMcu,0x801AA248,0x67 +asm/non_matchings/code/jpegdecoder/JpegDecoder_ParseNextSymbol.s,JpegDecoder_ParseNextSymbol,0x801AA3E4,0x4F +asm/non_matchings/code/jpegdecoder/JpegDecoder_ReadBits.s,JpegDecoder_ReadBits,0x801AA520,0x3C asm/non_matchings/code/z_game_over/GameOver_Init.s,GameOver_Init,0x801AA610,0x5 asm/non_matchings/code/z_game_over/GameOver_FadeLights.s,GameOver_FadeLights,0x801AA624,0x1A asm/non_matchings/code/z_game_over/GameOver_Update.s,GameOver_Update,0x801AA68C,0x105