changeset 11:258ca6c11b05

Identified SWI 16h and V2B4 Identified V2B4 as the flag to indicate to the IRQ handler that drawing is finished on the secondary screen and it is time to switch it visible. Also, identified SWI routine 16h as the one that shows the PREPARE! screen at the start of the game and between levels. Also added various comments.
author William Astle <lost@l-w.ca>
date Wed, 29 May 2013 22:42:25 -0600
parents c281f1f53962
children a1b93f4bd329
files dod.s
diffstat 1 files changed, 48 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Sun May 26 18:44:12 2013 -0600
+++ b/dod.s	Wed May 29 22:42:25 2013 -0600
@@ -97,11 +97,11 @@
 		dod S06
 		endm
 
-; clear graphics screen one; return parameter pointer in U
+; clear graphics screen currently visible; return parameter pointer in U
 cleargfx1	macro noexpand
 		dod S08
 		endm
-; clear graphics screen two; return parameter pointer in U
+; clear graphics screen currently used for drawing; return parameter pointer in U
 cleargfx2	macro noexpand
 		dod S09
 		endm
@@ -144,6 +144,10 @@
 fadeout		macro noexpand
 		dod S15
 		endm
+; display the PREPARE! screen
+showprepare	macro noexpand
+		dod S16
+		endm
 
 ; play a sound number from immediate data at full volume
 playsoundimm	macro noexpand
@@ -216,8 +220,8 @@
 V206		rmb 1
 V207		rmb 1
 V208		rmb 1
-V209		rmb 2				pointer to primary screen parameter block
-V20B		rmb 2				pointer to secondary screen parameter block
+V209		rmb 2				pointer to the parameter block of the currently shown screen
+V20B		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
 V211		rmb 2
@@ -315,7 +319,7 @@
 V2B0		rmb 1
 V2B1		rmb 1
 V2B2		rmb 2
-V2B4		rmb 1
+V2B4		rmb 1				nonzero means we're ready to swap graphics screens during IRQ
 V2B5		rmb 1
 V2B6		rmb 1
 V2B7		rmb 1				nonzero means nonstandard text location
@@ -460,7 +464,7 @@
 		fcb $39,$3c,$00,$68
 		fcb $da,$cc,$63,$09
 		fcb $48
-		clr <V2B7				reset text rendering to standard mode
+		clr V2B7				reset text rendering to standard mode
 		rts					
 LC0D1		dec V277
 		bsr LC114
@@ -482,8 +486,8 @@
 		delay					;
 		fadeout
 		cleargfx2				clear second graphics screen
-		dec V2B4
-		sync
+		dec V2B4				flag graphics swap ready
+		sync					wait for swap to happen
 		lda #2
 		ldu #LD7D5
 		bra LC131
@@ -500,7 +504,7 @@
 		clr V217
 		clra
 		ldu #LD7D9
-LC131		dod S16
+LC131		showprepare
 		dod S1A
 		ldy #V229
 LC139		lda ,u+
@@ -660,15 +664,15 @@
 		lbpl LC320
 		lda #2
 		tfr a,dp
-		tst V2B4
-		beq LC29D
-		ldd V209
-		ldu V20B
-		std V20B
-		stu V209
-		ldd 4,u
-		bsr LC266
-		clr V2B4
+		tst V2B4			do we have a screen swap to do?
+		beq LC29D			brif not
+		ldd V209			get currently visible screen pointer
+		ldu V20B			get newly drawn screen pointer
+		std V20B			save current screen as screen to draw
+		stu V209			save drawn screen as current
+		ldd 4,u				get the SAM value for the new screen
+		bsr LC266			go program the SAM
+		clr V2B4			flag no swap needed
 LC29D		tst V29C
 		beq LC2A9
 		com V29D
@@ -1114,14 +1118,14 @@
 		sta V270
 LC578		dec V26F
 		jsr [V2B2]
-		dec V2B4
-		sync
+		dec V2B4			set graphics swap required
+		sync				wait for swap to happen
 		dec V26E
 		lda V26E
 		cmpa #$f8
 		bgt LC578
 		cleargfx2
-		dec V2B4
+		dec V2B4			set graphics swap required
 		dec V228
 		clr keybufread			; reset keyboard buffer
 		clr keybufwrite			;
@@ -1129,8 +1133,8 @@
 LC595		cmpa #4
 		ble LC5AE
 LC599		jsr [V2B2]
-		dec V2B4
-		sync
+		dec V2B4			set graphics swap required
+		sync				wait for swap to happen
 		inc V26F
 		inc V26E
 		lda V26E
@@ -1158,7 +1162,7 @@
 LC5D7		bra LC5D7			wait forever (or until the IRQ does something)
 ; swi 13 routine
 LC5D9		ldu #V388
-		dec V2B7
+		dec V2B7			set to nonstandard text area
 		lda V22C
 		coma
 		sta 6,u
@@ -1180,7 +1184,7 @@
 		bpl LC5FD
 		std 4,u
 		renderstr
-		clr V2B7
+		clr V2B7			reset to standard text rendering
 		rts
 LC609		pshs a,b
 		std 4,u
@@ -1221,8 +1225,8 @@
 LC656		tst V228
 		bne LC65F
 		bsr LC660
-		dec V2B4
-		sync
+		dec V2B4			flag graphics swap required
+		sync				wait for swap to happen
 LC65F		rts
 LC660		pshs a,b,x,y,u
 		ldd V226
@@ -1310,19 +1314,19 @@
 		stb V29D
 		cleargfx2			clear second graphics screen
 		drawgraphic			go draw graphic
-		dec V2B4
-		sync				wait for an interrupt
+		dec V2B4			flag graphics swap required
+		sync				wait for swap to happen
 		puls x,u,pc			restore registers and return
-; swi 22 routine
-LC6E6		jsr LD489
-		ldd #$12c
-		std 4,u
-		renderstrimmp
+; swi 22 routine - display the PREPARE! screen
+LC6E6		jsr LD489			clear second graphics screen and set up for text mode
+		ldd #$12c			; set cursor position to the middle of the screen
+		std 4,u				;
+		renderstrimmp			display the PREPARE! message
 		fcb $3c,$24,$58,$06		packed string "PREPARE!"
 		fcb $45,$d8
-		clr V2B7
-		dec V2B4
-		rts
+		clr V2B7			reset to standard text rendering
+		dec V2B4			set graphic swap required
+		rts				return to caller
 ; swi 23 routine
 LC6FB		ldu V20F
 		stu 6,s
@@ -3093,7 +3097,7 @@
 LD472		lda #$ff
 		cmpb #1
 		bne LD46F
-LD478		dod S16
+LD478		showprepare
 		adda V281
 		dod S1A
 		dod S19
@@ -3106,7 +3110,7 @@
 		ldx ,u
 		ldu #V380
 		stx ,u
-		dec V2B7
+		dec V2B7			set to nonstandard text rendering
 		rts
 LD495		bsr LD489
 		clr V2B6
@@ -3152,7 +3156,7 @@
 		com 6,u
 LD4F7		bsr LD505
 		bra LD4ED
-LD4FB		clr V2B7
+LD4FB		clr V2B7			reset to standard text rendering
 		rts
 LD4FE		lda #$1f
 		renderchar
@@ -3327,8 +3331,8 @@
 		bsr LD66D
 		bsr LD684
 LD667		bsr LD684
-LD669		dec V2B4
-		sync
+LD669		dec V2B4			set graoguc swao required
+		sync				wait for swap to happen
 		rts
 LD66D		andb #3
 		stb V223
@@ -3410,8 +3414,8 @@
 		addd V221
 		std V221
 		dod S0C
-		dec V2B4
-		sync
+		dec V2B4			set graphics swap required
+		sync				wait for swap to happen
 		rts
 LD720		pshs a,b
 		clr ,-s