diff --git a/asm/code_08050038.s b/asm/code_08050038.s index 6f789d02..9e01870f 100644 --- a/asm/code_08050038.s +++ b/asm/code_08050038.s @@ -5,8 +5,8 @@ .text - thumb_func_start sub_08050154 -sub_08050154: @ 0x08050154 + thumb_func_start UpdateFade +UpdateFade: @ 0x08050154 push {r4, r5, r6, lr} ldr r4, _08050180 @ =gFadeControl ldrh r0, [r4, #8] diff --git a/asm/macros/scripts.inc b/asm/macros/scripts.inc index 240d481d..c165f8fe 100644 --- a/asm/macros/scripts.inc +++ b/asm/macros/scripts.inc @@ -329,7 +329,7 @@ .2byte \s .endm -.macro _0807E788 w:req +.macro SetFadeMask w:req .2byte 0x0c39 .4byte \w .endm diff --git a/data/scripts/script_0801232C.inc b/data/scripts/script_0801232C.inc index cca78f35..543e73ed 100644 --- a/data/scripts/script_0801232C.inc +++ b/data/scripts/script_0801232C.inc @@ -31,7 +31,7 @@ script_08012368: StopBgm BeginBlock _0807E778 0x0004 - _0807E788 0x00007fff + SetFadeMask 0x00007fff DoFade5 _0807E858 0x0080 EndBlock @@ -55,7 +55,7 @@ script_08012368: Wait 0x003c BeginBlock _0807E778 0x0004 - _0807E788 0xffffffff + SetFadeMask 0xffffffff DoFade4 _0807E858 0x0080 EndBlock diff --git a/data/scripts/script_08012430.inc b/data/scripts/script_08012430.inc index c18f6787..fbc1bae5 100644 --- a/data/scripts/script_08012430.inc +++ b/data/scripts/script_08012430.inc @@ -77,7 +77,7 @@ script_0801248A: MoveEntityToPlayer Call sub_0807F844 CameraTargetPlayer - _0807E788 0xffffffff + SetFadeMask 0xffffffff _0807E778 0x0004 _0807E800 0x00000000 WaitFor_2 diff --git a/data/scripts/script_0801319A.inc b/data/scripts/script_0801319A.inc index 4e7727b2..d3bac5c5 100644 --- a/data/scripts/script_0801319A.inc +++ b/data/scripts/script_0801319A.inc @@ -49,7 +49,7 @@ SCRIPT_START script_080131AC _0807EA94 _0807E5F8 0x00000020 WaitForSomething2 0x00000040 - _0807E788 0xffff7fff + SetFadeMask 0xffff7fff _0807E778 0x0004 DoFade5 WaitFor_2 @@ -60,7 +60,7 @@ SCRIPT_START script_080131AC Call sub_0807F5C0 TextboxNoOverlapFollowPos 0x1604, 0x0007 _0807EA94 - _0807E788 0xffffffff + SetFadeMask 0xffffffff _0807E778 0x0004 DoFade4 WaitFor_2 diff --git a/data/scripts/script_08016384.inc b/data/scripts/script_08016384.inc index 7887a419..cb512c2e 100644 --- a/data/scripts/script_08016384.inc +++ b/data/scripts/script_08016384.inc @@ -62,4 +62,4 @@ SCRIPT_START script_08016384 WaitFor_1 WaitFor_2 _0807E778 0x0004 - _0807E788 0x0000ffff + SetFadeMask 0x0000ffff diff --git a/include/main.h b/include/main.h index 679fd35f..0d3643ae 100644 --- a/include/main.h +++ b/include/main.h @@ -89,7 +89,7 @@ extern void DoSoftReset(void); extern void sub_08056260(void); extern void VBlankIntrWait(); extern void MessageUpdate(void); -extern void sub_08050154(void); +extern void UpdateFade(void); extern u8 gUnk_03003DE4; diff --git a/include/structures.h b/include/structures.h index 86962b43..5298e1f5 100644 --- a/include/structures.h +++ b/include/structures.h @@ -93,7 +93,7 @@ typedef struct { u8 field_0x1; u8 field_0x2; u8 field_0x3; - u32 field_0x4; + u32 mask; u16 fadeType; // fade in or out, are there others? u16 fadeSpeed; // subtracted from duration u16 fadeDuration; @@ -103,9 +103,9 @@ typedef struct { s16 field_0x14; u16 field_0x16; u16 field_0x18; -} struct_03000FD0; +} FadeControl; -extern struct_03000FD0 gFadeControl; +extern FadeControl gFadeControl; typedef struct { u8 filler0[0x1A]; diff --git a/include/tiles.h b/include/tiles.h new file mode 100644 index 00000000..9915face --- /dev/null +++ b/include/tiles.h @@ -0,0 +1,18 @@ +#ifndef TILES_H +#define TILES_H + +typedef enum { + CUT_BUSH = 0x1C, + CUT_GRASS = 0x1D, + CUT_SIGNPOST = 0x1E, + CUT_TREE = 0x1F, + ROCK = 0x55, + CHEST = 0x73, + SIGNPOST = 0x176, + PERMA_ROCK = 0x1D3, + PERMA_ROCK2 = 0x1D4, + PERMA_ROCK3 = 0x1D5, + PERMA_ROCK4 = 0x1D6, +} Tile; + +#endif // TILES_H diff --git a/src/audio.c b/src/audio.c index e8301fd6..32cd2f11 100644 --- a/src/audio.c +++ b/src/audio.c @@ -198,7 +198,6 @@ s32 fade(s32 target, s32 current) { void doPlaySound(u32 sound) { u32 volume; - u32 iVar2; MusicPlayerInfo* musicPlayerInfo; if (sound == 0) @@ -209,8 +208,7 @@ void doPlaySound(u32 sound) { } else { volume = gSoundPlayingInfo.volumeSfx; } - iVar2 = gSoundPlayingInfo.volumeMaster; - volume = iVar2 * volume / 0x100; + volume = gSoundPlayingInfo.volumeMaster * volume / 0x100; musicPlayerInfo = gMusicPlayers[gSongTable[sound].musicPlayerIndex].info; m4aMPlayImmInit(musicPlayerInfo); m4aMPlayVolumeControl(musicPlayerInfo, 0xffff, volume); diff --git a/src/game.c b/src/game.c index 69f344b8..ee37c155 100644 --- a/src/game.c +++ b/src/game.c @@ -67,7 +67,7 @@ void sub_0805212C(void) { #else sub_08052418(0, 0); gScreen.lcd.displayControl |= 0x600; - gFadeControl.field_0x4 = 0xffff; + gFadeControl.mask = 0x0000ffff; DoFade(4, 0x10); #endif } @@ -97,7 +97,7 @@ void sub_080521A0(void) { gMenu.field_0x3 = 0; sub_080A7114(1); sub_08052418(0, 0); - gFadeControl.field_0x4 = 0xffffffff; + gFadeControl.mask = 0xffffffff; break; case 1: if (gMenu.transitionTimer == 0) { diff --git a/src/intro.c b/src/intro.c index a181800e..55e7cad6 100644 --- a/src/intro.c +++ b/src/intro.c @@ -285,7 +285,7 @@ static void HandleJapaneseTitlescreenAnimationIntro(void) { gIntroState.subState++; gScreen.bg.bg1yOffset = 0; gScreen.bg.bg1Control = 0xc09; - gFadeControl.field_0x4 = 0x40; + gFadeControl.mask = 0x00000040; DoFade(6, 0x10); SoundReq(SFX_F8); } @@ -293,7 +293,7 @@ static void HandleJapaneseTitlescreenAnimationIntro(void) { break; case 1: if (!gFadeControl.active) { - gFadeControl.field_0x4 = -1; + gFadeControl.mask = 0xFFFFFFFF; gIntroState.subState++; #if defined(JP) || defined(EU) gIntroState.timer = 120; diff --git a/src/main.c b/src/main.c index 421fe0f1..08a6f0fc 100644 --- a/src/main.c +++ b/src/main.c @@ -81,7 +81,7 @@ void AgbMain(void) { gMain.ticks++; sScreenHandlers[gMain.screen](); MessageUpdate(); - sub_08050154(); + UpdateFade(); SoundLoop(); break; } diff --git a/src/manager/managerF.c b/src/manager/managerF.c index d7e1d7bb..76e49700 100644 --- a/src/manager/managerF.c +++ b/src/manager/managerF.c @@ -9,6 +9,7 @@ #include "textbox.h" #include "script.h" #include "utils.h" +#include "tiles.h" void sub_08058ECC(ManagerF*); @@ -335,7 +336,7 @@ void sub_0805930C(ManagerF* this) { } void SetDirtTile(u32 tile) { - SetTileType(0x1d, tile, 1); + SetTileType(CUT_GRASS, tile, 1); SetTileType(0, tile, 2); SetTileType(0, tile - 0x40, 2); } diff --git a/src/script.c b/src/script.c index fd1c2dcf..16cdac39 100644 --- a/src/script.c +++ b/src/script.c @@ -75,7 +75,7 @@ void ScriptCommand_WaitForPlayerAction0x17(Entity* entity, ScriptExecutionContex void ScriptCommand_WaitFor_1(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_WaitFor_2(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_0807E778(Entity* entity, ScriptExecutionContext* context); -void ScriptCommand_0807E788(Entity* entity, ScriptExecutionContext* context); +void ScriptCommand_SetFadeMask(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_0807E79C(Entity* entity, ScriptExecutionContext* context); void ScriptCommandNop2(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_DoFade4(Entity* entity, ScriptExecutionContext* context); @@ -220,7 +220,7 @@ const ScriptCommand gScriptCommands[] = { ScriptCommandNop, ScriptCommand_WaitFor_1, ScriptCommand_WaitFor_2, ScriptCommand_0807E778, - ScriptCommand_0807E788, + ScriptCommand_SetFadeMask, ScriptCommand_0807E79C, ScriptCommandNop2, ScriptCommand_DoFade4, @@ -1005,8 +1005,8 @@ void ScriptCommand_0807E778(Entity* entity, ScriptExecutionContext* context) { gActiveScriptInfo.unk_08 = context->scriptInstructionPointer[1]; } -void ScriptCommand_0807E788(Entity* entity, ScriptExecutionContext* context) { - gFadeControl.field_0x4 = GetNextScriptCommandWordAfterCommandMetadata(context->scriptInstructionPointer); +void ScriptCommand_SetFadeMask(Entity* entity, ScriptExecutionContext* context) { + gFadeControl.mask = GetNextScriptCommandWordAfterCommandMetadata(context->scriptInstructionPointer); } void ScriptCommand_0807E79C(Entity* entity, ScriptExecutionContext* context) { diff --git a/src/sub_08050008.c b/src/sub_08050008.c index df79883a..580c3a32 100644 --- a/src/sub_08050008.c +++ b/src/sub_08050008.c @@ -6,5 +6,5 @@ extern u32 gUnk_020354C0; void sub_08050008() { MemClear(&gUnk_020354C0, 128); - gFadeControl.field_0x4 = -1; + gFadeControl.mask = 0xFFFFFFFF; } diff --git a/src/sub_0805E374.c b/src/sub_0805E374.c index e035ce07..3ec3e287 100644 --- a/src/sub_0805E374.c +++ b/src/sub_0805E374.c @@ -9,7 +9,7 @@ Entity* sub_0805E374(Entity* param_1) { u8 r3 = gScreenTransition.field_0x24[8]; u8* array = gUnk_081091F8; - if (r3 != '\x02') { + if (r3 != 2) { array = gUnk_081091EE; } return sub_0805E3A0(param_1, array[param_1->kind]); diff --git a/src/sub_0807B820.c b/src/sub_0807B820.c index fabdc8d9..14da7b18 100644 --- a/src/sub_0807B820.c +++ b/src/sub_0807B820.c @@ -9,46 +9,46 @@ void sub_0807B7D8(u32 param_1, u32 param_2, u32 param_3) { sub_08000152(53); sub_0807B778(param_2, param_3); sub_0807B778(param_2 + 1, param_3); - sub_0807B778(param_2 + -1, param_3); + sub_0807B778(param_2 - 1, param_3); sub_0807B778(param_2 + 64, param_3); - sub_0807B778(param_2 + -64, param_3); + sub_0807B778(param_2 - 64, param_3); } else { SetTileType(param_1, param_2, param_3); } } void sub_0807B820(u32 param_1) { - SetTileType(620, param_1 + -65, 1); - SetTileType(627, param_1 + -65, 2); - SetTileType(621, param_1 + -64, 1); - SetTileType(628, param_1 + -64, 2); - SetTileType(622, param_1 + -63, 1); - SetTileType(629, param_1 + -63, 2); - SetTileType(623, param_1 + -1, 1); + SetTileType(620, param_1 - 65, 1); + SetTileType(627, param_1 - 65, 2); + SetTileType(621, param_1 - 64, 1); + SetTileType(628, param_1 - 64, 2); + SetTileType(622, param_1 - 63, 1); + SetTileType(629, param_1 - 63, 2); + SetTileType(623, param_1 - 1, 1); SetTileType(624, param_1, 1); SetTileType(626, param_1 + 1, 1); } void sub_0807B8A8(u32 param_1) { - SetTileType(636, param_1 + -65, 1); - SetTileType(643, param_1 + -65, 2); - SetTileType(637, param_1 + -64, 1); - SetTileType(644, param_1 + -64, 2); - SetTileType(638, param_1 + -63, 1); - SetTileType(645, param_1 + -63, 2); - SetTileType(639, param_1 + -1, 1); + SetTileType(636, param_1 - 65, 1); + SetTileType(643, param_1 - 65, 2); + SetTileType(637, param_1 - 64, 1); + SetTileType(644, param_1 - 64, 2); + SetTileType(638, param_1 - 63, 1); + SetTileType(645, param_1 - 63, 2); + SetTileType(639, param_1 - 1, 1); SetTileType(640, param_1, 1); SetTileType(642, param_1 + 1, 1); } void sub_0807B930(int param_1) { - SetTileType(652, param_1 + -65, 1); - SetTileType(659, param_1 + -65, 2); - SetTileType(653, param_1 + -64, 1); - SetTileType(660, param_1 + -64, 2); - SetTileType(654, param_1 + -63, 1); - SetTileType(661, param_1 + -63, 2); - SetTileType(655, param_1 + -1, 1); + SetTileType(652, param_1 - 65, 1); + SetTileType(659, param_1 - 65, 2); + SetTileType(653, param_1 - 64, 1); + SetTileType(660, param_1 - 64, 2); + SetTileType(654, param_1 - 63, 1); + SetTileType(661, param_1 - 63, 2); + SetTileType(655, param_1 - 1, 1); SetTileType(656, param_1, 1); SetTileType(658, param_1 + 1, 1); } diff --git a/src/sub_080A554C.c b/src/sub_080A554C.c index 4ec59e7f..dffcbab0 100644 --- a/src/sub_080A554C.c +++ b/src/sub_080A554C.c @@ -11,7 +11,7 @@ u32 sub_080A554C(u32 arg0) { if (arg0 != 0) { for (i = 0; i < 17; i++) { - if (arg0 == (&gUnk_02000090)[i]) + if (arg0 == gMenu.focusCoords[i]) return i; } } diff --git a/src/sub_08127D30.c b/src/sub_08127D30.c index aa953d3a..1ce3f625 100644 --- a/src/sub_08127D30.c +++ b/src/sub_08127D30.c @@ -3,8 +3,5 @@ extern u8 gUnk_08127D30[69]; u32 sub_08052654(u32 r0) { - // u32 r1 = gUnk_08127D30; - // u32 r1 = gUnk_08127D30; - return gUnk_08127D30[r0 * 4] == 129; }