Wishful Coding

Didn't you ever wish your
computer understood you?

Introduction To Game Boy Hacking at SHA2017

At SHA2017 I gave a workshop about Game Boy assembly programming. Despite the projector not working, it was fun to do, and I got some nice feedback. We looked at some code from Pokemon Red, made some small changes, and more. Unfortunately there was not enough time to dive into Super Mario Land and write code from scratch.

For those that want to continue, or were not there, the PDF can be downloaded here.

As a bonus, someone asked how you could disassemble Super Mario Land and extract images from it. In theory this should be easy by using pokemontools, but I could not get it to work right away.

What I did do is search the code for the location of the sprites. The VRAM tile data is located at 0x8000, so searching for that adress in the debugger gives a few places that copy data from ROM to VRAM. Using pokemontools, I was able to at least decode a block of tiles at 0x4032, shown below. Other blocks should be possible to find as well, but that’s for another time.

Super Mario Land tiles

USBTinyISP debug oscilloscope

When I’m using a normal Arduino board I usually just do printf debugging. But when I design a PCB with an AVR chip on it, I don’t always want to use serial.

Now if you have an expensive official AVR debugger, you can use debugwire with Atmel Studio, but that is a proprietary protocol that is not supported by avrdude and the USBTinyISP I have.

For my guitar tuner project I really needed a way to debug the program I’m writing. So I looked around if anyone had figured out something to do at least basic printf debugging via SPI.

The best thing I found is people using another Arduino to forward SPI commands to the Arduino serial console. That seemed a bit clumsy when I already have a perfectly fine SPI chip in my ISP.

So I took a break from my guitar tuner to write an SPI debugging tool. I configured the AVR as an SPI slave, and then used PyUSB to send SPI commands with the USBTinyISP. In this particular case it was more insightful to plot numerical values than to print text, so I used matplotlib to make a very basic “SPI oscilloscope” to probe some variables on the AVR.

oscilloscope

I put the code on Github. It’s pretty basic right now, but if people besides me actually need this kind of thing, it may eventually grow into a nice Arduino library and command line tool.

EV3 Puppy, retail edition

I wanted to make an EV3 tamagotchi with a friend, but after various experiments I found the Puppy that comes with the EV3 education set, which is way cuter than anything we designed so far. But the education version contains different parts than the retail version, so we could not build that one.

So I sat down to create a puppy with the parts from the retail edition of the EV3. The end results looks very similar, but the construction is quite different in places.

The only functional difference is that I did not add the touch sensor and added the infrared sensor instead. So you can’t pet this puppy, but it can detect when you’re near and track the beacon with its eyes.

Other than that it’s mostly the same as the educational version. It can tilt its head up and down, stand up and sit down, pee and display different emotions.

The code I wrote so far is only a dozen lines of Python, which I might upload later. The good news is that due to the Christmas holiday, I had time to make some nice building instructions, check them out!

Download building instructions