Emulating the 1990s Apollo “Tetris” and Running Code on Original Hardware



Author: Azya
Posted: 2025-11-06 08:22
Original: Article link

This article continues my series of articles (part one, part two) about “Tetris” games and the microcontrollers used in them. In the previous parts, we looked at the 4-bit Holtek microcontroller, variants of which were used in Brick Game and many other handheld electronic games released in the 1990s.

Since then, I have decapsulated more than a dozen chips from this family (extracted their dies from the IC packaging) and photographed them under a microscope. These came from familiar Brick Game units, various electronic keyrings and games from well-known manufacturers, including the Nintendo Mini Classics and Bandai Mame series. I was able to read the ROMs of nine of these and add support for them to the emulator from the previous article.

A virtual pet that also uses a 4-bit Holtek microcontroller
A virtual pet that also uses a 4-bit Holtek microcontroller

Naturally, I came across microcontrollers from manufacturers other than Holtek. I studied those too, dumping their ROMs and emulating them where possible. This article takes a closer look at one such chip.

Apollo 126 in 1 English Talking (B0202)

Typical Apollo case and box
Typical Apollo case and box

My unit was released in April 1995. It has the standard black Apollo case. The display’s segment layout is identical to that of many other Brick Games, including the E-23 from the previous article. However, the selection of games is a little unusual: besides the usual Tetris, racing and shooting games, there is a Frogger-like game and a slot machine. Another distinguishing feature is the voice commentary accompanying the games.

Beneath the blob of encapsulant, I found a Sunplus microcontroller labelled PA2071-160:

Sunplus chip with PA2071-160 marking on the die
Sunplus chip with PA2071-160 marking on the die

The first task was to determine the chip’s model or at least its family so that we could try to find documentation. Several specifications can be established from the photograph: the manufacturer is Sunplus, and the chip has 20 KB ROM, 192 B RAM, an LCD driver with 40 segments and 8 common lines, and an 8-bit 6502 core. Since the game also has voice commentary, the microcontroller must support speech playback. Armed with this information, I looked through the earliest archived versions of the Sunplus website on archive.org. Using tables like this one, I found the closest match: the SPL02B. Note the slight discrepancy in ROM size: the listed capacity is 19.5 KB, while our chip appears to have 20 KB. The reason will become clear later.

Documentation for SPL02B is fortunately available, although it is rather sparse, as is typical for specialised microcontrollers from that period.

SPL02B pad layout comparison

There is also a slight discrepancy in the pad layout: our chip has two extra pads near VDD2 and VDD3 which are absent from the datasheet diagram (on the left). The reason is unclear: the chip may not be an SPL02B but an SPL02A, for which I couldn’t find documentation. Alternatively, these pads may never have been intended for probing, as the absence of probe marks suggests.

Despite these minor discrepancies, we have identified the microcontroller and can establish its specifications from the official documentation: 8-bit core (a reduced 6502 variant) running at up to 1.5 MHz, 19.5 KB ROM, 192 B RAM and support for a 32 kHz crystal. The sound system includes two tone channels, a noise channel and a voice channel. Clearly, this is a considerably more capable chip than the Holtek microcontrollers described in the previous article.

Let’s examine its main features in more detail.

6502 Core

Comparison of SPL02 and 6502 cores (original photo)
Comparison of SPL02 and 6502 cores (original photo)

The photograph shows the SPL02 core on the left and the original MOS 6502D on the right. The physical layouts are completely different, but the underlying structure is the same: the instruction decoder at the top, the 8-bit ALU below, and the control logic in between.

ROM

ROM on the die
ROM on the die

The numbers on the left indicate the regions corresponding to individual bits, and the coloured rectangles mark the main program memory and four additional banks. If you flip the address space map from the datasheet, the order of the ROM blocks will match what we see in the photo:

ROM address space map

The ROM’s physical layout explains the discrepancy between the actual memory size and the documented capacity: the first 512 bytes, allocated for RAM and registers, are physically present on the chip but not addressable. If you zoom in on the section of ROM containing bit 0 of each byte, which occupies addresses $0000–$07FF, you can see that the first 512 bytes are simply filled with zeros (the same pattern is observed for the other bit planes):

ROM section containing bit 0 of each of 2048 bytes of main memory
ROM section containing bit 0 of each of 2048 bytes of main memory
ROM detail with cell states labelled
ROM detail with cell states labelled

On the left is an enlarged view of the area outlined in red, with the memory cell values labelled. The image resolution is clearly less than ideal, but I simply don’t have optics good enough to photograph large areas of a chip made with such a dense fabrication process. Even so, the bits are readable, and by adjusting focus and aperture, I was able to produce images suitable for automated bit recognition based on contrast, with an acceptably low error rate in the thousandths of a percent. But even thousandths of a percent of 163,840 bits are hundreds of errors scattered across an image with a resolution of about 6500×14,000 pixels, which I then found and corrected manually, bit by bit. It was a long, tedious job.

Two sets of photographs of the entire ROM, taken using different imaging settings, can be found here.

RAM

RAM fragment with control logic
RAM fragment with control logic

The RAM size is 192 bytes: the first 48 bytes are video memory, with 6 bytes allocated to each common line, and each bit in this block controls one of 48 segments. Since the microcontroller only supports 40 segments, every sixth byte is unused. The remaining 144 bytes are available for general-purpose use and for the stack.

Input/output and control registers

As with most microcontrollers, the SPL02 has special registers that control peripherals and operating modes. A total of 64 bytes is allocated for these at addresses $00C0–$00FF, although only 14 registers are actually used. This presents one of the main challenges when emulating the microcontroller: the datasheet describes the registers only in general terms, and doesn’t even specify the addresses of most of them. The G+ IDE for 6502 helped to solve part of the problem, as its header files for this microcontroller contain more detailed register descriptions:

;----------------------------------------------
;      I/O configuration for hardware system    
;---------------------------------------------- 
  P_C0H_IO_Ctrl                  EQU     0C0H   
  ;??       duty                                
  ;  ?      cpu clock                          
  ;   ?     Frosc                               
  ;     ?   port b 1:0                          
  ;      ?  port a 7:4                          
  ;       ? port a 3:0                          
  P_C1H_PortA_DataPort           EQU     0C1H   
  P_C3H_PortB_DataPort           EQU     0C3H  
  P_C4H_Freq_ToneA               EQU     0C4H  
  P_C6H_Freq_Vol_ToneA           EQU     0C6H  
  P_C8H_Freq_ToneB               EQU     0C8H   
  P_CAH_Freq_Vol_ToneB           EQU     0CAH   
  P_CCH_Noise_Type               EQU     0CCH   
  P_CEH_Noise_Vol                EQU     0CEH
  P_D0H_Standby_Normal_Config    EQU     0D0h   
  P_D2H_INT_Config               EQU     0D2h   
  P_D4H_Speech_Mode              EQU     0D4h   
  P_D5H_Speech_Data_Port         EQU     0D5h   
  P_D7H_Bank_Select_Port	     EQU	 0D7h   

I worked out some of the remaining details by running code on the actual hardware. I’ll return to this later.

Sound

Main logic of the sound generator
Main logic of the sound generator

A distinctive feature of this microcontroller is its 7-bit DAC, through which it outputs sound from two tone channels, one noise channel and a speech channel. The speech channel controls the DAC directly via the Speech register, making it possible to play 7-bit audio in software. This is how the Apollo provides its various short, unintelligible spoken comments during play.

Even with just seven bits, a sufficiently high sample rate can produce reasonably good audio. The limited ROM capacity, however, prevented the developers from making full use of the microcontroller’s capabilities. I examined the playback code and discovered that the phrases are stored in 4-bit PCM, two samples per byte, which are then mapped via a lookup table to the full 7-bit range and played back at around 6 kHz. Even with these limitations, the half-second recording of the word “Apollo” takes up 1,406 bytes.

The 7 digital lines from the upper left control the current at the audio output in the centre.
The 7 digital lines from the upper left control the current at the audio output in the centre.

Emulation

I ended the previous article by mentioning the BrickEmuPy emulator, which I initially wrote for Holtek microcontrollers, specifically for the E-23. At first, I thought I would stop there, but I became so fascinated by emulation that I started buying other “Tetris” handhelds and, more generally, any games with segmented LCDs from the 1980s and 1990s. I decapsulated their chips to recover the firmware and added support for them to my emulator.

Not all of these games used Holtek microcontrollers, of course, but wherever I could read a microcontroller’s ROM optically, I added support for it to BrickEmuPy. The SPL02 became the 11th family of microcontrollers supported by BrickEmuPy, and the total number of games now approaches 50.

A video demonstration of the Apollo 126 in 1 emulator:

Running external code

While debugging the B0202 emulator using the recovered ROM image, I came across an interesting section of code invoked by an external interrupt:

2FC0:	sei            ;78
2FC1:	lda #$CB       ;A9CB
2FC3:	sta $C0        ;85C0
2FC5:	lda #$00       ;A900
2FC7:	sta $C6        ;85C6
2FC9:	sta $CA        ;85CA
2FCB:	sta $CE        ;85CE
2FCD:	lda #$01       ;A901
2FCF:	sta $C3        ;85C3
2FD1:	lda #$00       ;A900
2FD3:	sta $C3        ;85C3
2FD5:	ldx #$00       ;A200
2FD7:	lda $C1        ;A5C1
2FD9:	sta $38, X     ;9538
2FDB:	lda #$02       ;A902
2FDD:	sta $C3        ;85C3
2FDF:	inx            ;E8
2FE0:	lda #$00       ;A900
2FE2:	sta $C3        ;85C3
2FE4:	cpx #$78       ;E078
2FE6:	bne 2FD7       ;D0EF
2FE8:	lda #$01       ;A901
2FEA:	sta $C3        ;85C3
2FEC:	jmp 0038       ;4C3800
;when will Habr finally start supporting different assembler notations :(

This subroutine reads 120 bytes from port A and stores them in RAM starting at $0038, clocking the transfer using the second bit of port B, after which it jumps to that address. If data is received from the port, the microcontroller begins executing it. If nothing is received and it reads a 0 (corresponding to the BRK instruction, which triggers an external interrupt), the process repeats until data arrives.

This is a debug mode that allows external code to be executed even after the mask-ROM chips have been manufactured.

To put it mildly, I was intrigued by the possibility of running my own code on a “Tetris” handheld. My first thought was to buy the same B0202 and try to invoke this debug mode, but I already had another Apollo, the 18 in 1 B0302, waiting to be examined. Its pinout turned out to be very similar to the B0202, so I assumed it used the same or a similar microcontroller and started experimenting on it.

B0302 main board. The pins used in debug mode are marked in red.
B0302 main board. The pins used in debug mode are marked in red.

The first problem could have stopped the experiment altogether: the external interrupt is not routed on the chip, so it cannot be triggered normally. However, it turned out that by inducing noise on the clock-setting resistor, the microcontroller is very likely to jump to the external interrupt vector. Simply touching the clock-setting resistor on the board with a finger produced the signal I had been hoping to see on the pads connected to the 2 least significant bits of port B: the transfer clocking, with timings matching the code above. Later I noticed that even simply reinserting the battery sometimes produced the same result (many of us probably remember the strange glitches that appeared when changing batteries as children).

Channel 1: port B line 0; Channel 2: port B line 1.
Channel 1: port B line 0; Channel 2: port B line 1.

I first tried sending instructions simply by pressing the buttons on the handheld. Of course, that meant sending one instruction 120 times, but it was enough to test the theory. And yes, it worked: the microcontroller predictably paused the transfer for the number of clock cycles corresponding to the number of instructions sent. At this point, I encountered a second difficulty: only the 7 least significant bits of port A are connected to the buttons, so any instructions using the high bit could not be transmitted directly. I’ll explain how I worked around this shortly.

The next task was to create a data source that would, in response to the clock signal from port B, press the buttons for us send data to port A. For this, I used a Raspberry Pi Pico 2, which receives data from a PC via its built-in serial port and, once the clock signal from port B has been stable for a while, sends the data to the Apollo microcontroller.

Raspberry Pi Pico 2 data source for the Apollo

Everything was ready to send a meaningful set of instructions, but I still needed to work around the missing high bit. At first, I simply avoided instructions that used it. This revealed another problem: programs using absolute addressing instructions did not run correctly. It turned out that, unlike the B0202, the debug mode of the B0302 stores the received data starting at $0000 rather than $0038. Once I figured this out, I was finally able to run my code. I don’t remember exactly what the code was, but it might have looked something like this:

0000: sec
loop:
0001: rol $00
0003: jmp loop
External code running on the Apollo LCD

The GIF shows the result. The program simply shifts the byte at address zero in RAM repeatedly, causing the segments mapped to it to flicker. The static segments represent parts of the program itself, since it resides in the RAM area allocated to video memory. Note how I trigger execution: I attached copper tape at one end to the traces near the chip and at the other end to the Apollo case, so there was no need to open it to trigger the interrupt.

Of course, having access to only half the instructions limits what you can write. Some code is needed to restore the data before executing the main program. The best approach I came up with was to shift each byte right before transmitting it, then rotate it back left through the carry flag after setting or clearing that flag according to the original least significant bit. This is probably easier to explain with code:

;corrective code
0000: sec
0001: rol $03
;code to be corrected
0003: .byte $54, $00
;after executing the first two instructions, "54 00" will become "A9 00"
;which corresponds to the previously inaccessible instruction lda #0

This approach has a significant drawback – each correction takes 2–3 bytes, which is rather wasteful when we have only 120 bytes available. The size of the correction code also varies, which is inconvenient. In the end, I settled on the following method of preparing the code for transmission:

dataSize = 74
;correcting the main code using the method described above
sec
rol $17
rol $0E
rol $10
rol $15
sec
rol $16
rol $1B
;main code correcting the data
ldx #dataSize-1

mainLoop:
inc loBitPtr+1
clc
loop8:
loBitPtr:
ror loBit1
beq mainLoop
lda data, X
rol
pha
dex
bmi start
jmp loop8
loBit:
;here lie the least significant bits

* = 120-dataSize

data:
;here are the bytes shifted right

* = 128-dataSize

start:

Using this method, it is possible to transmit 74 full bytes and place them starting at $0036. A more efficient solution could undoubtedly be devised (for example, sending a separate loader first), but I decided to stop here.

In Python, I wrote a script that accepts up to 74 bytes of machine code, combines it with the program above, and sends the complete 120 bytes to the Pico. The entire process is now automated: when I touch the Apollo’s clock-setting resistor, the Pico sends the program, which immediately begins running.

Reading the firmware

The first step was to write a program that transmits the B0302 firmware via port B:

ldx	#$00
lda #$00

bankLoop: ;iterate over ROM banks
sta $D7 ;store the current bank number in the bank select register D7
byteLoop:
lda (romPtr, X) ;fetch the next byte from ROM
rol
ldx #$08
bitLoop: ;shift this byte bit by bit
and #$FE
sta $C3 ;and send it via the 1st bit of port B
ora #$01
sta $C3 ;and clock the transfer via the 0th bit
ror
dex
bne bitLoop

inc romPtrL        ;increment the 16-bit address
bne byteLoop
inc romPtrH
lda romPtrH
cmp #$20           
bne byteLoop       ;until the end of the bank is reached
lda #$10           ;all banks start at $1000
sta romPtrH

inc bank           ;move to the next bank
lda bank
cmp #$04
bne bankLoop       ;until the last possible bank is reached
brk                ;after completing the transfer, start over

romPtr:
romPtrL:
.byte $00
romPtrH:
.byte $00
bank:
.byte $00

I captured the data sent through port B using a logic analyser. No need for decapsulation, photography or optical bit recognition!

It turned out that the B0302 has only two ROM banks (data is repeated in the others), i.e., a total of 11.5 KB of ROM. If we refer to the same table of microcontroller specifications, only the SPL03 has this ROM capacity. This means that the two Apollo boards contain slightly different controllers, and it can be assumed that the numbers in the B0202 and B0302 game codes indicate the corresponding microcontroller models. This also explains why the received data starts at $0000 rather than $0038: the B0302 has even less RAM than the B0202, just 128 bytes. Another unfortunate limitation is that, rather than a 7-bit DAC, the SPL03 has only 6-bit PWM output. This is split across two pins, but the Apollo design uses just one of them, effectively leaving only 5 bits for audio output.

Bad Apollo

Initially, I planned to write a simple game, but once it became clear that the total available memory is not 192 bytes but only 128, I had to abandon that idea. Instead, I decided to write a player for "Bad Apple!!" – a visually striking demo to run on the handheld, and one that is relatively straightforward to implement if the data is transmitted uncompressed.

Video and audio are stored on the Pico 2, which acts as external serial-access ROM, while the Apollo program requests and receives data in sync with the frame rate, which is 1/16384 of the microcontroller’s clock frequency, roughly 42 frames per second. Most of the data is audio in the form of 5-bit PCM at approximately 22 kHz.

After some experimentation, I settled on the following data format:

Each transmitted byte (with the high bit unavailable, as mentioned earlier) contains a 5-bit audio sample and 1 bit for the state of a single segment. I allocated 32 SPL03 core cycles to process one byte. During this time, the byte must be requested, received, the sample loaded into the voice port, and the corresponding segment switched on or off. The SPL03 has 32 bytes of video memory spread over a 48-byte address range, which I rounded up to 64 for convenience. Thus, each frame takes 64 × 8 × 32 (*) = 16,378 cycles, so the display is updated in sync with the LCD frame rate — exactly what was needed. The audio sample rate becomes 1/32 of the microcontroller frequency, which for the B0302 is roughly 21.7 kHz – more than sufficient; higher-quality uncompressed audio simply won’t fit in the 4 MB of Pico 2 flash.

(*):
64: Size of video memory rounded to 64
8: Bits per byte in video memory
32: Core cycles to process one received byte

Data Preparation

The audio was straightforward: I simply opened the original video’s audio track in Audacity and exported it as 8-bit raw PCM at the required sample rate.

The video required more work. First, I had to decide on the frame rate – the original video runs at 30 FPS, while the B0302, as mentioned, runs at 42 FPS. There were two options: duplicate some frames to bring the original up to 42 FPS, or drop frames to reduce it to 21 FPS (half the required rate) and use the extra frames to simulate additional greyscale levels. After comparing both approaches, I chose the second.

Audio and video are combined by a Python script, which discards the 3 least significant bits of the audio stream, placing the remaining bits in positions 5–1 (6–2 positions: this minimizes processing on the Apollo, as the SPL03 expects data in this format in the Speech port). The least significant bit sets the state of one of the 256 segments sequentially, frame by frame.

Player

With the data prepared, we can now write the code to play it back on the Apollo:

* = $36

ldx #$36
txs
jsr clearLCD

lda #$01
sta $D4            ;enable Speech Play Mode

main:
ldx #00 
mainLoop:
lda #$02 ;request the next byte from Pico
sta $C3 ;on the rising edge of B1
lda #$00
sta $C3
lda $C1 ;receive it from port A
sta $D5 ;and immediately write it to the Speech port

ror 		       ;save the 0th bit with the segment state into the carry flag
lda segStates             
rol                ;shift segStates left, adding the new segment state
bcc byteNotFull    ;and simultaneously check if a full byte has been received
sta $00, X         ;store the received byte in video memory
inx

lda #$02	       ;then duplicate the same process as above, but
sta $C3            ;with slight modifications to avoid delays
lda #$01	       ;related to storing the byte in video memory
sta $C3            ;to fit exactly into 32 cycles
sta segStates
lda $C1
sta $D5

ror
rol segStates

cpx #64            ;iterate over all 48 + 16 bytes of video memory
beq main           ;safely overlapping code area
jmp mainLoop

byteNotFull:
sta segStates
jmp mainLoop

segStates:
.byte 01

* = $055B

clearLCD:

Thanks to the input data format, the code is compact and fits comfortably within the available 74 bytes. The only difficulty was ensuring that each byte took exactly 32 cycles to process, no more and no less. Otherwise, the video memory updates would fall out of sync with the LCD refresh rate, causing unpleasant flickering.

Here’s what the result looks like:

Conclusion

Of course, Bad Apollo is just an attention-grabbing demo. The main and most difficult part of this work was recovering the firmware of two more Brick Game models from the 1990s, allowing me to write emulators and preserve the games for posterity (as grand as that might sound).

I hope to dump the ROMs of other Apollo models over time; there appear to have been at least a dozen. There is no guarantee that triggering an external interrupt will be as easy on all of them, though: for example, I tried the same thing on the Apollo 12 in 1 without success.

If anyone reading this wants to experiment with other Apollo models, please share your findings in the comments or contact me directly, even if the experiments are unsuccessful. I will do my best to answer any questions.

The source code described in this article is published on GitHub

Photos and other materials on the Apollo B0202 are published on archive.org


>> Home