[stella] Math riddle : Loading TIM64T with 43 burns only 36 scanlines (not 37)

Subject: [stella] Math riddle : Loading TIM64T with 43 burns only 36 scanlines (not 37)
From: Christian Bogey <khryssun@xxxxxxxx>
Date: Mon, 10 May 2004 15:09:52 +0200 (CEST)
I noticed the latest demos I wrote generated only 261
scanlines instead of 262...the only thing I changed
was the use of TIM64T (instead of looping 37 WSYNC)
for the Vertical Blank, so I made some tests and I
located the source of the problem :

Using the following code burns only 36 scanlines
instead of 37 (?!?) :

    LDA  #43
    STA  TIM64T

    BNE Wait_VBLANK_End

But I don't understand why !!! indeed :
- Storing 43 into TIM64T burns 43*64 = 2752 cycles
- so when INTIM reaches 0 : 2752/76 cycles = 36.21
scanlines were burnt.
- so wainting till the end of the current line with
STA WSYNC should give us 37 scanlines burnt.

Right ? Wrong !
It works in theory but doesn't seems to work in

I've included a demo to this post (with the source)
that just do the Vertical Sync and the Vertical Blank 
Period using TIM64T :
The program doesn't display anything. It should be run

with the DOS version of Z26. Launch it then press
alt-9 to display the number of scanlines generated =
39 instead of 40 (!?!)

I don't understand where I'am wrong !
Does anyone see where I'am making a mistake ?

This drives me crazy !

Take care,


Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com

Attachment: Bad_VBLANK.asm
Description: Bad_VBLANK.asm

Attachment: Bad_VBLANK.bin
Description: Bad_VBLANK.bin

Current Thread