changeset 26:4245a1b5c333

Identify more parsing routines, also the pull command Identify and label the generic object name parser and three variables used by it. Also decode the PULL command. Additionally, mark the bad command handler routine.
author William Astle <lost@l-w.ca>
date Fri, 26 Dec 2014 10:53:55 -0700
parents 5e2a87c2f9bc
children 811c4d1ee25d
files dod.s
diffstat 1 files changed, 64 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Fri Dec 26 10:35:07 2014 -0700
+++ b/dod.s	Fri Dec 26 10:53:55 2014 -0700
@@ -307,9 +307,9 @@
 V28B		rmb 1
 V28C		rmb 1
 V28D		rmb 1
-V28E		rmb 1
-V28F		rmb 1
-V290		rmb 1
+parseobjtype	rmb 1
+parseobjtypegen	rmb 1
+parsegenobj	rmb 1
 V291		rmb 1
 V292		rmb 2
 V294		rmb 1				; nonzero means to show creatures when displaying a scroll
@@ -2052,34 +2052,35 @@
 		stx V211			; save new input pointer location
 		tst wordbuff			; set flags for whether we have a word
 		puls a,x,u,pc			; restore registers and return
-LCBBA		clr V290
-		ldx #kwlist_obj
-		bsr LCBEC
-		bmi LCBC8
-		beq LCBDF
-		std V28E
-		rts
-LCBC8		dec V290
-		ldx #kwlist_adj
-		bsr LCBE7
-		ble LCBDF
-		std V28E
-		ldx #kwlist_obj
-		bsr LCBEC
-		ble LCBDF
-		cmpb V28F
-		bne LCBDF
-		rts
-LCBDF		leas 2,s			; don't return to caller - we're bailing out
-LCBE1		renderstrimmp			; display "???" for unknown command
+; Parse an object from command line
+parseobj	clr parsegenobj			; flag generic object type
+		ldx #kwlist_obj			; point to object type list
+		bsr LCBEC			; look up word in object type list
+		bmi parseobj000			; brif no match - try matching specific type
+		beq badcommandret		; brif no match - error out
+		std parseobjtype		; save object type matched
+		rts				; return to caller
+parseobj000	dec parsegenobj			; flag specific object type found
+		ldx #kwlist_adj			; point to specific object types
+		bsr LCBE7			; look up word in object type list
+		ble badcommandret		; brif no match
+		std parseobjtype		; save object type
+		ldx #kwlist_obj			; point to generic object types
+		bsr LCBEC			; look up keyword
+		ble badcommandret		; brif no match
+		cmpb parseobjtypegen		; did the object type match?
+		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
 		rts				; return to caller's caller
-LCBE7		pshs a,b,x,y,u
-		clra
-		bra LCBF4
+LCBE7		pshs a,b,x,y,u			; save registers
+		clra				; initialize specific type to zero
+		bra LCBF4			; go look up keyword
 LCBEC		pshs a,b,x,y,u			; save registers
-		clra
-		clrb
+		clra				; initialize specific type to zero
+		clrb				; initialize generic type to zero
 		bsr LCB96			; parse a word from the input line
 		bmi LCC2D			; brif no word present
 LCBF4		clr V278			; flag no match
@@ -2113,13 +2114,13 @@
 LCC2F		puls a,b,x,y,u,pc		; restore registers and return value, return
 LCC31		ldx #kwlist_dir			; point to direction keywords
 		bsr LCBEC			; evaluate the specified keyword
-		ble LCBDF			; brif no matching keyword
+		ble badcommandret		; brif no matching keyword
 		ldu #righthand			; point to right hand contents
 		cmpa #1				; is it right hand wanted?
 		beq LCC46			; brif so - return pointer
 		ldu #lefthand			; point to left hand contents
 		cmpa #0				; is it left hand wanted?
-		bne LCBDF			; brif not - error
+		bne badcommandret		; brif not - error
 LCC46		ldx ,u				; fetch object pointer to X (and set Z if nothing)
 		rts
 LCC49		pshs a,b,x,u
@@ -2890,7 +2891,7 @@
 		jsr LCBEC
 		beq LD2A7
 		bpl LD2A1
-		jsr LCBE1
+		jsr badcommand
 		bra LD2A7
 LD2A1		lsla
 		ldx #LD9D0
@@ -3118,7 +3119,7 @@
 		lda #1
 		bitb #2
 		bne LD478
-LD46F		jmp LCBE1
+LD46F		jmp badcommand
 LD472		lda #$ff
 		cmpb #1
 		bne LD46F
@@ -3203,18 +3204,18 @@
 		puls a,b,x,pc			; restore registers and return
 cmd_get		bsr LD576
 		bne LD573
-		jsr LCBBA
+		jsr parseobj
 		clr V291
 LD52B		ldd V213
 		jsr LCF53
 		beq LD573
-		tst V290
+		tst parsegenobj
 		bne LD53C
 		lda 10,x
-		cmpa V28F
+		cmpa parseobjtypegen
 		bra LD540
 LD53C		lda 9,x
-		cmpa V28E
+		cmpa parseobjtype
 LD540		bne LD52B
 		stx ,u
 		inc 5,x
@@ -3242,7 +3243,7 @@
 		std carryweight
 		dod S0C
 		bra LD5B7
-LD573		jmp LCBE1
+LD573		jmp badcommand
 LD576		jmp LCC31
 cmd_stow	bsr LD576			; get pointer to object in requested hand
 		beq LD573			; brif no object in the hand
@@ -3253,30 +3254,30 @@
 		clrb
 		std ,u
 		bra LD5B7			; update status line, etc.
-cmd_pull	bsr LD576
-		bne LD573
-		jsr LCBBA
-		ldx #backpack
-LD593		tfr x,y
-		ldx ,x
-		beq LD573
-		tst V290
-		bne LD5A3
-		lda 10,x
-		cmpa V28F
-		bra LD5A7
-LD5A3		lda 9,x
-		cmpa V28E
-LD5A7		bne LD593
-		ldd ,x
-		std ,y
-		stx ,u
-LD5AF		clra
+cmd_pull	bsr LD576			; fetch pointer to object in specified hand
+		bne LD573			; brif there is something in that hand
+		jsr parseobj			; parse object name
+		ldx #backpack			; point to backpack head pointer
+LD593		tfr x,y				; save previous pointer location
+		ldx ,x				; fetch pointer to next item
+		beq LD573			; brif end of list
+		tst parsegenobj			; is a specific object type requested?
+		bne LD5A3			; brif so
+		lda 10,x			; get object type (general) requested
+		cmpa parseobjtypegen		; does the object match?
+		bra LD5A7			; finish up the loop
+LD5A3		lda 9,x				; get object type (specific) requested
+		cmpa parseobjtype		; does it match requested object type?
+LD5A7		bne LD593			; brif not matching object
+		ldd ,x				; get next pointer
+		std ,y				; put in previous next pointer (remove from backpack)
+		stx ,u				; save object in the specified hand
+LD5AF		clra				; set up NULL pointer
 		clrb
-		cmpx curtorch
-		bne LD5B7
-		std curtorch
-LD5B7		updatestatus
+		cmpx curtorch			; is this object the current torch?
+		bne LD5B7			; brif not
+		std curtorch			; turn off current torch
+LD5B7		updatestatus			; update status line to reflect new hand contents
 		dod S0E
 		rts
 cmd_incant	ldx #kwlist_adj
@@ -3284,7 +3285,7 @@
 		ble LD5EF
 		tst V27B
 		beq LD5EF
-		std V28E
+		std parseobjtype
 		ldu lefthand
 		bsr LD5D0
 		ldu righthand
@@ -3294,7 +3295,7 @@
 		bne LD5EF
 		lda 7,u
 		beq LD5EF
-		cmpa V28E
+		cmpa parseobjtype
 		bne LD5EF
 		sta 9,u
 		setobjectspecs
@@ -3377,7 +3378,7 @@
 		subd #$20
 		bpl LD68B
 LD692		rts
-LD693		jmp LCBE1
+LD693		jmp badcommand
 LD696		ldu displayptr
 		cmpu #LCE66
 		bne LD6B9