lgblgblgb / xemu

Emulations (running on Linux/Unix/Windows/macOS, utilizing SDL2) of some - mainly - 8 bit machines, including the Commodore LCD, Commodore 65, and the MEGA65 as well.
https://github.com/lgblgblgb/xemu/wiki
GNU General Public License v2.0
201 stars 31 forks source link

MEGA65: correct CIA TOD implementation and behaviour #343

Open dillof opened 2 years ago

dillof commented 2 years ago

Describe the bug Writing 0 CIA TODs registers $DC08-$DC0B doesn't reset the clock. It works on a real MEGA65 as well as C64 (both real and vice).

Used version of the project The Evolving MEGA65 emulator from LGB This software is part of the Xemu project: https://github.com/lgblgblgb/xemu CREATED: travis@lgb on Darwin 18.7.0 at Tue Apr 26 10:24:46 GMT 2022 CREATED: clang 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.8) 64LE for osx VERSION: https://github.com/lgblgblgb/xemu.git master 08ed0450f53a65a285dcac802373aea4f9c6450d 20220426121838 official-build EMULATE: MEGA65 (mega65): xmega65 (../../build/bin/xmega65.native) for mega65 on osx (native) using cc

To Reproduce The following program demonstrates the problem.

stopwatch-min.zip

It's written in cc65 assembler.

Expected behavior It should start at 00:00:00.0.

Computer/Device (please complete the following information):

lgblgblgb commented 2 years ago

Thanks for the report! Yes, that is intentional, Xemu emulates the real-time clock for TOD (also for the RTC) getting the time there from the host OS (= the OS which runs Xemu). Thus it's impossible to set to other values. Sure, this is not the correct behaviour, needless to say though ;)

Of course I had/have plan to correct that at one point. Also keep in mind that the CIA emulation in Xemu is absolutely crude minimal implementation without about anything working not needed for the emulated machine to be able to work at all (this is true for some other things as well, not just CIA, I'm afraid).

I'll keep this open - and thanks again - surely I have to implement correct TOD behaviour at some point, when I get there. By the way, CIA emulation is shared with the C65 emulator, so a fix would fix both, using the same source.

lgblgblgb commented 2 years ago

By the way, also "TOD alarm" does not work. I'll refactor this issue being "correct TOD behaviour of CIAs" in general, I think.