Learn how to build a portable game console from scratch and some of the software ecosystem around it to make it easier to develop for.

That’s quite a sensationalist title!
I didn’t honestly set out to build a console, but it was a fun journey and I thought it would be great to share. There’s a couple learnings I would like to pass on and a couple hopes and dreams I have for the future.

Living in South Africa, I sometimes feel a little out of touch with all the cool gadgets that you can obtain overseas relatively easily and seemingly cheaply. coughArduboy cough. Thankfully I’ve been exposed to a couple pieces of awesome hardware from some cool people, via chatting and conferences, where they sometimes give out awesome badges.

My journey started about 3 years ago when I was given an ESP8266 for almost nothing from a friend who ordered them from overseas. All you have to do is write a bit of C code, upload via USB and it can host a website!

I wrote a previous article about my earlier ESP8266 tinkerings here.

On the back of that I got the BSides Cape Town 2016 badge which had some epic hardware on it too and for the past 6 or so months I have consistently been coming back to this project.

What was I trying to do?
Initially my goal was to write a game for the BSides Cape Town 2016 Badge.

I have always wanted to write games and for various reasons, I’ve never finished a full game, so more than anything I wanted to write the full game start to finish and release it into the wild in some form or fashion.

The badge was perfect for it. The ESP8266 is a great processor, the LiPo on the badge was great (well over 2 hours battery life ), the screen has a 128×64 pixel size and it has 8 buttons! There was a single caveat and a phrase I still remember, “We’re all red on the inside” which was how you remembered that the red wire of the battery goes on the inside two pin connetor or … FIRE!

I got Arduino IDE up and running, installed the required plugins (Screen and some small other libraries) did a few minor updates to get the code working on the latest versions of the library, the SSD1306 screen library had some awesome speed tweaks, saying you could now get over 60fps on it, using the BRZO I2C code which had optimised most of the code to assembler.

Sounding great! I actually got the game up and running and wrote the first part of the story. Yes, I came up with a story…

The Story
The game was going to be about the journey to DefCon. You fly a plan to the States, then to Las Vegas (Stage 1 and 2).

You drive from the airport to the hotel (Stage 3 and 4).

And you then have to hunt your way through the hallways to the conference venue looking for the talk you’re meant to attend (Final Stage). Initially this was going to be a beat em up about fighting your way to the talk, but that seemed a bit violent in the end…

There were a couple special effects and some code I’m really proud of in there, so I’ll come around that that again, but here’s the win screen for now.

Videos will follow once I have a change to explain them all.

The whole concept sounds easy enough, and I can happily say I did complete the game to the level it deserved. :-P

If you want to give it a go, it’s on this repo here. And this leads into my favourite part of the project and the continued work I’ve put into it. You can play it in a web-browser here and the maze game here, plus the voxel demo I made here.

The pivot
So after getting to a point where I liked the game quite a bit. I broke my BSides badge, very sad panda face, I had some guys help me fix it and it worked for a while again… until I broke it again. This put me on a multi path journey. I didn’t want to be without hardware again, so I would build my own and additionally, having to deploy to the badge everytime to test my current work was becoming a bit tedious, so I decided that I would write a game engine that worked on my PC as well.

Build your own badge adventure
I was happy with components of the ESP8266 and the SSD1306 screen, but I was very keen to have some sort of novetly feel to it (and I didn’t have buttons) so I researched a ton and found a way to do touch input over pencil.

I honestly spent too much time on this, but the learnings I gained were useful. I did decide to go with touch buttons hooked up to the analog signal on the ESP using digital input pins as 3.3V output drivers. Here’s a link to the original instructable I found on the topic. Then I found a way to multipliex the analog input since the ESP8266 only has one, here.

And with that I had avoided needing to buy buttons or a multiplexor chip like was on the original badge.

For power, I went with 2x AA batteries which can power the ESP8266 directly without any additional hardware.

The screen and processor slotted on nicely and with the updated libraries I was getting great frame rates on simple code.

I wired it all up on a breadboard and I was A for away.

After this I moved onto the protoboard version with a Wemos D1 Mini which was nice and small, while still having full functionality of the bigger ESP8266’s.

Play it anywhere
I also decided that making this cross compile was now a goal too, so that I could write and test the code on my desktop computer and then do slightly less vigorous testing on the device and a little less often too, to tighten my own internal feedback loop.

Brett Victor gave an amazing talk on Inventing on Principle a few years back and I always keep it in mind.”

Link

Related Content