@DATABASE "$VER: VGApatch 1 (22-Jan-96)"

@NODE MAIN "VGApatch V1 documentation"

VGApatch V1 documentation


      @{"Introduction" link INTRO}
      @{"Requirements" link REQ}
 @{"Copyright & Disclaimer" link COPY}
         @{"Usage" link USE}
    @{"Technical notes" link TECH}
         @{"Author" link AUTO}
@ENDNODE

@NODE INTRO "Introduction"
Have you ever noticed, that Eric Schwartz animations using Movieplayer
and the system alerts cannot make use of the VGA screenmodes, even if
you use a screenmode promotion utility ?
So on monitors like the 1942 and the M1438 there will be ugly black
spaces between the lines and on VGA monitors you will only see a big
mess.

This program forces all programs using your preferred screenmode,
if they use the View functions of graphics.library. This is the case
for intuition screens, for alerts and for most animation players, but
usually games and demos will hit the hardware directly and therefore
will not work.
@ENDNODE

@NODE REQ "Requirements"
VGApatch requires:

OS2.0 or better,
ECS chipset or better,
and a VGA, Multisync, 1942 or M1438 monitor or something like that.
@ENDNODE

@NODE COPY "Copyright & Disclaimer"
Note that this is a patch and patches can cause problems !
Use it at your own risk !
I am not responsible for anything that happens, especially
if it is something bad. :-)

VGApatch is Freeware, copyrighted by @{"me" link AUTO}.
You can copy it for free and use it for free, but do not charge
anything for it (except for a REALLY SMALL copying fee).

Distribution is allowed on Aminet, Meeting Pearls and Fish CDROMs.
If you put it on a PD/Shareware collection disk or CDROM or on a cover
disk of a disk magazine, then please send me a free copy.
@ENDNODE

@NODE USE "Usage"
VGApatch can be started from CLI only:

         VGApatch <modeid>
or       run >NIL: VGApatch <modeid>

To stop it you can send a CTRL-C to it.
If it was started with RUN, you can use the STATUS and BREAK commands
for that, otherwise simply press CTRL-C.

<modeid> is one of following:

         39024     for Multiscan monitor
         69024     for Euro72 monitor
         99004     for DblNTSC monitor
         a9004     for DblPAL monitor

Command line parsing is done very simple, so do not expect "VGApatch ?"
to work.
There might be small memory loss if using old OS1.3 programs like
Movieplayer. Sorry, I found no way around it.
If VGApatch forces a new screen mode, it centers the visible area in the
upper left of the screen. I hope that this does not cause problems.

The hint of the day:
I have added these Tooltypes to the Multiscan monitor icon and
adjusted the Overscan preferences. Now I have a 640x480 pixels
display running at 63Hz.

  TOTROWS=0x1fc
  TOTCLKS=0x6f
  HBSTRT=0x01
  HBSTOP=0x21
  VBSTRT=0x00
  VBSTOP=0xccd
@ENDNODE

@NODE TECH "Technical notes"
Well, this looks like the source code :-)



******************
*  VGApatch V1   *
* (C) 22-Jan-96  *
* Martin Gierich *
******************

;--------------------------------------------------------------

	INCDIR	Source:StripInc/
	INCLUDE	exec/exec_lib.i
	INCLUDE	graphics/graphics_lib.i
	INCLUDE	graphics/view.i
	INCLUDE	graphics/monitor.i

CALL	MACRO
	jsr	_LVO\1(a6)
	ENDM

;--------------------------------------------------------------
start:	clr.b	-1(a0,d0.l)	null-end argumentline
	move.l	a0,a2
	move.l	4.w,d6		d6=exec.library
	lea	gfxname(pc),a1
	moveq	#36,d0
	move.l	d6,a6
	CALL	OpenLibrary
	move.l	d0,d7		d7=graphics.library
	beq	NoGfx
	moveq	#0,d0
	moveq	#0,d1
.A	move.b	(a2)+,d1	get hexadecimal number
	cmp.b	#"0",d1
	blo.s	.B
	cmp.b	#"9",d1
	bls.s	.C
	bset	#5,d1
	cmp.b	#"a",d1
	blo.s	.B
	cmp.b	#"f",d1
	bhi.s	.B
	sub.b	#"a"+10+"0",d1
.C	sub.b	#"0",d1
	lsl.l	#4,d0
	or.b	d1,d0
	bra.s	.A
.B	lea	NewMoni(pc),a0
	move.l	d0,(a0)
	beq	NoMon
	and.l	#MONITOR_ID_MASK,d0
	sub.l	a1,a1
	move.l	d7,a6
	CALL	OpenMonitor
	lea	MonSpec(pc),a0
	move.l	d0,(a0)
	beq.s	NoMon
	move.l	d0,a1
	move.l	ms_LegalView+0(a1),4(a0)

	move.l	d7,a1		patch MakeVPort
	move.l	#_LVOMakeVPort,d0
	lea	Patch(pc),a0
	exg.l	d0,a0
	move.l	d6,a6
	CALL	SetFunction
	lea	OldFunc(pc),a0
	move.l	d0,(a0)
	beq.s	NoSet
	CALL	CacheClearU	self modifying code :-)

WaitC	moveq	#0,d0
	moveq	#0,d1
	bset	#12,d1
	jsr	_LVOSetSignal(a6)
	moveq	#0,d0
	bset	#12,d0
	jsr	_LVOWait(a6)	wait for CTRL-C
	move.l	d7,a1
	lea	Patch(pc),a0	check for other patches
	cmp.l	_LVOMakeVPort+2(a1),a0
	bne.s	WaitC

	move.l	d7,a1		unpatch MakeVPort
	move.l	#_LVOMakeVPort,d0
	move.l	OldFunc(pc),a0
	exg.l	d0,a0
	move.l	d6,a6
	CALL	SetFunction
NoSet	move.l	MonSpec(pc),a0	free stuff
	move.l	d7,a6
	CALL	CloseMonitor
NoMon	move.l	d7,a1
	move.l	d6,a6
	CALL	CloseLibrary	
NoGfx	moveq	#0,d0
	rts

;--------------------------------------------------------------

Patch:	movem.l	d0-d1/a0-a4,-(sp)
	move.l	a0,a3			a3=View
	move.l	a1,a2			a2=ViewPort
	CALL	GfxLookUp
	move.l	d0,a4			a4=ViewExtra (found)
	tst.l	d0
	bne.s	VEfnd
	moveq	#VIEW_EXTRA_TYPE,d0
	CALL	GfxNew
	move.l	d0,a4			a4=ViewExtra (created)
	tst.l	d0
	beq.s	NoPtch
	move.l	d0,a1
	move.l	a3,a0
	CALL	GfxAssociate
	bra.s	VEcrt

VEfnd	move.l	a2,a1	only patch ColorMap, if ViewExtra was found
	move.l	vp_ColorMap(a2),d0
	beq.s	NoPtch
	move.l	d0,a2
	tst.b	cm_Type(a2)
	beq.s	NoPtch
	move.l	a1,cm_vp(a2)
	move.l	MonSpec(pc),d0
	cmp.l	ve_Monitor(a4),d0	check if right monitor present
	beq.s	NoPtch
	move.l	cm_VPModeID(a2),d0
	and.l	#MONITOR_ID_MASK,d0	check for default monitor
	beq.s	VEcrt
	move.l	NewMoni(pc),d0
	move.l	d0,cm_VPModeID(a2)
	move.w	d0,vp_Modes(a1)
	CALL	FindDisplayInfo
	move.l	d0,cm_NormalDisplayInfo(a2)
	move.l	d0,cm_CoerceDisplayInfo(a2)

VEcrt	move.l	a3,ve_View(a4)
	lea	MonSpec(pc),a0
	move.l	(a0),ve_Monitor(a4)
	move.w	4(a0),v_DxOffset(a3)
	move.w	6(a0),v_DyOffset(a3)
	or.w	#V_EXTENDED_MODE,v_Modes(a3)

NoPtch	movem.l	(sp)+,d0-d1/a0-a4
	dc.w	$4ef9	jump to old jumpin
OldFunc	dc.l	0

NewMoni	dc.l	0	Global variables
MonSpec	dc.l	0
Voffset	dc.w	0,0

;--------------------------------------------------------------

gfxname	dc.b	"graphics.library",0
version	dc.b	"$VER: VGApatch 1.0 (22.1.96)",10,0

@ENDNODE

@NODE AUTO "Author"
Though this is a quite small program, I have spent lots of time in it,
because I had to find out how to make it work. Since this View stuff
of graphics.library is not well documented, this was a quite hard job.

It would be nice if you would write me a mail or (even better) a picture
postcard if you use this program.

Snail Mail:

  Martin Gierich
  Narzissenweg 7
  76297 Stutensee
  GERMANY

EMail:

  uj3w@rz.uni-karlsruhe.de
  uj3w@ibm3090.rz.uni-karlsruhe.de
@ENDNODE
