;
; +-------------------------------------------------------------------------+
; |   This file has been generated by The Interactive Disassembler (IDA)    |
; |        Copyright (c) 2009 by Hex-Rays, <support@hex-rays.com>           |
; +-------------------------------------------------------------------------+
;
; 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 ; "�ނ�݂ɂr�s�n�o�L�[�������肵�Ȃ�$"
		cmp	cs:byte_2EB, 1
		jz	short loc_13E
		mov	di, offset aVV	; "�Ȃ�łb�n�o�x�L�[�������肵�Ă��$"

loc_13E:
		mov	ax, 650h
		call	sub_1AE
		add	di, offset asc_219 - offset aVVtvVVrvsvnvog ; "���������Ǝv���́B�i�Q�[�����͂ˁj$"
		mov	ax, 6F0h
		call	sub_1AE
		add	di, offset aBivrvsvnvoglbV - offset asc_219 ; "�i�r�s�n�o�L�[�Ŗ߂���A�˂��j�@$"
		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 '�ނ�݂ɂr�s�n�o�L�[�������肵�Ȃ�$'
asc_219	db '���������Ǝv���́B�i�Q�[�����͂ˁj$'
aBivrvsvnvoglbV	db '�i�r�s�n�o�L�[�Ŗ߂���A�˂��j�@$'
aVV	db '�Ȃ�łb�n�o�x�L�[�������肵�Ă��$'
aVivBBbvVVmbBbb	db '���ȁ`�B�ӂ����`�B�@�@�i������x�A$'
aVbvnvovxglbIqv	db '�b�n�o�x�L�[�����Ζ߂���A�˂��j$'
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 ; "�؂�Ă������������Ԃ����܂��ˁB�����?"...
		jnb	short loc_3BD
		mov	dx, offset aGbgvgki ; "����������G���[�ł�\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 ; "�܂��A�풓���ĂȂ��ł�\r\n\r\n$"
		jmp	short loc_3BD
; ---------------------------------------------------------------------------

loc_3BA:
		mov	dx, offset aICbxscVGigvgvg ; "�Ӗ��s���ȃI�v�V�����悧�i�I�v�V������ "...

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 '�؂�Ă������������Ԃ����܂��ˁB����ł͂܂���',0Dh,0Ah

		db 0Dh,0Ah,'$'
aVVBapatuvVVVvv	db '�܂��A�풓���ĂȂ��ł�',0Dh,0Ah
		db 0Dh,0Ah,'$'
aICbxscVGigvgvg	db '�Ӗ��s���ȃI�v�V�����悧�i�I�v�V������ -R : ��� �̂݁j',0Dh,0Ah,'$'

aGbgvgki	db '����������G���[�ł�',0Dh,0Ah,'$'

		end start