From 234240387a7afb00ba013050f182f8578c894026 Mon Sep 17 00:00:00 2001 From: VariantXYZ Date: Tue, 11 Jul 2023 22:18:55 -0700 Subject: [PATCH] Add disassembly for functions related to Minigame A scoreboard --- game/src/minigames/core.asm | 148 +++++++++++++++++++++++++++++++++++- 1 file changed, 146 insertions(+), 2 deletions(-) diff --git a/game/src/minigames/core.asm b/game/src/minigames/core.asm index eacfb7fe..b4e98750 100644 --- a/game/src/minigames/core.asm +++ b/game/src/minigames/core.asm @@ -96,7 +96,7 @@ MinigameAMappingState:: ld b, 0 ld c, 0 ld hl, $9824 - call $4374 + call MinigameADrawScore call $43A1 ld a, 1 ld [$C0C0], a @@ -119,7 +119,7 @@ MinigameAPrepareFadeInState:: jp IncSubStateIndex MinigameADoFadeInState:: - call $4404 + call MinigameASetupScoreBoard call $41AB ld a, 1 ld [W_OAM_SpritesReady], a @@ -131,6 +131,150 @@ MinigameADoFadeInState:: ld [$C835], a jp IncSubStateIndex +SECTION "Minigame A State Machine 2", ROMX[$4404], BANK[$14] +MinigameASetupScoreBoard:: +; TODO: Annotate + ld a, [$C840] + or a + jr nz, .draw_score + ld a, [$C824] + and $3f + jr nz, .asm_5041c + ld a, [$C830] + dec a + cp $18 + jr c, .asm_5041c + ld [$C830], a +.asm_5041c + ld a, [$C830] + cp $28 + jr nz, .draw_score + ld a, $01 + ld [$C380], a +.draw_score + ld a, [$C827] + ld b, a + ld a, [$C826] + ld c, a + ld hl, $9824 + call MinigameADrawScore + ld a, [$C824] + and $03 + jr nz, .asm_50481 + ld a, [$C840] + cp $06 + jr c, .asm_5044e + ld a, [$C82A] + cp $0a + jr c, .asm_50481 + dec a + jr .asm_5047e +.asm_5044e + ld a, [$C841] + or a + jr z, .asm_50462 + dec a + ld [$C841], a + ld a, [$C82A] + or a + jr z, .asm_5045f + dec a +.asm_5045f + ld [$C82A], a +.asm_50462 + ld a, [$C83B] + or a + jr z, .asm_50481 + dec a + ld [$C83B], a + ld a, [$C82A] + inc a + cp $40 + jr c, .asm_5047e + ld a, $02 + ld [$C840], a + call $47c6 + ld a, $40 +.asm_5047e + ld [$C82A], a +.asm_50481 + ld a, [$C82A] + xor $ff + inc a + add $78 + ld b, a + ld hl, $5F36 + ld a, [$C824] + srl a + srl a + and $3f + bit 5, a + jr z, .asm_504a8 + and $1f + add l + ld l, a + ld a, $00 + adc h + ld h, a + ld a, [hl] + xor $ff + inc a + jr .asm_504af +.asm_504a8 + add l + ld l, a + ld a, $00 + adc h + ld h, a + ld a, [hl] +.asm_504af + sra a + sra a + sra a + sra a + add b + ld [W_ShadowREG_WY], a + ret + +SECTION "Minigame A State Machine 3", ROMX[$4374], BANK[$14] +MinigameADrawScore:: + ld d, $00 + ld a, b + and $0f + jr nz, .not_zero + xor a + jr .draw +.not_zero + add $f0 + ld d, $f0 +.draw + di + ld b, a + rst $20 + ld a, b + ld [hli], a + ei + ld a, c + swap a + and $0f + jr nz, .not_zero_2 + or d + jr .done_drawing +.not_zero_2 + add $f0 +.done_drawing + di + ld b, a + rst $20 + ld a, b + ld [hli], a + ld a, c + and $0f + add $f0 + ld [hl], a + ei + ret + SECTION "Minigame B State Machine 1", ROMX[$5F7C], BANK[$14] MinigameBStateMachine:: ld a, [W_CoreSubStateIndex]