The C64 community on Twitter pointed me in the direction of releasing Larry in a cartridge format. That’s something I never even considered because it used to mean creating physical hardware. Nowadays cartridges are just files so it could be useful, so next steps: figure out what they are and how they work.
I’m going to need up to almost a megabyte for graphics assets (uncompressed) so the standard simple 8KB or even 16KB cartridge image format won’t do it. I’m going to need a way to bank switch cartridges in order to expose at least 512KB of ROM to the machine.
The big advantage of this right now is that I get to do away with disk I/O and the associated slow KERNAL routines for it completely. This permits me to bank out the KERNAL ROM from the system as well, giving me more freedom to shift around the VIC memory as well. The VIC now sits in the top of the memory space so that I can have characters in RAM.The characters in RAM is a requirement because they take up a huge chunk of the 16KB VIC bank for no reason. Effectively I only need 52 letters, 10 numbers and a modest amount of punctuation. All the PETSCII symbols are a waste of space where sprite assets could live.
So that narrows the choice of VIC bank down to starting at either $4000 or $C000. It’s in the latter now, which was a good choice with KERNAL mapped in because the CPU could use KERNAL routines for free while the same address space is available for the VIC to use.
I’m going to leave this configuration in place for now, until there’s a compelling reason not to. Such a reason could be one of the cartridge modes, which apparently banks ROM into address $E000.
A tip from one of my Twitter followers points me towards the EasyFlash cartridge type so that’s what I’ll investigate now.
The REU plugs into the cartridge port of the computer but it also contains a complex DMA controller. It’s a fun device if you want to play video on your Commodore 64, but I’ve only ever seen two of them ‘in the wild’ so I’m not going to use it for my game. Larry should be playable on a stock 1982 Commodore 64. This is also why I haven’t yet completely abandoned the idea of a disk-based release yet. The thing should fit on four or five standard 1541 floppy-sides. I digress, though: cartridges for now!
EasyFlash, Magic Desk, Ocean cartridge?
The EasyFlash cartridge seems like it could fit what I’m trying to achieve. It features two flash chips of 512KB each, which can be banked into the C64 addressing space in pairs of 8KB at a time. This should be plenty of memory for my purposes. There being 64 banks of RAM could mean that I have one or even two banks available for the core game loader and the others could be (very wastefully) dedicated per scene. That should look fairly simple from a build perspective and doing a scene change should be practically instant: just flip the bank and jump to the scene’s initialization routine.
Big question: how does one build an EasyFlash cartridge image that’s usable for distribution? Found some code on Gitlab, but not sure how useful that will be. I need my build process to be automated. If this doesn’t work, maybe the Ocean Terminator II cartridge type could be an option. This holds 512KB of ROM in 64 8KB banks.
The VICE emulator also has resources on the CRT image format. This needs a lot of investigation but EasyFlash does seem the most valid for now. Apparently it’s not all that hard to generate an EasyFlash image from a bunch of PRG-files. The main steps are as follows:
- Generate PRG files for each pair of banks.
- Strip the load addresses from the PRG’s
- Generate a valid CRT header structure
- Generate CHIP fragments for the PRG’s bare payloads.
- Write header to CRT file
- Iterate over the CHIP fragments, write them at the bank offsets in the CRT file.
Seems simple enough, is probably harder than it looks. So now I’m sidetracked into a new Rust project that’ll allow me to do the above. I guess this beats trying to get all sorts of disk emulation to play nice across the board.
Ah well, just another tool I’ll get to open source at some point in the near future. Maybe it’ll get me a CSDb account so I can reach out to the SID composer Ghormak for permission to use his Leisure Suit Larry music track.