changeset 19:e6d601bc9723

Decode a fixed point multiply routine and additional USE command stuff Decoded a 16.0x0.8 multiply. Also decoded additional bits in the USE command.
author William Astle <lost@l-w.ca>
date Wed, 24 Dec 2014 23:48:31 -0700
parents 7c4ca17c8436
children d41997416b3c
files dod.s
diffstat 1 files changed, 23 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Wed Dec 24 23:32:01 2014 -0700
+++ b/dod.s	Wed Dec 24 23:48:31 2014 -0700
@@ -302,7 +302,7 @@
 V290		rmb 1
 V291		rmb 1
 V292		rmb 2
-V294		rmb 1
+V294		rmb 1				; nonzero means to show creatures when displaying a scroll
 V295		rmb 2
 V297		rmb 3
 V29A		rmb 1
@@ -1457,9 +1457,9 @@
 		fdb LC959			sound 9
 		fdb LC877			sound 10
 		fdb LC877			sound 11
-		fdb LC80A			sound 12
+		fdb LC80A			sound 12 - flask sound
 		fdb LC811			sound 13
-		fdb LC827			sound 14
+		fdb LC827			sound 14 - scroll sound
 		fdb LC8DA			sound 15
 		fdb LC8A6			sound 16
 		fdb LC8B2			sound 17 - torch sound
@@ -3072,20 +3072,21 @@
 		ldx ,u
 		cmpx 10,u
 		puls a,b,x,y,u,pc
-LD436		pshs a,b,x
-		clr V2C1
-		ldb 3,s
-		mul
-		std V2C2
-		lda ,s
-		ldb 2,s
-		mul
-		addd V2C1
-		lsl V2C3
+; Multiply X by the value in A, where the binary point in A is to the left of bit 7.
+LD436		pshs a,b,x			; save parameters and registers
+		clr V2C1			; blank out temp storage area
+		ldb 3,s				; get LSB of X
+		mul				; multiply LSB
+		std V2C2			; save in scratch variable
+		lda ,s				; fetch muliplier
+		ldb 2,s				; fetch MSB of X
+		mul				; multiply it
+		addd V2C1			; add in partial product
+		lsl V2C3			; shift product left (adjust for binary point in A)
 		rolb
 		rola
-		std ,s
-		puls a,b,x,pc
+		std ,s				; save integer result for return
+		puls a,b,x,pc			; clean up parameters, fetch product, and return
 cmd_climb	ldd V213
 		jsr LCFE1
 		bmi LD46F
@@ -3477,8 +3478,8 @@
 		clrb
 		bra LD790			; go set damage level and clean up flask
 LD787		ldx powerlevel			; fetch player power level
-		lda #$66			; 2/3 fraction
-		jsr LD436			; go calculate 2/3 of player power level
+		lda #$66			; roughly 0.4
+		jsr LD436			; go calculate 0.4 of player power level
 		addd damagelevel		; add that to the current damage level
 LD790		std damagelevel			; save new damage level
 LD792		ldb #$17			; type for "EMPTY"
@@ -3488,13 +3489,13 @@
 		dod S0D
 		dod S0C
 		rts
-LD7A0		clra
-		skip2
-LD7A2		lda #$ff
-		sta V294
+LD7A0		clra				; flag for not showing creatures
+		skip2				; skip over next instruction
+LD7A2		lda #$ff			; flag for do show creatures
+		sta V294			; set creature display flag
 		tst 11,u
 		bne LD7B6
-		playsoundimm $0e
+		playsoundimm $0e		; play the scroll sound
 		clr V2AD
 		ldx #LCDB2
 		stx V2B2