aboutsummaryrefslogtreecommitdiff
path: root/modes
diff options
context:
space:
mode:
authorAstatin <[email protected]>2025-06-03 14:51:59 +0200
committerAstatin <[email protected]>2025-06-03 14:51:59 +0200
commiteca91612b60b5379f9e8d6ce6f51366db54aacc3 (patch)
treec5fad4dc000a5430958fa8b354f69b3ba6628fe6 /modes
parentf3a70613f78023c25d9a075231cb55639a75ee99 (diff)
Add loading from pregenerated collision map
Diffstat (limited to 'modes')
-rw-r--r--modes/dungeongeneration.gbasm4
-rw-r--r--modes/maploading.gbasm172
-rw-r--r--modes/vblank_handler_list.gbasm4
3 files changed, 178 insertions, 2 deletions
diff --git a/modes/dungeongeneration.gbasm b/modes/dungeongeneration.gbasm
index 8c62081..c459805 100644
--- a/modes/dungeongeneration.gbasm
+++ b/modes/dungeongeneration.gbasm
@@ -145,10 +145,10 @@ Dungeon_generation_VBlank:
.RESET_INTERRUPTS
EI
- Wait_for_Interrupt.loop:
+ .Wait_for_Interrupt.loop:
LD A, $reg_lcd_status
HALT
- JP =Wait_for_Interrupt.loop
+ JP =.Wait_for_Interrupt.loop
Dungeon_generation_Out_Of_VBlank:
PUSH AF
diff --git a/modes/maploading.gbasm b/modes/maploading.gbasm
new file mode 100644
index 0000000..d96bca0
--- /dev/null
+++ b/modes/maploading.gbasm
@@ -0,0 +1,172 @@
+; 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
+
+.MACRODEF ENABLE_MODE_2_INTERRUPT
+ LD A, low(=Map_Loading_Out_Of_VBlank)
+ LD ($mem_stat_jump_destination), A
+ LD A, high(=Map_Loading_Out_Of_VBlank)
+ LD ($mem_stat_jump_destination+1), A
+ .RESET_INTERRUPTS
+ LD A, $20
+ LD $reg_lcd_status, A
+ LD A, $02
+ LD $reg_interrupt_enable, A
+.END
+
+.MACRODEF DISABLE_MODE_2_INTERRUPT
+ LD A, $00
+ LD $reg_lcd_status, A
+ LD A, $00
+ LD $reg_interrupt_enable, A
+.END
+
+Map_Loading:
+ LD SP, $fffe
+
+ LD A, $00
+ LD $reg_viewport_x, A
+ LD A, $68
+ LD $reg_viewport_y, A
+
+ LD A, $00
+ LD $mem_display_flag, A
+
+ LD HL, =Dungeon
+ CALL =Load_Dungeon_Txt
+
+ LD A, $f4
+ LD ($9ecb), A
+
+ LD HL, $9ec9
+ LD A, $mem_floor_count
+ CALL =Print_8bit
+
+ LD A, $07
+ LD $reg_bg_palette, A
+
+ LD A, $lcdc_guibg_tilemap
+ LD $reg_lcd_controller, A
+
+ CALL =Reset_Map
+
+ LD HL, $mem_dungeon_map
+ LD BC, $0080
+ LD DE, =_map_Test
+ CALL =memcpy
+
+ LD HL, =Dungeon
+ CALL =Load_Dungeon_Spawn_patterns
+ LD A, $entity_questgoalbunny_index
+ LD $mem_loaded_special_entity_index, A
+
+ CALL =Reload_EP_Cost
+ LD B, $0f
+ LD C, $0f
+ CALL =Initialize_Bunny
+ CALL =Reset_viewport_thingies
+
+ LD A, $mem_map_loading_flags
+ OR $01
+ LD $mem_map_loading_flags, A
+
+ LD HL, $mem_object_list
+ LD BC, $0080
+ CALL =bff
+
+ ; Reset animations
+ LD HL, $mem_animation_list
+ LD BC, $1f
+ CALL =bzero
+
+ ; Clear OAM buffer
+ LD HL, $mem_oam_buffer
+ LD BC, $00a0
+ 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
+
+ LD A, $00
+ LD $mem_oam_buffer_low, A
+ CALL =Display_Entities
+
+ CALL =Generation_Event_Execution
+
+ CALL =Load_Prepared_Map
+
+ CALL =VBlank_Wait
+
+Map_Loading_VBlank:
+ .ENABLE_MODE_2_INTERRUPT
+ EI
+
+ ; Heart
+ LD A, $f0
+ LD ($9d62), A
+
+ ; Energy points
+ LD A, $f1
+ LD ($9d66), A
+
+ ; Floor
+ LD A, $f4
+ LD ($9d73), A
+
+ LD B, B
+ CALL =Reload_Entities_Tile_Data
+ LD B, B
+ ; Clear OAM
+ LD HL, $fe00
+ LD BC, $00a0
+ CALL =bzero
+
+ LD DE, $mem_map_loading_buffer
+ LD HL, $9800
+ LD BC, $0400
+ CALL =memcpy
+ CALL =Load_Objects
+
+ LD HL, $9d71
+ LD A, $mem_floor_count
+ CALL =Print_8bit
+
+ CALL =Update_VBlank_Handler
+
+ DI
+ .DISABLE_MODE_2_INTERRUPT
+
+ CALL =Reset_Entities_Collision_Map
+
+ .ENABLE_VBLANK_INTERRUPTS
+ .RESET_INTERRUPTS
+ EI
+
+ .Wait_for_Interrupt.loop:
+ LD A, $reg_lcd_status
+ HALT
+ JP =.Wait_for_Interrupt.loop
+
+Map_Loading_Out_Of_VBlank:
+ PUSH AF
+ CALL =VBlank_Wait
+ .ENABLE_MODE_2_INTERRUPT
+ .RESET_INTERRUPTS
+ POP AF
+ RETI
diff --git a/modes/vblank_handler_list.gbasm b/modes/vblank_handler_list.gbasm
index 768147f..99db063 100644
--- a/modes/vblank_handler_list.gbasm
+++ b/modes/vblank_handler_list.gbasm
@@ -29,7 +29,11 @@ VBlank_Handler_List:
; 3 (new dungeon)
.DB =New_Dungeon
+ ; 4 (pregenerated map loading)
+ .DB =Map_Loading
+
.INCLUDE "modes/dialoguemenu.gbasm"
.INCLUDE "modes/dungeon.gbasm"
.INCLUDE "modes/loading.gbasm"
.INCLUDE "modes/dungeongeneration.gbasm"
+.INCLUDE "modes/maploading.gbasm"