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

Subject: Re: [stella] Why Timers refuse to work the way they should?
From: "Andrew Davie" <atari2600@xxxxxxxxxxxxx>
Date: Mon, 22 Sep 2003 15:39:12 +1000
;----------------------------------------------------------------------
         ; Do 192 scanlines
         ; 1st line has 5 cycles less then the others ,
         ; so blew it off if kernel is too tight

                   sta VBLANK          ; Turns VBLANK off
                   ldx #192            ; scanline counter
                   ;dex                ; uncomment here and below if needed
                   ;sta WSYNC          ; (prematuraly ends 1st scanline, but
                                       ;  guarantees that all the other
lines
                                       ;  have exactly the same cycle
counting)

Kernel
                   ;--Go kernel, go!

                   ;----------------
                   sta WSYNC
                   dex                 ;
                   bne Kernel          ;



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.

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.

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.

Cheers
A



----- Original Message ----- 
From: "Rodrigo Silva" <stella@xxxxxxxxxxxxx>
To: <stella@xxxxxxxxxxx>
Sent: Sunday, September 21, 2003 8:00 AM
Subject: [stella] Why Timers refuse to work the way they should?


> Hi again!
>
> This time im stretchin my newbie brain muscles creating (or ate least
> trying to)
> a perfect blank template. Trying to be really careful in every detail, as
im
> plannng to use this template for all demos, tutorial and exercices from
now on
> (or at least until the source gets so big i need to break it in modules)
>
> So, after digging hints here and there (like the variables section, 100%
> extracted from
> Andres tutorial), I present you with my 1st attempt of the perfectly
clean,
> standard,
> modern template for simple 2600 programs. 73 bytes that do absolutely
> nothing :) Please feel absolutely free to make any corrections,
> suggestions, recomendations, whatever, about style, conventions,
> optimizations, anything you think is
> worth pointing out.
>
> And I already some questions (the main reason for posting a file that
> doesnt work :)
>
> - Altought things look nice, this code generates 260 scanlines. Why are
> there missing 2? Replacing the timers for scanline counting loops, i
> figured there is one scanline missing in vblank section and the other in
> overscan. The very places im using timers instead of a counter. What am i
> doing wrong?
>
> - Is there any way to accuratly find out how many time cycles are left in
> each section? (marked with XXXX till i find out). Every attempt i made
> using cycle-controled loops gave different or weird results. For
example...
> after finding the maxmum number of cycles for 262 scanlines, fine-tuned by
> SLEEP n, if i change it to SLEEP n+1, scanlines go up to 280!! Wow, 18
> scanlines for a single cycle!
>
> Im completely clueless... and i swear i tried hard before bugging you...
>
> Cya,
> Rodrigo


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


Current Thread