irmen / pyc64

Commodore-64 simulator in pure Python
MIT License
82 stars 12 forks source link

Adding Minimal Tape I/O in realc64 #6

Closed daitangio closed 4 years ago

daitangio commented 4 years ago

How can we add minimal Tape I/O in the RealC64 Emulation? As far as I can understand reading http://wav-prg.sourceforge.net/tape.html

The C64 senses when the waveform goes from a value greater than zero to a value lesser than zero. This event is called trigger and causes an interrupt request to be delivered to CIA#1. This IRQ can be handled by an interrupt handler, or simply discovered by testing bit 4 of location $DC0D.

It is unclear to me which other CIA1 registers are involved in TAPE I/O Referring to http://unusedino.de/ec64/technical/aay/c64/ I spot:

| $DC04/56324/CIA1+4 Timer A Low-Byte (Kernal-IRQ, Tape) | $DC05/56325/CIA1+5 Timer A High-Byte (Kernal-IRQ, Tape) | $DC06/56326/CIA1+6 Timer B Low-Byte (Tape, Serial Port) | $DC07/56327/CIA1+7 Timer B High-Byte (Tape, Serial Port) | $DC0D/56333/CIA1+13 Interrupt (IRQ) Control Register

Where can I find detailed information on how tape I/O works? Btw: on my core2duo at 0.4Mhz it is usable :) 👍

irmen commented 4 years ago

I don't really know how tape I/O works, it's analog signal processing with strict timings. I don't think it is anywhere remotely feasible to do this in pure Python.

Vice64 has support for loading .tap files which are tape "image" files. Again, I have no idea what their format is or how to even start reading them...

Why bother with tape when you can have disk? :wink:

daitangio commented 4 years ago

Sorry Irmen I was misunderstood. I'd like to add some way to load/save programs inside realc64. I think to "patch" the tape code would be easier of patching disk code... My idea is to intercpet call to tape code loading/saving a entire byte and deflect it to a python file. I don't know if disk I/O is an easier job (disk are a bit more like "SCSI" device on Commodore: there is no low level signal decoding). I am looking forward C/64 I/O kernel to think about it.

irmen commented 4 years ago

I did something like this in my real C64 emulator in https://github.com/irmen/ksim65 :

https://github.com/irmen/ksim65/blob/d1d433c3a640e1429f8fe2755afa96ca39c4dfbb/src/main/kotlin/razorvine/c64emu/c64Main.kt#L82

daitangio commented 4 years ago

Very cool! I am learning how Kernal works, and I'd like to implement something on Disk I/O if you think it is a nice idea for pyc64.... I can take your code and pythonize it :)

daitangio commented 4 years ago

I have been inspired by your code on kim65! :) Have a nice Sunday!

irmen commented 4 years ago

code has been merged, thanks!