changeset 34:31983aaad910

ZPAUSE now has a way to resume the game ZPAUSE now takes the game into pause mode. Pause mode allows command entry but does not allow any game play commands. The "RESUME" command restarts the game.
author William Astle <lost@l-w.ca>
date Fri, 02 Jan 2015 18:31:30 -0700
parents ddac2cf283b2
children 48ad2dd3b1e9
files dod.s
diffstat 1 files changed, 37 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Fri Jan 02 18:06:59 2015 -0700
+++ b/dod.s	Fri Jan 02 18:31:30 2015 -0700
@@ -437,6 +437,7 @@
 columnctr	rmb 1				; column counter/tracker for displaying inventory list
 textother	rmb 1				; nonzero means nonstandard text location
 loadsaveflag	rmb 1				; load/save flag - <0 = ZLOAD, >0 = ZSAVE, 0 = regular init
+pausemode	rmb 1				; nonzero = game paused
 schedtabfree	rmb 2				; pointer to next free entry in the scheduling table
 readylistchg	rmb 1				; nonzero if the ready list processing should be restarted
 keybufread	rmb 1				; keyboard buffer read offset
@@ -675,7 +676,10 @@
 busywait000	leax -1,x			; have we reached 0?
 		bne busywait000			; brif not
 		rts
-LC1F5		ldu #schedlists+12		; point to ready list head
+LC1F5a		jsr LD1EB			; go process keyboard
+LC1F5		tst pausemode			; are we paused?
+		bne LC1F5a			; brif so
+		ldu #schedlists+12		; point to ready list head
 		clr readylistchg		; mark ready list restart not needed
 LC1FA		tfr u,y				; save ready list pointer
 LC1FC		ldu ,u				; are we at the end of the ready list?
@@ -3084,7 +3088,7 @@
 		cmpu #linebuffend		; is the buffer full?
 		bne LD2B4			; brif not
 LD26F		lda #32				; make a space
-		jsr putchr			; render it
+		jsr putchr			; render it (erase cursor)
 		ldd zero			; get end of string marker
 		std ,u++			; save in buffer
 		ldu #linebuff			; reset buffer pointer to start of line
@@ -3097,7 +3101,9 @@
 		jsr putstr			; display the backspace string
 		bra LD2B4			; get on with things
 LD28C		fcb 32,8,8,'_,8,0		; string to erase cursor and previous character
-LD292		ldx #kwlist_cmd			; point to command list
+LD292		tst pausemode			; are we paused?
+		lbne pausemodecmd		; brif so - go handle pause mode
+		ldx #kwlist_cmd			; point to command list
 		jsr lookup_word			; look up word in command list
 		beq LD2A7			; brif nothing to match
 		bpl LD2A1			; brif found
@@ -5449,7 +5455,9 @@
 		jmp START			; transfer control to the main stream code
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; This is the "pause mode". Pause mode has a completely different list of commands available to it.
-cmd_zpause	inc loadsaveflag		; freeze the game
+; The ZPAUSE command starts pause mode.
+cmd_zpause	dec disablesched		; freeze the scheduler
+		clr enableheart			; stop the heart
 		clearstatus			; clear the status bar
 		ldu #statusarea			; point to status area parameters
 		dec textother			; set to nonstandard rendering
@@ -5458,8 +5466,31 @@
 		jsr putstrimm			; display the pause notice
 		fcn '**PAUSED**'
 		clr textother			; reset display parameters
-cmd_zpause000	bra *
-		
+		dec pausemode			; mark game paused
+		rts
+; This is the puase mode command handler
+pausemodecmd	ldx #kwlist_pcmd		; point to command list
+		jsr lookup_word			; look up word in command list
+		beq pausemode000		; brif nothing to match
+		bpl pausemode001		; brif found
+		jsr badcommand			; show bad command string
+pausemode000	jmp LD2A7			; go on with new command
+pausemode001	lsla				; two bytes per jump table entry
+		ldx #pausecmd_jump		; point to command jump table
+		jsr [a,x]			; go handle command
+		jmp LD2A7			; go handle new command
+; Pause mode command list
+kwlist_pcmd	fcb 1
+		fcb 0				; RESUME
+		fcn 'RESUME'
+; Pause mode command jump table
+pausecmd_jump	fdb pcmd_resume			; RESUME command
+; This is the resume command
+pcmd_resume	updatestatus			; update the status line
+		dec enableheart			; enable heartbeat
+		clr disablesched		; re-enable scheduler
+		clr pausemode			; turn off pause mode
+		rts
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; This is the bit that intercepts RVEC12. It requires at least Extended Basic to work because it relies on multi-origin binaries.
 ; That will always be the case for Disk Basic. Theoretically, with just this, a loader will work from tape in Extended Basic