diff options
author | Daniel Harding <33dannye@gmail.com> | 2021-09-19 00:21:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-19 00:21:14 -0500 |
commit | df67aac83b466dadf5f74c881bf84dd9ef19bdfc (patch) | |
tree | 47501aced2d256052b8f78bc97328d5af5703add /src/home/frames.asm | |
parent | e4bce9b7ee5e89f8edfd921de2379f0fa06af206 (diff) | |
parent | 8dee6b7a11e85d6d4b9f8ec9fb9d53a499fd37dc (diff) |
Merge pull request #110 from ElectroDeoxys/master
Split Home bank
Diffstat (limited to 'src/home/frames.asm')
-rw-r--r-- | src/home/frames.asm | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/home/frames.asm b/src/home/frames.asm new file mode 100644 index 0000000..c32053d --- /dev/null +++ b/src/home/frames.asm @@ -0,0 +1,65 @@ +; calls DoFrame a times +DoAFrames: +.loop + push af + call DoFrame + pop af + dec a + jr nz, .loop + ret + +; updates background, sprites and other game variables, halts until vblank, and reads user input +; if wDebugPauseAllowed is not 0, the game can be paused (and resumed) by pressing the SELECT button +DoFrame: + push af + push hl + push de + push bc + ld hl, wDoFrameFunction ; context-specific function + call CallIndirect + call WaitForVBlank + call ReadJoypad + call HandleDPadRepeat + ld a, [wDebugPauseAllowed] + or a + jr z, .done + ldh a, [hKeysPressed] + and SELECT + jr z, .done +.game_paused_loop + call WaitForVBlank + call ReadJoypad + call HandleDPadRepeat + ldh a, [hKeysPressed] + and SELECT + jr z, .game_paused_loop +.done + pop bc + pop de + pop hl + pop af + ret + +; handle D-pad repeat counter +; used to quickly scroll through menus when a relevant D-pad key is held +HandleDPadRepeat: + ldh a, [hKeysHeld] + ldh [hDPadHeld], a + and D_PAD + jr z, .done + ld hl, hDPadRepeat + ldh a, [hKeysPressed] + and D_PAD + jr z, .dpad_key_held + ld [hl], 24 + ret +.dpad_key_held + dec [hl] + jr nz, .done + ld [hl], 6 + ret +.done + ldh a, [hKeysPressed] + and BUTTONS + ldh [hDPadHeld], a + ret |