MJoergen / C64MEGA65

Commodore 64 core for the MEGA65 based on the MiSTer FPGA C64 core
GNU General Public License v3.0
23 stars 4 forks source link

Support Kernals in EF3 #126

Open sy2002 opened 5 months ago

sy2002 commented 5 months ago

To support Kernals in the Easy Flash 3 (EF3), we need to be able to sense the cartridge's modifications of address line A14 as described here:

"Fortunately, a method was found which does not involve #DMA. Whenever a CPU read access to the address range $F000-$FFFF is detected, the cartridge pulls down the address line A14 for a fraction of the clock cycle. This changes any address between $F000-$FFFF to an address between $A000-$BFFF. After this is done, the state of #HIRAM can be read from #ROMH."

Taken from: http://skoe.de/kernal/kernal-cartridge.pdf

There are two ways of doing this that I currently see:

1) Enhancing our heuristics module (https://github.com/MJoergen/C64MEGA65/blob/develop/CORE/vhdl/cartridge_heuristics.vhd) and this code here: https://github.com/MJoergen/C64MEGA65/blob/develop/CORE/vhdl/main.vhd#L991 (This means: We monitor in realtime what the firmware code of the EF3 is doing and then act accordingly. We are already doing this today on R3/R3A boards, otherwise the EF3 would not work at all.)

2) Enhancing future MEGA65 PCBs to have circuit that allows us to continue to constantly write to the address bus while in parallel we can sense if the EF3 modifies A14. I guess this is something different than a standard Open Collector circuit.

Advantage of (1): No hardware change needed plus works on all MEGA65 revisions. But I consider this as pretty dangerous, see comments in main.vhd (see link above).

Advantage of (2): Clean solution

gardners commented 5 months ago

The third way: At the right time during each phi2 cycle when the KERNAL cartridge pulls A14 low to probe HIMEM, switch the A8-15 bank to input on the MEGA65 expansion port, and read A14: If it has gone low, then respond as a C64 would in this case, so that the KERNAL cart performs a KERNAL read, and then use that result.

sy2002 commented 5 months ago

@gardners Thank you for the third way. I totally missed that we can already today (starting from R3) switch the A8-15 bank to input!