From 522bde7b7e7d70fc86a5dac2042b7b20e05c197b Mon Sep 17 00:00:00 2001 From: Astatin Date: Thu, 29 Aug 2024 16:14:35 +0900 Subject: Fix issues related to VBlank wait in sameboy + Add stairs interactions --- map/loading.gbasm | 61 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 16 deletions(-) (limited to 'map/loading.gbasm') diff --git a/map/loading.gbasm b/map/loading.gbasm index bb3410b..a7783c8 100644 --- a/map/loading.gbasm +++ b/map/loading.gbasm @@ -48,17 +48,14 @@ Load_Row: ; (+1/-1 direction in B) LD A, $mem_viewport_x SUB $03 LD D, A + LD A, $mem_moving_animation_step + ADD D + LD D, A LD A, $mem_viewport_x ADD $0D LD E, A - Load_Row.For_X: - LD A, D - CALL =Load_Block - - INC D - LD A, D - CP E - JR NZ, =Load_Row.For_X + LD A, D + CALL =Load_Block POP DE POP BC @@ -90,20 +87,44 @@ Load_Column: ; (+1/-1 direction in B) LD A, $mem_viewport_y ADD $0D LD E, A - Load_Column.For_Y: - LD A, D - CALL =Load_Block - - INC B - LD A, B - CP E - JR NZ, =Load_Column.For_Y + LD A, $mem_moving_animation_step + ADD B + LD B, A + LD A, D + CALL =Load_Block POP DE POP BC POP AF RET +Display_Scrolling_Map: + LD A, $mem_map_loading_flags + BIT 0, A + JR Z, =Display_Scrolling_Map.End + + LD A, $mem_moving_sprite_direction + DEC A + AND $01 + SLA A + DEC A + LD B, A + LD A, $mem_moving_sprite_direction + DEC A + + BIT 1, A + JR NZ, =Display_Scrolling_Map.vertical + + Display_Scrolling_Map.horizontal: + CALL =Load_Column + JP =Display_Scrolling_Map.End + + Display_Scrolling_Map.vertical: + CALL =Load_Row + + Display_Scrolling_Map.End: + RET + Construct_Tile_Address: ; Construct Tile Map address from A and B in DE PUSH AF PUSH BC @@ -197,41 +218,49 @@ Load_Block: ; X in A, Y in B JR Z, =Load_Block.Empty Load_Block.Solid: LD A, C + CALL =VBlank_Wait LD (DE), A LD A, E OR $20 LD E, A LD A, C OR $02 + CALL =VBlank_Wait LD (DE), A INC E LD A, C OR $03 + CALL =VBlank_Wait LD (DE), A LD A, E AND $DF LD E, A LD A, C OR $01 + CALL =VBlank_Wait LD (DE), A JR =Load_Block.End Load_Block.Empty: LD A, $00 + CALL =VBlank_Wait LD (DE), A LD A, E OR $20 LD E, A LD A, $00 + CALL =VBlank_Wait LD (DE), A INC E LD A, $00 + CALL =VBlank_Wait LD (DE), A LD A, E AND $DF LD E, A LD A, $00 + CALL =VBlank_Wait LD (DE), A Load_Block.End: -- cgit v1.2.3-70-g09d2