Building A Modern Retro Console

There are a few dozen classic re-imaginings of classic game consoles, using hardware ranging from the ATMegas of the Uzebox to everyone’s favorite, stuffing some ROMs on a Raspi and calling it a day. You don’t necessarily learn anything doing that, which puts [Mike]’s custom game console head and shoulders above the rest.

The build started off as a plan for a Z80 computer with a dual ATMega GPU. He progressed far enough in the design where it would have been a masterpiece, but the inability to mill double-sided boards at home killed the design. Plans then moved on to an FPGA, then to an ATMega with the Analog Device AD725 PAL/NTSC encoder chip. That idea had a similar architecture to the Uzebox, but [Mike] wanted more power. He eventually settled on a PIC32 with the AD725.

This setup was capable of pumping out some impressive graphics, but for moving bits to a screen, you need DMA. [Mike] ran into a problem where the DMA timer runs at a maximum rate of 3.7 MHz. It’s a problem documented in a few projects, leading [Mike] to change his plan once again, this time to the STM32F4.

The bugs are worked out, and now [Mike] can stream a whole lot of pixels to a screen while still having some processing power left over to play a game. It’s a project that’s more than a year and a half old at this point, and so far he’s learned a lot.

9 thoughts on “Building A Modern Retro Console

  1. Some assorted comments:

    “Next, I’m using a computed GOTO. This allows my to wake up and jump to the correct state handler in the same number of cycles everytime. A SELECT of IF-ELSE block doesn’t have this property as the compiler tests each case.”

    If the number of SELECT cases is both large and contiguous enough, the compiler uses a jump table instead. This can sometimes be more efficient than you doing a manually computed jump, because with a computed jump the compiler cannot predict the outcome, and therefore no optimizations are possible. I sometimes pad selects with cases that will never be used, just to force it to use a jump table when appropriate; verifying the compiler does so by disassembling the compiled code.

    “This all worked after about a billion iterations of tweaking the timing and produced the desired display on my TV.”

    Attaching the MCU to a host PC via serial, and setting it up so that sending certain characters tweaked the timing on the fly, was a HUGE time saver for me. The final timings that worked best for NTSC video generation were slightly off from the official specs. Never could figure out why.

    “What I discovered was that when the DMA engine is driven by a timer the maximum rate it can manage is 3.7MHz.”

    I’m not fond of the PIC32 DMA either, too complex and too many wait states. The older dsPIC is more straightforward, with a dual-port RAM area just for DMA. Haven’t tried ARM. But apparently it’s working, and that’s what counts.

    Looks like [Mike]’s project is farther along than the blog posts, so looking forward to more updates soon.

    1. Thanks Chris. There is plenty more to come. I’m in the process of remaking an old DOS classic. It is going to take a while but I’ll post updates as I go. I don’t want to give it away yet. The next couple of posts will be about how I got the 3D rendered spinning cube going.

  2. For what its worth I have bumped up against DMA timer issues on the PIC32MZ and found a neat workaround on the MZ series (no idea if it works on the MX):

    If you just let the DMA rip at high priority it will transfer one word (the smaller word between source and destination) every five system bus clocks. Clocking the system at the maximum of 200MHz that gives a 40MHz DMA transfer clock. I’m using this to pump out an 800×600@60HZ VGA screen (or 640×360 dot doubled and double scanned to be a quarter 720p mode that I can fit in the 512k of on-die ram at 15bpp).

  3. I am also working on a retro computer design. I did even consider the STM32 as there is a Z80 emulator for it around on the net but I wanted my project to be a bit more authentic and use an actual Z80. This creates lots of problems finding modern(ish) chips that will work with a 5 Volt CPU.

    I didn’t consider either PAL or NTSC as I wanted higher resolution graphics than the original retro computers. The problem with TV outputs is that the specification for the video IF bandpass filter is only about 5 MHz. Of course you can get much higher clarity using a composite input but you are then working outside of the specification. With a well designed low-noise output stage you can achieve a *reasonable* but not *high* quality picture on *most* TV’s. Anything less then a well designed output stage will get poor results and even with a well designed circuit your mileage will vary from TV to TV.

    Alternatively, using one of the many VGA standards you can get a much better picture quality *and* be within specification, meaning that you can expect the same picture quality on all compatible monitors. I decided to give up on the little yellow RCA plug before even starting my project. The retro computers got just about everything you can get out of PAL / NTSC with their low resolutions.

    In any case you can get a VGA output from a relatively small CPLD or even smaller FPGA with noting more than R/2R resistors.

    In any case this is a great project and i will be giving it a skull.

    1. Something to watch for on the Z80 is it originally had some bugs which some programmers used as undocumented “features”. Some of those programs were used for rather important business things, so when Zilog released a debugged version of the CPU, the hue and cry was great enough that Zilog redesigned the CPU again and put the bugs back in.

    2. Thanks a lot. I started off with VGA in the first place but I really wanted retro graphics and a 16:9 aspect. I just can’t work out a way to do 16:9 over VGA on a modern LCD/Plasma TV. Modern video cards adjust their pixel clock to match what the TV asks for. That is out of my reach on a micro-controller.

      The picture in the Hackaday post was via composite to a 42inch plasma TV. I used my camera phone to take the shot. I’m actually really happy with the look. I also have an SVideo output ready to go.


      1. I have been developing VHDL on my coding computer desk that has a 19″ monitor for the PC, 15″ monitor for the VGA / VHDL testing and a 42″ widescreen plasma on the wall behind and above them.

        The 42″ plasma has a 15 pin input so I can connect my VHDL / VGA hardware directly to it and code for a 16:9 aspect ratio.

        What model is your plazma and does it have a 15 pin VGA input? Perhaps I could write some VHDL for it.

    1. Yes the bit box is similar and in fact I linked to it in part 1. Have a read about how I got to the STM32. It has been a long road. In any case. I’m doing this because I want to and that’s good enough for me. That said if I can draw some new audience to the Bitbox through my posts then that a win too. Bitbox has been a great inspiration for me and it’s where I got the idea about using a gated timer. That is wonderful project.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

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