diff options
author | Astatin <[email protected]> | 2025-03-04 18:27:00 +0900 |
---|---|---|
committer | Astatin <[email protected]> | 2025-03-04 18:27:00 +0900 |
commit | b04c85f5316b58a60b5ae161e9bbf3a20cf1b084 (patch) | |
tree | 04f42715a5cf7f6a08a742f6ef6b81e18249be36 | |
parent | afc683fd953bee5b7c9bed2439492cc7c1f87a49 (diff) |
Fix out of VBlank on dialogue open (most of the time) + object remove
-rw-r--r-- | definitions.gbasm | 14 | ||||
-rw-r--r-- | entity/bunny.gbasm | 1 | ||||
-rw-r--r-- | gui.gbasm | 17 | ||||
-rw-r--r-- | main.gbasm | 18 | ||||
-rw-r--r-- | map/loading.gbasm | 48 | ||||
-rw-r--r-- | map/objects.gbasm | 11 | ||||
-rw-r--r-- | playerattacks/hop.gbasm | 4 |
7 files changed, 89 insertions, 24 deletions
diff --git a/definitions.gbasm b/definitions.gbasm index 0fd7f90..c8bfc3a 100644 --- a/definitions.gbasm +++ b/definitions.gbasm @@ -2,6 +2,7 @@ .DEFINE reg_interrupt_flags ($0f) .DEFINE reg_lcd_controller ($40) .DEFINE reg_lcd_status ($41) +.DEFINE reg_ly ($44) .DEFINE reg_lyc ($45) .DEFINE reg_viewport_y ($42) .DEFINE reg_viewport_x ($43) @@ -45,7 +46,7 @@ .DEFINE mem_map_loading_flags ($c00c) ; bit 0: if the object should be reloaded (scroll or first load) -; bit 1: has a movement ended (objects interaction should be checked, entities sh0uld update their positions) +; bit 1: has a movement ended (objects interaction should be checked, entities should update their positions) ; bit 2: if the prepared block should be updated at the next frame ; bit 3: animation step is going up (?) @@ -60,8 +61,11 @@ .DEFINE mem_display_flag ($c013) ; bit 0: if dialogue box is displayed ; bit 1: dialogue box first line should be bold -; bit 2: if dialogue box text should be refreshed +; bit 2: if dialogue box text should be refreshed (part1) ; bit 3: if side window box should be displayed +; bit 4: if dialogue box text should be refreshed (part2) +; bit 5: if object display is paused +; bit 6: if additional tile should be loaded .DEFINE mem_current_mode ($c014) .DEFINE mem_requested_mode ($c015) @@ -112,6 +116,12 @@ .DEFINE mem_blinking_animation_counter ($c036) +.DEFINE mem_additional_loading_block_x ($c037) +.DEFINE mem_additional_loading_block_y ($c038) +.DEFINE mem_additional_loading_block_tile ($c039) +.DEFINE mem_additional_loading_block_position_1 ($c03a) +.DEFINE mem_additional_loading_block_position_2 ($c03b) + .DEFINE mem_next_free_head_lower_bytes ($c6ff) .DEFINE mem_dungeon_generation_heads $c700 ; Takes the memory from c700 to c717 diff --git a/entity/bunny.gbasm b/entity/bunny.gbasm index 084cf59..d2b9148 100644 --- a/entity/bunny.gbasm +++ b/entity/bunny.gbasm @@ -283,7 +283,6 @@ Move_Bunny: BIT 3, A JR Z, =.Middle_movement_doublespeed_viewport_update.end LD A, E - LD $dbg_var, A CP $02 JR NZ, =.Middle_movement_doublespeed_viewport_update.end @@ -18,18 +18,20 @@ Copy_Dialogue_Buffer: LD A, $mem_display_flag BIT 2, A - RET Z + JR Z, =Copy_Dialogue_Buffer_Part2 RES 2, A + SET 4, A LD $mem_display_flag, A LD HL, $9cb4 LD DE, $dialogue_first_line LD C, $12 - CALL =tilemap_memcpy + JP =tilemap_memcpy - ; LD HL, $9cd4 - ; LD DE, $dialogue_second_line - ; LD C, $12 - ; CALL =tilemap_memcpy +Copy_Dialogue_Buffer_Part2: + BIT 4, A + RET Z + RES 4, A + LD $mem_display_flag, A LD HL, $9cf4 LD DE, $dialogue_third_line @@ -300,6 +302,9 @@ Open_dialogue_on_dungeon_menu_mode: CP $enum_dungeon_menu_mode RET NZ + LD A, $mem_display_flag + BIT 0, A + RET NZ LD A, $0d LD $mem_display_flag, A @@ -154,6 +154,7 @@ New_Dungeon: .SET_WINDOW_LCDC_E .ENABLE_TOP_BAR .ENABLE_VBLANK_INTERRUPTS + .HBLANK_WAIT EI Wait_for_Interrupt.loop: HALT @@ -161,6 +162,7 @@ New_Dungeon: JP =Wait_for_Interrupt.loop VBLANK_Entrypoint: + DBG .SET_WINDOW_LCDC_E .ENABLE_TOP_BAR @@ -185,13 +187,22 @@ VBLANK_Entrypoint: LD A, $mem_bunny_mana CALL =Print_8bit - CALL =Display_Prepared_Block + CALL =Display_Prepared_Blocks CALL =Display_Object Skip_VBlank_Dungeon_Update: CALL =Copy_Dialogue_Buffer CALL =Display_dialogue_cursor + LD A, $reg_lcd_status + AND $03 + CP $01 + JR Z, =.skip_stop + ; STOP + .skip_stop: + LD $dbg_var A + + DBG ; LYC LD A, $0a LD $reg_lyc, A @@ -200,6 +211,7 @@ VBLANK_Entrypoint: EI CALL =Pad_Button_Check + CALL =Load_Additional_Block LD A, $mem_current_mode CP $enum_dungeon_mode @@ -210,10 +222,6 @@ VBLANK_Entrypoint: CALL =Respawn_Entities CALL =Prepare_Scrolling_Map - LD A, $mem_current_mode - LD B, A - LD A, $mem_animation_wait_frames - Skip_Dungeon_Update: LD A, $mem_current_mode diff --git a/map/loading.gbasm b/map/loading.gbasm index f7ba1ab..505bc53 100644 --- a/map/loading.gbasm +++ b/map/loading.gbasm @@ -13,7 +13,7 @@ Load_Map: .For_X: LD A, C CALL =Load_Block - CALL =Display_Prepared_Block + CALL =Display_Main_Prepared_Block INC C LD A, C @@ -251,19 +251,55 @@ Load_Block: ; X in A, Y in B POP BC RET -Display_Prepared_Block: - PUSH AF - PUSH BC - PUSH DE +Load_Additional_Block: + LD A, $mem_display_flag + BIT 6, A + RET Z + LD A, $mem_additional_loading_block_y + LD B, A + LD A, $mem_additional_loading_block_x + CALL =Load_Block + LD A, $mem_prepared_block_tile + LD $mem_additional_loading_block_tile, A + LD A, $mem_prepared_block_position_1 + LD $mem_additional_loading_block_position_1, A + LD A, $mem_prepared_block_position_2 + LD $mem_additional_loading_block_position_2, A + RET +Display_Prepared_Blocks: LD A, $mem_map_loading_flags BIT 2, A - JR Z, =.End + JR Z, =.Skip_Main LD A, $mem_map_loading_flags RES 2, A LD $mem_map_loading_flags, A + CALL =Display_Main_Prepared_Block + + .Skip_Main: + LD A, $mem_display_flag + BIT 6, A + RET Z + RES 6, A + LD $mem_display_flag, A + + LD A, $mem_additional_loading_block_tile + LD $mem_prepared_block_tile, A + LD A, $mem_additional_loading_block_position_1 + LD $mem_prepared_block_position_1, A + LD A, $mem_additional_loading_block_position_2 + LD $mem_prepared_block_position_2, A + JP =Display_Main_Prepared_Block + +Display_Main_Prepared_Block: + PUSH AF + PUSH BC + PUSH DE + + + LD A, $mem_prepared_block_position_1 LD D, A diff --git a/map/objects.gbasm b/map/objects.gbasm index 5bedeee..b1a43fe 100644 --- a/map/objects.gbasm +++ b/map/objects.gbasm @@ -212,6 +212,9 @@ Restore_EP_Action: RET Display_Object: + LD A, $mem_display_flag + BIT 5, A + RET NZ LD HL, $mem_object_list LD A, $mem_object_load_counter INC A @@ -296,8 +299,12 @@ Display_Object: Display_Objects.Nothing: LD A, D - CALL =Load_Block - CALL =Display_Prepared_Block + LD $mem_additional_loading_block_x, A + LD A, B + LD $mem_additional_loading_block_y, A + LD A, $mem_display_flag + SET 6, A + LD $mem_display_flag, A RET Load_Objects: diff --git a/playerattacks/hop.gbasm b/playerattacks/hop.gbasm index 8b48f6d..8aa445b 100644 --- a/playerattacks/hop.gbasm +++ b/playerattacks/hop.gbasm @@ -36,7 +36,7 @@ Hop_Attack_Loading_VBlank: BIT 2, A RET Z - CALL =Display_Prepared_Block + CALL =Display_Main_Prepared_Block LD A, $mem_prepared_loading_block_tile LD $mem_prepared_block_tile, A @@ -49,7 +49,7 @@ Hop_Attack_Loading_VBlank: SET 2, A LD $mem_map_loading_flags, A - CALL =Display_Prepared_Block + CALL =Display_Main_Prepared_Block LD A, $mem_bunny_direction AND $07 |