Browse Source

Skip player update if the background is scrolling

master
Forest Belton 3 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 inc hl
ld [hl], LOW(\1) ld [hl], LOW(\1)
ENDM 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 "hardware.inc"
INCLUDE "util.inc"
INCLUDE "png/map/intro.inc" INCLUDE "png/map/intro.inc"
SECTION "BG Data", WRAM0 SECTION "BG Data", WRAM0
@ -7,6 +9,8 @@ BG_COLLISION_DATA:: dw
BG_MAP_WIDTH:: db BG_MAP_WIDTH:: db
BG_MAP_HEIGHT:: db BG_MAP_HEIGHT:: db
BG_SCROLLING:: db
SECTION "BG Code", ROM0 SECTION "BG Code", ROM0
MACRO update_map_info MACRO update_map_info
@ -24,6 +28,8 @@ MACRO update_map_info
ENDM ENDM
BG_Init:: BG_Init::
SET8 BG_SCROLLING, 0
; copy map ; copy map
ld e, intro_HEIGHT ld e, intro_HEIGHT
ld bc, _SCRN0 ld bc, _SCRN0
@ -58,3 +64,6 @@ BG_Init::
update_map_info intro_COLLISION, intro_WIDTH, intro_HEIGHT update_map_info intro_COLLISION, intro_WIDTH, intro_HEIGHT
ret ret
BG_Update::
ret

+ 1
- 0
src/main.s View File

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

+ 7
- 2
src/player.s View File

@ -60,10 +60,15 @@ Player_Init::
ret ret
Player_Update:: 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 ; check for jump
ld hl, keys
ld b, [hl]
ld a, b ld a, b
and BTN_UP and BTN_UP
jr z, .jump_update_check jr z, .jump_update_check

Loading…
Cancel
Save