While I managed to partially simulate a Tama-Go figure a few months ago, I’ve been having problems with reliability ever since. After a few frames, the image would start “rolling” down the screen. I eventually figured out that this was due to timing issues (as usual) and used a board with a faster microcontroller to simulate the ROM so that it can run reliably for several hours.
I originally simulated the ROM from a ChipKit Uno Board. While this sort of worked, I would see signs that the Tamagotchi was getting corrupt data after a few seconds. This made it difficult to ‘test’ the Tamagotchi, as I couldn’t be confident that a test that didn’t work had been received correctly. After looking into several possible causes of the problem that people had suggested, including wires being too long, ‘noise’ in the circuit and bugs in my simulation program, I decided to try rewriting the program for a faster board, hoping that the problem was due to a timing issue (and if it was due to a bug, I wouldn’t make the same mistake twice).
I used an STM32F4 Discovery board, which I had on hand from a giveaway (but’s it’s a pretty awesome board, well worth the ~$15 they’re going for these days). By default, the MCU runs at 8 MHz, but it can be cranked up to 166 MHz, certainly enough to keep up with any Tamagotchi.
After programming the board to simulate the Tamagotchi ROM, I found that it worked for roughly 10 reads, and then would stall. Eventually, I figured out what was different about the reads that failed.
It turns out that after running SPI at ~600 kHz for several cycles, the Tamagotchi speeds up to 2.2 MHz. It seems to do this specifically when it is fetching pixels that will be displayed on the screen. This explains the behavior I was seeing with the ChipKit Uno, which has a maximum SPI speed of 2 MHz. Since it could almost keep up, it would take a few seconds before there were obvious errors.
I fixed this by tweaking the PLL settings to speed up the microcontroller on the discovery board (note that this required removing resistor 68 on the back of the board), after which it worked!
A simulated figure doesn’t always have to return the same value for the same address, so I could make my Tamagotchi display an animation, which a real figure can’t do.
Since I can now test things reliably, I saw what happened when I extended the dimensions of the displayed image. While it does allow displaying images the size of the full screen, it rejects the image before it’s large enough to overflow LCD RAM (boo!).
It does let you do cool things, like displaying a picture of yourself holding a Tamagotchi on a Tamagotchi.