Close
0%
0%

uChip Simple VGA Console

Cortex M0+, open source retro-gaming console, which connects to VGA and uses USB Gamepads/Keyboards.

Similar projects worth following
A 48 MHz Cortex M0+ and a 74AHC245 buffer implement a full retro-gaming console.

The CPU generates the VGA and audio signals by software. Three video modes are available: 2bpp bitmapped, 256-color tiled, and 16-color tiled modes.

Games are stored in the SD card. A lightweight USB stack and drivers allow to connect any keyboard or gamepad (HID class). The USB stack is modular so that this project can be hacked/reused for other purposes.

More than 64 sprites can be drawn on-screen, with full-screen arbitrary x-y scrolling and tile animation. The sprite engine supports x-y flipping and 90/180/270° rotation. Other features include vertical line remapping, per-line color/palette change, per tile and line arbitrary horizontal scroll, and custom background-sprite blend.


All this with only 256kB of flash, and 32 kB of RAM.

Introduction

Last year I presented a simple hand-held platform game, based on uChip, a 16-PDIP-sized development board, featuring an ATSAMD21E18 (Cortex M0+).  

Despite the good results (dual playfield, parallax scrolling, 16-bit colors, at 40 fps), I wanted an even more challenging project with uChip. About games, of course! 

What about a VGA-based console?

VGA signal generation represents quite a heavy constraint, as it must be performed in software on an ATSAMD21E18, and precise timings are required. In fact, the ATSAMD21E's DMA is not connected to the port pins, therefore software bit banging is required. Furthermore, even if the DMA were connected to the port, I would still have to generate the graphics on-the-fly, because there is no enough RAM for a framebuffer.

Software bit-banging means that the CPU is busy in generating the signals for the majority of its time, leaving only few milliseconds per frame, for actual game logic and console I/O handling.

Actually, to show uChip's potentialities, last year I implemented a very rudimentary VGA-based Tetris console, but later I realized that I still got a good deal of margin, for fancier graphics.

Fig. 1. The old version of uSVC (top) ... and the new one (bottom)!

Of course, due to memory, speed and I/O pin limitations we must forget about 16 bit graphics, so I will have to limit myself to only 256 on-screen colors. Still, check the differences between the old and the new version of tetris!

Fig. 2. On the left: the old tetris. On the right, the new one!

In a big surge of fantasy, I have named this simple uChip-based VGA console as "uChip Simple VGA console" or uSVC...

So, let's see some details of this 9-bit retro-gaming console!

A 9 bit console?

Gaming consoles were once classified by their number of bits. 8 vs 16 vs 32 (and later vs 64). The higher the number of bits, the more powerful they were (at least from the marketing viewpoint...).

As we will see later, this console, despite the 32-bit 48 MHz Cortex M0+ (much more powerful even than the Genesis 68k processor), cannot compete with any of the 16-bit consoles of the early '90s.  This is because consoles had custom hardware that allowed not only to generate the video/audio signals, but also handled 2D graphics, and mostly important, they had hardware sprites. Everything here must be done in software. 

Still, as we will see later that, in some cases, this console is more powerful than an 8-bit console of the '80s. In particular, we have a higher resolution, more on-screen colors and a bit of more memory and CPU "residual" speed (see later).

Therefore neither 8, nor 16 bits, just 9!

The specs

Here is an incomplete list of specs!

  • CPU: ATSAMD21E18 @48MHz
  • RAM: 32kB
  • Flash: 256kB (232 for games due to bootloader + game loader)
  • Games stored in SD and moved to Flash when you switch between games.
  • Modular USB Host to support standard USB peripherals.
  • Native support for standard USB Gamepads and keyboards.
  • Up to 256 on-screen color (256 color palette, RGB 332 color space)
  • Standard resolution of 320x200, at 57 Hz (30kHz horizontal frequency. These can be changed, but will leave less time for the CPU. All the VGA monitors and LCD TV sets I tested include 30kHz support). 400 vertical lines can be easily supported. Some effects already support 400 lines for better graphics.
  • 8-bpp or 4-bpp Tile-based modes. 4bpp tile mode include a inline color changing engine, which support arbitrary color changing for each vertical scanline.
  • 2-bpp bitmapped mode. The palette can be changed at every 8 horizontal pixels, allowing up to 256 simultaneous on-screen colors.
  • Tile-based modes support sprites.
  • More than 64 onscreen sprite (8x8 pixel size) in tile modes. Larger sprites are automatically handled, no need to create smaller sprites.
  • Sprite 90-180-270° rotation and X-Y mirroring.
  • Partially transparent sprites on 8-bpp, for explosions, lights, ghost, etc.
  • Tile and sprite priorities....
Read more »

View all 2 project logs

Enjoy this project?

Share

Discussions

Starhawk wrote 10/28/2020 at 16:36 point

Also: I wonder how much it would take to turn this into a more general-purpose computing box... more like what the Commodore Plus/4 was intended to be (and wasn't, because they dropped a barely-usable blooper instead of the decent office box they were aiming for), vs the C64...

I'd be interested in an exploration of that ;) something with a decent BASIC editor (say, comparable to what shipped with Windows 3.x), a lightweight word processor, and maybe a few other such utilities.

  Are you sure? yes | no

Nicola Wrachien wrote 10/30/2020 at 19:57 point

Hi Starhawk!
Thanks :)
The biggest issue I find is the very small amount of RAM: only 32 kB, of which most of it is used for graphics!
Yes, maybe one could add an external SPI RAM, but since you can access it only during the vertical blank (and only at 12 MHz), the effective bandwidth would be very small: only about 300kB/s ... Ok, maybe this would be enough for a Word Processor, where you have only to display a page at a time...

  Are you sure? yes | no

Starhawk wrote 10/31/2020 at 02:08 point

The Commodore 64 had twice that, and people did literally almost everything with those, at one point or another. It's pretty amazing. Folks are, even today, still finding new things to do with C64s... although the screen-resources bit works out a lot more like an Atari 2600, actually (look up the term "racing the beam" ;) ) and adding SPI RAM "externally" sounds a lot more like the Commodore Amiga's architecture...

...so basically you'd have the equivalent of an Atari 2600-ized Amiga... sort of.

That could be *very* interesting indeed!

  Are you sure? yes | no

Starhawk wrote 10/28/2020 at 16:33 point

Normally I get snippy about modern hardware "emulating" the old stuff, because it's extremely rare that anyone does it "properly", i.e., true to the spirit of that older gear, especially without invoking a number of anachronistic and thus absurd "conveniences" that the people who designed the original stuff never could have imagined (let alone implemented) in there era, simply because it's easier now to stick it on, rather than leaving it off...

"Composite video has horrible quality, so I'm gonna whack an HDMI port on BECAUSE I FREAKIN' CAN YA'LL...! Screw that old crappy TV fuzz!"

Ugh.

Similarly, those who gut a perfectly good vintage computer or console (or even one that just needs a little repair, without so much as a second thought to why it doesn't turn on instantly after 20+ years in a forgotten corner of Mom's attic)... I tend to think of those folks in the same light my grandfather, who worked on classic cars, both in their original era and up until shortly before his death in the mid-1990s, would've likely thought of those who buy an early-2000s Ford Thunderbird...

You can make it look as pretty as you want, tie a little bow on top, even... but it's still bulls*** underneath, and in the end, a turd is a turd.

My grandfather didn't pull his punches, either ;)

...BUT...

NONE OF THAT is applicable to this console. I am DEEPLY impressed, because *this* console, this design, this is absolutely true to the spirit of the original stuff. Sure it's quite a bit faster and more powerful "under the hood" -- but the way those extra horses are *used*, is the exact way it would've been done "back in the day".

You did this one right. Well done! ...and congrats on the blog article! ( https://hackaday.com/2020/10/28/a-vga-retro-console-with-everything-generated-from-a-single-arm-cortex-m0/ )

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates