Author: Azya
Posted: 2023-11-13 07:59
Original: Article link
By the time I was writing the previous article, more Brick Game units were already on their way to me. The first to arrive looked like this:
Brick Games of this type began appearing on the market around the late 2000s. I tried a different decapsulation method on this unit, hoping to avoid the problems I encountered last time. The method is as follows: heat the blob of encapsulant with a heat gun until it becomes soft, but not brittle (around 150°C). While continuing to heat, carefully lift the encapsulant with a scalpel, first away from the PCB and then, with particular care, away from the die itself. It sounds simple, but in practice it is not that easy. Although all three attempts were successful, the risk of damaging the die with a careless movement of the tweezers is still high. On the plus side, there’s no need to use any chemicals, which is particularly convenient when working at home.
Here is the die from the first unit:
As expected, the fabrication process is much denser. Unfortunately, there are no identifying markings, only the number “2008,” which is probably the mask fabrication year.
I won’t attempt an in-depth analysis here, but briefly: in the upper-right corner is 7.5 KB of ROM (which would be extremely difficult to read with an optical microscope), with 384 B of RAM beneath it. In the upper left corner is presumably the instruction decoder (which could be used to identify the microcontroller). I may be mistaken, but I assume this is an 8-bit microcontroller unrelated to the HT-443.
The next Brick Game arrived as a pile of internal components, so I don’t know what it looked like in its prime. The PCB shows a date of 12/8/2002, and judging by the button layout, it is a typical early-2000s “1 in 9999” model. Here is a photo of its die:
It has exactly the same architecture and almost the same die area; only the layout differs slightly. It has 3 KB of ROM and 160 B of RAM. Again, no identification marks, only the year(?) — 2003.
And here is the main subject of this article, modestly named the Super Brick Game E-23 PLUS MARK II 96 IN 1 from the Taiwanese company E-Star:
The blob of encapsulant was much larger than on the previous two units, so decapsulation took me half an hour, but the result was worth it:
It was the familiar HT-943 (also known as the HT443A0), just one year older than the one from the previous article.
Editor's insertion: DATASHEET PDF
For comparison, I photographed the dies together:
Of course, it is too early to draw conclusions from just four units, but we can tentatively suggest that the Taiwanese Brick Games of the early and mid-1990s were primarily based on 4-bit Holtek microcontrollers. By the late 1990s or early 2000s, as mass production shifted to China, the designs appear to have switched to a platform better suited to local production.
Reading the ROM
Naturally, I was primarily interested in the ROM, but at first glance it was a disappointment: practically unreadable.
Fortunately, illuminating the die at an angle produced much better results, although they were still not perfect:
Now the boundaries between "normal" transistors and those with a thicker oxide layer beneath the polysilicon are clearly visible. This is done to raise the transistor's threshold voltage, preventing it from turning on (so it can effectively be treated as absent). In the next image, red dots mark the "normal" transistors, whose gate oxide allows them to be switched by the decoder’s selection signal:
How do we turn this jumble of bits into a sequence of bytes and obtain a usable ROM image?
I touched on this briefly in the previous article, but I’ll explain it in more detail here, particularly as the task proved more difficult than expected.
Let’s examine the ROM and its surroundings in more detail:
As I noted earlier, the bits of each byte are grouped together. These groups are marked with black rectangles in the image above. To read a byte correctly, we need to determine the significance of each bit (MSB/LSB). This can be done by tracing the internal bus to which each group is connected back to the instruction decoder and using the instruction descriptions in the datasheet to establish the bit order. The resulting bit numbers are labelled in the image.
At the top are 12 repeating groups of transistors, marked with coloured rectangles. A pair of signals, one non-inverted and one inverted, runs from each group along the decoder lines around the ROM (shown in the corresponding colours). It is natural to assume that these lines define the 12-bit address of the byte being read, while the transistor groups form the circuits for the instruction counter registers, the stack (which has only one level here), and some auxiliary logic.
To determine the correct byte order, it is necessary to figure out how the decoder lines correspond to the sequence of address bits. This is a little more complicated than determining the significance of the data bits. All 12 address bits are connected to an 8-bit internal bus, whose significance has already been established. This means that some of the bits (the leftmost and rightmost four groups) share the lower bits of the bus. I therefore also had to analyse the register control lines: they are identical for the eight groups on the right, but differ for the four on the left. This suggests that the left four address bits are fed into the instruction counter separately from the eight on the right. I therefore assumed that the left four were the most significant bits. The address bit numbers are also labelled in the image.
There are two details I could not determine without reconstructing the full circuit: which line of each decoder pair carries the non-inverted signal and which carries the inverted signal, and the polarity of the data bits themselves. That leaves 2 possible ROM read orders and 2 possible ways of interpreting each byte — a manageable number of possibilities.
In practice, I ran into some problems. I initially read about ten bytes by hand for each possibility and disassembled them, but none looked as expected. Based on the datasheet, I expected to find something like an unconditional jump at address 0, from which the microcontroller starts after reset. I also expected to see unconditional jumps at addresses 4 and 8, the interrupt entry points, or at least a reti instruction if interrupts were unused. Instead, each result looked stranger than the last, so I had to check a number of less likely ROM read orders that didn’t fit the theory above. With no luck, I picked the most plausible of the original four possibilities and continued reading the ROM, gradually confirming that it was indeed the correct one. It turned out the firmware authors had ignored interrupts altogether and even used some unexpected instructions, such as decrementing a memory location immediately on startup and writing 0xE to port PA, which is physically unconnected:
000: dec [R3R2] ;0F
001: timer on ;38
002: mov A, 0xE ;7E
003: out PA, A ;30
004: mov R1R0, 0xFF ;5F0F
006: in A, PP ;34
007: ja0 04C ;804C
009: mov A, 0xF ;7F
00A: call E67 ;FE67
00C: jmp 002 ;E002
Emulator
Once I was confident I was on the right track, I continued decoding the ROM while debugging the emulator I had started writing earlier. After several days of work, the firmware was fully recovered, most of the emulator bugs had been ironed out, and obvious errors in the ROM image had been corrected. Finally, the long-awaited “01” appeared on the display. I felt a little like Victor Frankenstein shouting, “It’s alive!”
Of course, it didn’t look quite so good at first: I had only mapped some of the display segments belonging to the playing field. By the way, while reconstructing the segment map, I was struck by how irregularly they are arranged: the segments of one digit are addressed differently from those of the neighbouring digit, and different parts of the playing field use different arrangements. I don’t envy the programmers who had to write code for this display.
The emulator is still rough around the edges (for example, it has no sound), and I’m not sure I’ll finish it. Even in its current state, though, it can be useful for exploring the firmware, whether you want to write your own emulator or look for Easter eggs. Or you can simply play it for a bit of nostalgia :) The application supports basic debugging tools; the contents of all registers and RAM can be changed on the fly. It is written in Python using PyQt6, so it can run on any OS supported by that library (Linux, Windows, and macOS). The source code is available on GitHub, where you can also find the firmware image.
There are probably still some bugs, so if you own the same Brick Game model and notice anything that behaves differently from the original, please let me know — I’ll try to fix it.