forked from nmlgc/ReC98
-
Notifications
You must be signed in to change notification settings - Fork 0
/
th05_zuninit.asm
363 lines (304 loc) · 8.16 KB
/
th05_zuninit.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
;
; +-------------------------------------------------------------------------+
; | This file has been generated by The Interactive Disassembler (IDA) |
; | Copyright (c) 2009 by Hex-Rays, <[email protected]> |
; +-------------------------------------------------------------------------+
;
; Input MD5 : E22366913B7288F2EC82E280B386C86D
; File Name : th04/ZUN.COM:ZUNINIT (-I)
; Format : MS-DOS COM-file
; Base Address: 0h Range: 100h-4F1h Loaded length: 3F1h
; OS type : MS DOS
; Application type: Executable 16bit
.386
.model use16 tiny
.code
org 100h
; =============== S U B R O U T I N E =======================================
; Attributes: noreturn thunk
public start
start proc near
jmp start_0
start endp
even
; =============== S U B R O U T I N E =======================================
sub_104 proc far
cmp cs:byte_2EB, 0
jnz short locret_115
mov cs:byte_2EB, 1
call sub_128
locret_115:
iret
sub_104 endp
; =============== S U B R O U T I N E =======================================
sub_116 proc far
cmp cs:byte_2EB, 0
jnz short locret_127
mov cs:byte_2EB, 2
call sub_128
locret_127:
iret
sub_116 endp
; =============== S U B R O U T I N E =======================================
sub_128 proc near
pushf
pusha
push ds
push es
mov ah, 41h
int 18h
mov di, offset aVVtvVVrvsvnvog ; "むやみにSTOPキー押したりしない$"
cmp cs:byte_2EB, 1
jz short loc_13E
mov di, offset aVV ; "なんでCOPYキー押したりしてるの$"
loc_13E:
mov ax, 650h
call sub_1AE
add di, offset asc_219 - offset aVVtvVVrvsvnvog ; "方がいいと思うの。(ゲーム中はね)$"
mov ax, 6F0h
call sub_1AE
add di, offset aBivrvsvnvoglbV - offset asc_219 ; "(STOPキーで戻れるよ、ねっ) $"
mov ax, 790h
call sub_1AE
mov bl, cs:byte_2EB
loc_15B:
call sub_192
jnz short loc_15B
loc_160:
call sub_192
jz short loc_160
loc_165:
call sub_192
jnz short loc_165
mov ah, 40h
int 18h
mov di, offset aB@b@b@b@b@b@b@ ; " $"
mov ax, 650h
call sub_1AE
mov ax, 6F0h
call sub_1AE
mov ax, 790h
call sub_1AE
mov ah, 6
int 18h
pop es
pop ds
popa
popf
mov cs:byte_2EB, 0
retn
sub_128 endp
; =============== S U B R O U T I N E =======================================
sub_192 proc near
mov ah, 4
mov al, 0Ch
int 18h
test ah, bl
retn
sub_192 endp
even
; =============== S U B R O U T I N E =======================================
sub_19C proc near
shl ah, 1
cmp al, 9Fh
jnb short loc_1A7
cmp al, 80h
adc ax, 0FEDFh
loc_1A7:
sbb ax, 0DFFEh
and ax, 7F7Fh
retn
sub_19C endp
; =============== S U B R O U T I N E =======================================
sub_1AE proc near
push di
mov bx, di
mov dx, 0A000h
mov es, dx
assume es:nothing
mov di, ax
mov dx, ax
xor ax, ax
xor cx, cx
loc_1BE:
mov ax, cs:[bx]
cmp al, 24h
jz short loc_1DB
xchg ah, al
call sub_19C
xchg ah, al
sub al, 20h
stosw
or ah, 80h
stosw
add bx, 2
add cl, 2
jmp short loc_1BE
; ---------------------------------------------------------------------------
loc_1DB:
mov ax, 0A200h
mov es, ax
assume es:nothing
mov di, dx
mov ax, 41h
loc_1E5:
stosw
loop loc_1E5
pop di
retn
sub_1AE endp
; ---------------------------------------------------------------------------
ZUNP dw 'ZU', 'NP'
dword_1EE dd 0
dword_1F2 dd 0
aVVtvVVrvsvnvog db 'むやみにSTOPキー押したりしない$'
asc_219 db '方がいいと思うの。(ゲーム中はね)$'
aBivrvsvnvoglbV db '(STOPキーで戻れるよ、ねっ) $'
aVV db 'なんでCOPYキー押したりしてるの$'
aVivBBbvVVmbBbb db 'かな~。ふしぎ~。 (もう一度、$'
aVbvnvovxglbIqv db 'COPYキー押せば戻れるよ、ねっ)$'
aB@b@b@b@b@b@b@ db ' $'
byte_2EB db 0
; =============== S U B R O U T I N E =======================================
sub_2EC proc near
mov dx, offset aIntvectorSetPr ; "\r\nINTvector set program zuninit.com "...
mov ah, 9
int 21h ; DOS - PRINT STRING
; DS:DX -> string terminated by "$"
mov ax, 3506h
int 21h ; DOS - 2+ - GET INTERRUPT VECTOR
; AL = interrupt number
; Return: ES:BX = value of interrupt vector
xor ax, ax
cmp es:ZUNP+0, 'ZU'
jnz short locret_30D
cmp es:ZUNP+2, 'NP'
jnz short locret_30D
inc ax
locret_30D:
retn
sub_2EC endp
; =============== S U B R O U T I N E =======================================
start_0 proc near
mov si, 81h
loc_311:
lodsb
cmp al, 0Dh
jz short loc_322
cmp al, '/'
jz short loc_32C
cmp al, '-'
jz short loc_32C
cmp al, ' '
jbe short loc_311
loc_322:
call sub_2EC
test ax, ax
jz short loc_344
jmp loc_3B0
; ---------------------------------------------------------------------------
loc_32C:
lodsb
cmp al, ' '
jbe loc_3BA
and al, 0DFh
cmp al, 'R'
jnz loc_3BA
call sub_2EC
test ax, ax
jnz short loc_381
jmp short loc_3B5
; ---------------------------------------------------------------------------
loc_344:
mov ax, 3506h
int 21h ; DOS - 2+ - GET INTERRUPT VECTOR
; AL = interrupt number
; Return: ES:BX = value of interrupt vector
mov word ptr dword_1F2, bx
mov word ptr dword_1F2+2, es
mov dx, offset sub_104
mov ax, 2506h
int 21h ; DOS - SET INTERRUPT VECTOR
; AL = interrupt number
; DS:DX = new vector to be used for specified interrupt
mov ax, 3505h
int 21h ; DOS - 2+ - GET INTERRUPT VECTOR
; AL = interrupt number
; Return: ES:BX = value of interrupt vector
mov word ptr dword_1EE, bx
mov word ptr dword_1EE+2, es
mov dx, offset sub_116
mov ax, 2505h
int 21h ; DOS - SET INTERRUPT VECTOR
; AL = interrupt number
; DS:DX = new vector to be used for specified interrupt
mov dx, offset aVVxvVVVixfiovi ; "ちょこっとお部屋かりるね☆\r\n\r\n$"
mov ah, 9
int 21h ; DOS - PRINT STRING
; DS:DX -> string terminated by "$"
mov dx, offset sub_2EC
shr dx, 4
inc dx
mov ax, 3100h
int 21h ; DOS - DOS 2+ - TERMINATE BUT STAY RESIDENT
; AL = exit code, DX = program size, in paragraphs
; ---------------------------------------------------------------------------
loc_381:
push ds
lds dx, es:dword_1F2
mov ax, 2506h
int 21h ; DOS - SET INTERRUPT VECTOR
; AL = interrupt number
; DS:DX = new vector to be used for specified interrupt
lds dx, es:dword_1EE
mov ax, 2505h
int 21h ; DOS - SET INTERRUPT VECTOR
; AL = interrupt number
; DS:DX = new vector to be used for specified interrupt
pop ds
push es
mov es, word ptr es:2Ch
assume es:nothing
mov ah, 49h
int 21h ; DOS - 2+ - FREE MEMORY
; ES = segment address of area to be freed
pop es
mov ah, 49h
int 21h ; DOS - 2+ - FREE MEMORY
; ES = segment address of area to be freed
mov dx, offset aOVsvVVixfiov ; "借りてたお部屋をお返ししますね。それで?"...
jnb short loc_3BD
mov dx, offset aGbgvgki ; "メモリ解放エラーです\r\n$"
jmp short loc_3BD
; ---------------------------------------------------------------------------
loc_3B0:
mov dx, offset aVVVPatuvVVVB ; "すでに常駐してます~\r\n\r\n$"
jmp short loc_3BD
; ---------------------------------------------------------------------------
loc_3B5:
mov dx, offset aVVBapatuvVVVvv ; "まだ、常駐してないです\r\n\r\n$"
jmp short loc_3BD
; ---------------------------------------------------------------------------
loc_3BA:
mov dx, offset aICbxscVGigvgvg ; "意味不明なオプションよぉ(オプションは "...
loc_3BD:
mov ah, 9
int 21h ; DOS - PRINT STRING
; DS:DX -> string terminated by "$"
mov ax, 4C00h
int 21h ; DOS - 2+ - QUIT WITH EXIT CODE (EXIT)
start_0 endp ; AL = exit code
; ---------------------------------------------------------------------------
aIntvectorSetPr db 0Dh,0Ah
db 'INTvector set program zuninit.com Version1.02 (c)zun 1998',0Dh,0Ah,'$'
aVVxvVVVixfiovi db 'ちょこっとお部屋かりるね☆',0Dh,0Ah
db 0Dh,0Ah,'$'
aVVVPatuvVVVB db 'すでに常駐してます~',0Dh,0Ah
db 0Dh,0Ah,'$'
aOVsvVVixfiov db '借りてたお部屋をお返ししますね。それではまた☆',0Dh,0Ah
db 0Dh,0Ah,'$'
aVVBapatuvVVVvv db 'まだ、常駐してないです',0Dh,0Ah
db 0Dh,0Ah,'$'
aICbxscVGigvgvg db '意味不明なオプションよぉ(オプションは -R : 解放 のみ)',0Dh,0Ah,'$'
aGbgvgki db 'メモリ解放エラーです',0Dh,0Ah,'$'
end start