diff options
| -rw-r--r-- | .nasm/memory.txt | 4 | ||||
| -rw-r--r-- | src/driver.s | 2 | ||||
| -rw-r--r-- | src/items.s | 19 |
3 files changed, 16 insertions, 9 deletions
diff --git a/.nasm/memory.txt b/.nasm/memory.txt index 23ba954..1e5caad 100644 --- a/.nasm/memory.txt +++ b/.nasm/memory.txt @@ -34,9 +34,11 @@ $37: zp_next_enemy_cycle $38: zp_flags $40: zp_screen_y $41-$42: zp_position_y +$43: zp_player_tile_y $44: zp_velocity_y $45: zp_screen_x $46-$47: zp_position_x +$48: zp_player_tile_x $49: zp_velocity_x $50: zp_state $51: zp_walk_counter @@ -77,4 +79,4 @@ $4016: m_joypad $4017: m_frame_counter --- Summary (in bytes) --- -- Internal RAM: 415/2048 (20.26%) +- Internal RAM: 417/2048 (20.36%) diff --git a/src/driver.s b/src/driver.s index f747c4b..632af84 100644 --- a/src/driver.s +++ b/src/driver.s @@ -195,8 +195,6 @@ lda #BLINKING_TIME sta Driver::zp_blink_timer - ;; TODO: items falling down. - @no_update: rts diff --git a/src/items.s b/src/items.s index e90ae82..447b874 100644 --- a/src/items.s +++ b/src/items.s @@ -17,6 +17,13 @@ zp_player_screen_x = $45 ; asan:ignore PLAYER_WAIST = $0C + ;; The tile coordinates are also cached during the update() + ;; function. Reserve them into their own memory regions to avoid surprises + ;; by using the 'Globals::zp_arg0' and 'Globals::zp_arg1' variables which + ;; are also being used by the background check. + zp_player_tile_y = $43 + zp_player_tile_x = $48 + ;; Maximum amount of items allowed on screen at the same time. POOL_CAPACITY = 3 @@ -341,14 +348,14 @@ lsr lsr lsr - sta Globals::zp_arg0 + sta Items::zp_player_tile_y lda zp_player_screen_x lsr lsr lsr clc adc #1 - sta Globals::zp_arg1 + sta Items::zp_player_tile_x @loop: ;; This index will be valid throughout the iteration so different @@ -735,22 +742,22 @@ ;; Check for the Y tile coordinate. If it's not the same on either the ;; upper or the bottom parts of the item, then it's a no. - cmp Globals::zp_arg0 + cmp Items::zp_player_tile_y beq @check_x clc adc #1 - cmp Globals::zp_arg0 + cmp Items::zp_player_tile_y bne @no @check_x: ;; If the Y tile coordinate checks out, let's narrow it down to the X ;; coordinate. lda Items::zp_current_tiles + 1, x - cmp Globals::zp_arg1 + cmp Items::zp_player_tile_x beq @yes clc adc #1 - cmp Globals::zp_arg1 + cmp Items::zp_player_tile_x bne @no @yes: |
