[Separate translation units] [th04/th05] Low-level input (undecompilable)

Reason: Manual "tail call optimization" of input_reset_sense(), with
execution falling through to input_sense() immediately below.

Part of P0133, funded by [Anonymous].
This commit is contained in:
nmlgc 2021-01-18 20:47:07 +01:00
parent 53d3a6fb73
commit e4eed85c44
12 changed files with 175 additions and 30 deletions

View File

@ -150,17 +150,17 @@ 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\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\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 @&&|
$**
|
bin\th05\main.exe: bin\th05\main.obj th05\main010.cpp th05\main011.cpp th05\p_common.cpp th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\main012.cpp th05\main013.cpp bin\hfliplut.obj bin\th05\bullet.obj bin\th05\inp_h_w.obj bin\th05\frmdelay.obj bin\th04\cdg_load.obj th05\main031.cpp th05\main032.cpp th05\main033.cpp th05\main034.cpp
bin\th05\main.exe: bin\th05\main.obj th05\main010.cpp th05\main011.cpp th05\p_common.cpp th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\main012.cpp th05\main013.cpp bin\hfliplut.obj bin\th05\bullet.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\frmdelay.obj bin\th04\cdg_load.obj th05\main031.cpp th05\main032.cpp th05\main033.cpp th05\main034.cpp
$(CC) $(CFLAGS) -ml -3 -Z -DGAME=5 -DBINARY='M' -nbin\th05\ -eMAIN.EXE @&&|
$**
|
bin\th05\maine.exe: bin\th05\maine.obj th05\maine011.cpp th05\regist.cpp th05\staff.cpp 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\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

@ -103,6 +103,7 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe
th05/sprites/gaiji.asp \
|> !as |> bin\\th05\\gjinit.obj
: th05_memchk.asm |> !as |> bin\\th05\\memchk.obj
: th04\\input_s.asm |> $(AS) /dGAME=5 th04\%b %o |> bin\\th05\\%B.obj
: th04\\scoreupd.asm |> $(AS) /dGAME=5 th04\%b %o |> bin\\th05\\%B.obj
: th05\\player.asm |> !as5 |>
: th05\\hud_bar.asm |> !as5 |>

View File

@ -44,6 +44,7 @@ tasm32 /m /mx /kh32768 /t th04_maine.asm bin\th04\maine.obj
tasm32 /m /mx /kh32768 /t th05_zuninit.asm bin\th05\zuninit.obj
tasm32 /m /mx /kh32768 /t th05_gjinit.asm bin\th05\gjinit.obj
tasm32 /m /mx /kh32768 /t th05_memchk.asm bin\th05\memchk.obj
tasm32 /m /mx /kh32768 /t /dGAME=5 th04\input_s.asm bin\th05\input_s.obj
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

View File

@ -14,3 +14,127 @@ KEYGROUP_11 = 535h
KEYGROUP_12 = 536h
KEYGROUP_13 = 537h
KEYGROUP_14 = 538h
K0_ESC = 01h
K0_1 = 02h
K0_2 = 04h
K0_3 = 08h
K0_4 = 10h
K0_5 = 20h
K0_6 = 40h
K0_7 = 80h
K1_8 = 01h
K1_9 = 02h
K1_0 = 04h
K1_MINUS = 08h
K1_CIRCUMFLEX = 10h
K1_YEN = 20h
K1_BACKSPACE = 40h
K1_TAB = 80h
K2_Q = 01h
K2_W = 02h
K2_E = 04h
K2_R = 08h
K2_T = 10h
K2_Y = 20h
K2_U = 40h
K2_I = 80h
K3_O = 01h
K3_P = 02h
K3_AT = 04h
K3_LBRACKET = 08h
K3_RETURN = 10h
K3_A = 20h
K3_S = 40h
K3_D = 80h
K4_F = 01h
K4_G = 02h
K4_H = 04h
K4_J = 08h
K4_K = 10h
K4_L = 20h
K4_PLUS = 40h
K4_ASTERISK = 80h
K5_RBRACKET = 01h
K5_Z = 02h
K5_X = 04h
K5_C = 08h
K5_V = 10h
K5_B = 20h
K5_N = 40h
K5_M = 80h
K6_COMMA = 01h
K6_PERIOD = 02h
K6_SLASH = 04h
K6_UNDERSCORE = 08h
K6_SPACE = 10h
K6_XFER = 20h
K6_ROLL_UP = 40h
K6_ROLL_DOWN = 80h
K7_INS = 01h
K7_DEL = 02h
K7_ARROW_UP = 04h
K7_ARROW_LEFT = 08h
K7_ARROW_RIGHT = 10h
K7_ARROW_DOWN = 20h
K7_HOME_CLR = 40h
K7_END = 80h
K8_NUM_MINUS = 01h
K8_NUM_DIV = 02h
K8_NUM_7 = 04h
K8_NUM_8 = 08h
K8_NUM_9 = 10h
K8_NUM_MUL = 20h
K8_NUM_4 = 40h
K8_NUM_5 = 80h
K9_NUM_6 = 01h
K9_NUM_PLUS = 02h
K9_NUM_1 = 04h
K9_NUM_2 = 08h
K9_NUM_3 = 10h
K9_NUM_EQUALS = 20h
K9_NUM_0 = 40h
K9_NUM_COMMA = 80h
K10_NUM_PERIOD = 01h
K10_NFER = 02h
K10_VF1 = 04h
K10_VF2 = 08h
K10_VF3 = 10h
K10_VF4 = 20h
K10_VF5 = 40h
K11_NUM = 02h
K11_SYMBOL_SHIFT = 04h
K11_VOWEL_SHIFT = 08h
K11_CONSONANT_SHIFT = 10h
K11_HOME = 40h
K12_STOP = 01h
K12_COPY = 02h
K12_F1 = 04h
K12_F2 = 08h
K12_F3 = 10h
K12_F4 = 20h
K12_F5 = 40h
K12_F6 = 80h
K13_F7 = 01h
K13_F8 = 02h
K13_F9 = 04h
K13_F10 = 08h
K14_SHIFT = 01h
K14_CAPS = 02h
K14_KANA = 04h
K14_GRPH = 08h
K14_CTRL = 10h

View File

@ -18,109 +18,109 @@ else
endif
public _input_reset_sense
_input_reset_sense label proc
_input_reset_sense label proc
xor ax, ax
mov _key_det, ax
mov js_stat, ax
public _input_sense
_input_sense proc far
_input_sense proc far
xor ax, ax
mov es, ax
mov ah, byte ptr es:[KEYGROUP_7]
test ah, 4
test ah, K7_ARROW_UP
jz short @@down?
OR_INPUT_LOW INPUT_UP
@@down?:
test ah, 20h
test ah, K7_ARROW_DOWN
jz short @@left?
OR_INPUT_LOW INPUT_DOWN
@@left?:
test ah, 8
test ah, K7_ARROW_LEFT
jz short @@right?
OR_INPUT_LOW INPUT_LEFT
@@right?:
test ah, 10h
test ah, K7_ARROW_RIGHT
jz short @@num6?
OR_INPUT_LOW INPUT_RIGHT
@@num6?:
mov ah, byte ptr es:[KEYGROUP_9]
test ah, 1
test ah, K9_NUM_6
jz short @@num1?
OR_INPUT_LOW INPUT_RIGHT
@@num1?:
test ah, 4
test ah, K9_NUM_1
jz short @@num2?
OR_INPUT_HIGH INPUT_DOWN_LEFT
@@num2?:
test ah, 8
test ah, K9_NUM_2
jz short @@num3?
OR_INPUT_LOW INPUT_DOWN
@@num3?:
test ah, 10h
test ah, K9_NUM_3
jz short @@num4?
OR_INPUT_HIGH INPUT_DOWN_RIGHT
@@num4?:
mov ah, byte ptr es:[KEYGROUP_8]
test ah, 40h
test ah, K8_NUM_4
jz short @@num7?
OR_INPUT_LOW INPUT_LEFT
@@num7?:
test ah, 4
test ah, K8_NUM_7
jz short @@num8?
OR_INPUT_HIGH INPUT_UP_LEFT
@@num8?:
test ah, 8
test ah, K8_NUM_8
jz short @@num9?
OR_INPUT_LOW INPUT_UP
@@num9?:
test ah, 10h
test ah, K8_NUM_9
jz short @@z?
OR_INPUT_HIGH INPUT_UP_RIGHT
@@z?:
mov ah, byte ptr es:[KEYGROUP_5]
test ah, 2
test ah, K5_Z
jz short @@x?
OR_INPUT_LOW INPUT_SHOT
@@x?:
test ah, 4
test ah, K5_X
jz short @@q?
OR_INPUT_LOW INPUT_BOMB
@@q?:
mov ah, byte ptr es:[KEYGROUP_2]
test ah, 1
test ah, K2_Q
jz short @@esc?
OR_INPUT_HIGH INPUT_Q
@@esc?:
mov ah, byte ptr es:[KEYGROUP_0]
test ah, 1
test ah, K0_ESC
jz short @@return?
OR_INPUT_HIGH INPUT_CANCEL
@@return?:
mov ah, byte ptr es:[KEYGROUP_3]
test ah, 10h
test ah, K3_RETURN
jz short @@space?
OR_INPUT_HIGH INPUT_OK
@@space?:
mov ah, byte ptr es:[KEYGROUP_6]
test ah, 10h
test ah, K6_SPACE
jz short @@shift?
OR_INPUT_LOW INPUT_SHOT
@ -139,5 +139,5 @@ if GAME eq 5
mov ax, _key_det
endif
retf
_input_sense endp
_input_sense endp
even

20
th04/input_s.asm Normal file
View File

@ -0,0 +1,20 @@
.386
.model large SHARED_
locals
include twobyte.inc
include th04/hardware/input.inc
extrn _key_det:word
extrn _shiftkey:byte
extrn js_stat:word
extrn js_bexist:word
extrn JS_SENSE:proc
SHARED_ segment word public 'CODE' use16
assume cs:SHARED_
include th04/hardware/input_s.asm
SHARED_ ends
end

View File

@ -13133,7 +13133,7 @@ include th02/initmain.asm
include th04/formats/cdg_put_noalpha.asm
include th04/formats/cdg_put_plane_roll.asm
include th04/hardware/input_sense.asm
include th04/hardware/input_s.asm
include th04/snd/se.asm
extern CDG_LOAD_SINGLE_NOALPHA:proc
extern CDG_LOAD_ALL:proc

View File

@ -4613,7 +4613,7 @@ include th04/formats/cdg_put.asm
include th02/exit.asm
include th02/initmain.asm
db 0
include th04/hardware/input_sense.asm
include th04/hardware/input_s.asm
include th04/snd/se.asm
include th04/bgimage.asm
include th04/bgimage_put_rect.asm

View File

@ -2664,7 +2664,7 @@ include th02/exit.asm
include th02/initop.asm
db 0
include th04/formats/cdg_put_noalpha.asm
include th04/hardware/input_sense.asm
include th04/hardware/input_s.asm
include th04/snd/se.asm
include th04/hardware/egcrect.asm
include th04/bgimage.asm

View File

@ -10564,7 +10564,8 @@ include th04/math/vector2_at.asm
include th05/snd/load.asm
include th05/snd/kajaint.asm
include th02/initmain.asm
include th04/hardware/input_sense.asm
extern _input_reset_sense:proc
extern _input_sense:proc
extern _input_reset_sense_held:proc
extern INPUT_WAIT_FOR_CHANGE:proc
extern FRAME_DELAY:proc

View File

@ -7544,7 +7544,6 @@ include th05/formats/pi_put.asm
include th05/formats/pi_palette_apply.asm
include th05/formats/pi_free.asm
include th02/initmain.asm
include th04/hardware/input_sense.asm
extern _input_reset_sense_held:proc
extern INPUT_WAIT_FOR_CHANGE:proc
extern _snd_bgm_measure:proc

View File

@ -2549,7 +2549,6 @@ include th05/formats/pi_put.asm
include th05/formats/pi_palette_apply.asm
include th05/formats/pi_free.asm
include th02/initop.asm
include th04/hardware/input_sense.asm
extern _input_reset_sense_held:proc
extern INPUT_WAIT_FOR_CHANGE:proc
extern SND_DELAY_UNTIL_MEASURE:proc