I have a stupid question about the chip select and reset lines on a game boy cartridge

Discussion of programming and development for the original Game Boy and Game Boy Color.
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by spaceharrier »

Thank you for tolerating my stupid questions, you’re all experts and I am a worm.

I’m working a physical multiplexer that allows me to switch between six different inserted cartridges to run on Game Boy hardware.

This is for a Halloween costume that involves a giant playable game boy. I built a scalar board that will translate the game boys video signals to VGA and it seems to look good enough, even with a irregular pixel scaling.

One of the features that I want to add to this costume is the ability to switch out giant styrofoam cartridges on the back, with an rfid puck triggering a multiplexer.

To reduce hardware costs and make the board design simpler, I would like to be able to get away with not having to use a bunch of bus switching ICs if possible.

I was trying to look at schematics of cartridges online to understand what’s going on. Obviously they vary based on whatever bank switching architecture is used or whether or not there’s static ram on the cartridge.

Do any of the control lines on the cartridge, cs or reset, for example, set all of the io into a high impedance state, thus allowing me to minimize the total amount of electronic doodads I would need to put in my circuit design?
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by Dwedit »

All I know is that the NES M82 retail display unit was designed to provide full voltage to all cartridges at once. I don't know if you would need to do the same for a Gameboy cartridge switcher or not.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by lidnariq »

spaceharrier wrote: Tue Feb 28, 2023 9:03 am Do any of the control lines on the cartridge, cs or reset, for example, set all of the io into a high impedance state, thus allowing me to minimize the total amount of electronic doodads I would need to put in my circuit design?
/RD probably should do that, but I'm only about 80% confident, not 99%.

/RESET only affects MBCs, not ROMs.
/CS only specifies where cart RAM is - the name "CS" is a misnomer. It's asserted on access to addresses $A000-$FDFF (DMG) or $A000-$BFFF (CGB)
nitro2k01
Posts: 252
Joined: Sat Aug 28, 2010 9:01 am

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by nitro2k01 »

Let me make that a 99%. There should be no cases where the cartridge drives the data bus while /RD is high. So if all other lines are connected in parallel and you gate the /RD signal, that should get you there. However, you also want to gate the /WR signal for completeness, otherwise cartridge would be free to overwrite each other's SRAM! However, you might potentially still have signal integrity issues if you have long wires/PCB traces between the individual cartridges. You might for example want to add a lower value pullup resistor to /reset to guard against interference. (Maybe connect 50k in parallel with the existing one.)

The simplest way to do this using standard components is probably with a 74HC138 3-to-8 line decoder. This gives you an inherent guarantee multiple cartridges won't be activated simultaneously, even in the case of software bugs.

Connect '138 /E1 to GB /RD
Connect '138 /E2 to gnd (default on) or to your microcontroller as an extra master enable.
Connect '138 E3 to Vcc (default on) or the reset signal.

Connect A0-A2 to game selection controls form the microcontroller.

Connect Y0-Y7 to the respective cartridge /RD pins.

Repeat the process for /WR.

The protocol for switching games from the microcontroller would then be
1) Pull reset low to put everything in a safe state and avoid race conditions in the transition period.
2) Change the game id.
3) Pull reset high to start execution of the new game.

Another idea, depending on how much work you want to put in, and how precious space is, is to get a multi cart compatible cartridge. For example, this could be done using one of those cheap "xxx-in-1" cartridge sold on Ali Express/eBay. These can typically be programmed using a cartridge flasher available form various manufacturers. The caveat is that you need to replicate the functionality of the menu program and make a ROM packer. Your "menu" would then communicate, for example through the link port, with the microcontroller.
1) Pulse reset quickly to go back to the "menu".
2) The menu queries the microcontroller over the link port (aka SPI).
3) The "menu" uses this game selection to start the game using the cartridge's multicart functionality.

The first solution is more straightforward and can use off the shelf game paks. It's however bigger and less physically robust -- knock one cartridge to the side so that two adjacent pads are shorted, and the whole things stops working until resolved.

The second solution is more compact and physically robust. However, it requires specialized programming and could turn into a time sink if you're not sure what you're doing.

Both solutions assume you have a microcontroller to read the RFID tag, which can be used to control/communicate with the Gameboy/multiplexer.
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by spaceharrier »

Would something along these lines work for my needs (not full schematic)
WIP_MUX.png
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by lidnariq »

Your cartridge pinout is wrong...

Pins 3-5,30 are respectively /WR /RD /MA000-FDFF(aka "/CS" meaning "accessing cart RAM or system RAM") and /RST

Also these signals are all active low, so you want 74'138s, not 74'238s.
nitro2k01
Posts: 252
Joined: Sat Aug 28, 2010 9:01 am

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by nitro2k01 »

A few issues.

Your cartridge signals are mislabeled.
3 = /WR
4 = /RD
5 = RAM /CS
30 = /RESET

There's really no reason for /RD and /WR to have pullups in this circuit. They're always driven to either 0 or 1 by the mux so the pullup essentially does nothing.

74HC238 is the wrong mux. It's active high and you need active low which is 74HC138. Then connect either E1 or E2 instead of E3 to /RD and /WR respectively.

I would not recommend controlling the /RESET signal in this way however. The MBC on the cartridge can issue a reset on startup, (or later in some cartridges) which would briefly short circuit the output on the mux. If you do want to take this risk, 74HC238 is the right mux, and I'd recommend putting something like a 220 ohm resistor in series with each signal for current limiting. 74HC238 would hold all cartridges into reset, except the one selected.

I'm also once again going to do my due diligence and remind you of the potential finicky nature of connecting cartridges like this in parallel. Knock one to the side by mistake and the whole crashes and refuses to start until you reseat the cartridge.
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by spaceharrier »

nitro2k01 wrote: Tue May 30, 2023 6:16 pm I'm also once again going to do my due diligence and remind you of the potential finicky nature of connecting cartridges like this in parallel. Knock one to the side by mistake and the whole crashes and refuses to start until you reseat the cartridge.
I am modeling and 3d printing custom shrouds to hold each cartridge. The Chinese made edge connectors found online are flimsy.
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by Dwedit »

I think a mapper that acts as a Multicart, and Rom hacking would be simpler than trying to hardware hack multiple actual cartridges.

Or even an emulator.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by spaceharrier »

Dwedit wrote: Thu Jun 01, 2023 9:45 pm I think a mapper that acts as a Multicart, and Rom hacking would be simpler than trying to hardware hack multiple actual cartridges.

Or even an emulator.
I made a version of the costume with an emulator. However next year my wife and I are planning on taking a trip to Japan and we have two versions of this costume going to a convention in tokyo. I did not want to deal with any copyright issues so I'm building a multiplexer to run actual cartridges.

We're actually making two of these. And either a giant Link cable with a 485 transceiver or some wireless mechanism is going to allow both of them to run multiplayer games.
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by spaceharrier »

This is the Video driver, joypad, and game select side.

The RP2040 has enough horsepower to drive a 640x480 VGA image, is cheaper than an FPGA, and I did not see any tearing when testing.
I'm just using standard hobbyist-fare parts for the RFID puck reader.

The 5V mux select lines go to the other drawing for the cart select.

I've probably broken about a billion design rules in my schematic(not a professional board designer)
DRIVERSIDE.png
Another stupid question: Can I just drive the gameboy's power through the 5V line on the FFC connector?
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by lidnariq »

The DMG power supply expects to make multiple different voltages from the batteries, but it makes them all from the battery supply, not by using 5V as an input

I don't think anything will be harmed if it gets 5V but not Vbat nor -19V, but don't hold me to that.
spaceharrier
Posts: 40
Joined: Wed Jan 19, 2022 9:52 am

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by spaceharrier »

If I am using the micro to hold for a brief period to stabilize the gameboy's power, are there any commercial games that would be affected by severing the reset line to the cartridges completely (I don't recall any retail games ever resetting to the boot rom)?
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by lidnariq »

I think some of the MBCs deliberately pull /RST low at initial power-up.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: I have a stupid question about the chip select and reset lines on a game boy cartridge

Post by tepples »

And during the development of Border Crossing, I've speculated in the gbdev server that MBCs briefly assert reset during power-up to protect the contents of a battery-backed SRAM that might be connected to the MBC.
Post Reply