changeset 48:47bc11e767f8

Named numerous variables.
author William Astle <lost@l-w.ca>
date Sat, 27 Dec 2014 14:42:42 -0700
parents 90d91aa004d5
children 9ec3a1204f09
files dod.s
diffstat 1 files changed, 101 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Sat Dec 27 14:19:27 2014 -0700
+++ b/dod.s	Sat Dec 27 14:42:42 2014 -0700
@@ -247,27 +247,25 @@
 ; the direct page
 		org $200
 zero		rmb 2				; initialized to $0000
-V202		rmb 1
+V202		rmb 1				; apparently unused
 allones		rmb 2				; initialized to $ffff
-V205		rmb 1
-V206		rmb 1
-V207		rmb 1
-V208		rmb 1
+horizcent	rmb 2				; center coordinate for scaled graphics (X)
+vertcent	rmb 2				; center coordinate for scaled graphics (Y)
 screenvis	rmb 2				; pointer to the parameter block of the currently shown screen
 screendraw	rmb 2				; pointer to the parameter block of the screen to use for drawing
-V20D		rmb 2				; pointer to demo game command sequence
+demoseqptr	rmb 2				; pointer to demo game command sequence
 objectfree	rmb 2				; pointer to next free object data slot
 linebuffptr	rmb 2				; line input buffer pointer
 playerloc	rmb 2				; current player position in maze
-carryweight	rmb 2
-; powerlevel, V219, V21A, V21B, V21C, and damagelevel must remain in the same specific order
+carryweight	rmb 2				; how much weight the player is currently carrying (for movement cost)
+; powerlevel, magicoff, magicdef, physoff, physdef, and damagelevel must remain in the same specific order
 ; with the same spacing between them in order to match the same structure used by the creature
 ; data.
 powerlevel	rmb 2				; player power
-V219		rmb 1				; magical attack value (player)
-V21A		rmb 1
-V21B		rmb 1				; physical attack value (player)
-V21C		rmb 1
+magicoff	rmb 1				; magical attack value (player)
+magicdef	rmb 1				; magical defense value (player)
+physoff		rmb 1				; physical attack value (player)
+physdef		rmb 1				; physical defense value (player)
 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
@@ -293,12 +291,12 @@
 xystep		rmb 1				; the offset to add to pointer when moving to new row (line drawing)
 drawstart	rmb 2				; start address of drawing area (line drawing)
 drawend		rmb 2				; end address of drawing area (line drawing)
-V24B		rmb 4
-V24F		rmb 1
-V250		rmb 1
-V251		rmb 1
-V252		rmb 2
-V254		rmb 2
+		rmb 4				; *unused*
+horizscale	rmb 1				; horizontal scaling factor for rendering
+vertscale	rmb 1				; vertical scaling factor for rendering
+polyfirst	rmb 1				; for rendering images - set if this is the first vertex
+lastunscalex	rmb 2				; most recent unscaled X coordinate for rendering
+lastunscaley	rmb 2				; most recent unscaled Y coordinate for rendering
 V256		rmb 3
 V259		rmb 2
 V25B		rmb 2
@@ -309,11 +307,11 @@
 V263		rmb 2
 V265		rmb 6
 randomseed	rmb 3				; random number generator seed value
-effectivelight	rmb 1
+effectivelight	rmb 1				; effective light level in dungeon
 V26F		rmb 1
 V270		rmb 3
-V273		rmb 1
-V274		rmb 1
+movehalf	rmb 1				; set if rendering half step for MOVE
+movebackhalf	rmb 1				; set if rendering half step for MOVE BACK
 V275		rmb 2
 waitnewgame	rmb 1				; set if waiting for keypress to start new game
 V278		rmb 1
@@ -328,15 +326,15 @@
 holetabptr	rmb 2				; pointer to the hole table for this level
 V288		rmb 2
 V28A		rmb 1
-V28B		rmb 1
-V28C		rmb 1
-V28D		rmb 1
-parseobjtype	rmb 1
-parseobjtypegen	rmb 1
-parsegenobj	rmb 1
-V291		rmb 1				; for iterating over object list, zero means start, nonzero means underway
-V292		rmb 2				; current object pointer for iteration
-V294		rmb 1				; nonzero means to show creatures when displaying a scroll
+renderdist	rmb 1				; distance from "camera" for rendering
+objectcount	rmb 1				; number of objects of specific type to create when initializing
+objectlevel	rmb 1				; starting level (minimum) of object being created
+parseobjtype	rmb 1				; the type of object parsed from command
+parseobjtypegen	rmb 1				; the generic type of the object parsed
+parsegenobj	rmb 1				; nonzero if a generic object was parsed
+objiterstart	rmb 1				; for iterating over object list, zero means start, nonzero means underway
+objiterptr	rmb 2				; current pointer during object list iteration
+showseer	rmb 1				; nonzero means to show creatures when displaying a scroll
 V295		rmb 1				; 10Hz timer counter
 		rmb 1				; 1Hz timer counter
 V297		rmb 1				; 1 min timer counter
@@ -477,20 +475,20 @@
 		clra				; initialize object type
 LC08C		ldb ,u				; get object info
 		andb #$0f			; get low nibble
-		stb V28C			; save number to create (total)
+		stb objectcount			; save number to create (total)
 		ldb ,u+				; get object info again
 		lsrb				; get high nibble (object starting level)
 		lsrb
 		lsrb
 		lsrb
-		stb V28D			; save starting level
+		stb objectlevel			; save starting level
 LC09A		createobject			; create an object
 		dec 5,x				; mark as equipped or carried
 		incb				; bump level
 		cmpb #5				; was it level 5?
 		ble LC0A5			; brif yes
-		ldb V28D			; get level back
-LC0A5		dec V28C			; created enough objects?
+		ldb objectlevel			; get level back
+LC0A5		dec objectcount			; created enough objects?
 		bne LC09A			; brif not
 		inca				; move to next object type
 		cmpu #LDA91+18			; end of table?
@@ -564,7 +562,7 @@
 		dec disablesched		; disable scheduling events
 		ldx #displayscroll		; set to scroll display
 		stx displayptr
-		dec V294			; set to show creatures on map
+		dec showseer			; set to show creatures on map
 		updatedungeon			; show the dungeon map
 		delay				; delay for about 2.5 seconds
 		delay
@@ -847,7 +845,7 @@
 		clr V275			; undo special light level checking
 LC38E		clrb				; default to full bright
 		suba #7				; adjust level based on the order of the table used
-		suba V28B			; subtract render distance from light level
+		suba renderdist			; subtract render distance from light level
 		bge LC39F			; brif adjusted light level >= 0 - means we can see everything
 		decb				; change to dark default
 		cmpa #$f9			; are we in a partial visible range?
@@ -862,7 +860,7 @@
 ;
 ; The data at (X) is a series of operations as follows:
 ;
-; if (X) is < $FA, then the two bytes at (X) are an absolute Y and X coordinate. If V251 is clear, this is
+; if (X) is < $FA, then the two bytes at (X) are an absolute Y and X coordinate. If polyfirst is clear, this is
 ; the first vertex in a polygon and the coordinates are simply recorded. Otherwise, a line is drawn from
 ; the previous coordinates to the new coordinates. These coordinates have the Y coordinate first.
 ;
@@ -881,21 +879,21 @@
 ; FF: mark the next coordinates as the start of a new polygon.
 ;
 ; In all cases, the X and Y coordinates actually used have a scale factor applied to them based on the
-; distance from the defined centre of the graphics area which is stored in (V205,V207). The horizontal
-; scale factor is at V24F and the vertical scaling factor is at V250. A factor of 128 serves as a scale
+; distance from the defined centre of the graphics area which is stored in (horizcent,vertcent). The horizontal
+; scale factor is at horizscale and the vertical scaling factor is at vertscale. A factor of 128 serves as a scale
 ; factor of 1. 192 would be 1.5 and 64 would be 0.5.
 ;
 ; Variables used:
 ;
-; V205		the horizontal centre point for rendering graphics and scaling
-; V207		the vertical centre point for rendering graphics and scaling
+; horizcent	the horizontal centre point for rendering graphics and scaling
+; vertcent	the vertical centre point for rendering graphics and scaling
 ; lightlevel	the light level with respect to rendering the graphic
-; V24F		the horizontal scaling factor (binary point to the right of bit 7)
-; V250		the vertical scaling factor (binary point to the right of bit 7)
-; V251		nonzero if this is not the first coordinate in a polygon
-; V252		the most recent absolute unscaled X coordinate
-; V254		the most recent absolute unscaled Y coordinate
-LC3A2		clr V251			; mark input as start of polygon
+; horizscale	the horizontal scaling factor (binary point to the right of bit 7)
+; vertscale	the vertical scaling factor (binary point to the right of bit 7)
+; polyfirst	nonzero if this is not the first coordinate in a polygon
+; lastunscalex	the most recent absolute unscaled X coordinate
+; lastunscaley	the most recent absolute unscaled Y coordinate
+LC3A2		clr polyfirst			; mark input as start of polygon
 		lda lightlevel			; fetch dungeon light level
 		inca				; is it $ff (dark)?
 		beq LC3F6			; brif so - skip rendering
@@ -919,26 +917,26 @@
 LC3C6		ldx ,x				; get address of "routine" to jump to
 		skip2				; skip next instruction
 LC3C9		ldx ,s++			; get back saved input location
-LC3CB		clr V251			; reset polygon start flag to start
+LC3CB		clr polyfirst			; reset polygon start flag to start
 		bra LC3A9			; go process more input
-LC3CF		tst V251			; is this the first coordinate in a polygon?
+LC3CF		tst polyfirst			; is this the first coordinate in a polygon?
 		bne LC3D9			; brif not
 		bsr LC3E2			; fetch input coordinates and save them
-		dec V251			; flag as not first coordinate
+		dec polyfirst			; flag as not first coordinate
 		bra LC3A9			; go process more input
 LC3D9		bsr LC3E0			; set up coordinates to draw a line
 		jsr drawline			; draw the line
 		bra LC3A9			; go process more input
 LC3E0		bsr LC3F7			; move last end coordinates to line start
 LC3E2		ldb ,x+				; get the next Y coordinate and move pointer forward
-		stb V254			; save unscaled Y coordinate
+		stb lastunscaley		; save unscaled Y coordinate
 		bsr LC400			; scale the Y coordinate
-		addd V207			; add in base Y coordinate
+		addd vertcent			; add in base Y coordinate
 		std yend			; save scaled end coordinate for line
 		ldb ,x+				; get the next X coordinate and move pointer forward
-		stb V252			; save unscaled X coordinate
+		stb lastunscalex		; save unscaled X coordinate
 		bsr LC406			; scale the X coordinate
-		addd V205			; add in base X coordinate
+		addd horizcent			; add in base X coordinate
 		std xend			; save scaled X coordinate for line
 LC3F6		rts				; return to caller
 LC3F7		ldd yend			; fetch last Y coordinate
@@ -946,11 +944,11 @@
 		ldd xend			; fetch last X coordinate
 		std xbeg			; save as beginning of new line segment
 		rts				; return to caller
-LC400		lda V250			; get desired vertical scaling factor
-		subb V208			; find difference from Y base coordinate
+LC400		lda vertscale			; get desired vertical scaling factor
+		subb vertcent+1			; find difference from Y base coordinate
 		bra LC40A			; go finish calculating scale
-LC406		lda V24F			; get desired horizontal scale factor
-		subb V206			; find difference from X base coordinate
+LC406		lda horizscale			; get desired horizontal scale factor
+		subb horizcent+1		; find difference from X base coordinate
 LC40A		bcs LC40F			; brif negative difference
 		mul				; apply the scaling factor
 		bra LC414			; normalize to an integer in D and return
@@ -967,10 +965,10 @@
 		asrb				;*
 		asrb				;*
 		lslb				; and multiply by two
-		addb V254			; add in previous Y coordinate
-		stb V254			; save new Y coordinate
+		addb lastunscaley		; add in previous Y coordinate
+		stb lastunscaley		; save new Y coordinate
 		bsr LC400			; go scale the Y coordinate
-		addd V207			; add in the Y base coordinate
+		addd vertcent			; add in the Y base coordinate
 		std yend			; save new ending Y coordinate
 		ldb -1,x			; get back the input byte again
 		andb #$0f			; mask off the upper bits
@@ -978,10 +976,10 @@
 		beq LC438			; brif not
 		orb #$f0			; sign extend to 8 bits
 LC438		lslb				; multiply by two
-		addb V252			; add in saved X coordinate
-		stb V252			; save new X coordinate
+		addb lastunscalex		; add in saved X coordinate
+		stb lastunscalex		; save new X coordinate
 		bsr LC406			; go scale the X coordinate
-		addd V205			; add in base X coordinate
+		addd horizcent			; add in base X coordinate
 		std xend			; save new ending X coordinate
 		jsr drawline			; go draw a line
 		bra LC417			; look for another line segment
@@ -1339,7 +1337,7 @@
 ; fade in the image specified by (X) with sound effects, clear command area
 LC6A8		clearcommand			; clear the command area
 		ldd #$8080			;* set X and Y scale values to 1.0
-		std V24F			;*
+		std horizscale			;*
 		ldb V29E
 		beq LC6B7
 		ldb #$20			; set apparent lighting to 32 (less apparent)
@@ -1465,7 +1463,7 @@
 LC78D		deca				; move on to next creature
 		bpl LC783			; brif not finished all creatures
 		ldu #creaturetab-17		; point to creature table
-		clr V291			; set to iterate from beginning of object table
+		clr objiterstart		; set to iterate from beginning of object table
 LC795		jsr LCF63			; go fetch object			
 		beq LC7B6			; brif no more objects
 		tst 5,x				; is object carried?
@@ -2351,7 +2349,7 @@
 mdoormasks	fcb $02,$08,$20,$80		; direction masks to create magic doors
 ; This routine draws the display for a scroll.
 ;
-; If V294 is set to nonzero, it displays creature and object information (SEER SCROLL)
+; If showseer is set to nonzero, it displays creature and object information (SEER SCROLL)
 ; otherwise it shows only the maze, holes, and player location (VISION SCROLL).
 ;
 ; V27C is used as a temporary scratch counter for displaying the maze itself.
@@ -2377,9 +2375,9 @@
 		sta V27D			; reset X coordinate to far right
 		dec V27C			; move back a row
 		bpl LCDB9			; brif still in map
-		tst V294			; are we showing creatures and objects?
+		tst showseer			; are we showing creatures and objects?
 		beq LCE2B			; brif not
-		clr V291			; start iteration from scratch
+		clr objiterstart		; start iteration from scratch
 LCDE3		jsr LCF63			; go fetch object
 		beq LCDF7			; brif no more objects
 		tst 5,x				; is the object equipped/carried?
@@ -2427,20 +2425,20 @@
 		bra LCE38			; go check another entry
 LCE47		pshs a,x			; save registers
 		ldx #LCF48			; point to lighting level constants
-		tst V273			; is this a half step render?
+		tst movehalf			; is this a half step render?
 		bne LCE5C			; brif not
 		leax >1,x			; move ahead in the render scale constants
-		tst V274			; is it a half step back?
+		tst movebackhalf		; is it a half step back?
 LCE56		bne LCE5C			; brif not
 		leax >-11,x			; move to backstep levels
-LCE5C		lda V28B			; get distance to render
+LCE5C		lda renderdist			; get distance to render
 		lda a,x				; get scale factor for the distance
-		sta V24F			; save horizontal scaling factor
-		sta V250			; save vertical scaling factor
+		sta horizscale			; save horizontal scaling factor
+		sta vertscale			; save vertical scaling factor
 		puls a,x,pc			; restore registers and return
 ; This is the routine that shows the regular dungeon view.
 LCE66		cleargfx2			; clear the graphics area
-		clr V28B			; set render distance to immediate
+		clr renderdist			; set render distance to immediate
 		ldd playerloc			; get player location
 		std V27C			; save current render location
 LCE6E		bsr LCE47			; calculate scaling factor for current render location
@@ -2517,7 +2515,7 @@
 		lsla				; two bytes per pointer entry
 		ldx a,x				; get actual graphic for the hole present
 LCF09		bsr LCECE			; go render the graphic
-		clr V291			; reset object iterator
+		clr objiterstart		; reset object iterator
 LCF0D		ldd V27C			; get current room
 		jsr LCF53			; fetch next object on floor
 		beq LCF24			; brif no more objects
@@ -2536,8 +2534,8 @@
 		ldd V27C			; get current direction
 		jsr LD11B			; get pointer in that direction
 		std V27C			; save new location
-		inc V28B			; bump render distance (next room going forward)
-		lda V28B			; get distance
+		inc renderdist			; bump render distance (next room going forward)
+		lda renderdist			; get distance
 		cmpa #9				; is it 9 steps out?
 		lble LCE6E			; brif 9 or less - render another room
 LCF3D		rts				; return to caller
@@ -2554,13 +2552,13 @@
 LCF62		rts				; return to caller
 LCF63		pshs a				; save register
 		lda currentlevel		; fetch current level
-		ldx V292			; fetch object pointer
-		tst V291			; are we starting at beginning?
+		ldx objiterptr			; fetch object pointer
+		tst objiterstart		; are we starting at beginning?
 		bne LCF72			; brif not
 		ldx #objecttab-14		; point to start of table
-		dec V291			; mark not at beginning any more
+		dec objiterstart		; mark not at beginning any more
 LCF72		leax 14,x			; move to next object
-		stx V292			; save object pointer for iteration
+		stx objiterptr			; save object pointer for iteration
 		cmpx objectfree			; are we at the end of the table?
 		beq LCF80			; brif so - return
 		cmpa 4,x			; is the object on this level?
@@ -2683,7 +2681,7 @@
 		cmpa #10			; is it the wizard's image or wizard?
 		bge LD06D			; brif so
 		ldd 15,y			; fetch room location
-		clr V291			; reset object iterator
+		clr objiterstart		; reset object iterator
 		jsr LCF53			; fetch first object in room
 		beq LD06D			; brif no object in room
 		ldd 8,y				; get creature inventory pointer
@@ -2703,8 +2701,8 @@
 		bsr LD09E			; set modifiers if shield
 		ldx righthand			; get object in right hand
 		bsr LD09E			; set modifiers if shield
-		sta V21A			; save magical defense value for player
-		stb V21C			; save physical defense value for player
+		sta magicdef			; save magical defense value for player
+		stb physdef			; save physical defense value for player
 		tfr y,x				; put the creature as the attacker
 		ldu #powerlevel			; put the player as defender
 		jsr attack			; calculate an attack
@@ -2913,7 +2911,7 @@
 LD215		anda #$1f			; normalize down to 0...31
 		bsr LD24C			
 		bra LD1EF			; go handle another character
-LD21B		ldy V20D			; fetch pointer to command sequence
+LD21B		ldy demoseqptr			; fetch pointer to command sequence
 		ldb ,y+				; do we have a command to do?
 		bpl LD229			; brif so
 		delay				; wait for a bit
@@ -2934,7 +2932,7 @@
 		bne LD229			; brif not - get another
 		lda #$1f			; code for carriage return
 		bsr LD24C			; add character to buffer and process if needed
-		sty V20D			; save new command stream pointer
+		sty demoseqptr			; save new command stream pointer
 LD248		ldd #$0102			; reschedule for next tick
 		rts				; return to caller
 LD24C		pshs a,b,x,y,u			; save registers
@@ -2990,10 +2988,10 @@
 		ldu #emptyhand			; point to data for emtpy hand
 LD2C2		tfr u,y				; save object data pointer
 		lda 12,u			; fetch magical offense value
-		sta V219			; save for combat calculations
+		sta magicoff			; save for combat calculations
 		lda 13,u			; fetch physical offense value
-		sta V21B			; save for combat calculations
-		adda V219			; calculate sum of magical and physical damage
+		sta physoff			; save for combat calculations
+		adda magicoff			; calculate sum of magical and physical damage
 		rora				;* divide by 8
 		lsra				;*
 		lsra				;*
@@ -3283,7 +3281,7 @@
 		renderstrimmp			; show the "!CREATURE!" string if a creature is present
 		fcb $56,$c7,$22,$86		; packed string "!CREATURE!"
 		fcb $95,$91,$77,$f0
-LD4C0		clr V291			; reset object iterator
+LD4C0		clr objiterstart		; reset object iterator
 LD4C2		ldd playerloc			; get player location
 		jsr LCF53			; fetch next object
 		beq LD4CD			; brif no more objects
@@ -3333,7 +3331,7 @@
 cmd_get		bsr LD576			; go parse hand and return pointer to it
 		bne LD573			; brif no direction
 		jsr parseobj			; go parse an object
-		clr V291			; reset object iterator
+		clr objiterstart		; reset object iterator
 LD52B		ldd playerloc			; get current dungeon location
 		jsr LCF53			; fetch next object
 		beq LD573			; brif no more objects
@@ -3511,8 +3509,8 @@
 		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			; set horizontal and vertical scale factors to 1.0
-		clr V28B			; set render distance to 0 (immediate)
+		stx horizscale			; set horizontal and vertical scale factors to 1.0
+		clr renderdist			; set render distance to 0 (immediate)
 		setlighting			; set light level for rendering
 		cleargfx1			; clear screen
 		ldx #LD6C6			; point to outline graphic
@@ -3540,17 +3538,17 @@
 		jsr LCBEC			; look up direction
 		blt LD693			; brif bad direction
 		bgt LD6E3			; brif there is a direction
-		dec V273			; mark half step
+		dec movehalf			; mark half step
 		updatedungeon			; update display
 		clrb				; set direction to forward
-		clr V273			; set to normal display
+		clr movehalf			; 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
+		dec movebackhalf		; set half step back
 		updatedungeon			; go update display
 		ldb #2				; set direction to backward
-		clr V274			; set normal display
+		clr movebackhalf		; set normal display
 LD6EF		bsr LD720			; update position
 		bra LD70E			; go calculate movement cost, etc.
 LD6F3		cmpa #1				; is it MOVE RIGHT?
@@ -3641,7 +3639,7 @@
 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
+		sta showseer			; set creature display flag
 		tst 11,u			; is flask revealed?
 		bne LD7B6			; brif not - do nothing
 		playsoundimm $0e		; play the scroll sound
@@ -3688,15 +3686,13 @@
 		jmp irqsvc			; IRQ handler
 		fcb $17
 		fdb V202
-		fcb $01				; V202
+		fcb $01				; V202 - apparently unused
 		fdb $ffff			; allones - 16 bit all ones value, or -1
-		fcb $00				; V205
-		fcb $80				; V206
-		fcb 0				; V207
-		fcb $4c				; V208
+		fdb 128				; horizcent
+		fdb 76				; vertcent
 		fdb LD870			; screenvis - pointer to primary display screen info
 		fdb LD876			; screendraw - pointer to secondary display screen info
-		fdb demogame			; V20D - pointer to demo game command sequence
+		fdb demogame			; demoseqptr - pointer to demo game command sequence
 		fdb objecttab			; objectfree - next free object entry
 		fdb linebuff			; linebuffptr - the line input buffer pointer
 		fcb 12,22			; playerloc - starting coordinates in maze (y, x)