Re: [hatari-devel] PSG_WaitState() inaccuracy

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On 9.7.2022 12.20, Christian Zietz wrote:
please excuse if this is a known inaccuracy / limitation in Hatari.

Consider the attached cartridge which times accesses to the PSG (writes
to address 0xffff8800). It prints the number of 200 Hz ticks for
30000x64 accesses. In Hatari [1] in ST mode with cycle exact 68000
emulation the code takes 624 ticks.

While this is only 0.5% difference, using latest Hatari Git version, with TOS 1.04 UK (50Hz) I get 621 (with US version, I get 623).

Which Hatari / TOS version did you use?


On a real ST, the code takes 477 ticks, ca. 75% of the Hatari value.

Note that this inaccuracy is not limited to cartridges. It occurs with
code running from TOS ROMs or Alt-RAM, as well -- anything that is *not*
running from ST RAM. A cartridge was just the easiest way to test on
Hatari and real HW.

This 25% difference results from the PSG_WaitState() implementation [2],
which assigns four waitstates to every new instruction accessing the
PSG. Whereas in reality, only one waitstate is incurred for a PSG
access. However, the next bus-cycle accessing *ST-RAM* gets waitstates
until everything is realigned on a multiple of four. But this also
means: If you do not access ST-RAM, you don't see four waitstates.
Hence, "move.b  d1,(a1)" takes 9 instead of 12 cycles.

Note this isn't a regression in Hatari 2.4. Also, fixing it might be
difficult because you need to track when the next ST-RAM access occurs.

On quick browse of the Hatari docs, only mention of this is for Hatari v1.9 / ROMSPEED (= copying ROM to Alt-RAM to speed it up) in compatibility doc:

"Different memory timings on different memory areas aren't emulated yet, so no speed changes are visible"

I guess at least it should be mentioned also in the manual HW support section.


	- Eero

Regards
Christian

[1] Please note when testing: Hatari can only emulate a user-defined
cartridge when GEMDOS-drive emulation (among other things) is disabled.
EmuTOS does not support the virtual "c:" (lower case "c") drive for
cartridges on the desktop; thus, please test with Atari TOS.

[2] https://git.tuxfamily.org/hatari/hatari.git/tree/src/psg.c#n458
--
Christian Zietz  -  CHZ-Soft  -  czietz@xxxxxxx
WWW: https://www.chzsoft.de/
PGP/GnuPG-Key-ID: 0x52CB97F66DA025CA / 0x6DA025CA



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/