changeset 24:f401b8be83a8

Initial support for full ASCII string rendering Add routines to handle full ASCII string rendering. Also convert the two immediate strings on the into screen to ASCII format using the new infrastructure.
author William Astle <lost@l-w.ca>
date Thu, 01 Jan 2015 23:39:48 -0700
parents 5e61b3eac873
children dca3f8f2b811
files dod.s
diffstat 1 files changed, 53 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Thu Jan 01 23:02:58 2015 -0700
+++ b/dod.s	Thu Jan 01 23:39:48 2015 -0700
@@ -52,6 +52,8 @@
 ; I failed to elicit a response from Louis Jordan as described in the license grant. I am not surprised
 ; that I received no reply given that the page above was put online during or prior to 2006.
 
+		pragma cescapes			; we use C-style escapes in some of the strings
+
 ; some utility macros
 dod		macro noexpand
 		swi
@@ -73,6 +75,10 @@
 drawgraphic	macro noexpand
 		dod S01
 		endm
+; render an ASCIIZ string (immediate data)
+renderstrimm	macro noexpand
+		jsr putstrimm
+		endm
 ; render a packed string (immediate data)
 renderstrimmp	macro noexpand
 		dod S02
@@ -583,13 +589,8 @@
 		ldu #statusarea			; point to text parameters for status area
 		dec textother			; indicate nonstandard text area
 		clearstatus			; blank status line (where we'll put the copyright notice)
-		renderstrimmp			; display copyright message
-		fcb $f8,$df,$0c,$c9		; packed string "COPYRIGHT  DYNA MICRO  MCMLXXXII"
-		fcb $27,$45,$00,$02
-		fcb $65,$c1,$03,$52
-		fcb $39,$3c,$00,$68
-		fcb $da,$cc,$63,$09
-		fcb $48
+		renderstrimm			; show copyright message
+		fcn 'COPYRIGHT  DYNA MICRO  MCMLXXXII'
 		clr textother			; reset text rendering to standard mode
 		rts				; transfer control to correct game loop
 dodemo		dec waitnewgame			; flag demo game
@@ -597,17 +598,8 @@
 		ldx #img_wizard			; point to wizard image
 		dec enablefadesound		; enable fade sound effect
 		fadein				; fade the wizard in
-		renderstrimmp			; display <CR>"I DARE YE ENTER..."<CR>
-		fcb $9f,$d2,$02,$06		; packed "\rI DARE YE ENTER...\r" string
-		fcb $45,$06,$4a,$02
-		fcb $ba,$85,$97,$bd
-		fcb $ef,$80
-		renderstrimmp			; display "...THE DUNGEONS OF DAGGORATH!!!"
-		fcb $f7,$bd,$ea,$20		; packed "...THE DUNGEONS OF DAGGORATH!!!" string
-		fcb $a0,$25,$5c,$72
-		fcb $bd,$d3,$03,$cc
-		fcb $02,$04,$e7,$7c
-		fcb $83,$44,$6f,$7b
+		renderstrimm			; dare the player
+		fcn '\rI DARE YE ENTER...\r...THE DUNGEONS OF DAGGORATH!!!'
 		delay				;* wait for about 2.6 seconds
 		delay				;*
 		fadeout				; fade the wizard out
@@ -1041,6 +1033,22 @@
 LC454		lda ,x+				; fetch byte from string
 		bpl LC452			; brif not end of string - display it
 		rts				; return to caller
+; Display an ASCIIZ string at X
+putstr		pshs a,x			; save registers
+		skip2				; move over next instruction
+putstr000	bsr putchr			; display character
+		lda ,x+				; fetch character
+		bne putstr000			; brif not end of string - display it
+		puls a,x,pc			; restore registers and return
+; Display an ASCIIZ string at (S)
+putstrimm	pshs a,x			; save registers
+		ldx 3,s				; get string pointer
+		skip2				; move over next instruction
+putstrimm000	bsr putchr			; output character
+		lda ,x+				; fetch character from string
+		bne putstrimm000		; brif not end of string
+		stx 3,s				; save new return address
+		puls a,x,pc			; restore registers and return
 ; swi 4 routine
 ; display character in A
 LC459		tst textother			; are we looking for standard text mode?
@@ -1053,6 +1061,19 @@
 		jsr LC9D4			; go scroll the text area
 LC46C		stx 4,u				; save new screen location
 		rts				; return to caller
+; This routine displays the character in A, which is encoded as ASCII. All registers preserved.
+putchr		pshs a,b,x,y,u			; save registers
+		tst textother			; are we looking for standard text mode?
+		bne putchr000			; brif not
+		ldu #commandarea		; point to params for regular text area
+putchr000	ldx 4,u				; fetch current location
+		jsr rendercharascii		; go render the character
+		cmpx 2,u			; are we at the end of the text area?
+		blo putchr001			; brif not
+		jsr LC9D4			; go scroll the text area
+putchr001	stx 4,u				; save new screen location
+		puls a,b,x,y,u,pc		; restore registers and return
+
 ; swi 5 routine - decode packed string at X to stringbuf
 LC46F		ldu #stringbuf			; point to output buffer
 ; swi 6 routine - decode a packed string at X to U
@@ -1900,6 +1921,17 @@
 ; 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 commandarea.
+;
+; The putchr entry point renders a character which is already encoded as ASCII. It preserves all registers.
+rendercharascii	cmpa #8				; is it backspace?
+		beq LC9BF			; brif so
+		cmpa #13			; is it carriage return?
+		beq LC9CA			; brif so
+		cmpa #32			; is it non-printable?
+		blo render000			; brif so - treat as blank
+		bsr LCA17a			; go render actual character
+		leax 1,x			; move to next character position
+render000	rts
 LC9B2		cmpa #$24			; is it backspace?	
 		beq LC9BF			; brif so
 		cmpa #$1f			; carriage return?
@@ -1953,6 +1985,8 @@
 		lslb				;*
 		rola				;*
 		rts
+LCA17a		pshs a,b,x,y,u			; save registers
+		bra LCA29g			; go render character
 LCA17		pshs a,b,x,y,u			; save registers
 		tsta				; is it space?
 		beq LCA29b			; brif so
@@ -1978,7 +2012,7 @@
 LCA29e		lda #'?				; code for ?
 		skip2
 LCA29f		lda #'.				; code for .
-		ldb #8				; 8 bytes per font entry
+LCA29g		ldb #8				; 8 bytes per font entry
 		mul				; now D is offset
 		addd #fontdata-(32*8)		; offset into table
 		tfr d,x				; put pointer somewhere useful