[Decompilation] [th04] snd_kaja_interrupt()

4 games, 4 different versions of this function. Interestingly,
moving the game-specific differences to inline functions makes it
obvious that this function was only intended for BGM, not sound
effects.

Part of P0139, funded by [Anonymous].
This commit is contained in:
nmlgc 2021-04-28 18:35:37 +02:00
parent 4c0e76ab89
commit 7761f4e804
11 changed files with 19 additions and 32 deletions

View File

@ -133,17 +133,17 @@ 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\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_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 @&&|
$**
|
bin\th04\main.exe: bin\th04\main.obj bin\th04\scoreupd.obj th04\main011.cpp bin\th01\vplanset.obj bin\th03\vector2.obj bin\frmdely1.obj bin\hfliplut.obj th04\mpn_free.cpp bin\th04\input_w.obj th04\mpn_l_i.cpp bin\th04\vector.obj bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\cdg_put.obj bin\th04\exit.obj bin\th04\initmain.obj bin\th04\cdg_p_na.obj bin\th04\cdg_p_pr.obj bin\th04\input_s.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th04\cdg_load.obj th04\main032.cpp
bin\th04\main.exe: bin\th04\main.obj bin\th04\scoreupd.obj th04\main011.cpp bin\th01\vplanset.obj bin\th03\vector2.obj bin\frmdely1.obj bin\hfliplut.obj th04\mpn_free.cpp bin\th04\input_w.obj th04\mpn_l_i.cpp bin\th04\vector.obj bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\snd_kaja.obj bin\th04\cdg_put.obj bin\th04\exit.obj bin\th04\initmain.obj bin\th04\cdg_p_na.obj bin\th04\cdg_p_pr.obj bin\th04\input_s.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th04\cdg_load.obj th04\main032.cpp
$(CC) $(CFLAGS) $(LARGE_LFLAGS) -DGAME=4 -DBINARY='M' -3 -Z -nbin\th04\ -eMAIN.EXE @&&|
$**
|
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\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
$(CC) $(CFLAGS) $(LARGE_LFLAGS) -DGAME=4 -DBINARY='E' -Z -nbin\th04\ -eMAINE.EXE @&&|
$**
|

View File

@ -1,15 +1,20 @@
#pragma option -zCSHARED
extern "C" {
#include "platform.h"
#include "x86real.h"
#include "libs/kaja/kaja.h"
#include "th02/snd/snd.h"
#if (GAME >= 4)
#include "th04/snd/snd.h"
#else
#include "th02/snd/snd.h"
#endif
int16_t DEFCONV snd_kaja_interrupt(int16_t ax)
{
if(snd_active) {
if(snd_bgm_active()) {
_AX = ax;
if(snd_midi_active != true) {
if(snd_bgm_is_fm()) {
geninterrupt(PMD);
} else {
geninterrupt(MMD);
@ -17,3 +22,5 @@ int16_t DEFCONV snd_kaja_interrupt(int16_t ax)
}
return _AX;
}
}

View File

@ -1 +0,0 @@
#include "th02/snd/kajaint.c"

1
th02/snd_kaja.cpp Normal file
View File

@ -0,0 +1 @@
#include "th02/snd/kajaint.cpp"

View File

@ -1 +0,0 @@
#include "th02/snd/kajaint.c"

1
th03/snd_kaja.cpp Normal file
View File

@ -0,0 +1 @@
#include "th02/snd/kajaint.cpp"

View File

@ -1,21 +0,0 @@
public SND_KAJA_INTERRUPT
snd_kaja_interrupt proc
arg @@ax:word
push bp
mov bp, sp
cmp _snd_bgm_mode, SND_BGM_OFF
jz short @@ret
mov ax, @@ax
cmp _snd_bgm_mode, SND_BGM_MIDI
jz short @@midi
int 60h
jmp short @@ret
@@midi:
int 61h
@@ret:
pop bp
ret 2
snd_kaja_interrupt endp

1
th04/snd_kaja.cpp Normal file
View File

@ -0,0 +1 @@
#include "th02/snd/kajaint.cpp"

View File

@ -12980,10 +12980,10 @@ SHARED segment word public 'CODE' use16
extern VECTOR2_AT:proc
extern _snd_pmd_resident:proc
extern _snd_mmd_resident:proc
extern SND_KAJA_INTERRUPT:proc
SHARED ends
SHARED_ segment word public 'CODE' use16
include th04/snd/kajaint.asm
include th04/snd/detmodes.asm
include th04/snd/load.asm
extern CDG_PUT_8:proc

View File

@ -4590,13 +4590,13 @@ SHARED segment word public 'CODE' use16
extern VECTOR1_AT:proc
extern _snd_pmd_resident:proc
extern _snd_mmd_resident:proc
extern SND_KAJA_INTERRUPT: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 th04/snd/kajaint.asm
include th04/snd/detmodes.asm
include th03/snd/delaymea.asm
db 0

View File

@ -2641,13 +2641,13 @@ SHARED segment word public 'CODE' use16
extern VECTOR1_AT:proc
extern _snd_pmd_resident:proc
extern _snd_mmd_resident:proc
extern SND_KAJA_INTERRUPT: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 th04/snd/kajaint.asm
include th04/formats/cdg_put_nocolors.asm
include th04/snd/detmodes.asm
include th03/snd/delaymea.asm