Author: Azya
Posted: 2023-10-20 08:06
Original: Article link
This little investigation was prompted by a recent article on Habr, in which the author suggested that the famous 1990s “Tetris” handhelds might have used a 4-bit Holtek HT1130 microcontroller. I was surprised (and motivated) to learn that apparently no ROM dump had yet been made, and consequently no emulator existed for this line of games.
The assumption that Brick Game is based on the Holtek HT1130 has one weakness: the HT1130’s display driver can only control 128 segments, whereas a typical Brick Game has 200 (10x20) segments just for the playing field. So where did the information about the Holtek HT1130 come from? A quick search led me to the original source: a 2015 article, where the author mentions finding a datasheet for one variation of Brick Game — "Super Brickcal 9 in 1" — which runs on an HT113LA and differs from the classic version by having a smaller game field. He notes that the Holtek HT113LA is a custom variant of the Holtek HT1130, used not only in the Super Brickcal but also in many other simple handheld LCD games.
But I am interested in the more common versions of Brick Game — the recognisable cases with a curved waist, usually marked with the letter E and several digits. Two examples are the ES-118 and E-88, shown below:
I specifically bought these well-worn specimens to take apart. The E-88 was listed by the seller as defective, and among Brick Game enthusiasts, it is regarded as one of the classic models, so I’ll start with it.
“1 hour, 5 rubles” :) Is that a joke, or was someone really willing to pay to play Tetris by the hour?!
Wow. Opening it up unexpectedly reveals something of the previous owner’s inner world. Punk’s not dead!
Here is the chip I’m interested in, visible through the PCB:
A black blob of encapsulant protects the microcontroller die from the outside world, and removing it is no easy task. The most reliable method would be to dissolve it in nitric acid, but I’m not keen on using such methods at home. I therefore opted for a simpler, though less reliable, method: thermal decapsulation.
Decapsulation
The idea is to separate the entire blob, together with the die, from the PCB, then heat it over an open flame. As a result, the compound becomes brittle, allowing the bulk of it to be removed mechanically. Any remaining compound on the die surface is removed with dichloroethane (commonly sold as plastic glue).
As I mentioned, this method is not particularly reliable, and my lack of experience didn’t help: unfortunately, the die cracked in two during removal :( Most of the damage, as luck would have it, was in the ROM area, so I couldn’t read it this time. Here, then, is the brain of the Brick Game E-88 (in full resolution):
The HT-943E5 marking immediately stands out, along with a mask date of 1994 and a small Holtek logo etched into the die.
This confirms that the classic mid-1990s Brick Game runs on a Holtek microcontroller. What remains is to determine exactly which one.
Naturally, I immediately searched for HT-943. The closest match I found was the 8-bit HT-948, but its specifications don’t match what we see in the die photo — 16 KB ROM vs. 4 KB, 3328 bits RAM vs. 640, the number of controllable LCD segments still doesn’t match, and the 4-bit Super Brickcal hints that this is likely a 4-bit processor. In fact, someone more experienced could probably determine the ALU width from the die photo, but I am a complete amateur in microelectronics.
In the end, I downloaded every datasheet for a 4-bit Holtek microcontroller that I could find (fortunately there are only a couple dozen publicly available), and found an exact match — HT443A0.
Editor's insertion: DATASHEET PDF
Judge for yourself: the number of LCD segments (40) and total pins (8) match what we can identify in the die photo, as do the 160 RAM nibbles plus 80 LCD RAM. Most importantly, the datasheet shows the die pin positions and dimensions, which exactly match our specimen.
Now I’ll try my hand at being a Ken Shirriff and label the features I was able to identify on the die. As a reminder, my knowledge of microelectronics is fairly limited, so some of my assumptions may be wrong. I’d welcome corrections and additions from knowledgeable readers in the comments.
Let’s examine the ROM in more detail:
Variations in the transistor array are clearly visible; these encode the individual ROM bits. Simply put, where a horizontal line (doped layer) intersects a pink vertical area (polysilicon layer) — the bit is a 1; where it intersects a greenish area, it’s a 0. On the left, the decoder for the 6 most significant address bits is visible (the decoder for the 6 least significant address bits is located between the upper and lower ROM sections in the damaged area and is not visible in the photo). If you look closely, all horizontal lines converge in the upper-left corner — from there, one bit of the byte at a given address goes to the data bus. Each ROM section, like the one shown above, together with its mirrored counterpart on the right (there are 8 in total), contains the corresponding bit of all 4096 bytes of ROM. Unfortunately, this means that bits from the middle of every ROM byte have been destroyed. Not even a portion of the firmware can be read from this die.
While I wait for more donor chips to decapsulate, there is still one completely intact ROM: the one that stores the sound sequences. Let’s try to decode that, at least.
Melody ROM
From the datasheet, we know that the HT443A0 supports 16 sound sequences (referred to here as melodies), each of which may contain tones, noise or percussion sounds. Melodies 1–12 can contain up to 32 notes, and melodies 13–16 up to 64. Unfortunately, the number of bits per note is not specified, but we can calculate it: the die photo shows 4480 bits in the melody ROM, and according to the datasheet, there are 640 stored notes. Therefore, 4480 / 640 = 7 bits per note.
To read the ROM, we need to establish which bits belong to each note and which notes belong to each sequence. We can do this by examining the note and melody selection decoders.
The 5-bit decoder highlighted in red selects one of 32 pairs of vertical lines. It’s logical to assume that each of the 32 notes is stored in one pair of vertical lines. The 4-bit decoder in blue selects 1 of 16 groups of 7 horizontal lines (7 bits per note). A further 1-bit decoder, highlighted in green, allows an additional 32 notes to be addressed for the double-length sequences.
To make this explanation a little clearer, I’ll read the first note of the first sequence. First, the metal layer must be etched, as it hides part of the ROM. I used a low-temperature aluminium solder flux (composition unknown). Unfortunately, etching affects other IC layers, causing uneven colour changes (depending on layer thickness), making reading the ROM quite difficult. There’s no way to automate this: all 4480 bits have to be marked by hand :(
The photo shows the bit values of the first note of the first sequence, with arrows indicating the reading order from most to least significant bit.
And here is the complete first sound sequence:
1010110
1101011
0110101
1011010
1101101
1110110
1111011
0111101
1011110
1101111
0110111
0011011
0001101
1000110
1100011
0110001
1011000
0101100
0010110
1001011
0100101
1010101
1101001
1110100
0111010
1011010
1101110
1110111
0111011
0011101
1001110
1100111
An interesting sequence: I was expecting ordinary frequency-divider values, but this looks like the output of a linear-feedback shift register (LFSR). I vaguely remembered Ken Shirriff’s work on the reverse engineering of a greeting-card melody IC and went back to check. Sure enough, it uses exactly the same note representation. The linked article explains this in detail. In short, the frequency divider is determined by the number of LFSR steps until it reaches the value 1000000.
For example, the sequence for note 1111111 contains 8 steps:
1111111
0111111
0011111
0001111
0000111
0000011
0000001
1000000
The base sound frequency is determined by a clock divider configured by the factory mask, and its exact value is unknown to me. But I measured the sound frequency of this note on a working unit and obtained approximately 4200 Hz. A base frequency of 32768 Hz therefore fits — at this value, the note 1111111 corresponds to 4096 Hz (the small discrepancy is due to the tolerance of the resistor that sets the HT443A0 clock).
We can now identify the first sound sequence: it is the sound effect played when a piece moves horizontally in Tetris.
And what about Korobeiniki, the familiar Tetris tune? It occupies two 64-note melody slots, the 13th and 14th. Here is the beginning of the tune, with the corresponding frequencies:
0111010 - 1092Hz
0111010 - 1092Hz
0111010 - 1092Hz
0111010 - 1092Hz
1100011 - 819Hz
1100011 - 819Hz
0101100 - 886Hz
0101100 - 886Hz
1010010 - 993Hz
1010010 - 993Hz
1010010 - 993Hz
1010010 - 993Hz
0101100 - 886Hz
0101100 - 886Hz
1100011 - 819Hz
1100011 - 819Hz
1101111 - 728Hz
1101111 - 728Hz
1101111 - 728Hz
0000000
1101111 - 728Hz
1101111 - 728Hz
0101100 - 886Hz
0101100 - 886Hz
0111010 - 1092Hz
0111010 - 1092Hz
0111010 - 1092Hz
0111010 - 1092Hz
1010010 - 993Hz
1010010 - 993Hz
0101100 - 886Hz
0101100 - 886Hz
The duration of a note is set by repeating it, while silence is represented by zero.
In addition to the melody ROM, there is another, smaller ROM associated with the sound circuitry:
I haven’t analysed it yet, but it appears to contain the tempo divider for each sound sequence, the “instrument” type, and possibly other information.
In the near future, I plan to finally extract an intact die from its encapsulant and dump the firmware. Once that’s done, an emulator shouldn’t be far behind.