From 62e0167e2043fdce9e99145dd3b1e41304503bb1 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Mon, 3 May 2021 08:38:40 +0200 Subject: [PATCH] [Translation unit catch-up] [th03/th04/th05] snd_delay_until_measure(), game_exit_to_dos() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Segment alignment issues once again… but that completes the SHARED segments of all TH03 and TH05 binaries, for now! Part of P0139, funded by [Anonymous]. --- Makefile.mak | 8 ++++---- th02/exit_dos.asm | 11 ----------- th02/exit_dos.c | 5 +++++ th03/snd/delaymea.asm | 40 ---------------------------------------- th03_op.asm | 7 +------ th04_maine.asm | 3 +-- th04_op.asm | 4 ++-- th05_op.asm | 3 +-- 8 files changed, 14 insertions(+), 67 deletions(-) delete mode 100644 th02/exit_dos.asm delete mode 100644 th03/snd/delaymea.asm diff --git a/Makefile.mak b/Makefile.mak index a40bb1c0..9287a298 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -105,7 +105,7 @@ bin\th03\res_yume.com: th03\res_yume.cpp $** | masters.lib -bin\th03\op.exe: th03\op_01.cpp bin\th03\op.obj bin\th01\vplanset.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_load.obj bin\th03\exit.obj bin\th03\vector1.obj bin\th03\cdg_put.obj bin\frmdely1.obj bin\th03\input_s.obj bin\th03\pi_put.obj bin\th03\snd_kaja.obj bin\th03\initop.obj bin\th03\cdg_load.obj bin\th03\grppsafx.obj bin\th03\pi_load.obj bin\th03\inp_m_w.obj bin\th03\cdg_p_na.obj bin\hfliplut.obj bin\frmdely2.obj +bin\th03\op.exe: th03\op_01.cpp bin\th03\op.obj bin\exit_dos.obj bin\th01\vplanset.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_load.obj bin\th03\exit.obj bin\th03\vector1.obj bin\th03\cdg_put.obj bin\frmdely1.obj bin\th03\input_s.obj bin\th03\pi_put.obj bin\th03\snd_kaja.obj bin\th03\initop.obj bin\th03\cdg_load.obj bin\th03\grppsafx.obj bin\th03\pi_load.obj bin\th03\inp_m_w.obj bin\th03\cdg_p_na.obj bin\hfliplut.obj bin\frmdely2.obj $(CC) $(CFLAGS) $(LARGE_LFLAGS) -3 -Z -DGAME=3 -nbin\th03\ -eOP.EXE @&&| $** | @@ -133,7 +133,7 @@ bin\th04\res_huma.com: th04\res_huma.cpp $** | masters.lib -bin\th04\op.exe: bin\th04\op.obj th04\m_char.cpp bin\th01\vplanset.obj bin\frmdely1.obj bin\th03\pi_put.obj bin\th03\pi_load.obj bin\hfliplut.obj bin\th04\input_w.obj bin\th04\vector.obj bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\snd_kaja.obj bin\th04\cdg_p_nc.obj bin\th04\snd_mode.obj bin\th04\cdg_put.obj bin\th04\exit.obj bin\th04\initop.obj bin\th04\cdg_p_na.obj bin\th04\input_s.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th04\egcrect.obj bin\th04\bgimage.obj bin\th04\bgimager.obj bin\th04\cdg_load.obj th04\frmdely2.c +bin\th04\op.exe: bin\th04\op.obj th04\m_char.cpp bin\th01\vplanset.obj bin\frmdely1.obj bin\th03\pi_put.obj bin\th03\pi_load.obj bin\hfliplut.obj bin\th04\input_w.obj bin\th04\vector.obj bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\snd_kaja.obj bin\th04\cdg_p_nc.obj bin\th04\snd_mode.obj bin\th04\snd_dlym.obj bin\exit_dos.obj bin\th04\cdg_put.obj bin\th04\exit.obj bin\th04\initop.obj bin\th04\cdg_p_na.obj bin\th04\input_s.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th04\egcrect.obj bin\th04\bgimage.obj bin\th04\bgimager.obj bin\th04\cdg_load.obj th04\frmdely2.c $(CC) $(CFLAGS) $(LARGE_LFLAGS) -DGAME=4 -DBINARY='O' -3 -Z -d -nbin\th04\ -eOP.EXE @&&| $** | @@ -143,7 +143,7 @@ bin\th04\main.exe: bin\th04\main.obj bin\th04\scoreupd.obj th04\main011.cpp bin\ $** | -bin\th04\maine.exe: bin\th04\maine.obj th04\maine011.cpp bin\th01\vplanset.obj bin\frmdely1.obj bin\th03\pi_put.obj bin\th04\cdg_put.obj bin\th04\exit.obj bin\th04\initmain.obj bin\th04\input_s.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th04\bgimage.obj bin\th04\bgimager.obj bin\th03\pi_load.obj bin\th03\pi_put_q.obj bin\th04\cdg_load.obj bin\hfliplut.obj bin\th04\input_w.obj bin\th04\vector.obj bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\snd_kaja.obj bin\th04\snd_mode.obj +bin\th04\maine.exe: bin\th04\maine.obj th04\maine011.cpp bin\th01\vplanset.obj bin\frmdely1.obj bin\th03\pi_put.obj bin\th04\cdg_put.obj bin\th04\exit.obj bin\th04\initmain.obj bin\th04\input_s.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th04\bgimage.obj bin\th04\bgimager.obj bin\th03\pi_load.obj bin\th03\pi_put_q.obj bin\th04\cdg_load.obj bin\hfliplut.obj bin\th04\input_w.obj bin\th04\vector.obj bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\snd_kaja.obj bin\th04\snd_mode.obj bin\th04\snd_dlym.obj $(CC) $(CFLAGS) $(LARGE_LFLAGS) -DGAME=4 -DBINARY='E' -Z -nbin\th04\ -eMAINE.EXE @&&| $** | @@ -156,7 +156,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 bin\th04\cdg_p_na.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th04\bgimage.obj bin\th05\cdg_put.obj bin\th04\exit.obj bin\th05\vector.obj bin\th05\musicp_c.obj bin\th05\musicp_a.obj bin\th05\bgimager.obj bin\th05\snd_load.obj bin\th05\snd_kaja.obj bin\th05\pi_cpp_1.obj bin\th05\pi_asm_1.obj bin\th05\pi_cpp_2.obj bin\th05\pi_asm_2.obj bin\th05\initop.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj 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 bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\snd_mode.obj +bin\th05\op.exe: th05\op010.cpp bin\th05\op.obj th05\op011.cpp th05\m_char.cpp bin\th04\cdg_p_na.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th04\bgimage.obj bin\th05\cdg_put.obj bin\th04\exit.obj bin\th05\vector.obj bin\th05\musicp_c.obj bin\th05\musicp_a.obj bin\th05\bgimager.obj bin\th05\snd_load.obj bin\th05\snd_kaja.obj bin\th05\pi_cpp_1.obj bin\th05\pi_asm_1.obj bin\th05\pi_cpp_2.obj bin\th05\pi_asm_2.obj bin\th05\initop.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj 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 bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\snd_mode.obj bin\exit_dos.obj $(CC) $(CFLAGS) $(LARGE_LFLAGS) -DGAME=5 -DBINARY='O' -3 -Z -nbin\th05\ -eOP.EXE @&&| $** | diff --git a/th02/exit_dos.asm b/th02/exit_dos.asm deleted file mode 100644 index c37d1ed9..00000000 --- a/th02/exit_dos.asm +++ /dev/null @@ -1,11 +0,0 @@ -public _game_exit_to_dos -_game_exit_to_dos proc far - push bp - mov bp, sp - nopcall _game_exit - call key_beep_on - call text_systemline_show - call text_cursor_show - pop bp - retf -_game_exit_to_dos endp diff --git a/th02/exit_dos.c b/th02/exit_dos.c index 174d4edc..44bbe48c 100644 --- a/th02/exit_dos.c +++ b/th02/exit_dos.c @@ -3,6 +3,11 @@ #include "master.hpp" #include "th02/core/initexit.h" +// TODO: Remove this macro once those functions are part of the actual SHARED +// segment (not SHARED_) in TH04 and TH05, after graph_putsa_fx() has been +// turned into its own translation unit. +#define game_exit() __asm { nop; push cs; call near ptr game_exit; } + void game_exit_to_dos(void) { game_exit(); diff --git a/th03/snd/delaymea.asm b/th03/snd/delaymea.asm deleted file mode 100644 index 441972ec..00000000 --- a/th03/snd/delaymea.asm +++ /dev/null @@ -1,40 +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 -if GAME eq 4 - cmp _snd_bgm_mode, SND_BGM_OFF -else - cmp _snd_active, 0 -endif - jnz short @@retry - push [bp+@@frames_if_no_bgm] - nopcall frame_delay - pop bp - retf 4 - -@@retry: - mov ah, KAJA_GET_SONG_MEASURE -if GAME eq 4 - cmp _snd_bgm_mode, SND_BGM_MIDI -else - cmp _snd_midi_active, 1 -endif - jz short @@MIDI_is_active - int PMD - jmp short @@reached? - -@@MIDI_is_active: - mov dx, MMD_TICKS_PER_QUARTER_NOTE * 4 ; yes, hardcoded to 4/4 - int MMD - -@@reached?: - cmp ax, [bp+@@measure] - jb short @@retry - pop bp - retf 4 -snd_delay_until_measure endp diff --git a/th03_op.asm b/th03_op.asm index 89d0ebbd..98d32ae2 100644 --- a/th03_op.asm +++ b/th03_op.asm @@ -3603,13 +3603,8 @@ op_01_TEXT ends ; =========================================================================== -; Segment type: Pure code SHARED segment word public 'CODE' use16 - assume cs:SHARED - ;org 8 - assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing - -include th02/exit_dos.asm + extern _game_exit_to_dos:proc extern _snd_determine_mode:proc extern _snd_load:proc extern _game_exit:proc diff --git a/th04_maine.asm b/th04_maine.asm index 1f4f9cb1..fd19ccf5 100644 --- a/th04_maine.asm +++ b/th04_maine.asm @@ -4590,14 +4590,13 @@ SHARED segment word public 'CODE' use16 extern VECTOR1_AT:proc extern SND_KAJA_INTERRUPT:proc extern SND_DETERMINE_MODES:proc + extern SND_DELAY_UNTIL_MEASURE:proc SHARED ends SHARED_ segment word public 'CODE' use16 assume cs:g_SHARED assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing -include th03/snd/delaymea.asm - db 0 include th04/formats/cdg_put_plane.asm include th04/snd/load.asm include th04/hardware/grppsafx.asm diff --git a/th04_op.asm b/th04_op.asm index f29b530f..09de9c05 100644 --- a/th04_op.asm +++ b/th04_op.asm @@ -2642,14 +2642,14 @@ SHARED segment word public 'CODE' use16 extern SND_KAJA_INTERRUPT:proc extern CDG_PUT_NOCOLORS_8:proc extern SND_DETERMINE_MODES:proc + extern SND_DELAY_UNTIL_MEASURE:proc + extern _game_exit_to_dos:proc SHARED ends SHARED_ segment word public 'CODE' use16 assume cs:g_SHARED assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing -include th03/snd/delaymea.asm -include th02/exit_dos.asm include th04/snd/load.asm include th04/hardware/grppsafx.asm extern CDG_PUT_8:proc diff --git a/th05_op.asm b/th05_op.asm index 8513f039..7bfbc333 100644 --- a/th05_op.asm +++ b/th05_op.asm @@ -2516,6 +2516,7 @@ op_01_TEXT ends ; Segment type: Pure code SHARED segment word public 'CODE' use16 extern SND_DETERMINE_MODES:proc + extern _game_exit_to_dos:proc SHARED ends SHARED_ segment word public 'CODE' use16 @@ -2523,8 +2524,6 @@ SHARED_ segment word public 'CODE' use16 ; org 4 assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing -include th02/exit_dos.asm - db 0 include th04/hardware/grppsafx.asm extern CDG_PUT_NOALPHA_8:proc extern _snd_se_reset:proc