diff options
author | Astatin <[email protected]> | 2025-04-11 16:20:31 +0200 |
---|---|---|
committer | Astatin <[email protected]> | 2025-04-11 16:20:31 +0200 |
commit | a846ccc0cc20fe49b5ee07e252b370dc005b38cd (patch) | |
tree | 7996f4fdbca1e054bac3d87dd565178da9ba9191 | |
parent | 690ff7c09726d9e760b52b717c70e9567531175c (diff) |
Make hop the only default attack and make cats drop heal
-rw-r--r-- | definitions.gbasm | 6 | ||||
-rw-r--r-- | dialogues/dialogues.gbasm | 166 | ||||
-rw-r--r-- | dialogues/text.gbasm | 26 | ||||
-rw-r--r-- | dialogues/text.gbtxt | 20 | ||||
-rw-r--r-- | dialogues/utils.gbasm | 21 | ||||
-rw-r--r-- | entity/cat.gbasm | 36 | ||||
-rw-r--r-- | entity/list.gbasm | 2 | ||||
-rw-r--r-- | gui.gbasm | 13 | ||||
-rw-r--r-- | main.gbasm | 13 | ||||
-rw-r--r-- | map/objects.gbasm | 65 | ||||
-rw-r--r-- | modes/dungeongeneration.gbasm | 10 | ||||
-rw-r--r-- | playerattacks.gbasm | 16 | ||||
-rw-r--r-- | scripts/generate-tiledata.py | 2 | ||||
-rw-r--r-- | sprites/bg/box.png | bin | 0 -> 241 bytes | |||
-rw-r--r-- | tiles.gbasm | 2 | ||||
-rw-r--r-- | tileset.gbasm | 6 |
16 files changed, 377 insertions, 27 deletions
diff --git a/definitions.gbasm b/definitions.gbasm index 3bfa97b..0d6b882 100644 --- a/definitions.gbasm +++ b/definitions.gbasm @@ -140,6 +140,12 @@ .DEFINE mem_entity_spawning_pattern ($c046) +.DEFINE mem_number_of_attacks ($c047) +.DEFINE mem_cursor_max_position ($c048) + +.DEFINE mem_learn_attack_dialogue_ret_ptr $c049 ; Takes $c049 and $c04a +.DEFINE mem_learn_attack_attack_name_ptr $c04b ; Takes $c04b and $c04c + ; ## WARNING THE SPACE BETWEEN $c400 and $c800 is used as a buffer for the loading map function during dungeon generation .DEFINE mem_map_loading_buffer $c400 diff --git a/dialogues/dialogues.gbasm b/dialogues/dialogues.gbasm index 1fdcc80..1501a79 100644 --- a/dialogues/dialogues.gbasm +++ b/dialogues/dialogues.gbasm @@ -4,6 +4,7 @@ Dialogue_script_step: LD A, ($mem_dialogue_script_program_counter+1) LD L, A + .next: LD A, (HL+) LD BC, =Dialogue_script_instruction_Jump_Table @@ -26,10 +27,22 @@ Dialogue_script_instruction_Jump_Table: JP =.Text NOP - ;02 + ; 02 JP =.TextB NOP + ; 03 + JP =.Learn_Attack + NOP + + ; 04 + JP =.TextB_Indirect + NOP + + ; 05 + JP =.Learn_Attack_Return + NOP + .Text: PUSH HL LD HL, $dialogue_first_line @@ -67,6 +80,12 @@ Dialogue_script_instruction_Jump_Table: RET .TextB: + PUSH HL + LD HL, $dialogue_first_line + LD BC, $12 + CALL =bzero + POP HL + LD A, (HL+) LD B, A LD A, (HL+) @@ -76,6 +95,12 @@ Dialogue_script_instruction_Jump_Table: CALL =Print_str POP HL + PUSH HL + LD HL, $dialogue_third_line + LD BC, $12 + CALL =bzero + POP HL + LD A, (HL+) LD B, A LD A, (HL+) @@ -90,5 +115,144 @@ Dialogue_script_instruction_Jump_Table: RET + .TextB_Indirect: + PUSH HL + LD HL, $dialogue_first_line + LD BC, $12 + CALL =bzero + POP HL + + LD A, (HL+) + LD B, A + LD A, (HL+) + LD C, A + PUSH DE + LD A, (BC) + LD D, A + INC BC + LD A, (BC) + LD E, A + LD B, D + LD C, E + POP DE + PUSH HL + LD HL, $dialogue_first_line + DBG + CALL =Print_str + POP HL + + + PUSH HL + LD HL, $dialogue_third_line + LD BC, $12 + CALL =bzero + POP HL + + LD A, (HL+) + LD B, A + LD A, (HL+) + LD C, A + PUSH HL + LD HL, $dialogue_third_line + CALL =Print_str + POP HL + + LD A, $07 + LD $mem_display_flag, A + + RET + + .Learn_Attack: + LD A, (HL+) + LD E, A + + LD B, $00 + LD C, A + SLA C + RR B + SLA C + RR B + SLA C + RR B + LD A, C + ADD low(=Attack_List) + LD C, A + LD A, B + ADC high(=Attack_List) + LD B, A + + LD A, (BC) + LD ($mem_learn_attack_attack_name_ptr), A + INC BC + LD A, (BC) + LD ($mem_learn_attack_attack_name_ptr+1), A + + LD A, H + LD ($mem_learn_attack_dialogue_ret_ptr), A + LD A, L + LD ($mem_learn_attack_dialogue_ret_ptr+1), A + + LD A, E + LD HL, $mem_bunny_attacks + .Learn_Attack.Check_doubles.loop: + LD A, (HL) + CP E + JR Z, =.Learn_Attack.Duplicate + INC HL + LD A, L + CP low($mem_bunny_attacks+4) + JR NZ, =.Learn_Attack.Check_doubles.loop + + LD A, $mem_number_of_attacks + CP $04 + JR NC, =.Learn_Attack.Not_enough_slot + + .Learn_Attack.Success: + LD A, $mem_number_of_attacks + LD HL, $mem_bunny_attacks + ADD L + LD L, A + LD (HL), $02 + LD A, $mem_number_of_attacks + INC A + LD $mem_number_of_attacks, A + + LD HL, =.Learn_Attack.Dialogue + JP =Dialogue_script_step.next + .Learn_Attack.Dialogue: + .TEXT =New_attack_1t =New_attack_1b + .TEXTB_INDIRECT $mem_learn_attack_attack_name_ptr =Double_Exclamation + .LEARN_ATTACK_RET + + + .Learn_Attack.Not_enough_slot: + + LD HL, =.Learn_Attack.Not_enough_slot.Dialogue + JP =Dialogue_script_step.next + .Learn_Attack.Not_enough_slot.Dialogue: + .TEXT =No_attslot_1t =No_attslot_1b + .TEXTB_INDIRECT $mem_learn_attack_attack_name_ptr =Double_Exclamation + .TEXT =No_attslot_3t =No_attslot_3b + .TEXT =No_attslot_4t =Empty + .LEARN_ATTACK_RET + + .Learn_Attack.Duplicate: + LD HL, =.Learn_Attack.Duplicate.Dialogue + JP =Dialogue_script_step.next + .Learn_Attack.Duplicate.Dialogue: + .TEXT =dup_attack_1t =dup_attack_1b + .TEXTB_INDIRECT $mem_learn_attack_attack_name_ptr =Double_Exclamation + .TEXT =dup_attack_3t =dup_attack_3b + .TEXT =dup_attack_4t =Empty + .LEARN_ATTACK_RET + + .Learn_Attack_Return: + LD A, ($mem_learn_attack_dialogue_ret_ptr) + LD H, A + LD A, ($mem_learn_attack_dialogue_ret_ptr+1) + LD L, A + DBG + JP =Dialogue_script_step.next + .INCLUDE "dialogues/text.gbasm" .INCLUDE "dialogues/demo_quest.gbasm" diff --git a/dialogues/text.gbasm b/dialogues/text.gbasm index eaefa13..491d395 100644 --- a/dialogues/text.gbasm +++ b/dialogues/text.gbasm @@ -4,6 +4,32 @@ Bunny_Header_Text: .DB 0x8b, 0x9e, 0x97, 0x97, 0xa2, 0xaa, 0xff Unknown_Header_Text: .DB 0xa6, 0xa6, 0xa6, 0xaa, 0xff +Double_Exclamation: +.DB 0xa5, 0xa5, 0xff +New_attack_1t: +.DB 0xa2, 0x98, 0x9e, 0x0, 0x95, 0x8e, 0x8a, 0x9b, 0x97, 0x8e, 0x8d, 0x0, 0x9d, 0x91, 0x8e, 0xff +New_attack_1b: +.DB 0x8a, 0x9d, 0x9d, 0x8a, 0x8c, 0x94, 0xaa, 0xff +No_attslot_1t: +.DB 0xa2, 0x98, 0x9e, 0x0, 0x8f, 0x98, 0x9e, 0x97, 0x8d, 0x0, 0x9d, 0x91, 0x8e, 0xff +No_attslot_1b: +.DB 0x8a, 0x9d, 0x9d, 0x8a, 0x8c, 0x94, 0xaa, 0xff +No_attslot_3t: +.DB 0x8b, 0x9e, 0x9d, 0x0, 0xa2, 0x98, 0x9e, 0x0, 0x8a, 0x95, 0x9b, 0x8e, 0x8a, 0x8d, 0xa2, 0xff +No_attslot_3b: +.DB 0x94, 0x97, 0x98, 0xa0, 0x0, 0x9d, 0x98, 0x98, 0x0, 0x96, 0x8a, 0x97, 0xa2, 0xff +No_attslot_4t: +.DB 0x8a, 0x9d, 0x9d, 0x8a, 0x8c, 0x94, 0x9c, 0xa4, 0xa4, 0xa4, 0xff +dup_attack_1t: +.DB 0xa2, 0x98, 0x9e, 0x0, 0x8f, 0x98, 0x9e, 0x97, 0x8d, 0x0, 0x9d, 0x91, 0x8e, 0xff +dup_attack_1b: +.DB 0x8a, 0x9d, 0x9d, 0x8a, 0x8c, 0x94, 0xaa, 0xff +dup_attack_3t: +.DB 0x8b, 0x9e, 0x9d, 0x0, 0xa2, 0x98, 0x9e, 0x0, 0x8a, 0x95, 0x9b, 0x8e, 0x8a, 0x8d, 0xa2, 0xff +dup_attack_3b: +.DB 0x94, 0x97, 0x98, 0xa0, 0x0, 0x9d, 0x91, 0x92, 0x9c, 0xff +dup_attack_4t: +.DB 0x8a, 0x9d, 0x9d, 0x8a, 0x8c, 0x94, 0xa4, 0xa4, 0xa4, 0xff Dialogue_1_1b: .DB 0x91, 0x8e, 0x95, 0x95, 0x98, 0x0, 0xa5, 0xff Dialogue_1_2t: diff --git a/dialogues/text.gbtxt b/dialogues/text.gbtxt index ce9a261..246732c 100644 --- a/dialogues/text.gbtxt +++ b/dialogues/text.gbtxt @@ -2,6 +2,26 @@ Empty: Bunny_Header_Text: Bunny: Unknown_Header_Text: ???: +Double_Exclamation: !! + +New_attack_1t: You learned the +New_attack_1b: attack: + +No_attslot_1t: You found the +No_attslot_1b: attack: + +No_attslot_3t: But you already +No_attslot_3b: know too many + +No_attslot_4t: attacks... + +dup_attack_1t: You found the +dup_attack_1b: attack: + +dup_attack_3t: But you already +dup_attack_3b: know this + +dup_attack_4t: attack... Dialogue_1_1b: Hello ! diff --git a/dialogues/utils.gbasm b/dialogues/utils.gbasm index 38c9e51..51c0083 100644 --- a/dialogues/utils.gbasm +++ b/dialogues/utils.gbasm @@ -7,17 +7,32 @@ .END .MACRODEF END - .DB 00 + .DB $00 .END .MACRODEF TEXT first_line second_line - .DB 01 + .DB $01 .DB $first_line .DB $second_line .END .MACRODEF TEXTB first_line second_line - .DB 02 + .DB $02 .DB $first_line .DB $second_line .END + +.MACRODEF LEARN_ATTACK attack_idx + .DB $03 + .DB low($attack_idx) +.END + +.MACRODEF TEXTB_INDIRECT indirect_line second_line + .DB $04 + .DB $indirect_line + .DB $second_line +.END + +.MACRODEF LEARN_ATTACK_RET + .DB $05 +.END diff --git a/entity/cat.gbasm b/entity/cat.gbasm index 35d0b0c..1ddaac0 100644 --- a/entity/cat.gbasm +++ b/entity/cat.gbasm @@ -32,6 +32,42 @@ Cat_Turn: LD A, $mem_enemies_alive_count DEC A LD $mem_enemies_alive_count, A + + CALL =RNG_Step + AND $07 + CP $00 + JR NZ, =.skip_spawn_loot + PUSH HL + CALL =Find_Free_Object_slot + LD A, $80 + CP L + JR Z, =.skip_spawn_loot_pop_hl + + LD A, $6C + LD (HL+), A + LD A, B + LD (HL+), A + LD A, C + LD (HL+), A + CALL =Check_other_object_collision + CP $00 + JR NZ, =.skip_spawn_loot_pop_hl + LD A, L + AND $f8 + ADD $03 + LD L, A + LD (HL), $04 + LD A, L + SRA A + SRA A + SRA A + SUB $01 + LD $mem_object_load_counter, A + + .skip_spawn_loot_pop_hl: + POP HL + .skip_spawn_loot: + JP NZ, =.Skip_turn .Health_check.end: diff --git a/entity/list.gbasm b/entity/list.gbasm index 0e2ba86..762f43f 100644 --- a/entity/list.gbasm +++ b/entity/list.gbasm @@ -19,7 +19,7 @@ Entity_list: .DB $05 ; Spawning rate (2 lsb) - .DB 0b11 + .DB 0b10 .PADTO =.Fox+8 @@ -38,7 +38,7 @@ Copy_Dialogue_Buffer_Part2: LD C, $12 JP =tilemap_memcpy -Init_Menu: +Init_Attack_Menu: LD HL, $mem_bunny_attacks .MACRODEF SETUP_NEXT_ATTACK_MENU dialogue_buffer choice_routine ; Attack index pointer in (HL) @@ -97,6 +97,9 @@ Init_Menu: .SETUP_NEXT_ATTACK_MENU $dialogue_menu_choice2, $dialogue_menu_choice2_routine .SETUP_NEXT_ATTACK_MENU $dialogue_menu_choice3, $dialogue_menu_choice3_routine .SETUP_NEXT_ATTACK_MENU $dialogue_menu_choice4, $dialogue_menu_choice4_routine + + LD A, $mem_number_of_attacks + LD $mem_cursor_max_position, A RET Nothing: @@ -163,6 +166,8 @@ Move_dialogue_cursor: CP $enum_dungeon_menu_mode RET NZ + LD A, $mem_cursor_max_position + LD C, A LD A, $mem_last_button_direction LD B, A LD A, $mem_button_direction @@ -176,12 +181,16 @@ Move_dialogue_cursor: JR Z, =.Vertical_axis LD A, $mem_menu_cursor_position XOR $02 + CP C + JR NC, =Reload_EP_Cost LD $mem_menu_cursor_position, A JR =Reload_EP_Cost .Vertical_axis: LD A, $mem_menu_cursor_position XOR $01 + CP C + JR NC, =Reload_EP_Cost LD $mem_menu_cursor_position, A Reload_EP_Cost: @@ -307,7 +316,7 @@ Check_Open_Menu_button: BIT 3, A RET Z - CALL =Init_Menu + CALL =Init_Attack_Menu LD A, $enum_dungeon_menu_mode LD $mem_requested_mode, A @@ -104,6 +104,17 @@ Entrypoint: LD $mem_bunny_mana, A LD A, $01 LD $mem_floor_count, A + + LD HL, $mem_bunny_attacks + LD A, $01 + LD (HL+), A + XOR A + LD (HL+), A + LD (HL+), A + LD (HL+), A + LD A, $01 + LD $mem_number_of_attacks, A + CALL =Init_DemoQuest_Event CALL =Load_Tile @@ -113,6 +124,7 @@ Entrypoint: .INCLUDE "tiles.gbasm" .INCLUDE "rng.gbasm" .INCLUDE "utils.gbasm" +.INCLUDE "dialogues/utils.gbasm" .INCLUDE "buttons.gbasm" .INCLUDE "map/loading.gbasm" .INCLUDE "map/generation.gbasm" @@ -120,7 +132,6 @@ Entrypoint: .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" .INCLUDE "entity/bunny.gbasm" diff --git a/map/objects.gbasm b/map/objects.gbasm index ae2b60f..c20146f 100644 --- a/map/objects.gbasm +++ b/map/objects.gbasm @@ -11,6 +11,22 @@ Initialize_Objects: CALL =Spawn_leaf RET +Find_Free_Object_slot: ; Return free object slot in HL ($80 if none is found) + LD HL, $mem_object_list + + .loop: + LD A, $ff + CP (HL) + RET Z + + LD A, L + ADD $08 + LD L, A + CP $80 + JR NZ, =.loop + + RET + Spawn_object_in_random_room: ; Object tile in A, Object jump table id in E, Object pointer in HL LD (HL+), A @@ -55,6 +71,25 @@ Spawn_object_in_random_room: ; Object tile in A, Object jump table id in E, Obje CP $00 JR NZ, =.place_in_random_room + CALL =Check_other_object_collision + CP $00 + RET NZ + + INC HL + INC HL + + LD (HL), E + LD A, L + AND $f8 + ADD $08 + LD L, A + RET + +Check_other_object_collision: ; Object in HL (with only sprite x & y set), will be zeroed on collision and A will be 1 on return + LD A, L + AND $f8 + ADD $01 + LD L, A LD BC, $mem_object_list Object_check_collisions.loop: LD A, (BC) @@ -84,6 +119,7 @@ Spawn_object_in_random_room: ; Object tile in A, Object jump table id in E, Obje LD (HL), A DEC HL DEC HL + LD A, $01 RET Object_check_collisions.loop.next: @@ -97,15 +133,7 @@ Spawn_object_in_random_room: ; Object tile in A, Object jump table id in E, Obje LD C, A CP $80 JR NZ, =Object_check_collisions.loop - - INC HL - INC HL - - LD (HL), E - LD A, L - AND $f8 - ADD $08 - LD L, A + LD A, $00 RET Spawn_stairs: @@ -140,6 +168,11 @@ Object_Interaction_Jump_table: ; 03 JP =Restore_EP_Action + NOP + + ; 04 + JP =Heal_Attack_Box_Action + NOP Stairs_Action: LD A, $enum_dungeon_generation_mode @@ -184,6 +217,20 @@ Heal_Action: RET +Heal_Attack_Box_Action: + LD (HL), $00 + + .START_SCRIPT =.Script + + LD A, $enum_dungeon_dialogue_mode + LD $mem_requested_mode, A + + RET + + .Script: + .LEARN_ATTACK $02 + .END + Restore_EP_Action: LD A, $mem_bunny_mana ADD $15 diff --git a/modes/dungeongeneration.gbasm b/modes/dungeongeneration.gbasm index ace323b..9caa687 100644 --- a/modes/dungeongeneration.gbasm +++ b/modes/dungeongeneration.gbasm @@ -75,15 +75,7 @@ New_Dungeon: CALL =Update_Enemies_Spawning_Pattern 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 diff --git a/playerattacks.gbasm b/playerattacks.gbasm index b9b108b..d87368e 100644 --- a/playerattacks.gbasm +++ b/playerattacks.gbasm @@ -83,7 +83,23 @@ Canceled_Attack: LD $mem_bunny_mana, A RET +Empty_Attack: + RET + Attack_List: + .Empty: + ; Attack menu name string + .DB =Empty + + ; Attack function + .DB =Empty_Attack + + ; Energy point cost + .DB $00 + + .PADTO =.Empty+8 + + .Hop: ; Attack menu name string .DB =Hop_Attack_Menu_Txt diff --git a/scripts/generate-tiledata.py b/scripts/generate-tiledata.py index 0b8cb95..153c272 100644 --- a/scripts/generate-tiledata.py +++ b/scripts/generate-tiledata.py @@ -24,6 +24,8 @@ 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") +print("\n\t; Box") +get_sprite_png_parse_output("./sprites/bg/box.png") sprite_idx = 0xf0 print("Small_sprites:") diff --git a/sprites/bg/box.png b/sprites/bg/box.png Binary files differnew file mode 100644 index 0000000..1a56562 --- /dev/null +++ b/sprites/bg/box.png diff --git a/tiles.gbasm b/tiles.gbasm index 5d82543..eb04d60 100644 --- a/tiles.gbasm +++ b/tiles.gbasm @@ -16,7 +16,7 @@ Load_Tile: LD HL, $9200 LD DE, =BG_Tile_Image_Data - LD BC, $04c0 + LD BC, $0500 CALL =memcpy LD HL, $8f00 diff --git a/tileset.gbasm b/tileset.gbasm index 0b4cbcc..5dd99f3 100644 --- a/tileset.gbasm +++ b/tileset.gbasm @@ -97,6 +97,12 @@ BG_Tile_Image_Data: .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 + + ; Box + .DB $00, $00, $00, $00, $00, $00, $1f, $1f, $20, $20, $40, $40, $ff, $ff, $87, $80 ; 0x6c + .DB $00, $00, $00, $00, $00, $00, $fc, $fc, $3e, $06, $fa, $0e, $f2, $fe, $d2, $3e ; 0x6d + .DB $bf, $86, $f9, $f9, $8b, $89, $9f, $8f, $ff, $80, $80, $ff, $7f, $7f, $00, $00 ; 0x6e + .DB $d2, $3e, $f2, $fe, $d2, $3e, $d2, $3e, $92, $7e, $14, $fc, $f8, $f8, $00, $00 ; 0x6f Small_sprites: ; Heart |