changeset 26:ac26033d8e5f

Improved interface with Basic Cause RESET to do a cold start if pressed rather than something more unpredictable. Theoretically, intercepting the line input vector will cause DoD to restart on RESET but that then leaves no fast way to exit the game. This might be changed in the future if additional commands are added. (ZEXIT mabye?) Also, on every return from the I/O routines and also at game initialization, force standard clock mode. The method used should work on all versions of the Coco.
author William Astle <lost@l-w.ca>
date Fri, 02 Jan 2015 13:55:23 -0700
parents dca3f8f2b811
children 9b2a7e5c5708
files dod.s
diffstat 1 files changed, 36 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Thu Jan 01 23:51:41 2015 -0700
+++ b/dod.s	Fri Jan 02 13:55:23 2015 -0700
@@ -75,14 +75,6 @@
 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
-		endm
 ; render a packed string from (X)
 renderstr	macro noexpand
 		dod S03
@@ -505,10 +497,18 @@
 
 
 		org PROGLOAD
+; This routine forces the clock rate to the regular "slow" rate. The reason for the two bits is to make sure it gets
+; slowed down on both Coco3 and Coco1/2. It will also properly stop "double speed" mode on a Coco1/2. According to
+; the SAM data sheet, this is the correct sequence to force full slowdown.
+slowclock	sta $FFD8			; slow the clock rate down
+		sta $FFD6
+		rts
 START		ldu #dodemo			; point to the demo setup routine
 		bra LC008			; go handle the game
 LC005		ldu #dogame			; point to the real game setup routine
 LC008		lds #STACK			; put the stack somewhere safe
+		bsr slowclock			; force slow speed mode
+		clr >RSTFLG			; force a cold start on RESET
 		ldd #$34fc			; initializers for the PIA
 		sta PIA0+3			; set data mode, interrupts disabled (side B)
 		sta PIA0+1			; set data mode, interrupts disabled (side A)
@@ -589,7 +589,7 @@
 		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)
-		renderstrimm			; show copyright message
+		jsr putstrimm			; show copyright message
 		fcn '\x841982 Dyna Micro, \x842015 LWE Inc' ; (\x84 is a copyright sign)
 		clr textother			; reset text rendering to standard mode
 		rts				; transfer control to correct game loop
@@ -598,7 +598,7 @@
 		ldx #img_wizard			; point to wizard image
 		dec enablefadesound		; enable fade sound effect
 		fadein				; fade the wizard in
-		renderstrimm			; dare the player
+		jsr putstrimm			; dare the player
 		fcn '\rI DARE YE ENTER...\r...THE DUNGEONS OF DAGGORATH!!!'
 		delay				;* wait for about 2.6 seconds
 		delay				;*
@@ -1271,13 +1271,8 @@
 LC5B5		ldx #img_wizard			; point to wizard image
 		dec enablefadesound		; neable fade sound effect
 		fadeinclrst			; fade in the wizard
-		renderstrimmp			; display "YET ANOTHER DOES NOT RETURN..."
-		fcb $ff,$c1,$92,$d0		; packed "YET ANOTHER DOES NOT RETURN..." string
-		fcb $01,$73,$e8,$82
-		fcb $c8,$04,$79,$66
-		fcb $07,$3e,$80,$91
-		fcb $69,$59,$3b,$de
-		fcb $f0
+		jsr putstrimm			; display the death message
+		fcn '\r YET ANOTHER DOES NOT RETURN...'
 		clr nokeyboard			; enable keyboard polling in IRQ
 		dec waitnewgame			; set up to wait for keypress to start new game
 LC5D7		bra LC5D7			; wait forever (or until the IRQ does something)
@@ -1428,9 +1423,9 @@
 LC6E6		jsr LD489			; clear second graphics screen and set up for text mode
 		ldd #$12c			;* set cursor position to the middle of the screen
 		std 4,u				;*
-		renderstrimmp			; display the PREPARE! message
-		fcb $3c,$24,$58,$06		; packed string "PREPARE!"
-		fcb $45,$d8
+		jsr putstrimm			; display the PREPARE! message
+		fcn 'PREPARE!'
+;		renderstrimmp			; display the PREPARE! message
 		clr textother			; reset to standard text rendering
 		dec pageswap			; set graphic swap required
 		rts				; return to caller
@@ -2245,8 +2240,8 @@
 		bne badcommandret		; brif not
 		rts				; return to caller
 badcommandret	leas 2,s			; don't return to caller - we're bailing out
-badcommand	renderstrimmp			; display "???" for unknown command
-		fcb $17,$7b,$d0			; packed "???" string
+badcommand	jsr putstrimm			; display "???" for unknown command
+		fcn '???'
 		rts				; return to caller's caller
 LCBE7		pshs a,b,x,y,u			; save registers
 		clra				; initialize specific type to zero
@@ -3163,8 +3158,8 @@
 		anda #3				; 1 in 4 chance of a hit in the dark
 		bne LD375			; brif we didn't hit
 LD31F		playsoundimm $12		; play the "HIT" sound
-		renderstrimmp			; display the "!!!" for a successful hit
-		fcb $16,$f7,$b0			; packed "!!!" string
+		jsr putstrimm			; display "!!!" for a hit
+		fcn '!!!'
 		jsr damage			; calculate damage, apply to victim
 		bhi LD375			; brif not dead
 		leax 8,u			; point to inventory head pointer
@@ -3221,19 +3216,8 @@
 		rts				; return to caller
 LD386		ldx #img_wizard			; point to Wizard graphic
 		fadeinclrst			; fade in the wizard
-		renderstrimmp			; dipslay "ENOUGH! I TIRE OF THIS PLAY..."
-		fcb $ff,$c0,$57,$3e		; packed string "ENOUGH! I TIRE OF THIS PLAY..."
-		fcb $a7,$46,$c0,$90
-		fcb $51,$32,$28,$1e
-		fcb $60,$51,$09,$98
-		fcb $20,$c0,$e7,$de
-		fcb $f0
-		renderstrimmp			; also display "PREPARE TO MEET THY DOOM!!!"
-		fcb $e8,$00,$08,$48		; packed string "PREPARE TO MEET THY DOOM!!!"
-		fcb $b0,$0c,$8a,$0a
-		fcb $3c,$0d,$29,$68
-		fcb $0a,$23,$20,$23
-		fcb $de,$dd,$ef,$60
+		jsr putstrimm			; display the angry message after level 3
+		fcn '\r ENOUGH! I TIRE OF THIS PLAY...   PREPARE TO MEET THY DOOM!!!'
 		delay				; delay a bit
 		ldu curtorch			; fetch current torch
 		stu backpack			; put it in the backpack
@@ -3399,19 +3383,16 @@
 		clr columnctr			; flag column zero in object list
 		ldd #10				;* set up to centre "IN THIS ROOM"
 		std 4,u				;* column 10, row 0
-		renderstrimmp			; show the "IN THIS ROOM" heading
-		fcb $62,$5c,$0a,$21		; packed string "IN THIS ROOM"
-		fcb $33,$04,$9e,$f6
-		fcb $fc
+		jsr putstrimm
+		fcn 'IN THIS ROOM\r'
 		ldd playerloc			; get player location
 		jsr LCF82			; get creature at player location
 		beq LD4C0			; brif no creature there
 		ldx 4,u				; get current text position
 		leax 11,x			; move 11 over
 		stx 4,u				; save new position
-		renderstrimmp			; show the "!CREATURE!" string if a creature is present
-		fcb $56,$c7,$22,$86		; packed string "!CREATURE!"
-		fcb $95,$91,$77,$f0
+		jsr putstrimm
+		fcn '!CREATURE!\r'
 LD4C0		clr objiterstart		; reset object iterator
 LD4C2		ldd playerloc			; get player location
 		jsr LCF53			; fetch next object
@@ -3428,9 +3409,8 @@
 		ldx 4,u				; get current text location
 		leax 12,x			; adjust for centering
 		stx 4,u				; save new text location
-		renderstrimmp			; display "BACKPACK" heading
-		fcb $40,$82,$35,$c0		; packed string "BACKPACK"
-		fcb $23,$5f,$c0
+		jsr putstrimm
+		fcn 'BACKPACK\r'
 		ldx #backpack			; point to backpack head pointer
 LD4ED		ldx ,x				; get next item in backpack
 		beq LD4FB			; brif nothing else in backpack
@@ -3565,19 +3545,8 @@
 LD5F0		ldx #img_goodwiz		; point to good wizard image
 		dec enablefadesound		; enable fade sound effect
 		fadeinclrst			; fade in the wizard
-		renderstrimmp			; display victory message line 1
-		fcb $ff,$c4,$54,$3d		; packed string victory message line 1
-		fcb $84,$d8,$08,$59
-		fcb $D1,$2e,$c8,$03
-		fcb $70,$a6,$93,$05
-		fcb $10,$50,$20,$2e
-		fcb $20
-		renderstrimmp			; dispaly victory message line 2
-		fcb $c8,$00,$00,$00		; packed string victory message line 2
-		fcb $00,$03,$cc,$00
-		fcb $81,$c5,$b8,$2e
-		fcb $9d,$06,$44,$f7
-		fcb $bc
+		jsr putstrimm			; display victory message
+		fcn '\rBEHOLD! DESTINY AWAITS THE HAND        OF A NEW WIZARD...'
 LD621		bra LD621			; Do nothing until IRQ decides something should happen
 cmd_reveal	jsr LCC31			; parse a hand and get pointer to hand
 		ldu ,u				; is there an object there?
@@ -4942,6 +4911,7 @@
 error_hook000	lds error_stack			; reset the stack to a known state
 		bsr restore_dp			; reset the direct page
 		bsr error_cleartrap		; clear the error trap on error
+		jsr slowclock			; force slow clock mode
 		jmp ,x				; transfer control to the handler
 ; This is the routine that installs a handler and the cleanup routine.
 error_settrap	stx error_handler		; set the handler
@@ -4962,6 +4932,7 @@
 		bsr set_basdp			; set direct page for Basic call
 		jsr [hook_openi]		; go call the file open handler in ROM
 		bsr restore_dp			; restore direct page
+		jsr slowclock			; force slow down
 		clra				; set Z for success
 		bsr error_cleartrap		; clear the error trap
 		puls d,x,y,u,pc			; restore registers and return
@@ -4975,6 +4946,7 @@
 		bsr set_basdp			; set direct page for Basic call
 		jsr [hook_openo]		; go call the file open handler in ROM
 		bsr restore_dp			; restore direct page
+		jsr slowclock			; force slow down
 		clra				; set Z for success
 		bsr error_cleartrap		; clear the error trap
 		puls d,x,y,u,pc			; restore registers and return
@@ -4998,6 +4970,7 @@
 		bsr error_settrap		; register error handler
 		bsr set_basdp			; set up DP correctly
 		jsr $A426			; call the "close one file" handler
+		jsr slowclock			; force slow down
 		clra				; set Z for success
 		bsr error_cleartrap		; clear the error trap
 		bra restore_dp			; restore DP and return
@@ -5009,8 +4982,9 @@
 		bsr set_basdp			; set up DP properly
 		jsr $A282			; write byte
 		bsr restore_dp			; restore direct page
+		jsr slowclock			; force slow down
 		clrb				; reset C for no error
-		bsr error_cleartrap		; clear the error trap
+		jsr error_cleartrap		; clear the error trap
 		puls b,x,y,u,pc			; restore registers and return
 ; This routine reads a byte from the currently open file and returns it in A.
 ; In the event of an error, return C set and close the file. Otherwise, return C clear.
@@ -5022,6 +4996,7 @@
 		jsr $A176			; go read a character
 		sta ,s				; save return value
 		bsr restore_dp			; reset DP
+		jsr slowclock			; force slow down
 		clrb				; reset C for no error
 		puls d,x,y,u,pc			; restore registers and return
 ; This is the IO error handler for file I/O