[Separate translation units] [th05] pi_free() (undecompilable)

Well, it *would* have been decompilable, but that ridiculous placement
of the nullptr assignment would have forced the entire function call to
be spelled out in inline ASM, verbatim. No amount of comma operator
trickery would have generated the same instructions either. And for a
function this small and obvious in what its decompilation *should* be,
it really defeated the purpose of adding a separate translation unit…

Part of P0134, funded by [Anonymous].
This commit is contained in:
nmlgc 2021-02-12 17:39:51 +01:00
parent 0d66e748d1
commit 2777bae55b
10 changed files with 53 additions and 26 deletions

View File

@ -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 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\th05\op.exe: th05\op010.cpp bin\th05\op.obj th05\op011.cpp th05\m_char.cpp 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
$(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\initmain.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\snd_dlym.obj 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\pi_asm_2.obj bin\th05\initmain.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj 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 @&&|
$**
|

View File

@ -109,6 +109,7 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe
: th05\\player.asm |> !as5 |>
: th05\\hud_bar.asm |> !as5 |>
: th05\\bullet.asm |> !as5 |>
: th05\\pi_asm_2.asm |> !as5 |>
: th05_op.asm | \
th05/sprites/piano_l.asp \
|> !as |> bin\\th05\\op.obj

View File

@ -50,6 +50,7 @@ tasm32 /m /mx /kh32768 /t /dGAME=5 th04\scoreupd.asm bin\th05\scoreupd.obj
tasm32 /m /mx /kh32768 /t /dGAME=5 th05\player.asm bin\th05\player.obj
tasm32 /m /mx /kh32768 /t /dGAME=5 th05\hud_bar.asm bin\th05\hud_bar.obj
tasm32 /m /mx /kh32768 /t /dGAME=5 th05\bullet.asm bin\th05\bullet.obj
tasm32 /m /mx /kh32768 /t /dGAME=5 th05\pi_asm_2.asm bin\th05\pi_asm_2.obj
tasm32 /m /mx /kh32768 /t th05_op.asm bin\th05\op.obj
tasm32 /m /mx /kh32768 /t th05_main.asm bin\th05\main.obj
tasm32 /m /mx /kh32768 /t th05_maine.asm bin\th05\maine.obj

View File

@ -7,3 +7,6 @@ include libs/master.lib/macros.inc
GAIJI_PUTSA procdesc pascal far \
x:word, y:word, strp_seg:word, strp_off:word, atrb:word
GRAPH_PI_FREE procdesc pascal far \
header:far ptr, image:far ptr
PALETTE_SHOW procdesc pascal far

View File

@ -1,7 +1,7 @@
#include "th03/formats/pi.h"
#undef pi_free
int pascal pi_free(int slot);
void pascal pi_free(int slot);
// Like pi_put_8() and pi_put_quarter_8(), but applying the mask with the given
// ID while blitting.

42
th05/formats/pi_asm_2.asm Normal file
View File

@ -0,0 +1,42 @@
; Second TH05 .PI assembly translation unit.
.386
.model large
locals
include pc98.inc
include libs/master.lib/func.inc
include libs/master.lib/master.inc
include th03/arg_bx.inc
extrn _pi_headers:PiHeader
extrn _pi_buffers:far ptr
SHARED_ segment word public 'CODE' use16
assume cs:SHARED_
public PI_FREE
func pi_free
arg_bx far, @slot:word
mov bx, @slot
mov ax, bx
shl bx, 2
add bx, offset _pi_buffers
cmp dword ptr [bx], 0
jz short @@ret
imul ax, size PiHeader
add ax, offset _pi_headers
push ds
push ax
push word ptr [bx+2]
push word ptr [bx]
mov dword ptr [bx], 0
call graph_pi_free
@@ret:
ret 2
endfunc
SHARED_ ends
end

View File

@ -1,21 +0,0 @@
public PI_FREE
func pi_free
arg_bx far, @slot:word
mov bx, @slot
mov ax, bx
shl bx, 2
add bx, offset _pi_buffers
cmp dword ptr [bx], 0
jz short @@ret
imul ax, size PiHeader
add ax, offset _pi_headers
push ds
push ax
push word ptr [bx+2]
push word ptr [bx]
mov dword ptr [bx], 0
call graph_pi_free
@@ret:
ret_bx
endfunc

1
th05/pi_asm_2.asm Normal file
View File

@ -0,0 +1 @@
include th05/formats/pi_asm_2.asm

View File

@ -7542,7 +7542,7 @@ include th05/formats/pi_put_masked.asm
include th05/formats/pi_load.asm
include th05/formats/pi_put.asm
include th05/formats/pi_palette_apply.asm
include th05/formats/pi_free.asm
extern PI_FREE:proc
extern GAME_INIT_MAIN:proc
extern _input_reset_sense_held:proc
extern INPUT_WAIT_FOR_CHANGE:proc

View File

@ -2547,7 +2547,7 @@ include th05/formats/pi_put_masked.asm
include th05/formats/pi_load.asm
include th05/formats/pi_put.asm
include th05/formats/pi_palette_apply.asm
include th05/formats/pi_free.asm
extern PI_FREE:proc
extern _game_init_op:proc
extern _input_reset_sense_held:proc
extern INPUT_WAIT_FOR_CHANGE:proc