[Decompilation] [th01] Blitting full-width numbers onto VRAM

Part of P0091, funded by Ember2528.
This commit is contained in:
nmlgc 2020-05-07 15:04:34 +02:00
parent 651d09f5bd
commit 4f87ec8152
9 changed files with 208 additions and 406 deletions

View File

@ -53,7 +53,7 @@ bin\th01\op.exe: bin\th01\op.obj th01\op_01.cpp th01\op_02.c th01\op_03.c th01\o
$**
|
bin\th01\reiiden.exe: bin\th01\reiiden.obj th01\main_01.cpp th01\main_02.c th01\main_03.c th01\main_04.c th01\main_05.c th01\main_06.cpp th01\main_07.cpp th01\main_08.cpp th01\main_12.c th01\main_13.c th01\main_14.c th01\main_16.c th01\main_19.cpp
bin\th01\reiiden.exe: bin\th01\reiiden.obj th01\main_01.cpp th01\main_02.c th01\main_03.c th01\main_04.c th01\main_05.c th01\main_06.cpp th01\main_07.cpp th01\main_08.cpp th01\main_12.c th01\main_13.c th01\main_14.c th01\main_16.c th01\main_19.cpp th01\main_25.cpp
$(CC) $(CFLAGS) -ml -3 -DGAME=1 -DBINARY='M' -nbin\th01\ -eREIIDEN.EXE @&&|
$**
|

View File

@ -14,6 +14,8 @@ extern "C" {
#include "th01/hardware/input.hpp"
#include "th01/hiscore/scoredat.hpp"
#include "th01/hardware/grppfnfx.cpp"
// Input
// -----
void input_sense(bool16 reset_repeat)

View File

@ -83,6 +83,17 @@ int text_extent_fx(int fx, const unsigned char *str);
// ----------------------
#include "th01/hardware/grppsafx.h"
void graph_printf_fx(int left, int top, int fx, const char *fmt, ...);
// Puts the rightmost N [digits] of [num] onto the graphics RAM, using
// full-width digits, and applying the given effect. (Consequently, the units
// place will appear at x = [left] + (([digits] - 1) * GLYPH_FULL_W).)
// Each digit is blitted separately; if [num_prev] is nonzero, the function
// only blits the digits of [num] that differ from those in [num_prev].
// Will put nothing if [put_leading_zeroes] is false and [num] is 0.
void graph_putfwnum_fx(
int left, int top, int fx, int digits,
long num, long num_prev, bool16 put_leading_zeroes
);
/// ----
/// Blitting

View File

@ -0,0 +1,35 @@
struct hack { const char* NUM[10]; }; // XXX
extern const hack FULLWIDTH_NUMBERS;
void graph_putfwnum_fx(
int left, int top, int fx, int digits, long num, long num_prev, bool16 put
)
{
int x = left;
int divisor_i;
int digit;
int digit_prev;
unsigned long divisor = 1;
const hack FW = FULLWIDTH_NUMBERS;
for(divisor_i = 0; divisor_i < digits; divisor_i++) {
divisor *= 10;
}
do {
divisor /= 10;
if(x > (RES_X - GLYPH_FULL_W)) {
return;
}
digit = ((num / divisor) % 10);
digit_prev = ((num_prev / divisor) % 10);
if(digit != 0) {
put = true;
}
if(put && ((digit != digit_prev) || !num_prev)) {
graph_putsa_fx(x, top, fx, FW.NUM[digit]);
}
x += GLYPH_FULL_W;
} while(divisor > 1);
}

View File

@ -0,0 +1,10 @@
aFW_0 db 'O',0
aFW_1 db 'P',0
aFW_2 db 'Q',0
aFW_3 db 'R',0
aFW_4 db 'S',0
aFW_5 db 'T',0
aFW_6 db 'U',0
aFW_7 db 'V',0
aFW_8 db 'W',0
aFW_9 db 'X',0

View File

@ -0,0 +1,3 @@
public _FULLWIDTH_NUMBERS
_FULLWIDTH_NUMBERS label dword
dd aFW_0, aFW_1, aFW_2, aFW_3, aFW_4, aFW_5, aFW_6, aFW_7, aFW_8, aFW_9

15
th01/main_25.cpp Normal file
View File

@ -0,0 +1,15 @@
/* ReC98
* -----
* Code segment #25 of TH01's REIIDEN.EXE
*/
#pragma option -3 -Z
extern "C" {
#include "platform.h"
#include "pc98.h"
#include "th01/hardware/grppsafx.h"
#include "th01/hardware/grppfnfx.cpp"
}

View File

@ -372,140 +372,7 @@ fuuin_01_TEXT ends
; Segment type: Pure code
fuuin_02_TEXT segment byte public 'CODE' use16
assume cs:fuuin_02_TEXT
;org 8
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_A168 proc far
var_30 = byte ptr -30h
var_8 = word ptr -8
var_6 = word ptr -6
var_4 = word ptr -4
var_2 = word ptr -2
arg_0 = word ptr 6
arg_2 = word ptr 8
arg_4 = word ptr 0Ah
arg_6 = word ptr 0Ch
arg_8 = word ptr 0Eh
arg_A = word ptr 10h
arg_C = word ptr 12h
arg_E = word ptr 14h
arg_10 = word ptr 16h
enter 30h, 0
push si
push di
mov si, [bp+arg_0]
mov [bp+var_6], 0
mov [bp+var_8], 1
lea ax, [bp+var_30]
push ss
push ax
push ds
push offset FULLWIDTH_NUMBERS
mov cx, 28h ; '('
call SCOPY@
xor di, di
jmp short loc_A1A7
; ---------------------------------------------------------------------------
loc_A190:
xor cx, cx
mov bx, 0Ah
mov dx, [bp+var_6]
mov ax, [bp+var_8]
call LXMUL@
mov [bp+var_6], dx
mov [bp+var_8], ax
inc di
loc_A1A7:
cmp di, [bp+arg_6]
jl short loc_A190
loc_A1AC:
push 0
push 0Ah
push [bp+var_6]
push [bp+var_8]
call far ptr F_LUDIV@
mov [bp+var_6], dx
mov [bp+var_8], ax
cmp si, 270h
jle short loc_A1CA
jmp loc_A261
; ---------------------------------------------------------------------------
loc_A1CA:
push 0
push 0Ah
push [bp+var_6]
push [bp+var_8]
push [bp+arg_A]
push [bp+arg_8]
call far ptr F_LUDIV@
push dx
push ax
call far ptr LUMOD@
mov [bp+var_2], ax
push 0
push 0Ah
push [bp+var_6]
push [bp+var_8]
push [bp+arg_E]
push [bp+arg_C]
call far ptr F_LUDIV@
push dx
push ax
call far ptr LUMOD@
mov [bp+var_4], ax
cmp [bp+var_2], 0
jz short loc_A213
mov [bp+arg_10], 1
loc_A213:
cmp [bp+arg_10], 0
jz short loc_A24A
mov ax, [bp+var_2]
cmp ax, [bp+var_4]
jnz short loc_A229
mov ax, [bp+arg_C]
or ax, [bp+arg_E]
jnz short loc_A24A
loc_A229:
mov bx, [bp+var_2]
shl bx, 2
lea ax, [bp+var_30]
add bx, ax
call _graph_putsa_fx c, si, [bp+arg_2], [bp+arg_4], word ptr ss:[bx], word ptr ss:[bx+2]
loc_A24A:
add si, 10h
cmp [bp+var_6], 0
jbe short loc_A256
jmp loc_A1AC
; ---------------------------------------------------------------------------
loc_A256:
jnz short loc_A261
cmp [bp+var_8], 1
jbe short loc_A261
jmp loc_A1AC
; ---------------------------------------------------------------------------
loc_A261:
pop di
pop si
leave
retf
sub_A168 endp
extern _graph_putfwnum_fx:proc
extern _input_sense:proc
extern _input_reset_sense:proc
extern _scoredat_name_byte_encode:proc
@ -768,7 +635,6 @@ sub_A801 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_A9FF proc far
var_12 = byte ptr -12h
@ -1020,9 +886,9 @@ loc_AB77:
push 144
call _graph_putsa_fx
add sp, 0Ah
push 0
push 0
push 0
push 0 ; put_leading_zeroes
push 0 ; num_prev (high)
push 0 ; num_prev (low)
cmp di, si
jnz short loc_ABA1
mov dx, [bp+arg_4]
@ -1039,9 +905,9 @@ loc_ABA1:
mov ax, es:[bx]
loc_ABB3:
push dx
push ax
push 7
push dx ; num (high)
push ax ; num (low)
push 7 ; digits
cmp si, di
jnz short loc_ABC0
mov ax, 3
@ -1053,13 +919,13 @@ loc_ABC0:
loc_ABC3:
or ax, 30h
push ax
push ax ; fx
mov ax, si
shl ax, 4
add ax, 40h
push ax
push 160h
call fuuin_02:sub_A168
add ax, 64
push ax ; top
push 352 ; left
call fuuin_02:_graph_putfwnum_fx
add sp, 12h
cmp si, di
jz short loc_ABEE
@ -1077,9 +943,9 @@ loc_ABEE:
jge short loc_AC3F
loc_ABF8:
push 0
push 0
push 0
push 0 ; put_leading_zeroes
push 0 ; num_prev (high)
push 0 ; num_prev (low)
cmp si, di
jnz short loc_AC07
mov ax, [bp+arg_6]
@ -1095,9 +961,9 @@ loc_AC07:
loc_AC14:
cwd
push dx
push ax
push 2
push dx ; num (high)
push ax ; num (low)
push 2 ; digits
cmp si, di
jnz short loc_AC22
mov ax, 3
@ -1109,13 +975,13 @@ loc_AC22:
loc_AC25:
or ax, 20h
push ax
push ax ; fx
mov ax, si
shl ax, 4
add ax, 40h
push ax
push 210h
call fuuin_02:sub_A168
add ax, 64
push ax ; top
push 528 ; left
call fuuin_02:_graph_putfwnum_fx
add sp, 12h
jmp loc_ACCD
; ---------------------------------------------------------------------------
@ -4373,44 +4239,43 @@ arg0 db 'op',0
db 0
include th01/hardware/input_main_end[data].asm
dd 0
db 49h ; I
db 81h
db 48h ; H
db 81h
db 94h
db 81h
db 95h
db 81h
db 96h
db 81h
db 98h
db 81h
db 99h
db 81h
db 9Fh
db 81h
db 87h
db 81h
db 88h
db 81h
db 89h
db 81h
db 8Ah
db 81h
db 63h ; c
db 81h
db 67h ; g
db 81h
db 68h ; h
db 81h
db 5Eh ; ^
db 81h
db 44h ; D
db 81h
db 45h ; E
db 81h
FULLWIDTH_NUMBERS dd aFW_0, aFW_1, aFW_2, aFW_3, aFW_4
dd aFW_5, aFW_6, aFW_7, aFW_8, aFW_9
db 49h ; I
db 81h
db 48h ; H
db 81h
db 94h
db 81h
db 95h
db 81h
db 96h
db 81h
db 98h
db 81h
db 99h
db 81h
db 9Fh
db 81h
db 87h
db 81h
db 88h
db 81h
db 89h
db 81h
db 8Ah
db 81h
db 63h ; c
db 81h
db 67h ; g
db 81h
db 68h ; h
db 81h
db 5Eh ; ^
db 81h
db 44h ; D
db 81h
db 45h ; E
db 81h
include th01/hardware/grppfnfx_ptrs[data].asm
aBqbqbqbqbqbqbq db '________',0
aB@b@b@b@b@b@b@ db '        ',0
aHiscore_0 db 'HISCORE',0
@ -4419,16 +4284,7 @@ off_12C1E dd aB@gcbGwbB@
dd aB@gmbGGlb@ ; " ノーマル "
dd aB@gnbGhb@b@ ; " ハード  "
dd aGlgigegbgbgn ; "ルナティック"
aFW_0 db 'O',0
aFW_1 db 'P',0
aFW_2 db 'Q',0
aFW_3 db 'R',0
aFW_4 db 'S',0
aFW_5 db 'T',0
aFW_6 db 'U',0
aFW_7 db 'V',0
aFW_8 db 'W',0
aFW_9 db 'X',0
include th01/hardware/grppfnfx[data].asm
include th01/hiscore/scorelod[data].asm
; char aCC[]
aCC db '%c%c',0

View File

@ -69,6 +69,7 @@ include th01/th01.inc
main_01 group main_01_TEXT, main_01__TEXT
main_19 group main_19_TEXT, main_19__TEXT
main_25 group main_25_TEXT, main_25__TEXT
; ===========================================================================
@ -8849,8 +8850,8 @@ loc_13EFC:
push 144
call _graph_putsa_fx
add sp, 0Ah
push 0
pushd 0
push 0 ; put_leading_zeroes
pushd 0 ; num_prev
cmp [bp+arg_0], si
jnz short loc_13F22
mov eax, [bp+arg_2]
@ -8865,14 +8866,14 @@ loc_13F22:
mov eax, es:[bx]
loc_13F31:
push eax
push 7
push eax ; num
push 7 ; digits
mov ax, di
or ax, 30h
push ax
push [bp+@@top]
push 160h
call sub_18589
push ax ; fx
push [bp+@@top] ; top
push 352 ; left
call _graph_putfwnum_fx
add sp, 12h
cmp si, [bp+arg_0]
jz short loc_13F5E
@ -8890,8 +8891,8 @@ loc_13F5E:
jge short loc_13FA1
loc_13F69:
push 0
pushd 0
push 0 ; put_leading_zeroes
pushd 0 ; num_prev
cmp si, [bp+arg_0]
jnz short loc_13F78
mov ax, [bp+arg_6]
@ -8907,14 +8908,14 @@ loc_13F78:
loc_13F85:
cwde
push eax
push 2
push eax ; num
push 2 ; digits
mov ax, di
or ax, 20h
push ax
push [bp+@@top]
push 210h
call sub_18589
push ax ; fx
push [bp+@@top] ; top
push 528 ; left
call _graph_putfwnum_fx
add sp, 12h
jmp short loc_13FFF
; ---------------------------------------------------------------------------
@ -16895,108 +16896,14 @@ main_24_TEXT ends
; Segment type: Pure code
main_25_TEXT segment byte public 'CODE' use16
assume cs:main_25_TEXT
extern _graph_putfwnum_fx:proc
main_25_TEXT ends
main_25__TEXT segment byte public 'CODE' use16
assume cs:main_25
;org 9
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_18589 proc far
var_30 = byte ptr -30h
var_8 = dword ptr -8
var_4 = word ptr -4
var_2 = word ptr -2
@@left = word ptr 6
@@top = word ptr 8
@@fx = word ptr 0Ah
arg_6 = word ptr 0Ch
arg_8 = dword ptr 0Eh
arg_C = dword ptr 12h
arg_10 = word ptr 16h
enter 30h, 0
push si
push di
mov si, [bp+@@left]
mov [bp+var_8], 1
lea ax, [bp+var_30]
push ss
push ax
push ds
push offset off_35A97
mov cx, 28h ; '('
call SCOPY@
xor di, di
jmp short loc_185BC
; ---------------------------------------------------------------------------
loc_185AF:
mov eax, [bp+var_8]
imul eax, 0Ah
mov [bp+var_8], eax
inc di
loc_185BC:
cmp di, [bp+arg_6]
jl short loc_185AF
loc_185C1:
mov ebx, 0Ah
mov eax, [bp+var_8]
xor edx, edx
div ebx
mov [bp+var_8], eax
cmp si, (RES_X - GLYPH_FULL_W)
jg short loc_18653
mov eax, [bp+arg_8]
xor edx, edx
div [bp+var_8]
mov ebx, 0Ah
xor edx, edx
div ebx
mov [bp+var_2], dx
mov eax, [bp+arg_C]
xor edx, edx
div [bp+var_8]
xor edx, edx
div ebx
mov [bp+var_4], dx
cmp [bp+var_2], 0
jz short loc_18614
mov [bp+arg_10], 1
loc_18614:
cmp [bp+arg_10], 0
jz short loc_18647
mov ax, [bp+var_2]
cmp ax, [bp+var_4]
jnz short loc_18629
cmp [bp+arg_C], 0
jnz short loc_18647
loc_18629:
mov bx, [bp+var_2]
shl bx, 2
lea ax, [bp+var_30]
add bx, ax
call _graph_putsa_fx c, si, [bp+@@top], [bp+@@fx], large dword ptr ss:[bx]
loc_18647:
add si, 10h
cmp [bp+var_8], 1
ja loc_185C1
loc_18653:
pop di
pop si
leave
retf
sub_18589 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
@ -17093,7 +17000,7 @@ loc_18723:
push 1
call _graph_accesspage_func
pop cx
push 1
push 1 ; put_leading_zeroes
cmp byte_35A96, 1
jnz short loc_18740
xor eax, eax
@ -17104,16 +17011,16 @@ loc_18740:
mov eax, dword_35ABF
loc_18744:
push eax
pushd [_score]
push 70027h
pushd 100h
call sub_18589
push eax ; num_prev
pushd [_score] ; num
push (7 shl 16) or 27h ; (digits) or (fx)
pushd (0 shl 16) or 256 ; (top) or (left)
call _graph_putfwnum_fx
add sp, 12h
push 0
call _graph_accesspage_func
pop cx
push 1
push 1 ; put_leading_zeroes
cmp byte_35A96, 1
jnz short loc_18774
xor eax, eax
@ -17124,11 +17031,11 @@ loc_18774:
mov eax, dword_35ABF
loc_18778:
push eax
pushd [_score]
push 70027h
pushd 100h
call sub_18589
push eax ; num_prev
pushd [_score] ; num
push (7 shl 16) or 27h ; (digits) or (fx)
pushd (0 shl 16) or 256 ; (top) or (left)
call _graph_putfwnum_fx
add sp, 12h
mov eax, _score
mov dword_35ABF, eax
@ -17213,7 +17120,7 @@ loc_1881F:
push 1
call _graph_accesspage_func
pop cx
push 1
push 1 ; put_leading_zeroes
cmp byte_35A96, 1
jnz short loc_18839
xor ax, ax
@ -17225,17 +17132,17 @@ loc_18839:
loc_1883C:
cwde
push eax
push eax ; num_prev
movsx eax, word_34A84
push eax
push 20027h
pushd 190h
call sub_18589
push eax ; num
push (2 shl 16) or 27h ; (digits) or (fx)
pushd (0 shl 16) or 400 ; (top) or (left)
call _graph_putfwnum_fx
add sp, 12h
push 0
call _graph_accesspage_func
pop cx
push 1
push 1 ; put_leading_zeroes
cmp byte_35A96, 1
jnz short loc_18870
xor ax, ax
@ -17247,12 +17154,12 @@ loc_18870:
loc_18873:
cwde
push eax
push eax ; num_prev
movsx eax, word_34A84
push eax
push 20027h
pushd 190h
call sub_18589
push eax ; num
push (2 shl 16) or 27h ; (digits) or (fx)
pushd (0 shl 16) or 400 ; (top) or (left)
call _graph_putfwnum_fx
add sp, 12h
mov ax, word_34A84
mov word_39DA4, ax
@ -17340,7 +17247,7 @@ loc_18928:
loc_1893C:
cmp si, 7
jl short loc_188CD
push 1
push 1 ; put_leading_zeroes
cmp byte_35A96, 1
jnz short loc_1894F
xor eax, eax
@ -17351,11 +17258,11 @@ loc_1894F:
mov eax, dword_39DA6
loc_18953:
push eax
pushd [_score]
push 70037h
push 100100h
call sub_18589
push eax ; num_prev
pushd [_score] ; num
push (7 shl 16) or 37h ; (digits) or (fx)
push (16 shl 16) or 256 ; (top) or (left)
call _graph_putfwnum_fx
add sp, 12h
xor si, si
jmp short loc_189B6
@ -17401,7 +17308,7 @@ loc_189AB:
loc_189B6:
cmp si, 2
jl short loc_18971
push 1
push 1 ; put_leading_zeroes
cmp byte_35A96, 1
jnz short loc_189C8
xor ax, ax
@ -17413,12 +17320,12 @@ loc_189C8:
loc_189CB:
cwde
push eax
push eax ; num_prev
movsx eax, word_34A84
push eax
push 20037h
push 100190h
call sub_18589
push eax ; num
push (2 shl 16) or 37h ; (digits) or (fx)
push (16 shl 16) or 400 ; (top) or (left)
call _graph_putfwnum_fx
add sp, 12h
dec [bp+var_2]
@ -17494,13 +17401,7 @@ loc_18A60:
push 0
call _graph_accesspage_func
pop cx
push 1
pushd 0
pushd [_score]
push 70037h
push 100100h
call sub_18589
add sp, 12h
call _graph_putfwnum_fx c, large (16 shl 16) or 256, large (7 shl 16) or 37h, large [_score], large 0, 1
push 1
call _graph_accesspage_func
pop cx
@ -17549,13 +17450,7 @@ loc_18AD8:
push 0
call _graph_accesspage_func
pop cx
push 1
pushd 63h ; 'c'
pushd 0
push 20037h
push 100190h
call sub_18589
add sp, 12h
call _graph_putfwnum_fx c, large (16 shl 16) or 400, large (2 shl 16) or 37h, large 0, large 99, 1
or di, di
jz loc_18B95
push 1
@ -17591,13 +17486,13 @@ loc_18B33:
push 0
call _graph_accesspage_func
pop cx
push 1
pushd 0
push 1 ; put_leading_zeroes
pushd 0 ; num_prev
les bx, _resident
pushd dword ptr es:[bx+reiidenconfig_t.hiscore]
push 70027h
pushd 100h
call sub_18589
pushd dword ptr es:[bx+reiidenconfig_t.hiscore] ; num
push (7 shl 16) or 27h ; (digits) or (fx)
pushd (0 shl 16) or 256 ; (top) or (left)
call _graph_putfwnum_fx
add sp, 12h
push 1
call _graph_accesspage_func
@ -17647,13 +17542,7 @@ loc_18BB2:
jl short loc_18B99
loc_18BB7:
push 1
pushd 63h ; 'c'
pushd 0
push 20027h
pushd 190h
call sub_18589
add sp, 12h
call _graph_putfwnum_fx c, large (0 shl 16) or 400, large (2 shl 16) or 27h, large 0, large 99, 1
push 0B00000h
push 100h
nopcall sub_18CD3
@ -18475,7 +18364,7 @@ loc_19229:
retf
sub_190D6 endp
main_25_TEXT ends
main_25__TEXT ends
; ===========================================================================
@ -61274,28 +61163,9 @@ aExtend db 'Extend!!',0
aVpf db 'PäÝ',0
db 0
byte_35A96 db 0
off_35A97 dd aVo_0
; "O"
dd aVp_0 ; "P"
dd aVq_0 ; "Q"
dd aVr_0 ; "R"
dd aVs_0 ; "S"
dd aVt_0 ; "T"
dd aVu_0 ; "U"
dd aVv_0 ; "V"
dd aVw_0 ; "W"
dd aVx_0 ; "X"
include th01/hardware/grppfnfx_ptrs[data].asm
dword_35ABF dd 0
aVo_0 db 'O',0
aVp_0 db 'P',0
aVq_0 db 'Q',0
aVr_0 db 'R',0
aVs_0 db 'S',0
aVt_0 db 'T',0
aVu_0 db 'U',0
aVv_0 db 'V',0
aVw_0 db 'W',0
aVx_0 db 'X',0
include th01/hardware/grppfnfx[data].asm
db 0
db 0E8h
db 3