Page 2 of 2

Re: How does RND() and TIMER work?

Posted: Tue Sep 09, 2014 1:26 pm
by jedie
Good question... I will check this. Maybe my simple PIA implementation is wrong here... Thanks for the suggestions...

Re: How does RND() and TIMER work?

Posted: Sun Sep 14, 2014 10:24 pm
by jedie
I found the IRQ trace part of XRoar: https://gist.github.com/jedie/4400c4c086c3b2d84592 (on gist, because of linebreaks here)

So, the IRQ routine reads PIA from $ff03 and $ff02:

Code: Select all

9d3d| b6ff03      LDA     $ff03               cc=98 a=b5 b=01 dp=00 x=00b4 y=b39b u=82ec s=7f1e| E..IN...

9d43| b6ff02      LDA     $ff02               cc=94 a=00 b=01 dp=00 x=00b4 y=b39b u=82ec s=7f1e| E..I.Z..



... a while later ...




Think i found the bug in DragonPy and fix it with: https://github.com/jedie/DragonPy/commi ... 2650b854ce

Now i see the TIMER values increase...



I updated my test script:

Code: Select all

10 CLS
20 TIMER=0
30 FOR I=0 TO 100
40 PRINT @0,"COUNTER=";I;"- TIMER=";TIMER
50 NEXT
I run it with DragonPy and CoCo and Dragon ROMs... results are:

CoCo:

Code: Select all

COUNTER=100 - TIMER=244
Dragon64:

Code: Select all

COUNTER=100 - TIMER=245
Dragon32:

Code: Select all

COUNTER=100 - TIMER=246
But with XRoar these values are:
CoCo and Dragon32:

Code: Select all

COUNTER=100 - TIMER=154
Hm... Are my CPU cycles completely wrong or are my trigger with 17784 cycles wrong?

Re: How does RND() and TIMER work?

Posted: Mon Sep 15, 2014 9:15 pm
by sorchard
jedie wrote:Are my CPU cycles completely wrong or are my trigger with 17784 cycles wrong?
It's hard to say just by looking at the numbers. It's behaving as if (1) a large class of instructions are adding too many cycles to the counter or (2) the irq callback is occurring faster than once per 17784 cycles.

Does your instruction trace include irq events and the value of the cycle counter at each instruction? This might help you solve the mystery...

Re: How does RND() and TIMER work?

Posted: Wed Sep 17, 2014 4:15 pm
by jedie
I modify the test script a little bit and count to 500:

Code: Select all

10 COUNT=500
20 CLS
30 TIMER=0
40 FOR I=0 TO COUNT
50 PRINT @0,"COUNTER=";I;"- TIMER=";TIMER
60 NEXT
I run this on a real Dragon 64 and get:
COUNTER=500 - TIMER=761
I start it multiple times and get: 760, 761, 760, 761, 761, 761, 761, 761, 761, 760

In Xroar i get:
COUNTER=500 - TIMER=771
and also start multiple times: 771, 771, 771, 771, 767, 770, 770, 771, 770, 771

and with DragonPy:
COUNTER=500 - TIMER=1228
and: 1228, 1229, 1228, 1228, 1228, 1229, 1229

I wonder, that DragonPy also produce very equally result...

Now i will compare traces...