changeset 8:7599c6d44eb5

Identified several more SWI routines and commented them. Identified serveral SWI routines and identified them: 1 and 11h through 15h Also added some useful names on several veriables.
author William Astle <lost@l-w.ca>
date Sun, 26 May 2013 12:43:36 -0600
parents c7e6b6318fea
children b0415d785676
files dod.s
diffstat 1 files changed, 267 insertions(+), 201 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Sun May 26 01:10:11 2013 -0600
+++ b/dod.s	Sun May 26 12:43:36 2013 -0600
@@ -72,6 +72,10 @@
 		fcb \1
 		endm
 
+; draw a graphic with graphic data at (X)
+drawgraphic	macro noexpand
+		dod S01
+		endm
 ; render a packed string (immediate data)
 renderstrimmp	macro noexpand
 		dod S02
@@ -120,6 +124,27 @@
 		dod S10
 		endm
 
+; set a block of memory (from X to U-1) to $00
+clearblock	macro noexpand
+		dod S11
+		endm
+; set a block of memory (from X to U-1) to $ff
+setblock	macro noexpand
+		dod S12
+		endm
+; fade in the image at (X) with sound effects at scale 1.0, clear status and command area
+fadeinclrst	macro noexpand
+		dod S13
+		endm
+; fade in the image at (X) with sound effects at scale 1.0, clear command area
+fadein		macro noexpand
+		dod S14
+		endm
+; fade out image at (X) with sound effects, clear command area
+fadeout		macro noexpand
+		dod S15
+		endm
+
 ; play a sound number from immediate data at full volume
 playsoundimm	macro noexpand
 		dod S1B,\1
@@ -215,20 +240,20 @@
 V22B		rmb 1
 V22C		rmb 1				the current level background colour mask
 V22D		rmb 1				the current light level, $ff means dark
-V22E		rmb 1				counter between pixels when drawing lines
-V22F		rmb 2				start Y coord for line drawing
-V231		rmb 2				start X coord for line drawing
-V233		rmb 2				end Y coord for line drawing
-V235		rmb 2				end X coord for line drawing
-V237		rmb 3				current X coordinate when drawing line
-V23A		rmb 3				current Y coordinate when drawing line
-V23D		rmb 3				difference in X coordinate between pixels when drawing line
-V240		rmb 3				difference in Y coordinate between pixels when drawing line
-V243		rmb 2				number of pixels to draw in a line
-V245		rmb 1				the offset to add to pointer when moving to new byte (line drawing)
-V246		rmb 1				the offset to add to pointer when moving to new row (line drawing)
-V247		rmb 2				start address of drawing area (line drawing)
-V249		rmb 2				end address of drawing area (line drawing)
+lightcount	rmb 1				counter between pixels when drawing lines
+ybeg		rmb 2				start Y coord for line drawing
+xbeg		rmb 2				start X coord for line drawing
+yend		rmb 2				end Y coord for line drawing
+xend		rmb 2				end X coord for line drawing
+xcur		rmb 3				current X coordinate when drawing line
+ycur		rmb 3				current Y coordinate when drawing line
+xpstep		rmb 3				difference in X coordinate between pixels when drawing line
+ypstep		rmb 3				difference in Y coordinate between pixels when drawing line
+pixelcount	rmb 2				number of pixels to draw in a line
+xbstep		rmb 1				the offset to add to pointer when moving to new byte (line drawing)
+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
@@ -297,8 +322,8 @@
 V2B8		rmb 1
 V2B9		rmb 2
 V2BB		rmb 1
-V2BC		rmb 1				keyboard buffer read offset
-V2BD		rmb 1				keyboard buffer write offset
+keybufread	rmb 1				keyboard buffer read offset
+keybufwrite	rmb 1				keyboard buffer write offset
 		rmb 3
 V2C1		rmb 1				temporary variable used during line drawing and division
 V2C2		rmb 1				temporary variable used during division
@@ -307,7 +332,7 @@
 V2C5		rmb 1
 V2C6		rmb 1
 V2C7		rmb 10
-V2D1		rmb 32				keyboard ring buffer
+keybuf		rmb 32				keyboard ring buffer
 V2F1		rmb 32
 V311		rmb 2
 V313		rmb 32
@@ -441,7 +466,7 @@
 		bsr LC114
 		ldx #LDF10
 		dec V29E
-		dod S14
+		fadein
 		renderstrimmp				display <CR>"I DARE YE ENTER..."<CR>
 		fcb $9f,$d2,$02,$06
 		fcb $45,$06,$4a,$02
@@ -455,7 +480,7 @@
 		fcb $83,$44,$6f,$7b
 		delay					; wait for about 2.6 seconds
 		delay					;
-		dod S15
+		fadeout
 		cleargfx2				clear second graphics screen
 		dec V2B4
 		sync
@@ -710,23 +735,23 @@
 LC329		pshs cc,b,x			save registers and interrupt status
 		orcc #$10			disable IRQ
 		clra				flag no key pressed
-		ldx #V2D1			point to keyboard ring buffer
-		ldb V2BC			get buffer read offset
-		cmpb V2BD			same as buffer write offset?
+		ldx #keybuf			point to keyboard ring buffer
+		ldb keybufread			get buffer read offset
+		cmpb keybufwrite		same as buffer write offset?
 		beq LC33E			brif so - no key available
 		lda b,x				fetch key from buffer
 		incb				bump buffer pointer
 		andb #$1f			wrap around if needed
-		stb V2BC			save new buffer read offset
+		stb keybufread			save new buffer read offset
 LC33E		puls cc,b,x,pc			restore registers and interrupts
 LC340		pshs cc,b,x			save registers and interrupt status
 		orcc #$10			disable IRQ
-		ldx #V2D1			point to keyboard ring buffer
-		ldb V2BD			get buffer write offset
+		ldx #keybuf			point to keyboard ring buffer
+		ldb keybufwrite			get buffer write offset
 		sta b,x				stash new key
 		incb				bump buffer pointer
 		andb #$1f			wrap around if needed
-		stb V2BD			save new buffer write offset
+		stb keybufwrite			save new buffer write offset
 		puls cc,b,x,pc			restore registers and interrupts
 ; SWI handler
 LC352		andcc #$ef			re-enable IRQ - SWI disables it
@@ -774,11 +799,48 @@
 LC39F		stb V22D
 		rts
 ; SWI 1 routine
-; Render a graphic from (X)
-LC3A2		clr V251
-		lda V22D
-		inca
-		beq LC3F6
+;***********************************************************************************************************
+; This routine renders a line graphic from the specification stored at (X).
+;
+; 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
+; 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.
+;
+; If (X) is >= $FA, it is a special operation defined as follows:
+;
+; FA: return from a "subroutine" to the previous flow
+; FB: call a subroutine at the memory address in the next two bytes
+; FC: draw a series of points using relative motion. The following byte is split into nibbles with the
+;	upper nibble being the Y displacement and the lower nibble being the X displacement. These values
+;	are signed and will be doubled when applied to the drawing. This gives a range of -32 to +30 in
+;	steps of 2 for each direction. If both displacements are zero (a zero byte), this is the end of
+;	the relative sequence. The end of one of these sequences is the end of a polygon.
+; FD: like FB but doesn't record the previous location
+; FE: flags the end of the input and causes a return to the caller. Do not use this in a subroutine as
+;	the stack will have been used to record the return data location.
+; 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
+; 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
+; V22D		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
+		lda V22D			fetch dungeon light level
+		inca				is it $ff (dark)?
+		beq LC3F6			brif so - skip rendering
 LC3A9		ldb ,x				fetch input data
 		subb #$fa			adjust for operation codes
 		blo LC3CF			brif not operation code
@@ -791,7 +853,7 @@
 		fcb LC417-LC3B9			(FC) polygon
 		fcb LC3C6-LC3B9			(FD) jump to a new "routine"
 		fcb LC3F6-LC3B9			(FE) end of input - return to caller
-		fcb LC3CB-LC3B9			(FF)
+		fcb LC3CB-LC3B9			(FF) next coordinates are start of new polygon
 LC3BF		ldd ,x++			get address of "subroutine" to call
 		stx ,--s			save return address
 		tfr d,x				set new "execution" address
@@ -799,71 +861,71 @@
 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
-		bra LC3A9			go process more input
-LC3CF		tst V251
-		bne LC3D9
-		bsr LC3E2
-		dec V251
+LC3CB		clr V251			reset polygon start flag to start
 		bra LC3A9			go process more input
-LC3D9		bsr LC3E0
-		jsr LCAB7
-		bra LC3A9
-LC3E0		bsr LC3F7
-LC3E2		ldb ,x+				get the input byte and move pointer on
-		stb V254			save input byte for later
-		bsr LC400
-		addd V207
-		std V233
-		ldb ,x+				get the next input byte and move pointer on
-		stb V252			save it for later
-		bsr LC406
-		addd V205
-		std V235
+LC3CF		tst V251			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
+		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
+		bsr LC400			scale the Y coordinate
+		addd V207			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
+		bsr LC406			scale the X coordinate
+		addd V205			add in base X coordinate
+		std xend			save scaled X coordinate for line
 LC3F6		rts				return to caller
-LC3F7		ldd V233
-		std V22F
-		ldd V235
-		std V231
-		rts
-LC400		lda V250
-		subb V208
-		bra LC40A
-LC406		lda V24F
-		subb V206
-LC40A		bcs LC40F
-		mul
-		bra LC414
-LC40F		negb
-		mul
-		jsr LCA99			negate D
-LC414		jmp LD377			shift right 7 bits (signed) and return
+LC3F7		ldd yend			fetch last Y coordinate
+		std ybeg			save as begining of new line segment
+		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
+		bra LC40A			go finish calculating scale
+LC406		lda V24F			get desired horizontal scale factor
+		subb V206			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
+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
 LC417		lda ,x+				get next byte in input
 		beq LC3CB			brif NUL - end of values
-		bsr LC3F7
-		ldb -1,x			get the byte following operation code
-		asrb				; move high nibble to low nibble, keep sign
+		bsr LC3F7			move last end coordinate to start coordinate for line
+		ldb -1,x			get the relative movement specifications
+		asrb				; fetch high nibble signed extended into B
 		asrb				;
 		asrb				;
 		asrb				;
 		lslb				and multiply by two
-		addb V254			add in previous coordinate
-		stb V254			save new coordinate
-		bsr LC400
-		addd V207
-		std V233
+		addb V254			add in previous Y coordinate
+		stb V254			save new Y coordinate
+		bsr LC400			go scale the Y coordinate
+		addd V207			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
 		bitb #8				is bit 3 set?
 		beq LC438			brif not
 		orb #$f0			sign extend to 8 bits
 LC438		lslb				multiply by two
-		addb V252			add in saved coordinate
-		stb V252			save new coordinate
-		bsr LC406
-		addd V205
-		std V235
-		jsr LCAB7			go draw a line
+		addb V252			add in saved X coordinate
+		stb V252			save new X coordinate
+		bsr LC406			go scale the X coordinate
+		addd V205			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
 ; swi 2 routine
 ; fetch a packed string immediately following the call and display it
@@ -1061,8 +1123,8 @@
 		cleargfx2
 		dec V2B4
 		dec V228
-		clr V2BC			; reset keyboard buffer
-		clr V2BD			;
+		clr keybufread			; reset keyboard buffer
+		clr keybufwrite			;
 		bra LC5AE
 LC595		cmpa #4
 		ble LC5AE
@@ -1083,7 +1145,7 @@
 ; This routine handles player death
 LC5B5		ldx #LDF10			
 		dec V29E
-		dod S13
+		fadeinclrst
 		renderstrimmp
 		fcb $ff,$c1,$92,$d0		"YET ANOTHER DOES NOT RETURN..."
 		fcb $01,$73,$e8,$82
@@ -1185,15 +1247,17 @@
 		decb				are we done yet?
 		bne LC681			brif not
 		rts
+; these two routine clear an area to 0 (black) or $ff (white) starting at X and
+; ending at U
 ; swi 17 routine
-LC686		clra
-		skip2
+LC686		clra				set area to $00 (clear to black)
+		skip2				skip next byte
 ; swi 18 routine
-LC688		lda #$ff
-LC68A		sta ,x+
-		cmpx 10,s
-		bne LC68A
-		rts
+LC688		lda #$ff			set area to $FF (clear to white)
+LC68A		sta ,x+				clear a byte
+		cmpx 10,s			are we done yet?
+		bne LC68A			brif not
+		rts				return to caller
 ; This looks like a leftover from earlier development which had the
 ; rom calls as a SWI call instead of using SWI2. This routine cannot
 ; be reached through the SWI mechanism and it cannot be called directly
@@ -1208,42 +1272,44 @@
 		stx 6,s				;
 		rts
 ; swi 19 routine
-; Render the
+; fade in the image specified by (X) with sound effects, clear status line and command area
 LC6A4		clr V2B1
 		clearstatus			clear the status area
 ; swi 20 routine
+; fade in the image specified by (X) with sound effects, clear command area
 LC6A8		clearcommand			clear the command area
-		ldd #$8080
-		std V24F
+		ldd #$8080			; set X and Y scale values to 1.0
+		std V24F			;
 		ldb V29E
 		beq LC6B7
-		ldb #$20
+		ldb #$20			set apparent lighting to 32 (less apparent)
 		dec V29C
-LC6B7		bsr LC6D7
-		decb
-		decb
-		bpl LC6B7
+LC6B7		bsr LC6D7			go draw the image
+		decb				; reduce lighting count - make more apparent
+		decb				;
+		bpl LC6B7			brif not done 16 steps
 		clr V29C
 		clr V29E
 LC6C1		playsoundimm $16
-		rts
+		rts				return to caller
 ; swi 21 routine
-LC6C5		clearcommand
+; fade out the image specified by (X) with sound effects, clear command area
+LC6C5		clearcommand			clear the command entry area
 		bsr LC6C1
-		clrb
+		clrb				set apparent illumination to fully lit			
 		dec V29C
-LC6CC		bsr LC6D7
-		incb
-		incb
-		cmpb #$20
-		bne LC6CC
+LC6CC		bsr LC6D7			go draw the image
+		incb				; bump lighting count (make less apparent)
+		incb				;
+		cmpb #$20			have we done 16 steps?
+		bne LC6CC			brif not
 		clr V29C
-		rts
+		rts				return to caller
 LC6D7		pshs x,u			save registers
-		stb V22D
+		stb V22D			set illumination value for graphic rendering
 		stb V29D
 		cleargfx2			clear second graphics screen
-		dod S01				go draw graphic
+		drawgraphic			go draw graphic
 		dec V2B4
 		sync				wait for an interrupt
 		puls x,u,pc			restore registers and return
@@ -1319,9 +1385,9 @@
 		bpl LC76A
 		decb
 		bpl LC768
-		ldx #V3D4
-		ldu #V5F4
-		dod S11
+		ldx #V3D4			get start address to clear
+		ldu #V5F4			get end address to clear
+		clearblock			go clear area to zeros
 		jsr LC053
 		jsr LCC9C
 		ldu V282
@@ -1799,7 +1865,7 @@
 		addd #1				adding 1 turns it into negation
 		rts				return to caller
 LCA9F		pshs a,b,x			save registers
-		ldx V243			get number of pixels to draw
+		ldx pixelcount			get number of pixels to draw
 		ldd ,s				get the difference
 		bpl LCAAE			brif positive
 		bsr LCA99			negate difference
@@ -1810,99 +1876,99 @@
 		std ,s				save step value
 		puls a,b,x,pc			restore registers and return
 LCAB4		jmp LCB8A			go return from the line drawing routine
-; Draw a line from (V231,V22F) to (V235,V233) respecting the light level in the dungeon (V22D)
+; Draw a line from (xbeg,ybeg) to (xend,yend) respecting the light level in the dungeon (V22D)
 ; which is used as a step count between when to actually draw pixels.
 ;
 ; Variables used:
-; V22D	the current light level in the dungeon
-; V22E	how many pixels left before we actually draw another
-; V22F	input start Y
-; V231	input start X
-; V233	input end Y
-; V235	input end X
-; V237	X coordinate of pixel to be drawn (24 bits with 8 bits after binary point)
-; V23A	U cpprdomate of pixel to be drawn (24 bits with 8 bits after binary point)
-; V23D	24 bit X coordinate difference (per pixel)
-; V240	24 bit Y coordinate difference (per pixel)
-; V243	number of pixels to draw in the line
-; V245	the offset for when X coordinate goes to a new byte
-; V246	the offset for when Y coordinate goes to a new line
-; V247	the start address of the graphics screen area the line is within
-; V249	the end address of the graphics screen area the line is within
-; V2C1	a temporary scratch variable
+; V22D		the current light level in the dungeon
+; lightcount	how many pixels left before we actually draw another
+; ybeg		input start Y
+; xbeg		input start X
+; yend		input end Y
+; xend		input end X
+; xcur		X coordinate of pixel to be drawn (24 bits with 8 bits after binary point)
+; ycur		U cpprdomate of pixel to be drawn (24 bits with 8 bits after binary point)
+; xpstep	24 bit X coordinate difference (per pixel)
+; ypstep	24 bit Y coordinate difference (per pixel)
+; pixelcount	number of pixels to draw in the line
+; xbstep	the offset for when X coordinate goes to a new byte
+; xystep	the offset for when Y coordinate goes to a new line
+; drawstart	the start address of the graphics screen area the line is within
+; drawend	the end address of the graphics screen area the line is within
+; V2C1		a temporary scratch variable
 ;
-; Note: V240+1 and V23D+1 are also used as temporary holding values for the
+; Note: ypstep+1 and xpstep+1 are also used as temporary holding values for the
 ; integer difference in the Y and X coordinates respectively.
-LCAB7		pshs a,b,x,y,u			save registers
+drawline	pshs a,b,x,y,u			save registers
 		inc V22D			are we completely dark?
 		beq LCAB4			brif so - we can short circuit drawing entirely
 		lda V22D			get light level in dungeon
-		sta V22E			save in working count (skip count for pixel drawing)
-		ldd V235			get end X coordinate
-		subd V231			subtract start X coordinate
-		std V23D+1			save coordinate difference
+		sta lightcount			save in working count (skip count for pixel drawing)
+		ldd xend			get end X coordinate
+		subd xbeg			subtract start X coordinate
+		std xpstep+1			save coordinate difference
 		bpl LCACB			brif positive difference
 		bsr LCA99			negate the difference
-LCACB		std V243			save absolute value of X difference as pixel count
-		ldd V233			get end Y coordinate
-		subd V22F			subtract start Y coordinate
-		std V240+1			save coordinate difference
+LCACB		std pixelcount			save absolute value of X difference as pixel count
+		ldd yend			get end Y coordinate
+		subd ybeg			subtract start Y coordinate
+		std ypstep+1			save coordinate difference
 		bpl LCAD7			brif positive difference
 		bsr LCA99			negate the difference
-LCAD7		cmpd V243			is the Y difference bigger than X?
+LCAD7		cmpd pixelcount			is the Y difference bigger than X?
 		blt LCAE0			brif not
-		std V243			save Y difference as pixel count
+		std pixelcount			save Y difference as pixel count
 		beq LCAB4			brif no pixels to draw - short circuit
-LCAE0		ldd V23D+1			get X difference
+LCAE0		ldd xpstep+1			get X difference
 		bsr LCA9F			calculate X stepping value
-		std V23D+1			save X stepping value
+		std xpstep+1			save X stepping value
 		tfr a,b				save msb of difference
 		sex				sign extend it
 		ldb #1				X stepping value - 1 for ascending
-		sta V23D			sign extend stepping difference to 24 bits
+		sta xpstep			sign extend stepping difference to 24 bits
 		bpl LCAF0			brif positive
 		negb				set stepping value to -1
-LCAF0		stb V245			save X byte stepping value
-		ldd V240+1			get Y difference
+LCAF0		stb xbstep			save X byte stepping value
+		ldd ypstep+1			get Y difference
 		bsr LCA9F			calculate Y step value
-		std V240+1			save result
+		std ypstep+1			save result
 		tfr a,b				save msb of difference
 		sex				sign extend it
 		ldb #$20			Y byte stepping value - 32 bytes per line, ascending
-		sta V240			sign extend the difference to 24 bits
+		sta ypstep			sign extend the difference to 24 bits
 		bpl LCB02			brif positive
 		negb				negate the difference - -32 bytes per line, descending
-LCB02		stb V246			save Y byte stepping value
-		ldd V231			get start X coordinate
-		std V237			save in X coordinate counter
-		ldd V22F			get start Y coordinate
-		std V23A			save in Y coordinate counter
+LCB02		stb xystep			save Y byte stepping value
+		ldd xbeg			get start X coordinate
+		std xcur			save in X coordinate counter
+		ldd ybeg			get start Y coordinate
+		std ycur			save in Y coordinate counter
 		lda #$80			value for low 8 bits to make the values ".5"
-		sta V237+2			set X coordinate to ".5"
-		sta V23A+2			set Y coordinate to ".5"
+		sta xcur+2			set X coordinate to ".5"
+		sta ycur+2			set Y coordinate to ".5"
 		ldx 2,u				get end of graphics area address
-		stx V249			save it for later
+		stx drawend			save it for later
 		ldx ,u				get start of graphics area address
-		stx V247			save it for later
-		ldd V23A			get Y coordinate for pixel
+		stx drawstart			save it for later
+		ldd ycur			get Y coordinate for pixel
 		jsr LCA0C			shift left 5 bits - 32 bytes per row
 		leax d,x			add to screen start address
-		ldd V237			get X coordinate for pixel
+		ldd xcur			get X coordinate for pixel
 		jsr LD37F			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 V243			get number of pixels to draw
-LCB2E		dec V22E			are we ready to draw another pixel (due to light level)?
+		ldy pixelcount			get number of pixels to draw
+LCB2E		dec lightcount			are we ready to draw another pixel (due to light level)?
 		bne LCB54			brif not
 		lda V22D			get light level
-		sta V22E			reset current "pixel delay"
-		tst V237			is X coordinate off the right of the screen?
+		sta lightcount			reset current "pixel delay"
+		tst xcur			is X coordinate off the right of the screen?
 		bne LCB54			brif so
-		cmpx V247			is the pixel address before the start of the graphics area?
+		cmpx drawstart			is the pixel address before the start of the graphics area?
 		blo LCB54			brif so
-		cmpx V249			is the pixel address after the end of the graphics area?
+		cmpx drawend			is the pixel address after the end of the graphics area?
 		bhs LCB54			brif so
-		ldb V237+1			get X coordinate lsb
+		ldb xcur+1			get X coordinate lsb
 		andb #7				mask off low 3 bits for offset in byte
 		lda b,u				get pixel mask to use
 		tst V22C			currently using black background?
@@ -1912,30 +1978,30 @@
 		skip2				skip next instruction
 LCB50		ora ,x				merge in existing graphics data (black background)
 		sta ,x				save new graphics data on the screen
-LCB54		lda V237+1			get X coordinate lsb
+LCB54		lda xcur+1			get X coordinate lsb
 		anda #$f8			mask off the pixel offset in the byte
 		sta V2C1			save it for later
-		ldd V237+1			get X coordinate low bits
-		addd V23D+1			add in X difference
-		std V237+1			save new low bits for X coordinate
-		ldb V237			get X coordinate high bits
-		adcb V23D			add in difference high bits
-		stb V237			save new X coordinate high bits
+		ldd xcur+1			get X coordinate low bits
+		addd xpstep+1			add in X difference
+		std xcur+1			save new low bits for X coordinate
+		ldb xcur			get X coordinate high bits
+		adcb xpstep			add in difference high bits
+		stb xcur			save new X coordinate high bits
 		anda #$f8			mask off pixel offset in data byte
 		cmpa V2C1			are we in the same byte?
 		beq LCB70			brif so
-		ldb V245			get byte X step value 
+		ldb xbstep			get byte X step value 
 		leax b,x			move pointer appropriately
-LCB70		ldd V23A+1			get Y coord low bits
+LCB70		ldd ycur+1			get Y coord low bits
 		sta V2C1			save screen Y coordinate
-		addd V240+1			add in Y step value low bits
-		std V23A+1			save new low bits
-		ldb V23A			get Y coord high bits
-		adcb V240			add in Y step value high bits
-		stb V23A			save new Y coord high bits
+		addd ypstep+1			add in Y step value low bits
+		std ycur+1			save new low bits
+		ldb ycur			get Y coord high bits
+		adcb ypstep			add in Y step value high bits
+		stb ycur			save new Y coord high bits
 		cmpa V2C1			are we on the same scren row?
 		beq LCB86			brif so
-		ldb V246			get Y byte step value
+		ldb xystep			get Y byte step value
 		leax b,x			move pointer appropriately
 LCB86		leay -1,y			have we drawn all the pixels?
 		bne LCB2E			brif not - draw another
@@ -2075,9 +2141,9 @@
 		andb #$1f
 		cmpb 1,s
 LCC9A		puls a,b,pc
-LCC9C		ldx #V5F4
-		ldu #V9F4
-		dod S12
+LCC9C		ldx #V5F4			get start address to set to $ff
+		ldu #V9F4			get end address
+		setblock			go set block to $ff
 		ldx #LCD9F
 		ldb V281
 		abx
@@ -2340,7 +2406,7 @@
 LCECE		pshs u
 		dod S00
 		ldu V20B
-		dod S01
+		drawgraphic
 		puls u,pc
 LCED8		ldd V27C
 		jsr LCF82
@@ -2916,7 +2982,7 @@
 		rorb
 		rts
 LD386		ldx #LDF10
-		dod S13
+		fadeinclrst
 		renderstrimmp
 		fcb $ff,$c0,$57,$3e		packed string "ENOUGH! I TIRE OF THIS PLAY..."
 		fcb $a7,$46,$c0,$90
@@ -2943,7 +3009,7 @@
 		dod S1A
 		jsr LCF97
 		std V213
-		dod S15
+		fadeout
 		dod S19
 		rts
 LD3D7		pshs a,b,x,u
@@ -3211,7 +3277,7 @@
 LD5EF		rts
 LD5F0		ldx #LDF39
 		dec V29E
-		dod S13
+		fadeinclrst
 		renderstrimmp
 		fcb $ff,$c4,$54,$3d		packed string victory message line 1
 		fcb $84,$d8,$08,$59
@@ -3292,17 +3358,17 @@
 		dod S00
 		cleargfx1
 		ldx #LD6C6
-		dod S01
+		drawgraphic
 		ldx #$11
-		stx V22F
+		stx ybeg
 		ldx #$87
-		stx V233
+		stx yend
 		clra
 LD6B9		rts
-LD6BA		std V231
-		std V235
+LD6BA		std xbeg
+		std xend
 		bsr LD6C0
-LD6C0		jsr LCAB7
+LD6C0		jsr drawline
 		com V22C
 		rts
 LD6C6		fcb $10,$00,$10,$ff
@@ -3425,9 +3491,9 @@
 LD7B7		bsr LD7BC
 		dec V2B8
 		rts
-LD7BC		ldx #V313
-		leau $20,x
-		dod S12
+LD7BC		ldx #V313			get start address to set to $ff
+		leau $20,x			set $20 bytes
+		setblock			go clear block to $ff
 		jmp LCB96
 LD7C7		bsr LD7BC
 		stx CBUFAD