diff options
author | Astatin <[email protected]> | 2025-03-13 19:08:09 +0900 |
---|---|---|
committer | Astatin <[email protected]> | 2025-03-13 19:08:09 +0900 |
commit | 62701690d1c7b95b639d63d0cb9cd6ebeb9ac876 (patch) | |
tree | 833c88d35818c4d63e7d440355254aeb47af2cfd | |
parent | ab45947d3fdc9885c497d9fc3dd124c7986f6ea4 (diff) |
Adding multi-step dialogue
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | definitions.gbasm | 7 | ||||
-rw-r--r-- | dialogues/demo_quest.gbasm | 5 | ||||
-rw-r--r-- | dialogues/dialogues.gbasm | 94 | ||||
-rw-r--r-- | dialogues/text.gbasm | 12 | ||||
-rw-r--r-- | dialogues/text.gbtxt | 8 | ||||
-rw-r--r-- | dialogues/utils.gbasm | 23 | ||||
-rw-r--r-- | entity/actions.gbasm | 17 | ||||
-rw-r--r-- | entity/bunny.gbasm | 84 | ||||
-rw-r--r-- | entity/init.gbasm | 1 | ||||
-rw-r--r-- | entity/questgoal.gbasm | 11 | ||||
-rw-r--r-- | gui.gbasm | 48 | ||||
-rw-r--r-- | main.gbasm | 9 | ||||
-rw-r--r-- | rng.gbasm | 2 | ||||
-rw-r--r-- | sprites/gui/borders.png | bin | 169 -> 201 bytes | |||
-rw-r--r-- | text.gbasm (renamed from dialogues.gbasm) | 6 | ||||
-rw-r--r-- | text.gbtxt (renamed from dialogues.gbtxt) | 3 | ||||
-rw-r--r-- | tiles.gbasm | 2 | ||||
-rw-r--r-- | tileset.gbasm | 4 |
20 files changed, 277 insertions, 66 deletions
@@ -5,10 +5,10 @@ all: run tileset.gbasm: ./scripts/generate-tiledata.py $(wildcard ./sprites/**/* ./sprites/*) python ./scripts/generate-tiledata.py > tileset.gbasm -dialogues.gbasm: ./dialogues.gbtxt ./scripts/generate_from_gbtxt.py - python ./scripts/generate_from_gbtxt.py dialogues.gbtxt > dialogues.gbasm +%.gbasm: ./%.gbtxt ./scripts/generate_from_gbtxt.py + python ./scripts/generate_from_gbtxt.py $< > $@ -build/main.rom: main.gbasm tileset.gbasm dialogues.gbasm +build/main.rom: main.gbasm tileset.gbasm text.gbasm dialogues/text.gbasm mkdir -p build gbasm $< $@ > build/main.sym @@ -1,5 +1,4 @@ Bugs: - -> Emulator crash with "not implemented: Only XKB keymaps are supported when unfocused (or workspace change maybe ?) Accessibility issues: -> freeze/earcopter attack patterns are not obvious (either needs to be shown on map or add select menu with infos if not possible + tutorial to explain the existence of select menu ?) diff --git a/definitions.gbasm b/definitions.gbasm index 30fc296..154384a 100644 --- a/definitions.gbasm +++ b/definitions.gbasm @@ -49,6 +49,7 @@ ; 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 (?) +; bit 4: animation step should start to go up on next frame .DEFINE mem_prepared_block_tile ($c00d) .DEFINE mem_prepared_block_position_1 ($c00e) @@ -124,7 +125,11 @@ .DEFINE mem_floor_count ($c03c) -.DEFINE mem_loop_rng_timer ($c03d) +.DEFINE mem_loop_frame_timer ($c03d) + +.DEFINE mem_dialogue_script_program_counter $c03e ; takes c03e and c03f + +.DEFINE mem_entity_being_attacked_low ($c040) .DEFINE mem_next_free_head_lower_bytes ($c6ff) diff --git a/dialogues/demo_quest.gbasm b/dialogues/demo_quest.gbasm new file mode 100644 index 0000000..ea9dd46 --- /dev/null +++ b/dialogues/demo_quest.gbasm @@ -0,0 +1,5 @@ +Demo_quest_bunny: +.TEXTB =Bunny_Header_Text =Dialogue_1_1b +.TEXT =Dialogue_1_2t =Dialogue_1_2b +.TEXT =Dialogue_1_3t =Empty +.END diff --git a/dialogues/dialogues.gbasm b/dialogues/dialogues.gbasm new file mode 100644 index 0000000..1fdcc80 --- /dev/null +++ b/dialogues/dialogues.gbasm @@ -0,0 +1,94 @@ +Dialogue_script_step: + LD A, ($mem_dialogue_script_program_counter) + LD H, A + LD A, ($mem_dialogue_script_program_counter+1) + LD L, A + + LD A, (HL+) + + LD BC, =Dialogue_script_instruction_Jump_Table + + .JUMP_TABLE + + LD A, H + LD ($mem_dialogue_script_program_counter), A + LD A, L + LD ($mem_dialogue_script_program_counter+1), A + + RET + +Dialogue_script_instruction_Jump_Table: + ; 00 + JP =Exit_Menu + NOP + + ; 01 + JP =.Text + NOP + + ;02 + JP =.TextB + NOP + + .Text: + 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 HL + LD HL, $dialogue_first_line + 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, $05 + LD $mem_display_flag, A + + RET + + .TextB: + LD A, (HL+) + LD B, A + LD A, (HL+) + LD C, A + PUSH HL + LD HL, $dialogue_first_line + CALL =Print_str + 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 + +.INCLUDE "dialogues/text.gbasm" +.INCLUDE "dialogues/demo_quest.gbasm" diff --git a/dialogues/text.gbasm b/dialogues/text.gbasm new file mode 100644 index 0000000..c8895d7 --- /dev/null +++ b/dialogues/text.gbasm @@ -0,0 +1,12 @@ +Empty: +.DB , 0xff +Bunny_Header_Text: +.DB 0x8b, 0x9e, 0x97, 0x97, 0xa2, 0xaa, 0xff +Dialogue_1_1b: +.DB 0x91, 0x8e, 0x95, 0x95, 0x98, 0x0, 0xa5, 0xff +Dialogue_1_2t: +.DB 0x92, 0x0, 0x8a, 0x96, 0x0, 0x9c, 0x9d, 0x9e, 0x8c, 0x94, 0x0, 0x92, 0x97, 0x0, 0x9d, 0x91, 0x92, 0x9c, 0xff +Dialogue_1_2b: +.DB 0x8d, 0x9e, 0x97, 0x90, 0x8e, 0x98, 0x97, 0xa4, 0xff +Dialogue_1_3t: +.DB 0xa0, 0x98, 0x9e, 0x95, 0x8d, 0x0, 0xa2, 0x98, 0x9e, 0x0, 0x91, 0x8e, 0x95, 0x99, 0x0, 0x96, 0x8e, 0xa6, 0xff diff --git a/dialogues/text.gbtxt b/dialogues/text.gbtxt new file mode 100644 index 0000000..64c16b2 --- /dev/null +++ b/dialogues/text.gbtxt @@ -0,0 +1,8 @@ +Empty: +Bunny_Header_Text: Bunny: +Dialogue_1_1b: Hello ! + +Dialogue_1_2t: I am stuck in this +Dialogue_1_2b: dungeon. + +Dialogue_1_3t: Would you help me? diff --git a/dialogues/utils.gbasm b/dialogues/utils.gbasm new file mode 100644 index 0000000..38c9e51 --- /dev/null +++ b/dialogues/utils.gbasm @@ -0,0 +1,23 @@ +.MACRODEF START_SCRIPT script + LD A, high($script) + LD ($mem_dialogue_script_program_counter), A + LD A, low($script) + LD ($mem_dialogue_script_program_counter+1), A + CALL =Dialogue_script_step +.END + +.MACRODEF END + .DB 00 +.END + +.MACRODEF TEXT first_line second_line + .DB 01 + .DB $first_line + .DB $second_line +.END + +.MACRODEF TEXTB first_line second_line + .DB 02 + .DB $first_line + .DB $second_line +.END diff --git a/entity/actions.gbasm b/entity/actions.gbasm index 051b488..ebbfb18 100644 --- a/entity/actions.gbasm +++ b/entity/actions.gbasm @@ -158,15 +158,14 @@ Interaction_Jump_table: Enemy_Interaction: LD A, L AND $f0 - ADD $06 - LD L, A - LD A, (HL) - DEC A - DAA - LD (HL+), A + LD $mem_entity_being_attacked_low, A + LD A, $mem_bunny_direction + AND $07 + OR $10 + LD $mem_bunny_direction, A - SET 3, (HL) - LD A, $24 - LD $mem_blinking_animation_counter, A + LD A, $mem_map_loading_flags + SET 4, A + LD $mem_map_loading_flags, A RET diff --git a/entity/bunny.gbasm b/entity/bunny.gbasm index 8438d3e..32cff97 100644 --- a/entity/bunny.gbasm +++ b/entity/bunny.gbasm @@ -58,6 +58,9 @@ Move_Bunny: .Start_action_or_movement: LD A, $mem_map_loading_flags + BIT 4, A + JP NZ, =.Start_action_or_movement.start_from_interaction + BIT 3, A JP NZ, =.Start_action_or_movement.end @@ -65,7 +68,7 @@ Move_Bunny: LD A, $mem_button_direction CP $00 - JP Z, =.Start_action_or_movement.test_action + JP Z, =.Start_action_or_movement.end SET 3, A LD D, A @@ -105,22 +108,9 @@ Move_Bunny: JR =.Start_action_or_movement.end - .Start_action_or_movement.test_action: - LD A, $mem_button_action - LD B, A - LD A, $mem_last_button_action - XOR B - AND B - CP $00 - JR Z, =.Start_action_or_movement.end - BIT 0, A - JR Z, =.Start_action_or_movement.end - LD A, $mem_bunny_direction - AND $07 - OR $10 - LD $mem_bunny_direction, A - + .Start_action_or_movement.start_from_interaction: LD A, $mem_map_loading_flags + RES 4, A SET 3, A LD $mem_map_loading_flags, A .Start_action_or_movement.end: @@ -137,6 +127,36 @@ Move_Bunny: LD $mem_bunny_flags, A .Reset_Blinking_flag.end: + .Delayed_Attack: + LD A, $mem_moving_animation_step + CP $08 + JR NZ, =.Delayed_Attack.end + + LD A, $mem_map_loading_flags + BIT 3, A + JR Z, =.Delayed_Attack.end + + LD A, $mem_entity_being_attacked_low + CP $00 + JR Z, =.Delayed_Attack.end + + ADD $06 + LD L, A + LD H, high($mem_entities_list) + LD A, (HL) + DEC A + DAA + LD (HL+), A + DBG + + SET 3, (HL) + LD A, $24 + LD $mem_blinking_animation_counter, A + + LD A, $00 + LD $mem_entity_being_attacked_low, A + .Delayed_Attack.end: + .Scroll_viewport: LD A, $mem_map_loading_flags BIT 3, A @@ -300,19 +320,20 @@ Move_Bunny: LD $mem_viewport_y, A .Middle_movement_doublespeed_viewport_update.end: - .Interaction: LD A, $mem_map_loading_flags BIT 3, A - JP Z, =.Interaction.end - LD A, $mem_moving_animation_step - CP $02 JP NZ, =.Interaction.end - - LD A, $mem_bunny_direction - AND $f8 - CP $10 - JR NZ, =.Interaction.end + .Interaction.test_action: + LD A, $mem_button_action + LD B, A + LD A, $mem_last_button_action + XOR B + AND B + CP $00 + JP Z, =.Interaction.end + BIT 0, A + JP Z, =.Interaction.end LD A, $mem_bunny_x LD B, A @@ -332,7 +353,7 @@ Move_Bunny: ADD $10 LD L, A CP $00 - JR Z, =.Interaction.end + JR Z, =.Interaction.for_else LD A, (HL+) CP $00 @@ -358,9 +379,20 @@ Move_Bunny: POP BC POP HL + JR =.Interaction.end .Interaction.entities_loop.next: JR =.Interaction.entities_loop + + .Interaction.for_else: + LD A, $mem_bunny_direction + AND $07 + OR $10 + LD $mem_bunny_direction, A + + LD A, $mem_map_loading_flags + SET 4, A + LD $mem_map_loading_flags, A .Interaction.end: .Check_End_Action: diff --git a/entity/init.gbasm b/entity/init.gbasm index d263248..e9a3cbc 100644 --- a/entity/init.gbasm +++ b/entity/init.gbasm @@ -137,7 +137,6 @@ Initialize_Enemy: ; HL => pointer to entity struct ADD $03 Initialize_Entity: ; HL => pointer to entity struct, A => entity loaded index - DBG LD E, A SLA A SLA A diff --git a/entity/questgoal.gbasm b/entity/questgoal.gbasm index d39f786..9885cea 100644 --- a/entity/questgoal.gbasm +++ b/entity/questgoal.gbasm @@ -39,16 +39,7 @@ Open_Dialogue: JR =.Check_end .Check_end: - LD HL, $dialogue_first_line - LD BC, =Bunny_Prefix - CALL =Print_str - - LD HL, $dialogue_third_line - LD BC, =Text_1 - CALL =Print_str - - LD A, $07 - LD $mem_display_flag, A + .START_SCRIPT =Demo_quest_bunny LD A, $mem_bunny_direction AND $0f @@ -223,6 +223,11 @@ Reload_EP_Cost: RET Check_dialogue_action: + LD A, $mem_display_flag + AND 0b00010100 + CP $00 + RET NZ + LD A, $mem_current_mode CP $enum_dungeon_menu_mode JR Z, =.Dungeon_Menu @@ -239,7 +244,7 @@ Check_dialogue_action: CP $00 RET Z BIT 0, A - JP NZ, =Exit_Menu + JP NZ, =Dialogue_script_step RET .Dungeon_Menu: @@ -323,3 +328,44 @@ Open_dialogue_on_dungeon_menu_mode: LD $mem_display_flag, A RET + +Dialogue_Arrow_Animation: + LD A, $mem_display_flag + BIT 0, A + RET Z + + LD A, $mem_current_mode + CP $enum_dungeon_dialogue_mode + JR Z, =.dialogue + + LD A, $18 + LD ($9d05), A + LD A, $14 + LD ($9d06), A + RET + + .dialogue: + LD A, $mem_loop_frame_timer + AND $7f + CP $4e + JR C, =.normal + CP $5a + JR C, =.down + CP $66 + JR C, =.normal + CP $72 + JR C, =.down + + .normal: + LD A, $19 + LD ($9d05), A + LD A, $1a + LD ($9d06), A + RET + + .down: + LD A, $1b + LD ($9d05), A + LD A, $1c + LD ($9d06), A + RET @@ -209,6 +209,7 @@ VBLANK_Entrypoint: CALL =Display_Object Skip_VBlank_Dungeon_Update: + CALL =Dialogue_Arrow_Animation CALL =Copy_Dialogue_Buffer CALL =Display_dialogue_cursor @@ -247,9 +248,9 @@ VBLANK_Entrypoint: CALL =Display_Animation_List CALL =Display_Entities - LD A, $mem_loop_rng_timer + LD A, $mem_loop_frame_timer INC A - LD $mem_loop_rng_timer, A + LD $mem_loop_frame_timer, A .ENABLE_VBLANK_INTERRUPTS RET @@ -309,6 +310,7 @@ STAT_Entrypoint: .INCLUDE "map/generation.gbasm" .INCLUDE "map/objects.gbasm" .INCLUDE "gui.gbasm" +.INCLUDE "dialogues/utils.gbasm" .INCLUDE "entity/utils.gbasm" .INCLUDE "entity/init.gbasm" .INCLUDE "entity/bunny.gbasm" @@ -324,4 +326,5 @@ STAT_Entrypoint: .INCLUDE "playerattacks.gbasm" .INCLUDE "enemiesattacks.gbasm" .INCLUDE "tileset.gbasm" -.INCLUDE "dialogues.gbasm" +.INCLUDE "text.gbasm" +.INCLUDE "dialogues/dialogues.gbasm" @@ -60,7 +60,7 @@ RNG_Step: LD A, D LD $mem_rng_state_1, A - LD A, $mem_loop_rng_timer + LD A, $mem_loop_frame_timer LD D, A LD A, E diff --git a/sprites/gui/borders.png b/sprites/gui/borders.png Binary files differindex cba5872..bc8122d 100644 --- a/sprites/gui/borders.png +++ b/sprites/gui/borders.png diff --git a/dialogues.gbasm b/text.gbasm index 0deea6d..22ce9d2 100644 --- a/dialogues.gbasm +++ b/text.gbasm @@ -1,9 +1,3 @@ -Bunny_Prefix: -.DB 0x8b, 0x9e, 0x97, 0x97, 0xa2, 0xaa, 0xff -Text_1: -.DB 0x91, 0x8e, 0x95, 0x95, 0x98, 0x0, 0xa5, 0xff -Debug_Text: -.DB 0x8d, 0x8b, 0x90, 0xff Hop_Attack_Menu_Txt: .DB 0x91, 0x98, 0x99, 0xff Heal_Attack_Menu_Txt: diff --git a/dialogues.gbtxt b/text.gbtxt index 790b759..546b64f 100644 --- a/dialogues.gbtxt +++ b/text.gbtxt @@ -1,6 +1,3 @@ -Bunny_Prefix: Bunny: -Text_1: Hello ! -Debug_Text: DBG Hop_Attack_Menu_Txt: Hop Heal_Attack_Menu_Txt: Heal Freeze_Attack_Menu_Txt: Freeze diff --git a/tiles.gbasm b/tiles.gbasm index 3e91a30..bc5e6e6 100644 --- a/tiles.gbasm +++ b/tiles.gbasm @@ -11,7 +11,7 @@ Load_Tile: LD HL, $9100 LD DE, =GUI_Border_Data - LD BC, $0090 + LD BC, $00d0 CALL =memcpy LD HL, $9200 diff --git a/tileset.gbasm b/tileset.gbasm index e3a03ac..0b4cbcc 100644 --- a/tileset.gbasm +++ b/tileset.gbasm @@ -8,6 +8,10 @@ GUI_Border_Data: .DB $06, $02, $06, $02, $06, $02, $06, $02, $06, $02, $06, $02, $06, $02, $06, $02 ; 0x16 .DB $00, $00, $ff, $ff, $ff, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0x17 .DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $ff, $00, $ff, $ff, $00, $00 ; 0x18 + .DB $07, $07, $07, $04, $03, $02, $01, $01, $00, $00, $ff, $00, $ff, $ff, $00, $00 ; 0x19 + .DB $e6, $e2, $e6, $22, $c6, $42, $86, $82, $0e, $02, $fc, $04, $f8, $f8, $00, $00 ; 0x1a + .DB $00, $00, $07, $07, $07, $04, $03, $02, $01, $01, $ff, $00, $ff, $ff, $00, $00 ; 0x1b + .DB $06, $02, $e6, $e2, $e6, $22, $c6, $42, $8e, $82, $fc, $04, $f8, $f8, $00, $00 ; 0x1c BG_Tile_Image_Data: ; Trees |