[stella] Cycle counting discrepancy?

Subject: [stella] Cycle counting discrepancy?
From: Mark De Smet <desmet@xxxxxxxxxxxx>
Date: Tue, 21 Sep 1999 19:03:48 -0500 (CDT)
I was going over the total frame cycle time in my game, and was trying to
make some computations.  I came up with some descrepancies that came down
from Bensema's 'How to draw a playfield'.

In it, he has a 'vertical blank' section:

VerticalBlank
	LDX  #0
	LDA  #2
	STA  WSYNC  
	STA  WSYNC
	STA  WSYNC
	STA  VSYNC ;Begin vertical sync.
	STA  WSYNC ; First line of VSYNC
	STA  WSYNC ; Second line of VSYNC.

	LDA  #44
	STA  TIM64T

	STA  WSYNC ; Third line of VSYNC.
	STA  VSYNC ; (0)

	RTS  

I am uncertain about why the first three STA WSYNC's are there.

The rest of the screen sections seem to work out with the correct number
of lines.  The drawscreen part does 192 lines, and the overscan does 30 as
expected.  As I understand it, the 'vertical sync' part should turn on
VSYNC at the beginning of a line, wait for three lines to complete and
turn it off.  The above routine does this, but there are three additional
WSYNC's.  In the overall view, those three WSYNC's are added to the
overscan(because they appear before the start of VSYNC), so that the
overscan is actually 33 lines long.

Should not the 30 counter in the overscan be changed to be 27 for correct
scan lines?(or the WSYNC's in verticalblank be removed)  Did I miss
something?




On a slightly different point, I realized that many people out there are
putting the entirety of thier code into the vertical blank time, not
realiseing that there is a whole ton more free time during the overscan.
Mostly because the 'how to draw a playfield' document makes that a loop of
WSYNC's.  So, I went about figuring out a good timer value to use to allow
more game code to be used there.  I would appreciate it if someone could
check that this is correct.

Old 'how to draw a playfield' code:

OverScan
	LDX #30
KillLines
	 STA WSYNC
	 DEX
	 BNE KillLines
	RTS

My new code:


OverScan
	STA WSYNC
	LDA #34
	STA TIM64T

;you have tons of time here to do stuff(mainly, about 2100 
;processor cycles), like call a subroutine to do more game
;computations.

endoverscan
	LDA INTIM
	BNE endoverscan
	LDA  #2
	STA WSYNC

	RTS


Is this an accurate replacement?  As in, does it take up the same number
of lines?

Mark


--
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread