changeset 22:b54feb3d64eb

Identified several aspects related to object creation Identified the object creation routine (SWI call 23). Also identified SWI call 24 which sets the specifications for an object based on its type. Also identified the initial equipment creation code. Also identified several variable areas including the object data table. Also identified the data tables for objects in the ROM.
author William Astle <lost@l-w.ca>
date Fri, 26 Dec 2014 00:51:50 -0700
parents 0a6eb8cabe1d
children 7c2f57937862
files dod.s
diffstat 1 files changed, 193 insertions(+), 167 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Thu Dec 25 22:38:14 2014 -0700
+++ b/dod.s	Fri Dec 26 00:51:50 2014 -0700
@@ -151,7 +151,14 @@
 showprepare	macro noexpand
 		dod S16
 		endm
-
+; create object of type in A
+createobject	macro noexpand
+		dod S17
+		endm
+; set object specs (object pointer in U)
+setobjectspecs	macro noexpand
+		dod S18
+		endm
 ; play a sound number from immediate data at full volume
 playsoundimm	macro noexpand
 		dod S1B,\1
@@ -226,11 +233,11 @@
 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
-V20F		rmb 2
+objectfree		rmb 2				; pointer to next free object data slot
 V211		rmb 2
 V213		rmb 1
 V214		rmb 1
-V215		rmb 2
+carryweight	rmb 2
 powerlevel	rmb 2				; player power
 V219		rmb 1
 V21A		rmb 1
@@ -365,19 +372,18 @@
 V398		rmb 43
 V3C3		rmb 17
 V3D4		rmb $220
-V5F4		rmb $400
+mazedata	rmb $400
 V9F4		rmb 9
 V9FD		rmb $10a
-VB07		rmb 10
-VB11		rmb 4
-VB15		rmb $3f0
+emptyhand	rmb 10				; "object" information for empty hand
+objecttab	rmb 72*14			; the object data table (room for 72 entries)
 VF05		equ *
 
 
 		org $c000
-START		ldu #LC0D1			point to the demo setup routine
+START		ldu #dodemo			point to the demo setup routine
 		bra LC008			go handle the game
-LC005		ldu #LC124			point to the real game setup routine
+LC005		ldu #dogame			point to the real game setup routine
 LC008		lds #STACK			put the stack somewhere safe
 		ldx #PIA0			point at PIA0
 		ldd #$34fa			initializers for the PIA
@@ -421,7 +427,7 @@
 		ldx #V9FD
 		stx V2B9
 LC066		clr ,x+
-		cmpx #VB07
+		cmpx #emptyhand
 		blo LC066
 		ldy #LD7DC
 		dec V2BB
@@ -445,7 +451,7 @@
 		lsrb
 		lsrb
 		stb V28D
-LC09A		dod S17
+LC09A		createobject
 		dec 5,x
 		incb
 		cmpb #5
@@ -468,58 +474,58 @@
 		fcb $48
 		clr V2B7				reset text rendering to standard mode
 		rts					
-LC0D1		dec V277
+dodemo		dec V277
 		bsr LC114
-		ldx #img_wizard
+		ldx #img_wizard				; point to wizard image
 		dec V29E
-		fadein
-		renderstrimmp				display <CR>"I DARE YE ENTER..."<CR>
-		fcb $9f,$d2,$02,$06
+		fadein					; fade the wizard in
+		renderstrimmp				; display <CR>"I DARE YE ENTER..."<CR>
+		fcb $9f,$d2,$02,$06			; packed "\rI DARE YE ENTER...\r" string
 		fcb $45,$06,$4a,$02
 		fcb $ba,$85,$97,$bd
 		fcb $ef,$80
-		renderstrimmp				display "...THE DUNGEONS OF DAGGORATH!!!"
-		fcb $f7,$bd,$ea,$20
+		renderstrimmp				; display "...THE DUNGEONS OF DAGGORATH!!!"
+		fcb $f7,$bd,$ea,$20			; packed "...THE DUNGEONS OF DAGGORATH!!!" string
 		fcb $a0,$25,$5c,$72
 		fcb $bd,$d3,$03,$cc
 		fcb $02,$04,$e7,$7c
 		fcb $83,$44,$6f,$7b
-		delay					; wait for about 2.6 seconds
-		delay					;
-		fadeout
-		cleargfx2				clear second graphics screen
-		dec pageswap				flag graphics swap ready
-		sync					wait for swap to happen
-		lda #2
-		ldu #LD7D5
-		bra LC131
-LC114		ldd #$343c				set up initializers for PIAs
-		sta PIA1+1				set data mode, no interrupts, cassette off
-		stb PIA1+3				set data mode, no interrupts, sound on
-		inca					adjust to enable interrupt
-		sta PIA0+3				set data mode, enable VSYNC, clear MSB of analog MUX
-		cwai #$ef				enable IRQ and wait for one
-		rts					return to caller
-LC124		bsr LC114
+		delay					;* wait for about 2.6 seconds
+		delay					;*
+		fadeout					; fade the wizard out
+		cleargfx2				; clear second graphics screen
+		dec pageswap				; flag graphics swap ready
+		sync					; wait for swap to happen
+		lda #2					; create maze for level 3
+		ldu #startobjdemo			; point to demo game object list
+		bra LC131				; go start demo running
+LC114		ldd #$343c				; set up initializers for PIAs
+		sta PIA1+1				; set data mode, no interrupts, cassette off
+		stb PIA1+3				; set data mode, no interrupts, sound on
+		inca					; adjust to enable interrupt
+		sta PIA0+3				; set data mode, enable VSYNC, clear MSB of analog MUX
+		cwai #$ef				; enable IRQ and wait for one
+		rts					; return to caller
+dogame		bsr LC114				; set up interrupts and sound
 		ldd #$100b
 		std V213
-		clr powerlevel
-		clra
-		ldu #LD7D9
-LC131		showprepare
-		dod S1A
-		ldy #backpack
-LC139		lda ,u+
-		bmi LC14F
-		dod S17
+		clr powerlevel				; reset power level to new game level (keeps LSB of default value)
+		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
+		ldy #backpack				; point to backpack list head pointer
+LC139		lda ,u+					; get object to create
+		bmi LC14F				; brif end of list
+		createobject				; create requested object
 		inc 5,x
-		exg x,u
-		dod S18
-		exg x,u
-		clr 11,x
-		stx ,y
-		tfr x,y
-		bra LC139
+		exg x,u					; swap object pointer and list pointer
+		setobjectspecs				; set the specs properly (as in fully revealed)
+		exg x,u					; swap pointers back
+		clr 11,x				; mark object revealed
+		stx ,y					; save new object in backpack list
+		tfr x,y					; move list pointer to object just created
+		bra LC139				; go look for another object to create
 LC14F		tst V277
 		beq LC166
 		dec V29B
@@ -1228,7 +1234,7 @@
 ; swi 14 routine
 LC656		tst V228
 		bne LC65F
-		bsr LC660
+		bsr LC660			; go update the display
 		dec pageswap			; flag graphics swap required
 		sync				; wait for swap to happen
 LC65F		rts
@@ -1332,42 +1338,46 @@
 		dec pageswap			set graphic swap required
 		rts				return to caller
 ; swi 23 routine
-LC6FB		ldu V20F
-		stu 6,s
-		leax 14,u
-		stx V20F
-		sta 9,u
+LC6FB		ldu objectfree			; fetch free point in object table
+		stu 6,s				; save pointer for return
+		leax 14,u			; move to next entry in table
+		stx objectfree			; save as new free point in object table
+		sta 9,u				; set object type to requested type
 		stb 4,u
-		dod S18
-		ldb 10,u
-		ldx #LC719
-		lda b,x
-		bmi LC718
-		ldb 11,u
-		dod S18
-		stb 11,u
+		setobjectspecs			; set up object specs from data tables
+		ldb 10,u			; fetch object general type
+		ldx #LC719			; point to modifier table
+		lda b,x				; get modified type entry
+		bmi LC718			; brif no modification
+		ldb 11,u			; get reveal strength of original object type
+		setobjectspecs			; set up object data from replacement type
+		stb 11,u			; restore reveal strength
 LC718		rts
-LC719		fcb $ff,$ff,$ff,$10
-		fcb $11,$0f
+LC719		fcb $ff				; flasks do not get a replacment
+		fcb $ff				; rings do not get a replacement
+		fcb $ff				; scrolls do not get a replacement
+		fcb $10				; shields default to leather shield specs
+		fcb $11				; swords default to wooden sword specs
+		fcb $0f				; torches default to pine torch specs
 ; swi 24 routine
-LC71F		lsla
+LC71F		lsla				; four bytes per object specs entry
 		lsla
-		ldx #LDA00
-		leay a,x
-		leax 10,u
-		lda #4
-		jsr LC04B
-		ldx #LDA60
-LC730		leax 4,x
-		lda ,x
-		bmi LC742
-		cmpa 3,s
-		bne LC730
-		ldd 1,x
+		ldx #objspecs			; point to object data table
+		leay a,x			; point to correct entry in table
+		leax 10,u			; point to location in data table
+		lda #4				; four bytes to copy
+		jsr LC04B			; copy data into new object
+		ldx #objextraspecs-4		; point to extra object data
+LC730		leax 4,x			; move to next entry
+		lda ,x				; is it end of table?
+		bmi LC742			; brif so
+		cmpa 3,s			; is this entry for the object type we're creating?
+		bne LC730			; brif not - try another
+		ldd 1,x				; copy the ring charges and defensive values
 		std 6,u
 		lda 3,x
 		sta 8,u
-LC742		rts
+LC742		rts				; return to caller
 ; swi 25 routine
 LC743		clearstatus
 		clearcommand
@@ -1394,7 +1404,7 @@
 		decb
 		bpl LC768
 		ldx #V3D4			get start address to clear
-		ldu #V5F4			get end address to clear
+		ldu #mazedata			get end address to clear
 		clearblock			go clear area to zeros
 		jsr LC053
 		jsr LCC9C
@@ -1414,7 +1424,7 @@
 		tst 5,x
 		bpl LC795
 LC79E		leau 17,u
-		cmpu #V5F4
+		cmpu #mazedata
 		blo LC7AA
 		ldu #V3D4
 LC7AA		tst 12,u
@@ -2144,7 +2154,7 @@
 		tfr d,x
 		ldb #$20
 		mul
-		addd #V5F4
+		addd #mazedata
 		exg d,x
 		abx
 		puls a,b,pc
@@ -2155,7 +2165,7 @@
 		andb #$1f
 		cmpb 1,s
 LCC9A		puls a,b,pc
-LCC9C		ldx #V5F4			get start address to set to $ff
+LCC9C		ldx #mazedata			get start address to set to $ff
 		ldu #V9F4			get end address
 		setblock			go set block to $ff
 		ldx #LCD9F
@@ -2320,7 +2330,7 @@
 		bra LCDE3
 LCDF7		ldx #V3C3
 LCDFA		leax $11,x
-		cmpx #V5F4
+		cmpx #mazedata
 		beq LCE2B
 		tst 12,x
 		beq LCDFA
@@ -2488,11 +2498,11 @@
 		ldx V292
 		tst V291
 		bne LCF72
-		ldx #VB07
+		ldx #emptyhand
 		dec V291
 LCF72		leax 14,x
 		stx V292
-		cmpx V20F
+		cmpx objectfree
 		beq LCF80
 		cmpa 4,x
 		bne LCF72
@@ -2500,7 +2510,7 @@
 LCF80		puls a,pc
 LCF82		ldx #V3C3
 LCF85		leax $11,x
-		cmpx #V5F4
+		cmpx #mazedata
 		beq LCF96
 		cmpd 15,x
 		bne LCF85
@@ -2893,20 +2903,20 @@
 cmd_attack	jsr LCC31			; get pointer to specified hand
 		ldu ,u				; fetch item in specified hand
 		bne LD2C2			; brif item there
-		ldu #VB07			; point to data for emtpy hand
+		ldu #emptyhand			; point to data for emtpy hand
 LD2C2		tfr u,y				; save object data pointer
 		lda 12,u			
 		sta V219
 		lda 13,u
 		sta V21B
-		adda V219
-		rora
+		adda V219			; calculate sum of magical and physical damage
+		rora				; divide by 8
 		lsra
 		lsra
-		ldx powerlevel
-		jsr LD436
-		addd damagelevel
-		std damagelevel
+		ldx powerlevel			; fetch current player power
+		jsr applyscale			; apply the scale factor calculated above
+		addd damagelevel		; apply the wielding cost to play damage
+		std damagelevel			; save new damage value
 		lda 10,u			; get object type
 		adda #12			; offset into sound table
 		ldb #$ff			; set full volume
@@ -2972,7 +2982,7 @@
 		ldd #$713
 		std V226
 		ldx #$b23
-		stx V20F
+		stx objectfree
 		ldd zero
 		std backpack
 		std curtorch
@@ -2995,35 +3005,35 @@
 LD383		asra
 		rorb
 		rts
-LD386		ldx #img_wizard
-		fadeinclrst
-		renderstrimmp
-		fcb $ff,$c0,$57,$3e		packed string "ENOUGH! I TIRE OF THIS PLAY..."
+LD386		ldx #img_wizard			; point to Wizard graphic
+		fadeinclrst			; fade in the wizard
+		renderstrimmp			; dipslay "ENOUGH! I TIRE OF THIS PLAY..."
+		fcb $ff,$c0,$57,$3e		; packed string "ENOUGH! I TIRE OF THIS PLAY..."
 		fcb $a7,$46,$c0,$90
 		fcb $51,$32,$28,$1e
 		fcb $60,$51,$09,$98
 		fcb $20,$c0,$e7,$de
 		fcb $f0
-		renderstrimmp
-		fcb $e8,$00,$08,$48		packed string "PREPARE TO MEET THY DOOM!!!"
+		renderstrimmp			; also display "PREPARE TO MEET THY DOOM!!!"
+		fcb $e8,$00,$08,$48		; packed string "PREPARE TO MEET THY DOOM!!!"
 		fcb $b0,$0c,$8a,$0a
 		fcb $3c,$0d,$29,$68
 		fcb $0a,$23,$20,$23
 		fcb $de,$dd,$ef,$60
-		delay
-		ldu curtorch
-		stu backpack
-		beq LD3C4
-		clra
+		delay				; delay a bit
+		ldu curtorch			; fetch current torch
+		stu backpack			; put it in the backpack
+		beq LD3C4			; brif no torch
+		clra				; make sure the torch is the only thing in the backpack
 		clrb
 		std ,u
-LD3C4		ldd #200
-		std V215
-		lda #3
+LD3C4		ldd #200			; set player carry weight to 200
+		std carryweight
+		lda #3				
 		dod S1A
 		jsr LCF97
 		std V213
-		fadeout
+		fadeout				; fade out the wizard
 		dod S19
 		rts
 LD3D7		pshs a,b,x,u
@@ -3057,18 +3067,18 @@
 		tfr x,y
 		ldx ,y
 		lda 2,y
-		bsr LD436
+		bsr applyscale
 		tfr d,x
 		lda 3,u
-		bsr LD436
+		bsr applyscale
 		addd 10,u
 		std 10,u
 		ldx ,y
 		lda 4,y
-		bsr LD436
+		bsr applyscale
 		tfr d,x
 		lda 5,u
-		bsr LD436
+		bsr applyscale
 		addd 10,u
 		std 10,u
 		ldx ,u
@@ -3076,7 +3086,7 @@
 		puls a,b,x,y,u,pc
 ; Multiply X by the value in A, where the binary point in A is to the left of bit 6. Return only the
 ; integer result in D (rounded down).
-LD436		pshs a,b,x			; save parameters and registers
+applyscale	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
@@ -3225,8 +3235,8 @@
 		ldb b,x
 		negb
 		sex
-LD56B		addd V215
-		std V215
+LD56B		addd carryweight
+		std carryweight
 		dod S0C
 		bra LD5B7
 LD573		jmp LCBE1
@@ -3284,7 +3294,7 @@
 		cmpa V28E
 		bne LD5EF
 		sta 9,u
-		dod S18
+		setobjectspecs
 		playsoundimm $0D
 		updatestatus
 		clr 7,u
@@ -3318,7 +3328,7 @@
 		cmpd powerlevel
 		bgt LD63E
 		lda 9,u
-LD638		dod S18
+LD638		setobjectspecs
 		clr 11,u
 		updatestatus
 LD63E		rts
@@ -3420,7 +3430,7 @@
 		bsr LD720
 		bne LD70E
 		jsr LD674
-LD70E		ldd V215
+LD70E		ldd carryweight
 		jsr LD37F
 		addd #3
 		addd damagelevel
@@ -3482,7 +3492,7 @@
 		bra LD790			; go set damage level and clean up flask
 LD787		ldx powerlevel			; fetch player power level
 		lda #$66			; roughly 0.8
-		jsr LD436			; go calculate 80% of player power level
+		jsr applyscale			; go calculate 80% 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"
@@ -3517,9 +3527,15 @@
 		std BLKTYP
 		inc V2B8			; flag ZSAVE
 		rts
-LD7D5		fcb $0d,$0f,$10,$ff
-LD7D9		fcb $11,$0f
-		fcb $ff
+; Objects in backpack for demo game
+startobjdemo	fcb 13				; iron sword
+		fcb 15				; pine torch
+		fcb 16				; leather shield
+		fcb $ff				; end of list
+; Objects in backpack for normal game
+startobj	fcb 17				; wooden sword
+		fcb 15				; pine torch
+		fcb $ff				; end of list
 LD7DC		fdb LD1EB
 		fdb LD1C2
 		fdb LD1D5
@@ -3544,11 +3560,11 @@
 		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 VB15			V20F
+		fdb objecttab			objectfree - next free object entry
 		fdb V2F1			V211
 		fcb $0c				V213
 		fcb $16				V214
-		fdb $23				V215
+		fdb $23				carryweight - the weight of objects the player is carrying
 		fdb $17a0			powerlevel - player power level
 		fcb $54	
 		fdb V380
@@ -3583,8 +3599,8 @@
 		fcb $02,$02,$02,$04
 		fcb $04,$08,$00,$01
 		fcb 4
-		fdb VB11
-		fcb $04,$00,$00,$05
+		fdb emptyhand+10
+		fcb $04,$00,$00,$05		; empty hand attack data
 		fcb 0
 
 ; these tables are used for clearing and otherwise setting up the graphics screens
@@ -3739,43 +3755,53 @@
 LD9FA		fcb $05,$01
 
 LD9FC		fcb $0A,$19,$19,$0A
-LDA00		fcb $01,$FF,$00,$05
-LDA04		fcb $01,$AA,$00,$05
-LDA08		fcb $04,$96,$40,$40
-LDA0C		fcb $03,$8C,$0D,$1A
-LDA10		fcb $02,$82,$00,$05
-LDA14		fcb $00,$46,$00,$05
-LDA18		fcb $01,$34,$00,$05
-LDA1C		fcb $02,$32,$00,$05
-LDA20		fcb $00,$30,$00,$05
-LDA24		fcb $00,$28,$00,$05
-LDA28		fcb $05,$46,$00,$05
-LDA2C		fcb $03,$19,$00,$1A
-LDA30		fcb $01,$0D,$00,$05
-LDA34		fcb $04,$0D,$00,$28
-LDA38		fcb $05,$19,$00,$05
-LDA3C		fcb $05,$05,$00,$05
-LDA40		fcb $03,$05,$00,$0A
-LDA44		fcb $04,$05,$00,$10
-LDA48		fcb $01,$00,$00,$00
-LDA4C		fcb $01,$00,$FF,$FF
-LDA50		fcb $01,$00,$FF,$FF
-LDA54		fcb $01,$00,$FF,$FF
-LDA58		fcb $01,$00,$00,$05
-LDA5C		fcb $00,$00,$00,$05
-LDA60		fcb $05,$05,$00,$05
-LDA64		fcb $00,$03,$12,$00
-LDA68		fcb $01,$03,$13,$00
-LDA6C		fcb $03,$40,$40,$00
-LDA70		fcb $06,$03,$14,$00
-LDA74		fcb $0A,$3C,$0D,$0B
-LDA78		fcb $0B,$60,$80,$00
-LDA7C		fcb $0C,$03,$15,$00
-LDA80		fcb $0E,$1E,$0A,$04
-LDA84		fcb $0F,$0F,$07,$00
-LDA88		fcb $10,$6C,$80,$00
-LDA8C		fcb $18,$00,$00,$00
-LDA90		fcb $FF
+; This is the object data table. Each entry is four bytes as follows:
+; 0	object type
+; 1	reveal strength required
+; 2	magical offense multiplier	
+; 3	physical offense multiplier
+objspecs	fcb $01,$FF,$00,$05		; supreme ring
+		fcb $01,$AA,$00,$05		; joule ring
+		fcb $04,$96,$40,$40		; elvish sword
+		fcb $03,$8C,$0D,$1A		; mithril shield
+		fcb $02,$82,$00,$05		; seer scroll
+		fcb $00,$46,$00,$05		; thews flask
+		fcb $01,$34,$00,$05		; rime ring
+		fcb $02,$32,$00,$05		; vision scroll
+		fcb $00,$30,$00,$05		; abye flask
+		fcb $00,$28,$00,$05		; hale flask
+		fcb $05,$46,$00,$05		; solar torch
+		fcb $03,$19,$00,$1A		; bronze shield
+		fcb $01,$0D,$00,$05		; vulcan ring
+		fcb $04,$0D,$00,$28		; iron sword
+		fcb $05,$19,$00,$05		; lunar torch
+		fcb $05,$05,$00,$05		; pine torch
+		fcb $03,$05,$00,$0A		; leather shield
+		fcb $04,$05,$00,$10		; wooden sword
+		fcb $01,$00,$00,$00		; final ring
+		fcb $01,$00,$FF,$FF		; energy ring
+		fcb $01,$00,$FF,$FF		; ice ring
+		fcb $01,$00,$FF,$FF		; fire ring
+		fcb $01,$00,$00,$05		; gold ring
+		fcb $00,$00,$00,$05		; empty flask
+		fcb $05,$05,$00,$05		; dead torch
+; This table has additional object data including ring charges, etc, organized as follows:
+; 0	object number
+; 1	burn time (torch), charges (ring), magical defense (shield)
+; 2	physical light (torch), physical defense (shield)
+; 3	magical ight (torch)
+objextraspecs	fcb $00,$03,$12,$00		; supreme ring
+		fcb $01,$03,$13,$00		; joule ring
+		fcb $03,$40,$40,$00		; mithril shield
+		fcb $06,$03,$14,$00		; rime ring
+		fcb $0A,$3C,$0D,$0B		; solar torch
+		fcb $0B,$60,$80,$00		; bronze shield
+		fcb $0C,$03,$15,$00		; vulcan ring
+		fcb $0E,$1E,$0A,$04		; lunar torch
+		fcb $0F,$0F,$07,$00		; pine torch
+		fcb $10,$6C,$80,$00		; leather shield
+		fcb $18,$00,$00,$00		; dead torch
+		fcb $FF				; end of table
 
 LDA91		fcb $41,$31,$31