; PRTSCRN  -- PRINTSCREEN RSX --
;------------------------------------------------------------------
;	A memory resident print screen utility for the Osborne Exec
;
; USAGE
;	Once the command PRTSCRN is issued, the program will remain 
;	available for use until the next cold boot (System Reset).
;	PRTSCRN may be included as a command in the EXECST batch line.
;
;	Once loaded typing ^\ (control backslash) will print the 
;	screen on the listing device.
;
;	The command may be used from within any program when the 
;	program calls for keyboard input so long as the program
;	meets the following specifications:
;	1.  Does not use RAM above D400 hex
;	2.  Use BDOS (not BIOS) calls for keyboard input.
;	3.  Will ignore keyboard input of ^\ (otherwise change
;		the Marker character in the ASM source and
;		re-assemble).
;
;	Copyright 1985 by Gordon Wilk
;			  6707 Springpark Ave
;			  Los Angeles CA 9005
;	May be copied for personal non-commercial uses
;
;-------------------------------------------------------------------
;		--- RSX HEADER ---
;
SERIAL:		DB	0,0,0,0,0,0	;for loader use
START:		JMP	ORIGIN		;to start of RSX code
NEXT:		JMP	$-$		;filled in by loader
PREV:		dw	0		;filled in by loader
REMOVE:		DB	0		;DON'T remove
NONBANK:	DB	0		;banked
RNAME		DB	'PRTSCRN '	;8 char rsx name
LOADER:		DB	0,0,0		;for loader use
;
;
;		--- EQUATES ---
;	
CONIN		EQU	01	;console input
DIRIO		EQU	06	;console direct input
CR		EQU	0Dh	;carraige return
Scrn1		EQU	0D430h	;put the screen here in bank 1
Scrn7		EQU	0C000h	;the screen is here in bank 7
ScrnSiz 	EQU	00BCFh 	;screen length w/o attribute bytes
ScrnWid		EQU	80	; 80 column wide screen
ScrnLns		EQU	24	; 24 lines per screen
Marker		EQU	28	; The control character to print 
;				;  the screen = ^\
Bank1		EQU	01H	;Bank one switch byte
Bank7		EQU	41H	;Bank 7 switch byte
;
; THE NEXT TWO EQUEATES ARE CORRECT FOR VERSION 1.0 BIOS ONLY
; Run Install to modify for other versions
MOVE		EQU	0FB3Bh	;address of BIOS routine
XMOVE		EQU	0FB8Ah	;address of BIOS routine
;
;-------------------------------------------------------------
;		RSX PROCESSOR
;-------------------------------------------------------------
ORIGIN:
		MOV	A,C		;which BDOS function?
		CPI	CONIN		;catch it
		JZ	Caught
		CPI	DIRIO		;catch it
		JNZ	NEXT		;otherwise pass it on
;					; to BDOS and quit by jump
;	
Caught:
		LXI	H,0		;save current stack
		DAD	SP		; in staksav
		SHLD	StakSav
		LXI	SP,LocStak	;set up a local stack
;
		CALL	NEXT		;Pass call on to BDOS
;					; to see what character
;					; comes back
;
		PUSH    PSW		;Save that character
		CPI	Marker		;Is it the char we want to see?
		CZ	SNAP		;If so print the screen
		POP	PSW		;Finished, get the char back
		LHLD	StakSav		;Restore the stack
		SPHL			; and
		RET			;    quit
;------------------------------------------------
;		SNAP    A screen dump routine
;------------------------------------------------
;
SNAP:
		MVI	C,Bank7		;source bank
		MVI	B,Bank1		;destination bank
		CALL	XMOVE		;BIOS set for interbank move
;
		LXI	D,Scrn7		;source address
		LXI	H,Scrn1		;destination address
		LXI	B,ScrnSiz	;size
		CALL	MOVE		;BIOS do interbank move
;
		MVI	B,ScrnLns	;B=lines
		LXI	H,Scrn1		;HL=adr of byte to print
;Loop for each line
LineLoop	MVI	C,ScrnWid	;C=columns
;Loop for each column
ColLoop		MOV	E,M		;put char in E
		CALL	ListChar	;PRINT IT
		INX	H		;next column
		DCR	C		;decrement col count
		SUB	A		;
		CMP	C		; is it zero yet?
		JNZ	ColLoop		;NO, not at end of line
		DCR	B		;EOL - decrement line count
		CMP	B		; is it zero yet?
		JZ	Exit		;YES - done
		LXI	D,128-80	;NO, skip over line extensions
		DAD	D
		JMP	LineLoop	;Go do next line
Exit		MVI 	E,CR		;End with CR
;
ListChar	PUSH	B		;Save BC and HL
		PUSH	H
		MVI	C,05		;List out
		CALL	NEXT		;which is how an RSX calls BDOS
		POP	H		;restore
		POP	B
		RET
;
StakSav		DW	0		;Where we save the old stack
		DS	32		;Our local stack
LocStak		DW	0
		END
