; Program: TST_WRAP.S
;
; Author:  BKM
; Copyright (c) 1992, BKM, All Rights Reserved
;
; History:
;  It seemed to me that the best place to start in checking for
;   why the Monochrome screen would wrap in certain programs was
;   to determine what the programs that wrapped were doing.
;   The best program that I have found is MONST2 (Debugger).
;  I noticed that the screen would wrap when I used the 'V'
;   command.  This lead me to the idea that what was happening
;   was a problem with the program changing the physical and 
;   logical screen addresses.
;  It did not matter what you passed for the values to Physbase
;   or Logbase.  Only passing the resolution from a variable 
;   or as a constant mattered.  If I passed a -1, the program 
;   would not wrap.
;
;**************************************
; System equates...
;**************************************
GEMDOS		equ	$01
XBIOS		equ	$0e

; GEMDOS functions...
SetBlock	equ	$4a
Pterm		equ	$4c

; XBIOS functions...
Setscreen	equ	$05
Supexec		equ	$38
;**************************************
	text
_Start:
		move.l	$04(sp),a3		; Basepage
		move.l	$0c(a3),d0		; TEXT length
		add.l	$14(a3),d0		; DATA length
		add.l	$1c(a3),d0		; BSS length
		add.l	#$100,d0		; stack size
		move.l	#Mystack,sp		; Use it
		move.l	d0,-(sp)		; Shrink memory
		clr.w	-(sp)
		move.w	#SetBlock,-(sp)
		trap	#GEMDOS
		add.l	#12,sp
_Get_Res:
		move.w	#4,-(sp)		; Get resolution
		trap	#XBIOS			; and save it.
		addq.l	#2,sp
		move.w	d0,Res
_Set_Res:
		move.w	Res,-(sp)		; Setscreen
		move.l	#-1,-(sp)		; using original values
		move.l	#-1,-(sp)
		move.w	#Setscreen,-(sp)
		trap	#XBIOS
		add.l	#12,sp
_Exit:
		clr.w	-(sp)			; No return code
		move.w	#Pterm,-(sp)		; Exit not resident
		trap	#GEMDOS
		illegal				; If it ever gets here
						; we're in big trouble!!!

		even
		bss
Res		ds.w	1			; Hold Current Resolution
		ds.l	100			; Space for stack goes here
Mystack		ds.l	0
