; Program:  WRAP_FIX.S
; Version 1.50
;
; Author:  BKM
; Copyright (c) 1992, BKM, All rights reserved
;
; Purpose:
;  This program will attempt to 'fix' the screen wrap on the Mega/STe
;  while in mono.
;
; How:
;  Whenever the Mega/STe is in monochrome and a setscreen (XBIOS 5) 
;  command is executed, with the resolution being passed as anything 
;  other than a -1, the screen can wrap.  We will replace the XBIOS 
;  (TRAP #14) routine with one that checks for a setscreen command and
;  for a parameter of 2 for the resolution.  If so, we will replace
;  the resolution value with -1.  It will then fall through to the old
;  XBIOS routine.
;
;**************************
GEMDOS		equ	$01
BIOS            equ	$0d

; GEMDOS Routines
Cconws		equ	$09
Ptermres        equ	$31

; BIOS Routines
Setexec         equ	$05

; XBIOS Routines
Setscreen       equ	$05
;**************************
	text
_start:
	lea	_end,a3			; Get program size
	suba.l	4(sp),a3
_get_vec:
	move.l	#-1,-(sp)		; Get XBIOS vector
	move.w	#46,-(sp)
	move.w	#Setexec,-(sp)
	trap	#BIOS
	addq.l	#8,sp
	move.l	d0,_oldvc		; Save it
_rep_vec:
	move.l	#_My_Xbios,-(sp)	; Replace with my own
	move.w	#46,-(sp)
	move.w	#Setexec,-(sp)
	trap	#BIOS
	addq.l	#8,sp
_dsp_title:
	move.l	#_Title,-(sp)		; Display Title on screen
	move.w	#Cconws,-(sp)
	trap	#GEMDOS
	addq.l	#6,sp
_finish:
	move.w	#0,-(sp)		; Exit and retain our program
	move.l	a3,-(sp)
	move.w	#Ptermres,-(sp)
	trap	#GEMDOS
	illegal				; If we ever get here, we're
					; in big trouble!
_My_Xbios:
	move.l	usp,a0
	cmpi.w	#Setscreen,(a0)		; Command is Setscreen?
	bne.s	_exit			; No - fall through
	cmpi.w	#$02,$0a(a0)		; Resolution = 2 (Mono?)
	bne.s	_exit			; No - fall through
	move.w	#-1,$0a(a0)		; Yes- replace with -1
_exit:
	movea.l	_oldvc,a0		; Fall through
	jmp	(a0)
	illegal				; If we ever get here, we're
					; in big trouble!
	even
	data

_Title:	dc.b	$0d,$0a,$1b,'p'
	dc.b	'Wrap Fix 1.50',$9e
	dc.b	$1b,'q',$0d,$0a
	dc.b	' (c) BKM 1992 '
	dc.b	$0d,$0a,$00

	even
	bss

_oldvc: ds.l	1
_end:
