Analysis model: gpt-5.5 xhigh

Mayday by Yodel - Technical Dissection

Scope

Mayday is Yodel's MS-DOS demo released at The Computer Crossroad 1993. It placed third in the PC Demo competition, after Triton's Crystal Dream II and Extreme's Lunatic.

Release year: 1993.

This writeup is based on the public mayday.zip archive, its included notes, PKLITE-unpacked child executables, a complete direct runtime run, static disassembly, and direct binary inspection of the VGA, timer, audio, decompression, and drawing loops.

Public references:

Verified Production Credits

The executable's own ending and the structured production record together give a small, individually checkable maker ledger. Snooky, located in Varberg, Sweden, is credited for the code. The ending additionally credits TCC, individually recorded in Sweden, for the CRT-shut contribution and says that TCC wrote the replay system. Dr. Hardcore, better known as Goto80, located in Göteborg, Sweden, is credited for the rave-part music. The Quiz, The Intro, Techno, Ducktale, VU-wrap, and Ending are names of sections in the internal credit sequence, not six additional people.

Offset notation:

The included text file has old private contact listings. Those are intentionally not reproduced here.

Complete Direct Runtime Run

I ran the checked release launcher under DOSBox-X 2026.01.02 with an emulated Sound Blaster Pro 2 at the release's expected 220h, IRQ 7, DMA 1 settings. No keyboard input was needed. The launcher executed all five children in order, the ending completed, and control returned naturally to the DOS prompt after about 11:02 of captured session time.

Capture time Directly observed runtime state
about 00:35–02:12 The first child moves from a simulated system-overload display into the dated starfield story about the Yodelfrize and its crew.
about 02:12–05:38 The long second child cycles through a monochrome spiral, logo and title forms, palette changes, and projected shaded geometry.
about 05:38–05:51 A short planar interlude bridges the large scripted part and the vector landscape.
about 05:51–08:03 A purple YODEL logo sits above a continuously changing multicolor vector-dot landscape while a curved text line moves along the bottom.
about 08:03–11:02 The final child shows its starfield, large outlined credit/scroller text, ending artwork, and CRT-style close before DOS regains control.

The first published animation is one continuous direct excerpt from a fresh run of the released MAYDAY.003 child. The file was copied unchanged to an .EXE name only because the DOS command shell will not launch an MZ program whose release filename ends in .003:

Continuous Mayday runtime excerpt showing the multicolor vector-dot landscape below the Yodel logo

A second direct child run now exposes the short .002 interlude as motion rather than reducing it to a verbal bridge. The figures enter, change pose, and accumulate below the logo; this is one continuous 16-second excerpt, not a tiled contact sheet:

Continuous Mayday planar interlude with animated figures accumulating below the Yodel logo

The late frame makes the planar population especially clear without asking the reader to stop an animation at exactly the right moment:

Mayday planar interlude late frame with the screen populated by animated figures

The complete 640x400 source and the published excerpts are used only for their video frames. Sound Blaster emulation kept the guest timer/player path active while SDL used a dummy host driver; no audio was monitored or published. The period contact page reached at the very end is also excluded from the published media.

Runtime-To-Code Concordance

The observed five-part sequence follows the launcher's five consecutive DOS EXEC calls exactly. Each visual handoff returns to the parent before the next Mayday.000 through Mayday.004 filename is dispatched, and the DOS prompt at the end confirms that the parent restores its saved state and exits.

Observed part Recovered implementation
overload/story opening .000 entry at 0x130, palette interpolators at 0x316, 0x35e, and 0x3a9, story-frame expansion at 0x7d1, and planar point plotter at 0x89d
spiral, pictures, and shaded forms .001 script dispatch at 0x3fe, RLE/direct plane loader at 0x52d, projected geometry at 0x73e/0x85f, and triangle filler at 0xe45
short planar interlude .002 mode-0Dh setup and background upload at 0xaa, page/fade loop at 0x169, and 32-object update loop at 0x23a
vector-dot landscape .003 projection at 0x255, edge builder at 0x35b, strip renderer at 0x410, and saved-position dot plot/erase helper at 0x56f
credits, scroller, and close .004 ending RLE at 0x1d1, palette fade at 0x266, scroller at 0x37c..0x55d, CRT routine at 0x568, and final palette helper at 0x71a

The live landscape excerpt directly exercises the .003 path described later: its moving 1024-dot surface agrees with the projection, edge interpolation, eight-strip renderer, and erase-list organization instead of merely matching a static logo frame.

The new planar excerpt independently exercises .002: the unchanging logo belongs to the uploaded background, while the growing set of small figures is the visible result of the 32-object update path operating across successive pages. That division is much easier to see in continuous motion than in one screenshot.

Archive Layout

The public archive contains a tiny launcher, five child executables, and two small text files:

FILE_ID.DIZ       267 bytes
MAYDAY.000    297,683 bytes
MAYDAY.001    144,718 bytes
MAYDAY.002     11,610 bytes
MAYDAY.003    148,091 bytes
MAYDAY.004    158,787 bytes
MAYDAY.EXE      1,178 bytes
README.NOW        236 bytes

Archive and original-file hashes:

8bf479a1ea06b331c6272a108371c5b257882b82e55744485a61cfffea3e4cc9  mayday.zip
b4e47b3b952363df3d94134a54747fe467d24f4255bcd0d9fb436c547ec980b7  FILE_ID.DIZ
5a74cf23e0c6b96695fecfe37b6bb5cedcb798e3f0b1f08cbd040bbaa3d7af98  MAYDAY.000
ed204ae53747880a75c7c7aa3325af5ed21da656f81132daa6513ff59e23de6e  MAYDAY.001
734f63d31561f639871f3a623ed4e1cb481c93cf54592907d29e3c443d81abaf  MAYDAY.002
a971eec1bd4c51f0220cf019e7aafe513591b0a378ac2428525b076f078a3fd1  MAYDAY.003
882ccd9c0c647f8a5d9ecc0031e68aa74cddbba64f43269f554af3fc81290966  MAYDAY.004
d58ec2e46519d7b9a1973049c385c1b48c16ddb4500172637c0a6a7cc77a0387  MAYDAY.EXE
3900dd5cddf2ed539cd55bb63932b5e478476ee5a4a0fb39e10cdbbb49671967  README.NOW

The release note says the demo must be run from hard disk and expects a Sound Blaster using DMA 1 and IRQ 7. Base port probing covers 210h through 260h. That matches the code shape: audio is not an external player left beside the demo. A timer-driven replay engine is copied into several child executables.

FILE_ID.DIZ calls the demo "a little story." That is accurate structurally: the launcher chains five standalone MZ programs. Each part owns its graphics mode, asset blocks, and often its own copy of the music engine.

Unpacking

All executable files are PKLITE-packed. Running them through UNP in DOSBox-X produced these recovered MZ images:

MAYDAY.EXE       804 bytes
MAYDAY.000   558,918 bytes
MAYDAY.001   578,230 bytes
MAYDAY.002    33,489 bytes
MAYDAY.003   305,846 bytes
MAYDAY.004   315,360 bytes

Recovered-file hashes:

736aafb052b29cc6afc873d041d0efce94c098ff027916e6574f1d005697fcfd  MAYDAY.000
8f54197b8537b3911996246984b72c7f1f753033312f5b939ab3474e8101011b  MAYDAY.001
8983b003cf40d3962c9a7f364b0de59317ad5f435b15b1bee712350eaefb3fde  MAYDAY.002
909c16231e0df30318df3a6fb5a035a1216b39edd2adf4e26724d5c937b8ccf2  MAYDAY.003
e0974048ee1c8a8f4451825bbe9d27dd7a15b14c7138476d5107e614980f0d7b  MAYDAY.004
b1203598789227b514cd7c52077d00931f47ffa65a09d71e27bade56a0366d1f  MAYDAY.EXE

The recovered MZ headers are ordinary real-mode executables:

file        size after UNP  entry        stack       relocs  header paras
MAYDAY.000        558,918   0000:0010    8863:0800      63            18
MAYDAY.001        578,230   0000:0010    8d13:0100      91            25
MAYDAY.002         33,489   0000:0000    082b:0100       2             3
MAYDAY.003        305,846   0000:0010    4a9f:0100      43            13
MAYDAY.004        315,360   0000:0010    4cf1:0100      43            13
MAYDAY.EXE            804   0000:0010    0031:0040       1             2

The relocation counts are useful. These are not raw .COM blobs with fixed load assumptions. They are linked MZ programs with segment fixups, then PKLITE was applied over each one.

Launcher

The launcher is small but important because it defines the demo's sequencing. After UNP, the launcher entry is at MAYDAY.EXE+0x30.

The startup does this:

  1. Sets DS to the launcher's load segment and installs a small stack.
  2. Reads the current PIC mask from port 21h and saves it.
  3. Masks all IRQs with out 21h,ffh.
  4. Sets video mode 12h, asks BIOS for the active mode with int 10h AH=0Fh, and prints a VGA-compatible adapter warning if the mode did not stick.
  5. Switches back to text mode 02h.
  6. Asks DOS for the largest available memory block with int 21h AH=48h, BX=ffffh.
  7. Requires at least 0x9048 paragraphs, then warns if there is not enough conventional memory.
  8. Calls a DOS EXEC helper five times, once for each child file.
  9. Restores the original PIC mask and exits to DOS.

The child filenames live consecutively in the launcher:

Mayday.000
Mayday.001
Mayday.002
Mayday.003
Mayday.004

The helper at MAYDAY.EXE+0xbf builds a DOS EXEC parameter block and calls:

mov ax,4b00h
mov bx,000ch       ; parameter block
int 21h

Before the EXEC call it stores SS:SP into code variables, because DOS may return through the same real-mode context after the child exits. Afterward it restores the stack and dispatches the next child.

This is why the five large files can be treated as parts instead of overlays. The parent does not page them into a common engine. DOS loads and unloads each program as a separate process.

Overall Part Map

The part names below are inferred from strings, credits, and visible routine shape:

MAYDAY.000  story intro, palette transitions, image planes, point effects
MAYDAY.001  large scripted visual part with RLE pictures, palette events, 3D spans
MAYDAY.002  compact Mode 0Dh planar sprite/dot interlude
MAYDAY.003  3D landscape/scroller section with 1024 realtime vector dots
MAYDAY.004  ending credits, star/dot field, scroller, and CRT shutoff

The split is not merely aesthetic. Every child sets its own video state, often hooks its own timer routine, and owns independent tables. That raises disk and memory cost, but keeps each part simpler and avoids a large shared runtime.

Shared Timer and Audio Engine

The larger parts contain copies of a TCC music engine. The .000, .001, .003, and .004 copies are very similar. The setup code in .000 around MAYDAY.000+0x11f0 is representative:

in  al,21h
mov [7c65],al       ; save PIC mask

mov ax,1113h
mov es:[20h],ax     ; IRQ0 vector offset
mov ax,cs
mov es:[22h],ax     ; IRQ0 vector segment

mov al,0feh
out 21h,al          ; temporarily leave IRQ0 unmasked

mov al,36h
out 43h,al          ; PIT channel 0, square-wave mode
mov bx,[7c48]       ; reload
mov al,bl
out 40h,al
mov al,bh
out 40h,al

mov al,7fh
out 21h,al
mov al,20h
out 20h,al          ; EOI

The timer hook writes the IRQ0 vector at 0000:0020, programs PIT channel 0 through ports 43h/40h, and keeps a saved PIC mask for cleanup. The replay therefore runs independently of the visual frame loop.

The ISR body starts near MAYDAY.000+0x1233. Its inner mixer is compact:

push registers
ds = music data segment

acc = table[channel0_index]
acc += table[channel1_index]
acc += table[channel2_index]
acc += table[channel3_index]
acc >>= 2
jmp [selected_output_backend]

The table base in .000 is around 0x3ac0. Channel phases and step values are updated before the average sample is emitted. The backend pointer chooses one of several output paths:

03bch, 0378h, 0278h  LPT DAC-style output
PIT channel 2         PC speaker volume-style output
ring buffer           memory-buffer output
Sound Blaster path    setup selected by the release note's IRQ/DMA assumptions

The PC speaker path programs PIT channel 2:

mov al,0b0h
out 43h,al
xlat                 ; volume/period table
out 42h,al

The buffered output path increments a ring offset, masks it with 0x07ff, and uses half/full boundary tests to decide when a block is ready. That explains why the release note is strict about Sound Blaster DMA and IRQ settings: the timer replay path and the hardware output path need to stay aligned.

The key observation is that Mayday is not just a sequence of picture loaders with music somewhere outside. The audio tick is resident inside the visual parts, and it is frequent enough that the visual loops must be written around retrace waits and IRQ activity.

MAYDAY.000: Story Frames, Palette Math, and Planar Points

MAYDAY.000 enters at MAYDAY.000+0x130 and sets DS to 0x7f26. It begins by initializing many table pointers and segment constants, then uses BIOS mode 13h as a staging state before switching to tweaked planar VGA.

Row-Offset Table

At MAYDAY.000+0x2c7 the part builds a row table:

di = row_table
ax = 0
cx = 0190h
repeat:
    stosw
    ax += 00a0h

The stride 0xa0 is 160 bytes, not the normal 320-byte mode-13h stride. That fits a half-width or planar/tweaked layout where one logical row is split over VGA planes. Later point code uses this table to compute the byte offset for a pixel row without multiplying in the frame loop.

Palette Interpolation

Several loops around MAYDAY.000+0x316, +0x35e, and +0x3a9 perform fade and crossfade work. The loop at +0x316 is a clean example:

for frame in 0..63:
    inverse = 64 - frame
    for i in 0..255:
        a = palette_a[i] * inverse >> 4
        b = palette_b[i] * frame   >> 4
        value = a + b
        dac[i].r = value
        dac[i].g = value
        dac[i].b = value
    wait/upload 0x300 DAC bytes

The right shift by 4 is a little coarse for a 6-bit VGA DAC, but it is cheap on 286/386 machines and keeps the blend loop simple. The upload helper at MAYDAY.000+0xc54 writes a complete 768-byte DAC block.

Tweaked Planar Setup

The part then leaves plain mode 13h and writes VGA registers directly:

3c2 = 63h          miscellaneous output
3c4 sequencer      clocking and memory mode changes
3d4 CRTC           offset register 13h = 50h
3c4 map mask       all planes enabled for clear
A000               clear display memory

CRTC offset 0x50 means 80 bytes per scanline in the active planar layout. Combined with four planes, that maps neatly to 320 logical pixels per row while allowing plane-select drawing.

Chunky-to-Planar Upload

The image upload at MAYDAY.000+0x4a7 runs four passes:

for plane_mask in [1, 2, 4, 8]:
    out 3c4 index 2, plane_mask
    for row in 0..159:
        copy 0x30 bytes from packed picture stream to A000
        dst += 0x70

Each row writes only 0x30 bytes and skips 0x70, so the stored image is a stripe or panel rather than a full 320-pixel row. Plane masks let the part load one bitplane at a time, which avoids runtime bit shuffling during display.

Story-Frame Expansion

The routine around MAYDAY.000+0x7d1 toggles the visible page and expands picture data:

display_page ^= 0200h
CRTC start high ^= 20h

for each plane:
    set map mask
    if stream is RLE:
        while dst != 1f40h:
            count = *src++
            value = *src++
            repeat count times: *dst++ = value
    else:
        copy 0x0fa0 words

The page flip is done by changing the CRTC start registers rather than by moving pixels. 0x1f40 is 8000 bytes, the natural size of one 320x200 planar plane. Four such planes make the complete 16-color image.

The text embedded in this part establishes the story about the Yodel crew, the starship, TCC, and Snooky. Technically those story beats are carried by planar image pages and palette ramps rather than by a general text renderer.

Planar Point Plotter

The point helper at MAYDAY.000+0x89d is a classic Mode-X-style pixel writer:

input:
    AX = x
    CX = y
    color = [1a4a]

row = row_table[y]
byte_offset = row + (x >> 2)
plane = x & 3

out 3ce index 4, plane              ; read map select
old = A000[byte_offset]
if old <= 3fh:
    out 3c4 index 2, plane_mask[plane]
    A000[byte_offset] = color

save byte_offset and plane mask for erase

The test against 0x3f is a simple overdraw rule. Low-valued pixels are safe to replace, high-valued pixels are preserved as foreground or picture detail.

The paired erase/update helper around MAYDAY.000+0x8fb uses the saved byte-offset and plane-mask arrays. That is faster than recomputing where every point used to be, and it avoids clearing the whole screen.

MAYDAY.001: Scripted Pictures and Span Geometry

MAYDAY.001 is the largest recovered file. It enters at MAYDAY.001+0x1a0 and sets DS to 0x833c. It contains mode setup, RLE images, palette event logic, and a substantial projected-geometry renderer.

Backdrop RLE

At MAYDAY.001+0x397 the part expands a large picture into A000:

dst = A000:0000
src = 6130:0000

while dst != fa00h:
    count = *src++
    value = *src++
    if value == 0:
        dst += count
    else:
        repeat count times:
            *dst++ = value

The skip-on-zero rule makes transparent or empty runs cheap. 0xfa00 is 64,000 bytes, the full mode-13h page size.

Script Dispatch

The dispatch loop near MAYDAY.001+0x3fe reads one byte from a script table:

cmd = script[script_index]
script[script_index] = 0

if cmd == 00h:
    use current command
if cmd == ffh:
    exit part
else:
    jump jump_table[cmd]

Resetting the script byte after reading it makes the cue one-shot. This is a small but useful trick for demo timing: the main loop can keep scanning the same table, and event bytes vanish as they are consumed.

Palette Cycling

The palette code around MAYDAY.001+0x433 and +0x4d1 animates one or two important DAC entries rather than uploading a full palette every time:

phase = (phase + step) & 3fh
index = (palette_bank << 6) | phase
rgb = table[index]

DAC[0x0f] = rgb
DAC[0x00] = complement_or_pair(rgb)

This is cheap enough to run inside the frame loop. A single highlighted color can pulse, invert, or move through a lookup strip while the rest of the picture stays stable.

RLE or Direct Plane Loader

The image loader at MAYDAY.001+0x52d chooses a segment from a table and checks the first byte:

seg = segment_table[index]
if seg[0] >= 1:
    decode count/value pairs until one 8000-byte plane is filled
else:
    copy 0x0fa0 words directly

This mixed format is pragmatic. Pictures that compress well use RLE. Pictures with high entropy are copied directly so the depacker does not waste time on a larger encoded stream.

Projected Quadrilateral

The projected-geometry section around MAYDAY.001+0x73e and +0x85f computes four screen vertices from lookup-table motion. The recurring pattern is:

value = table[phase_a] +/- table[phase_b]
depth = table[phase_z] + bias

screen_x = (0x00aa * value_x) / depth + center_x
screen_y = (0x00aa * value_y) / depth + center_y

The constant 0xaa is the perspective scale. Division is expensive, but the part only projects a few vertices per frame. It spends the real time in the span loops that follow.

Edge Tables

After projection, the code prepares 32-entry edge tables at offsets including 0x3178, 0x31b8, 0x31f8, and 0x3238:

delta = endpoint_b - endpoint_a
lookup_index = (delta + 0x13f) << 5

for i in 0..31:
    edge[i] = base + perspective_or_curve_table[lookup_index + i]

The render loop can then use table values directly instead of doing one divide or slope calculation per scanline.

Strip Writer

The strip loop around MAYDAY.001+0x410 writes eight wide strips:

for strip in 0..7:
    left  = edge_table_a[strip]
    right = edge_table_b[strip]
    for x in 0..0x13f:
        dst[x] = texture_or_shade[left/right derived index]

The exact table pairing changes by subroutine, but the shape is constant: precompute edges, then fill long contiguous runs. This is the right tradeoff for 1993 VGA: slow setup is acceptable if the inner loop is mostly indexed loads and byte stores.

Triangle Filler

The triangle helper at MAYDAY.001+0xe45 sorts three vertices by y, then computes fixed-point edge deltas:

sort vertices so y0 <= y1 <= y2

left_step_a  = (x1 - x0) / (y1 - y0)
right_step   = (x2 - x0) / (y2 - y0)
left_step_b  = (x2 - x1) / (y2 - y1)

for y from y0 to y1:
    fill x_left..x_right
    x_left += left_step_a
    x_right += right_step

for y from y1 to y2:
    fill x_left..x_right
    x_left += left_step_b
    x_right += right_step

The caller selects map masks before calling the filler, so the same triangle logic can draw into different VGA planes or layers.

MAYDAY.002: Compact Planar Sprite Kernel

MAYDAY.002 is the smallest part and also the easiest place to see a pure inner loop. It enters at MAYDAY.002+0x30, sets DS to 0x01cb, and uses BIOS mode 0Dh - 320x200, 16-color planar graphics.

Palette and Row Table

The startup shifts a 48-byte palette table right by two:

for i in 0..47:
    palette[i] >>= 2

That converts byte-wide RGB values to the VGA DAC's 6-bit range.

At MAYDAY.002+0x54, it builds a 200-entry row table:

offset = 0
for y in 0..199:
    row_table[y] = offset
    offset += 0x2a

The stride 0x2a is 42 bytes. A normal 320-pixel 4-plane row consumes 40 bytes per plane; the extra two bytes match the CRTC offset change that follows. The part is deliberately using a slightly wider virtual row.

After setting mode 0Dh, it clears A000 and writes CRTC offset register 13h with 0x15. CRTC offset is counted in words, so 0x15 * 2 = 42 bytes per row.

Attribute and DAC Setup

The palette setup reads port 3DAh to reset the VGA attribute flip-flop, then writes 16 attribute entries through port 3C0h. It also uploads 24 DAC bytes from the local table at 0x6338.

The use of both attribute entries and DAC bytes is normal for mode 0Dh: the attribute registers choose logical palette mappings, while DAC entries define the final RGB values.

Four-Plane Background Upload

The block at MAYDAY.002+0xaa uploads the static background with four plane passes:

for plane_mask in [1, 2, 4, 8]:
    out 3c4 index 2, plane_mask
    for band in 0..39:
        copy 0x14 words
        dst += 0x1fd8
        src -= 0x28
        copy mirrored 0x14 words
        dst -= 0x1ffe

The large positive and negative jumps are the interesting part. The code is not just streaming rows. It copies a strip, jumps to the matching area in another page or half-screen, copies the mirrored strip, then returns near the next input row. That creates a symmetric background without storing both halves in the same literal order.

Fade and Page Flip

The loop at MAYDAY.002+0x169 runs for 0x800 iterations. Once the frame counter reaches 0x46, it starts a fade counter at 0x3f.

Each frame:

if frame == 0x46:
    fade = 0x3f

if fade <= 0x3f:
    fade -= 1

visible_start_high ^= 0x20
wait vertical retrace

for each of 0x30 palette bytes:
    out_value = original_value * fade >> 6
upload to DAC

The CRTC start high byte toggles between two 8 KB pages. The part can draw to one page while showing the other, then swap by changing the display start.

Enabling Moving Objects

The block around MAYDAY.002+0x1dc alternates the work page and clears a rectangle:

active_page ^= 0200h
clear 0x0bda words from offset 0x078c

Then, every so often, it copies one word from a staged table at 0x646a into the live velocity table at 0x64ea. Over time this activates up to 32 moving objects rather than starting them all at once.

Object Update

The object loop at MAYDAY.002+0x23a iterates 32 entries:

phase[i] = (phase[i] + phase_step[i]) mod 0x60

x[i] += x_velocity[i]
if x[i] < 0 or x[i] > 0x130:
    x_velocity[i] = -x_velocity[i]

y[i] += y_velocity[i]
if y[i] > 0x2a8:
    y_velocity[i] = -y_velocity[i] + small_adjustment

The y value is larger than screen pixels because it is kept in a fixed-point or half-row domain. Later the loop shifts it before indexing the row table.

Masked 3-Byte, 21-Row Sprite Stamp

The draw kernel is the classic section. It computes a destination byte and a phase-dependent shape offset:

row = row_table[(y >> 1) & even_mask]
dst = row + (x >> 3)
shape = ((phase & 0xf8) ^ (x & 7)) << 8

Then it repeats this for each of four planes:

set sequencer map mask for this plane
set graphics read map select for this plane

for row in 0..20:
    b0 = A000[dst + 0]
    b1 = A000[dst + 1]
    b2 = A000[dst + 2]

    b0 = (b0 & mask[shape + 0]) ^ sprite[shape + plane_base + 0]
    b1 = (b1 & mask[shape + 1]) ^ sprite[shape + plane_base + 1]
    b2 = (b2 & mask[shape + 2]) ^ sprite[shape + plane_base + 2]

    A000[dst + 0] = b0
    A000[dst + 1] = b1
    A000[dst + 2] = b2

    shape += 3
    dst += 0x2a

The stamp is 24 pixels wide, because three bytes in one plane represent 24 horizontal pixels. It is 21 rows tall. The four plane passes produce a complete 16-color object. The AND/XOR composition lets the sprite carry both a cutout mask and color bits without a branch per pixel.

This part is a good example of why planar VGA was still useful for small objects. The CPU never touches individual pixels. It edits three bytes per row per plane and lets the VGA plane selection turn those bytes into colored pixels.

MAYDAY.003: 3D Landscape and 1024 Dots

MAYDAY.003 contains the most explicit description of its own effect. The embedded scroller says it uses "1024 real-time calculated vector-dots" and also mentions a 3D landscape. The code matches that claim.

Stream Remap and Setup

At MAYDAY.003+0x111, the part remaps a byte stream at 0x3688 through a table at 0x4dea until it reaches byte value 1:

while *p != 1:
    *p = remap_table[*p]
    p++

This looks like a compact asset postprocess: store smaller symbolic values in the file, then convert them to display values during startup.

The part then sets mode 13h, copies an image from segment 0x112b, and uploads the palette through the helper at MAYDAY.003+0x55c.

Horizontal Pattern Injection

The loop at MAYDAY.003+0x1b4 injects eight bytes from a phase table into eight horizontal bands:

phase = ring_phase
for each band_offset in [39e8h, 3b28h, 3c68h, 3da8h, ...]:
    A000[band_offset + x] = pattern[1400h + phase]
    phase = next phase

Each band is 320 bytes apart, so the offsets are scanline-related. This gives the scene a moving raster or ground-pattern layer without redrawing the whole screen.

Projection

The 3D setup around MAYDAY.003+0x255 computes four projected points. It uses lookup values from a table segment and several phases:

vx = table[phase_a] - table[phase_b]
vy = table[phase_c] + table[phase_d]
vz = table[phase_z] + bias
if vz > 0x1ff:
    vz = 0x1ff

screen_x = (0x00aa * vx) / vz + 0x00a0
screen_y = -(0x00aa * vy) / vz + 0x006a

The projected pairs are stored around 0x3168..0x3176. Again, division is limited to a small setup phase. The frame-heavy work uses tables.

Edge Interpolation

The edge builder at MAYDAY.003+0x35b converts the projected quadrilateral into four 32-entry tables:

for each edge:
    delta = endpoint_b - endpoint_a
    table_base = (delta + 0x13f) << 5
    for i in 0..31:
        edge[i] = lookup[table_base + i] + base

This is the same philosophy as .001: convert perspective or slope work into short tables, then let the renderer stream bytes.

Strip Renderer

The renderer at MAYDAY.003+0x410 writes eight strips of 0x140 columns:

for strip in 0..7:
    a = edge_a[strip]
    b = edge_b[strip]
    c = edge_c[strip]
    d = edge_d[strip]

    for x in 0..319:
        texture_index = combined edge-derived value
        A000[dst + x] = texture[texture_index]

The exact arithmetic is table-heavy, but the loop shape is clear: eight bands, wide byte stores, and precomputed edge motion. That is a landscape renderer tailored for mode 13h.

Dot Plot and Erase

The point helper at MAYDAY.003+0x56f is simpler than the planar helper in .000:

dst = row_table[y] + x

old_dst = saved_dst[i]
A000[old_dst] = old_restore_or_zero

A000[dst] = color_table[i]
saved_dst[i] = dst

Because mode 13h is chunky, plotting is a single byte store. The erase list keeps the 1024 dots from needing a full-screen clear.

MAYDAY.004: Ending, Stars, Scroller, and CRT Shutoff

MAYDAY.004 is the ending part. Its embedded credits list The Quiz, The Intro, Techno, Ducktale, VU-wrap, and Ending sections; code is credited to Snooky, with a CRT-shut contribution by TCC. The end text also says the music system was entirely coded by TCC.

Planar Ending Setup

The part starts in mode 13h, then switches into a tweaked planar layout:

3c2 = 63h
3c4 sequencer memory setup
3d4 CRTC offset 13h = 28h
CRTC start = bb80h
clear A000

CRTC offset 0x28 is 40 bytes per row, a common 320-pixel planar width. The start value places the visible page near the end of VGA memory.

Star/Spark Seeding

The setup at MAYDAY.004+0x1a4 creates 0x7b point entries:

for i in 0..0x7a:
    dst = table_2a0d[i]
    mask = table_2a10[i]
    set map mask = mask
    A000[dst] = pixel_value
    A000[dst + 0x7d00] = pixel_value
    saved_dst[i] = dst
    saved_mask[i] = mask

It draws into two pages up front so the later page flipping does not reveal an uninitialized star layer.

Ending Background RLE

The loader at MAYDAY.004+0x1d1 expands four planes from a segment near 0x0145:

for plane_mask in [1, 2, 4, 8]:
    set map mask
    count_words = header_for_this_plane
    while count_words remain:
        pair = *src++
        value = high_byte(pair)
        count = low_byte(pair)
        repeat count times:
            *dst++ = value

The stream packs count and value into one word. That saves one byte per run and keeps the depacker very small.

128-Frame Palette Fade

At MAYDAY.004+0x266 the ending fades the image in:

for factor in 0..127:
    wait retrace
    for i in 0..0x2ff:
        dac[i] = palette[i] * factor >> 7
    upload DAC block

The shift by seven matches the 128-frame fade. The multiply gives a smooth ramp without a precomputed fade table.

Scripted CRTC Start

The small loop at MAYDAY.004+0x2b1 reads pairs from table 0x280d and writes them to the CRTC start registers:

for each frame:
    start = crtc_start_table[i]
    out 3d4 index 0ch, high(start)
    out 3d4 index 0dh, low(start)

This gives an inexpensive vertical or page movement effect. The CRTC start changes what part of A000 is scanned out; the image data stays where it is.

Scroller and Row Copy

The end scroller runs through MAYDAY.004+0x37c..0x55d. It saves the relevant sequencer and graphics registers, waits on display timing, then emits glyph rows into planar memory.

The core text-row operation:

char = text_stream[text_index]
glyph = font_base + char * glyph_stride

for glyph_row in 0..12:
    copy 6 bytes from glyph row to A000 row

Six bytes per row is 48 pixels in one plane, enough for chunky-looking large letters after plane composition. The loop also copies the current row to a second page:

A000[dst + 0x3e80] = A000[dst]

That gives it a ready duplicate for page movement and star overlay.

Projected Star/Dot Update

During the ending, the star entries are erased and reprojected:

z = (stored_z - base_z) & 0x01ff
x = (char_x << 7) / z + 0x64
y = (char_y << 7) / z + 0xa0
brightness = (~(z - 0x64)) >> 2
plot(x, y, brightness)

The helper at MAYDAY.004+0x6c6 handles the VGA plane selection and byte write. The divide is per point, so this is costlier than a pure table effect, but the point count in this ending section is modest.

CRT Shutoff

The final routine begins around MAYDAY.004+0x568. It restores drawing state, unprotects CRTC register 11h, and alters vertical timing registers in a tight sequence before returning to text mode.

The visible goal is a monitor-collapse effect:

restore VGA state needed for text return
unprotect vertical retrace/end register
for several timed steps:
    change vertical display and overflow fields
    wait display timing
set text mode
load font
restore text palette
copy final text buffer to B800
fade text palette

The palette fade helper at MAYDAY.004+0x71a waits for retrace and uploads 0x30 DAC bytes. The final text-mode restore is careful enough that the demo can leave DOS in a readable state after intentionally abusing CRTC timing.

Why Mayday Feels Fancy

Mayday's sophistication is not from one giant engine. It comes from many purpose-built real-mode parts chained together:

In that sense it sits between two styles of early-1990s PC demo design. It is not as centralized as later protected-mode demos, but it is much more organized than a loose collection of single effects. The five child executables let Yodel build a story demo with different VGA tricks in each act, while the shared timer/audio code keeps the production tied together.