changeset 44:0fb9772b77fc

Decoded MOVE command.
author William Astle <lost@l-w.ca>
date Sat, 27 Dec 2014 01:23:13 -0700
parents 0f6cab894de8
children 8af580d56e9f
files dod.s
diffstat 1 files changed, 65 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Sat Dec 27 01:11:26 2014 -0700
+++ b/dod.s	Sat Dec 27 01:23:13 2014 -0700
@@ -2786,19 +2786,19 @@
 		fdb 1				; move east (0, +1)
 		fdb $100			; move south (+1, 0)
 		fdb $ff				; move west (0, -1)
-LD136		pshs a,b,x,y,u
-		bsr LD11B
-		jsr LCC8E
-		bne LD14D
-		tfr d,u
-		lda ,x
-		inca
-		beq LD14C
-		stu ,s
-		stx 2,s
-		lda #1
-LD14C		deca
-LD14D		puls a,b,x,y,u,pc
+LD136		pshs a,b,x,y,u			; save registers
+		bsr LD11B			; calculate new coordinates
+		jsr LCC8E			; check if we fell off map
+		bne LD14D			; brif so
+		tfr d,u				; save coordinates for later
+		lda ,x				; get data at the new location
+		inca				; is it a room?
+		beq LD14C			; brif not
+		stu ,s				; save new coordinates for return
+		stx 2,s				; save new room pointer
+		lda #1				; set so we get Z=1 on return
+LD14C		deca				; set flags for success/fail
+LD14D		puls a,b,x,y,u,pc		; restore registers and return
 LD14F		pshs a,b,x
 		addb 14,y
 		andb #3
@@ -3535,60 +3535,60 @@
 		fcb 136,0
 		fcb 136,255
 		fcb $fe
-cmd_move	ldx #kwlist_dir
-		jsr LCBEC
-		blt LD693
-		bgt LD6E3
-		dec V273
-		updatedungeon
-		clrb
-		clr V273
-		bra LD6EF
-LD6E3		cmpa #2
-		bne LD6F3
-		dec V274
-		updatedungeon
-		ldb #2
-		clr V274
-LD6EF		bsr LD720
-		bra LD70E
-LD6F3		cmpa #1
-		bne LD701
-		ldb #1
-		bsr LD720
-		bne LD70E
-		bsr LD684
-		bra LD70E
-LD701		cmpa #0
-		bne LD693
-		ldb #3
-		bsr LD720
-		bne LD70E
-		jsr LD674
-LD70E		ldd carryweight
-		jsr asrd3
-		addd #3
-		addd damagelevel
-		std damagelevel
-		checkdamage
+cmd_move	ldx #kwlist_dir			; point to direction list
+		jsr LCBEC			; look up direction
+		blt LD693			; brif bad direction
+		bgt LD6E3			; brif there is a direction
+		dec V273			; mark half step
+		updatedungeon			; update display
+		clrb				; set direction to forward
+		clr V273			; set to normal display
+		bra LD6EF			; go finish up
+LD6E3		cmpa #2				; is it MOVE BACK?
+		bne LD6F3			; brif not
+		dec V274			; set half step back
+		updatedungeon			; go update display
+		ldb #2				; set direction to backward
+		clr V274			; set normal display
+LD6EF		bsr LD720			; update position
+		bra LD70E			; go calculate movement cost, etc.
+LD6F3		cmpa #1				; is it MOVE RIGHT?
+		bne LD701			; brif not
+		ldb #1				; set direction to right
+		bsr LD720			; update position
+		bne LD70E			; brif movement failed
+		bsr LD684			; do a sweep left
+		bra LD70E			; calculate movement cost, etc.
+LD701		cmpa #0				; is it LEFT?
+		bne LD693			; brif not
+		ldb #3				; set direction to left
+		bsr LD720			; update position
+		bne LD70E			; brif movement failed
+		jsr LD674			; do a sweep right
+LD70E		ldd carryweight			; get current carry weight
+		jsr asrd3			; divide by 8
+		addd #3				; add 3 for player weight
+		addd damagelevel		; add to damage level
+		std damagelevel			; save new damage level
+		checkdamage			; check for pasing out
 		dec pageswap			; set graphics swap required
 		sync				; wait for swap to happen
-		rts
-LD720		pshs a,b
-		clr ,-s
-		addb facing
-		andb #3
-		stb V28A
-		ldd playerloc
-		jsr LD136
-		beq LD738
-		playsoundimm $14
-		dec ,s
-		ldd playerloc
-LD738		std playerloc
-		jsr LC660
-		tst ,s+
-		puls a,b,pc
+		rts				; return to caller
+LD720		pshs a,b			; save registers
+		clr ,-s				; make a temp
+		addb facing			; add direction to current facing direction
+		andb #3				; normalize to 0-3
+		stb V28A			; save move direction
+		ldd playerloc			; get current player location
+		jsr LD136			; calculate movement
+		beq LD738			; brif movement succeeds
+		playsoundimm $14		; play the "hit the wall" sound
+		dec ,s				; flag failed movement
+		ldd playerloc			; get current location as result
+LD738		std playerloc			; save new location
+		jsr LC660			; go update the display
+		tst ,s+				; set flags for did movement succeed?
+		puls a,b,pc			; restore registers and return
 cmd_use		jsr LCC31			; fetch pointer to object in specified hand
 		beq LD767			; brif nothing in the hand
 		ldd 9,x				; fetch object type and subtype