forked from nmlgc/ReC98
-
Notifications
You must be signed in to change notification settings - Fork 0
/
th02_zuninit.asm
494 lines (427 loc) · 12 KB
/
th02_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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
;
; +-------------------------------------------------------------------------+
; | This file has been generated by The Interactive Disassembler (IDA) |
; | Copyright (c) 2009 by Hex-Rays, <[email protected]> |
; +-------------------------------------------------------------------------+
;
; Input MD5 : 04F7FC8F2C807428042289437780947F
; File Name : th02/ZUN.COM:ZUNINIT
; Format : MS-DOS COM-file
; Base Address: 0h Range: 100h-66Eh Loaded length: 56Eh
; OS type : MS DOS
; Application type: Executable 16bit
.286
.model tiny
; ===========================================================================
; Segment type: Pure code
_TEXT segment use16
assume cs:_TEXT
org 100h
assume es:nothing, ss:nothing, ds:_TEXT
; =============== S U B R O U T I N E =======================================
; Attributes: noreturn thunk
public start
start proc near
jmp start_0
start endp
; =============== S U B R O U T I N E =======================================
sub_103 proc far
pushf
push ax
push bx
push cx
push dx
push ds
push di
push es
mov bx, ax
shl bx, 1
xor ax, ax
mov dx, cs:off_312[bx]
call sub_202
mov ax, 0A0h
mov dx, offset aGkgBGuglbV ; "リターンキーを押してね$"
call sub_202
loc_122:
mov ah, 4
mov al, 3
int 18h ; TRANSFER TO ROM BASIC
; causes transfer to ROM-based BASIC (IBM-PC)
; often reboots a compatible; often has no effect at all
test ah, 10h
jz short loc_122
pop es
pop di
pop ds
pop dx
pop cx
pop bx
pop ax
popf
iret
sub_103 endp
; =============== S U B R O U T I N E =======================================
sub_136 proc far
cmp cs:byte_24D, 0
jnz short locret_147
mov cs:byte_24D, 1
call sub_15A
locret_147:
iret
sub_136 endp
; =============== S U B R O U T I N E =======================================
sub_148 proc far
cmp cs:byte_24D, 0
jnz short locret_159
mov cs:byte_24D, 2
call sub_15A
locret_159:
iret
sub_148 endp
; =============== S U B R O U T I N E =======================================
sub_15A proc near
pushf
push ax
push bx
push cx
push dx
push ds
push di
push es
mov ah, 41h
int 18h ; TRANSFER TO ROM BASIC
; causes transfer to ROM-based BASIC (IBM-PC)
; often reboots a compatible; often has no effect at all
cmp cs:byte_24D, 2
jz short loc_18D
mov ax, 650h
mov dx, offset aVVtvVVrvsvnvog ; "むやみにSTOPキー押したりしない$"
call sub_202
mov ax, 6F0h
mov dx, offset asc_341 ; "方がいいと思うの。(ゲーム中はね)$"
call sub_202
mov ax, 790h
mov dx, offset aBivrvsvnvoglbV ; "(STOPキーで戻れるよ、ねっ) $"
call sub_202
mov bl, 1
jmp short loc_1AA
; ---------------------------------------------------------------------------
loc_18D:
mov ax, 650h
mov dx, offset aVV ; "なんでCOPYキー押したりしてるの$"
call sub_202
mov ax, 6F0h
mov dx, offset aVivBBbvVVmbBbb ; "かな~。ふしぎ~。 (もう一度、$"
call sub_202
mov ax, 790h
mov dx, offset aVbvnvovxglbIqv ; "COPYキー押せば戻れるよ、ねっ)$"
call sub_202
mov bl, 2
loc_1AA:
mov ah, 4
mov al, 0Ch
int 18h ; TRANSFER TO ROM BASIC
; causes transfer to ROM-based BASIC (IBM-PC)
; often reboots a compatible; often has no effect at all
test ah, bl
jnz short loc_1AA
loc_1B4:
mov ah, 4
mov al, 0Ch
int 18h ; TRANSFER TO ROM BASIC
; causes transfer to ROM-based BASIC (IBM-PC)
; often reboots a compatible; often has no effect at all
test ah, bl
jz short loc_1B4
mov ah, 40h
int 18h ; TRANSFER TO ROM BASIC
; causes transfer to ROM-based BASIC (IBM-PC)
; often reboots a compatible; often has no effect at all
mov ax, 650h
mov dx, offset aB@b@b@b@b@b@b@ ; " $"
call sub_202
mov ax, 6F0h
mov dx, offset aB@b@b@b@b@b@b@ ; " $"
call sub_202
mov ax, 790h
mov dx, offset aB@b@b@b@b@b@b@ ; " $"
call sub_202
mov ah, 6
int 18h ; TRANSFER TO ROM BASIC
; causes transfer to ROM-based BASIC (IBM-PC)
; often reboots a compatible; often has no effect at all
pop es
pop di
pop ds
pop dx
pop cx
pop bx
pop ax
popf
mov cs:byte_24D, 0
retn
sub_15A endp
; =============== S U B R O U T I N E =======================================
sub_1F0 proc near
shl ah, 1
cmp al, 9Fh
jnb short loc_1FB
cmp al, 80h
adc ax, 0FEDFh
loc_1FB:
sbb ax, 0DFFEh
and ax, 7F7Fh
retn
sub_1F0 endp
; =============== S U B R O U T I N E =======================================
sub_202 proc near
mov bx, dx
mov di, 0A000h
mov es, di
assume es:nothing
mov di, ax
mov dx, ax
xor ax, ax
xor cx, cx
loc_211:
mov ax, cs:[bx]
cmp al, 24h
jz short loc_22C
xchg ah, al
call sub_1F0
xchg ah, al
sub al, 20h
stosw
or ah, 80h
stosw
inc bx
inc bx
inc cx
inc cx
jmp short loc_211
; ---------------------------------------------------------------------------
loc_22C:
mov di, 0A200h
mov es, di
assume es:nothing
mov di, dx
mov ax, 41h
loc_236:
dec cx
stosw
jz short locret_23C
jmp short loc_236
; ---------------------------------------------------------------------------
locret_23C:
retn
sub_202 endp
; ---------------------------------------------------------------------------
ZUNP dw 'ZU', 'NP'
dword_241 dd 0
dword_245 dd 0
dword_249 dd 0
byte_24D db 0
aGkgBGuglbV db 'リターンキーを押してね$'
aVV_0 db 'なんかのエラーですぅ$'
aGtg@gcglvkvVVi db 'ファイルがみつかんないよぉ$'
aGbgvgkvkslvsvV db 'メモリが足りないんですぅ$'
aGogbgGtg@gcglv db 'バッチファイルから起動してよぉ$'
aGngcgxgrgavGtg db 'ハイスコアのファイルがおかしいよぅ、だからハイスコアは消えちゃったよ$'
off_312 dw offset aVV_0
; "なんかのエラーですぅ$"
dw offset aVV_0 ; "なんかのエラーですぅ$"
dw offset aGtg@gcglvkvVVi ; "ファイルがみつかんないよぉ$"
dw offset aGbgvgkvkslvsvV ; "メモリが足りないんですぅ$"
dw offset aGogbgGtg@gcglv ; "バッチファイルから起動してよぉ$"
dw offset aGngcgxgrgavGtg ; "ハイスコアのファイルがおかしいよぅ、だ・...
aVVtvVVrvsvnvog db 'むやみにSTOPキー押したりしない$'
asc_341 db '方がいいと思うの。(ゲーム中はね)$'
aBivrvsvnvoglbV db '(STOPキーで戻れるよ、ねっ) $'
aB@b@b@b@b@b@b@ db ' $'
aVV db 'なんでCOPYキー押したりしてるの$'
aVivBBbvVVmbBbb db 'かな~。ふしぎ~。 (もう一度、$'
aVbvnvovxglbIqv db 'COPYキー押せば戻れるよ、ねっ)$'
; =============== S U B R O U T I N E =======================================
sub_413 proc near
mov dx, offset aIntvectorSetPr ; "\r\n\r\nINTvector set program zuninit.com "...
mov ah, 9
int 21h ; DOS - PRINT STRING
; DS:DX -> string terminated by "$"
mov ax, 3559h
int 21h ; DOS - 2+ - GET INTERRUPT VECTOR
; AL = interrupt number
; Return: ES:BX = value of interrupt vector
cmp es:ZUNP, 'ZU'
jnz short loc_436
cmp es:ZUNP+2, 'NP'
jnz short loc_436
mov ax, 1
jmp short locret_439
; ---------------------------------------------------------------------------
loc_436:
mov ax, 0
locret_439:
retn
sub_413 endp
; =============== S U B R O U T I N E =======================================
; Attributes: noreturn
start_0 proc near
mov si, 81h
loc_43D:
lodsb
cmp al, 0Dh
jz short loc_44E
cmp al, 2Fh
jz short loc_458
cmp al, 2Dh
jz short loc_458
cmp al, 20h
jbe short loc_43D
loc_44E:
call sub_413
test ax, ax
jz short loc_473
jmp loc_515
; ---------------------------------------------------------------------------
loc_458:
lodsb
cmp al, 20h
ja short loc_460
jmp loc_527
; ---------------------------------------------------------------------------
loc_460:
and al, 0DFh
cmp al, 52h
jz short loc_469
jmp loc_527
; ---------------------------------------------------------------------------
loc_469:
call sub_413
test ax, ax
jnz short loc_4C9
jmp loc_51E
; ---------------------------------------------------------------------------
loc_473:
mov word ptr cs:dword_241, bx
mov word ptr cs:dword_241+2, es
mov dx, offset sub_103
mov ax, 2559h
int 21h ; DOS - SET INTERRUPT VECTOR
; AL = interrupt number
; DS:DX = new vector to be used for specified interrupt
mov ah, 35h
mov al, 6
int 21h ; DOS - 2+ - GET INTERRUPT VECTOR
; AL = interrupt number
; Return: ES:BX = value of interrupt vector
mov word ptr cs:dword_249, bx
mov word ptr cs:dword_249+2, es
mov dx, offset sub_136
mov ax, 2506h
int 21h ; DOS - SET INTERRUPT VECTOR
; AL = interrupt number
; DS:DX = new vector to be used for specified interrupt
mov ah, 35h
mov al, 5
int 21h ; DOS - 2+ - GET INTERRUPT VECTOR
; AL = interrupt number
; Return: ES:BX = value of interrupt vector
mov word ptr cs:dword_245, bx
mov word ptr cs:dword_245+2, es
mov dx, offset sub_148
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 aVVxvVVGbgvgkvi ; "ちょこっとメモリかりるね\r\n\r\n$"
mov ah, 9
int 21h ; DOS - PRINT STRING
; DS:DX -> string terminated by "$"
mov dx, offset sub_413
mov cl, 4
shr dx, cl
inc dx
mov ax, 3100h
int 21h ; DOS - DOS 2+ - TERMINATE BUT STAY RESIDENT
; AL = exit code, DX = program size, in paragraphs
; ---------------------------------------------------------------------------
loc_4C9:
push ds
mov dx, word ptr es:dword_241
mov ds, word ptr es:dword_241+2
mov ax, 2559h
int 21h ; DOS - SET INTERRUPT VECTOR
; AL = interrupt number
; DS:DX = new vector to be used for specified interrupt
mov dx, word ptr es:dword_249
mov ds, word ptr es:dword_249+2
mov ax, 2506h
int 21h ; DOS - SET INTERRUPT VECTOR
; AL = interrupt number
; DS:DX = new vector to be used for specified interrupt
mov dx, word ptr es:dword_245
mov ds, word ptr es:dword_245+2
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 aGbgvgkvivcpVjv ; "メモリから消えてなくなっちゃったけど、・...
jnb short loc_50F
mov dx, offset aGbgvgki ; "メモリ解放エラーです。 : zuninit.com\r\n$"
loc_50F:
mov ah, 9
int 21h ; DOS - PRINT STRING
; DS:DX -> string terminated by "$"
jmp short loc_530
; ---------------------------------------------------------------------------
loc_515:
mov dx, offset aVVVPatuvVVsv ; "すでに常駐してるの\r\n\r\n$"
mov ah, 9
int 21h ; DOS - PRINT STRING
; DS:DX -> string terminated by "$"
jmp short loc_530
; ---------------------------------------------------------------------------
loc_51E:
mov dx, offset aVVBapatuvVVVvv ; "まだ、常駐してないわぁ\r\n\r\n$"
mov ah, 9
int 21h ; DOS - PRINT STRING
; DS:DX -> string terminated by "$"
jmp short loc_530
; ---------------------------------------------------------------------------
loc_527:
mov dx, offset aICbxscVGigvgvg ; "意味不明なオプションよぉ(オプションは "...
mov ah, 9
int 21h ; DOS - PRINT STRING
; DS:DX -> string terminated by "$"
jmp short $+2
loc_530:
mov ax, 4C00h
int 21h ; DOS - 2+ - QUIT WITH EXIT CODE (EXIT)
start_0 endp ; AL = exit code
; ---------------------------------------------------------------------------
aIntvectorSetPr db 0Dh,0Ah
db 0Dh,0Ah
db 'INTvector set program zuninit.com Version1.00 (c)zun 1997',0Dh,0Ah,'$'
aVVxvVVGbgvgkvi db 'ちょこっとメモリかりるね',0Dh,0Ah
db 0Dh,0Ah,'$'
aVVVPatuvVVsv db 'すでに常駐してるの',0Dh,0Ah
db 0Dh,0Ah,'$'
aGbgvgkvivcpVjv db 'メモリから消えてなくなっちゃったけど、きっとまたあえるよ、ねっ',0Dh,0Ah
db 0Dh,0Ah,'$'
aVVBapatuvVVVvv db 'まだ、常駐してないわぁ',0Dh,0Ah
db 0Dh,0Ah,'$'
aICbxscVGigvgvg db '意味不明なオプションよぉ(オプションは -Rのみ)',0Dh,0Ah,'$'
aGbgvgki db 'メモリ解放エラーです。 : zuninit.com',0Dh,0Ah,'$'
_TEXT ends
end start