diff options
author | Astatin <[email protected]> | 2025-03-25 19:01:47 +0900 |
---|---|---|
committer | Astatin <[email protected]> | 2025-03-25 19:01:47 +0900 |
commit | fb8e853fd0c6660696e762f67877b4d24a9f4c22 (patch) | |
tree | 4c2c69bd5e13bebfe02534541e4adcf2b67f335f | |
parent | 2df3daa5128a27381fe5208fa4eac59ab10bdd9c (diff) |
Separate modes VBlank functions
-rw-r--r-- | animation.gbasm | 1 | ||||
-rw-r--r-- | definitions.gbasm | 18 | ||||
-rw-r--r-- | enemiesattacks/laser.gbasm | 1 | ||||
-rw-r--r-- | entity/actions.gbasm | 60 | ||||
-rw-r--r-- | entity/bunny.gbasm | 13 | ||||
-rw-r--r-- | entity/list.gbasm | 2 | ||||
-rw-r--r-- | entity/penguin.gbasm | 13 | ||||
-rw-r--r-- | init.gbasm | 10 | ||||
-rw-r--r-- | main.gbasm | 213 | ||||
-rw-r--r-- | modes/dialoguemenu.gbasm | 39 | ||||
-rw-r--r-- | modes/dungeon.gbasm | 172 | ||||
-rw-r--r-- | modes/dungeongeneration.gbasm | 93 | ||||
-rw-r--r-- | modes/loading.gbasm | 36 | ||||
-rw-r--r-- | modes/vblank_handler_list.gbasm | 32 | ||||
-rw-r--r-- | playerattacks/earcoptr.gbasm | 1 | ||||
-rw-r--r-- | playerattacks/freeze.gbasm | 2 | ||||
-rw-r--r-- | playerattacks/heal.gbasm | 1 | ||||
-rw-r--r-- | playerattacks/hop.gbasm | 15 | ||||
-rw-r--r-- | scripts/parse_sprite_png.py | 6 |
19 files changed, 446 insertions, 282 deletions
diff --git a/animation.gbasm b/animation.gbasm index c136eb9..fdd64ae 100644 --- a/animation.gbasm +++ b/animation.gbasm @@ -11,6 +11,7 @@ Animation_Wait_Mode: LD A, $enum_dungeon_mode LD $mem_current_mode, A LD $mem_requested_mode, A + CALL =Update_VBlank_Handler RET Display_Animation_List: diff --git a/definitions.gbasm b/definitions.gbasm index 6a01759..3bb4c60 100644 --- a/definitions.gbasm +++ b/definitions.gbasm @@ -71,13 +71,14 @@ .DEFINE mem_current_mode ($c014) .DEFINE mem_requested_mode ($c015) +; bit 0-3: which vblank handler group ; bit 7: setp if map, objects and gui update are frozen .DEFINE enum_dungeon_mode $00 -.DEFINE enum_dead_mode $01 -.DEFINE enum_dungeon_menu_mode $80 -.DEFINE enum_dungeon_dialogue_mode $81 -.DEFINE enum_loading_mode $82 -.DEFINE enum_animation_wait_mode $83 +.DEFINE enum_dead_mode $10 +.DEFINE enum_dungeon_menu_mode $01 +.DEFINE enum_dungeon_dialogue_mode $11 +.DEFINE enum_loading_mode $02 +.DEFINE enum_animation_wait_mode $12 .DEFINE mem_menu_cursor_position ($c016) .DEFINE mem_last_button_direction ($c017) @@ -132,6 +133,11 @@ .DEFINE mem_entity_being_attacked_low ($c040) +.DEFINE mem_vblank_jump_instruction $c041 ; takes from c041 to c043 +.DEFINE mem_vblank_jump_destination $c042 ; takes from c042 to c043 +.DEFINE mem_stat_jump_instruction $c044 ; takes from c044 to c046 +.DEFINE mem_stat_jump_destination $c045 ; takes from c045 to c046 + .DEFINE mem_next_free_head_lower_bytes ($c6ff) .DEFINE mem_dungeon_generation_heads $c700 ; Takes the memory from c700 to c717 @@ -239,8 +245,10 @@ ; bit 3: blinking mode ; status: u8 ; ; bit 0: whether or not turns should be skipped +; ; bit 2: whether or not the status should be removed for the next turn ; ; 01: freeze ; ; 02: invincible +; ; 04: end of freeze ; mana: u8 ; _padding: u48 ; diff --git a/enemiesattacks/laser.gbasm b/enemiesattacks/laser.gbasm index 2c1cebb..caf6db2 100644 --- a/enemiesattacks/laser.gbasm +++ b/enemiesattacks/laser.gbasm @@ -82,6 +82,7 @@ Laser_Enemy_Attack: ; Direction to face in E. Result in BC (XY), Direction in D LD A, $enum_animation_wait_mode LD $mem_requested_mode, A LD $mem_current_mode, A + CALL =Update_VBlank_Handler LD A, E SUB $f LD E, A diff --git a/entity/actions.gbasm b/entity/actions.gbasm index 8b9e3a6..57b9e78 100644 --- a/entity/actions.gbasm +++ b/entity/actions.gbasm @@ -54,66 +54,6 @@ Entity_Action: LD L, A RET -Update_Animation_Steps: - LD A, $mem_blinking_animation_counter - DEC A - CP $ff - JR Z, =.Skip_blinking_update - LD $mem_blinking_animation_counter, A - .Skip_blinking_update: - - LD A, $mem_map_loading_flags - BIT 3, A - JR Z, =.update_mode - - LD A, $mem_moving_animation_step - INC A - AND $0f - LD $mem_moving_animation_step, A - - CP $00 - JR NZ, =.end - - LD A, $mem_map_loading_flags - RES 3, A - SET 1, A - LD $mem_map_loading_flags, A - - .update_mode: - - ; We need to make sure that the mode doesn't change to a mode with objects update while a dialogue box refresh is currently being done - LD A, $mem_current_mode - BIT 7, A - JR Z, =.set_current_mode - LD A, $mem_display_flag - AND 0b00010100 - CP $00 - JR NZ, =.end - - .set_current_mode: - LD A, $mem_requested_mode - LD $mem_current_mode, A - - .end: - LD A, $mem_bunny_health - CP $00 - RET NZ - LD A, $mem_moving_animation_step - CP $00 - RET NZ - - .Dead_mode: - - LD A, $20 - LD $mem_bunny_direction, A - - LD A, $enum_dead_mode - LD $mem_current_mode, A - - .CLOSE_DIALOGUE - - RET - Turn_Jump_table: ; 00 RET diff --git a/entity/bunny.gbasm b/entity/bunny.gbasm index 29f66d9..7789ec5 100644 --- a/entity/bunny.gbasm +++ b/entity/bunny.gbasm @@ -6,6 +6,17 @@ Move_Bunny: LD E, $02 .Normal_speed: + .Finish_unfreeze: + LD A, $mem_moving_animation_step + CP $00 + JR NZ, =.Finish_unfreeze.end + LD A, $mem_bunny_status + CP $04 + JR NZ, =.Finish_unfreeze.end + LD A, $00 + LD $mem_bunny_status, A + .Finish_unfreeze.end: + .Freeze_shiver: LD A, $mem_moving_animation_step CP $00 @@ -35,7 +46,7 @@ Move_Bunny: JP NC, =.Skip_turn .Unfreeze: - LD A, $00 + LD A, $04 LD $mem_bunny_status, A LD A, $mem_bunny_flags RES 1, A diff --git a/entity/list.gbasm b/entity/list.gbasm index 7f09455..5aa71bd 100644 --- a/entity/list.gbasm +++ b/entity/list.gbasm @@ -79,7 +79,7 @@ Entity_list: .DB $00 ; Starting mana - .DB $03 + .DB $05 .PADTO =.Penguin+8 diff --git a/entity/penguin.gbasm b/entity/penguin.gbasm index 0078fb9..75bba8c 100644 --- a/entity/penguin.gbasm +++ b/entity/penguin.gbasm @@ -88,11 +88,9 @@ Penguin_Turn: LD A, $mem_bunny_status CP $01 - JR NZ, =.Try_Freeze_Attack - .Run_away: - CALL =Walking_Away - - JR =.Start_action_or_movement.end + JR Z, =.Run_away + CP $04 + JR Z, =.Run_away .Try_Freeze_Attack: LD A, L @@ -118,6 +116,11 @@ Penguin_Turn: JR =.Start_action_or_movement.end + .Run_away: + CALL =Walking_Away + + JR =.Start_action_or_movement.end + .Try_Walking: CALL =Walking .Start_action_or_movement.end: @@ -2,11 +2,11 @@ .PADTO 0x0040 VBlank: - JP =VBLANK_Entrypoint + JP $mem_vblank_jump_instruction .PADTO 0x0048 STAT: - JP =STAT_Entrypoint + JP $mem_stat_jump_instruction .PADTO 0x0100 Start: @@ -64,6 +64,12 @@ Empty_VRAM: ; (Clear screen) LD A, $obj_palette_frozen LD $reg_obj1_palette, A + ; Interrupt jmp instruction + LD A, $c3 ; Unconditional imm16 jump + LD ($mem_vblank_jump_instruction), A + LD ($mem_stat_jump_instruction), A + + Initialize_Window_GUI: LD A, $48 LD $reg_window_y, A @@ -79,6 +79,10 @@ .END .MACRODEF ENABLE_LYC_INTERRUPT + LD A, low(=STAT_Entrypoint) + LD ($mem_stat_jump_destination), A + LD A, high(=STAT_Entrypoint) + LD ($mem_stat_jump_destination+1), A .RESET_STAT_INTERRUPT LD A, $02 LD $reg_interrupt_enable, A @@ -102,212 +106,8 @@ Entrypoint: LD $mem_floor_count, A CALL =Init_DemoQuest_Event -New_Dungeon: - LD SP, $fffe - LD HL, $mem_loaded_enemies_indices - LD A, $02 - LD (HL+), A - LD (HL+), A - LD A, $00 - LD (HL+), A - LD A, $03 - LD (HL+), A - LD A, $06 - LD $mem_loaded_special_entity_index, A - LD HL, $mem_bunny_attacks - LD A, $00 - LD (HL+), A - INC A - LD (HL+), A - INC A - LD (HL+), A - INC A - LD (HL+), A - CALL =Reload_EP_Cost - CALL =Dungeon_Generation - CALL =Initialize_Entities - CALL =Initialize_Objects - - ; Reset animations - LD HL, $mem_animation_list - LD BC, $1f - CALL =bzero - - LD A, $00 - LD $mem_display_flag, A - LD $mem_moving_animation_step, A - LD $mem_animation_wait_frames, A - LD $mem_blinking_animation_counter, A - - LD A, $mem_bunny_x - LD $mem_bunny_predicted_x, A - LD A, $mem_bunny_y - LD $mem_bunny_predicted_y, A - - LD A, $mem_map_loading_flags - RES 3, A - LD $mem_map_loading_flags, A - - ; Clear OAM - LD HL, $fe00 - LD BC, $00a0 - CALL =bzero - - LD A, $enum_dungeon_mode - LD $mem_current_mode, A - LD $mem_requested_mode, A - - ; Heart - LD A, $f0 - LD ($9d62), A - - ; Energy points - LD A, $f1 - LD ($9d66), A - - ; Floor - LD A, $f4 - LD ($9d73), A - - CALL =Generation_Event_Execution - - CALL =Reload_Entities_Tile_Data - CALL =Reset_Entities_Collision_Map - - CALL =Load_Tile - CALL =Load_Map - CALL =Load_Objects - - .SET_WINDOW_LCDC_E - .ENABLE_TOP_BAR - .ENABLE_VBLANK_INTERRUPTS - EI - Wait_for_Interrupt.loop: - HALT - EI - JP =Wait_for_Interrupt.loop - -VBLANK_Entrypoint: - .SET_WINDOW_LCDC_E - .ENABLE_TOP_BAR - - LD A, $palette_bold_font - LD $reg_bg_palette, A - - LD HL, $9d71 - LD A, $mem_floor_count - CALL =Print_8bit - - CALL $OAM_DMA_Transfer_routine - CALL =Loading_Mode_VBlank - - LD A, $mem_current_mode - BIT 7, A - JR NZ, =Skip_VBlank_Dungeon_Update - LD HL, $9d60 - LD A, $mem_bunny_health - CALL =Print_8bit - - LD HL, $9d64 - LD A, $mem_bunny_mana - CALL =Print_8bit - - CALL =Display_Prepared_Blocks - CALL =Display_Object - Skip_VBlank_Dungeon_Update: - - CALL =Dialogue_Arrow_Animation - CALL =Copy_Dialogue_Buffer - CALL =Display_dialogue_cursor - - ; LYC - LD A, $0a - LD $reg_lyc, A - .ENABLE_LYC_INTERRUPT - .RESET_STAT_INTERRUPT - EI - - CALL =Pad_Button_Check - CALL =Load_Additional_Block - - LD A, $mem_current_mode - CP $enum_dungeon_mode - JR NZ, =Skip_Dungeon_Update - - CALL =Entities_Actions - CALL =Object_Interactions_Check - CALL =Respawn_Entities - CALL =Prepare_Scrolling_Map - - Skip_Dungeon_Update: - LD A, $mem_current_mode - - CALL =Loading_Mode_Regular - CALL =Animation_Wait_Mode - CALL =Update_Animation_Steps - CALL =Open_dialogue_on_dungeon_menu_mode - CALL =Check_Open_Menu_button - CALL =Move_dialogue_cursor - CALL =Check_dialogue_action - - LD A, $00 - LD $mem_oam_buffer_low, A - CALL =Display_Animation_List - CALL =Display_Entities - - LD A, $mem_loop_frame_timer - INC A - LD $mem_loop_frame_timer, A - - .ENABLE_VBLANK_INTERRUPTS - RETI - -STAT_Entrypoint: - PUSH AF - PUSH DE - .SET_WINDOW_LCDC_E - - LD A, $reg_lyc - CP $0a - JR Z, =.End_Top_Bar - CP $67 - JR Z, =.Start_dialogue - .Thin_font: - LD A, $palette_thin_font - LD $reg_bg_palette, A - JR =.skip_dialogue - - .Start_dialogue: - LD A, $mem_display_flag - BIT 0, A - JR Z, =.skip_dialogue - .ENABLE_DIALOGUE - LD A, $mem_display_flag - BIT 1, A - JR Z, =.Thin_font - LD A, $palette_bold_font - LD $reg_bg_palette, A - LD A, $77 - LD $reg_lyc, A - .RESET_STAT_INTERRUPT - POP DE - POP AF - RETI - - .skip_dialogue: - .DISABLE_LYC_INTERRUPT - POP DE - POP AF - RETI - - .End_Top_Bar: - .DISABLE_DIALOGUE - LD A, $67 - LD $reg_lyc, A - .RESET_STAT_INTERRUPT - POP DE - POP AF - RETI + JP =New_Dungeon + .INCLUDE "tiles.gbasm" .INCLUDE "rng.gbasm" @@ -318,6 +118,7 @@ STAT_Entrypoint: .INCLUDE "map/objects.gbasm" .INCLUDE "map/generationevents.gbasm" .INCLUDE "gui.gbasm" +.INCLUDE "modes/vblank_handler_list.gbasm" .INCLUDE "dialogues/utils.gbasm" .INCLUDE "entity/utils.gbasm" .INCLUDE "entity/init.gbasm" diff --git a/modes/dialoguemenu.gbasm b/modes/dialoguemenu.gbasm new file mode 100644 index 0000000..5138c40 --- /dev/null +++ b/modes/dialoguemenu.gbasm @@ -0,0 +1,39 @@ +Dialogue_VBLANK_Entrypoint: + .SET_WINDOW_LCDC_E + .ENABLE_TOP_BAR + + LD A, $palette_bold_font + LD $reg_bg_palette, A + + CALL $OAM_DMA_Transfer_routine + + CALL =Dialogue_Arrow_Animation + CALL =Copy_Dialogue_Buffer + CALL =Display_dialogue_cursor + + ; LYC + LD A, $0a + LD $reg_lyc, A + .ENABLE_LYC_INTERRUPT + .RESET_STAT_INTERRUPT + EI + + CALL =Pad_Button_Check + + CALL =Update_Blinking_Counter + CALL =Update_Animation_Steps + CALL =Open_dialogue_on_dungeon_menu_mode + CALL =Move_dialogue_cursor + CALL =Check_dialogue_action + + LD A, $00 + LD $mem_oam_buffer_low, A + CALL =Display_Animation_List + CALL =Display_Entities + + LD A, $mem_loop_frame_timer + INC A + LD $mem_loop_frame_timer, A + + .ENABLE_VBLANK_INTERRUPTS + RETI diff --git a/modes/dungeon.gbasm b/modes/dungeon.gbasm new file mode 100644 index 0000000..41fc11d --- /dev/null +++ b/modes/dungeon.gbasm @@ -0,0 +1,172 @@ +Update_Blinking_Counter: + LD A, $mem_blinking_animation_counter + DEC A + CP $ff + RET Z + LD $mem_blinking_animation_counter, A + RET + +Update_Animation_Steps: + LD A, $mem_map_loading_flags + BIT 3, A + JR Z, =.update_mode + + LD A, $mem_moving_animation_step + INC A + AND $0f + LD $mem_moving_animation_step, A + + CP $00 + JR NZ, =.end + + LD A, $mem_map_loading_flags + RES 3, A + SET 1, A + LD $mem_map_loading_flags, A + + .update_mode: + + ; We need to make sure that the mode doesn't change to a mode with objects update while a dialogue box refresh is currently being done + LD A, $mem_current_mode + BIT 7, A + JR Z, =.set_current_mode + LD A, $mem_display_flag + AND 0b00010100 + CP $00 + JR NZ, =.end + + .set_current_mode: + LD A, $mem_requested_mode + LD $mem_current_mode, A + CALL =Update_VBlank_Handler + + .end: + LD A, $mem_bunny_health + CP $00 + RET NZ + LD A, $mem_moving_animation_step + CP $00 + RET NZ + + .Dead_mode: + + LD A, $20 + LD $mem_bunny_direction, A + + LD A, $enum_dead_mode + LD $mem_current_mode, A + CALL =Update_VBlank_Handler + + .CLOSE_DIALOGUE + + RET + +STAT_Entrypoint: + PUSH AF + PUSH DE + .SET_WINDOW_LCDC_E + + LD A, $reg_lyc + CP $0a + JR Z, =.End_Top_Bar + CP $67 + JR Z, =.Start_dialogue + .Thin_font: + LD A, $palette_thin_font + LD $reg_bg_palette, A + JR =.skip_dialogue + + .Start_dialogue: + LD A, $mem_display_flag + BIT 0, A + JR Z, =.skip_dialogue + .ENABLE_DIALOGUE + LD A, $mem_display_flag + BIT 1, A + JR Z, =.Thin_font + LD A, $palette_bold_font + LD $reg_bg_palette, A + LD A, $77 + LD $reg_lyc, A + .RESET_STAT_INTERRUPT + POP DE + POP AF + RETI + + .skip_dialogue: + .DISABLE_LYC_INTERRUPT + POP DE + POP AF + RETI + + .End_Top_Bar: + .DISABLE_DIALOGUE + LD A, $67 + LD $reg_lyc, A + .RESET_STAT_INTERRUPT + POP DE + POP AF + RETI + +Dungeon_VBLANK_Entrypoint: + .SET_WINDOW_LCDC_E + .ENABLE_TOP_BAR + + LD A, $palette_bold_font + LD $reg_bg_palette, A + + CALL $OAM_DMA_Transfer_routine + + LD A, $mem_current_mode + BIT 7, A + JR NZ, =Skip_VBlank_Dungeon_Update + LD HL, $9d60 + LD A, $mem_bunny_health + CALL =Print_8bit + + LD HL, $9d64 + LD A, $mem_bunny_mana + CALL =Print_8bit + + CALL =Display_Prepared_Blocks + CALL =Display_Object + Skip_VBlank_Dungeon_Update: + + ; LYC + LD A, $0a + LD $reg_lyc, A + .ENABLE_LYC_INTERRUPT + .RESET_STAT_INTERRUPT + EI + + CALL =Pad_Button_Check + CALL =Load_Additional_Block + + LD A, $mem_current_mode + CP $enum_dungeon_mode + JR NZ, =Skip_Dungeon_Update + + CALL =Entities_Actions + CALL =Object_Interactions_Check + CALL =Respawn_Entities + CALL =Prepare_Scrolling_Map + + Skip_Dungeon_Update: + LD A, $mem_current_mode + + CALL =Animation_Wait_Mode + CALL =Update_Blinking_Counter + CALL =Update_Animation_Steps + CALL =Check_Open_Menu_button + + LD A, $00 + LD $mem_oam_buffer_low, A + CALL =Display_Animation_List + CALL =Display_Entities + + LD A, $mem_loop_frame_timer + INC A + LD $mem_loop_frame_timer, A + + .ENABLE_VBLANK_INTERRUPTS + RETI diff --git a/modes/dungeongeneration.gbasm b/modes/dungeongeneration.gbasm new file mode 100644 index 0000000..9576e6d --- /dev/null +++ b/modes/dungeongeneration.gbasm @@ -0,0 +1,93 @@ +; VBlank: Write loading text, then wait for generation, then loading vram stuff +; When VBlank interrupts -> context switch +; When stat out of vblank interrupt -> context switch back to generation + +New_Dungeon: + LD SP, $fffe + LD HL, $mem_loaded_enemies_indices + LD A, $02 + LD (HL+), A + LD (HL+), A + LD A, $00 + LD (HL+), A + LD A, $03 + LD (HL+), A + LD A, $06 + LD $mem_loaded_special_entity_index, A + LD HL, $mem_bunny_attacks + LD A, $00 + LD (HL+), A + INC A + LD (HL+), A + INC A + LD (HL+), A + INC A + LD (HL+), A + CALL =Reload_EP_Cost + CALL =Dungeon_Generation + CALL =Initialize_Entities + CALL =Initialize_Objects + + ; Reset animations + LD HL, $mem_animation_list + LD BC, $1f + CALL =bzero + + LD A, $00 + LD $mem_display_flag, A + LD $mem_moving_animation_step, A + LD $mem_animation_wait_frames, A + LD $mem_blinking_animation_counter, A + + LD A, $mem_bunny_x + LD $mem_bunny_predicted_x, A + LD A, $mem_bunny_y + LD $mem_bunny_predicted_y, A + + LD A, $mem_map_loading_flags + RES 3, A + LD $mem_map_loading_flags, A + + LD A, $enum_dungeon_mode + LD $mem_current_mode, A + LD $mem_requested_mode, A + CALL =Update_VBlank_Handler + + ; Heart + LD A, $f0 + LD ($9d62), A + + ; Energy points + LD A, $f1 + LD ($9d66), A + + ; Floor + LD A, $f4 + LD ($9d73), A + + CALL =Generation_Event_Execution + + CALL =Reload_Entities_Tile_Data + CALL =Reset_Entities_Collision_Map + + ; Clear OAM + LD HL, $fe00 + LD BC, $00a0 + CALL =bzero + + CALL =Load_Tile + CALL =Load_Map + CALL =Load_Objects + + LD HL, $9d71 + LD A, $mem_floor_count + CALL =Print_8bit + + .SET_WINDOW_LCDC_E + .ENABLE_TOP_BAR + .ENABLE_VBLANK_INTERRUPTS + EI + Wait_for_Interrupt.loop: + HALT + EI + JP =Wait_for_Interrupt.loop diff --git a/modes/loading.gbasm b/modes/loading.gbasm new file mode 100644 index 0000000..dea6e89 --- /dev/null +++ b/modes/loading.gbasm @@ -0,0 +1,36 @@ +Loading_VBLANK_Entrypoint: + .SET_WINDOW_LCDC_E + .ENABLE_TOP_BAR + + LD A, $palette_bold_font + LD $reg_bg_palette, A + + CALL $OAM_DMA_Transfer_routine + CALL =Loading_Mode_VBlank + + ; LYC + LD A, $0a + LD $reg_lyc, A + .ENABLE_LYC_INTERRUPT + .RESET_STAT_INTERRUPT + EI + + CALL =Pad_Button_Check + CALL =Load_Additional_Block + + CALL =Animation_Wait_Mode + CALL =Update_Blinking_Counter + CALL =Update_Animation_Steps + CALL =Loading_Mode_Regular + + LD A, $00 + LD $mem_oam_buffer_low, A + CALL =Display_Animation_List + CALL =Display_Entities + + LD A, $mem_loop_frame_timer + INC A + LD $mem_loop_frame_timer, A + + .ENABLE_VBLANK_INTERRUPTS + RETI diff --git a/modes/vblank_handler_list.gbasm b/modes/vblank_handler_list.gbasm new file mode 100644 index 0000000..61f0836 --- /dev/null +++ b/modes/vblank_handler_list.gbasm @@ -0,0 +1,32 @@ +Update_VBlank_Handler: + PUSH HL + LD A, $mem_current_mode + AND $0f + SLA A + LD HL, =VBlank_Handler_List + ADD L + LD L, A + LD A, $00 + ADC H + LD H, A + LD A, (HL+) + LD ($mem_vblank_jump_destination+1), A + LD A, (HL) + LD ($mem_vblank_jump_destination), A + POP HL + RET + +VBlank_Handler_List: + ; 0 (dungeon, dead) + .DB =Dungeon_VBLANK_Entrypoint + + ; 1 (dungeon dialogue, menu) + .DB =Dialogue_VBLANK_Entrypoint + + ; 2 (loading, animation) + .DB =Loading_VBLANK_Entrypoint + +.INCLUDE "modes/dialoguemenu.gbasm" +.INCLUDE "modes/dungeon.gbasm" +.INCLUDE "modes/loading.gbasm" +.INCLUDE "modes/dungeongeneration.gbasm" diff --git a/playerattacks/earcoptr.gbasm b/playerattacks/earcoptr.gbasm index d17d88b..ef6a4b5 100644 --- a/playerattacks/earcoptr.gbasm +++ b/playerattacks/earcoptr.gbasm @@ -9,6 +9,7 @@ Earcoptr_Attack_Loading_VBlank: LD A, $enum_dungeon_mode LD $mem_current_mode, A LD $mem_requested_mode, A + CALL =Update_VBlank_Handler LD A, $mem_map_loading_flags SET 3, A LD $mem_map_loading_flags, A diff --git a/playerattacks/freeze.gbasm b/playerattacks/freeze.gbasm index e7aefa7..80e3ca1 100644 --- a/playerattacks/freeze.gbasm +++ b/playerattacks/freeze.gbasm @@ -37,6 +37,8 @@ Freeze_Attack_Loading_VBlank: LD A, $enum_dungeon_mode LD $mem_current_mode, A LD $mem_requested_mode, A + CALL =Update_VBlank_Handler + LD A, $mem_map_loading_flags SET 3, A LD $mem_map_loading_flags, A diff --git a/playerattacks/heal.gbasm b/playerattacks/heal.gbasm index 72f83fe..2cc7b10 100644 --- a/playerattacks/heal.gbasm +++ b/playerattacks/heal.gbasm @@ -24,6 +24,7 @@ Heal_Attack: LD A, $enum_dungeon_mode LD $mem_requested_mode, A LD $mem_current_mode, A + CALL =Update_VBlank_Handler .CLOSE_DIALOGUE diff --git a/playerattacks/hop.gbasm b/playerattacks/hop.gbasm index 8aa445b..ac89acd 100644 --- a/playerattacks/hop.gbasm +++ b/playerattacks/hop.gbasm @@ -87,12 +87,19 @@ Hop_Attack_Loading_VBlank: INC A AND $0f LD $mem_loading_step, A + RET + + +Hop_Attack_Loading_Regular: + LD A, $mem_loading_step CP $00 - RET NZ + JR NZ, =.preload_tiles LD A, $enum_dungeon_mode LD $mem_current_mode, A LD $mem_requested_mode, A + CALL =Update_VBlank_Handler + CALL =Fix_Bunny_screen LD A, $mem_bunny_direction OR $38 LD $mem_bunny_direction, A @@ -104,7 +111,11 @@ Hop_Attack_Loading_VBlank: LD $mem_bunny_flags, A RET -Hop_Attack_Loading_Regular: + + .preload_tiles: + LD A, $mem_current_mode + CP $enum_loading_mode + RET NZ CALL =Preload_Map_Hop LD A, $mem_prepared_block_tile diff --git a/scripts/parse_sprite_png.py b/scripts/parse_sprite_png.py index 5f9df9c..730b487 100644 --- a/scripts/parse_sprite_png.py +++ b/scripts/parse_sprite_png.py @@ -4,6 +4,8 @@ import sys sprite_8x16 = "--8x16" in sys.argv +sprite_8x8 = "--8x8" in sys.argv + sprite_1bpp = "--1bpp" in sys.argv file = Image.open(sys.argv[1]).convert("RGB") @@ -25,6 +27,10 @@ def getpx(sprite_nb, x, y): sprite_line = sprite_double_line * 2 + sprite_tile_y sprite_column = sprite_double_column * 2 + sprite_tile_x + if sprite_8x8: + sprite_line = int(sprite_nb / (file.width / 8)) + sprite_column = int(sprite_nb % (file.width / 8)) + if file.width < 16: sprite_line = sprite_column * 2 + sprite_line sprite_column = 0 |