Analysis model: gpt-5.5 xhigh
8088 MPH by Hornet + CRTC + DESiRE - Technical Dissection
8088 MPH is the Revision 2015 oldskool-winning MS-DOS demo by Hornet,
CRTC, and DESiRE. The earlier queue note accidentally called it 8088 RPM;
the production, archive, NFO, and public writeups all use 8088 MPH.
Release year: 2015
This is outside the current chronological 1980s/early-1990s sweep, but it deserves special treatment because it is a modern demo that deliberately targets the original IBM PC/XT envelope: 4.77 MHz 8088, IBM CGA, composite video, and the internal PC speaker. The impressive part is not just that it looks good on that machine. It makes effects that were generally assumed to need a different home-computer architecture:
- a final-version calibration path for old-style and new-style IBM CGA cards;
- composite-CGA colour synthesis far beyond normal 4-colour graphics;
- CRTC restarts and per-scanline start-address changes;
- cycle lockstep between CPU, CGA, PIT/DRAM refresh, and the CRT beam;
- large generated speedcode bodies instead of generic render loops;
- a 4-channel MOD-like PC-speaker player near the end.
The hard limit is that the demo is meant for real IBM CGA timing. DOSBox-X can show the structure of the files, and source plus disassembly explain the loops, but emulator playback is not proof of the final visual result. The final NFO only guarantees correct operation on real IBM 5150/5155/5160-class hardware with a 4.77 MHz 8088 and IBM CGA.
Full-Demo Visual Sequence
The sequence below uses the 15 stills attached to Trixter's screen-by-screen
write-up from a real-hardware capture. These are source-order still numbers
from mph_screenhots.avi, not local DOSBox-X timestamps. For 8088 MPH, that
is intentional: emulator timing is the problem being documented, so a fake
emulator timecode would be misleading.

The GIF above is assembled directly from five same-size 1080x720 stills in
that real-hardware sequence. It is a compact index into the source-order
screens below, not a DOSBox capture.
Source still 001 - simulated text mode and logo unroll

The opening first sells a plain PC text-screen premise, then reveals the logo by copying new scanlines during hidden time. It belongs with the loader and CRTC constraints: the viewer sees a simple text illusion, but the implementation is already avoiding the normal limits of CGA graphics start-address changes.
Source still 002 - 16-colour composite title art

This is the clean title-art result after the unroll. It is not the 1024-colour mode yet; it is VileR's title artwork recomposed for composite CGA colour, so it is the first "CGA is not just four flat colours" proof before the more abusive text-mode colour machinery arrives.
Source still 003 - bobbing loader text

The large intertitle text bobs by changing the 6845 display start address from a stable software vertical-retrace hook. This is the audience-facing version of the loader API: effects can prepare in the background while the loader owns the transition timing.
Source still 004 - moire interference

The interference pattern uses text-mode block characters and unrolled code rather than a normal bitmap blitter. This maps directly to the moire section below: two source patterns are combined through the cheapest CGA-visible writes the effect can get away with.
Source still 005 - rotozoomer

The rotozoomer is a deliberately bandwidth-conscious effect: it spends the limited 8088/CGA write budget on a recognizable transform, including the tradeoff of drawing every other line. In the analysis below, it sits in the same family as the generated narrow code paths and "only touch what matters" decisions.
Source still 006 - 1024-colour CGA claim

This is the visual headline for the composite text-mode colour trick. The picture depends on 80-column text patterns, foreground/background attributes, fixed character bit phases, and CRTC restart abuse instead of a hidden framebuffer mode.
Source still 007 - starfield

The starfield is intentionally classic, but it is still built as a table-driven and unrolled CGA-memory move problem. The particle/starfield section below explains why the "dots" are more about bus scheduling than about a generic particle loop.
Source still 008 - beam-raced sprite scene

The vehicle sprite scene combines compiled sprite output with vertical screen movement through the 6845 start-address register. Its redraw has to happen after the beam has passed the relevant screen line, so this is one of the most literal "race the beam" moments in the visual run.
Source still 009 - vectorballs spelling IBM

The vectorball logo uses a small visible region and a hidden half-page so it can erase and redraw the balls before flipping the start address. It makes the limited CGA memory layout feel like double-buffering by shrinking the problem until a hidden page exists.
Source still 010 - 256-colour plasma variant

This plasma is a writable variant of the composite colour system. It limits the active colour space to make attribute writes practical, then still has to avoid CGA snow by writing during retrace windows.
Source still 011 - 1024-colour drip picture

The portrait uses the 1024-colour display idea, then exploits the start-address changes to make the vertical drip. The key context is that the colour system and the motion trick are the same hardware abuse, not two independent layers.
Source still 012 - Kefrens/raster bars

The bars are cycle counted rather than horizontal-retrace polled. This is where the lockstep section below matters most: even DRAM refresh timing is moved so the CRTC and CPU stay in a predictable relationship.
Source still 013 - shaded torus/polygon part

The torus/polygon scene is about minimizing changed pixels and CGA writes. It uses the same practical rule as several other parts: calculate and touch only the regions that must change because every CGA memory write is expensive.
Source still 014 - 80x100 1024-colour credits picture

The portrait strip is the most compact explanation of the per-scanline restart idea: restart the CRTC start address every scanline and turn text memory into a 100-line 1024-colour image source. It belongs with both the 1K-colour and CRTC restart sections.
Source still 015 - final credits and PC-speaker MOD player

The final card pairs the ANSI-style credits with the PC-speaker MOD player. The audio VM section below is about how the demo keeps a four-channel ProTracker mix flowing through the PIT/PPI speaker path while still running on the same 4.77 MHz 8088.
Hardware And Calibration References

The map above is generated from the final archive, UNP-expanded scratch files, and the public Reenigne source tree. It is explanatory, not a raw video frame.
The final archive also ships reference calibration images:


Real-Hardware-To-Code Concordance
The sequence GIF and stills above are source-order frames from Trixter's real-hardware capture/write-up, not local DOSBox timing captures. That matters: this production is specifically about effects that fail when the emulator, CGA card, CPU clock, refresh cadence, or composite phase is wrong.
| Visual evidence | Code path / data path | What it proves |
|---|---|---|
| Real-hardware sequence GIF | Five same-size 1080x720 source-order stills from the public real-hardware sequence. |
The animation preview is an index into hardware-correct output, not a synthetic DOSBox recording. |
| Source stills 001-003: text premise, title art, bobbing loader text | Final loader manifest, INT F8h part API, intertitle records, CRTC start-address changes, and loader release handshake. |
The apparent text/logo setup is already part-managed and CRTC-timed, not a plain DOS text intro. |
| Source still 004: moire interference | Moire source pattern/shifted-copy setup and generated cell renderer using pop ax, xor ax,[bp+offset], and stosb/skip writes. |
The pattern is speedcode over CGA-visible text bytes, not a generic bitmap XOR loop. |
| Source still 005: rotozoomer | Bandwidth-conscious generated/narrow code paths and every-other-line tradeoffs described by the part family. | The effect spends the limited 8088/CGA write budget only where the transform is visible. |
| Source stills 006, 011, and 014: 1024-colour image modes | Composite CGA text-mode colour synthesis, 80-column character/attribute phase choices, one-scanline rows, and per-scanline CRTC restart loops. | These pictures are analog composite/CRTC abuse, not a hidden 256-colour framebuffer. |
| Source still 007: starfield | 948 copied particle kernels with self-patched immediate operands for old/new positions. | The starfield is table/code-generated bus scheduling, not a central particle struct loop. |
| Source still 008: sprite scene | Compiled sprite output plus 6845 start-address vertical movement after beam position constraints. | The sprite scene is a literal beam-race phase, with drawing timed after the beam passes. |
| Source still 009: vectorballs | Small visible region and hidden half-page strategy, with start-address flipping. | It manufactures a double-buffer-like effect by shrinking the visible problem. |
| Source still 010: 256-colour plasma | Writable composite-colour variant plus retrace-window writes to avoid CGA snow. | Even the more writable plasma remains constrained by CGA bus/snow timing. |
| Source still 012: Kefrens/raster bars | lockstep, PIT channel 1 refresh cadence, generated per-scanline body, CGA/CRTC writes, and audio/timing output in the line loop. |
This is cycle-counted scanline code whose correctness depends on CPU/CGA/PIT phase. |
| Source still 013: shaded torus/polygon | Generated renderer strategy that minimizes changed pixels and CGA writes. | The polygon part is optimized around "touch only what changed", not full-frame redraw. |
| Source still 015: final credits and MOD playback | PC-speaker MOD mixer, 288-cycle sample slot, patched immediates, v-instructions, h-instruction schedule, and CRTC updates inside the audio VM. | The credits animation is scheduled inside the fixed-time speaker player rather than running beside it. |
| Old/new CGA calibration images | Final archive calibration assets plus card-family phase adjustment path. | Calibration is technical evidence: the later colour tricks depend on card revision and composite phase. |
| Generated hardware pipeline map | Final archive, UNP scratch expansion, and public source tree mapping. | The map is explanatory navigation, not runtime footage. |
The important boundary is that the media proves the real-hardware visual
targets, while the code/source/archive evidence explains the mechanisms. For
8088 MPH, a local emulator capture would be weaker evidence than the
real-hardware still sequence.
Sources
- Pouet page: https://www.pouet.net/prod.php?which=65371
- Scene.org final archive page: https://files.scene.org/view/parties/2015/revision15/demo_oldskool/8088mph_final.zip
- Scene.org final archive: https://files.scene.org/get/parties/2015/revision15/demo_oldskool/8088mph_final.zip
- Trixter overview, real-hardware video, and screen-by-screen still sequence: https://trixter.oldskool.org/2015/04/07/8088-mph-we-break-all-your-emulators/
- Real-hardware video capture embedded from the Trixter overview: https://www.youtube.com/watch?v=yHXx3orN35Y
- Reenigne 1K-colour article: https://www.reenigne.org/blog/1k-colours-on-cga-how-its-done/
- Reenigne PC-speaker MOD article: https://www.reenigne.org/blog/8088-pc-speaker-mod-player-how-its-done/
- Reenigne follow-up/source notes: https://www.reenigne.org/blog/more-8088-mph-how-its-done/
- Reenigne public source tree:
https://github.com/reenigne/reenigne, inspected at commit
474aced6e6decd8149972fa517e0e732841f94f8.
Archive
The examined file is the final scene.org archive:
8088mph_final.zip 709780 bytes
Hashes:
762f57803a40b4b2682c1a6652826152bb62d7427b18d0cb064926bca8af8755 8088mph_final.zip
e4914dfa692af834c314d66ae4ea0bba0f4755dd06d3d3064b423724ee7e002d 8088MPH.EXE
a2ea444d65770b712570962fa424d6a5741b36782e1b4d549e84fe61ab59905e 8088MPH.NFO
01cc7b8da569a68b4b76b103384c999c08f4c3d2a4182807e0ceed2897a52857 dskimage/8088mph.360
The archive is not a single demo executable. It is a loader plus numbered effect files:
8088MPH.EXE 19571 bytes loader, PKLITE-packed MZ
8088MPH.001 6814 bytes packed COM-style part
8088MPH.002 14986 bytes packed MZ part
8088MPH.003 6243 bytes packed COM-style part
8088MPH.004 19440 bytes packed MZ part
8088MPH.005 18510 bytes packed MZ part
8088MPH.006 36645 bytes unpacked MZ part
8088MPH.007 9949 bytes packed COM-style part
8088MPH.008 4435 bytes packed MZ part
8088MPH.009 9485 bytes packed MZ part
8088MPH.00A 34290 bytes packed MZ part
8088MPH.00B 89246 bytes packed MZ part
8088MPH.00C 10738 bytes packed COM-style part
8088MPH.00D 25721 bytes packed MZ part
N088MPH.005 18902 bytes new-CGA alternate
N088MPH.009 9385 bytes new-CGA alternate
N088MPH.00C 10852 bytes new-CGA alternate
dskimage/8088mph.360 368640 bytes ready-to-boot/use 360K disk image
The final-version calibration PNGs are also included. Those images are not runtime captures made here; they are part of the official final archive.
UNP Scratch Expansion
Running UNP.EXE under DOSBox-X against copied scratch files produced usable
depacked files for the loader and most parts:
8088MPH.EXE 19571 -> 52380 bytes MZ, entry 0000:0D8F, 166 relocs
8088MPH.001 6814 -> 41565 bytes COM-style body
8088MPH.002 14986 -> 23648 bytes MZ, entry 0000:090A
8088MPH.003 6243 -> 9972 bytes COM-style body
8088MPH.004 19440 -> 75312 bytes MZ, entry 0000:0502
8088MPH.005 18510 -> 72240 bytes MZ, entry 0000:0000
8088MPH.006 36645 -> 36645 bytes already usable MZ, entry 0000:0240
8088MPH.007 9949 -> 20166 bytes COM-style body
8088MPH.008 4435 -> 8350 bytes MZ, entry 0000:0525
8088MPH.009 9485 -> 23232 bytes MZ, entry 0000:001A
8088MPH.00A 34290 -> 416080 bytes MZ, entry 0000:0000
8088MPH.00B 89246 -> 200856 bytes MZ, entry 0000:36EA
8088MPH.00C 10738 -> 18005 bytes COM-style body
8088MPH.00D 25721 -> 185840 bytes MZ, entry 0000:0000
This is important because the final disk files are still compressed. The
interesting code is the depacked code that the loader transfers to. I do not
treat the native depklite scratch output as primary evidence here because it
crashed after writing several memory images; the DOS UNP run gave cleaner
MZ/COM outputs.
Loader Script
The depacked loader contains a plain intertitle/effect manifest after the MZ
declared image. It is a sequence of filename | number | text records:
8088mph.001 | 0 |
8088mph.002 | 0 |
8088mph.003 | 16 | welcome to / 4.77 mhz! / welcome to cga! / what's a bitplane?
8088mph.004 | 0 | and now i see / with eyes serene / the very heart / of the machine
8088mph.005 | 0 | no copper! / no vic-ii! / what are we / supposed to do?
8088mph.006 | 13 | dots are / my favours... / except / when they're / saviour's.
8088mph.007 | 28 | sprites? / where we're / going, / we don't / need sprites
8088mph.008 | 25 | you may want to / close your eyes / for this
8088mph.009 | 18 |
8088mph.00A | 30 | race the beam / on your mark... / get set... / go!
8088mph.00B | 44 | if my calculations are correct...
8088mph.00C | 8 | and now we must bid you farewell / no paula... / no sid... / no problem
8088mph.00D | 0 |
The text is not a precise wall-clock timeline by itself, but it is the final loader's own visible sequence. The numeric field is used by the loader as part metadata/timing/control data; the record order is the strongest archive-level evidence for the run order.
The loader also contains these operational strings:
NOCHECK
DEBUGSHELL
Metric cycle count ... deviates ... from what we were expecting.
This demo only runs properly on a 4.77MHz 8088 with a real CGA card.
So the loader is doing more than exec next file. It checks for a loader
already present, provides a debug shell path, has an explicit bypass token, and
contains the famous hardware warning.
Part API
Several source files and unpacked parts share the same loader API pattern. A
part first checks interrupt vector F8h, then calls it with a cookie request:
xor bx,bx
mov es,bx
mov di,(0F8h * 4) + 2
cmp word [es:di],bx
je exit
mov ax,0700h
int 0F8h
cmp ax,0C0DEh
jne exit
After the part has built its tables or speedcode, it signals readiness and waits until the loader releases it:
mov ah,01h
int 0F8h ; ready
mov ah,02h
stc
wait:
int 0F8h
jnc wait ; carry clear means hold
That handshake matters because many parts have expensive setup phases: decompressing assets, generating unrolled code, building lookup tables, or copying full text/CGA pages. The loader can show intertitles while the next part prepares itself, then release it on a controlled transition.
Hardware Target
The demo is built around these fixed assumptions:
CPU: Intel 8088 at 4.77 MHz
Video: IBM CGA with Motorola 6845-compatible CRTC
Display: preferably NTSC composite output for artifact/composite colour
Audio: internal PC speaker through PIT/PPI
RAM: final package may use hundreds of KB; Kefrens is the hungry part
The port vocabulary repeats through the unpacked files:
3D4h/3D5h CGA/6845 index and data
3D8h CGA mode control
3D9h CGA palette/overscan/background
3DAh CGA status: display enable and vertical sync bits
40h PIT channel 0
41h PIT channel 1, normally DRAM refresh timing
42h PIT channel 2, PC speaker counter
43h PIT mode control
20h/21h PIC command and interrupt mask
60h/61h keyboard data and PPI/speaker/keyboard acknowledge
On a normal DOS demo these are often occasional setup ports. In 8088 MPH,
many of them are frame-loop ports. The demo is not just drawing into B800h;
it is timing when the CRTC sees that memory.
CGA Calibration
The final version starts with old-CGA/new-CGA calibration because IBM CGA cards do not all generate identical composite NTSC color. The final NFO says the user can tune sync, horizontal phase, and border color before starting the demo. The two included reference PNGs show the intended output for old and new CGA card families.
Technically this is not a cosmetic menu. The later 1K-colour effects depend on phase relationships in the composite signal. If the card revision and phase are wrong, the same bytes in text memory produce different colours on the monitor.
The calibration source uses the same low-level building blocks as the show:
direct B800h fills, CGA mode register writes, palette writes, CRTC register
programming, and repeated waits on 3DAh display-enable/vertical-sync status.
initCGA: The Shared Mode Builder
The Reenigne source tree has a shared initCGA macro. It does the standard
thing the BIOS normally hides, but with parameters that no normal BIOS mode
offers:
write 3D8h = mode control
write 3D9h = palette/overscan/background
write CRTC registers 00h..0Fh via 3D4h/3D5h
choose horizontal total/displayed/sync from HRES flag
derive vertical total/displayed/sync from scanlines-per-character
set maximum scanline address to scanlines_per_character - 1
reset start address to 0000h
The same macro can make:
40-column text-style modes with altered character height
80-column text-style modes with composite colorburst
320x200 and 640x200 graphics-derived modes
1-scanline or 2-scanline character rows
This is why the demo looks like it has more video modes than CGA really has. It is not discovering a hidden VGA-like framebuffer. It is changing how the 6845 walks CGA memory and how the composite monitor interprets the byte stream.
Lockstep: CPU, CGA, Refresh, Beam
The fundamental timing problem is that an 8088 instruction stream is not normally a stable scanline metronome. CGA memory accesses add wait states, the 8088 prefetch queue changes instruction timing, and DRAM refresh steals bus cycles.
The shared lockstep macro attacks that in three phases:
- program a tiny temporary CRTC frame;
- turn DRAM refresh off briefly, then force a known sequence of CGA memory
accesses and
mulinstructions to put CPU and CGA into repeatable phase; - watch
3DAhdisplay-enable transitions in a loop whose duration is chosen so the remaining possible CRTC states collapse into one.
The source comments say the loop takes 144 cycles and can iterate at most three times. The important details are:
safeRefreshOff
mov ax,0B800h
mov es,ax
mov ds,ax
...
mul cl
lodsb
mul cl
...
in al,dx ; dx = 03DAh
test al,1 ; display-enable bit
jnz loopTop
For several beam-racing effects, the parts then re-enable refresh at a different cadence:
mov al,TIMER1 | LSB | MODE2 | BINARY
out 43h,al
mov al,19
out 41h,al ; PIT channel 1 refresh rate
The public notes explain the reason: a scanline is treated as a 304-cycle budget, and changing refresh to a 76-cycle cadence puts four refresh events in predictable positions per scanline. That is the difference between "cycle counted in source" and "cycle counted on the real bus."
1K/1024-Colour Composite Trick
Normal CGA graphics gives four colours at once. Composite CGA artifacting can
give more colours by exploiting the NTSC color carrier. 8088 MPH goes much
further by using text-mode character patterns as colour generators.
The high-level logic is:
1. Use composite output, not RGBI, for the big colour result.
2. Use 80-column text patterns whose bit phases create artifact colours.
3. Combine foreground colour, background colour, and character bit pattern.
4. Use selected fixed-font characters whose top scanlines have useful bit
patterns.
5. Force 1-scanline rows where needed so characters that only work on one
scanline can still contribute stable colour.
The hard CRTC problem is that a CGA/6845 frame cannot simply be "262 one-row text rows." The workaround is CRTC restart abuse:
make many tiny CRTC frames inside one CRT frame
suppress the real vsync except where the monitor needs it
rewrite start address during the active picture
use text memory as a phase-colour lookup texture
The 1024-colour reference source does this directly. A representative per-line step is:
wait display enabled
wait display disabled
wait display enabled
write CRTC start address high/low
advance source address by one text row
wait display disabled
In the full-screen variant, that is repeated for almost every scanline. The
payload in B800h is not a normal bitmap. It is a carefully chosen set of
character/attribute pairs whose composite waveform is the picture.
CRTC Restart Inner Loop
The restart effect family uses 3DAh as a scanline gate and 3D4h as the
control surface. In simplified form:
for each visible scanline:
wait for display enable
wait for display disable
wait for next display enable
write CRTC start-address high register 0Ch
write CRTC start-address low register 0Dh
add 80 bytes to the next source row
wait for display disable
The register writes are the expensive part, so the loops are unrolled or macro-generated. The exact code must land in the blanking interval where the next scanline's address can be set without tearing the current one.
The billions source shows a related raster experiment using a 200-line
unrolled frame. Each scanline writes a small sequence of CRTC register values
and one byte to video memory, padded to a stable budget:
write CRTC vertical/display registers
write one byte with STOSB
pad with fixed NOP count
repeat for 200 scanlines
sync on 3DAh vertical/display state
This is "race the beam" literally. The CPU is not preparing a complete frame and letting the video card scan it later. It is changing the video card while the monitor is being fed.
Moire Inner Loop
The moire part is one of the cleanest pure CPU/video loops. It uses 40-column text mode and a half-block character trick to get an 80x50-ish chunky surface. The source says only 47 rows are completed at full rate, leaving some rows blank.
Setup creates a shifted copy of the picture:
original bytes: NM QP VU ...
shifted bytes: PN UQ ...
Then it builds about a thousand copies of a tiny cell renderer. The essential cell operation is:
pop ax
xor ax,[bp+offset]
stosb
inc di
mov al,ah
stosb
inc di
Meaning:
SP points into one version of the circle bitmap.
BP points into the shifted version.
POP AX fetches two source bytes quickly.
XOR combines the two bitmaps.
STOSB / INC DI writes one visible byte and skips its attribute mate.
MOV AL,AH / STOSB writes the second half.
At the end of each 20-cell row, the unroller emits:
add sp,stride-40
add bp,stride
So the per-row motion is not done by an index expression in the inner loop.
The code stream itself carries the offsets. For the transition out, blocks of
the generated code are overwritten: the xor ax,[bp+offset] part is replaced
with a constant-zero path, erasing chunks of the moire renderer as the exit
progresses.
Particle Starfield
The particle/starfield path is also code-generated. The published source says the hot particle body is 15 bytes and is copied 948 times. The body is:
mov di,old_position
stosb
shl di,1
mov di,[di]
es: mov [di],ah
mov [old_position_operand],di
The trick is that old_position is not a global array lookup. It is the
immediate operand embedded in that particle's own code. Each particle updates
its own future instruction stream:
1. DI starts as the particle's previous logical position.
2. STOSB erases/damages the old byte path.
3. SHL DI maps a logical point to a word-table index.
4. MOV DI,[DI] maps that to the next screen address.
5. ES:[DI] gets the colour byte.
6. The immediate operand in this mini-kernel is rewritten to the new position.
The result is a "loop" made of 948 specialized loops with no central particle structure to decode every frame. That is exactly the kind of tradeoff the 8088 likes: spend memory and generation time to remove per-particle addressing logic.
Kefrens/Raster Bars
The Kefrens part is the memory-hungry one. It creates a large unrolled body: one generated scanline chunk per visible scanline, plus tables for pixel masks, sample data, and phase/stride data.
The setup sequence:
copy header into the unrolled-code area
repeat 200 times:
copy a scanline template
patch the raster/sample segment for this scanline
copy footer
build pixel tables for even/odd x and y cases
enter lockstep and set PIT1 refresh cadence
program CGA/CRTC for the line-buffer layout
install a minimal INT 08h handler
call the generated scanline body
The representative generated scanline body does three jobs:
1. Pick the per-scanline data segment.
2. Composite two character cells into CGA memory using AND/OR masks.
3. Output one byte of sound timing data.
The simplified flow is:
mov ds,scanline_segment
mov sp,[bx]
pop di
read current CGA word
and/or with precomputed masks
stosw
repeat for adjacent word
pop ax
out dx,al ; raster/CRTC/palette-side byte
mov ds,bp
lodsb
out soundPort,al ; audio byte, often port E0h or 42h depending build
This explains the visual character of the part. It is not a normal framebuffer Kefrens implementation. It is closer to an Atari 2600 style line buffer: make the right change before the beam reaches the next line, then let the display hardware repeat/scan it.
The public follow-up notes also point out that external IRQs can destabilize this part. That matches the code: it masks interrupts, changes timer rates, and assumes the CPU will be where the CRTC expects it to be on the next scanline.
Landscape Speedcode
The landscape part is a generated-code renderer rather than a compact loop. Its setup builds several regions:
landscape segment
speedcode segment
stack/data segment
perspective/texture segment
sky pointer and jump tables
DI correction table
column start offsets for 160 columns
For each column it emits code based on a distance table and sine table. The build phase writes instructions such as:
load texture segment/address
compute UV offset from camera angle and distance
load a height/sample word
subtract from current horizon accumulator
call a generated filling routine
patch the immediate byte that marks the current top of ground/sky
The main loop then updates camera angle and cameraU/cameraV, scrolls the CGA
start address via CRTC registers 0Ch/0Dh, clears newly exposed columns, and
transfers control into the speedcode at the column matching the current
view angle:
update camera angle
write CRTC start address from vramOffset
clear the columns exposed by horizontal scroll
patch a byte in speedcode to make a temporary RETF stop point
push speedcode segment and selected column entry
set ES=B800h, DI=bottom-screen start
RETF into generated renderer
restore patched byte after return
That RETF into generated renderer is the key. The view is not drawn by
looping x=0..159 with branches. The code stream is already the column loop,
and the runtime jumps into the correct place.
PC-Speaker MOD Player
The end credits are one of the most impressive technical parts: a 4-channel MOD-derived player through the PC speaker on a 4.77 MHz 8088.
The central mixer is deliberately tiny. In simplified form:
add bp,freq0 ; channel 0 phase
mov bx,bp
mov bl,wave0
mov al,[bx]
add si,freq1
mov bx,si
mov bl,wave1
add al,[bx]
add di,freq2
mov bx,di
mov bl,wave2
add al,[bx]
add dx,freq3
mov bx,dx
mov bl,wave3
add al,[bx]
out 42h,al
The four phase registers are BP, SI, DI, and DX. The waveform table is
"sideways": the low byte selects the waveform/volume-baked sample, while the
high byte is the position within that 256-byte waveform. That avoids shifts in
the hot path. Frequencies and waveform numbers are immediates in the code so
the player can patch them.
The sample loop is designed around a 288-cycle slot, which gives roughly 16.6 kHz at 4.77 MHz. The code does not use a normal timer interrupt for every sample. It counts cycles and uses the PIT/speaker as output hardware.
To change notes without destroying the sample budget, the loop contains a
patch subroutine after the loop falls through:
regular sample slot:
mix four channels
output one PIT/speaker byte
LOOP back
patch slot:
POP patch_address
POP patch_value
write patch_value into code
reload CX with count until next patch
jump back into mixer
The real leap is the v-instruction idea. The NOP padding area at the start
of the sample loop becomes a tiny fixed-time bytecode area. Some ticks patch
that NOP area into useful work: change ES, update a CRTC start-address byte,
emit a text character, or advance song-data pointers. The macro assembler in
credits/mod.asm then becomes a generator for those v-instructions.
That is why the credits can scroll and update the screen while the audio is still playing. The animation is not outside the player. It is scheduled inside the fixed-time audio loop.
CRTC Updates Inside The Audio VM
One public article shows a representative v-instruction that updates the CGA start address:
mov bx,dx
mov dx,03D4h
mov ax,990Dh
out dx,ax
mov dx,bx
The 99h byte is patched to the desired start-address value. This is an
important pattern: even the code that is generated as a "virtual instruction"
is itself self-modifying. The credits therefore have three layers:
CPU instructions
v-instructions assembled into fixed-time NOP slots
h-instructions/data stream that generate the v-instruction schedule
That is overkill for a normal PC speaker routine. Here it is the mechanism that lets the demo spend almost the whole machine on audio while still moving the visible credits.
Snow, Refresh, And Why Emulators Failed
Several effects depend on behavior that old PC software usually avoids:
- direct CGA memory writes in modes where snow is visible;
- exact
3DAhdisplay-enable timing; - 6845 start-address changes during active display;
- PIT channel 1 refresh timing;
- 8088 prefetch queue side effects;
- instruction-level bus-cycle timing with CGA wait states.
The final archive's warning is therefore not just drama. A clone CGA card, VGA card, emulator, or faster 8088-compatible machine can preserve the DOS API and still fail the demo. The "program" is the whole bus/video/timer system, not just the bytes in the EXE.
What Each Numbered Part Contributes
This table combines the final loader script, archive inspection, public source names, and hardware signatures. It is intentionally conservative where the exact final filename-to-source mapping is not unique.
001 early setup / calibration-adjacent binary body; heavy CGA/PIT signatures
002 loader-supported MZ part with PIT0/PPI/keyboard use
003 intertitle + early CGA body, introduces the 4.77 MHz/CGA premise
004 large MZ effect part, UNP expands to 75 KB, heavy direct CGA output
005 old-CGA effect part with new-CGA alternate N088MPH.005
006 already-unpacked MZ; particle/dot-family signatures
007 sprite/no-sprites sequence; timer and CRTC signatures
008 flash/close-your-eyes sequence; PIT and CRTC signatures
009 old-CGA effect part with new-CGA alternate N088MPH.009
00A race-the-beam setup; expands to 416 KB and has CRTC/PIT lockstep shape
00B large beam-racing / Back-to-the-Future-scripted part; expands to 200 KB
00C old/new-CGA alternate body; farewell setup
00D final credits/audio body; expands to 185 KB and matches MOD-player scale
The loader text names the audience-visible beats. The source tree names the implementation families: calibration, 1024 colours, particles, moire, Kefrens, landscape, sprites/polygons, and credits/MOD audio.
Why It Works
The demo is built from a small number of ruthless decisions:
- Treat CGA text memory as an analog composite signal generator.
- Replace general loops with generated, one-purpose code.
- Put every important loop into a known phase relative to the display beam.
- Move DRAM refresh timing when the bus schedule needs it.
- Use self-modification as the normal data path, not as a stunt.
- Share control through a tiny loader API so each part can prepare a different hardware state.
That is why 8088 MPH feels like it has "Amiga/C64 tricks" on a PC that has
neither a copper nor sprites nor a SID. It does not emulate those chips. It
finds the IBM PC's own exploitable clocks: CGA composite phase, 6845 scan
timing, PIT counters, the 8088 prefetch queue, and the PC speaker input path.
The classic inner loops are therefore not one single loop. They are the pattern repeated across the production:
precompute or generate a very narrow code path
enter exact CPU/CGA/PIT phase
spend the hot path only on bus-visible work
patch the code stream instead of carrying runtime state
restore just enough DOS/video state to hand control back
That is the real trick behind the demo: it treats the whole original PC as a cycle-programmable display/audio machine.