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.

Update 2022/04: In the meantime, Hucky has created a new site with lots of information on this cart (in German): Hucky’s Bastelbude

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 are available on Thingiverse.

 


Update

For those of you who are interested in building one of the cartridges, PCBs can easily be obtained now:

 

27 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 here for a description of the CRT file format.

  11. I tried but without success…I have to check it again.
    But maybe there is a difference between this PAL version and NTSC..I don’t understand if all cartridges are working on both system..I’m so confused

  12. Hi, I wrote to you also on GIT HUB….Your The Magic Desk Cart seems not working on C64C…I tested it on C64 breadbin and it works fine, with the same ROM on C64C does not… I have another MAGIC DESK cart compatible and it works fine on all C64 models and the same rom…

  13. Thanks for your feedback, but I cannot confirm this. I own two “C64C” and the cartridges I’ve built (as well as variants thereof) work just fine on those machines. Also, the design has been out there for a while. I have no numbers, but I expect quite a few people will have tried it by now, on different kinds of C64. No one has reported that kind of issue before.

    Maybe one of the logic ICs your are using is a bit fishy? Have you tried replacing them with ones from a different source?

  14. Thanks for your reply….So, is a bit strange problem…..On C64 Assy 250469 Rev. B GREEN board, works…The same card does not on Assy 250469 Rev. B “yellow” board… In another GREEN board, same ASSY, does not works. I use 74LS174P+74LS02N in your board and 74LS273N+74LS02N in other MagicDesk board model clone (this one works fine in any Commodore model and ASSY I have tried). Thank you…

  15. The letters “P” and “N” at the end are just the way of the respective producer to denote the packaging (DIP), as far as I know. I think it is more likely that your 74LS174P is actually “half-broken” or at least not working as cleanly as it should.

  16. Thank you for raply..Yes, problem persist….Changed 74LS174N, problem persist on some C64C….On C64 breadbin all LS are working fine…

  17. Now I bought some 74HCT174E (I was not able to find N, I hope it will resolve)…

  18. Hello.
    I wanted to talk to you about your 64kCart.
    We wanted to create a game and we thought about your cartridge as a support for it.
    We don’t want to make a profit and would only charge the price of the components and the cost of production.
    We would like to know if you have any objection to us using your cartridge as a support for it.

    Best Regards

  19. That sounds great to me and I would be happy if you based your project on my cartridge, as long as you are not planning to use the design commercially. But as I noted in my blog post, I did not design the actual circuit for the cart. Credit for that belongs to Hucky, whom I met on http://www.forum64.de. So, if you plan on using the 64kCart design I think it would be befitting to ask for his permission, too. He goes by the nick Hucky on Forum64 where you could contact him using a private conversation.

    I would be thrilled to learn more about the game you are planning and how it progresses. Let me know if you need further help, e.g. when trying to get in contact with Hucky.

  20. Hey there,
    Can you please repost your MagicDesk cartridge to Thingiverse.
    The download link is dead.

    Thank you

  21. The Download of the individual STL files was still working, actually. I just re-uploaded one of the files and now the link to download all files seems to be working again. Thingiverse acts infuriatingly faulty at times…

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.