Bank Switching Cartridges

Cartridges for the C64 provide either 8K or 16K of ROM that will replace parts of the memory visible to the CPU when plugged into the expansion port. Either 8K or 16K, that is all the Commodore can see directly on a cartridge. Then there is an auto-start mechanism implemented in the Kernal that can be triggered to execute code contained in that ROM when the machine is powered on or reset. Jani features an excellent article about how to create such simple cartridges on his site which I have linked to before.

A simple ROM cartridge: the OpenC64Cart.

Now, a maximum of 16K is not very much. Any cartridge that provides more data needs to implement some form of bank switching, i.e. some mechanism to switch between different sections (banks) of ROM. The simplest way to do so would be by using hardware jumpers like the OpenC64Cart shown above. Often, the visible bank is selected by writing to the I/O area in memory. But there are other, more esoteric methods like the one used by the Super Zaxxon cartridges.

The “64k-Karte”

Lately, I’ve been studying a couple of generic bank switching cartridges for the Commodore 64/128. The first one I came across was a board created by Hucky called the “64k-Karte”. It caught my interest when Hucky presented Super Mario Bros. 64 starting from such a cartridge.

The 64kCart, my rendition of Hucky’s bank switching cartridge.

I found a mirror of Hucky’s original page describing the cartridge and I created my own version of the board using KiCAD. As the name implies, this cartridge supports up to 64K of ROM divided into banks of 8K each, numbered 7 down to 0. On reset, bank 7 is selected by default and EXROM is pulled low so that those 8K are visible at $8000.

64kCart schematics

There is a 74LS173 4-bit register on the board that latches D0-D3 when triggered by the IO1 line. The first 3 bits are used to switch between the banks in reversed order and the 4th bit allows the cartridge to be disabled, pulling EXROM high and thus enabling RAM access at $8000. In his post on the Lemon64 forum, e5frog gives a short code snippet showing how to use this: Writing values between #$00 and #$07 to $DE00 will switch between the ROM banks with #$00 selecting the highest bank and #$07 the lowest one. Writing the value #$08 to $DE00 will disable the cartridge until a reset is triggered.

So, the SMB64 cartridge presented by Hucky works by auto-starting a bootloader in the default bank. This loader first copies itself into RAM. Then it switches through the other banks, copying the code of the game to where it would otherwise be loaded to from disk. When this is done, the loader disables the cartridge and starts the actual game.

The Magic Desk Cart

Only after I had built the 64kCart, I learned about the “Magic Desk” cartridge created by Msolajic and Zzarko. And it was even later that I discovered that KiCAD files were available for this cartridge. Oh well. By then, I had alread created my own Magic Desk compatible layout.

The MagicDeskCart Rev.1 with wrong labels on the jumper.

Just like the 64kCart, the Magic Desk is using banks of 8K each mapped to $8000. But it uses a 74LS174 6-bit register, so with one bit again used to disable the module it can address up to 32 banks, i.e. a total of 256K of ROM. Also, the order of the banks is not inverted, so that bank 0 is located at the beginning of the EPROM. Another advantage of the Magic Desk is that its format is supported by the Vice emulator, which greatly helps when testing software.

Magic Desk Cart schematics.

Aside from those differences, working with the Magic Desk is quite similar. Writing values between #$00 and #$1f to $DE00 will switch between the ROM banks, with #$00 selecting the lowest bank and #$1f the highest one. Writing the value #$80 to $DE00 will disable the cartridge until a reset is triggered.

For both the 64kCart and the Magic Desk there are utility programs available that will create ROM images from a single or even multiple program files. But I haven’t looked into these, yet.

The Magic Desk Dual

Inspired by the “Double-Ender” cartridges that were made for the Atari 2600 back in the day and following the suggestion of a user on Forum64 I then went on to create another Magic Desk compatible cartridge.

First sketch of the MDD circuit.

With no additional logic except for a diode and a pull-up resistor it should be possible to create such a “Double-Ender” cartridge with both games contained in the same ROM chip. Depending on which way the cartridge is inserted into the expansion port, a different set of memory banks is selected. I dubbed the board the “Magic Desk Dual” and the project files are also available on Github.

The first Magic Desk Dual cartridge assembled and tested.

Wouldn’t it be great to have a cartridge running Super Mario Bros. one way, and The Great Giana Sisters the other way around? 😉

Of course, the MDD must be used with care because the entire bus is connected to both ends of the cartridge. Accidentally shortened pins or ESDs could potentially damage the computer.

The MDD in its case.

I also created a case for the MDD cartridge that is suitable for 3D printing. The STL files for the case will be available on Thingiverse, soon.

 
 

13 thoughts on “Bank Switching Cartridges

  1. Hello
    I was wondering if you have managed to get Giana sisters to work with the intro as it seems hard to find this ?

  2. Hi,
    thanks a lot for your post!

    I have done Mario Bros as Hucky edition that you have described…and it works..I’m very happy..I love this game 🙂

    Now I have done even your double ending Cartridge in order to put it on Mario + Giana.
    I have a simple question: I have to write Eprom with 64K Giana.bin (The Joker’s file on Forum64.de) and the other 64K with MarioBros.bin or I have to do a special .bin file.
    I have OTP Eprom…only one shot as you know…:-(

    Thankyou very much!

  3. Yikes, you should really get yourself some EEPROMs for this. 🙂 They are really cheap if you order them from China, probably much cheaper than PROMs. If you really want to take your first shot using a PROM then the risk is on you!
    That being said, the first thing you must be aware of is that my MagicDeskDual cart requires MagicDesk compatible .bin files and not Hucky compatible ones. Any MagicDesk compatible .bin file smaller than 128k will work. The additional circuit on the cart controls A17. A17 will be 0 one way and 1 if you flip the cart around. So, you have to burn the first .bin file into the ROM starting at location 0x00000 and the second .bin file starting at 0x20000.

  4. Hi and thank you very much for replying!
    You’re right too but the last time I had taken 5pcs from China but after a few cycles they no longer cancel under the lamp … absurd. Anyway with the Covid problem I should wait at least 30 days.

    Tell me if I understand correctly.
    This type of “Dual Magic Desk” card (also the Magic Desk) supports / reads “BIN” files up to 128K each

    The file uploaded to make Mario Bros is 64K. This file is not compatible with this cartridge?

    Giana Sisters bin file (from Forum64) is always 64K and I understand that is ready to copy on Eprom on this “Magic Desk” cartridge.

    So for this “Dual Magic Desk” version is not enough to load these two BIN files that I have already used?
    One from 0x00000 and the other from 0x20000.Is it correct?

    Thankyou again

  5. It is not a matter of file size. You mentioned that you made Mario cartridge using Hucky’s design and the bank switching of those carts differs from that of the Magic Desk carts. (This is actually explained in the blog post above…) The loader that is run on the C64 when the cartridge is inserted must reflect the different ways of bank switching of course. And this loader is included in the “BIN file”. So you cannot use the same file that you used for Hucky’s cart. You have to use one that includes the Magic Desk compatible loader.

  6. Ah…:-(
    So I could upload the Giana Sister bin file found on the forum which is already compatible with the “Magic Desk” while on the other side I should upload a compatible and revised Mario Bros file for the Magic Desk … and how do you do it? : – /
    Is there a program that does this conversion or can it be downloaded somewhere?

  7. The CRT file included in the “official” release actually includes the Magic Desk compatible version. It has later been converted to work on Hucky’s cart. Use cartconv to extract the binary.

  8. Hi again

    Now I understand that I need CRT file..I found it
    I will try it but (catconv.exe) but I’m not able to use Linux platform.Is there a Windows based version?

  9. Ok very good..
    I managed to start this “catconv.exe” from Dos and gave it the command cartconv -i SuperMarioBrosV1.2.crt -o SuperMarioBros.bin

    I therefore opened both files with Hex Editor and I noticed that the only difference between the two files is that the bin generated does not have 0x00000 up to 0x00040 where it reported “C64 cartridge @ .. vice cart”.

    So you tell me that this bin file obtained is a BIN file compatible only with the Magic Deskcart. I mean that it doesn’t work with a generic 64K Card?

    If I load it on the Eprom and insert it on the Magic Deskcart then does it work?

    Thanks again

  10. There is no such thing as a “generic 64K card”. And please, see herehere for a description of the CRT file format.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.