changeset 34:acf702e04bdf

More comments on random generator and scheduler table Annotate the default scheduled routines table. Also describe the actual process of the random number generator.
author William Astle <lost@l-w.ca>
date Fri, 26 Dec 2014 21:33:20 -0700
parents 28a84507a829
children 7072cfd10af3
files dod.s
diffstat 1 files changed, 31 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Fri Dec 26 21:20:45 2014 -0700
+++ b/dod.s	Fri Dec 26 21:33:20 2014 -0700
@@ -686,7 +686,7 @@
 		blo setSAM000			; brif not
 		puls a,b,x,pc			; restore registers and return
 ; IRQ service routine
-LC27D		ldx #PIA1			; point to PIA1
+irqsvc		ldx #PIA1			; point to PIA1
 		lda -29,x			; get interrupt status
 		lbpl LC320			; brif not VSYCN
 		lda #zero/256			; point to direct page MSB
@@ -794,7 +794,7 @@
 		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
+swisvc		andcc #$ef			; re-enable IRQ - SWI disables it
 		ldx 10,s			; get return address
 		lda ,x+				; get operation code
 		stx 10,s			; save new return address
@@ -811,7 +811,7 @@
 		jsr [,s++]			; call the routine
 		rti				; return to caller
 ; SWI2 handler
-LC371		clrb				;* restore direct page for ROM call
+swi2svc		clrb				;* restore direct page for ROM call
 		tfr b,dp			;*
 		ldu 10,s			; get return address
 		ldb ,u+				; get ROM routine offset
@@ -1062,24 +1062,24 @@
 LC4CC		ldb ,x+				; fetch input data - already aligned
 		rts				; return to caller
 ; swi 7 routine
-; Generate a random number based on seed in randomseed, return 8 bit value in A
-LC4CF		ldx #8
-LC4D2		clrb
-		ldy #8
-		lda randomseed+2
-		anda #$e1
-LC4DB		lsla
-		bcc LC4DF
-		incb
-LC4DF		leay -1,y
-		bne LC4DB
-		lsrb
-		rol randomseed
-		rol randomseed+1
-		rol randomseed+2
-		leax -1,x
-		bne LC4D2
-		lda randomseed
+; Generate a pseudo random number based on seed in randomseed, return 8 bit value in A
+LC4CF		ldx #8				; need to generate 8 bits
+LC4D2		clrb				; initialize 1s counter
+		ldy #8				; 8 bits in byte to count
+		lda randomseed+2		; get lsb of seed
+		anda #$e1			; drop bits 4-1 (keep 7,6,5,0)
+LC4DB		lsla				; shift modified seed lsb left
+		bcc LC4DF			; brif no carry
+		incb				; bump 1s count
+LC4DF		leay -1,y			; done 8 bits?
+		bne LC4DB			; brif not
+		lsrb				; take bit 0 of the count
+		rol randomseed			;* and shift it into the seed value
+		rol randomseed+1		;*
+		rol randomseed+2		;*
+		leax -1,x			; have we generated 8 bits?
+		bne LC4D2			; brif not
+		lda randomseed			; get msb of current seed value
 		sta 3,s				; save 8 bit random value for return
 		rts				; return to caller
 ; swi 8 routine - clear first graphics screen
@@ -3604,19 +3604,19 @@
 		fcb 15				; pine torch
 		fcb $ff				; end of list
 ; This is the list of routines that get scheduling entries by default.
-LD7DC		fdb LD1EB
-		fdb LD1C2
-		fdb LD1D5
-		fdb LD19B
-		fdb LD027
-		fdb 0
+LD7DC		fdb LD1EB			; keyboard input processing
+		fdb LD1C2			; dungeon display update
+		fdb LD1D5			; damage healing tick
+		fdb LD19B			; tick down torch life
+		fdb LD027			; add the "revenge" monsters for the current level
+		fdb 0				; end of routine list
 ; cold start variable initializers
 LD7E8		fcb 12
 		fdb $103
-		jmp LC371
-		jmp LC352
-		jmp LC27D
-		jmp LC27D
+		jmp swi2svc			; SWI2 handler
+		jmp swisvc			; SWI handler
+		jmp irqsvc			; FIRQ handler (why??)
+		jmp irqsvc			; IRQ handler
 		fcb $17
 		fdb V202
 		fcb $01				; V202