From f1ba4dadeb1348ba59fbba20ff1314b863470231 Mon Sep 17 00:00:00 2001 From: Forest Belton <65484+forestbelton@users.noreply.github.com> Date: Tue, 6 Jul 2021 21:33:42 -0400 Subject: [PATCH] Skip player update if the background is scrolling --- inc/util.inc | 9 +++++++++ src/bg.s | 9 +++++++++ src/main.s | 1 + src/player.s | 9 +++++++-- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/inc/util.inc b/inc/util.inc index 8c4a726..e40be8f 100644 --- a/inc/util.inc +++ b/inc/util.inc @@ -5,3 +5,12 @@ MACRO STORE16 inc hl ld [hl], LOW(\1) ENDM + +; Stores an 8-bit value into memory +; \1 Write address +; \2 8-bit value +MACRO SET8 + ld h, HIGH(\1) + ld l, LOW(\1) + ld [hl], \2 +ENDM diff --git a/src/bg.s b/src/bg.s index 4bb1e29..3069a78 100644 --- a/src/bg.s +++ b/src/bg.s @@ -1,4 +1,6 @@ INCLUDE "hardware.inc" +INCLUDE "util.inc" + INCLUDE "png/map/intro.inc" SECTION "BG Data", WRAM0 @@ -7,6 +9,8 @@ BG_COLLISION_DATA:: dw BG_MAP_WIDTH:: db BG_MAP_HEIGHT:: db +BG_SCROLLING:: db + SECTION "BG Code", ROM0 MACRO update_map_info @@ -24,6 +28,8 @@ MACRO update_map_info ENDM BG_Init:: + SET8 BG_SCROLLING, 0 + ; copy map ld e, intro_HEIGHT ld bc, _SCRN0 @@ -58,3 +64,6 @@ BG_Init:: update_map_info intro_COLLISION, intro_WIDTH, intro_HEIGHT ret + +BG_Update:: + ret diff --git a/src/main.s b/src/main.s index 7cf5085..4e35120 100644 --- a/src/main.s +++ b/src/main.s @@ -53,6 +53,7 @@ start: call Keys_Update call Player_Update + call BG_Update ; wait for vblank halt diff --git a/src/player.s b/src/player.s index 96618f3..c66b742 100644 --- a/src/player.s +++ b/src/player.s @@ -60,10 +60,15 @@ Player_Init:: ret Player_Update:: - ld hl, keys - ld b, [hl] + ; suspend player state while map is scrolling + ld hl, BG_SCROLLING + ld a, [hl] + or a + ret nz ; check for jump + ld hl, keys + ld b, [hl] ld a, b and BTN_UP jr z, .jump_update_check