Skip to content

Commit

Permalink
[th04/memchk] Initial state
Browse files Browse the repository at this point in the history
Needlessly linked with TCC rather than TLINK, adding almost 4 KB of
completely unnecessary libc startup code.

Or maybe not, since ZUN doesn't free the allocated memory himself, but
relies on libc to do that?

Part of P0117, funded by [Anonymous].
  • Loading branch information
nmlgc committed Sep 16, 2020
1 parent 197202d commit 90b7ace
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Makefile.mak
Expand Up @@ -9,7 +9,7 @@ PIPELINE = \grzview.com
TH01 = \zunsoft.com \op.exe \reiiden.exe \fuuin.exe
TH02 = \zuninit.com \zun_res.com \op.exe \main.exe \maine.exe \zun.com
TH03 = \zunsp.com \res_yume.com \op.exe \main.exe \mainl.exe \zun.com
TH04 = \zuninit.com \res_huma.com \op.exe \main.exe \maine.exe
TH04 = \zuninit.com \memchk.com \res_huma.com \op.exe \main.exe \maine.exe
TH05 = \zuninit.com \res_kso.com \op.exe \main.exe \maine.exe

all: pipeline th01 th02 th03 th04 th05
Expand Down Expand Up @@ -109,6 +109,9 @@ bin\th03\mainl.exe: bin\th03\mainl.obj bin\th03\inp_m_w.obj bin\th03\cdg_p_na.ob
$**
|

bin\th04\memchk.com: bin\th04\memchk.obj
$(CC) $(CFLAGS) -mt -lt $**

bin\th04\res_huma.com: th04\res_huma.cpp
$(CC) $(CFLAGS) -mt -lt -Z -DGAME=4 -nbin\th04\ -eRES_HUMA.COM @&&|
$**
Expand Down
1 change: 1 addition & 0 deletions Tupfile
Expand Up @@ -72,6 +72,7 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe
: th03_mainl.asm |> !as |> bin\\th03\\mainl.obj

: th04_zuninit.asm |> !as |> bin\\th04\\zuninit.obj
: th04_memchk.asm |> !as |> bin\\th04\\memchk.obj
: th04\\scoreupd.asm |> !as4 |>
: th04_op.asm |> !as |> bin\\th04\\op.obj
: th04_main.asm | \
Expand Down
1 change: 1 addition & 0 deletions Tupfile.bat
Expand Up @@ -30,6 +30,7 @@ tasm32 /m /mx /kh32768 /t th03_op.asm bin\th03\op.obj
tasm32 /m /mx /kh32768 /t th03_main.asm bin\th03\main.obj
tasm32 /m /mx /kh32768 /t th03_mainl.asm bin\th03\mainl.obj
tasm32 /m /mx /kh32768 /t th04_zuninit.asm bin\th04\zuninit.obj
tasm32 /m /mx /kh32768 /t th04_memchk.asm bin\th04\memchk.obj
tasm32 /m /mx /kh32768 /t /dGAME=4 th04\scoreupd.asm bin\th04\scoreupd.obj
tasm32 /m /mx /kh32768 /t th04_op.asm bin\th04\op.obj
tasm32 /m /mx /kh32768 /t th04_main.asm bin\th04\main.obj
Expand Down
118 changes: 118 additions & 0 deletions th04_memchk.asm
@@ -0,0 +1,118 @@
;
; +-------------------------------------------------------------------------+
; | This file has been generated by The Interactive Disassembler (IDA) |
; | Copyright (c) 2009 by Hex-Rays, <support@hex-rays.com> |
; +-------------------------------------------------------------------------+
;
; Input MD5 : 9466D867385BD4CC0A6FD3E3D4E9FB01

; File Name : th04/ZUN.COM:MEMCHK (-M)
; Format : MS-DOS COM-file
; Base Address: 0h Range: 100h-10E2h Loaded length: FE2h
; OS type : MS DOS
; Application type: Executable 16bit

.286

DGROUP group _TEXT, _DATA

_TEXT segment byte 'CODE' use16
assume cs:_TEXT

; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame

; int __cdecl main(int argc, const char **argv, const char **envp)
public _main
_main proc near

var_2 = word ptr -2
argc = word ptr 4
argv = word ptr 6
envp = word ptr 8

enter 2, 0
call sub_3B6
mov [bp+var_2], ax
push offset DGROUP:asc_E8E ; "空きメインメモリチェック\n\n"
call sub_38E
cmp [bp+var_2], 7530h
ja short loc_389
push offset DGROUP:aVVxvVSlvsvVvvi ; "ちょっと足りないかも、もう少し増やして"...
call sub_38E
mov ax, 0FFh
leave
retn
; ---------------------------------------------------------------------------

loc_389:
xor ax, ax
leave
retn
_main endp
db 0

; =============== S U B R O U T I N E =======================================


sub_38E proc near
mov bx, sp
mov cx, si
mov si, ss:[bx+2]
lodsb
or al, al
jz short loc_3B0
mov ah, 2

loc_39D:
cmp al, 0Ah
jnz short loc_3A7
mov dl, 0Dh
int 21h ; DOS - DISPLAY OUTPUT
; DL = character to send to standard output
mov al, 0Ah

loc_3A7:
mov dl, al
int 21h ; DOS - DISPLAY OUTPUT
; DL = character to send to standard output
lodsb
or al, al
jnz short loc_39D

loc_3B0:
mov si, cx
retn 2
sub_38E endp
nop

; =============== S U B R O U T I N E =======================================


sub_3B6 proc near
mov ah, 48h
mov bx, 0FFFFh
int 21h ; DOS - 2+ - ALLOCATE MEMORY
; BX = number of 16-byte paragraphs desired
cmp ax, 8
jnz short loc_3C6
mov ax, bx
clc
retn
; ---------------------------------------------------------------------------

loc_3C6:
xor ax, ax
stc
retn
sub_3B6 endp
_TEXT ends

_DATA segment byte 'DATA' use16
asc_E8E db '空きメインメモリチェック',0Ah
db 0Ah,0
aVVxvVSlvsvVvvi db 'ちょっと足りないかも、もう少し増やしてから起動してね',0
_DATA ends

end

0 comments on commit 90b7ace

Please sign in to comment.