Re: [stella] Why Timers refuse to work the way they should?

Subject: Re: [stella] Why Timers refuse to work the way they should?
From: Rodrigo Silva <stella@xxxxxxxxxxxxx>
Date: Tue, 23 Sep 2003 21:44:24 -0300
Hi there again!

The comment "has 5 cycles less" is not correct.
Immediately before the above code is a sta WSYNC.

The 6502 halts to the start of the next line.
Then 5 cycles are used (sta/ldx)

Then we enter the loop, which immediately does a WSYNC
The *next* scanline starts with dex/bne (5 cycles, if the branch is taken
and NOT over a page boundary)

SO each line in this kernel has a WSYNC followed by 5 cycles (management)
followed by 68 cycles available for "stuff" on each line.
Looks to me like this is an equal amount for each and every line - nothing
particularly special about the first.

Hummmm.... you're right! Didnt realize that the 5 management cycles applied to all lines *except* the 1st one... so its 5 cycles for every line, from first to last. thanks a lot! :)

Another commenting issue...

 ECHO [*-$F000+6]d,"out of 4096 ROM bytes used",[$FFF9-*]d,"bytes left"

I think that should be $FFFA-*
If the current org is at $FFF9 you have, in fact, one byte available, not 0.

My fault... $10000 - 6 = $FFFA. Thanks!

As to the "missing scanlines" I generally make it so its 'about right' with
the timers, then chuck in another few "sta WSYNC" as required to get it to
the exact number of scanlines required.

That would certainly work, but... its quite unconfortable for me to do something just "to make it fit". This is meant to be a template for future work, so, at least here, i want to know how every bit of code works. I wouldnt mind to add a few "sta WSYNC" in order to make a final version of a game work, but... in such an early stage this really bugs me. What can be wrong in such a simple piece of code? I know it may sound stupid, but Im really stalled in this template, cant move ahead while i dont debug this...

Would greatly appreciate *any* word of advice!


Archives (includes files) at
Unsub & more at

Current Thread