Plutiedev's blog


What to watch out for when making cartridges

Published on 2020-oct-15

With all these new Mega Drive releases lately we've had a lot of people complain about cartridges being of low quality and potentially putting consoles at risk. Shouting at a dying forum or something is not going to help any vendors realize what they're doing wrong, so I'm quickly putting together here what to look out for. This probably deserves a proper page with strict specs to follow some day.

5V vs 3.3V components

Yes, this thing again.

Mega Drive is a 5V machine and everything on the cartridge slot is 5V. Modern components are usually 3.3V instead (or even 1.8V). Now, using modern components is great, you can get cheap Flash memory that way! But you absolutely must not mix 5V and 3.3V signals as-is.

If you're using 3.3V (or 1.8V) components, you must use a voltage regulator and level shifters (the former generates 3.3V VCC out of 5V VCC, the latter converts signals between both voltages). Connecting 5V directly to 3.3V components risks damage long term, in particular to the latter.

Board beveling

The hot topic of the day!

Something that may be easy to overlook is that the bottom of the board should be beveled (i.e. thinned down). This is important to reduce risk of damaging the cartridge slot: if the board isn't beveled then there's little room for margin to maneauver and you risk pushing down the pins when inserting the cartridge, potentially damaging it permanently. With beveling the board is easier to insert and pins will be at most pushed a bit outward instead, which is much safer.

Here's how the bottom of the board should look like (based on that PDF called GEN-CART-BASIC-fabnotes.pdf that keeps circulating around), note that 0.063 inches is a common thickness for boards:

The thickness of the board at the top is 0.063 inches, while it becomes 0.017 inches at the bottom. The beveling is done at an angle of 30 degrees, giving the beveled surface a height of 0.040 inches.

Chamfered corners

Related to the above, the bottom corners of the board should also be chamfered in a similar way, making them more rounded instead of hard corners. This one isn't as critical at least (failing to do this simply makes it a bit harder to seat or unseat the board) but you should still try to do it.

Ground shield

This one is easy to miss if one isn't putting much thought into it, but ideally you should cover up any empty space in the board with a trace to GND. This acts as a RF shield and helps reduce risk of interference with other nearby electronics.

Bringing this up since I've seen a few boards without it.

One last note

Check the actual boards please. I'm seeing a lot of people going "they make shitty cartridges!" over stuff that was done wrong long ago but nobody bothering to confirm if their newest releases still do it, or what they are doing wrong (because without details we have to assume the absolute worst). It starts getting hard to trust those comments if we can't tell for sure if they're still true nowadays (they may be, but we can't tell).

This gets even more important as new issues are found. Board beveling is something that people only started paying attention like last year or so. I'm sure that we'll find yet more issues in the future that we're currently ignoring, and we're probably going to be slamming manufacturers for getting that wrong back when nobody was paying attention.

I suppose there's also some mea culpa for not having put together yet a page giving full specs for cartridges to follow. It's very easy to get everything wrong when there isn't any checklist to follow, after all!

Game Gear on Mega Drive idea

Published on 2020-jul-13

One of the Mega Drive features is being able to run Master System games with an adapter. The Game Gear is mostly a handled Master System, but it has enough differences that playing those games on a Mega Drive isn't feasible (colors are all wrong, and also the Start button doesn't work so most games can't go past the title screen).

Some time ago krikzz revealed the Mega Everdrive Pro's features and one of the things is does is running NES games. It works by having part of the NES running on its FPGA and letting the Mega Drive handle video output. Now, this is just a "bonus" feature and it doesn't work great (CHR-ROM bank switching is a big problem), but for many games it should be good enough.

On the other hand this also got me wondering if it'd be feasible to take the same approach with the Game Gear. Its VDP is significantly less flexible than the NES PPU, so maybe the results could be better?

So here's an idea of how I think it could work (feel free to copy them). Note that the goal here is to try making most games work, but it's not gonna be 100% perfect unless take over the video output with a passthrough cable like the 32X.

Core

Video

The graphics would work as follows:

On VRAM/CRAM accesses:

On the tilemap layer:

On sprites:

On the palette:

Input

68000 would be reading the controller every frame and passing its buttons to the Game Gear core. D-pad would be mapped as-is, B and C to buttons 1 and 2, and Start to… Start.

Probably nobody will bother with the Gear-to-Gear cable, but if you *really* insist, the port used by it is practically the same you can find on the Mega Drive itself (serial mode included!), so you could attempt to pass it onto the player 2 port… but you'd need a custom cable, another Game Gear or Mega Drive, and timing may make it unfeasible anyway.

Audio

Alternatively, you could implement a stereo PSG in the cartridge itself and push its output through the audio-in lines in the cartridge slot, which solves all the issues (but wouldn't be as fun :P).

Compatibility issues

Now obviously the above shows that compatibility isn't going to be perfect, and I'm not that well versed on the Game Gear catalog, but I can think of a few cases that are obviously problematic:

Super Game Boy approach

On the other hand we could take Nintendo's approach which was to put the entire hardware in the cartridge and treat the console as a glorified passthrough that just passes over controller inputs. Audio can go through the audio-in lines in the cartridge slot, so that isn't a problem.

Video is another issue. Display is 160×144, but Game Gear can output up to 31 colors (which won't fit in a single tile) so we need to send *two* screenfuls. That'd be 720 tiles to transfer. That'd require extending vblank to get all the bandwidth we can, which means the border will have to be a solid color. Assuming 320×224, that'd require 117 lines to transfer (ignoring overhead). With the extra vblank time we get from disabling display in the border we get… 112 lines (in NTSC). Oops.

Many Game Gear games push against the borders of the screen, so trying to remove lines is probably not an option, which means you'd need to get accustomed to tearing. You could try to optimize by avoiding sending tiles that haven't changed or don't need both palettes, though it only reduces the chance of it being an issue and would be harder to implement.

Oh, and don't forget about the palettes. Again, the above was all assuming the palette doesn't change mid-screen, which breaks some raster effects. Trying to transfer 31 colors per line is not easy. You could probably disable display mid-line (the borders to the sides really help here), but even then expect to still see a few CRAM dots on the sides of the screen.

YM2612 programming warning

Published on 2020-jan-03

I've already seen at least a couple of homebrew games trip over this so I think this deserves a warning.

Do not rely on undefined behavior when reading the YM2612 status. The behavior differs between hardware revisions, and your game will break on a lot of consoles if you don't follow this advice.

If you're using one of the popular sound drivers this shouldn't be an issue, but if you're making your own sound code, mind the following:

In particular, always make sure to read only from $4000 (or $A04000 if accessing from 68000), and to not expect a particular byte value to show up. If you're waiting for the YM2612 to stop being busy, only check bit 7 and ignore the rest, if you're waiting for the timers then only check the relevant bit.

Just because it works on your console doesn't mean it will work on all of them. If you can't afford to test multiple revisions then at the very least follow the above advice to get you out of trouble.

Explanation

The Mega Drive underwent several hardware revisions over time to reduce costs. In particular, there are two major variants of the YM2612 in use (the original discrete YM2612 and a later YM3438-based variant integrated into the main ASIC). On top of that the Teradrive uses a discrete YM3438.

These variants differ in how they handle reading the status port in undocumented ways. Some variants only return a valid status value on the first address ($4000), and on top of that the values of bits 6-2 may be either zeroes or a previously written value depending on which variant it is (which is why you should ignore their value).

Retroflag Controller-M review

Published on 2019-nov-15

Earlier this month I purchased a Retroflag Controller-M and I thought I may as well make write a review of it. Testing involved playing Xeno Crisis, a full playthrough of Arkagis Revolution and iwis slapping the buttons because she likes clicky sounds.

Here's the link for the official Amazon listing for the controller. As a disclaimer, I bought it from a local store in Argentina instead (to avoid having to deal with import headaches).

Retroflag's controller looks pretty similar to a Mega Drive 6-button controller, down to the size. There are some practical concessions however: there's a Select button on top of the Start button, and instead of a Mode button there are L and R buttons. The latter two are built to look like the original Mode button, which is nice.

(iwis claims that it's not L and R buttons but "weft mode" and "wight mode" buttons)

The D-pad seems to happily take all the abuse going on so far (turns out Arkagis Revolution is surprisingly hard on the D-pad), albeit of course the question is how many months it will last. At least pressing the directions feels nice. The L and R buttons may be a bit too easy to press, so be careful where you place your fingers, but everything else seems OK.

The Controller-M shows up as either a generic XBOX controller (if in XInput mode) or a generic retro controller (if in DirectInput mode), so get ready to rebind buttons (at least the button mappings seem decent). This may or may not be an issue depending what you're using, the controller lets you swap Z/C with L/R if really needed. The controller also works with a Switch, according to their site.

If you're OK with the original 6-button controller's size and are ready to rebind buttons, you should be fine.

Known issues

Input details

The controller maps its buttons like this:

Retroflag's site includes how the controller buttons map to a modern controller's buttons, but the box also mentions some features that I'm going to include here in case somebody loses the box and needs help:

Stop being obsessed with "authenticity"

Published on 2019-oct-03

Rant time.

Something that annoys me is how people seem obsessed with looking "authentic" and how they think you absolutely need to provide unique box designs for every region (and of course both "old" and "new" designs for each, since the designs changed halfway through the console's lifetime). Does anybody realize how much of an inventory hell is this?

Worse yet, there's the trademark infringement issue — they just look too close to the official Sega designs, and Sega definitely has trademark on those again nowadays (both because of Sonic Mania and because of the Minis, not to mention all the Mega Drive merchandise). No, using "16 BIT CARTRIDGE" doesn't change the fact the design is still too close, if anything it only makes it look like a cheap bootleg.

Also, it's not like we're selling these games at local stores that you walked in and looked at the shelf for a game to rent or buy, but rather at on-line stores that sell globally, if not outright a Kickstarter campaign. That also kills the "authenticity" aspect really hard. On top of that, our new games look nothing like the ones from back in the day, as our culture has changed a lot since then.

Can we just admit that this isn't the '90s and acknowledge we're doing a whole new thing?

So what then?

I'd honestly prefer if we just dropped the Sega-like designs and let the game artwork fill the whole box. When we aren't pretending to be a Sega knock-off the boxes will look a lot better and feel less "bootleg", and you avoid risking the anger of a lawyer who may be in bad mood that day. Also, it means you just need a single box design and won't need to worry if you sell too much or too little of a given edition.

Acknowledging that we're a global market (if niche) also means no region lockout. Thankfully I haven't really seen trouble over this yet, but it means you should always consider "universal" shells when possible (those that fit in both Western and Japanese consoles). This way nobody has to worry about whether a game will work in their console or not, and again the inventory benefit of not having to worry about multiple editions.

Also don't forget to check out commercial homebrew guidelines in this site! There's some useful advice there, coming mostly from previous experiences. Learn from our past mistakes and you'll make everybody's lives easier.