*
* PatchNTSC.asm
*
* Patches "OpenScreen()" so that Screens higher than 216
* will have the "ViewMode->Interlace"-Flag set
*
* Allows NTSC-Users to use PAL programs without loosing the
* bottom of screen
*
* © 1990 by Oliver Wagner
*	    Landsberge 5
*	    4322 Sprockhövel
*	    West Germany
*
* Freely distributable IF no charge is made for anything!
* Darf nicht von Mitgliedern der "Schwarzen Liste" der PD-Vertreiber
* (erstellt durch die AmigaUserGroupSwitzerland AUGS) genutzt/verbreitet
* werden!
*
* A68k PatchNTSC.asm
* BLINK PatchNTSC.asm,lib:small.lib to PatchNTSC
*

call	MACRO
	xref	_LVO\1
	jsr	_LVO\1(a6)
	ENDM
jump	MACRO
	xref	_LVO\1
	jmp	_LVO\1(a6)
	ENDM

	CODE
	move.l	4,a6
	move.l	$114(a6),a0
	moveq	#0,d7
	tst.l	$ac(a0)
	bne.s	fromcli
	lea	$5c(a0),a0
	call	WaitPort
	call	GetMsg
	move.l	d0,d7
fromcli:
	lea	dosname(pc),a1
	call	OldOpenLibrary
	move.l	d0,d6
	lea	intname(pc),a1
	call	OldOpenLibrary
	move.l	d0,a5
	move.l	-196(a5),a3
	cmp.l	#'Olli',20(a3)
	bne.s	install
* remove patch
	move.l	a3,a1
	move.l	16(a1),-196(a5)
	moveq	#24,d0
	call	FreeMem
	lea	remmsg(pc),a4
exit:
	move.l	d6,a6
	tst.l	d7
	bne.s	fromwb
	call	Output
	bra.s	writeit
fromwb:
	lea	winddef(pc),a0
	move.l	a0,d1
	move.l	#1005,d2
	call	Open
	move.l	d0,d4
	beq.s	nowrite
writeit:
	moveq	#-1,d3
	move.l	a4,d2
	move.l	d0,d1
len:
	addq.l	#1,d3
	tst.b	(a4)+
	bne.s	len
	call	Write
	tst.l	d7
	beq.s	nowrite
	moveq	#127,d1
	call	Delay
	move.l	d4,d1
	call	Close
nowrite:
	move.l	4,a6
	tst.l	d7
	bne.s	replywb
	moveq	#0,d0
	rts
replywb:
	move.l	d7,a1
	jump	ReplyMsg

install:
	lea	insmsg(pc),a4
	moveq	#0,d1
	moveq	#24,d0
	call	AllocMem
	move.l	d0,d4
	lea	old+2(pc),a0
	move.l	a3,(a0)
	lea	newopen(pc),a0
	move.l	d0,a1
	moveq	#5,d0
copy:
	move.l	(a0)+,(a1)+
	dbf	d0,copy
	move.l	d4,-196(a5)
	bra.s	exit

newopen:
	cmp.w	#216,6(a0)
	ble.s	old
	or.w	#4,12(a0)
old:
	jmp	$f000000
	dc.l	'Olli'

dosname:
	dc.b	"dos.library",0
intname:
	dc.b	"intuition.library",0
remmsg:
	dc.b	10,$9b,"33;1m PatchNTSC ",$9b,"0;1m removed!",10,10,0
insmsg:
	dc.b	10,$9b,"33;1m PatchNTSC ",$9b,"0;1m installed!",10
	dc.b	" © 1990 by Oliver Wagner / Ultimate Computer Arts",10
	dc.b	$9b,"0m 'OpenScreen()' patched for Height >216",10,10,0
winddef:
	dc.b	"con:30/40/420/61/PatchNTSC",0

	END

