Grevious: A Shoot-em Up for Ben Heck’s gameBadge3

Recently, I’ve been working on creating my own game for Ben Heckendorn’s upcoming release of his gameBadge version 3.

Midwest Gaming Classic

Last year, my teenage son Lincoln and I left the girls at home and went on a guys’ trip. We flew out to Milwaukee, Wisconsin in April 2022 to attend one of the premier classic gaming conventions in the US – Midwest Gaming Classic. It was indeed as much fun as you can imagine. And the icing on the cake was the rich father/son time that Lincoln and I were able to spend together. We spent hours jamming buttons on free-play arcade and pinball machines – saving the president in Bad Dudes, rescuing April O’Neill in TMNT, and preventing Mr. Burns from taking over the world in The Simpsons… a truly productive time with my teenage son.

Lincoln and I in awe of our accomplishment of rescuing POTUS

If you’ve never been to MGC, it’s a sight to behold. You don’t truly get an understanding of the magnitude of hundreds of arcade games, pinball machines, and vintage computer displays until you walk into that convention center yourself. This picture gives you an idea, but definitely doesn’t do the experience justice.

The convention center was packed with arcade and pinball machines at MGC 2022

In fact, Lincoln and I had such a great time, that we’re doing it again this year! That’s right, we’re heading back out to Milwaukee for MGC 2023 at the end of March. We can hardly wait to get back out there for 3 more days of extreme nerding out.

A very happy father and son retro gaming squad

Ben Heck’s gameBadge

At MGC 2022, Lincoln and I were able to spend some time with one of my favorite maker personalities, Ben Heckendorn, to build his electronic gaming badge, the gameBadge2.

It was a joy to spend some time with Ben Heck!

If you’re not privileged enough to be familiar with Ben’s gameBadge designs, they’re wearable video game systems that attach to a lanyard and hang around your neck as a conference badge. For MGC 2022, Ben programmed the gameBadge2 with a Moon Patrol clone that he created, which he called Moon Force. And he did a great job with it – Moon Force is fun to play, and quite addictive! To this day, nearly 9 months later, the gameBadge2 sits on my desk and I pick it up to play a quick round of Moon Force several times per week, trying to get past the next level and beat my high scores.

The gameBadge2 with Moon Force loaded up and ready to start

Now, if you’ve read my Raspberry Pi Pico article a few weeks ago, you would know that I’ve been playing with the Pico quite a lot lately. So, when I heard that Ben was working on version 3 of the gameBadge for MGC 2023 and that it was Pico-based, I had to reach out and see if there was any way I could help. So, for this coming MGC, I’m going to give Ben a hand as an assistant in his gameBadge workshops, to help folks through their builds of the gameBadge3.

In the meantime, I’ve been testing out the hardware design and Ben’s game library by building my own game for gameBadge3. We’ve squashed a few bugs in the process, and when MGC rolls around, the folks in the workshop will have a couple of different games to play on their gameBadge.

The Making of Grevious

Gradius on the NES

The game I’m working on is a clone of the space-scrolling shoot ’em up variety. If you’re familiar with the Gradius franchise on NES and SNES, then you’ll recognize the main influence for Grevious.

I originally started writing Grevious last year for a different device – the Arduboy. I fell in love with the Arduboy FX when it first arrived in my mailbox late in 2021, after pre-ordering and waiting for months on end. The Arduboy is a neat little platform, but squeezing a game with many levels and a variety of enemies into it is rather tough, mostly due to the memory limitations. I never finished Grevious for Arduboy – not because of the game mechanics, necessarily, but because I couldn’t get the levels I designed to fit into memory. I worked on optimizing it off and on for several weeks, and eventually lost interest.

Grevious on Arduboy ran great, but I was limited in my level design

So, when I thought about writing a gameBadge3 game, it was a no-brainer for me to take this opportunity to resurrect Grevious and finish it up. Since the Arduboy is Arduino-based, and Ben is using Arduino on the gameBadge3, I thought my existing Grevious code would port over easily. But as with porting over any code between platforms, it’s seldom as easy as you think it’s going to be. In the end, I ended up re-writing all the game mechanics for Grevious.

Graphics

One of the main adjustments I had to make for the gameBadge3 was to overhaul my background and sprite rendering engine to fit into the approach that Ben designed for the gameBadge. Throughout the development of gameBadge3, Ben wanted to give it an NES-style of graphics. So even though the 125MHz, dual-core MCU can deliver better graphics, the game library leverages a “nametable” and is limited to NES-style color palettes.

If you’re not familiar with how NES uses a nametable, then do yourself a favor – head over to the gameBadge3 wiki, and read the wiki page that I wrote on how the nametable and viewport works.

True to the NES approach, the gameBadge3 nametable is a fixed array of screen tiles that can hold up to 4 full screens of data in a 2 screen x 2 screen grid. The viewport is layered on top of the nametable, to provide a fixed window into the portion of the nametable that’s displayed on the LCD. To give the illusion of scrolling, you only need to incrementally move the viewport around the nametable.

The viewport is a window into the nametable, which determines what’s displayed on the screen

Since the nametable is a fixed size, however, you can only scroll one full screen, until you hit the edge of the nametable and wrap around to the start of the first screen. Therefore, if you want a continuous level (like I have in Grevious), you have to swap screen pages in and out of the nametable as the scrolling is occurring. And that’s exactly what I did for Grevious. I won’t go into the details on the code here, but if you’re interested in writing your own gameBadge3 game, the source code for Grevious is in the Sample Games folder in the gameBadge3 repository.

Designing the graphics for the Arduboy version of Grevious, was pretty simple, as I didn’t have many options. The Arduboy is a 2-color display (black or white) with a 128×64 pixel screen. The gameBadge3, however, provides a 64-color palette, and each tile or sprite can use 4 of those colors.

A side-by-side comparison of Grevious on Arduboy (left) vs Grevious on gameBadge3 (right)
The player’s ship in Grevious

Four colors for a sprite aren’t very much, but it’s more than I had with the Arduboy. Coupled with the fact that the gameBadge3 display is 120×120 pixels, meant that I needed to redraw the tiles and sprites for Grevious. Now, I’ll be the first to admit that I’m no graphic artist. Pixel art seems like it should be easier since you’re limited in the size and available colors. This isn’t necessarily true, though. Having a smaller canvas with limited colors really means that you need to take extra liberties to have your sprite look like the thing it’s meant to be. All that said, here are the sprites I can up with for the player’s ship.

At the time I’m writing this, I’m still working on enemy sprites and background tiles for the levels, so I won’t share those right now. But you can expect that it’s going to be very Gradius-like in it’s look and feel.

Audio

The audio on the gameBadge3 is one of the things I’m most excited about. There’s a low-power, IS31AP4991A amplifier on board, with an external speaker. This is a step-up from Ben’s last gameBadge, which used a piezo buzzer with an internal tone generator. Additionally, Ben has wired up 4 separate PWM outputs from the Pico and combined the signals through some passive summing circuitry before it enters the amp.

In other words, the gameBadge3 has 4-voice audio! Because of this, it should be possible to emulate a wave generator for each of the audio channels and have a somewhat authentic-sounding NES audio experience.

I have yet to work on the audio for Grevious, but you can expect some groovy space background music, with sounds of alien spacecraft destruction layered on top.

Conclusion

As MGC 2023 approaches, and as I continue working on Grevious, I’ll write an updated article to demonstrate more of the progress and give you a taste of what the game is like. For now, though, I hope this article whets your appetite for the gameBadge3.

If you’re heading out to MGC this year, post a reply and let me know! At the time I’m writing this, there are a few open slots in Ben’s gameBadge workshop, so definitely go register for one of those.

And if you’re unable to make it to Milwaukee for MGC, the gameBadge3 is something that you can build on your own as well. Although the development is still in progress, things should be getting wrapped up over the next few weeks. Grab the files from the GitHub repository go build your own game!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s