Possible to read directly from prg / cartridge disk slots?

26 views
Skip to first unread message

David Hogan

unread,
Oct 30, 2016, 6:59:45 AM10/30/16
to kerberos-midi
Hi,

Is it possible to map a page of flash storage for reading directly by c64 code, or alternative to preload flash to SRAM when starting a prg?

I'm playing around with sample playback code, and I was thinking it would be convenient to store the samples separately from the .prg so the samples don't need to be transferred over midi each time I change the code. Also opens up possibility of more samples than would fit in C64 RAM. Ideally I would select the flash bank much as a memory bank is selectable and then addressable.

I guess as a workaround I could enable disk mode and use it to copy cartridge disk data to SRAM at prg startup. I'm thinking this would be quite slow though.

My goals are to minimise time spent waiting for code updates to transfer over midi and also to keep startup time low - is it possible?

Cheers,
Dave

Frank Buss

unread,
Oct 30, 2016, 8:34:41 AM10/30/16
to kerberos-midi
Yes, you can map flash to RAM and access the SRAM. See the Developer's Guide ( http://www.frank-buss.de/kerberos/developers-guide.pdf ) how to access the SRAM, page 3 (regs are here: https://github.com/FrankBuss/kerberos/blob/master/c64/src/regs.inc ) and page 7. If you load a program over MIDI, it is saved in $10000-$1ffff in the SRAM, so the easiest way would be to load your program with the samples once, then you can load the program only and read the last loaded samples from SRAM.

For mapping the flash to RAM, you can enable the game cartridge mode, which allows to map any flash area to $8000-$9fff as ROM (maybe I should make this available for the menu as well, because then 4 k CRT files could be saved in the slots and then used). In fact that's the way the menu loads a program from a slot in flash, see https://github.com/FrankBuss/kerberos/blob/master/c64/src/main_menu.c#L155 . So you could store your samples as a program in a slot, or even 1 MB as an EasyFlash image, then access it from your program with this method.

If you start the Kerberos App with the command line argument "debugging", you can even load the entire flash with the "Dump flash" command from the "MIDI config and test" tab. Then replace maybe the second 1 MB with your samples and save it back with "Upload flash". But be careful with this function, you can erase the menu with it, which is at the beginning. But if you have a SD2IEC drive, you can always restore it by loading the menu from https://github.com/FrankBuss/kerberos/raw/master/c64/menu.prg on the C64 and then flashing https://github.com/FrankBuss/kerberos/raw/master/c64/menu.bin with the "Flash menu BIN" function on the "File transfer" page in the Kerberos App again.

David Hogan

unread,
Oct 30, 2016, 2:32:25 PM10/30/16
to kerberos-midi
Thank you so much Frank, that reply is a goldmine of useful information - I can clearly achieve what I want in a bunch of different ways. I had been considering creating an easyflash image for this but that would have meant transferring 1MB over MIDI each build, not fun. I love that loading a program over MIDI leaves a copy in SRAM, that's going to be extremely useful.

Cheers!
Dave
Reply all
Reply to author
Forward
0 new messages