[Separate translation units] [th02] snd_mmd_resident() (undecompilable)

Reason: Wants to be word-aligned, and the previous version in OP.EXE,
game_exit(), is not, despite having an even length :(
Oh well, at least I'm confident enough about it by now to document it.
And out of all decompilations to be thrown away, this is a pretty
dispensable one.

Part of P0133, funded by [Anonymous].
This commit is contained in:
nmlgc 2021-01-28 20:43:49 +01:00
parent cdbd621f91
commit 84d4914a3b
11 changed files with 41 additions and 43 deletions

View File

@ -78,17 +78,17 @@ bin\th02\zun_res.com: th02\zun_res1.c th02\zun_res2.c th02\zun_res3.c
$**
| masters.lib
bin\th02\op.exe: th02\op_01.cpp bin\exit_dos.obj bin\th02\zunerror.obj bin\th02\grppsafx.obj bin\th02\op.obj th02\op_02_1.cpp bin\th02\pi_load.obj bin\th02\grp_rect.obj bin\frmdely2.obj th02\op_02_2.cpp bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_load.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj th02\op_02_3.cpp bin\th02\snd_se.obj bin\frmdely1.obj th02\op_03.cpp th02\op_04.cpp th02\op_05.cpp th02\op_06.cpp
bin\th02\op.exe: th02\op_01.cpp bin\exit_dos.obj bin\th02\zunerror.obj bin\th02\grppsafx.obj bin\th02\op.obj th02\op_02_1.cpp bin\th02\pi_load.obj bin\th02\grp_rect.obj bin\frmdely2.obj th02\op_02_2.cpp bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_load.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj th02\op_02_3.cpp bin\th02\snd_se.obj bin\frmdely1.obj th02\op_03.cpp th02\op_04.cpp th02\op_05.cpp th02\op_06.cpp
$(CC) $(CFLAGS) -ml -Z -DGAME=2 -nbin\th02\ -eOP.EXE @&&|
$**
|
bin\th02\main.exe: bin\th02\main.obj bin\th02\zunerror.obj th02\main02_1.cpp bin\th02\pi_load.obj bin\th02\vector.obj bin\frmdely1.obj th02\main02_2.cpp bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_dlyv.obj bin\th02\snd_load.obj th02\mptn_i.cpp bin\th02\initmain.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj bin\th02\snd_dlym.obj bin\th02\snd_se.obj th02\main_03.cpp
bin\th02\main.exe: bin\th02\main.obj bin\th02\zunerror.obj th02\main02_1.cpp bin\th02\pi_load.obj bin\th02\vector.obj bin\frmdely1.obj th02\main02_2.cpp bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_dlyv.obj bin\th02\snd_load.obj th02\mptn_i.cpp bin\th02\initmain.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj bin\th02\snd_dlym.obj bin\th02\snd_se.obj th02\main_03.cpp
$(CC) $(CFLAGS) -ml -Z -DGAME=2 -nbin\th02\ -eMAIN.EXE @&&|
$**
|
bin\th02\maine.exe: bin\th02\maine.obj bin\th02\grppsafx.obj th02\maine021.cpp bin\th02\pi_load.obj bin\frmdely1.obj th02\maine022.cpp bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_load.obj bin\th02\initmain.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj bin\th02\snd_dlym.obj th02\maine_03.c th02\maine_04.cpp th02\maine_05.cpp
bin\th02\maine.exe: bin\th02\maine.obj bin\th02\grppsafx.obj th02\maine021.cpp bin\th02\pi_load.obj bin\frmdely1.obj th02\maine022.cpp bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_load.obj bin\th02\initmain.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj bin\th02\snd_dlym.obj th02\maine_03.c th02\maine_04.cpp th02\maine_05.cpp
$(CC) $(CFLAGS) -ml -3 -Z -DGAME=2 -nbin\th02\ -eMAINE.EXE @&&|
$**
|

View File

@ -368,6 +368,19 @@ static_storage db 2, 0, 6
@_STCON_$qv endp
```
## Padding bytes in code segments
- `0x00` is only emitted to word-align `switch` jump tables with `-a2`.
Anywhere else, it indicates the start or end of a word-aligned `SEGMENT`
compiled from assembly. Borland C++ never adds padding between functions or
segments.
**Certainty**: Would love to find a proper compiler or linker setting for
this, but it doesn't seem to exist. The `#pragma codestring \x00` workaround
doesn't respect different alignment requirements of surrounding translation
units, after all.
## C++
In C++ mode, the value of a `const` scalar-type variable declared at global

View File

@ -68,6 +68,7 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe
: th02_zuninit.asm |> !as |> bin\\th02\\zuninit.obj
: th02\\snd_se.asm |> !as2 |>
: th02\\snd_mmdr.asm |> !as2 |>
: th02_op.asm |> !as |> bin\\th02\\op.obj
: th02_main.asm | \
th02/sprites/pellet.asp \

View File

@ -25,6 +25,7 @@ tasm32 /m /mx /kh32768 /t th01_reiiden.asm bin\th01\reiiden.obj
tasm32 /m /mx /kh32768 /t th01_fuuin.asm bin\th01\fuuin.obj
tasm32 /m /mx /kh32768 /t th02_zuninit.asm bin\th02\zuninit.obj
tasm32 /m /mx /kh32768 /t /dGAME=2 th02\snd_se.asm bin\th02\snd_se.obj
tasm32 /m /mx /kh32768 /t /dGAME=2 th02\snd_mmdr.asm bin\th02\snd_mmdr.obj
tasm32 /m /mx /kh32768 /t th02_op.asm bin\th02\op.obj
tasm32 /m /mx /kh32768 /t th02_main.asm bin\th02\main.obj
tasm32 /m /mx /kh32768 /t th02_maine.asm bin\th02\maine.obj

View File

@ -8,14 +8,11 @@
extern "C" {
#include <dos.h>
#include "libs/kaja/kaja.h"
#include "th02/th02.h"
#include "master.hpp"
#include "th02/hardware/frmdelay.h"
#include "th02/hardware/input.hpp"
#include "th02/snd/snd.h"
#include "th02/hardware/input.c"
#include "th02/exit.c"
#include "th02/snd/mmd_res.c"
}

View File

@ -7,12 +7,10 @@
extern "C" {
#include <dos.h>
#include "libs/kaja/kaja.h"
#include "th02/th02.h"
#include "master.hpp"
#include "th02/hardware/frmdelay.h"
#include "th02/hardware/input.hpp"
#include "th02/snd/snd.h"
#include "th02/formats/pf.hpp"
#include "th02/snd/data.c"
@ -20,5 +18,4 @@ extern const char pf_fn[] = PF_FN;
#include "th02/hardware/input.c"
#include "th02/exit.c"
#include "th02/snd/mmd_res.c"
}

View File

@ -8,12 +8,10 @@
extern "C" {
#include <dos.h>
#include "libs/kaja/kaja.h"
#include "th02/th02.h"
#include "master.hpp"
#include "th02/mem.h"
#include "th02/core/initexit.h"
#include "th02/snd/snd.h"
#include "th02/formats/pf.hpp"
#include "th02/hardware/frmdelay.h"
#include "th02/hardware/input.hpp"
@ -25,8 +23,4 @@ const char pf_fn[] = PF_FN;
#include "th02/hardware/input.c"
#include "th02/core/initop.cpp"
#include "th02/exit.c"
#pragma codestring "\x00"
#include "th02/snd/mmd_res.c"
}

View File

@ -2,7 +2,7 @@ public _snd_mmd_resident
_snd_mmd_resident proc
xor ax, ax
mov es, ax
les bx, dword ptr es:[61h * 4]
les bx, dword ptr es:[MMD * 4]
assume es:nothing
cmp byte ptr es:[bx+2], 'M'
jnz short @@nope
@ -10,7 +10,7 @@ _snd_mmd_resident proc
jnz short @@nope
cmp byte ptr es:[bx+4], 'D'
jnz short @@nope
mov _snd_interrupt_if_midi, 61h
mov _snd_interrupt_if_midi, MMD
if GAME le 3
mov _snd_midi_active, 1
endif
@ -25,4 +25,4 @@ endif
xor ax, ax
ret
_snd_mmd_resident endp
nop ; word alignment
even

View File

@ -1,23 +0,0 @@
#pragma option -k-
int snd_mmd_resident(void)
{
_AX = 0;
__asm mov es, ax;
__asm les bx, dword ptr es:[MMD * 4];
__asm cmp byte ptr es:[bx+2], 'M';
__asm jnz nope;
__asm cmp byte ptr es:[bx+3], 'M';
__asm jnz nope;
__asm cmp byte ptr es:[bx+4], 'D';
__asm jnz nope;
snd_interrupt_if_midi = MMD;
snd_midi_active = 1;
snd_midi_possible = 1;
return 1;
nope:
snd_midi_possible = 0;
return 0;
}
#pragma codestring "\x90"

View File

@ -27,8 +27,10 @@ extern bool snd_midi_possible;
// check for an actual installed FM sound source is done by
// snd_determine_mode().
bool16 snd_pmd_resident(void);
#if GAME != 3
int snd_mmd_resident(void);
#if (GAME != 3)
// Returns whether the MMD driver is resident at its interrupt. If it is,
// ≤TH03 sets [snd_midi_active] to true.
bool16 snd_mmd_resident(void);
#endif
// Checks whether an FM sound source is active, and sets [snd_fm_possible]

16
th02/snd_mmdr.asm Normal file
View File

@ -0,0 +1,16 @@
.386
.model large SHARED
locals
include libs/kaja/kaja.inc
extrn _snd_interrupt_if_midi:byte
extrn _snd_midi_active:byte
extrn _snd_midi_possible:byte
SHARED segment word public 'CODE' use16
assume cs:SHARED
include th02/snd/mmd_res.asm
SHARED ends
end