;	SCROLL
;
;	By Philip Avery 22-May-08
;
;	Demonstrates hardware scroll for M100/102.
;	Displays a bb ccc etc with hi-speed scroll.
;
;	Uses MTCPM's CONOUT as a stand-alone LCD character printing system.
;	CONOUT is essentially the required M100 ROM routines & tables that drive
;	the LCD extracted into a stand-alone routine. Uses no external memory
;	locations, ie references to FFF#H are changed to locations at the end of
;	this program.
;
;	Assembled by: TASM 	ROM comments by Steve Adolph.
;	
;	CONOUT Input: Reg C contains ASCII char to print on LCD
;
;	Overview of Hardware scrolling:
;
;	Refer to page 229 of HD44102 LCD Driver application notes (pdf)
;	Process: All drivers are turned on, then scrolled to next page, ie move
;	lines up one. Line 4 (assuming lines on LCD are 0-7) is copied into Copy
;	Buffer one driver at a time (50 bytes). Then copied from Buffer to driver
;	immediately above to form line 3.
;
;	The bottom line (7) is cleared, then new line (what would be line 8 before
;	scroll) is sent to line 7. Update LCD RAM to match scrolled screen.
;	
;
;	Only change to ROM LCD code is removal of call to 752BH (Set page to 00
;	on all LCD drivers).
;
;	--------------------------------------------------------------

	.org	55000 	; d6d8h
	
Loop	mvi	e,061h	;a  Generates the text: a bb ccc etc
Loop1	mov 	a,e
	sui	053h
	mov	d,a
Loop2	mov	c,e
	call	Conout
	dcr	d
	jnz	Loop2
	mvi	c,0dh	;cr
	call	Conout
	inr	e
	mov	a,e
	cpi	07bh	;past z?
	jz	Loop
	jmp	Loop1

Linban	ora	a	;Line to Actual Bank conversion
	cpi	4	;Entry: a=Line # to convert
	jm	Linban1
	sui	4	;Convert Linec to Virtual Bank, ie 0-3
Linban1	mov	b,a	;Save Virtual bank
	lda	spage	;LCD page 0-3
	mov	c,a
	mov	a,b
	ora	c
	jz	Linban4	;Virtb & spage = 0
	mov	a,b
Linban3	inr	a
	ani	3
	dcr	c
	jnz	Linban3
Linban4	rrc	;Actual bank. Make xx000000
	rrc	
	ret	;Exit: a=xx000000



Lined	ora	a	;Line to Drivers conversion
	cpi	4	;Entry: a=Line # to convert
	jm	Lined1
	mvi	a,0e0h	;Lines 4-7, turn on lower drivers
	out	0b9h
	in	0bah
	ori	3
	out	0bah
	jmp	Lined2
Lined1	mvi	a,1fh	;Lines 0-3, turn on upper drivers
	out	0b9h
	in	0bah
	ani	0fch
	out	0bah
Lined2	ret

Bmove	mov	a,m	;Block move HL to DE for BC
	stax	d
	inx	h
	inx	d
	dcx	b
	mov	a,b
	ora	c
	jnz	Bmove
	ret

Erasel	di		;Erase line. Entry: a=line#
	call	Lined	;Turn on drivers
	call	Linban	;Determine bank
	out 	0feh	;Turn on banks
	mvi	b,50
	xra	a
Erase1	call	R7548H	;Lcd wait
	out	0ffh	;Clear driver bytes (bottom line)
	dcr	b
	jnz	Erase1
	ei
	ret

Scroll	push	psw
	push	b
	push	d
	push	h
	
Keyp	call	7242h	;Check for key to Pause
	jz	Scroll1
Keyp0	lxi	h,0f00h	; Paused
Keyp1	dcx	h
	mov	a,h
	ora	l
	jnz	Keyp1
Keyp2	call	7242h	;Ending pause?
	jz	Keyp2	;No

		
Scroll1	lda	spage	;LCD page 0-3
	inr	a	;Calc next LCD page, ie scroll up a line
	ani	3
	sta	spage
	dcr	a
	ani	3
	sta	bbank	;Bottom bank (LCD page - 1)
	di
	mvi	a,0ffh	;Turn on LCD drivers E0-E7
	out	0b9h
	in	0bah	;Turn on LCD drivers E8-E9
	ori	3
	out	0bah
	
	lda	spage	;Get next LCD page count (0-3) xx
	rrc		;Make xx111110
	rrc
	ori	62	;Scroll command
	ani	0feh
	out	0feh	;Scroll all drivers
	
Scopy	lxi	h,copyt	;Copy Table. Copy line 4 to 3 (bottom drivers to top drivers)
	mvi	a,1	;Init Dest driver (driver 0)
	sta	destd	;Store Dest driver
Scopy1	mov	a,m	;Get B9h select
	out	0b9h	;Turn on Source driver
	inx	h	;Get BAh select
	in	0bah
	ani	0fch
	ora	m
	out	0bah
	inx	h
	push	h	;Store copyt pointer
	lda	bbank	;Get which bank to copy from xx
	rrc		;Make xx000000 (byte select=0)
	rrc
	out	0feh	
	lxi	h,copyb	;Copy buffer (50 bytes)
	mvi	b,50	;Copy 50 bytes
	call	R7548H	;Lcd wait
	in	0ffh	;Dummy read required
Scopy2	call	R7548H	;Lcd wait
	in	0ffh	;Get display byte
	mov	m,a
	inx	h
	dcr	b
	jnz	Scopy2	;Get next byte
	lda	destd	;Get Dest driver
	out	0b9h	;Always 0-4
	in	0bah	;Turn off drivers 8&9
	ani	0fch
	out	0bah
	lda	bbank
	rrc
	rrc
	out	0feh
	lxi	h,copyb	;Copy buffer (50 bytes)
	mvi	b,50	;Get 50 bytes
Scopy3	mov	a,m
	call	R7548H	;Lcd wait
	out	0ffh	;Send display byte
	inx	h
	dcr	b
	jnz	Scopy3
	lda	destd	;Copied 1 driver, do others
	rlc	
	cpi	20h	;Done 5 drivers?
	jz	Scopy4
	sta	destd	;No
	pop	h	;Get copyt pointer
	jmp	Scopy1
Scopy4	ei
	pop	h	;Get copyt pointer - fix stack
	pop	h
	pop	d
	pop	b
	pop	psw
	ret

Conout	push	psw	; Save registers
	push	b
	push	h
	push	d
	mov	a,c
	cpi	0dh	;Check for CR
	jz	Conout2
	cpi	08h	;Check for delete
	jz	Conout4

Conout1	call	R73EEH
	lda	RFFF5H	; Col
	inr	a
	cpi	40	; Past eol?
	jnz	Conoute	

Conout2	lda 	scred	;Scrolled already?
	ora	a
	jnz	Conou2a
	lda	RFFF4H	;Then do CR
	inr	a
	cpi	8	;Beyond bottom of screen?
	jnz	Conout3
Conou2a	Call	Scroll	;Yes, then scroll
	mvi	a,1
	sta	scred
	lda	spage	;Mod row to suit page
	ora	a
	jnz	Conou2b
	mvi	a,7
	jmp	Conou2c
Conou2b	adi	3
Conou2c	sta	RFFF4H
	mvi	a,7	;Erase Line 7
	call	Erasel
	lxi	h,lcdram ;'Scroll' LCD RAM
	mov	d,h
	mov	e,l
	lxi	b,40
	dad	b
	call	Bmove	;Block move
	jmp	Conou3b

Conout3	sta	RFFF4H	;Next row
Conou3b	xra	a	;Col = 0
	jmp	Conoute
Conout4	lda	RFFF5H	;Col
	ora	a
	jz	Conout5	;Is it zero? Go up a row
	dcr	a
	jmp	Conoute
Conout5	lda	RFFF4H	;Row
	dcr	a
	sta	RFFF4H
	mvi	a,39	;End of previous row

Conoute	sta	RFFF5H
	pop	d
	pop	h	;Restore registers
	pop	b
	pop	psw
	ret		;To BIOS

R73EEH	CALL 	R765CH   ; Set interrupt to 1DH	Character plotting level 7.  Plot character in C on LCD at (H,L)
	MOV 	A,C
	LXI 	D,R7710H
	SUI 	20H
	JZ 	R7410H
	INX 	D
	CPI 	60H
	JC 	R7410H
	LXI 	D,R76B1H
R7410H	PUSH	PSW
	MOV 	L,A
	MVI 	H,00H
	MOV 	B,H
	MOV 	C,L
	DAD	H
	DAD 	H
	DAD 	B
	POP 	PSW
	PUSH 	PSW
	JC 	R741FH
	DAD 	B
R741FH	DAD 	D
	POP 	PSW
	JNC 	R7430H
	LXI 	D,0FFECH    ; Cursor bit pattern storage
	PUSH 	D
	MVI 	B,05H
	CALL 	R2542H     ; Move B bytes from M to (DE)
	XRA 	A	
	STAX 	D	
	POP 	H	
R7430H	MVI 	D,01H	
	CALL 	R74A2H	; Byte Plot - Send bit pattern to LCD for character
			
	;CALL 	R752BH	; init LCD drivers
			
R743CH	MVI 	A,09H	
	SIM	
	RET	
	
	CALL 	R765CH   ; Set interrupt to 1DH	
	DCR 	D	
	DCR 	E	
	XCHG	
	SHLD 	RFFF4H	
	JMP 	R743CH	
			
;============================================	============================================	;		744C	Turns on the pixel (x,y) Where D contains x and E contains y.
;		744D	Turns off the pixel (x,y) Where D contains x, and E contains y.
;			Plot (set) point (D,E) on the LCD
	ORI 	0AFH	;or A with  1010 1111 - meaningless -  carry on to 744EH for PLOT
;============================================	============================================
	XRA 	A	; tricky entrance command - xor A for UNPLOT
			
	PUSH 	PSW	
	CALL 	R765CH	; Set interrupt to 1DH
	PUSH 	D	
	MVI 	C,0FEH	
	MOV 	A,D	
R7456H	INR 	C	; loop to find out how many drivers to skip over based on D, column data.  C will be 00, 02, 04, 06, 08
	INR 	C	
	MOV 	D,A	
	SUI 	32H	
	JNC 	R7456H	
	MVI 	B,00H	
	LXI 	H,R7643H ; point HL to upper LCD chip selects vectors
	MOV	A,E	; load A with y data
	RAL		; 3 rotations, identify upper or lower LCD 
	RAL	
	RAL	
			
	JNC 	R746DH	; jump ahead if carry not set -- do not change vector
	LXI 	H,R764DH	; point HL to lower LCD chip selects vectors
R746DH	DAD 	B	; adds an offset to either table entry of BC
	MOV 	B,A	
			
	CALL 	R753BH     ; Enable LCD drivers after short delay	
	MOV 	A,B	
	ANI 	0C0H	
	ORA 	D	; create the command byte.
	MOV 	B,A	
	MVI 	E,01H	
	LXI 	H,0FFECH    ; Cursor bit pattern storage	
	CALL 	R74F5H	; this routine sends a byte as a command, and reads or writes E values depending on D…command is in A, HL points to character table.  Read back one character and put it in HL.
	POP	D	
	MOV 	D,B	
	MOV 	A,E	
	ANI 	07H	
	ADD 	A	
	MOV 	C,A	
	MVI 	B,00H	
	LXI 	H,R7643H    ; 8155 PIO chip bit patterns	pattern of 2^n, n=10.
	DAD 	B	
	POP 	PSW	
	MOV 	A,M	
	LXI 	H,0FFECH    ; Cursor bit pattern storage	
	JNZ 	R7497H	
	CMA	
	ANA 	M	
	MVI 	B,0B6H
	jmp	R7498H
R7497H	ora	m	
R7498H	MOV 	M,A	
	MOV 	B,D	
	MVI 	E,01H	
	CALL 	R74F6H	; this routine sends a byte as a command, and reads or writes E values depending on D…command is in A, HL points to character table
	JMP 	R743CH	
			
;============================================	============================================
R74A2H	PUSH 	H	; Byte Plot - Send bit pattern to LCD for character, HL [points to 6 byte character data
	MVI 	E,06H	; load E with a byte count of 6
	LDA 	RFFF5H	; load accumulator with FFF5 data column position
	CPI 	08H	; compare to 08H
	JZ 	R74B7H	; jump to 74b7 if A=08H
	CPI 	10H	; compare to 10H
	JZ 	R74B9H	; jump to 74b9 if A=10H
	CPI 	21H	; compare to 21H
	JNZ 	R74BBH	;jump to 74bb if A=21H
R74B7H	DCR 	E	
	DCR 	E	
R74B9H	DCR 	E	; this section deals with the characters that overlap the drivers
	DCR 	E	
			
R74BBH	MOV 	C,A	; load C with column position
	ADD 	C	; add C to A
	ADD 	C	; add C to A
	MOV 	C,A	; load C with what is 3x the original column data
	MVI 	B,00H	; load B with 00H- BC holds the table index
	LDA 	RFFF4H	; load accumulator with row location
	RAR		; rotate right
	RAR		; rotate right
	RAR		; rotate right - now accumulator is shifted 3 right through carry.
	LXI 	H,R75C9H	; load HL with 75C9H - pointer to table for lower LCD
	JC 	R74D0H	; if row was 4,5,6,7 then jump forward
	LXI 	H,R7551H ; 8155 PIO chip bit patterns for Upper LCD drivers otherwise, load HL with pointer to upper LCD table
R74D0H	DAD 	B	; now BC holds the index into the table, add it to HL
	MOV 	B,A	; move A to B, B HOLDS ROW DATA
			
	CALL 	R753BH   ; Enable LCD drivers after short delay	
	SHLD 	RFFF6H	; store the contents of HL in FFF6H, the pointer to the LCD table
	MOV 	A,B	; restore A
	ORA 	M	; or A with the contents of HL, which should be the first byte in the table at pointer
	MOV 	B,A	; the initial data word for programming page and column is formed
	POP 	H	; pull hl off stack, hl is pointing to dot matrix bytes (6)
	DCR 	D	; D contains read or write, 1 or zero
	CALL 	R74F7H	; this routine sends a byte as a command, and reads or writes E values depending on D
	INR 	D	; restore D to original value
	MVI 	A,06H	; load A with 06
	SUB 	E	
	RZ		; if 6 bytes were intended to be written, then return, else the remainder must be written to the adjacent driver
	MOV 	E,A	; put the remainder into E
	PUSH 	H	
	LHLD 	RFFF6H	
	INX 	H	; get the next pointer IE next driver
	CALL 	R753BH	; Enable LCD drivers after short delay	enable this driver
	POP	H	
	MOV 	A,B	; B holds the command, set xy address in LCD driver
	ANI 	0C0H	; and A with 1100 0000 H -- restore XY address to 00, set's carry flag to zero
	MOV 	B,A	; put result back in B
	DCR 	D	; decrement D
	JC 	R74F7H	; ?? Odd.  Will never jump here because carry is always 00. Looks like a non-command from 74F4 but..very tricky….And this path carries on at 74F7H	
			
;============================================	============================================
R74F5H	ORI 	0AFH	; the bit plotting routine calls 74F5- meaningless- carry on at 74F7H
;============================================	============================================
R74F6H	XRA 	A	; the bit plotting routine calls 74F6 - inverts A
;============================================	============================================
R74F7H	PUSH 	D	; this routine sends a byte as a command, and reads or writes E values depending on PSW…command is in B, HL points to character table
	PUSH 	PSW	; A is either cleared, or set to some value.
	MOV 	A,B	
	CALL 	R7548H   ; Wait for LCD driver to be available	
	OUT 	0FEH	; send command in A to LCD drivers
	JZ 	R7507H	; if D was one, continue else jump to 7507
	CALL 	R7548H   ; Wait for LCD driver to be available	
	IN 	0FFH	; get a data byte from the selected driver
R7507H	POP 	PSW	
	JNZ 	R751BH	; if D was a zero, then jump ahead to 751B
R750BH	IN 	0FEH	
	RAL	
	JC 	R750BH	; test for status of LCD driver again, wait for ready
	MOV 	A,M	; HL points to xy data in LCD driver table…load in A
	OUT 	0FFH	; program data to LCD driver with data in A
	INX 	H	; increment HL
	DCR 	E	; decrement E
	JNZ 	R750BH	; if not zero, then more data to write…loop back
	POP 	D	
	RET		; return when E=0
			
R751BH	IN 	0FEH	
	RAL	
	JC 	R751BH	; test for status of LCD driver again, wait for ready
	IN 	0FFH	; get data from LCD
	MOV 	M,A	; put data in HL
	INX 	H	; increment hl
	DCR 	E	; decrement E
	JNZ 	R751BH	; if not zero, then more data to read…loop back
	POP 	D	
	RET		; return when E=0
			
;============================================	============================================
;			set page to 00 on all LCD drivers
R752BH	CALL 	R7533H	; Enable LCD drivers after short delay
	MVI 	A,3EH	; form command 3E
	OUT 	0FEH	; Send page 0 command to LCD drivers
	RET	
;============================================	============================================
R7533H	MVI 	C,03H	; Enable LCD drivers after short delay  HL points to the bit pattern array
	CALL 	R7657H   ; Delay routine - decrement C until zero
	LXI 	H,7641H	; POINT TO LCD DATA TO SELECT ALL DRIVERS
			
;============================================	============================================
R753BH	MOV 	A,M	; Enable LCD drivers.  HL points to the bit pattern array
	OUT 	0B9H	; send M to B9
	INX 	H	; increment HL
	IN 	0BAH	; get current data in BA
	ANI	0FCH	; and with FCh 1111 1100
	ORA 	M	; or A with M
	OUT 	0BAH	; send data to Bah
	INX 	H	; increment HL 
	RET			
			
;============================================	============================================
R7548H	PUSH 	PSW	; Wait for LCD driver to be available
R7549H	IN 	0FEH	; get status from selected driver
	RAL		; rotate left, test for MSB set, which is the status of the LCD driver
	JC 	R7549H	; if carry set (IE busy) then go back and get status again
	POP 	PSW	
	RET		; return if status = 0

;============================================	============================================
R7551H	.DB	01H,00H,00H,01H,00H,06H,01H,00H	; 8155 PIO chip bit patterns for UpperLCD drivers
	.DB	0CH,01H,00H,12H,01H,00H,18H,01H	
	.DB	00H,1EH,01H,00H,24H,01H,00H,2AH	
	.DB	01H,00H,30H,02H,00H,04H,02H,00H	
	.DB	0AH,02H,00H,10H,02H,00H,16H,02H	
	.DB	00H,1CH,02H,00H,22H,02H,00H,28H	
	.DB	02H,00H,2EH,04H,00H,02H,04H,00H	
	.DB	08H,04H,00H,0EH,04H,00H,14H,04H	
	.DB	00H,1AH,04H,00H,20H,04H,00H,26H	
	.DB	04H,00H,2CH,08H,00H,00H,08H,00H	
	.DB	06H,08H,00H,0CH,08H,00H,12H,08H	
	.DB	00H,18H,08H,00H,1EH,08H,00H,24H	
	.DB	08H,00H,2AH,08H,00H,30H,10H,00H	
	.DB	04H,10H,00H,0AH,10H,00H,10H,10H	
	.DB	00H,16H,10H,00H,1CH,10H,00H,22H	
			
R75C9H	.DB	20H,00H,00H,20H,00H,06H,20H,00H	; 8155 PIO chip bit patterns for Lower LCD drivers
	.DB	0CH,20H,00H,12H,20H,00H,18H,20H	
	.DB	00H,1EH,20H,00H,24H,20H,00H,2AH	
	.DB	20H,00H,30H,40H,00H,04H,40H,00H	
	.DB	0AH,40H,00H,10H,40H,00H,16H,40H	
	.DB	00H,1CH,40H,00H,22H,40H,00H,28H	
	.DB	40H,00H,2EH,80H,00H,02H,80H,00H	
	.DB	08H,80H,00H,0EH,80H,00H,14H,80H	
	.DB	00H,1AH,80H,00H,20H,80H,00H,26H	
	.DB	80H,00H,2CH,00H,01H,00H,00H,01H	
	.DB	06H,00H,01H,0CH,00H,01H,12H,00H	
	.DB	01H,18H,00H,01H,1EH,00H,01H,24H	
	.DB	00H,01H,2AH,00H,01H,30H,00H,02H	
	.DB	04H,00H,02H,0AH,00H,02H,10H,00H	; 6C39 and 6C3A
	.DB	02H,16H,00H,02H,1CH,00H,02H,22H	
	.DB	0FFH,03H			; All '1's for selection of all the LCD drivers at once. Calls to 7533H selects all LCD drivers.  Calls to 753BH selects a single driver.
			
;============================================	============================================
	.DB	01H,00H,02H,00H,04H,00H,08H,00H,10H,00H	; LCD chip select patterns / 8155 PIO chip bit patterns
	.DB	20H,00H,40H,00H,80H,00H,00H,01H,00H,02H	; pattern of 2^n, n=10. 00000000 00000001, 00000000 00000010, ….00000010 00000000
			
;============================================	============================================
			; LCD chip select patterns
R7641H	.DB	0FFH,03H	; All '1's for selection of all the LCD drivers at once. Calls to 7533H selects all LCD drivers.  Calls to 753BH selects a single driver.
			
			
;============================================	============================================
R7643H	.DB	01H,00H,02H,00H,04H,00H,08H,00H,10H,00H	; LCD chip select patterns / 8155 PIO chip bit patterns
R764DH	.DB	20H,00H,40H,00H,80H,00H,00H,01H,00H,02H	; pattern of 2^n, n=10. 00000000 00000001, 00000000 00000010, ….00000010 00000000
			
R7657H	DCR 	C	; Delay routine - decrement C until zero
	JNZ 	R7657H  ; Delay routine - decrement C until zero	
	RET	
			
;============================================	============================================
R765CH	DI		; Set interrupt to 1DH
	MVI 	A,1DH	; Mask all interrupts except serial data in RST 6.5
	SIM	
	EI	
	RET

R2542H	MOV 	A,M	; Move B bytes from M to (DE)
	STAX 	D	; Moves B bytes from address in HL to address in DE in an increasing manner
	INX H	
	INX D	
	DCR B	
	JNZ 	R2542H  ; Move B bytes from M to (DE)	
	RET	
			
R76B1H	RLC
	RLC
	ANI 	03H
	RET

R7710H	.DB	00H,00H,00H,00H,00H,00H,00H,00H,4FH	; LCD char generator shape table (20H-7FH
	.DB	00H,00H,00H,07H,00H,07H,00H,14H		; Character set 5-bytes each.
	.DB	7FH,14H,7FH,14H,24H,2AH,7FH,2AH	
        .DB	12H,23H,13H,08H,64H,62H,3AH,45H	
        .DB	4AH,30H,28H,00H,04H,02H,01H,00H	
        .DB	00H,1CH,22H,41H,00H,00H,41H,22H	
        .DB	1CH,00H,22H,14H,7FH,14H,22H,08H	
        .DB	08H,3EH,08H,08H,00H,80H,60H,00H	
        .DB	00H,08H,08H,08H,08H,08H,00H,60H	
        .DB	60H,00H,00H,40H,20H,10H,08H,04H	
        .DB	3EH,51H,49H,45H,3EH,44H,42H,7FH	
        .DB	40H,40H,62H,51H,51H,49H,46H,22H	
        .DB	41H,49H,49H,36H,18H,14H,12H,7FH	
        .DB	10H,47H,45H,45H,29H,11H,3CH,4AH
        .DB	49H,49H,30H,03H,01H,79H,05H,03H
        .DB	36H,49H,49H,49H,36H,06H,49H,49H
        .DB	29H,1EH,00H,00H,24H,00H,00H,00H
        .DB	80H,64H,00H,00H,08H,1CH,36H,63H
        .DB	41H,14H,14H,14H,14H,14H,41H,63H
        .DB	36H,1CH,08H,02H,01H,51H,09H,06H
        .DB	32H,49H,79H,41H,3EH,7CH,12H,11H
        .DB	12H,7CH,41H,7FH,49H,49H,36H,1CH
        .DB	22H,41H,41H,22H,41H,7FH,41H,22H
        .DB	1CH,7FH,49H,49H,49H,41H,7FH,09H
        .DB	09H,09H,01H,3EH,41H,49H,49H,3AH
        .DB	7FH,08H,08H,08H,7FH,00H,41H,7FH
        .DB	41H,00H,30H,40H,41H,3FH,01H,7FH
        .DB	08H,14H,22H,41H,7FH,40H,40H,40H
        .DB	40H,7FH,02H,0CH,02H,7FH,7FH,06H
        .DB	08H,30H,7FH,3EH,41H,41H,41H,3EH
        .DB	7FH,09H,09H,09H,06H,3EH,41H,51H
        .DB	21H,5EH,7FH,09H,19H,29H,46H,26H
        .DB	49H,49H,49H,32H,01H,01H,7FH,01H
        .DB	01H,3FH,40H,40H,40H,3FH,0FH,30H
        .DB	40H,30H,0FH,7FH,20H,18H,20H,7FH
        .DB	63H,14H,08H,14H,63H,07H,08H,78H
        .DB	08H,07H,61H,51H,49H,45H,43H,00H
        .DB	7FH,41H,41H,00H,04H,08H,10H,20H
        .DB	40H,00H,41H,41H,7FH,00H,04H,02H
        .DB	01H,02H,04H,40H,40H,40H,40H,40H
        .DB	00H,01H,02H,04H,00H,20H,54H,54H
        .DB	54H,78H,7FH,28H,44H,44H,38H,38H
        .DB	44H,44H,44H,28H,38H,44H,44H,28H
        .DB	7FH,38H,54H,54H,54H,18H,08H,08H
        .DB	7EH,09H,0AH,18H,0A4H,0A4H,98H,7CH
        .DB	7FH,04H,04H,04H,78H,00H,44H,7DH
        .DB	40H,00H,40H,80H,84H,7DH,00H,00H
        .DB	7FH,10H,28H,44H,00H,41H,7FH,40H
        .DB	00H,7CH,04H,78H,04H,78H,7CH,08H
        .DB	04H,04H,78H,38H,44H,44H,44H,38H
        .DB	0FCH,18H,24H,24H,18H,18H,24H,24H
        .DB	18H,0FCH,7CH,08H,04H,04H,08H,58H
        .DB	54H,54H,54H,24H,04H,3FH,44H,44H
        .DB	20H,3CH,40H,40H,3CH,40H,1CH,20H
        .DB	40H,20H,1CH,3CH,40H,38H,40H,3CH
        .DB	44H,28H,10H,28H,44H,1CH,0A0H,0A0H
        .DB	90H,7CH,44H,64H,54H,4CH,44H,00H
        .DB	08H,36H,41H,41H,00H,00H,77H,00H
        .DB	00H,41H,41H,36H,08H,00H,02H,01H
        .DB	02H,04H,02H,00H,00H,00H,00H,00H
		
;============================================
        .DB	66H,77H,49H,49H,77H,66H,0FCH,86H	; LCD char generator shape table (80H-FFH)
        .DB	0D7H,0EEH,0FCH,00H,7FH,63H,14H,08H	
        .DB	14H,00H,78H,76H,62H,4AH,0EH,00H	
        .DB	0EEH,44H,0FFH,0FFH,44H,0EEH,0CH,4CH	
        .DB	7FH,4CH,0CH,00H,7CH,56H,7FH,56H	
        .DB	7CH,00H,7DH,77H,47H,77H,7FH,00H	
        .DB	00H,00H,7DH,00H,00H,00H,10H,20H	
        .DB	1CH,02H,02H,02H,54H,34H,1CH,16H	
        .DB	15H,00H,41H,63H,55H,49H,63H,00H	
        .DB	24H,12H,12H,24H,12H,00H,44H,44H	
        .DB	5FH,44H,44H,00H,00H,40H,3EH,01H	
        .DB	00H,00H,00H,08H,1CH,3EH,00H,00H	
        .DB	98H,0F4H,12H,12H,0F4H,98H,0F8H,94H
        .DB	12H,12H,94H,0F8H,14H,22H,7FH,22H
        .DB	14H,00H,0A0H,56H,3DH,56H,0A0H,00H
        .DB	4CH,2AH,1DH,2AH,48H,00H,38H,28H
        .DB	39H,05H,03H,0FH,00H,16H,3DH,16H
        .DB	00H,00H,42H,25H,15H,28H,54H,22H
        .DB	04H,02H,3FH,02H,04H,00H,10H,20H
        .DB	7EH,20H,10H,00H,08H,08H,2AH,1CH
        .DB	08H,00H,08H,1CH,2AH,08H,08H,00H
        .DB	1CH,57H,61H,57H,1CH,00H,08H,14H
        .DB	22H,14H,08H,00H,1EH,22H,44H,22H
        .DB	1EH,00H,1CH,12H,71H,12H,1CH,00H
        .DB	00H,04H,02H,01H,00H,00H,20H,55H
        .DB	56H,54H,78H,00H,0EH,51H,31H,11H
        .DB	0AH,00H,64H,7FH,45H,45H,20H,00H
        .DB	00H,01H,02H,04H,00H,00H,7FH,10H
        .DB	10H,0FH,10H,00H,00H,02H,05H,02H
        .DB	00H,00H,04H,0CH,1CH,0CH,04H,00H
        .DB	00H,04H,7FH,04H,00H,00H,18H,0A7H
        .DB	0A5H,0E5H,18H,00H,7FH,41H,65H,51H
        .DB	7FH,00H,7FH,41H,5DH,49H,7FH,00H
        .DB	17H,08H,34H,22H,71H,00H,55H,3FH
        .DB	10H,68H,44H,0E2H,17H,08H,04H,6AH
        .DB	59H,00H,06H,09H,7FH,01H,7FH,01H
        .DB	29H,2AH,7CH,2AH,29H,00H,70H,29H
        .DB	24H,29H,70H,00H,38H,45H,44H,45H
        .DB	38H,00H,3CH,41H,40H,41H,3CH,00H
        .DB	1CH,22H,7FH,22H,14H,00H,08H,04H
        .DB	04H,08H,04H,00H,20H,55H,54H,55H
        .DB	78H,00H,30H,4AH,48H,4AH,30H,00H
        .DB	3CH,41H,40H,21H,7CH,00H,40H,7FH
        .DB	49H,49H,3EH,00H,71H,11H,67H,11H
        .DB	71H,00H,38H,54H,56H,55H,18H,00H
        .DB	3CH,41H,42H,20H,7CH,00H,38H,55H
        .DB	56H,54H,18H,00H,00H,04H,00H,04H
        .DB	00H,00H,48H,7EH,49H,01H,02H,00H
        .DB	40H,0AAH,0A9H,0AAH,0F0H,00H,70H,0AAH
        .DB	0A9H,0AAH,30H,00H,00H,02H,0E9H,02H
        .DB	00H,00H,30H,4AH,49H,4AH,30H,00H
        .DB	38H,42H,41H,22H,78H,00H,08H,04H
        .DB	02H,04H,08H,00H,38H,55H,54H,55H
        .DB	18H,00H,00H,02H,68H,02H,00H,00H
        .DB	20H,54H,56H,55H,7CH,00H,00H,00H
        .DB	6AH,01H,00H,00H,30H,48H,4AH,49H
        .DB	30H,00H,3CH,40H,42H,21H,7CH,00H
        .DB	0CH,50H,52H,51H,3CH,00H,7AH,11H
        .DB	09H,0AH,71H,00H,42H,0A9H,0A9H,0AAH
        .DB	0F1H,00H,32H,49H,49H,4AH,31H,00H
        .DB	0E0H,52H,49H,52H,0E0H,00H,0F8H,0AAH
        .DB	0A9H,0AAH,88H,00H,00H,8AH,0F9H,8AH
        .DB	00H,00H,70H,8AH,89H,8AH,70H,00H
        .DB	78H,82H,81H,82H,78H,00H,00H,45H
        .DB	7CH,45H,00H,00H,7CH,55H,54H,55H
        .DB	44H,00H,7CH,54H,56H,55H,44H,00H
        .DB	0E0H,50H,4AH,51H,0E0H,00H,00H,88H
        .DB	0FAH,89H,00H,00H,70H,88H,8AH,89H
        .DB	70H,00H,3CH,40H,42H,41H,3CH,00H
        .DB	0CH,10H,62H,11H,0CH,00H,3CH,41H
        .DB	42H,40H,3CH,00H,7CH,55H,56H,54H
        .DB	44H,00H,0E0H,51H,4AH,50H,0E0H,00H
        .DB	00H,00H,00H,00H,00H,00H,0FH,0FH
        .DB	0FH,00H,00H,00H,00H,00H,00H,0FH
        .DB	0FH,0FH,0F0H,0F0H,0F0H,00H,00H,00H
        .DB	00H,00H,00H,0F0H,0F0H,0F0H,0FH,0FH
        .DB	0FH,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0FH
        .DB	0FH,0FH,0FH,0FH,0FH,0FH,0FH,0FH
        .DB	0F0H,0F0H,0F0H,0F0H,0F0H,0F0H,0FFH,0FFH
        .DB	0FFH,00H,00H,00H,00H,00H,00H,0FFH
        .DB	0FFH,0FFH,0FFH,0FFH,0FFH,0FH,0FH,0FH
        .DB	0FH,0FH,0FH,0FFH,0FFH,0FFH,0FFH,0FFH
        .DB	0FFH,0F0H,0F0H,0F0H,0F0H,0F0H,0F0H0,0FFH
        .DB	0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
        .DB	00H,00H,0F8H,08H,08H,08H,08H,08H
        .DB	08H,08H,08H,08H,08H,08H,0F8H,00H
        .DB	00H,00H,08H,08H,0F8H,08H,08H,08H
        .DB	00H,00H,0FFH,08H,08H,08H,00H,00H
        .DB	0FFH,00H,00H,00H,00H,00H,0FH,08H
        .DB	08H,08H,08H,08H,0FH,00H,00H,00H
        .DB	08H,08H,0FH,08H,08H,08H,08H,08H
        .DB	0FFH,00H,00H,00H,08H,08H,0FFH,08H
        .DB	08H,08H,3FH,1FH,0FH,07H,03H,01H	
        .DB	80H,0C0H,0E0H,0F0H,0F8H,0FCH,01H,03H	
        .DB	07H,0FH,1FH,3FH,0FCH,0F8H,0F0H,0E0H	
        .DB	0C0H,80H,55H,0AAH,55H,0AAH,55H,0AAH	
		
RFFF4H	.DB	00H	; LCD Row (tricked - see linec)	
RFFF5H  .DB	00H	; LCD Column
RFFF6H	.DB	00H,00H

; For Scrolling
spage	.DB	00h
bbank	.DB	00h	;Bottom bank (for Copy). Source & Dest Bank works out same number
linec	.db	00h	;Line count 0-7 (8)
copyt	.db	20h,00	;Copy Table (B9H,BAH) - Dr 5-0
	.db	40h,00	;Dr 6-1
	.db	80h,00	;Dr 7-2
	.db	00,01	;Dr 8-3
	.db	00,02	;Dr 9-4
copyb	.block	50	;Copy buffer. (Possibly use stack for ROM scroll?)
lcdram	.block	320	;LCD RAM
destd	.db	00
scred	.db	00
	.end
			
			
