changeset 37:026865a318f3

Decoded CLIMB and named several routines Filled in some missing comments and named swi 25 and swi 26 routines. Also decoded the CLIMB command.
author William Astle <lost@l-w.ca>
date Fri, 26 Dec 2014 22:40:55 -0700
parents 25ba333c286e
children c8893fb9cacc
files dod.s
diffstat 1 files changed, 63 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Fri Dec 26 22:28:19 2014 -0700
+++ b/dod.s	Fri Dec 26 22:40:55 2014 -0700
@@ -171,6 +171,14 @@
 setobjectspecs	macro noexpand
 		dod S18
 		endm
+; reset display and show dungeon
+resetdisplay	macro noexpand
+		dod S19
+		endm
+; generate a level
+createlevel	macro noexpand
+		dod S1A
+		endm
 ; play a sound number from immediate data at full volume
 playsoundimm	macro noexpand
 		dod S1B,\1
@@ -532,7 +540,7 @@
 		clra				; create maze for level 1
 		ldu #startobj			; point to new game backpack object list
 LC131		showprepare			; show the PREPARE! screen
-		dod S1A				; create maze
+		createlevel			; create maze
 		ldy #backpack			; point to backpack list head pointer
 LC139		lda ,u+				; get object to create
 		bmi LC14F			; brif end of list
@@ -557,7 +565,7 @@
 		clr disablesched		; enable scheduling events
 		sync				; wait a couple of ticks
 		sync
-LC166		dod S19				; clear command and status areas and show the dungeon
+LC166		resetdisplay			; clear command and status areas and show the dungeon
 		showprompt			; show command prompt
 		jmp LC1F5			; go to main loop
 LC16D		stx CBUFAD			; set address to read to
@@ -615,7 +623,7 @@
 		lds #STACK			; reset stack pointer
 LC1EC		jsr enablepiairq		; make sure PIAs are set right
 		clr V2B8			; flag regular operations
-		dod S19				; clear command and status areas, update appropriately
+		resetdisplay			; clear command and status areas, update appropriately
 		showprompt			; show command prompt
 LC1F5		ldu #V2AB			; point to ready list head
 		clr V2BB			; mark ready list restart not needed
@@ -942,7 +950,7 @@
 LC40F		negb				; make coordinate difference positive
 		mul				; apply the scaling factor
 		jsr LCA99			; negate coordinate value
-LC414		jmp LD377			; normalize to an integer in D and return
+LC414		jmp asrd7			; normalize to an integer in D and return
 LC417		lda ,x+				; get next byte in input
 		beq LC3CB			; brif NUL - end of values
 		bsr LC3F7			; move last end coordinate to start coordinate for line
@@ -1041,25 +1049,25 @@
 ; value 1: lower 3 bits of current input byte and upper 2 bits of next one
 ; consumes a byte
 LC4B0		ldd ,x+				; fetch input data and consume a byte
-		jmp LD379			; align in low bits of B
+		jmp asrd6			; align in low bits of B
 ; value 2: bits 5...1 of current input byte
 LC4B5		ldb ,x				; fetch input byte
 		bra LC4AE			; align in low bits of B
 ; value 3: bits 0 of current byte and upper 4 bits of next one
 ; consumes a byte
 LC4B9		ldd ,x+				; fetch input data and consume a byte
-		jmp LD37D			; align in low bits of B
+		jmp asrd4			; align in low bits of B
 ; value 4: low 4 bits of input byte and high bit of next one
 ; consumes a byte
 LC4BE		ldd ,x+				; fetch input data and consume a byte
-		jmp LD377			; align in low bits of B
+		jmp asrd7			; align in low bits of B
 ; value 5: bits 6...2 of current input byte
 LC4C3		ldb ,x				; fetch input data
 		bra LC4AD			; align in low bits of B
 ; value 6: low two bits of current input byte and high 3 bits of next one
 ; consums a byte
 LC4C7		ldd ,x+				; fetch input data and consume a byte
-		jmp LD37B			; align in low bits of B
+		jmp asrd5			; align in low bits of B
 ; value 7: low 5 bits of current input byte
 ; consumes a byte
 LC4CC		ldb ,x+				; fetch input data - already aligned
@@ -2010,7 +2018,7 @@
 		jsr LCA0C			; shift left 5 bits - 32 bytes per row
 		leax d,x			; add to screen start address
 		ldd xcur			; get X coordinate for pixel
-		jsr LD37F			; shift right 3 bits - 8 pixels per byte
+		jsr asrd3			; shift right 3 bits - 8 pixels per byte
 		leax d,x			; add to row start address
 		ldu #LCB8E			; point to table of pixel masks
 		ldy pixelcount			; get number of pixels to draw
@@ -2865,7 +2873,7 @@
 LD1D5		clra				; set NULL value
 		clrb
 		subd damagelevel		; subtract it from the current damage level
-		jsr LD379			; shift right 6 bits (divide by 64)
+		jsr asrd6			; shift right 6 bits (divide by 64)
 		addd damagelevel		; reduce damage level by 1/64 of original damage level
 		bgt LD1E2			; brif new damage level > 0
 		clra				; minimize damage level at 0
@@ -2928,7 +2936,7 @@
 LD24C		pshs a,b,x,y,u			; save registers
 		tst V2AD			; are we starting a new command string?
 		bne LD256			; brif not
-		dod S19				; clear command area, reset status, and redisplay dungeon
+		resetdisplay			; clear command area, reset status, and redisplay dungeon
 		showprompt			; show the prompt
 LD256		ldu linebuffptr			; get input buffer pointer
 		cmpa #$1f			; end of line?
@@ -3040,7 +3048,7 @@
 		updatedungeon
 		playsoundimm $15		; play the "kill" sound
 		ldd ,u				; fetch creature power level
-		bsr LD37F			; divide by 8
+		bsr asrd3			; divide by 8
 		addd powerlevel			; add gained power to current power level
 		bpl LD351			; brif power level did not overflow
 		lda #$7f			; maximize power level at 32767
@@ -3060,23 +3068,24 @@
 		std curtorch			; mark no torch burning
 		std righthand			; mark right hand empty
 		std lefthand			; mark left hand empty
-		dod S19
-LD375		checkdamage
-LD377		asra
-		rorb
-LD379		asra
-		rorb
-LD37B		asra
+		resetdisplay			; reset display and show dungeon
+LD375		checkdamage			; update the damage situation
+; The following are pointless in this routine - we're returning from a command and D is zero anyway!
+asrd7		asra				; enter here to do an arithmetic right shift 7 bits
 		rorb
-LD37D		asra
-		rorb
-LD37F		asra
+asrd6		asra				; enter here to do an arithmetic right shift 6 bits
 		rorb
-LD381		asra
+asrd5		asra				; enter here to do an arithmetic right shift 5 bits
 		rorb
-LD383		asra
+asrd4		asra				; enter here to do an arithmetic right shift 4 bits
 		rorb
-		rts
+asrd3		asra				; enter here to do an arithmetic right shift 3 bits
+		rorb
+		asra
+		rorb
+		asra
+		rorb
+		rts				; return to caller
 LD386		ldx #img_wizard			; point to Wizard graphic
 		fadeinclrst			; fade in the wizard
 		renderstrimmp			; dipslay "ENOUGH! I TIRE OF THIS PLAY..."
@@ -3102,11 +3111,11 @@
 LD3C4		ldd #200			; set player carry weight to 200
 		std carryweight
 		lda #3				
-		dod S1A
+		createlevel
 		jsr LCF97
 		std playerloc
 		fadeout				; fade out the wizard
-		dod S19
+		resetdisplay
 		rts
 LD3D7		pshs a,b,x,u
 		lda #15
@@ -3169,37 +3178,37 @@
 		addd accum0			; add in partial product
 		lsl accum0+2			;* shift product left so binary point is to the right of
 		rolb				;* of the upper 16 bits - leave interger result in D.
-		rola
+		rola				;*
 		std ,s				; save integer result for return
 		puls a,b,x,pc			; clean up parameters, fetch product, and return
-cmd_climb	ldd playerloc
-		jsr LCFE1
-		bmi LD46F
-		sta accum0
-		ldx #kwlist_dir
-		jsr LCBEC
-		ble LD46F
-		ldb accum0
-		cmpa #4
-		beq LD472
-		cmpa #5
-		bne LD46F
-		lda #1
-		bitb #2
-		bne LD478
-LD46F		jmp badcommand
-LD472		lda #$ff
-		cmpb #1
-		bne LD46F
-LD478		showprepare
-		adda currentlevel
-		dod S1A
-		dod S19
-		rts
+cmd_climb	ldd playerloc			; get player location
+		jsr LCFE1			; fetch hole information
+		bmi LD46F			; brif no holes
+		sta accum0			; save hole info
+		ldx #kwlist_dir			; point to direction list
+		jsr LCBEC			; go parse direction
+		ble LD46F			; brif no direction
+		ldb accum0			; get hole info
+		cmpa #4				; is it up?
+		beq LD472			; brif so
+		cmpa #5				; is it down?
+		bne LD46F			; brif not
+		lda #1				; level goes up one if we descend
+		bitb #2				; is there a hole down?
+		bne LD478			; brif so
+LD46F		jmp badcommand			; complain about bad direction or no hole
+LD472		lda #$ff			; level goes down one if we ascend
+		cmpb #1				; do we have a ladder?
+		bne LD46F			; brif not
+LD478		showprepare			; show the scary PREPARE! screen
+		adda currentlevel		; calculate the new level number
+		createlevel			; build the new level
+		resetdisplay			; reset everything and show the maze
+		rts				; return to caller
 cmd_examine	ldx #LD495			; pointer to the inventory display routine
 		stx displayptr			; set up the display update routine
 		updatedungeon			; update the display
-		rts
+		rts				; return to caller
 LD489		cleargfx2			; clear graphics
 		ldx ,u
 		ldu #V380
@@ -3503,7 +3512,7 @@
 		bne LD70E
 		jsr LD674
 LD70E		ldd carryweight
-		jsr LD37F
+		jsr asrd3
 		addd #3
 		addd damagelevel
 		std damagelevel