changeset 43:0f6cab894de8

Decoded TURN command.
author William Astle <lost@l-w.ca>
date Sat, 27 Dec 2014 01:11:26 -0700
parents ae9b5c72c3f3
children 0fb9772b77fc
files dod.s
diffstat 1 files changed, 73 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Sat Dec 27 00:53:28 2014 -0700
+++ b/dod.s	Sat Dec 27 01:11:26 2014 -0700
@@ -267,7 +267,7 @@
 lefthand	rmb 2				; pointer to object carried in left hand
 righthand	rmb 2				; pointer to object carried in right hand
 damagelevel	rmb 2				; player damage level
-V223		rmb 1
+facing		rmb 1				; the direction the player is facing
 curtorch	rmb 2				; pointer to currently mounted torch
 baselight	rmb 2				; base light level in dungeon
 nokeyboard	rmb 1				; set if no keyboard operations should be done during IRQ
@@ -2453,7 +2453,7 @@
 		lsra
 		leax -1,x
 		bne LCE7D
-		ldb V223
+		ldb facing
 		ldu #neighbourbuff
 		leau b,u
 		ldy #LDBDE
@@ -2475,7 +2475,7 @@
 LCEB2		tfr x,y
 		tst b,u
 		bne LCEB1
-		addb V223
+		addb facing
 		stb V28A
 		ldd V27C
 		jsr LD11B
@@ -2527,7 +2527,7 @@
 		bra LCF0D
 LCF24		tst ,u
 		bne LCF3D
-		lda V223
+		lda facing
 		sta V28A
 		ldd V27C
 		jsr LD11B
@@ -3463,74 +3463,78 @@
 		clr 11,u			; mark object as revealed
 		updatestatus			; update the status area
 LD63E		rts				; return to caller
-cmd_turn	ldx #kwlist_dir
-		jsr LCBEC
-		ble LD693
-		ldb V223
-		cmpa #0
-		bne LD654
-		decb
-		bsr LD66D
-		bsr LD674
-		bra LD669
-LD654		cmpa #1
-		bne LD65D
-		incb
-		bsr LD66D
-		bra LD667
-LD65D		cmpa #3
-		bne LD693
-		addb #2
-		bsr LD66D
-		bsr LD684
-LD667		bsr LD684
-LD669		dec pageswap			; set graoguc swao required
+cmd_turn	ldx #kwlist_dir			; point to direction list
+		jsr LCBEC			; look up word in list
+		ble LD693			; brif no match or no word
+		ldb facing			; get current direction
+		cmpa #0				; TURN LEFT?
+		bne LD654			; brif not
+		decb				; rotate counter clockwise
+		bsr LD66D			; normalize direction and update display
+		bsr LD674			; sweep right
+		bra LD669			; finish up
+LD654		cmpa #1				; TURN RIGHT?
+		bne LD65D			; brif not
+		incb				; rotate clockwise
+		bsr LD66D			; normalize direction and update display
+		bra LD667			; sweep left and finish up
+LD65D		cmpa #3				; TURN AROUND?
+		bne LD693			; brif not
+		addb #2				; turn 180
+		bsr LD66D			; normalize direction and update display
+		bsr LD684			; sweep left and fall through
+LD667		bsr LD684			; sweep left
+LD669		dec pageswap			; set graphic swap required
 		sync				; wait for swap to happen
-		rts
-LD66D		andb #3
-		stb V223
-		jmp LC660
-LD674		bsr LD696
-		bne LD683
-		ldd #8
-LD67B		bsr LD6BA
-		addd #$20
-		tsta
-		beq LD67B
-LD683		rts
-LD684		bsr LD696
-		bne LD692
-		ldd #$f8
-LD68B		bsr LD6BA
-		subd #$20
-		bpl LD68B
-LD692		rts
-LD693		jmp badcommand
-LD696		ldu displayptr
-		cmpu #LCE66
-		bne LD6B9
-		ldx #$8080
+		rts				; return to caller
+LD66D		andb #3				; normalize direction to 0-3
+		stb facing			; save new direction faced
+		jmp LC660			; go update display and return
+LD674		bsr LD696			; draw outline and set up for a vertical line
+		bne LD683			; brif not displaying anything
+		ldd #8				; start at column 8
+LD67B		bsr LD6BA			; draw and erase vertical line
+		addd #$20			; move right 32 pixels
+		tsta				; did we wrap?
+		beq LD67B			; brif not - keep going
+LD683		rts				; return to caller
+LD684		bsr LD696			; set up for drawing the sweep
+		bne LD692			; brif we aren't drawing anything
+		ldd #$f8			; start at X coord 248
+LD68B		bsr LD6BA			; draw and undraw the line
+		subd #$20			; move left 32 pixels
+		bpl LD68B			; brif we haven't wrapped yet - do another
+LD692		rts				; return to caller
+LD693		jmp badcommand			; carp about a bad command
+LD696		ldu displayptr			; get display pointer
+		cmpu #LCE66			; is it the regular dungeon display
+		bne LD6B9			; brif not - don't show turning
+		ldx #$8080			; scale factors of 1.0
 		stx V24F
 		clr V28B
 		dod S00
-		cleargfx1
-		ldx #LD6C6
-		drawgraphic
-		ldx #$11
-		stx ybeg
-		ldx #$87
-		stx yend
-		clra
-LD6B9		rts
-LD6BA		std xbeg
-		std xend
-		bsr LD6C0
-LD6C0		jsr drawline
-		com levbgmask
-		rts
-LD6C6		fcb $10,$00,$10,$ff
-		fcb $ff,$88,$00,$88
-		fcb $ff,$fe
+		cleargfx1			; clear screen
+		ldx #LD6C6			; point to outline graphic
+		drawgraphic			; draw it
+		ldx #$11			;* set start Y coord to 17
+		stx ybeg			;*
+		ldx #$87			;= set end Y coord to 135
+		stx yend			;=
+		clra				; clear Z
+LD6B9		rts				; return to caller
+LD6BA		std xbeg			; set start X coord
+		std xend			; set end X coord
+		bsr LD6C0			; draw the line and invert mask
+LD6C0		jsr drawline			; draw the line again
+		com levbgmask			; invert mask
+		rts				; return to caller
+; This is top and bottom lines during a turn sweep
+LD6C6		fcb 16,0
+		fcb 16,255
+		fcb $ff
+		fcb 136,0
+		fcb 136,255
+		fcb $fe
 cmd_move	ldx #kwlist_dir
 		jsr LCBEC
 		blt LD693
@@ -3572,7 +3576,7 @@
 		rts
 LD720		pshs a,b
 		clr ,-s
-		addb V223
+		addb facing
 		andb #3
 		stb V28A
 		ldd playerloc