diff --git a/Makefile.mak b/Makefile.mak index 3c13a086..1a3d636a 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -150,7 +150,7 @@ bin\th05\res_kso.com: th05\res_kso.cpp $** | masters.lib -bin\th05\op.exe: th05\op010.cpp bin\th05\op.obj th05\op011.cpp th05\m_char.cpp th05\cdg_p_nc.cpp bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th05\egcrect.obj bin\hfliplut.obj +bin\th05\op.exe: th05\op010.cpp bin\th05\op.obj th05\op011.cpp th05\m_char.cpp bin\th05\snd_dlym.obj th05\cdg_p_nc.cpp bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th05\egcrect.obj bin\hfliplut.obj $(CC) $(CFLAGS) -ml -DGAME=5 -DBINARY='O' -3 -Z -nbin\th05\ -eOP.EXE @&&| $** | @@ -160,7 +160,7 @@ bin\th05\main.exe: bin\th05\main.obj th05\main010.cpp th05\main011.cpp th05\p_co $** | -bin\th05\maine.exe: bin\th05\maine.obj th05\maine011.cpp th05\regist.cpp th05\staff.cpp bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th05\egcrect.obj bin\hfliplut.obj +bin\th05\maine.exe: bin\th05\maine.obj th05\maine011.cpp th05\regist.cpp th05\staff.cpp bin\th05\snd_dlym.obj bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th05\egcrect.obj bin\hfliplut.obj $(CC) $(CFLAGS) -ml -DGAME=5 -DBINARY='E' -Z -nbin\th05\ -eMAINE.EXE @&&| $** | diff --git a/th03/snd/delaymea.cpp b/th03/snd/delaymea.cpp index 1935c48c..34bd5610 100644 --- a/th03/snd/delaymea.cpp +++ b/th03/snd/delaymea.cpp @@ -12,9 +12,7 @@ extern "C" { #endif #include "th02/snd/measure.hpp" -void pascal snd_delay_until_measure( - unsigned int measure, unsigned int frames_if_no_bgm -) +void pascal snd_delay_until_measure(int measure, unsigned int frames_if_no_bgm) { if(!snd_is_active()) { frame_delay(frames_if_no_bgm); diff --git a/th03/snd/snd.h b/th03/snd/snd.h index 0a6ad646..26d6652e 100644 --- a/th03/snd/snd.h +++ b/th03/snd/snd.h @@ -1,6 +1,4 @@ #include "th02/snd/snd.h" // Adds a customizable delay to the TH02 version. -void pascal snd_delay_until_measure( - unsigned int measure, unsigned int frames_if_no_bgm -); +void pascal snd_delay_until_measure(int measure, unsigned int frames_if_no_bgm); diff --git a/th04/snd/snd.h b/th04/snd/snd.h index 82eb0581..c1cd1cd8 100644 --- a/th04/snd/snd.h +++ b/th04/snd/snd.h @@ -1,4 +1,4 @@ -#include "th02/snd/snd.h" +#include "th03/snd/snd.h" typedef enum { SND_BGM_OFF = 0, diff --git a/th04/zunsoft.asm b/th04/zunsoft.asm index 059e64c6..c2dd358e 100644 --- a/th04/zunsoft.asm +++ b/th04/zunsoft.asm @@ -321,8 +321,7 @@ endif @@more_pyros?: cmp si, ZUNSOFT_PYRO_COUNT jl short @@next_pyro - push (2 shl 16) - call snd_delay_until_measure + call snd_delay_until_measure pascal, (2 shl 16) mov PaletteTone, 100 call palette_show call super_entry_bfnt pascal, ds, offset aZun02_bft diff --git a/th05/snd/delaymea.asm b/th05/snd/delaymea.asm deleted file mode 100644 index 13078f00..00000000 --- a/th05/snd/delaymea.asm +++ /dev/null @@ -1,29 +0,0 @@ -public SND_DELAY_UNTIL_MEASURE -snd_delay_until_measure proc far - -@@frames_if_no_bgm = word ptr 6 -@@measure = word ptr 8 - - push bp - mov bp, sp - push si - -@@retry: - call _snd_bgm_measure - mov si, ax - or si, si - jge short @@reached? - push [bp+@@frames_if_no_bgm] - nopcall frame_delay - jmp short @@ret - -@@reached?: - cmp si, [bp+@@measure] - jl short @@retry - -@@ret: - pop si - pop bp - retf 4 -snd_delay_until_measure endp - db 0 diff --git a/th05/snd/delaymea.cpp b/th05/snd/delaymea.cpp new file mode 100644 index 00000000..e21e5d53 --- /dev/null +++ b/th05/snd/delaymea.cpp @@ -0,0 +1,37 @@ +#pragma codeseg SHARED_ + +extern "C" { +#include +#include "platform.h" +#include "libs/kaja/kaja.h" +#include "th02/hardware/frmdelay.h" +#include "th05/snd/snd.h" +#include "th02/snd/measure.hpp" +} + +int snd_bgm_measure(void) +{ + if(!snd_is_active()) { + return -1; + } + return snd_get_song_measure(); +} + +void pascal snd_delay_until_measure(int measure, unsigned int frames_if_no_bgm) +{ + int measure_cur; + do { + measure_cur = snd_bgm_measure(); + if(measure_cur < 0) { + /* TODO: Replace with the decompiled call + * frame_delay(frames_if_no_bgm); + * once the segmentation allows us to, if ever */ + __asm { + push frames_if_no_bgm; nop; push cs; call near ptr frame_delay; + } + return; + } + } while(measure_cur < measure); +} + +#pragma codestring "\x00" diff --git a/th05/snd/measure.asm b/th05/snd/measure.asm deleted file mode 100644 index 6d0e81e6..00000000 --- a/th05/snd/measure.asm +++ /dev/null @@ -1,25 +0,0 @@ -public _snd_bgm_measure -_snd_bgm_measure proc far - push bp - mov bp, sp - cmp _snd_bgm_mode, SND_BGM_OFF - jnz short @@BGM_is_active - mov ax, -1 - pop bp - retf - -@@BGM_is_active: - mov ah, KAJA_GET_SONG_MEASURE - cmp _snd_bgm_mode, SND_BGM_MIDI - jz short @@MIDI_is_active - int PMD - jmp short @@ret - -@@MIDI_is_active: - mov dx, MMD_TICKS_PER_QUARTER_NOTE * 4 - int MMD - -@@ret: - pop bp - retf -_snd_bgm_measure endp diff --git a/th05/snd_dlym.cpp b/th05/snd_dlym.cpp new file mode 100644 index 00000000..3020e483 --- /dev/null +++ b/th05/snd_dlym.cpp @@ -0,0 +1 @@ +#include "th05/snd/delaymea.cpp" diff --git a/th05_maine.asm b/th05_maine.asm index 0072cbc4..e1797d7c 100644 --- a/th05_maine.asm +++ b/th05_maine.asm @@ -831,9 +831,7 @@ loc_AB4A: call sub_A7FE cmp byte_14F8E, 0 jnz loc_AF8F ; default - push [bp+var_2] - push [bp+var_4] - call snd_delay_until_measure + call snd_delay_until_measure pascal, [bp+var_2], [bp+var_4] jmp loc_AF8F ; default ; --------------------------------------------------------------------------- @@ -7549,8 +7547,8 @@ include th02/initmain.asm include th04/hardware/input_sense.asm include th05/hardware/input_held.asm include th05/hardware/input_wait.asm -include th05/snd/measure.asm -include th05/snd/delaymea.asm + extern _snd_bgm_measure:proc + extern SND_DELAY_UNTIL_MEASURE:proc extern FRAME_DELAY:proc extern CDG_LOAD_ALL_NOALPHA:proc extern CDG_FREE_ALL:proc diff --git a/th05_op.asm b/th05_op.asm index bddf6e74..0dee0b87 100644 --- a/th05_op.asm +++ b/th05_op.asm @@ -2552,8 +2552,7 @@ include th02/initop.asm include th04/hardware/input_sense.asm include th05/hardware/input_held.asm include th05/hardware/input_wait.asm -include th05/snd/measure.asm -include th05/snd/delaymea.asm + extern SND_DELAY_UNTIL_MEASURE:proc extern CDG_PUT_NOCOLORS_8:proc extern FRAME_DELAY:proc extern CDG_LOAD_SINGLE_NOALPHA:proc