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: F011 FDC internal block buffer behaviour difference between MEGA65 and Xemu #251

Open lgblgblgb opened 3 years ago

lgblgblgb commented 3 years ago

Shallan has created a nice loader for his works, which uses F011 registers directly to load needed files etc. That works on MEGA65.

With Xemu/MEGA65 it does not work.

However, interestingly, if the disk image is attached, AND the PRG file itself injected externally, it works. It seems, the initial loading (of the program itself) from disk breaks the loader then for whatever reason, which won't happen with external injection used. This suggests that there is some kind of "non-clean state" or something of the emulated F011 FDC controller, if used before (to load the PRG) which ruins the loader then.

I tested this with "LUMA" so the fix is intended to be "LUMAfix" (pun intended ...) ;)

Details

So, extract the main program file from luma.d81, let's call it luma.prg.

This works (loader is OK): -prg luma.prg -8 luma.d81

While just this (then loading the program inside the emulator) does not: -8 luma.d81

lgblgblgb commented 3 years ago

Breaking news

So, it turned out (by Shallan) that the problem is $D087 which is the data access register for the internal block buffer of F011. This register is emulated by Xemu of course, otherwise even ROM would not work. However, there is some difference between Xemu and MEGA65, since this is the problem here. The difference should be somewhat tricky, as it does not affect the behaviour of the ROM at least.

Though, Shallan stated he will use a workaround, clearly, this difference should be addressed and corrected in Xemu! Thus I modify the title of this issue to reflect the situation better.

This may also explains why LUMA worked with PRG inject: probably, the problem is the incorrect block buffer pointer handling, though, it's initially correct, but "messed up" by ROM on LOAD. It's a curious thing why ROM does not care about a problem like this, that's why I think, it's maybe a kind of tricky problem to attack.