changeset 4:dc07cebba65c

Additional comments related to text rendering Added an explanation of the text display system and updated various comments on the text rendering.
author William Astle <lost@l-w.ca>
date Fri, 24 May 2013 23:07:53 -0600
parents 969c3d833728
children ff6eaa09bb56
files dod.s
diffstat 1 files changed, 55 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Fri May 24 22:35:49 2013 -0600
+++ b/dod.s	Fri May 24 23:07:53 2013 -0600
@@ -136,9 +136,9 @@
 ; the direct page
 		org $200
 V1F4		equ $1f4
-V200		rmb 2
+V200		rmb 2				initialized to $0000
 V202		rmb 1
-V203		rmb 2
+V203		rmb 2				initialized to $ffff
 V205		rmb 1
 V206		rmb 1
 V207		rmb 1
@@ -271,17 +271,17 @@
 V333		rmb 2
 V335		rmb 1
 V336		rmb 33
-V357		rmb 7
-V35E		rmb 3
+V357		rmb 10				temporary buffer used for decoding font data
 V361		rmb 31
 V380		rmb 6
 V386		rmb 2
 V388		rmb 6
 V38E		rmb 2
-V390		rmb 2
-V392		rmb 2				current end of screen address
-V394		rmb 2				current system text display location
-V396		rmb 2
+V390		rmb 2				current start offset of the text area
+V392		rmb 2				current end of offset of text area (character cell)
+V394		rmb 2				current text cursor position (character cell)
+V396		rmb 1				current screen background color mask
+V397		rmb 1				nonzero if text should NOT be rendered to secondary screen
 V398		rmb 43
 V3C3		rmb 17
 V3D4		rmb 20
@@ -835,7 +835,7 @@
 		ldu #V390			point to display state information
 LC460		ldx 4,u				fetch current screen location
 		jsr LC9B2			actually display the appropriate character
-		cmpx 2,u			are we at the end of the screen?
+		cmpx 2,u			are we at the end of text area?
 		blo LC46C			brif not
 		jsr LC9D4			go scroll the text area
 LC46C		stx 4,u				save new screen location
@@ -1600,7 +1600,31 @@
 		fcb LC759-LC743
 		fcb LC7C8-LC759
 		fcb LC7D0-LC7C8
-; Display the character in A on the screen at X
+;***********************************************************************************************************
+; The following code handles displaying text on the screen. It works as follows.
+;
+; The graphics screen is divided into a grid of character cells 32 columns wide by 24 rows high. Each cell
+; is 8 pixels wide by 8 pixels high. Text can be rendered anywhere on the screen as long as it fits within
+; a character cell. The cells line up on even bytes which makes actually rendering the characters fast.
+;
+; Characters are encoded in 5 bits as follows: A through Z are given codes 1 through 26. 0 is a space. 27
+; is the exclamation point, 28 is the underscore, 29 is the question mark, and 30 is the period. Code 31
+; is used as a carriage return. Codes 32 and 33 are the left and right parts of the contracted heart symbol
+; while 34 and 35 are the left and right parts of the expanded heart symbol. 36 is backspace.
+;
+; Glyphs for codes 0 through 30 are encoded using the packed five bit encoding and are located at LDB1B. They
+; are encoded in a 5 by 7 bitmap which is shifted to be offset one pixel from the left of the character cell
+; upon decoding.
+;
+; The glyphs for the heart codes are in unpacked encoding and are located at LDBB6 and occupy the entire
+; 8 bit width of the character cell.
+;
+; These routines expect a pointer to the text configuration parameters in U. At offset 0 is the start address
+; of the scrollable area of the screen (memory address). At offset 2 is the ending character cell address of
+; the scrollable area of the screen. At offset 4 is the current printing position. At offset 6 is a mask with
+; all pixels set to the background colour. At offset 7 a flag which when nonzero inhibits rendering text to
+; the secondary graphics screen area. For the ordinary command entry area at the bottom of the screen, this
+; will point to V390.
 LC9B2		cmpa #$24			is it backspace?	
 		beq LC9BF			brif so
 		cmpa #$1f			vertical spacer?
@@ -1609,10 +1633,10 @@
 		leax 1,x			move to next character position
 		rts				return to caller
 LC9BF		leax -1,x			move display pointer back one
-		cmpx V203			
-		bne LC9C9			
+		cmpx V203			did we wrap around negative?			
+		bne LC9C9			brif not
 		ldx 2,u				get end of text area
-		leax -1,x			move back one position
+		leax -1,x			move back one position to be in the text area
 LC9C9		rts				return to caller
 LC9CA		leax $20,x			move pointer forward one character row
 		exg d,x				move pointer so we can do math
@@ -1621,12 +1645,12 @@
 		rts				return to caller
 LC9D4		pshs a,b,x,y			save registers
 		ldx ,u				get start of screen address
-		ldd 2,u				get end of screen address
-		subd #$20			knock one pixel row off it
+		ldd 2,u				get end of text area
+		subd #$20			knock one character row off it
 		std 2,s				save new display location
-		bsr LCA10			multiply by 8 - 8 rows
+		bsr LCA10			multiply by 8 - 8 pixel rows per cell
 		tfr d,y				save counter
-LC9E3		ldd $100,x			get bytes 8 screen rows ahead
+LC9E3		ldd $100,x			get bytes 8 pixel rows ahead
 		tst 7,u				do we need to skip the second screen?
 		bne LC9EF			brif so
 		std $1800,x			save scroll data on second screen
@@ -1643,16 +1667,16 @@
 		leay -2,y			are we done yet?
 		bne LC9FC			brif not
 		puls a,b,x,y,pc			restore registers and return
-LCA0C		lslb
-		rola
-		lslb
-		rola
-LCA10		lslb
-		rola
-LCA12		lslb
-		rola
-		lslb
-		rola
+LCA0C		lslb				; enter here to shift D left 5 bits
+		rola				;
+		lslb				;
+		rola				;
+LCA10		lslb				; enter here to shift D left 3 bits
+		rola				;
+LCA12		lslb				; enter here to shift D left 2 bits
+		rola				;
+		lslb				;
+		rola				;
 		rts
 LCA17		pshs a,b,x,y,u			save registers
 		cmpa #$20			is it a printing character?
@@ -3353,7 +3377,9 @@
 		jmp LC27D
 		fcb $17
 		fdb V202
-		fcb $01,$FF,$ff,$00
+		fcb $01				V202
+		fdb $ffff			V203 - 16 bit all ones value, or -1
+		fcb $00
 		fcb $80,$00,$4c,$d8
 		fcb $70,$d8,$76,$d9
 		fcb $88,$0b,$15,$02
@@ -3616,7 +3642,7 @@
 		fcb $30,$00,$00,$00,$1f		char code 28 - underscore
 		fcb $33,$a2,$13,$10,$04		char code 29 - ?
 		fcb $30,$00,$00,$00,$04		char code 30 - .
-; some special characters
+; some special glyphs
 LDBB6		fcb $00,$00,$01,$01,$00,$00,$00	char code 32 - left part of contracted heart
 		fcb $00,$a0,$f0,$f0,$e0,$40,$00	char code 33 - right part of contracted heart
 		fcb $00,$01,$03,$03,$01,$00,$00	char code 34 - left half of expanded heart