From 32b02147925566bac93bf71b002860335583574c Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 9 Sep 2021 08:51:12 +0100 Subject: Split home bank --- src/home/frames.asm | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/home/frames.asm (limited to 'src/home/frames.asm') diff --git a/src/home/frames.asm b/src/home/frames.asm new file mode 100644 index 0000000..8ed36a2 --- /dev/null +++ b/src/home/frames.asm @@ -0,0 +1,65 @@ +; calls DoFrame a times +DoAFrames: ; 0536 (0:0536) +.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: ; 053f (0:053f) + 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: ; 0572 (0:0572) + 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 -- cgit v1.2.3 From 0017fc2d171c87d7bab4c9be90e1069ae95a8071 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 9 Sep 2021 08:54:29 +0100 Subject: Remove home bank address comments --- src/home/frames.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/home/frames.asm') diff --git a/src/home/frames.asm b/src/home/frames.asm index 8ed36a2..c32053d 100644 --- a/src/home/frames.asm +++ b/src/home/frames.asm @@ -1,5 +1,5 @@ ; calls DoFrame a times -DoAFrames: ; 0536 (0:0536) +DoAFrames: .loop push af call DoFrame @@ -10,7 +10,7 @@ DoAFrames: ; 0536 (0:0536) ; 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: ; 053f (0:053f) +DoFrame: push af push hl push de @@ -42,7 +42,7 @@ DoFrame: ; 053f (0:053f) ; handle D-pad repeat counter ; used to quickly scroll through menus when a relevant D-pad key is held -HandleDPadRepeat: ; 0572 (0:0572) +HandleDPadRepeat: ldh a, [hKeysHeld] ldh [hDPadHeld], a and D_PAD -- cgit v1.2.3