0001   0000             ;**************************************************
0002   0000             ;* NAME: linedemo
0003   0000             ;**************************************************
0004   0000             ;* DESCRIPTION:
0005   0000             ;*   6803 TASM line demo
0006   0000             ;*   Copyright (c) 2011 by James Diffendaffer
0007   0000             ;* Version: 1.01
0008   0000             ;* Date: July 20, 2011
0009   0000             ;**************************************************
0010   0000             
0011   0000             ;include MOTO.h
0012   0000             ;defined for tasm.  tasm doesn't normally support motorola directives
0013   0000             .MSFIRST        ; Most Significant byte first
0014   0000             
0015   0000             #define EQU     .EQU
0016   0000             #define ORG     .ORG
0017   0000             #define RMB     .BLOCK
0018   0000             #define FCB     .BYTE
0019   0000             #define FCC     .TEXT
0020   0000             #define FDB     .WORD
0021   0000             #define END	.END
0022   0000             
0023   0000             #define equ     .EQU
0024   0000             #define org     .ORG
0025   0000             #define rmb     .BLOCK
0026   0000             #define fcb     .BYTE
0027   0000             #define fcc     .TEXT
0028   0000             #define fdb     .WORD
0029   0000             #define	end	.END
0030   0000             
0031   0000             
0032   0000             ;**************************************************
0033   0000             ;MC-10 ROM entry vector addresses
0034   0000             ;**************************************************
0035   0000             POLCAT	equ	$FFDC		; Read the keyboard
0036   0000             CHROUT	equ	$FFDE		; Output a character to the current device
0037   0000             CRSDON	equ	$FFE0		; Turn on the Cassette
0038   0000             BLKIN	equ	$FFE2		; Write a block of data to the cassette
0039   0000             BLKOUT	equ	$FFE4		; Read a block of data from the cassette
0040   0000             SNDOUT	equ	$FFE6		; Sound Output
0041   0000             WRTLDR	equ	$FFE8		; Write Leader
0042   0000             GIVABF	equ	$FFEA		; Convert 2 bytes to Basic
0043   0000             INTCNV	equ	$FFEC		; Convert BASIC to 2 bytes
0044   0000             
0045   0000             ;**************************************************
0046   0000             ;MC-10 Graphics hardware definitions
0047   0000             ;**************************************************
0048   0000             #define	screen	$4000		; address of MC-10 screen memory
0049   0000             #define	vdgport	$BFFF		; I/O address to set the VDG mode
0050   0000             #define	SG4	%00000000	; SG4 semigraphics 4 mode bits
0051   0000             #define	SG6	%00000100	; SG6 semigraphics 6 mode bits
0052   0000             #define	CG1	%00100000	; CG1 graphics mode bits
0053   0000             #define	RG1	%00110000	; RG1 graphics mode bits
0054   0000             #define	CG2	%00101000	; CG2 graphics mode bits
0055   0000             #define	RG2	%00111000	; RG2 graphics mode bits
0056   0000             #define	CG3	%00100100	; CG3 graphics mode bits
0057   0000             #define	RG3	%00110100	; RG3 graphics mode bits
0058   0000             #define	CG6	%00101100	; CG6 graphics mode bits
0059   0000             #define	RG6	%00111100	; RG6 graphics mode bits
0060   0000             #define	CSS	%01000000	; color set select bit
0061   0000             
0062   0000             
0063   0000             ;**************************************************
0064   0000             ;* screen parameters
0065   0000             ;*
0066   0000             ;*  Define the graphics mode you are going to use as 1
0067   0000             ;*  This is used to set up all the screen parameters used by
0068   0000             ;*  the graphics routines so they will work in your 
0069   0000             ;*  chosen mode.  Currently only supports RG (2 color)
0070   0000             ;*  graphics modes.
0071   0000             ;**************************************************
0072   0000             #define GFX_RG3	1		; Set the mode we will use here
0073   0000             
0074   0000             
0075   0000             ;**************************************************
0076   0000             ;* sets up the screen parameters based on define above
0077   0000             ;**************************************************
0078   0000~            #ifdef GFX_CG1			; parameters for CG1
0079   0000~            ScreenWidth	equ	64
0080   0000~            ScreenHeight	equ	64
0081   0000~            BytesPerLine	equ	(ScreenWidth)/4
0082   0000             #endif
0083   0000~            #ifdef GFX_CG2			; parameters for CG2
0084   0000~            ScreenWidth	equ	128
0085   0000~            ScreenHeight	equ	64
0086   0000~            BytesPerLine	equ	(ScreenWidth)/4
0087   0000             #endif
0088   0000~            #ifdef GFX_CG3			; parameters for CG2
0089   0000~            ScreenWidth	equ	128
0090   0000~            ScreenHeight	equ	96
0091   0000~            BytesPerLine	equ	(ScreenWidth)/4
0092   0000             #endif
0093   0000~            #ifdef GFX_CG4			; parameters for CG4
0094   0000~            ScreenWidth	equ	128
0095   0000~            ScreenHeight	equ	192
0096   0000~            BytesPerLine	equ	(ScreenWidth)/4
0097   0000             #endif
0098   0000             
0099   0000~            #ifdef GFX_RG1			; parameters for RG2
0100   0000~            ScreenWidth	equ	128
0101   0000~            ScreenHeight	equ	64
0102   0000~            BytesPerLine	equ	((ScreenWidth)/8)
0103   0000             #endif
0104   0000~            #ifdef GFX_RG2			; parameters for RG2
0105   0000~            ScreenWidth	equ	128
0106   0000~            ScreenHeight	equ	96
0107   0000~            BytesPerLine	equ	((ScreenWidth)/8)
0108   0000             #endif
0109   0000             #ifdef GFX_RG3			; parameters for RG3
0110   0000             ScreenWidth	equ	128
0111   0000             ScreenHeight	equ	192
0112   0000             BytesPerLine	equ	((ScreenWidth)/8)
0113   0000             #endif
0114   0000~            #ifdef GFX_RG6			; parameters for RG4
0115   0000~            ScreenWidth	equ	256
0116   0000~            ScreenHeight	equ	192
0117   0000~            BytesPerLine	equ	((ScreenWidth)/8)
0118   0000             #endif
0119   0000             
0120   0000             MAX_X	equ	ScreenWidth-1
0121   0000             MAX_Y	equ	ScreenHeight-1
0122   0000             
0123   0000             ;**************************************************
0124   0000             ;page zero variables
0125   0000             ;**************************************************
0126   0000             temp0	equ	$00A0				; temporary storage location.  used for transfering D to X or X to D etc...
0127   0000             temp1	equ	temp0+2				; temporary storage location.
0128   0000             temp2	equ	temp1+2				; temporary storage location.
0129   0000             temp3	equ	temp2+2				; temporary storage location.
0130   0000             temp4	equ	temp3+2
0131   0000             ; for graphics
0132   0000             ;HX0	equ	temp0+2				; High byte of 16 bit X0 for use in X register, always zero
0133   0000             ;X0	equ	HX0+1				; X0
0134   0000             X0	equ	temp4+2				; X0
0135   0000             HY0	equ	X0+1				; High byte of 16 bit Y0 for use in X register, always zero
0136   0000             Y0	equ	HY0+1
0137   0000             ;HX1	equ	Y0+1				; High byte of 16 bit X1 for use in X register, always zero
0138   0000             ;X1	equ	HX1+1				; X1
0139   0000             X1	equ	Y0+1				; X1
0140   0000             HY1	equ	X1+1				; High byte of 16 bit Y1 for use in X register, always zero
0141   0000             Y1	equ	HY1+1				; Y1	
0142   0000             
0143   0000             ;OE	equ	Y1+1
0144   0000             charptr	equ	Y1+1
0145   0000             fscreen	equ	charptr+2
0146   0000             fcount	equ	fscreen+2
0147   0000             stacktmp	equ	fcount+1
0148   0000             
0149   0000             _endusrvars	equ	stacktmp+2
0150   0000             
0151   0000             ;**************************************************
0152   0000             ; bresenham line routine variables
0153   0000             ;**************************************************
0154   0000             f	equ	_endusrvars	;fdb	0	; Bresenham's variable
0155   0000             dx	equ	f+2	;fdb	0		; delta x
0156   0000             dy	equ	dx+2	;fdb	0		; delta y
0157   0000             sx	equ	dy+2	;fdb	0		; step direction flags
0158   0000             sy	equ	sx+2	;fdb	0
0159   0000             
0160   0000             ;**************************************************
0161   0000             ; graphics text routine variables
0162   0000             ;**************************************************
0163   0000             row	equ	sy+2
0164   0000             col	equ	row+1
0165   0000             
0166   0000             stacktemp	equ	col+1
0167   0000             
0168   0000             
0169   0000             
0170   0000             
0171   0000             ;**************************************************
0172   0000             
0173   0000             ;START	org	$9000		;where to store out program
0174   4C00             START	org	(screen+(BytesPerLine*ScreenHeight))	;start right after screen memory
0175   4C00             ;**************************************************
0176   4C00             ;* NAME: linedemo
0177   4C00             ;**************************************************
0178   4C00             ;* DESCRIPTION:
0179   4C00             ;**************************************************
0180   4C00             linedemo:
0181   4C00             	; save the registers we will modify
0182   4C00             ;	psha
0183   4C00             ;	pshb
0184   4C00             ;	pshx
0185   4C00             
0186   4C00             ; init page zero variables for line/pixel routines
0187   4C00 86 10       	ldaa	#BytesPerLine		; for the multiply in the set routine
0188   4C02 97 AB       	staa	HY0	
0189   4C04 97 AE       	staa	HY1
0190   4C06             ;	clra
0191   4C06             ;	staa	HX0			;clear the MSBs, only used for loading X
0192   4C06             ;	staa	HX1
0193   4C06 BD 4C 46    	jsr	cls
0194   4C09             
0195   4C09             	;***************************
0196   4C09             	; set graphics mode here, make sure you defined it as 1 in the define/equ section above
0197   4C09             	; so that the graphics routines will work for that mode
0198   4C09             	;***************************
0199   4C09 86 74       	ldaa	#RG3+CSS		; the graphics and color mode
0200   4C0B B7 BF FF    	staa	vdgport			; set it
0201   4C0E             
0202   4C0E CC 00 00    	ldd	#$0000			; row, col
0203   4C11 97 C1       	staa	row
0204   4C13 D7 C2       	stab	col
0205   4C15             start:
0206   4C15             
0207   4C15 86 20       lllm:	ldaa	#' '			; the first character in the font
0208   4C17 97 A6       	staa	temp3			; save it as a counter
0209   4C19             llll:
0210   4C19 BD 4D BF    	jsr	print_64		; print the character
0211   4C1C 7C 00 A6    	inc	temp3			; select next character
0212   4C1F 96 A6       	ldaa	temp3			; load it
0213   4C21 81 7E       	cmpa	#'~'			; are we past the last character in the font?
0214   4C23 2F F4       	ble	llll			;  branch if not
0215   4C25             	
0216   4C25             ;	ldaa	row
0217   4C25             ;	cmpa	((ScreenHeight/8)*(BytesPerLine/2))	;#14
0218   4C25             ;	ble	lllm
0219   4C25             
0220   4C25             	
0221   4C25 C6 7F       	ldab	#MAX_X			; start X1 at right of screen
0222   4C27 D7 A6       	stab	temp3
0223   4C29             loopa:
0224   4C29             	; X0,Y0,X1,Y1 are modified in the line drawing routine and must be set for each line
0225   4C29 86 3F       	ldaa	#(MAX_X/2)		; X0 is at the middle of the screen
0226   4C2B 97 AA       	staa	X0
0227   4C2D 4F          	clra				; Y0 is at the top of the screen
0228   4C2E 97 AC       	staa	Y0
0229   4C30 96 A6       	ldaa	temp3
0230   4C32 97 AD       	staa	X1			; set the current X1
0231   4C34             ;	ldaa	#(MAX_Y /2)		; Y1 is half way down the screen
0232   4C34 86 BF       	ldaa	#MAX_Y			; Y1 at the bottom of the screen
0233   4C36 97 AF       	staa	Y1
0234   4C38 BD 4C 6F    	jsr	_line			; draw the line
0235   4C3B             
0236   4C3B 96 A6       	ldaa	temp3			; load X1
0237   4C3D 82 07       	sbca	#7			; subract 7
0238   4C3F 97 A6       	staa	temp3			; save it
0239   4C41 26 E6       	bne	loopa			; go again until X1 = 0
0240   4C43             
0241   4C43             
0242   4C43             
0243   4C43             	
0244   4C43             	
0245   4C43             
0246   4C43             					
0247   4C43             waitkey:
0248   4C43             ;	ldaa	$0002			;check for keypress
0249   4C43             ;	ldx	POLCAT				
0250   4C43             ;	jsr	0,x
0251   4C43             ;	beq	waitkey			; 0 = no key pressed
0252   4C43             
0253   4C43 20 D0       	bra	start
0254   4C45             
0255   4C45 39          	rts
0256   4C46             	
0257   4C46             	
0258   4C46             ;**************************************************
0259   4C46             ;* NAME: cls
0260   4C46             ;**************************************************
0261   4C46             ;* DESCRIPTION:
0262   4C46             ;*  Clears the screen memory to zeros
0263   4C46             ;*
0264   4C46             ;* The stack pointer is used as 2nd pointer register
0265   4C46             ;* but interrupts must be disabled to do this.
0266   4C46             ;* We could just use X as a pointer but PSHX is faster
0267   4C46             ;* than the alternative code
0268   4C46             ;**************************************************
0269   4C46             cls
0270   4C46 3C          	pshx
0271   4C47 37          	pshb
0272   4C48             ;	psha
0273   4C48             	
0274   4C48 30          	tsx				; copy stack pointer to x
0275   4C49 DF C3       	stx	stacktemp
0276   4C4B             ;	wai				;<- uncomment if you want to make sure cls takes place between interrupts
0277   4C4B 0F          	sei				;disable interrupts
0278   4C4C CE 4B FF    	ldx	#screen+(BytesPerLine*(ScreenHeight))-1	;last screen address.
0279   4C4F 35          	txs				;point S to screen top
0280   4C50 CE 00 00    	ldx	#0			;clear the screen to zeros
0281   4C53 C6 60       	ldab	#((BytesPerLine*(ScreenHeight))/32)		;number of loops to clear screen
0282   4C55             clsloop:
0283   4C55 3C          	pshx				; Partially unrolled loop clears at least an entire screen row each pass
0284   4C56 3C          	pshx				;  lets us use an 8 bit loop counter even in RG6
0285   4C57 3C          	pshx				;  so we don't have to dec and test LSB and MSB of loop counter (there is no DECD instruction)
0286   4C58 3C          	pshx				;  32 bytes / pass = first power of 2 with loop counter below 256 (fits in 1 byte)
0287   4C59 3C          	pshx				; Fewer loops also requires fewer loop instructions to execute
0288   4C5A 3C          	pshx				;  and saves a lot of clock cycles.
0289   4C5B 3C          	pshx
0290   4C5C 3C          	pshx
0291   4C5D 3C          	pshx
0292   4C5E 3C          	pshx
0293   4C5F 3C          	pshx
0294   4C60 3C          	pshx
0295   4C61 3C          	pshx
0296   4C62 3C          	pshx
0297   4C63 3C          	pshx
0298   4C64 3C          	pshx
0299   4C65 5A          	decb				;decrement loop counter
0300   4C66 26 ED       	bne	clsloop			;branch until it equals zero
0301   4C68 DE C3       	ldx	stacktemp
0302   4C6A 35          	txs				;restore the stack pointer
0303   4C6B 0E          	cli				;enable interrupts
0304   4C6C             
0305   4C6C             ;	pula
0306   4C6C 33          	pulb
0307   4C6D 38          	pulx
0308   4C6E             
0309   4C6E 39          	rts
0310   4C6F             
0311   4C6F             	
0312   4C6F             ;**************************************************
0313   4C6F             ;* NAME: _line
0314   4C6F             ;**************************************************
0315   4C6F             ;* DESCRIPTION:
0316   4C6F             ;
0317   4C6F             ; line.s				9/20/2008
0318   4C6F             ;
0319   4C6F             ; This is the symmetric Bresenham's line algorithm.
0320   4C6F             ; Based loosely on 6502 Atari code by Bart Jaszcz
0321   4C6F             ;
0322   4C6F             ; author:
0323   4C6F             ;	James Diffendaffer
0324   4C6F             ;
0325   4C6F             ;**************************************************
0326   4C6F             
0327   4C6F             _line:
0328   4C6F 3C          	pshx				; save registers
0329   4C70 37          	pshb
0330   4C71 36          	psha
0331   4C72             	
0332   4C72 4F          	clra				; clear MSB or D register
0333   4C73 D6 AA       	ldab	X0			; get X0 coordinate
0334   4C75 DD B7       	std	f			; store in f
0335   4C77 D6 AD       	ldab	X1
0336   4C79 93 B7       	subd	f			; dx -= f (X1 -= X0)
0337   4C7B DD B9       	std	dx			; differenc in X
0338   4C7D 2B 07       	bmi	negate1			; if dx is negative, negate it
0339   4C7F CC 00 01    	ldd	#1			; otherwise dx is positive
0340   4C82 D7 BD       	stab	sx			; set positive step-x flag
0341   4C84             ;	ldaa	#0			; clear MSB of D for calc_dy
0342   4C84             ;	bpl	calc_dy			; continue to calc dy code
0343   4C84 20 09       	bra	calc_dy			; continue to calc dy code
0344   4C86             
0345   4C86             negate1:				; negate dx so it's now positive
0346   4C86 4F          	clra
0347   4C87 5F          	clrb
0348   4C88 93 B9       	subd	dx
0349   4C8A DD B9       	std	dx
0350   4C8C 7F 00 BD    	clr	sx			; set step-x flag to 0 (negative step)
0351   4C8F             calc_dy:
0352   4C8F 4F          	clra				; MSB of D should already be clear?
0353   4C90             	
0354   4C90 D6 AC       	ldab	Y0			; get Y0 coordinate
0355   4C92 DD B7       	std	f			; store in f
0356   4C94 D6 AF       	ldab	Y1			; get Y1 coordinate
0357   4C96 93 B7       	subd	f			; dy -= f (Y1 -= Y0)
0358   4C98 DD BB       	std	dy			; difference in y
0359   4C9A 2B 06       	bmi	negate2			; if dy is negative, negate it
0360   4C9C 86 01       	ldaa	#1			; otherwise dy is positive
0361   4C9E 97 BF       	staa	sy			; set positive step-y flag
0362   4CA0 20 09       	bra	init			; continue to init code
0363   4CA2             negate2:				; negate dy so it's now positive
0364   4CA2 4F          	clra
0365   4CA3 5F          	clrb
0366   4CA4 93 BB       	subd	dy
0367   4CA6 DD BB       	std	dy
0368   4CA8 7F 00 BF    	clr	sy			; set step-x flag to 0 (negative step)
0369   4CAB             
0370   4CAB BD 4D 69    init:	jsr	_xy_plot_0		; plot endpoints
0371   4CAE BD 4D 8C    	jsr	_xy_plot_1
0372   4CB1             
0373   4CB1 DC B9       	ldd	dx			; compare dx and dy
0374   4CB3 93 BB       	subd	dy	
0375   4CB5             ;	bcc	y_init			; if dx < dy jump to y init
0376   4CB5 2B 58       	bmi	y_init			; if dx < dy jump to y init
0377   4CB7             
0378   4CB7             x_init:
0379   4CB7 DC B9       	ldd	dx
0380   4CB9 04          	lsrd				; divide dx by 2 (interation count)
0381   4CBA CE 00 00    	ldx	#0			; clear x
0382   4CBD 3A          	abx				; store in x register (loop counter)
0383   4CBE             	;asl16	dy			; dy <<= 1
0384   4CBE DC BB       	ldd	dy
0385   4CC0 05          	asld
0386   4CC1 DD BB       	std	dy
0387   4CC3             	
0388   4CC3             	;dif16	f, dy, dx		; f = dy - dx
0389   4CC3 93 B9       	subd	dx
0390   4CC5 DD B7       	std	f
0391   4CC7             	;asl16	dx			; dx <<= 1
0392   4CC7 DC B9       	ldd	dx
0393   4CC9 05          	asld
0394   4CCA DD B9       	std	dx
0395   4CCC             x_loop:
0396   4CCC DC B7       	ldd	f			; load high byte of f into a
0397   4CCE 2B 18       	bmi	change_x		; if f < 0 jump to change x
0398   4CD0 96 BF       	ldaa	sy			; load step-y flag
0399   4CD2 27 08       	beq	skip1			; 0 means negative, jump over positive code
0400   4CD4 7A 00 AF    	dec	Y1			; decrement Y1 coordinate
0401   4CD7 7C 00 AC    	inc	Y0			; increment Y0 coordinate
0402   4CDA 20 06       	bra	subtract_dx		; relative jump to subtract dx (always taken)
0403   4CDC 7C 00 AF    skip1:	inc	Y1			; increment Y1
0404   4CDF 7A 00 AC    	dec	Y0			; decrement Y0
0405   4CE2             subtract_dx:
0406   4CE2             	;sub16	f, dx			; f -= dx
0407   4CE2 DC B7       	ldd	f
0408   4CE4 93 B9       	subd	dx
0409   4CE6 DD B7       	std	f
0410   4CE8             change_x:
0411   4CE8 96 BD       	ldaa	sx			; load step-x flag
0412   4CEA 27 08       	beq	skip2			; 0 means negative, jump over positve code
0413   4CEC 7A 00 AD    	dec	X1			; decrement X1 coordinate
0414   4CEF 7C 00 AA    	inc	X0			; increment X0 coordinate
0415   4CF2 20 06       	bra	x_plot			; branch to x plot (always taken)
0416   4CF4             skip2:
0417   4CF4 7C 00 AD    	inc	X1			; increment X1 coordinate
0418   4CF7 7A 00 AA    	dec	X0			; decrement X0 coordinate
0419   4CFA             x_plot:
0420   4CFA 3C          	pshx
0421   4CFB BD 4D 69    	jsr	_xy_plot_0		; plot endpoints
0422   4CFE BD 4D 8C    	jsr	_xy_plot_1
0423   4D01 38          	pulx
0424   4D02             
0425   4D02             	;add16	f, dy			; f += dy
0426   4D02 DC B7       	ldd	f
0427   4D04 D3 BB       	addd	dy
0428   4D06 DD B7       	std	f
0429   4D08             
0430   4D08 09          	dex				; decrement loop counter (x register)
0431   4D09 26 C1       	bne	x_loop			; jump to top of x loop
0432   4D0B             
0433   4D0B 32          	pula				; restore registers
0434   4D0C 33          	pulb
0435   4D0D 38          	pulx
0436   4D0E 39          	rts				; return from line routine
0437   4D0F             
0438   4D0F             y_init:
0439   4D0F CE 00 00    	ldx	#0
0440   4D12 DC BB       	ldd	dy			; load y difference
0441   4D14 54          	lsrb				; divide dy by 2 (interation count)
0442   4D15 3A          	abx				; store in x register (loop counter)
0443   4D16             	;asl16	dx			; dy <<= 1
0444   4D16 DC B9       	ldd	dx
0445   4D18 05          	asld
0446   4D19 DD B9       	std	dx
0447   4D1B             	;dif16	f, dx, dy		; f = dx - dy
0448   4D1B DC B9       	ldd	dx
0449   4D1D 93 BB       	subd	dy
0450   4D1F DD B7       	std	f
0451   4D21             	;asl16	dy			; dy <<= 1
0452   4D21 DC BB       	ldd	dy
0453   4D23 05          	asld
0454   4D24 DD BB       	std	dy
0455   4D26             y_loop:
0456   4D26 DC B7       	ldd	f			; load high byte of f into a
0457   4D28 2B 18       	bmi	change_y		; if f < 0 jump to change y
0458   4D2A 96 BD       	ldaa	sx			; load step-x flag
0459   4D2C 27 08       	beq	skip3			; 0 means negative, jump over positive code
0460   4D2E 7A 00 AD    	dec	X1			; decrement Y1 coordinate
0461   4D31 7C 00 AA    	inc	X0			; increment Y0 coordinate
0462   4D34 20 06       	bra	subtract_dy		; relative jump to subtract dy (always taken)
0463   4D36             skip3:
0464   4D36 7C 00 AD    	inc	X1			; increment Y1
0465   4D39 7A 00 AA    	dec	X0			; decrement Y0
0466   4D3C             subtract_dy:
0467   4D3C             	;sub16	f, dy			; f -= dy
0468   4D3C DC B7       	ldd	f
0469   4D3E 93 BB       	subd	dy
0470   4D40 DD B7       	std	f
0471   4D42             change_y:
0472   4D42 96 BF       	ldaa	sy			; load step-y flag
0473   4D44 27 08       	beq	skip4			; 0 means negative, jump over positve code
0474   4D46 7A 00 AF    	dec	Y1			; decrement Y1 coordinate
0475   4D49 7C 00 AC    	inc	Y0			; increment Y0 coordinate
0476   4D4C 20 06       	bra	y_plot			; branch to y plot (always taken)
0477   4D4E             skip4:
0478   4D4E 7C 00 AF    	inc	Y1			; increment Y1 coordinate
0479   4D51 7A 00 AC    	dec	Y0			; decrement Y0 coordinate
0480   4D54             y_plot:
0481   4D54 3C          	pshx
0482   4D55 BD 4D 69    	jsr	_xy_plot_0		; plot endpoints
0483   4D58 BD 4D 8C    	jsr	_xy_plot_1
0484   4D5B 38          	pulx
0485   4D5C             
0486   4D5C             	;add16	f, dx			; f += dx
0487   4D5C DC B7       	ldd	f
0488   4D5E D3 B9       	addd	dx
0489   4D60 DD B7       	std	f
0490   4D62             
0491   4D62 09          	dex				; decrement loop counter (x register)
0492   4D63 26 C1       	bne	y_loop			; jump to top of y loop
0493   4D65             
0494   4D65 32          	pula
0495   4D66 33          	pulb
0496   4D67 38          	pulx
0497   4D68 39          	rts				; return from line routine
0498   4D69             
0499   4D69             ;**************************************************
0500   4D69             ;* NAME: 
0501   4D69             ;**************************************************
0502   4D69             ;* DESCRIPTION:
0503   4D69             ; plot the X0,Y0 coordinate
0504   4D69             ;**************************************************
0505   4D69             _xy_plot_0
0506   4D69             	;get address for line Y0
0507   4D69 DC AB       	ldd	HY0
0508   4D6B 3D          	mul				; multiply by 32 (number of bytes/line), 32 is already in high byte
0509   4D6C C3 40 00    	addd	#screen			; add base screen address, d now contains screen line address
0510   4D6F DD A0       	std	temp0			; transfer to x.   TDX and TXD instructions would be so much nicer
0511   4D71 DE A0       	ldx	temp0
0512   4D73             
0513   4D73             	; now add the byte offset for X0
0514   4D73 D6 AA       	ldab	X0			; calculate byte offset for X0
0515   4D75 54          	lsrb				;  just use top 5 bits
0516   4D76 54          	lsrb
0517   4D77 54          	lsrb
0518   4D78 3A          	abx				; add to screen line address, x now contains the screen pointer
0519   4D79 DF A0       	stx	temp0			; save screen address for later
0520   4D7B             
0521   4D7B             	; get the pixel set mask
0522   4D7B CE 4D AF    	ldx	#PixelLookupSet		;clear x
0523   4D7E D6 AA       	ldab	X0			; now get bottom 3 bits of X for pixel info
0524   4D80 C4 07       	andb	#%00000111
0525   4D82 3A          	abx				; add it to x
0526   4D83 A6 00       	ldaa	,x			; get pixel mask
0527   4D85             	; update to the screen
0528   4D85 DE A0       	ldx	temp0			; recover the screen address
0529   4D87 AA 00       	oraa	,x			; OR pixel with current screen data
0530   4D89 A7 00       	staa	,x			; save it back to the screen
0531   4D8B             
0532   4D8B             ;	; get the pixel reset mask
0533   4D8B             ;	ldx	#PixelLookupReset	;clear x
0534   4D8B             ;	ldab	X0			; now get bottom 3 bits of X for pixel info
0535   4D8B             ;	andb	#%00000111
0536   4D8B             ;	abx				; add it to x
0537   4D8B             ;	ldaa	,x			; get pixel
0538   4D8B             ;	; update the screen
0539   4D8B             ;	ldx	temp0			; recover the screen address
0540   4D8B             ;	anda	,x			; and pixel mask with current screen data
0541   4D8B             ;	staa	,x			; save it back to the screen
0542   4D8B             
0543   4D8B 39          	rts				; return
0544   4D8C             	
0545   4D8C             ;**************************************************
0546   4D8C             ;* NAME: 
0547   4D8C             ;**************************************************
0548   4D8C             ;* DESCRIPTION:
0549   4D8C             ; plot the X1,Y1 coordinate
0550   4D8C             ;**************************************************
0551   4D8C             _xy_plot_1
0552   4D8C             	;get address for line Y1
0553   4D8C DC AE       	ldd	HY1
0554   4D8E 3D          	mul				; multiply by 32 (number of bytes/line)
0555   4D8F C3 40 00    	addd	#screen			; add base screen address, d now contains screen line address
0556   4D92 DD A0       	std	temp0			; transfer to x.   TDX and TXD instructions would be so much nicer
0557   4D94 DE A0       	ldx	temp0
0558   4D96             
0559   4D96             	; now add the byte offset for X0
0560   4D96 D6 AD       	ldab	X1			; calculate byte offset for X1
0561   4D98 54          	lsrb				;  just use top 5 bits
0562   4D99 54          	lsrb
0563   4D9A 54          	lsrb
0564   4D9B 3A          	abx				; add to screen line address, x now contains the screen pointer
0565   4D9C DF A0       	stx	temp0				; save screen address for later
0566   4D9E             
0567   4D9E             	; get the pixel set mask
0568   4D9E CE 4D AF    	ldx	#PixelLookupSet		;clear x
0569   4DA1 D6 AD       	ldab	X1			; now get bottom 3 bits of X for pixel info
0570   4DA3 C4 07       	andb	#%00000111
0571   4DA5 3A          	abx				; add it to x
0572   4DA6 A6 00       	ldaa	,x			; get pixel mask
0573   4DA8             	; update to the screen
0574   4DA8 DE A0       	ldx	temp0			; recover the screen address
0575   4DAA AA 00       	oraa	,x			; OR pixel with current screen data
0576   4DAC A7 00       	staa	,x			; save it back to the screen
0577   4DAE             
0578   4DAE             ;	; get the pixel reset mask
0579   4DAE             ;	ldx	#PixelLookupReset	;clear x
0580   4DAE             ;	ldab	X1			; now get bottom 3 bits of X for pixel info
0581   4DAE             ;	andb	#%00000111
0582   4DAE             ;	abx				; add it to x
0583   4DAE             ;	ldaa	,x			; get pixel
0584   4DAE             ;	; update the screen
0585   4DAE             ;	ldx	temp0			; recover the screen address
0586   4DAE             ;	anda	,x			; and pixel mask with current screen data
0587   4DAE             ;	staa	,x			; save it back to the screen
0588   4DAE 39          	rts				; return
0589   4DAF             
0590   4DAF             
0591   4DAF             	
0592   4DAF             ;**************************************************
0593   4DAF             ;* Pixel Lookup table for setting pixels
0594   4DAF             ;**************************************************
0595   4DAF             PixelLookupSet:
0596   4DAF 80          	fcb	%10000000
0597   4DB0 40          	fcb	%01000000
0598   4DB1 20          	fcb	%00100000
0599   4DB2 10          	fcb	%00010000
0600   4DB3 08          	fcb	%00001000
0601   4DB4 04          	fcb	%00000100
0602   4DB5 02          	fcb	%00000010
0603   4DB6 01          	fcb	%00000001
0604   4DB7             
0605   4DB7             
0606   4DB7             ;**************************************************
0607   4DB7             ;* Pixel Lookup table for resetting pixels
0608   4DB7             ;**************************************************
0609   4DB7             PixelLookupReset:
0610   4DB7             
0611   4DB7 7F          	fcb	%01111111
0612   4DB8 BF          	fcb	%10111111
0613   4DB9 DF          	fcb	%11011111
0614   4DBA EF          	fcb	%11101111
0615   4DBB F7          	fcb	%11110111
0616   4DBC FB          	fcb	%11111011
0617   4DBD FD          	fcb	%11111101
0618   4DBE FE          	fcb	%11111110
0619   4DBF             
0620   4DBF             	
0621   4DBF             ;**************************************************
0622   4DBF             ;*
0623   4DBF             ;**************************************************
0624   4DBF             ;* placeholder for print string routine
0625   4DBF             ;**************************************************
0626   4DBF             	
0627   4DBF             ;	ldaa	col
0628   4DBF             ;	inca			; next column
0629   4DBF             ;	staa	col
0630   4DBF             ;	cmpa	#63		; 64 chsrs / line (0-63)
0631   4DBF             ;	blt	cexit
0632   4DBF             ;	clra
0633   4DBF             ;	staa	col
0634   4DBF             ;	ldaa	row
0635   4DBF             ;	inca
0636   4DBF             ;	cmpa	#23		; 24 lines (0-23(
0637   4DBF             ;	blt	next
0638   4DBF             ;	deca
0639   4DBF             ;next:	
0640   4DBF             ;	staa	row
0641   4DBF             ;
0642   4DBF             ;	jsr	scroll
0643   4DBF             
0644   4DBF             	
0645   4DBF             ;**************************************************
0646   4DBF             ; NAME: print_64
0647   4DBF             ;**************************************************
0648   4DBF             ;* Description:
0649   4DBF             ;*  64 Column text display driver
0650   4DBF             ;*  Routine does not print at pixel X,Y but
0651   4DBF             ;*  prints at a character position.
0652   4DBF             ;*  Once a string printing routine is written, 
0653   4DBF             ;*  some of the code may be moved to that.
0654   4DBF             ;*  Based partially on a routine for the Sinclair Spectrum
0655   4DBF             ;**************************************************
0656   4DBF             
0657   4DBF             print_64:
0658   4DBF             	; a contains character
0659   4DBF 16          	tab				; copy to b
0660   4DC0 84 01       	anda	#%00000001		; get least significat bit (determines odd/even)
0661   4DC2 48          	lsla
0662   4DC3 97 A2       	staa	temp1			; save it (OddEvenCharacter flag)
0663   4DC5             
0664   4DC5 C0 20       	subb	#' '			; printable character set data starts at space, ASCII 32
0665   4DC7 54          	lsrb				;  divide by two because table has data for two characters in each byte
0666   4DC8 86 07       	ldaa	#7			;  7 bytes per character
0667   4DCA 3D          	mul				;  multiply them
0668   4DCB             ;nextch:	
0669   4DCB C3 4E 93    	addd	#font			; base address of font
0670   4DCE DD B0       	std	charptr			; transfer to character pointer
0671   4DD0             	
0672   4DD0             	; convert the row to the base screen address
0673   4DD0 5F          	clrb				;  clear the LSB for below
0674   4DD1 96 C1       	ldaa	row			; load row into A
0675   4DD3~            #if BytesPerLine = 32			; 32 bytes per row, * 8 rows per line = 256, just load into MSB to multiply by 256
0676   4DD3~            					; nothing to do
0677   4DD3             #endif
0678   4DD3             #if BytesPerLine = 16		; 16 bytes per row, * 8 rows per line = 128, load into MSB and shift right (/2)
0679   4DD3 44          	lsra				;  divide by 2
0680   4DD4 56          	rorb
0681   4DD5             #endif
0682   4DD5~            #if BytesPerLine = 8		; 8 bytes per row, * 8 rows per line = 64, load into MSB and shift right shift right (/4)
0683   4DD5~            					; shift could have been either direction (LSB * 4 or MSB / 4) but already in A so...
0684   4DD5~            	lsra				; divide by 4
0685   4DD5~            	rorb
0686   4DD5~            	lsra
0687   4DD5~            	rorb
0688   4DD5             #endif
0689   4DD5             ;#else					; multiply is faster if more shifting is required (not used just and example)
0690   4DD5             ;					;  actually, loading into LSB and shifting left would be faster but it doesn't matter anyway
0691   4DD5             ;					;  since there is no mode less than 8 bytes / line or more than 32 / line
0692   4DD5             ;	ldaa	row			; load row into A
0693   4DD5             ;	ldab	#(BytesPerLine*8)	; size of a ROW
0694   4DD5             ;	mul				; mul by number of ROWs
0695   4DD5             ;#endif
0696   4DD5 C3 40 10    	addd	#(BytesPerLine+screen)	; top line of character is always blank so skip it
0697   4DD8 DD B2       	std	fscreen			; save it.
0698   4DDA             
0699   4DDA             	; add the column
0700   4DDA D6 C2       	ldab	col			; calculate byte offset
0701   4DDC C4 01       	andb	#%00000001		; Hi/Lo nibble flag in a
0702   4DDE DB A2       	addb	temp1			;  add the current Odd Even Column flag
0703   4DE0             					;  Bit 0 now contains OE char flag, bit 1 now contains OE screen flag
0704   4DE0 4F          	clra
0705   4DE1 58          	lslb				;  multiply by 2 because jump table is 4 longs not bytes
0706   4DE2 C3 4E 04    	addd	#ChrJmpTBL
0707   4DE5 DD A0       	std	temp0
0708   4DE7             
0709   4DE7 D6 C2       	ldab	col			; 2 columns / byte
0710   4DE9 54          	lsrb
0711   4DEA 4F          	clra
0712   4DEB D3 B2       	addd	fscreen			; add the screen line address
0713   4DED DD B2       	std	fscreen			; save it
0714   4DEF             
0715   4DEF C6 07       	ldab	#7
0716   4DF1 D7 B4       	stab	fcount
0717   4DF3             
0718   4DF3 0F          	sei				; disable interrupts
0719   4DF4 30          	tsx				; get stack pointer
0720   4DF5 DF B5       	stx	stacktmp		; save the stack pointer
0721   4DF7 DE B0       	ldx	charptr
0722   4DF9 35          	txs				; point the stack to the current character
0723   4DFA             
0724   4DFA             	; basically using the least significant bits of the character and column
0725   4DFA             	; we grabbed and shifted as an offset into the jump table
0726   4DFA             	; it may be faster overall just to do a few tests and branches but I haven't checked yet
0727   4DFA DE A0       	ldx	temp0			; get the offset
0728   4DFC EC 00       	ldd	,x			; load the routine address
0729   4DFE DD A0       	std	temp0			; transfer the address to X
0730   4E00 DE A0       	ldx	temp0
0731   4E02 6E 00       	jmp	,x			; call it
0732   4E04             
0733   4E04             ChrJmpTBL:
0734   4E04 4E 0C       	fdb	ll_lp			;left nibble left side
0735   4E06 4E 3E       	fdb	lr_lp			;left nibble right side
0736   4E08 4E 77       	fdb	rl_lp			;right nibble left side
0737   4E0A 4E 25       	fdb	rr_lp			;right nibble right side
0738   4E0C             
0739   4E0C             	
0740   4E0C             ; notice the z80 oriented comment from the original code	
0741   4E0C             ;**************************************************
0742   4E0C             ; WRITE A CHARACTER TO THE SCREEN
0743   4E0C             ; There are four separate routines
0744   4E0C             ; HL points to the first byte of a character in FONT
0745   4E0C             ; DE points to the first byte of the screen address
0746   4E0C             ;**************************************************
0747   4E0C             
0748   4E0C             ;**************************************************
0749   4E0C             ;* left nibble on left hand side
0750   4E0C             ;**************************************************
0751   4E0C             ll_lp:
0752   4E0C DE B2       	ldx	fscreen		; point to screen byte
0753   4E0E             ll_lp2:
0754   4E0E 32          	pula			; get byte of font and point to next font data
0755   4E0F 94 F0       	anda	%11110000	; mask area used by new character
0756   4E11 E6 00       	ldab	,x		; read byte at destination
0757   4E13 D4 0F       	andb	%00001111	; mask off unused half
0758   4E15 97 A0       	staa	temp0
0759   4E17 DA A0       	orab	temp0		; combine with background
0760   4E19 E7 00       	stab	,x		; write it back
0761   4E1B             
0762   4E1B C6 10       	ldab	#BytesPerLine	; 32 bytes / row
0763   4E1D 3A          	abx			; point to next screen location
0764   4E1E             
0765   4E1E 7A 00 B4    	dec	fcount		; loop 7 times
0766   4E21 26 EB       	bne	ll_lp2
0767   4E23 20 32       	bra	charexit
0768   4E25             	
0769   4E25             ;**************************************************
0770   4E25             ; right nibble on right hand side
0771   4E25             ;**************************************************
0772   4E25             rr_lp:
0773   4E25 DE B2       	ldx	fscreen		; point to screen destination
0774   4E27             rr_lp2:
0775   4E27 32          	pula			; get byte of font and point to next font data
0776   4E28 94 0F       	anda	%00001111	; mask area used by new character
0777   4E2A E6 00       	ldab	,x		; read byte at destination
0778   4E2C D4 F0       	andb	%11110000	; mask off unused half
0779   4E2E 97 A0       	staa	temp0
0780   4E30 DA A0       	orab	temp0		; combine with background
0781   4E32 E7 00       	stab	,x		; write it back
0782   4E34             
0783   4E34 C6 10       	ldab	#BytesPerLine	; 32 bytes / row
0784   4E36 3A          	abx			; point to next screen location
0785   4E37             
0786   4E37 7A 00 B4    	dec	fcount		; loop 8 times
0787   4E3A 26 EB       	bne	rr_lp2
0788   4E3C 20 19       	bra	charexit
0789   4E3E             
0790   4E3E             
0791   4E3E             ;**************************************************
0792   4E3E             ; left nibble on right hand side
0793   4E3E             ;**************************************************
0794   4E3E             lr_lp:
0795   4E3E DE B2       	ldx	fscreen		; read byte at destination
0796   4E40             lr_lp2:
0797   4E40 32          	pula			; get byte of font and point to next font data
0798   4E41 44          	lsra			; shift right
0799   4E42 44          	lsra			; four bits
0800   4E43 44          	lsra			; leaving 7-4
0801   4E44 44          	lsra			; empty
0802   4E45             
0803   4E45             ;	anda	%00001111	; mask area used by new character
0804   4E45 E6 00       	ldab	,x		; read byte at destination
0805   4E47 D4 F0       	andb	%11110000	; mask off unused half
0806   4E49 97 A0       	staa	temp0
0807   4E4B DA A0       	orab	temp0		; combine with background
0808   4E4D E7 00       	stab	,x		; write it back
0809   4E4F             	
0810   4E4F C6 10       	ldab	#BytesPerLine	; 32 bytes / row
0811   4E51 3A          	abx			; point to next screen location
0812   4E52             
0813   4E52 7A 00 B4    	dec	fcount		; loop 7 times
0814   4E55 26 E9       	bne	lr_lp2
0815   4E57             
0816   4E57             ;shared exit code placed in a center routine to make sure it stays within range of a relative brance
0817   4E57             charexit:
0818   4E57             	;restore stack pointer and interrupts
0819   4E57 DE B5       	ldx	stacktmp	; restore the stack pointer
0820   4E59 35          	txs
0821   4E5A 0E          	cli			; enable interrupts
0822   4E5B             
0823   4E5B             	;update column, row, and scroll when needed
0824   4E5B 96 C2       	ldaa	col		; next column
0825   4E5D 4C          	inca
0826   4E5E 97 C2       	staa	col
0827   4E60 81 20       	cmpa	#(BytesPerLine*2)	; 64 chsrs / line (0-63)
0828   4E62 26 12       	bne	cexit		; is column past the end of a line?
0829   4E64 7F 00 C2    	clr	col		; set column to zero
0830   4E67 96 C1       	ldaa	row		; increment the row
0831   4E69 4C          	inca
0832   4E6A 97 C1       	staa	row
0833   4E6C 81 18       	cmpa	#(ScreenHeight/8)	; 24 lines (0-23)
0834   4E6E 2D 06       	blt	cexit		; branch if row isn't past the end of the screen
0835   4E70 7A 00 C1    	dec	row		; reduce row back to last line
0836   4E73 BD 4F E3    	jsr	scroll		; scroll the screen
0837   4E76 39          cexit:	rts			; return
0838   4E77             
0839   4E77             
0840   4E77             ;**************************************************
0841   4E77             ;* right nibble on left hand side
0842   4E77             ;**************************************************
0843   4E77             rl_lp:
0844   4E77 DE B2       	ldx	fscreen		; point to screen destination
0845   4E79             rl_lp2:
0846   4E79 32          	pula			; get byte of font and point to next font data
0847   4E7A 48          	lsla
0848   4E7B 48          	lsla
0849   4E7C 48          	lsla
0850   4E7D 48          	lsla
0851   4E7E             
0852   4E7E             ;	anda	%11110000	; mask area used by new character
0853   4E7E E6 00       	ldab	,x		; read byte at destination
0854   4E80 D4 0F       	andb	%00001111	; mask off unused half
0855   4E82 97 A0       	staa	temp0
0856   4E84 DA A0       	orab	temp0		; combine with background
0857   4E86 E7 00       	stab	,x		; write it back
0858   4E88             
0859   4E88 C6 10       	ldab	#BytesPerLine	; 32 bytes / row
0860   4E8A 3A          	abx			; point to next screen location
0861   4E8B             
0862   4E8B 7A 00 B4    	dec	fcount		; loop 7 times
0863   4E8E 26 E9       	bne	rl_lp2		
0864   4E90 20 C5       	bra	charexit
0865   4E92             
0866   4E92             ;**************************************************
0867   4E92             ; TEXT VARIABLES
0868   4E92             ; Used by the 64 column driver
0869   4E92             ;**************************************************
0870   4E92             atflg:
0871   4E92 00          	fcb	0		; AT flag
0872   4E93             
0873   4E93             ;row:
0874   4E93             ;	fcb	0		; row
0875   4E93             ;
0876   4E93             ;col:
0877   4E93             ;	fcb	0		; col
0878   4E93             
0879   4E93             ;**************************************************
0880   4E93             ; HALF WIDTH 4x8 FONT
0881   4E93             ; Top row is always zero and not stored (336 bytes)
0882   4E93             ; characters are 4 bits wide and 7 bits high 
0883   4E93             ; (the top row is always blank)
0884   4E93             ; There are two characters stored in each group of
0885   4E93             ; 7 bytes.  Each byte has bits for one character in
0886   4E93             ; the high nibble and bits for another in the low nibble
0887   4E93             ;**************************************************
0888   4E93             font:
0889   4E93 020202020002	fcb	$02, $02, $02, $02, $00, $02, $00	; !
0889   4E99 00
0890   4E9A 525702020702	fcb	$52, $57, $02, $02, $07, $02, $00	;"#
0890   4EA0 00
0891   4EA1 257162327425	fcb	$25, $71, $62, $32, $74, $25, $00	;$%
0891   4EA7 00
0892   4EA8 224230505030	fcb	$22, $42, $30, $50, $50, $30, $00	;&'
0892   4EAE 00
0893   4EAF 142241414122	fcb	$14, $22, $41, $41, $41, $22, $14	;()
0893   4EB5 14
0894   4EB6 207022570200	fcb	$20, $70, $22, $57, $02, $00, $00	;*+
0894   4EBC 00
0895   4EBD 000000070020	fcb	$00, $00, $00, $07, $00, $20, $20	;,-
0895   4EC3 20
0896   4EC4 010102020414	fcb	$01, $01, $02, $02, $04, $14, $00	;./
0896   4ECA 00
0897   4ECB 225652525227	fcb	$22, $56, $52, $52, $52, $27, $00	;01
0897   4ED1 00
0898   4ED2 275112214572	fcb	$27, $51, $12, $21, $45, $72, $00	;23
0898   4ED8 00
0899   4ED9 575456711512	fcb	$57, $54, $56, $71, $15, $12, $00	;45
0899   4EDF 00
0900   4EE0 172161525222	fcb	$17, $21, $61, $52, $52, $22, $00	;67
0900   4EE6 00
0901   4EE7 225525535224	fcb	$22, $55, $25, $53, $52, $24, $00	;89
0901   4EED 00
0902   4EEE 000022000022	fcb	$00, $00, $22, $00, $00, $22, $02	;:;
0902   4EF4 02
0903   4EF5 001027402710	fcb	$00, $10, $27, $40, $27, $10, $00	;<=
0903   4EFB 00
0904   4EFC 024521122042	fcb	$02, $45, $21, $12, $20, $42, $00	;>?
0904   4F02 00
0905   4F03 235575774535	fcb	$23, $55, $75, $77, $45, $35, $00	;@A
0905   4F09 00
0906   4F0A 635464545463	fcb	$63, $54, $64, $54, $54, $63, $00	;BC
0906   4F10 00
0907   4F11 675456545467	fcb	$67, $54, $56, $54, $54, $67, $00	;DE
0907   4F17 00
0908   4F18 734464454543	fcb	$73, $44, $64, $45, $45, $43, $00	;FG
0908   4F1E 00
0909   4F1F 575272525257	fcb	$57, $52, $72, $52, $52, $57, $00	;HI
0909   4F25 00
0910   4F26 351516555525	fcb	$35, $15, $16, $55, $55, $25, $00	;JK
0910   4F2C 00
0911   4F2D 454745454575	fcb	$45, $47, $45, $45, $45, $75, $00	;LM
0911   4F33 00
0912   4F34 625555555552	fcb	$62, $55, $55, $55, $55, $52, $00	;NO
0912   4F3A 00
0913   4F3B 625555654543	fcb	$62, $55, $55, $65, $45, $43, $00	;PQ
0913   4F41 00
0914   4F42 635452615552	fcb	$63, $54, $52, $61, $55, $52, $00	;RS
0914   4F48 00
0915   4F49 752525252522	fcb	$75, $25, $25, $25, $25, $22, $00	;TU
0915   4F4F 00
0916   4F50 555555552725	fcb	$55, $55, $55, $55, $27, $25, $00	;VW
0916   4F56 00
0917   4F57 555525225252	fcb	$55, $55, $25, $22, $52, $52, $00	;XY
0917   4F5D 00
0918   4F5E 731222224272	fcb	$73, $12, $22, $22, $42, $72, $03	;Z[
0918   4F64 03
0919   4F65 464222221212	fcb	$46, $42, $22, $22, $12, $12, $06	;\]
0919   4F6B 06
0920   4F6C 205000000000	fcb	$20, $50, $00, $00, $00, $00, $0f	;^_
0920   4F72 0F
0921   4F73 201003050503	fcb	$20, $10, $03, $05, $05, $03, $00	;a
0921   4F79 00
0922   4F7A 404063545463	fcb	$40, $40, $63, $54, $54, $63, $00	;bc
0922   4F80 00
0923   4F81 101032555633	fcb	$10, $10, $32, $55, $56, $33, $00	;de
0923   4F87 00
0924   4F88 102073252543	fcb	$10, $20, $73, $25, $25, $43, $06	;fg
0924   4F8E 06
0925   4F8F 424066525257	fcb	$42, $40, $66, $52, $52, $57, $00	;hi
0925   4F95 00
0926   4F96 140435161555	fcb	$14, $04, $35, $16, $15, $55, $20	;jk
0926   4F9C 20
0927   4F9D 602025272575	fcb	$60, $20, $25, $27, $25, $75, $00	;lm
0927   4FA3 00
0928   4FA4 000062555552	fcb	$00, $00, $62, $55, $55, $52, $00	;no
0928   4FAA 00
0929   4FAB 000063555563	fcb	$00, $00, $63, $55, $55, $63, $41	;pq
0929   4FB1 41
0930   4FB2 000053664346	fcb	$00, $00, $53, $66, $43, $46, $00	;rs
0930   4FB8 00
0931   4FB9 002075252512	fcb	$00, $20, $75, $25, $25, $12, $00	;tu
0931   4FBF 00
0932   4FC0 000055552725	fcb	$00, $00, $55, $55, $27, $25, $00	;vw
0932   4FC6 00
0933   4FC7 000055252553	fcb	$00, $00, $55, $25, $25, $53, $06	;xy
0933   4FCD 06
0934   4FCE 010272346272	fcb	$01, $02, $72, $34, $62, $72, $01	;z{
0934   4FD4 01
0935   4FD5 242222212222	fcb	$24, $22, $22, $21, $22, $22, $04	;|}
0935   4FDB 04
0936   4FDC 56A906040609	fcb	$56, $a9, $06, $04, $06, $09, $06	;~
0936   4FE2 06
0937   4FE3             	
0938   4FE3             
0939   4FE3             ;**************************************************
0940   4FE3             ;* NAME: scroll
0941   4FE3             ;**************************************************
0942   4FE3             ;* Description:
0943   4FE3             ;*  scroll the 24 line display
0944   4FE3             ;**************************************************
0945   4FE3             scroll:
0946   4FE3 CC 05 C0    	ldd	#((ScreenHeight-8)*(BytesPerLine/2))	;scroll # char lines-1, 8 lines /char, # bytes/row / 2 bytes per loop
0947   4FE6 4C          	inca
0948   4FE7 DD A0       	std	temp0			; loop counter
0949   4FE9 0F          	sei				; disable interrupts
0950   4FEA 30          	tsx				; get stack pointer
0951   4FEB DF B5       	stx	stacktmp		; save the stack pointer
0952   4FED CE 40 80    	ldx	#screen+(BytesPerLine*8)	; character line +1
0953   4FF0 35          	txs				; point the stack to the current character
0954   4FF1 CE 40 00    	ldx	#screen			;
0955   4FF4             	;the scroll section
0956   4FF4             scrolla:
0957   4FF4 32          	pula				; grab 2 bytes from a row lower on the screen
0958   4FF5 33          	pulb
0959   4FF6 ED 00       	std	,x			; store them in their new location a row up
0960   4FF8 08          	inx				; increment x twice since we are doing two bytes at a time
0961   4FF9 08          	inx
0962   4FFA 7A 00 A1    	dec	temp0+1			; decrement the low byte of our loop counter
0963   4FFD 26 F5       	bne	scrolla			; branch until it's zero
0964   4FFF 7A 00 A0     	dec	temp0			; decrement the high byte of our loop counter
0965   5002 2E F0       	bgt	scrolla			; keep going until it's zero
0966   5004             
0967   5004             	;restore stack & interrupts
0968   5004 DE B5       	ldx	stacktmp		; restore the stack pointer
0969   5006 35          	txs
0970   5007 0E          	cli				; enable interrupts
0971   5008             	
0972   5008             	;clear the bottom line
0973   5008 86 40       	ldaa	#(BytesPerLine*(8/2))	; # bytes/row, # rows / char, set 2 bytes at a time
0974   500A 97 A0       	staa	temp0			; loop counter
0975   500C CE 4B 80    	ldx	#screen+(BytesPerLine*(ScreenHeight-8))	; starting screen address
0976   500F CC 00 00    	ldd	#0			; to clear bytes with
0977   5012             scrollb:
0978   5012 ED 00       	std	,x			; clear 2 bytes
0979   5014 08          	inx				; increment the pointer twice since we are doing 2 at a time
0980   5015 08          	inx
0981   5016 7A 00 A0    	dec	temp0			; decrement the loop counter
0982   5019 26 F7       	bne	scrollb			; go until the counter hits zero
0983   501B             	
0984   501B 39          	rts				; done
0985   501C             	
0986   501C             	
0987   501C             	
0988   501C             	end
0989   501C             ;**************************************************
0990   501C             ;**************************************************
tasm: Number of errors = 0
