Introducing Nano Arcade — fusing Nano with Space Invaders

James Coxon
6 min readSep 10, 2020

--

At the Nano Meet-up 2019 a number of pieces of hardware were presented including a Space Invaders arcade machine (a modern clone to be exact from 1up) which required a small amount of Nano to play and the top score won the jackpot. It was a horrible hack merging the built-in embedded linux board with a supervising raspberry pi zero controlling the arcade over a unstable serial connection – most of the day was spent trying to debug it enough for it to actually run.

Since that demo I’ve worked with NanoIsSuperior to rebuild the whole device, make it robust, reliable but most of all even more awesome. We are proud to present the new and improved NanoArcade : Space Invaders

How do I play?

  1. Before you start playing make sure you download Natrium Wallet (as you’ll need it later!)
  2. Start playing a game of Space Invaders and try and get the highest score possible.
  3. At the end of your game you’ll be shown a QR code which contains a seed with some Nano already loaded, using the Paper Wallet function you can scan this code and collect the Nano. The arcade pays out depending on your score.

How does it work?

Its a little complicated…

The arcade’s internal system is based a small embedded linux system with a 3.4 kernel and has a limited busybox implementation. Space Invaders is a custom proprietary emulator that is triggered by a custom menu binary. These are all roped together with a few shell scripts started by a init.d startup script. There is a 2018 copy of mplayer which is able to play videos via the framebuffer as well as a copy of dropbear (a light weight ssh server/client clone). Through the excellent work of /u/BerryBerrySneaky it is possible to identify both the onboard serial port pads but also an unpopulated usb header.

To actually build a usable faucet you need a way to interface with the Nano network (through a Nano node), a way of generating a seed, loading a nano account with a particular amount of nano, creating a QR code and displaying it for the user to scan.

The original hack involved us piggybacking a raspberry pi zero and connecting to the serial port, using python we attempted to manipulate the game over the serial console. While it worked reasonably well for manipulating the game it was harder to have a reliable system of moving QR codes etc across the serial port in the short time frames to make the game/Nano interface flow.

Following the meet-up we started again, using the piggybacked raspberry pi we were able to debug using the serial console. After a few weeks of working our way through the embedded linux system searching for a way to connect it to a network (including a red herring of a set of kernel modules including a wifi driver which wasn’t actually the correct kernel version and so doesn’t work) we noted that the arcade’s kernel had the cdc_ether module built in. This would allow for a usb2 to ethernet adapter (Amazon) to be connected to the arcade’s usb port and therefore allow us to connect to a network and therefore the internet. We were able to locate a statically compiled version of full busybox which then gave us access to a udhcp client which got us connected to the internet.

Having the piggybacked raspberry pi was not an ideal way of managing the arcade’s linux system and now that we had an internet connection it would be a lot easier if we could directly login to the arcade. We were able to achieving this by having the arcade make a ssh connection to our server and then setting up a reverse ssh tunnel allow us to then open a console back into the arcade. The challenge was that the implementation of dropbear didn’t seem to work with public keys and you can’t just echo in the password so its not easy to setup a automatic connection. Instead we were able to statically compile sshpass which allowed us to script the password for the ssh connection. Now that we had a stable connection to the internet we were able to remove the piggybacked pi.

We now had an arcade machine running an old embedded linux system that can connect to the internet via a usb/ethernet adapter and then setup a reverse ssh tunnel allowing easy access for development and debugging.

The arcade’s Space Invaders emulator saves the score to a file we setup a bash script to monitor it for any changes, when it saves the score the script would kill the emulator and hexdumped the file to get the score. The script then uses scp to transfer the score in a text file to the server. The server has already generated a random seed, it calculates the first Nano account, loads it with the correct amount of Nano based on the highscore. When it generated the seed it had also created a QR code of the seed using the pyqrcode module, saved this as a png, then used ffmpeg to convert the png to a a single frame video. The arcade then uses scp to grab this video and download it onto the arcade. The QR code is then shown on the arcade using mplayer and this allows the user to scan the code and sweep the accounts to their natrium wallet and the system loops around again ready for the next game.

As there will be periods of time when the game is not being used we also built a screensaver of custom videos. This involved creating a playlist of videos that are played by the mplayer over the top of the menu binary (as we use the framebuffer we can override previous images). The menu binary exits when a button is pressed so we used another bash script to monitor for the menu process, when a button is pressed the menu process exits, the script then kills mplayer and the Space Invaders emulator is started.

We were also able to add a video that is displayed if there was no network, unfortunately despite our best efforts the network adapter would only work if we plugged the adapter in after the arcade had booted. The no network video allowed us to prompt staff to replug the network adapter.

Compared to the original hack the new setup with a proper network connection is significantly more reliable but also a lot slicker. We’ve also been able to add some extra touches such as the screensaver to make the Nano Arcade a much more polished system.

Whats Next?

The next step is to actually come and play the game! We’ve installed it at the awesome Pixel Bar in Leeds who have previously hosted our Nano controlled Xmas Tree. Come and play Space Invaders and earn a little Nano.

  • Check out a short video of the arcade in action: YouTube
  • Photos by Jeremy Kelly
  • Follow Pixel Bar on Twitter
  • We are always looking for new projects involving Nano – please get in contact if you have any ideas or projects you’d like us to get involved with.

--

--