;	SNAP    A screen dump routine
;
;------	EQUATES -------------------------
;	
;	BDOS LOCATIONS
BOOT	EQU	00	;warmboot
BDOS	EQU	05	;BDOS call
;
;	PROGRAM CONSTANTS
CR	EQU	0Dh	;carraige return
SCRN1	EQU	0A000H	;put the screen here in bank 1
SCRN8	EQU	0C000H	;the screen is here in bank 8
SCRNSIZ EQU	0CBFH-SCRN8 ;screen length
SCRNWID	EQU	80	; 80 column wide screen
SCRNLN	EQU	24	; 24 lines per screen
;
;---------------MACROS----------------------
;
;			;;Bank switching macro
ONE	EQU	01H
SEVEN	EQU	41H
EIGHT	EQU	81H
BANK	MACRO	NUMBER		;;Enable bank #
	MVI	A,NUMBER
	OUT	0
	ENDM
;				
BLKMOVE MACRO	FROM,TO,LENGTH  ;;Block move
	LXI	H,FROM
	LXI	D,TO
	LXI	B,LENGTH
	DB	0EDH,0B0H	;z80 LDIR
	ENDM
;------------------------------------------------
;	MAIN
;------------------------------------------------
	ORG	100H
	LXI	SP,STAK
;
	BANK	SEVEN		;enable screen
	BLKMOVE SCRN8,SCRN1,SCRNSIZ	;Move screen to bank 1
	BANK	ONE		;Back to bank one
	MVI	B,SCRNLN	;B=lines
	LXI	H,SCRN1		;HL=adr of byte to print
;Loop for each line
LINLOOP	MVI	C,SCRNWID	;C=columns
;Loop for each column
COLOOP	MOV	E,M		;put char in E
	CALL	LCHAR		;PRINT IT
	INX	H		;next column
	DCR	C		;decrment col count
	SUB	A		;
	CMP	C		; is it zero yet?
	JNZ	COLOOP		;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	LINLOOP		;Go do next line
EXIT	MVI 	E,CR		;End with CR
	CALL	LCHAR
	CALL	BOOT		; and out
;
LCHAR	PUSH	B		;Save BC and HL
	PUSH	H
	MVI	C,05		;List out
	CALL	BDOS
	POP	H		;restore
	POP	B
	RET
;
	DS	64		;Stack
STAK	DW	0
	END
