From cce14a83a5ef7b8bd3e8affa1cf5d52b00329b0a Mon Sep 17 00:00:00 2001 From: Astatin Date: Fri, 14 Feb 2025 17:16:05 +0900 Subject: Fix laser animation + make EP work + add leaf to restore EP --- animations/laser.gbasm | 32 +++++++++++++++------- definitions.gbasm | 2 +- gui.gbasm | 13 +++++++-- main.gbasm | 6 ++-- map/objects.gbasm | 38 +++++++++++++++++++++++-- scripts/generate-tiledata.py | 7 +++-- sprites/bg/leaf.png | Bin 0 -> 260 bytes tiles.gbasm | 7 ++++- tileset.gbasm | 18 ++++++++---- tree-tileset | 64 +++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 160 insertions(+), 27 deletions(-) create mode 100644 sprites/bg/leaf.png create mode 100644 tree-tileset diff --git a/animations/laser.gbasm b/animations/laser.gbasm index 5c70eaf..e466652 100644 --- a/animations/laser.gbasm +++ b/animations/laser.gbasm @@ -1,6 +1,12 @@ +Set_E_Skip_display: + LD E, $01 +RET + Laser_Animation: INC HL + LD E, $00 + LD A, (HL+) ADD $80 LD D, A @@ -8,10 +14,10 @@ Laser_Animation: LD B, A SUB $82 CP D - RET NC + CALL NC, =Set_E_Skip_display ADD $0e CP D - RET C + CALL C, =Set_E_Skip_display LD A, D SUB $80 SUB B @@ -26,10 +32,10 @@ Laser_Animation: LD C, A SUB $82 CP D - RET NC + CALL NC, =Set_E_Skip_display ADD $0d CP D - RET C + CALL C, =Set_E_Skip_display LD A, D SUB $80 SUB C @@ -38,12 +44,14 @@ Laser_Animation: ADD $06 LD C, A - LD E, (HL) - DEC E - DEC E - CP E + LD A, E + LD $tmp_var_1, A + + LD A, (HL) + SUB $02 JP C, =.End_animation - LD (HL), E + LD E, A + LD (HL), A DEC HL DEC HL @@ -86,12 +94,16 @@ Laser_Animation: .Skip_move_animation_tile: + LD A, $tmp_var_1 + CP $01 + RET Z + LD A, $0f AND E CPL INC A ADD $0f - + .ADD_A_TO_DIRECTION_BC .ADD_MOVING_ANIMATION_OFFSET diff --git a/definitions.gbasm b/definitions.gbasm index 054ea4e..9cec50c 100644 --- a/definitions.gbasm +++ b/definitions.gbasm @@ -53,7 +53,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 should update their positions) +; bit 1: has a movement ended (objects interaction should be checked, entities sh0uld update their positions) ; bit 2: if the prepared block should be updated at the next frame ; bit 3: animation step is going up (?) diff --git a/gui.gbasm b/gui.gbasm index 2e8e8f6..14fbd07 100644 --- a/gui.gbasm +++ b/gui.gbasm @@ -117,9 +117,9 @@ Display_dialogue_cursor: LD B, A LD A, $mem_bunny_mana CP B - LD H, $69 + LD H, $f2 JR NC, =.Skip_Disable_cursor_setting - LD H, $6b + LD H, $f3 .Skip_Disable_cursor_setting: LD A, $mem_menu_cursor_position @@ -237,6 +237,15 @@ Check_dialogue_action: CP $enum_dungeon_menu_mode RET NZ + LD A, $mem_current_focused_attack_ep_cost + LD B, A + LD A, $mem_bunny_mana + CP B + RET C + SUB B + DAA + LD $mem_bunny_mana, A + LD HL, $dialogue_menu_choice1_routine LD A, $mem_menu_cursor_position diff --git a/main.gbasm b/main.gbasm index c3edbcf..7087691 100644 --- a/main.gbasm +++ b/main.gbasm @@ -93,7 +93,7 @@ Entrypoint: CALL =Initialize_RNG LD A, $20 LD $mem_bunny_health, A - LD A, $3 + LD A, $30 LD $mem_bunny_mana, A New_Dungeon: LD SP, $fffe @@ -131,11 +131,11 @@ New_Dungeon: LD $mem_requested_mode, A ; Heart - LD A, $68 + LD A, $f0 LD ($9d62), A ; Energy points - LD A, $6a + LD A, $f1 LD ($9d66), A .SET_WINDOW_LCDC_E diff --git a/map/objects.gbasm b/map/objects.gbasm index 9f0af1f..db49487 100644 --- a/map/objects.gbasm +++ b/map/objects.gbasm @@ -8,6 +8,7 @@ Initialize_Objects: LD HL, $mem_object_list CALL =Spawn_stairs CALL =Spawn_carrot + CALL =Spawn_leaf RET Spawn_object_in_random_room: ; Object tile in A, Object jump table id in E @@ -108,6 +109,11 @@ Spawn_carrot: LD E, $02 JP =Spawn_object_in_random_room +Spawn_leaf: + LD A, $68 + LD E, $03 + JP =Spawn_object_in_random_room + Object_Interaction_Jump_table: ; 00 RET @@ -116,14 +122,17 @@ Object_Interaction_Jump_table: NOP ; 01 - JP =Stairs_action + JP =Stairs_Action NOP ; 02 JP =Heal_Action NOP -Stairs_action: + ; 03 + JP =Restore_EP_Action + +Stairs_Action: DI LD A, $00 LD $reg_interrupt_flags, A @@ -164,6 +173,29 @@ Heal_Action: RET +Restore_EP_Action: + LD A, $mem_bunny_mana + ADD $15 + DAA + JR NC, =.Set_mana + LD A, $99 + .Set_mana: + LD $mem_bunny_mana, A + + PUSH BC + LD A, $mem_bunny_x + LD B, A + LD A, $mem_bunny_y + LD C, A + LD A, $01 + LD E, $20 + CALL =Try_Launch_Animation + POP BC + + ; LD (HL), $00 + + RET + Display_Object: LD HL, $mem_object_list LD A, $mem_object_load_counter @@ -273,6 +305,8 @@ Object_Interactions_Check: LD A, $mem_map_loading_flags BIT 1, A JR Z, =.End + RES 1, A + LD $mem_map_loading_flags, A LD HL, $mem_object_list LD A, $mem_bunny_x LD C, A diff --git a/scripts/generate-tiledata.py b/scripts/generate-tiledata.py index a743261..f49db34 100644 --- a/scripts/generate-tiledata.py +++ b/scripts/generate-tiledata.py @@ -22,14 +22,17 @@ print("\n\t; Stairs") get_sprite_png_parse_output("./sprites/bg/stairs.png") print("\n\t; Carrot") get_sprite_png_parse_output("./sprites/bg/carrot.png") +print("\n\t; Leaf") +get_sprite_png_parse_output("./sprites/bg/leaf.png") +sprite_idx = 0xf0 print("Small_sprites:") print("\n\t; Heart") get_sprite_png_parse_output("./sprites/gui/heart.png") -print("\n\t; Cursor") -get_sprite_png_parse_output("./sprites/gui/cursor.png") print("\n\t; Energy") get_sprite_png_parse_output("./sprites/gui/energy-points.png") +print("\n\t; Cursor") +get_sprite_png_parse_output("./sprites/gui/cursor.png") print("\n\t; Disabled Cursor") get_sprite_png_parse_output("./sprites/gui/disabled-cursor.png") diff --git a/sprites/bg/leaf.png b/sprites/bg/leaf.png new file mode 100644 index 0000000..0067e90 Binary files /dev/null and b/sprites/bg/leaf.png differ diff --git a/tiles.gbasm b/tiles.gbasm index 0ef0425..65655c2 100644 --- a/tiles.gbasm +++ b/tiles.gbasm @@ -19,6 +19,11 @@ Load_Tile: LD BC, $04c0 CALL =memcpy + LD HL, $8f00 + LD DE, =Small_sprites + LD BC, $0040 + CALL =memcpy + LD HL, $8600 LD DE, =Animation_Sprites_Data LD BC, $0060 @@ -87,5 +92,5 @@ Dialogue_Box_Tilemap_data: Cost_Window_Tilemap_data: .DB 0x11, 0x17, 0x17, 0x17, 0x17, 0x17, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 .DB 0x15, 0xab, 0xac, 0xad, 0xae, 0xaf, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .DB 0x15, 0x00, 0x00, 0x00, 0x00, 0x6a, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .DB 0x15, 0x00, 0x00, 0x00, 0x00, 0xf1, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 .DB 0x12, 0x18, 0x18, 0x18, 0x18, 0x18, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/tileset.gbasm b/tileset.gbasm index 7c950a4..cb07c51 100644 --- a/tileset.gbasm +++ b/tileset.gbasm @@ -87,19 +87,25 @@ BG_Tile_Image_Data: .DB $00, $00, $30, $30, $58, $68, $74, $5c, $7e, $6a, $fc, $d4, $58, $78, $20, $20 ; 0x65 .DB $10, $10, $10, $10, $21, $20, $23, $20, $47, $43, $4c, $4c, $70, $70, $00, $00 ; 0x66 .DB $30, $10, $70, $10, $e0, $20, $c0, $c0, $00, $00, $00, $00, $00, $00, $00, $00 ; 0x67 + + ; Leaf + .DB $00, $00, $01, $01, $06, $06, $0a, $09, $15, $12, $2b, $24, $57, $48, $57, $48 ; 0x68 + .DB $00, $00, $fe, $fe, $82, $7e, $7c, $84, $e8, $18, $f0, $10, $d0, $30, $d0, $30 ; 0x69 + .DB $6f, $50, $6f, $50, $1e, $21, $58, $4f, $97, $b7, $a0, $e0, $a0, $e0, $40, $40 ; 0x6a + .DB $a0, $60, $a0, $60, $20, $e0, $40, $c0, $80, $80, $00, $00, $00, $00, $00, $00 ; 0x6b Small_sprites: ; Heart - .DB $00, $00, $6c, $6c, $fe, $92, $fe, $82, $7c, $44, $38, $28, $10, $10, $00, $00 ; 0x68 - - ; Cursor - .DB $00, $00, $60, $60, $78, $78, $7e, $7e, $7e, $7e, $78, $78, $60, $60, $00, $00 ; 0x69 + .DB $00, $00, $6c, $6c, $fe, $92, $fe, $82, $7c, $44, $38, $28, $10, $10, $00, $00 ; 0xf0 ; Energy - .DB $70, $70, $f8, $88, $fe, $be, $ff, $91, $ff, $b5, $ff, $81, $7e, $76, $08, $08 ; 0x6a + .DB $70, $70, $f8, $88, $fe, $be, $ff, $91, $ff, $b5, $ff, $81, $7e, $76, $08, $08 ; 0xf1 + + ; Cursor + .DB $00, $00, $60, $60, $78, $78, $7e, $7e, $7e, $7e, $78, $78, $60, $60, $00, $00 ; 0xf2 ; Disabled Cursor - .DB $00, $00, $22, $00, $36, $00, $1c, $00, $1c, $00, $36, $00, $22, $00, $00, $00 ; 0x6b + .DB $00, $00, $22, $00, $36, $00, $1c, $00, $1c, $00, $36, $00, $22, $00, $00, $00 ; 0xf3 Font_Data: .DB $00, $00, $38, $3c, $44, $46, $44, $46, $44, $46, $44, $46, $38, $3c, $00, $00 ; 0x80 diff --git a/tree-tileset b/tree-tileset new file mode 100644 index 0000000..f0b17b6 --- /dev/null +++ b/tree-tileset @@ -0,0 +1,64 @@ + .DB $07, $07, $1c, $1f, $38, $37, $3a, $27, $64, $6f, $41, $7f, $47, $78, $4d, $7d + .DB $f0, $f0, $b0, $d0, $38, $f8, $8c, $7c, $86, $fe, $be, $c6, $c2, $ee, $c2, $ee + .DB $70, $7f, $22, $3f, $6d, $73, $58, $6f, $6d, $5a, $6d, $7d, $3f, $3f, $00, $00 + .DB $16, $fe, $74, $dc, $34, $bc, $4e, $fe, $6a, $d6, $c6, $fe, $fc, $fc, $00, $00 + .DB $07, $07, $1c, $1f, $38, $37, $3a, $27, $e4, $ef, $c1, $ff, $c7, $b8, $cd, $3d + .DB $80, $80, $f0, $f0, $30, $d0, $b8, $78, $8c, $fc, $86, $fe, $be, $c6, $c2, $ee + .DB $70, $7f, $82, $ff, $2d, $d3, $58, $af, $6d, $1a, $fc, $bd, $ef, $ef, $00, $00 + .DB $16, $fe, $74, $dc, $34, $bc, $4e, $fe, $6a, $d6, $c6, $fe, $fc, $fc, $00, $00 + .DB $07, $07, $1c, $1f, $38, $37, $3a, $27, $64, $6f, $41, $7f, $47, $78, $4d, $7d + .DB $80, $80, $f0, $f0, $30, $d0, $b8, $78, $8e, $fe, $87, $ff, $bd, $c7, $c3, $ee + .DB $70, $7f, $22, $3f, $6d, $73, $58, $6f, $6d, $5a, $6d, $7d, $3f, $3f, $00, $00 + .DB $13, $ff, $76, $df, $35, $ba, $48, $fd, $69, $d7, $ef, $ef, $38, $38, $00, $00 + .DB $07, $07, $1c, $1f, $38, $37, $3a, $27, $64, $6f, $c1, $ff, $c7, $b8, $cd, $3d + .DB $80, $80, $f0, $f0, $30, $d0, $b8, $78, $8c, $fc, $87, $ff, $bd, $c7, $c3, $ee + .DB $70, $7f, $82, $ff, $2d, $d3, $58, $af, $6d, $1a, $fd, $bd, $e7, $e7, $00, $00 + .DB $13, $ff, $76, $df, $35, $ba, $48, $fd, $69, $d7, $e3, $ef, $3e, $3e, $00, $00 + .DB $3f, $27, $3c, $3f, $38, $37, $3a, $27, $64, $6f, $41, $7f, $47, $78, $4d, $7d + .DB $bf, $dd, $fb, $ff, $3f, $db, $be, $7e, $86, $fe, $82, $fe, $bf, $c3, $c1, $e7 + .DB $70, $7f, $22, $3f, $6d, $73, $58, $6f, $6d, $5a, $6d, $7d, $3f, $3f, $00, $00 + .DB $1b, $ff, $7a, $de, $3a, $be, $47, $ff, $65, $db, $e3, $ef, $3e, $3e, $00, $00 + .DB $ff, $a7, $5c, $ff, $38, $f7, $ba, $67, $e4, $ef, $c1, $ff, $c7, $b8, $cd, $3d + .DB $be, $da, $f6, $fe, $3e, $d6, $bc, $7c, $8c, $fc, $84, $fc, $be, $c6, $c2, $ee + .DB $70, $7f, $82, $ff, $2d, $d3, $58, $af, $6d, $1a, $fc, $bd, $ef, $ef, $00, $00 + .DB $16, $fe, $74, $dc, $34, $bc, $4e, $fe, $6a, $d6, $c6, $fe, $fc, $fc, $00, $00 + .DB $3f, $27, $3c, $3f, $38, $37, $3a, $27, $64, $6f, $41, $7f, $47, $78, $4d, $7d + .DB $bd, $da, $f7, $fd, $3a, $d7, $ba, $7d, $8e, $fe, $87, $ff, $bd, $c7, $c3, $ee + .DB $70, $7f, $22, $3f, $6d, $73, $58, $6f, $6d, $5a, $6d, $7d, $3f, $3f, $00, $00 + .DB $13, $ff, $76, $df, $35, $ba, $48, $fd, $69, $d7, $ef, $ef, $38, $38, $00, $00 + .DB $ff, $a7, $5c, $ff, $38, $f7, $ba, $67, $e4, $ef, $c1, $ff, $c7, $b8, $cd, $3d + .DB $bd, $da, $f7, $fd, $3a, $d7, $ba, $7d, $8e, $fe, $87, $ff, $bd, $c7, $c3, $ee + .DB $70, $7f, $82, $ff, $2d, $d3, $58, $af, $6d, $1a, $fd, $bd, $e7, $e7, $00, $00 + .DB $13, $ff, $76, $df, $35, $ba, $48, $fd, $69, $d7, $e3, $ef, $3e, $3e, $00, $00 + .DB $07, $07, $1c, $1f, $38, $37, $3a, $27, $64, $6f, $41, $7f, $47, $78, $6d, $7d + .DB $f0, $f0, $b0, $d0, $38, $f8, $8c, $7c, $86, $fe, $be, $c6, $c2, $ee, $92, $fe + .DB $30, $3f, $22, $3f, $6d, $73, $58, $6f, $6d, $7a, $2c, $3d, $22, $3f, $37, $23 + .DB $76, $de, $34, $bc, $4c, $fc, $6e, $d6, $42, $ee, $9e, $fa, $72, $a6, $be, $5a + .DB $07, $07, $1c, $1f, $38, $37, $3a, $27, $e4, $ef, $c1, $ff, $c7, $b8, $cd, $3d + .DB $80, $80, $f0, $f0, $30, $d0, $b8, $78, $8c, $fc, $86, $fe, $be, $c6, $c2, $ee + .DB $70, $7f, $82, $ff, $2d, $d3, $58, $af, $6d, $1a, $cc, $bd, $a2, $ff, $37, $e3 + .DB $12, $fe, $76, $de, $34, $bc, $4c, $fc, $6e, $d6, $c2, $ee, $1e, $fa, $f2, $26 + .DB $07, $07, $1c, $1f, $38, $37, $3a, $27, $64, $6f, $41, $7f, $47, $78, $6d, $7d + .DB $80, $80, $f0, $f0, $30, $d0, $b8, $78, $8e, $fe, $87, $ff, $bd, $c7, $c3, $ee + .DB $30, $3f, $22, $3f, $6d, $73, $58, $6f, $6d, $7a, $2c, $3d, $22, $3f, $37, $23 + .DB $13, $ff, $76, $df, $35, $ba, $48, $fd, $69, $d7, $c1, $ef, $1c, $fb, $f0, $27 + .DB $07, $07, $1c, $1f, $38, $37, $3a, $27, $64, $6f, $c1, $ff, $c7, $b8, $cd, $3d + .DB $80, $80, $f0, $f0, $30, $d0, $b8, $78, $8c, $fc, $87, $ff, $bd, $c7, $c3, $ee + .DB $70, $7f, $82, $ff, $2d, $d3, $58, $af, $6d, $1a, $cc, $bd, $a2, $ff, $37, $e2 + .DB $13, $ff, $76, $df, $35, $ba, $48, $fd, $69, $d7, $c1, $ef, $1c, $fb, $f0, $27 + .DB $3f, $27, $3c, $3f, $38, $37, $3a, $27, $64, $6f, $41, $7f, $47, $78, $6d, $7d + .DB $bf, $dd, $fb, $ff, $3f, $db, $be, $7e, $86, $fe, $82, $fe, $bf, $c3, $c3, $e7 + .DB $30, $3f, $22, $3f, $6d, $73, $58, $6f, $6d, $7a, $2c, $3d, $22, $3f, $37, $23 + .DB $76, $de, $34, $bc, $4c, $fc, $6e, $d6, $42, $ee, $9e, $fa, $72, $a6, $be, $5a + .DB $ff, $a7, $5c, $ff, $38, $f7, $ba, $67, $e4, $ef, $c1, $ff, $c7, $b8, $cd, $3d + .DB $be, $da, $f6, $fe, $3e, $d6, $bc, $7c, $8c, $fc, $84, $fc, $bc, $c4, $c6, $ee + .DB $70, $7f, $82, $ff, $2d, $d3, $58, $af, $6d, $1a, $cc, $bd, $a2, $ff, $37, $e3 + .DB $12, $fe, $76, $de, $34, $bc, $4c, $fc, $6e, $d6, $c2, $ee, $1e, $fa, $f2, $26 + .DB $3f, $27, $3c, $3f, $38, $37, $3a, $27, $64, $6f, $61, $7f, $47, $78, $4d, $7d + .DB $bd, $da, $f7, $fd, $3a, $d7, $ba, $7d, $8e, $fe, $87, $ff, $bd, $c7, $c3, $ee + .DB $70, $7f, $22, $3f, $6d, $73, $58, $6f, $4d, $7a, $4c, $7d, $42, $7f, $77, $63 + .DB $13, $ff, $76, $df, $35, $ba, $48, $fd, $69, $d7, $c1, $ef, $1c, $fb, $f0, $27 + .DB $ff, $a7, $5c, $ff, $38, $f7, $ba, $67, $e4, $ef, $c1, $ff, $c7, $b8, $cd, $3d + .DB $bd, $da, $f7, $fd, $3a, $d7, $ba, $7d, $8e, $fe, $87, $ff, $bd, $c7, $c3, $ee + .DB $70, $7f, $82, $ff, $2d, $d3, $58, $af, $6d, $1a, $cc, $bd, $a2, $ff, $37, $e3 + .DB $13, $ff, $76, $df, $35, $ba, $48, $fd, $69, $d7, $c1, $ef, $1c, $fb, $f0, $27 -- cgit v1.2.3-70-g09d2