; Program to switch to 52, 80, or 104 column screen
; if SCREEN-PAC is installed.
;
; Original by Chris Hill, July 1983
; Modified by Jim Woolley, 11/83
;
; Usage:
;     A>TO arg
; where arg is 52, 80, or 104
;
	LADR	EQU	0E1A5H
	BIOS	EQU	0E4E5H	;location to call
				;in BIOS
	bdos	equ	5
	arg	equ	5ch + 1	;pointer to argument
	offset	equ	4000h	;shadow RAM offset
	scrnpac	equ	2400h	;pointer to screen-pac test value
;	SETSC	EQU	03H	;for 80 columns  
;	SETSC	EQU	00H	;remove leading
;				;semicolon for 52 columns
;	SETSC	EQU	O1H	;remove leading 
				;semicolon for 104 columns
	ORG 	0100H
;
	lxi	h,start		;move code at start to
	lxi	d,offset	;  offset above shadow RAM
	mvi	c,finish-start	;length of code to move
movit	mov	a,m		;from
	stax	d		;to
	inx	h
	inx	d
	dcr	c
	jnz	movit		;continue move
	call	offset		;check if screen-pac
	ani	2
	jz	argval		;jump if yes
	lxi	d,msg1		;else display msg
	mvi	c,9
	jmp	bdos		;done
;
msg1	db	'SCREEN-PAC not installed$'
;
start	di			;code to check if
	out	0		;  screen-pac installed
	lda	scrnpac		;  must run above shadow RAM
	out	1
	ei
	ret
finish	equ	$
;
argval	lda	arg		;get 1st digit
	sui	30h		;convert from ASCII
	jm	quit
	call	x10		;multiply by 10
	mov	c,a		;save it
	lda	arg + 1		;get 2nd digit
	sui	30h		;convert from ASCII
	jm	quit
	add	c		;get whole number
	mov	c,a		;save it
	lda	arg + 2		;see if 3rd digit
	cpi	20h
	mov	a,c		;get back whole number
	jz	check		;jump if no 3rd digit
	call	x10		;else multiply by 10
	mov	c,a		;save it
	lda	arg + 2		;get 3rd digit
	sui	30h		;convert from ASCII
	jm	quit
	add	c		;get whole number
	mov	c,a		;save it
	lda	arg + 3		;see if 4th digit
	cpi	20h
	jnz	quit		;4th digit not allowed
	mov	a,c		;get back whole number
	cpi	104
	mvi	c,1
	jz	ok
check	cpi	52		;verify appropriate value
	mvi	c,0
	jz	ok
	cpi	80
	mvi	c,3
	jz	ok
;
quit	lxi	d,msg2		;tell how to use
	mvi	c,9
	jmp	bdos		;done
;
msg2	db	'Usage:  TO arg, where arg = 52, 80, or 104$'
;
ok 	LXI 	H,LADR		;get address of loc-GET
	          		;ation to change
	mov	m,c		;put appropriate value
				; into that loc.
	jmp	BIOS		;call to extended BIOS
				;and done
;
x10				;get 10*a
	add	a		;2*a
	mov	b,a		;save it
	add	a		;4*a
	add	a		;8*a
	add	b		;10*a
	ret
