mirror of https://github.com/nmlgc/ReC98.git
[Decompilation] [th04] RES_HUMA.COM
Part of P0077, funded by Splashman and -Tom-.
This commit is contained in:
parent
a1c3acd9f1
commit
4e53b97552
|
@ -91,6 +91,11 @@ bin\th03\main.exe: bin\th03\main.obj th03\main_01.cpp th03\sprite16.cpp
|
|||
$**
|
||||
|
|
||||
|
||||
bin\th04\res_huma.com: th04\res_huma.cpp
|
||||
$(CC) $(CFLAGS) -mt -lt -Z -DGAME=4 -nbin\th04\ -eRES_HUMA.COM @&&|
|
||||
$**
|
||||
| masters.lib
|
||||
|
||||
bin\th04\op.exe: bin\th04\op.obj th04\op_01.cpp th04\op_02.c
|
||||
$(CC) $(CFLAGS) -ml -DGAME=4 -DBINARY='O' -nbin\th04\ -eOP.EXE @&&|
|
||||
$**
|
||||
|
|
|
@ -23,7 +23,6 @@ if errorlevel 9009 goto no_tasm32
|
|||
%ReC98_ASM% th03_main.asm bin\th03\main.obj
|
||||
%ReC98_ASM% th03_mainl.asm bin\th03\mainl.obj
|
||||
|
||||
%ReC98_ASM% th04_res_huma.asm bin\th04\res_huma.obj
|
||||
%ReC98_ASM% th04_op.asm bin\th04\op.obj
|
||||
%ReC98_ASM% th04_main.asm bin\th04\main.obj
|
||||
%ReC98_ASM% th04_maine.asm bin\th04\maine.obj
|
||||
|
|
|
@ -47,5 +47,8 @@ int main(int argc, const unsigned char **argv)
|
|||
resident_bytes[i] = 0;
|
||||
}
|
||||
cfg_init(sgm);
|
||||
#ifdef RES_INIT_BOTTOM
|
||||
RES_INIT_BOTTOM;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/* ReC98
|
||||
* -----
|
||||
* TH04 ZUN.COM -S. Initializes the resident structure and configuration file
|
||||
* required in order to run TH04.
|
||||
*/
|
||||
|
||||
#include <ReC98.h>
|
||||
#include "th01/ranks.h"
|
||||
#include "th04/score.h"
|
||||
#include "th04/resident.hpp"
|
||||
#include "th04/snd/snd.h"
|
||||
#include "th04/formats/cfg.h"
|
||||
|
||||
#pragma option -a1
|
||||
|
||||
char debug = 0;
|
||||
const cfg_options_t OPTS_DEFAULT = {
|
||||
RANK_DEFAULT, CFG_LIVES_DEFAULT, CFG_BOMBS_DEFAULT,
|
||||
SND_BGM_FM26, SND_SE_FM, true
|
||||
};
|
||||
|
||||
void cfg_init(seg_t resident_sgm)
|
||||
{
|
||||
const char *fn = CFG_FN;
|
||||
cfg_options_t opts = OPTS_DEFAULT;
|
||||
cfg_t cfg_in;
|
||||
|
||||
if(!file_ropen(fn)) {
|
||||
recreate:
|
||||
file_create(fn);
|
||||
file_write(&opts, sizeof(opts));
|
||||
} else {
|
||||
file_read(&cfg_in, sizeof(cfg_in));
|
||||
file_close();
|
||||
if((
|
||||
cfg_in.opts.rank
|
||||
+ cfg_in.opts.lives
|
||||
+ cfg_in.opts.bombs
|
||||
+ cfg_in.opts.bgm_mode
|
||||
+ cfg_in.opts.se_mode
|
||||
+ cfg_in.opts.turbo_mode
|
||||
) != cfg_in.opts_sum) {
|
||||
goto recreate;
|
||||
}
|
||||
file_append(fn);
|
||||
file_seek(offsetof(cfg_t, resident), 0);
|
||||
}
|
||||
file_write(&resident_sgm, sizeof(resident_sgm));
|
||||
file_write(&debug, sizeof(debug));
|
||||
// Yes, this is uninitialized if the file didn't exist!
|
||||
file_write(&cfg_in.opts_sum, sizeof(cfg_in.opts_sum));
|
||||
file_close();
|
||||
}
|
||||
|
||||
#define LOGO \
|
||||
"東方幻想郷用 常駐プログラム RES_HUMA.com Version1.00 (c)zun 1998"
|
||||
|
||||
#define RES_INIT_BOTTOM { \
|
||||
resident_t far *resident = reinterpret_cast<resident_t far *>(resident_bytes); \
|
||||
if(debug) { \
|
||||
resident->debug = true; \
|
||||
} \
|
||||
}
|
||||
|
||||
#include "th02/res_init.c"
|
|
@ -1,3 +1,4 @@
|
|||
#pragma option -a1
|
||||
#define RES_ID "HUMAConfig"
|
||||
typedef struct {
|
||||
char id[RES_ID_LEN];
|
||||
|
@ -54,3 +55,4 @@ typedef struct {
|
|||
unsigned char turbo_mode;
|
||||
int8_t unused_5[182];
|
||||
} resident_t;
|
||||
#pragma option -a.
|
||||
|
|
|
@ -1,380 +0,0 @@
|
|||
;
|
||||
; +-------------------------------------------------------------------------+
|
||||
; | This file has been generated by The Interactive Disassembler (IDA) |
|
||||
; | Copyright (c) 2009 by Hex-Rays, <support@hex-rays.com> |
|
||||
; +-------------------------------------------------------------------------+
|
||||
;
|
||||
; Input MD5 : C84DB5A5C97E54BA50E3BE80D8C24034
|
||||
|
||||
; File Name : th04/ZUN.COM:RES_HUMA (-S)
|
||||
; Format : MS-DOS COM-file
|
||||
; Base Address: 0h Range: 100h-19D8h Loaded length: 18D8h
|
||||
; OS type : MS DOS
|
||||
; Application type: Executable 16bit
|
||||
|
||||
.286
|
||||
.model tiny
|
||||
__TINY__ equ 1
|
||||
|
||||
include ReC98.inc
|
||||
include th04/th04.inc
|
||||
|
||||
; ===========================================================================
|
||||
|
||||
; Segment type: Pure code
|
||||
_TEXT segment word public 'CODE' use16
|
||||
assume cs:_TEXT
|
||||
assume es:nothing, ss:nothing, ds:_TEXT
|
||||
|
||||
include libs/BorlandC/c0.asm
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: bp-based frame
|
||||
|
||||
sub_367 proc near
|
||||
|
||||
var_10 = byte ptr -10h
|
||||
var_F = byte ptr -0Fh
|
||||
var_E = byte ptr -0Eh
|
||||
var_D = byte ptr -0Dh
|
||||
var_C = byte ptr -0Ch
|
||||
var_B = byte ptr -0Bh
|
||||
var_7 = byte ptr -7
|
||||
var_6 = byte ptr -6
|
||||
arg_0 = byte ptr 4
|
||||
|
||||
enter 10h, 0
|
||||
push si
|
||||
mov si, offset aMiko_cfg ; "miko.cfg"
|
||||
lea ax, [bp+var_6]
|
||||
push ss
|
||||
push ax
|
||||
push ds
|
||||
push offset unk_15FF
|
||||
mov cx, 6
|
||||
call N_SCOPY@
|
||||
push si
|
||||
call file_ropen
|
||||
or ax, ax
|
||||
jnz short loc_396
|
||||
|
||||
loc_386:
|
||||
push si
|
||||
call file_create
|
||||
push ss
|
||||
lea ax, [bp+var_6]
|
||||
push ax
|
||||
push 6
|
||||
call file_write
|
||||
jmp short loc_3DC
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_396:
|
||||
push ss
|
||||
lea ax, [bp+var_10]
|
||||
push ax
|
||||
push 0Ah
|
||||
call file_read
|
||||
call file_close
|
||||
mov al, [bp+var_10]
|
||||
cbw
|
||||
push ax
|
||||
mov al, [bp+var_F]
|
||||
cbw
|
||||
pop dx
|
||||
add dx, ax
|
||||
mov al, [bp+var_E]
|
||||
cbw
|
||||
add dx, ax
|
||||
mov al, [bp+var_D]
|
||||
cbw
|
||||
add dx, ax
|
||||
mov al, [bp+var_C]
|
||||
cbw
|
||||
add dx, ax
|
||||
mov al, [bp+var_B]
|
||||
cbw
|
||||
add dx, ax
|
||||
mov al, [bp+var_7]
|
||||
cbw
|
||||
cmp dx, ax
|
||||
jnz short loc_386
|
||||
push si
|
||||
call file_append
|
||||
push 0
|
||||
push 6
|
||||
push 0
|
||||
call file_seek
|
||||
|
||||
loc_3DC:
|
||||
push ss
|
||||
lea ax, [bp+arg_0]
|
||||
push ax
|
||||
push 2
|
||||
call file_write
|
||||
push ds
|
||||
push offset byte_15FE
|
||||
push 1
|
||||
call file_write
|
||||
push ss
|
||||
lea ax, [bp+var_7]
|
||||
push ax
|
||||
push 1
|
||||
call file_write
|
||||
call file_close
|
||||
pop si
|
||||
leave
|
||||
retn
|
||||
sub_367 endp
|
||||
|
||||
|
||||
; =============== 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)
|
||||
_main proc near
|
||||
|
||||
var_C = dword ptr -0Ch
|
||||
var_8 = dword ptr -8
|
||||
var_4 = word ptr -4
|
||||
var_2 = word ptr -2
|
||||
_argc = word ptr 4
|
||||
_argv = word ptr 6
|
||||
_envp = word ptr 8
|
||||
|
||||
enter 0Ch, 0
|
||||
push si
|
||||
push di
|
||||
mov si, [bp+_argv]
|
||||
mov [bp+var_2], offset aHumaconfig ; "HUMAConfig"
|
||||
push [bp+var_2]
|
||||
push 0Ah
|
||||
push 10h
|
||||
call resdata_exist
|
||||
mov di, ax
|
||||
push offset aUmx ; "\n\n東方幻想郷用 常駐プログラム RES_HU"...
|
||||
call dos_puts2
|
||||
call graph_clear
|
||||
cmp [bp+_argc], 2
|
||||
jnz short loc_485
|
||||
mov bx, [si+2]
|
||||
cmp byte ptr [bx], '-'
|
||||
jz short loc_435
|
||||
cmp byte ptr [bx], '/'
|
||||
jnz short loc_45A
|
||||
|
||||
loc_435:
|
||||
mov bx, [si+2]
|
||||
cmp byte ptr [bx+1], 'R'
|
||||
jz short loc_444
|
||||
cmp byte ptr [bx+1], 'r'
|
||||
jnz short loc_45A
|
||||
|
||||
loc_444:
|
||||
or di, di
|
||||
jnz short loc_44D
|
||||
push offset aVavVBavVVvvVV ; "わたし、まだいませんよぉ\n\n"
|
||||
jmp short loc_4A4
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_44D:
|
||||
push di
|
||||
call dos_free
|
||||
push offset aVVcvVcbavVIqvj ; "さよなら、また会えたらいいな\n\n"
|
||||
call dos_puts2
|
||||
jmp loc_4F5
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_45A:
|
||||
mov bx, [si+2]
|
||||
cmp byte ptr [bx], '-'
|
||||
jz short loc_467
|
||||
cmp byte ptr [bx], '/'
|
||||
jnz short loc_47D
|
||||
|
||||
loc_467:
|
||||
mov bx, [si+2]
|
||||
cmp byte ptr [bx+1], 'D'
|
||||
jz short loc_476
|
||||
cmp byte ptr [bx+1], 'd'
|
||||
jnz short loc_47D
|
||||
|
||||
loc_476:
|
||||
mov byte_15FE, 1
|
||||
jmp short loc_485
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_47D:
|
||||
push offset aVV ; "そんなオプション付けられても、困るんで・...
|
||||
call dos_puts2
|
||||
jmp short loc_4A7
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_485:
|
||||
or di, di
|
||||
jz short loc_491
|
||||
push offset aVavVBavVVVvvVV ; "わたし、すでにいますよぉ\n\n"
|
||||
call dos_puts2
|
||||
jmp short loc_4A7
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_491:
|
||||
push [bp+var_2]
|
||||
push 0Ah
|
||||
push 10h
|
||||
call resdata_create
|
||||
mov di, ax
|
||||
or di, di
|
||||
jnz short loc_4AC
|
||||
push offset aNVVVV ; "作れません、わたしの居場所がないの!\n\n"
|
||||
|
||||
loc_4A4:
|
||||
call dos_puts2
|
||||
|
||||
loc_4A7:
|
||||
mov ax, 1
|
||||
jmp short loc_4F7
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_4AC:
|
||||
mov word ptr [bp+var_8+2], di
|
||||
mov word ptr [bp+var_8], 0
|
||||
push offset aVVVVBavcvivVnv ; "それでは、よろしくお願いします\n\n"
|
||||
call dos_puts2
|
||||
mov [bp+var_4], 0Bh
|
||||
jmp short loc_4CE
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_4C1:
|
||||
les bx, [bp+var_8]
|
||||
add bx, [bp+var_4]
|
||||
mov byte ptr es:[bx], 0
|
||||
inc [bp+var_4]
|
||||
|
||||
loc_4CE:
|
||||
cmp [bp+var_4], 100h
|
||||
jl short loc_4C1
|
||||
push di
|
||||
call sub_367
|
||||
pop cx
|
||||
mov dx, word ptr [bp+var_8+2]
|
||||
mov ax, word ptr [bp+var_8]
|
||||
mov word ptr [bp+var_C+2], dx
|
||||
mov word ptr [bp+var_C], ax
|
||||
cmp byte_15FE, 0
|
||||
jz short loc_4F5
|
||||
les bx, [bp+var_C]
|
||||
mov es:[bx+resident_t.debug_mode], 1
|
||||
|
||||
loc_4F5:
|
||||
xor ax, ax
|
||||
|
||||
loc_4F7:
|
||||
pop di
|
||||
pop si
|
||||
leave
|
||||
retn
|
||||
_main endp
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
db 0
|
||||
include libs/master.lib/graph_clear.asm
|
||||
include libs/master.lib/resdata.asm
|
||||
include libs/master.lib/file_read.asm
|
||||
include libs/master.lib/file_close.asm
|
||||
include libs/master.lib/file_ropen.asm
|
||||
include libs/master.lib/file_write.asm
|
||||
include libs/master.lib/file_create.asm
|
||||
include libs/master.lib/file_seek.asm
|
||||
include libs/master.lib/file_append.asm
|
||||
include libs/master.lib/dos_free.asm
|
||||
include libs/master.lib/dos_axdx.asm
|
||||
include libs/master.lib/dos_puts2.asm
|
||||
include libs/master.lib/dos_ropen.asm
|
||||
include libs/BorlandC/_abort.asm
|
||||
include libs/BorlandC/atexit.asm
|
||||
include libs/BorlandC/errormsg.asm
|
||||
include libs/BorlandC/exit.asm
|
||||
include libs/BorlandC/ioerror.asm
|
||||
include libs/BorlandC/_isatty.asm
|
||||
include libs/BorlandC/lseek.asm
|
||||
include libs/BorlandC/n_scopy.asm
|
||||
include libs/BorlandC/setupio.asm
|
||||
include libs/BorlandC/brk.asm
|
||||
include libs/BorlandC/nearheap.asm
|
||||
include libs/BorlandC/pathops.asm
|
||||
include libs/BorlandC/fflush.asm
|
||||
include libs/BorlandC/flushall.asm
|
||||
include libs/BorlandC/fseek.asm
|
||||
include libs/BorlandC/setvbuf.asm
|
||||
include libs/BorlandC/_strlen.asm
|
||||
include libs/BorlandC/write.asm
|
||||
include libs/BorlandC/writea.asm
|
||||
include libs/BorlandC/xfflush.asm
|
||||
include libs/BorlandC/setargv.asm
|
||||
db 8 dup(0)
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
include libs/BorlandC/c0[data].asm
|
||||
|
||||
byte_15FE db 0
|
||||
unk_15FF db 0FFh
|
||||
db CFG_LIVES_DEFAULT
|
||||
db CFG_BOMBS_DEFAULT
|
||||
db 1
|
||||
db 1
|
||||
db 1
|
||||
aMiko_cfg db 'miko.cfg',0
|
||||
aHumaconfig db 'HUMAConfig',0
|
||||
aUmx db 0Ah
|
||||
db 0Ah
|
||||
db '東方幻想郷用 常駐プログラム RES_HUMA.com Version1.00 (c)zun 1998',0Ah,0
|
||||
aVavVBavVVvvVV db 'わたし、まだいませんよぉ',0Ah
|
||||
db 0Ah,0
|
||||
aVVcvVcbavVIqvj db 'さよなら、また会えたらいいな',0Ah
|
||||
db 0Ah,0
|
||||
aVV db 'そんなオプション付けられても、困るんですけど',0Ah
|
||||
db 0Ah,0
|
||||
aVavVBavVVVvvVV db 'わたし、すでにいますよぉ',0Ah
|
||||
db 0Ah,0
|
||||
aNVVVV db '作れません、わたしの居場所がないの!',0Ah
|
||||
db 0Ah,0
|
||||
aVVVVBavcvivVnv db 'それでは、よろしくお願いします',0Ah
|
||||
db 0Ah,0
|
||||
include libs/master.lib/version[data].asm
|
||||
include libs/master.lib/grp[data].asm
|
||||
include libs/master.lib/resdata[data].asm
|
||||
include libs/master.lib/fil[data].asm
|
||||
include libs/master.lib/dos_ropen[data].asm
|
||||
include libs/BorlandC/_abort[data].asm
|
||||
include libs/BorlandC/atexit[data].asm
|
||||
include libs/BorlandC/exit[data].asm
|
||||
include libs/BorlandC/files[data].asm
|
||||
__heaplen dw 0
|
||||
include libs/BorlandC/ioerror[data].asm
|
||||
include libs/BorlandC/stklen[data].asm
|
||||
include libs/BorlandC/nearheap[data].asm
|
||||
include libs/BorlandC/pathops[data].asm
|
||||
include libs/BorlandC/setvbuf[data].asm
|
||||
include libs/BorlandC/sysnerr[data].asm
|
||||
include libs/BorlandC/setargv[data].asm
|
||||
|
||||
InitStart label byte
|
||||
include libs/BorlandC/setupio[initdata].asm
|
||||
include libs/BorlandC/pathops[initdata].asm
|
||||
include libs/BorlandC/setargv[initdata].asm
|
||||
InitEnd label byte
|
||||
|
||||
ExitStart label byte
|
||||
ExitEnd label byte
|
||||
|
||||
bdata@ label byte
|
||||
include libs/master.lib/fil[bss].asm
|
||||
include libs/BorlandC/atexit[bss].asm
|
||||
edata@ label byte
|
||||
_TEXT ends
|
||||
|
||||
|
||||
end startx
|
Loading…
Reference in New Issue