Browse Source

Skip player update if the background is scrolling

master
Forest Belton 2 years ago
parent
commit
f1ba4dadeb
4 changed files with 26 additions and 2 deletions
  1. +9
    -0
      inc/util.inc
  2. +9
    -0
      src/bg.s
  3. +1
    -0
      src/main.s
  4. +7
    -2
      src/player.s

+ 9
- 0
inc/util.inc View File

@ -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

+ 9
- 0
src/bg.s View File

@ -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

+ 1
- 0
src/main.s View File

@ -53,6 +53,7 @@ start:
call Keys_Update
call Player_Update
call BG_Update
; wait for vblank
halt

+ 7
- 2
src/player.s View File

@ -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

Loading…
Cancel
Save