changeset 36:25ba333c286e

Identify various bits related to creature spawning Identified the creature data table. Also decode various routines related to creature spawning.
author William Astle <lost@l-w.ca>
date Fri, 26 Dec 2014 22:28:19 -0700
parents 7072cfd10af3
children 026865a318f3
files dod.s
diffstat 1 files changed, 105 insertions(+), 111 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Fri Dec 26 22:01:53 2014 -0700
+++ b/dod.s	Fri Dec 26 22:28:19 2014 -0700
@@ -1444,36 +1444,36 @@
 		lda #11				; offset for wizard
 LC783		ldb a,u				; get number of creatures required
 		beq LC78D			; brif none
-LC787		jsr LCFA5
+LC787		jsr LCFA5			; create a creature
 		decb				; created enough creatures?
 		bne LC787			; brif not
 LC78D		deca				; move on to next creature
 		bpl LC783			; brif not finished all creatures
 		ldu #creaturetab-17		; point to creature table
-		clr V291
-LC795		jsr LCF63			
-		beq LC7B6
-		tst 5,x
-		bpl LC795
-LC79E		leau 17,u
-		cmpu #mazedata
-		blo LC7AA
-		ldu #creaturetab
-LC7AA		tst 12,u
-		beq LC79E
-		ldd 8,u
-		stx 8,u
-		std ,x
-		bra LC795
-LC7B6		lda currentlevel
-		anda #1
-		nega
-		sta levbgmask
-		sta V396
-		sta V386
-		coma
-		sta V38E
-		rts
+		clr V291			; 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?
+		bpl LC795			; brif so - fetch another
+LC79E		leau 17,u			; move to next creature entry
+		cmpu #mazedata			; are we at the end of the creature table?
+		blo LC7AA			; brif not - use this creature
+		ldu #creaturetab		; point to start of creature table
+LC7AA		tst 12,u			; is creature alive?
+		beq LC79E			; brif not
+		ldd 8,u				; get existing creature inventory
+		stx 8,u				; put this object at start of creature inventory
+		std ,x				; now put remaining inventory in the "next" pointer
+		bra LC795			; go place another object
+LC7B6		lda currentlevel		; get current level
+		anda #1				; set to "1" for odd, "0" for even
+		nega				; negate - set to 00 for even, ff for odd
+		sta levbgmask			; set level background mask
+		sta V396			; set background mask for command area
+		sta V386			; set background mask for text area
+		coma				; invert mask
+		sta V38E			; set background mask for status line
+		rts				; return to caller
 ; swi 27 routine
 ; play a sound specified by the immediate identifier
 LC7C8		ldx 12,s			; fetch return address
@@ -1489,18 +1489,18 @@
 		clr PIA1			; turn off sound output
 		rts				; return to caller
 ; the jump table for sound routines
-LC7DC		fdb LC82B			; sound 0
-		fdb LC850			; sound 1
-		fdb LC951			; sound 2
-		fdb LC83C			; sound 3
-		fdb LC8E2			; sound 4
-		fdb LC955			; sound 5
-		fdb LC84A			; sound 6
-		fdb LC8DE			; sound 7
-		fdb LC84D			; sound 8
-		fdb LC959			; sound 9
-		fdb LC877			; sound 10
-		fdb LC877			; sound 11
+LC7DC		fdb LC82B			; sound 0 - spider sound
+		fdb LC850			; sound 1 - viper sound
+		fdb LC951			; sound 2 - club giant sound
+		fdb LC83C			; sound 3 - blob sound
+		fdb LC8E2			; sound 4 - knight sound
+		fdb LC955			; sound 5 - axe giant sound
+		fdb LC84A			; sound 6 - scorpion sound
+		fdb LC8DE			; sound 7 - shield knight sound
+		fdb LC84D			; sound 8 - wraith sound
+		fdb LC959			; sound 9 - galdrog sound
+		fdb LC877			; sound 10 - wizard's image sound
+		fdb LC877			; sound 11 - wizard sound
 		fdb LC80A			; sound 12 - flask sound
 		fdb LC811			; sound 13 - ring sound
 		fdb LC827			; sound 14 - scroll sound
@@ -2564,40 +2564,41 @@
 		tst 12,x			; is the creature alive?
 		beq LCF85			; brif not - check another
 LCF96		rts				; return to caller, Z clear if we found a creature
-LCF97		pshs a,b,x
-LCF99		jsr LCC71
-		std ,s
-		lda ,x
-		inca
-		beq LCF99
-		puls a,b,x,pc
-LCFA5		pshs a,b,x,y,u
-LCFA7		ldu #creaturetab-17
-LCFAA		leau $11,u
-		tst 12,u
-		bne LCFAA
-		dec 12,u
-		sta 13,u
-		ldb #8
-		mul
-		addd #LDABB
-		tfr d,y
-		tfr u,x
-		lda #8
-		jsr LC04B
-LCFC4		bsr LCF97
-		bsr LCF82
-		bne LCFC4
-		std 15,u
-		tfr u,x
-		jsr LC25C
-		stx 5,u
-		ldd #LD041
-		std 3,u
-		lda 6,x
-		ldb #4
-		jsr LC21D
-		puls a,b,x,y,u,pc
+LCF97		pshs a,b,x			; save registers
+LCF99		jsr LCC71			; get a starting point for the creature
+		std ,s				; save resulting location
+		lda ,x				; fetch room data at location
+		inca				; is it a room?
+		beq LCF99			; brif not - try again
+		puls a,b,x,pc			; restore registers, return value, and return
+; Create a creature
+LCFA5		pshs a,b,x,y,u			; save registers
+LCFA7		ldu #creaturetab-17		; point to creature table
+LCFAA		leau $11,u			; move to next entry
+		tst 12,u			; is creature alive?
+		bne LCFAA			; brif not - look for another entry
+		dec 12,u			; mark creature alive
+		sta 13,u			; set creature type as requested
+		ldb #8				; 8 bytes per creature data
+		mul				; get offset into creature data table
+		addd #LDABB			; now we have a pointer to this creatures data
+		tfr d,y				; put creature data pointer in Y (source pointer)
+		tfr u,x				; put creature slot into X (destination pointer)
+		lda #8				; there are 8 bytes for each creature info
+		jsr LC04B			; copy data into this creature slot
+LCFC4		bsr LCF97			; get a location to start the creature in
+		bsr LCF82			; check if there's already a creature there
+		bne LCFC4			; brif so - try again
+		std 15,u			; put the creature there
+		tfr u,x				; save creature pointer
+		jsr LC25C			; get scheduling entry
+		stx 5,u				; save creature pointer in scheduling entry
+		ldd #LD041			; creature scheduling handler
+		std 3,u				; set handler for this entry
+		lda 6,x				; get scheduling ticks for creature
+		ldb #4				; put in 10Hz list
+		jsr LC21D			; go add to scheduling list
+		puls a,b,x,y,u,pc		; restore registers and return
 LCFE1		pshs a,b,x,u
 		ldu holetabptr
 		bsr LCFF2
@@ -3889,46 +3890,39 @@
 		fcb $03				; 1 leather shield each, level 1-3
 		fcb $04				; 1 wooden sword each, level 1-4
 ; pointers to creature images
-LDAA3		fdb LDE26
-		fdb LDFCA
-		fdb LDD41
-		fdb LDE59
-		fdb LDE82
-		fdb LDD51
-		fdb LDE3F
-		fdb LDE9D
-		fdb LDE07
-		fdb LDDA3
-		fdb img_wizardgen
-		fdb img_wizard
-
-LDABB		fcb $00
-
-LDABC		fcb $20,$00,$FF,$80
-LDAC0		fcb $FF,$17,$0B,$00
-LDAC4		fcb $38,$00,$FF,$50
-LDAC8		fcb $80,$0F,$07,$00
-LDACC		fcb $C8,$00,$FF,$34
-LDAD0		fcb $C0,$1D,$17,$01
-LDAD4		fcb $30,$00,$FF,$60
-LDAD8		fcb $A7,$1F,$1F,$01
-LDADC		fcb $F8,$00,$80,$60
-LDAE0		fcb $3C,$0D,$07,$02
-LDAE4		fcb $C0,$00,$80,$80
-LDAE8		fcb $30,$11,$0D,$01
-LDAEC		fcb $90,$FF,$80,$FF
-LDAF0		fcb $80,$05,$04,$03
-LDAF4		fcb $20,$00,$40,$FF
-LDAF8		fcb $08,$0D,$07,$03
-LDAFC		fcb $20,$C0,$10,$C0
-LDB00		fcb $08,$03,$03,$03
-LDB04		fcb $E8,$FF,$05,$FF
-LDB08		fcb $03,$04,$03,$03
-LDB0C		fcb $E8,$FF,$06,$FF
-LDB10		fcb $00,$0D,$07,$1F
-LDB14		fcb $40,$FF,$06,$FF
-LDB18		fcb $00,$0D,$07
-
+LDAA3		fdb LDE26			; spider
+		fdb LDFCA			; viper
+		fdb LDD41			; club giant
+		fdb LDE59			; blob
+		fdb LDE82			; knight
+		fdb LDD51			; axe giant
+		fdb LDE3F			; scorpion
+		fdb LDE9D			; shield knight
+		fdb LDE07			; wraith
+		fdb LDDA3			; galdrog
+		fdb img_wizardgen		; wizard's image
+		fdb img_wizard			; wizard
+; This is the creature data table. Each entry is 8 bytes organized as follows:
+; 0
+; 1
+; 2
+; 3
+; 4
+; 5
+; 6	creature scheduling speed (movement)
+; 7
+LDABB		fcb $00,$20,$00,$FF,$80,$FF,$17,$0B ; spider
+		fcb $00,$38,$00,$FF,$50,$80,$0F,$07 ; viper
+		fcb $00,$C8,$00,$FF,$34,$C0,$1D,$17 ; club giant
+		fcb $01,$30,$00,$FF,$60,$A7,$1F,$1F ; blob
+		fcb $01,$F8,$00,$80,$60,$3C,$0D,$07 ; knight
+		fcb $02,$C0,$00,$80,$80,$30,$11,$0D ; axe giant
+		fcb $01,$90,$FF,$80,$FF,$80,$05,$04 ; scorpion
+		fcb $03,$20,$00,$40,$FF,$08,$0D,$07 ; shield knight
+		fcb $03,$20,$C0,$10,$C0,$08,$03,$03 ; wraith
+		fcb $03,$E8,$FF,$05,$FF,$03,$04,$03 ; galdrog
+		fcb $03,$E8,$FF,$06,$FF,$00,$0D,$07 ; wizard's image
+		fcb $1F,$40,$FF,$06,$FF,$00,$0D,$07 ; wizard
 ; This is the text font - these values are in packed format
 LDB1B		fcb $30,$00,$00,$00,$00		; char code 0 - space
 		fcb $31,$15,$18,$fe,$31		; char code 1 - A