aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAstatin <[email protected]>2025-08-07 16:53:50 +0200
committerAstatin <[email protected]>2025-08-07 16:53:50 +0200
commit41b5858e855c68e01bf388e54abd82661e846585 (patch)
treedc552e5de42e033f49cb9774c7f1af2b737a5fc0
parent162fad62713d6b2e175c4cd5d7e53ebe7dedef11 (diff)
Add heal sound effect + remove useless tile loads
-rw-r--r--Makefile2
-rw-r--r--definitions.gbasm2
-rw-r--r--main.gbasm1
-rw-r--r--map/loading/dungeontiles.gbasm7
-rw-r--r--map/objects.gbasm5
-rw-r--r--modes/dungeon.gbasm3
-rw-r--r--modes/dungeongeneration.gbasm19
-rw-r--r--music/soundeffects/heal.gbasm58
-rw-r--r--playerattacks/heal.gbasm2
-rw-r--r--scripts/cut-recording-cycle.py21
10 files changed, 117 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index d43ed01..f130a43 100644
--- a/Makefile
+++ b/Makefile
@@ -58,7 +58,7 @@ build/game_linux_x86-64: build/makeself/start.sh build/makeself/main.rom build/m
run: build/main.rom
mkdir -p recordings
- gb $< --record-input "./recordings/$(shell date -Iseconds).record" -v infos,errors,debug # ,halt_cycles
+ gb $< --record-input "./recordings/$(shell date -Iseconds).record" -v infos,errors,debug,halt_cycles
sameboy: build/main.rom
sameboy build/main.rom
diff --git a/definitions.gbasm b/definitions.gbasm
index 7e9cecf..2fba957 100644
--- a/definitions.gbasm
+++ b/definitions.gbasm
@@ -54,7 +54,7 @@
.DEFINE mem_rng_state_2 ($c00b) ; 2 bytes
.DEFINE mem_map_loading_flags ($c00c)
-; bit 0: scroll or first load (object loading and load map)
+; bit 0: scroll or first load (load map)
; 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 (?)
diff --git a/main.gbasm b/main.gbasm
index 61aa158..5d39faf 100644
--- a/main.gbasm
+++ b/main.gbasm
@@ -65,6 +65,7 @@ Entrypoint:
.INCLUDE "map/dungeons.gbasm"
.INCLUDE "music/soundeffects/click.gbasm"
.INCLUDE "music/soundeffects/menu.gbasm"
+.INCLUDE "music/soundeffects/heal.gbasm"
.INCLUDE "music/soundeffects/nextfloor.gbasm"
_music_Dungeon:
diff --git a/map/loading/dungeontiles.gbasm b/map/loading/dungeontiles.gbasm
index ad02ff1..ea33593 100644
--- a/map/loading/dungeontiles.gbasm
+++ b/map/loading/dungeontiles.gbasm
@@ -24,6 +24,9 @@ Load_Prepared_Map:
CP E
JR NZ, =.For_X
+ LD A, $mem_viewport_x
+ SUB $02
+ LD C, A
INC B
LD A, B
CP D
@@ -107,6 +110,9 @@ Prepare_Scrolling_Map:
LD A, $mem_map_loading_flags
BIT 0, A
JR Z, =Display_Scrolling_Map.End
+ RES 0, A
+ LD $mem_map_loading_flags, A
+
LD A, $mem_moving_animation_step
LD C, A
@@ -328,7 +334,6 @@ Display_Prepared_Blocks:
LD ($mem_prepared_block_position), A
LD A, ($mem_additional_loading_block_position+1)
LD ($mem_prepared_block_position+1), A
- JP =Display_Main_Prepared_Block
Display_Main_Prepared_Block:
PUSH AF
diff --git a/map/objects.gbasm b/map/objects.gbasm
index e7dd028..4fdc195 100644
--- a/map/objects.gbasm
+++ b/map/objects.gbasm
@@ -247,6 +247,8 @@ Heal_Action:
POP DE
POP BC
+ .SET_SOUND_EFFECT =_sound_effect_Heal
+
LD (HL), $00
RET
@@ -364,6 +366,8 @@ Restore_EP_Action:
POP DE
POP BC
+ .SET_SOUND_EFFECT =_sound_effect_Heal
+
LD (HL), $00
RET
@@ -387,6 +391,7 @@ Display_Object:
CP $FF
RET Z
LD C, A
+
CP $00
JR NZ, =.skip_remove_object_after_display
LD (HL), $FF
diff --git a/modes/dungeon.gbasm b/modes/dungeon.gbasm
index e67847b..b747375 100644
--- a/modes/dungeon.gbasm
+++ b/modes/dungeon.gbasm
@@ -11,6 +11,9 @@ Update_Animation_Steps:
BIT 3, A
JR Z, =.update_mode
+ LD A, $mem_map_loading_flags
+ SET 0, A
+ LD $mem_map_loading_flags, A
LD A, $mem_moving_animation_step
INC A
AND $0f
diff --git a/modes/dungeongeneration.gbasm b/modes/dungeongeneration.gbasm
index 1a0498f..dc6fd8a 100644
--- a/modes/dungeongeneration.gbasm
+++ b/modes/dungeongeneration.gbasm
@@ -225,6 +225,22 @@ Dungeon_generation_VBlank:
CALL =Reset_Entities_Collision_Map
+ LD A, $mem_loop_frame_timer
+ ADD $3c
+ LD B, A
+ .wait_1s.loop:
+ HALT
+ LD A, $mem_loop_frame_timer
+ CP B
+ JR NZ, =.wait_1s.loop
+
+ LD A, $mem_display_flag
+ RES 6, A
+ LD $mem_display_flag, A
+ LD A, $mem_map_loading_flags
+ RES 2, A
+ RES 0, A
+ LD $mem_map_loading_flags, A
LD A, $mem_sound_flags
CP $00
CALL Z, =Reset_Music_Channels
@@ -248,6 +264,9 @@ Dungeon_generation_Out_Of_VBlank:
PUSH HL
LD A, $saved_rom_bank
PUSH AF
+ LD A, $mem_loop_frame_timer
+ INC A
+ LD $mem_loop_frame_timer, A
CALL =Play_Music
CALL =VBlank_Wait
.ENABLE_MODE_2_INTERRUPT
diff --git a/music/soundeffects/heal.gbasm b/music/soundeffects/heal.gbasm
new file mode 100644
index 0000000..b68a8c4
--- /dev/null
+++ b/music/soundeffects/heal.gbasm
@@ -0,0 +1,58 @@
+_sound_effect_Heal:
+ LD A, $mem_sound_flags
+ SET 2, A
+ LD $mem_sound_flags, A
+
+ LD A, $3f
+ LD ($16), A
+ LD A, $82
+ LD ($17), A
+ LD A, $06
+ LD ($18), A
+ LD A, $87
+ LD ($19), A
+
+ .RET_WAIT_NEXT_FRAME
+ .RET_WAIT_NEXT_FRAME
+ .RET_WAIT_NEXT_FRAME
+ .RET_WAIT_NEXT_FRAME
+
+ LD A, $3f
+ LD ($16), A
+ LD A, $82
+ LD ($17), A
+ LD A, $83
+ LD ($18), A
+ LD A, $87
+ LD ($19), A
+
+ .RET_WAIT_NEXT_FRAME
+ .RET_WAIT_NEXT_FRAME
+
+ LD A, $3f
+ LD ($16), A
+ LD A, $82
+ LD ($17), A
+ LD A, $ac
+ LD ($18), A
+ LD A, $87
+ LD ($19), A
+
+ .RET_WAIT_NEXT_FRAME
+ .RET_WAIT_NEXT_FRAME
+
+ LD A, $3f
+ LD ($16), A
+ LD A, $82
+ LD ($17), A
+ LD A, $c1
+ LD ($18), A
+ LD A, $87
+ LD ($19), A
+
+ LD A, $mem_sound_flags
+ AND 0b11000001
+ LD $mem_sound_flags, A
+ LD A, $ff
+ LD ($mem_sound_effect_pc), A
+ RET
diff --git a/playerattacks/heal.gbasm b/playerattacks/heal.gbasm
index b8718b9..a757a2c 100644
--- a/playerattacks/heal.gbasm
+++ b/playerattacks/heal.gbasm
@@ -23,6 +23,8 @@ Heal_Attack:
POP DE
POP BC
+ .SET_SOUND_EFFECT =_sound_effect_Heal
+
LD A, $enum_dungeon_mode
LD $mem_requested_mode, A
LD $mem_current_mode, A
diff --git a/scripts/cut-recording-cycle.py b/scripts/cut-recording-cycle.py
new file mode 100644
index 0000000..ba1491b
--- /dev/null
+++ b/scripts/cut-recording-cycle.py
@@ -0,0 +1,21 @@
+import sys
+
+file = open(sys.argv[1], "rb")
+output_file = open(sys.argv[2], "wb")
+cycle = int(sys.argv[3])
+
+last_cycle_update = 0
+while True:
+ next_cycle_update_buf = file.read(16)
+ if len(next_cycle_update_buf) < 16:
+ break
+ inputs = file.read(2)
+
+ next_cycle_update = int.from_bytes(next_cycle_update_buf, byteorder="little", signed=False)
+ print("CYCLES: %d, input1: %08x, input2: %08x" % (next_cycle_update, inputs[0], inputs[1]))
+
+ if next_cycle_update > cycle:
+ break
+
+ output_file.write(next_cycle_update.to_bytes(16, byteorder="little", signed=False))
+ output_file.write(inputs)