Analysis model: gpt-5.5 xhigh

Goldorak by Real-Time - Technical Dissection

Scope

Goldorak is a 1995 MS-DOS demo by Real-Time, also listed as Realtime on some catalog pages. It won the PC demo competition at Somewhere In Holland 1995. The demo is far larger than the MZ image DOS initially loads: the front program is an LZEXE-compressed real-mode executable, and the remaining two megabytes are a self-read overlay/resource area.

Public references:

This writeup is based on the scene.org archive, the bundled text files, a DOSBox-X execution check, LZEXE expansion of the front program, and static disassembly of the expanded loader/runtime image. The visible front program contains real visual, audio, VGA, XMS, and overlay routines. It does not contain every visual part as one flat block, so I do not claim complete recovery of all scene scripts or assets.

Old private contact material from the text files is intentionally omitted.

Credits And Requirements

The bundled GOLDORAK.NFO identifies the demo as a Real-Time production dated 23 June 1995 and says it was released at SIH'95. It asks for a 486DX2-class machine, local-bus or PCI VGA, about 575 KB of conventional memory, and about 2.1 MB of extended memory because the whole demo is loaded before running. Sound is optional, but the release supports Gravis UltraSound only and detects it through ULTRASND.

The same note gives this high-level split:

Those notes are useful for mapping the show, but the technical sections below stick to code and data that can be seen in the binaries.

Examined Files

Archive:

1cf300a9839b239ca47afced604fcb58c2d3e8760cc23906267bcf8116679a59  goldorak.zip

Archive contents:

GOLDORAK.EXE  2140667 bytes  1995-07-05 19:08
GOLDORAK.NFO     9804 bytes  1995-07-05 19:06
GOLDORAK.TXT      831 bytes  1995-07-04 22:40
FILE_ID.DIZ       664 bytes  1996-06-27 04:04

Extracted file hashes:

54ffc172a8081e78021991bbaeb298ed186a7e577a65b627ca04ae5dc55b8eff  FILE_ID.DIZ
4fe17019b96877d3a1f12a4e49d8323986e34117b7406621d5868620bcf4b8ac  GOLDORAK.EXE
57d249c909a9c889f7032a9a81ac4ad58d59eb66c1af8a4c072a369cd1e75600  GOLDORAK.NFO
cea29c0564e985068d122aaea10017d2a24884572d2e9c01d65651b4fac44422  GOLDORAK.TXT

After LZEXE expansion of the front program:

cf5a128f3c2ca37a12cea365551dcd93c74029bdff684d429ef009b26c6e4f82  GOLDORAK.UNP.EXE

GOLDORAK.TXT permits non-commercial copying, forbids commercial distribution without written permission, forbids modification without author permission, and places operating responsibility on the user.

MZ Layout And The Overlay Tail

The shipped GOLDORAK.EXE is reported as LZEXE v0.91 compressed. The MZ header describes only the loader/front portion:

physical file length:      2140667 bytes
MZ-declared image length:    45047 bytes
header bytes:                   32
relocations:                     0
minalloc/maxalloc:        0x13bc / 0x13fc paragraphs
initial SS:SP:            0x121a:0x0080
entry CS:IP:              0x0ac6:0x000e
entry file offset:        0xac8e

The expanded front program is a normal 75,008-byte MZ executable:

physical/MZ length:          75008 bytes
header bytes:                 2048
relocations:                   462
minalloc/maxalloc:        0x0c5f / 0x0c9f paragraphs
initial SS:SP:            0x1938:0x1388
entry CS:IP:              0x0000:0x0115
entry file offset:        0x0915

That difference matters. DOS loads the small front image; the front image then opens its own executable and reads the large tail area itself. Treating the 2.1 MB file as one loaded MZ image would misread most of the design.

The original file contains the marker FBOV at file offset 0xaff7. The expanded front contains code that scans its own executable, computes the end of the MZ image, seeks there, and searches for that marker. Once found, it stores:

file handle:        0x1290
overlay base low:   0x1278
overlay base high:  0x127a

It also installs an overlay interrupt path. The setup code writes a handler pointer and uses DOS interrupt-vector services, then the front program can call overlay stubs rather than having every part resident at once.

Self-File And Overlay Lookup

The overlay search routine starts near file offset 0xc0ad in the expanded front. Its important steps are:

c0ec: mov ax,4200h       ; seek in own file
c0f3: int 21h
c0ff: mov cx,0008h       ; read candidate header
c102: mov ah,3fh
c104: int 21h
c10f: cmp word [bp-0a],5a4dh

If the candidate is an MZ header, it computes:

image_bytes = pages * 512 - ((-last_page_bytes) & 0x1ff)

and seeks to the end of that MZ image. If the candidate begins with FB but is not FBOV, it adds the record length plus eight and keeps scanning. When it sees:

c12e: cmp word [bp-0a],4246h ; "FB"
c135: cmp word [bp-08],564fh ; "OV"

it records the overlay base and file handle. That is the point where the front program becomes a loader for the hidden tail.

The actual record load routine at 0xc308 is direct:

c31a: mov dx,es:[0004]     ; record file offset low
c31f: mov cx,es:[0006]     ; record file offset high
c324: add dx,[1278]        ; add overlay base
c328: adc cx,[127a]
c32c: mov ax,4200h
c32f: int 21h              ; seek
c338: mov cx,es:[0008]     ; code/data size
c33d: mov ah,3fh
c33f: int 21h              ; read block

After the code/data block it may read a relocation-word list. The relocation loop is tiny:

c368: shr cx,1
c372: lodsw
c373: mov bx,ax
c375: add es:[bx],di
c378: loop c372

The record contains offsets to 16-bit segment words. The loader adds the load segment delta in DI to each of them. This is a conventional segmented overlay fixup, but compact enough to sit inside a demo-specific loader.

XMS Loader

The demo uses extended memory rather than repeatedly reading from disk during the show. It checks for an XMS driver by reading the interrupt 67h vector and comparing the driver signature stored behind it:

c679: mov ax,3567h
c67c: int 21h
c681: mov cx,0008h
c684: mov di,000ah
c68b: repe cmpsb

Then it uses XMS calls through int 67h:

AH=41h  query free extended memory
AH=43h  allocate extended memory block
AH=47h  lock block
AH=44h  move extended memory block
AH=48h  unlock block
AH=45h  free block

The conventional-to-XMS copy path at 0xc73c works in chunks of up to 0x4000 bytes. Its inner copy is simple and fast:

c756: mov cx,4000h
c759: sub cx,di
c75b: cmp cx,dx
c75f: mov cx,dx
c763: push ds
c764: push es
c765: mov es,[80f8]
c769: mov ds,[1288]
c76d: cld
c76e: rep movsb

The code tracks a 16 KB XMS move window with BX:DI; when DI reaches 0x4000, it increments BX and wraps DI to zero. The matching load-back path at 0xc780 locks the block, performs AH=44h moves, and copies back to conventional memory with the same chunk discipline.

Main Sequencer

The expanded entry at 0x0915 is Borland Pascal style far-call code. It does initial runtime setup, parses the command line, loads front resources, and then switches to mode 13h:

0a19: mov ax,0013h
0a1c: int 10h

The command-line part number is stored around 0x12d6. The NFO says the user can start from part 1 through 4; the code matches that by comparing [12d6] before each part call. Skipping state is stored around 0x12d4, and there is a special flag at 0x7370 for a command-line option.

The visible far-call sequence includes part entries such as:

0612:0020  file offset 0x6940
060f:0020  file offset 0x6910
060c:0020  file offset 0x68e0
0609:0020  file offset 0x68b0
0606:0020  file offset 0x6880
0355:0020  file offset 0x3d70
0352:0020  file offset 0x3d40
0073:0020  file offset 0x0f50
0070:0020  file offset 0x0f20
006d:0020  file offset 0x0ef0

Several of these targets are stubs or table-backed entry points rather than plain linear code. That is another reason to avoid pretending the visual show is one continuous disassembly.

3D Matrix Setup

The routine at 0x2dd4 builds a fixed-point transform matrix from angle indexes. The angle table pair is visible at 0x2c88 and 0x2f58; surrounding part wrappers update angles modulo 0x168, i.e. decimal 360.

The start of 0x2dd4 doubles angle indexes to word offsets, reads sin/cos values, and multiplies them:

2ddb: mov bx,[bp+0e]
2dde: add bx,bx
2de0: mov si,[bp+0a]
2de3: add si,si
2de5: mov ax,[si+2f58]
2de9: imul word [bx+2c88]
2df0: shld dx,ax,07h
2df4: shl ax,07h

The routine stores intermediate 32-bit products, combines them into the matrix terms, then normalizes each term with arithmetic shifts:

2ef1: mov eax,es:[di]
2ef5: sar eax,07h
2ef9: mov es:[di],eax
2efd: mov eax,es:[di+04]
2f02: sar eax,0eh
2f06: mov es:[di+04],eax

The output matrix uses 32-bit fixed-point cells with translation slots. The helper at 0x304a writes translation terms as input words shifted left by seven:

3057: cwde
3059: shl eax,07h
305d: mov es:[di],eax

This is not just decorative setup. The later point transform routines consume that matrix directly.

Point Transform And Projection

The three-component transform helper at 0x2c9c multiplies a 3D point by the matrix and writes three transformed words:

2cb4: mov ecx,es:[si]
2cbd: movsx edx,word [di]
2cc1: imul ecx,edx
2ccf: movsx edx,word [di+02]
2cd4: imul eax,edx
2cd8: add ecx,eax
2cea: imul eax,edx
2cee: add ecx,eax
2cf1: add ecx,es:[si+0c]
2cf6: sar ecx,07h
2cfa: mov gs:[bx],cx

The projection helper at 0x2f8f divides by depth and centers the result on a 320x200 screen. It scales by 2^11, divides by a depth-derived denominator, then adds 0xa0 for X and 0x64 for Y:

2f9f: mov ax,[si+04]
2fa3: shld dx,ax,0bh
2fa7: shl ax,0bh
2faa: idiv bx
2fac: neg ax
2fae: add ax,0800h
2fb1: add ax,ax
...
2fc1: add ax,00a0h
2fd7: add ax,0064h

The clamp rules in the polygon setup later use bounds 0..319 and 0..199, which confirms the 320x200 target.

Sorting Draw Items

There are two quicksort-like routines around 0x624c and 0x62e3. Both sort a table of 4-byte far pointers at 0x52f2. One compares a 32-bit value at the pointed object; the other compares a word at pointed-object offset +4.

The swap is a 386 dword exchange implemented by load/store:

6295: mov eax,[si+52f2]
629a: mov ecx,[bx+52f2]
629f: mov [si+52f2],ecx
62a4: mov [bx+52f2],eax

This is the sort path a 3D renderer needs before drawing face or object records. The exact object layout is still only partly mapped, but the sorting mechanism itself is clear.

Solid Span Fill

The solid polygon routine begins at 0x637a. It first scans vertices to find minimum and maximum Y and X values, rejecting polygons outside the 320x200 range:

63f3: cmp word cs:[2659],013fh ; max X <= 319
63fe: cmp word cs:[2662],0000h ; min X >= 0
6408: cmp word cs:[2633],00c7h ; min Y <= 199
6413: cmp word cs:[264b],0000h ; max Y >= 0

It then picks two active edges around the top vertex. For each edge it computes fixed-point dx/dy and color slope:

64db: sub di,cx       ; delta X
64dd: sub ax,dx       ; delta Y
64e3: cwde
64e5: shl eax,08h
64ef: idiv edi
64f2: mov [04e6],eax  ; X slope
...
650a: sub al,cl       ; color delta
650f: shl eax,08h
6515: idiv edi
6518: mov [050a],ax   ; color slope

The scanline pointer is computed as:

646a: mov di,ax
646c: shl ax,08h
646f: shl di,06h
6472: add di,ax       ; y * 320

The inner loop at 0x665a writes a horizontal run. AH is the current color; DX is the per-pixel color slope:

665a: mov es:[di],ah
665d: inc di
665e: add ax,dx
6660: dec si
6661: jne 665a

After each scanline it advances both edges and both color endpoints:

6684: add ebx,[04e6]
6689: add edx,[04ea]
668e: mov ax,[050a]
6691: add [0506],ax
6695: mov ax,[050c]
6698: add [0508],ax

This is a classic real-mode span filler: edge walkers in 24.8-ish fixed point, one byte per pixel, one color accumulator per endpoint.

Depth-Tested Span Variant

The larger renderer at 0x8ecd and 0x9067 uses the same broad structure but adds per-pixel depth. It projects vertices into arrays at 0x7204, 0x7214, and 0x7218, then enters the span routine at 0x9067.

The active edge setup computes slopes for screen X, color/texture value, and a depth-like value. The inner loop loads the current depth into BX, compares it with a GS buffer entry, and only writes the pixel if the test passes:

943e: mov ebx,edx
9441: sar ebx,10h
9445: mov ecx,eax
9448: sar ecx,10h
944e: cmp bx,gs:[bp+00]
9452: jl 945b
9454: mov es:[di],cl
9457: mov gs:[bp+00],bx

The loop then advances pixel, depth-buffer index, and fixed-point accumulators:

945b: inc di
945c: add bp,0002h
945f: add ax,1234h
9462: adc cx,1234h
9466: add dx,1234h
946a: adc bx,1234h
946e: dec si
946f: jne 944e

The 0x1234 constants are not literal visual constants. They are placeholder words in this disassembly view; nearby code stores computed slope words into CS-owned locations before the span loop runs. The observed behavior is a self-patched or table-patched inner loop for fewer memory reads during each pixel.

This is the strongest recovered visual loop in the front program: fixed-point edge walking, per-pixel depth comparison, byte output, and depth-buffer update.

VGA Plane Transfers

The front program contains both chunky-style and planar VGA helpers.

The routine at 0xc9bf reads the four VGA planes from A000:0000 into a linear destination. It selects each read plane through VGA read-map register index 4 at port 0x3ce, then writes bytes every four positions:

c9d9: mov dx,03ceh
c9dc: mov al,04h
c9de: mov ah,bl
c9e0: out dx,ax
c9e9: lodsb
c9eb: mov es:[edi],al
c9ef: add edi,00000004h
c9f9: inc edi
c9fb: inc bl
c9fe: jne c9d9

The reverse helper at 0xca05 writes a linear source into planar VGA memory. It selects the write plane with sequencer map mask register 2 at port 0x3c4, then walks every fourth byte from the input:

ca1f: mov dx,03c4h
ca22: mov al,02h
ca24: mov ah,bl
ca26: out dx,ax
ca2f: mov al,[esi]
ca33: stosb
ca34: add esi,00000004h
ca3e: add bl,bl
ca40: cmp bl,10h
ca43: jne ca1f

These two helpers are exactly the kind of VGA trick a 1995 DOS demo uses when it wants a convenient chunky work buffer but still needs to present through planar/tweaked VGA modes.

Palette And Morph Helpers

The DAC range writer at 0xcb77 streams palette bytes to ports 0x3c8/0x3c9:

cb7d: mov dx,03c8h
cb80: mov ax,[bp+0c]
cb83: out dx,al
cb84: inc dx
cb8c: mov ax,cx
cb8e: add cx,cx
cb90: add cx,ax       ; 3 bytes per DAC entry
cb9f: rep outsb

Two small byte-morph routines at 0xca4a, 0xcaa9, and 0xcb2e compare current and target byte arrays and move them toward each other. One computes per-byte step data; another applies it; the last one adjusts mismatching bytes by one:

cadf: mov ax,[si]
cae1: mul word [bp+06]
cae6: mov ah,gs:[bx]
caeb: sub ax,[si+02]
caf2: add [si+02],dx
cb14: mov al,[si+03]
cb17: mov es:[di],al

and:

cb58: repe cmpsb
cb5c: mov al,01h
cb60: dec byte [si-01]
cb65: inc byte [si-01]
cb68: jmp cb58

Those are useful for palette/object fades and byte-field interpolation. The call sites decide whether the input arrays are colors, table bytes, or part state.

VBlank, DAC Single Entry, And Keyboard

The basic mode set wrapper is a BIOS call:

c7f6: xor ah,ah
c7f8: int 10h

There are two vertical-retrace waits. One waits for retrace high and then low, which gives a full edge gate:

c7fe: mov dx,03dah
c801: in al,dx
c802: and al,08h
c804: je c801
c806: in al,dx
c807: and al,08h
c809: jne c806

The one-entry DAC writer is the usual 0x3c8, then RGB to 0x3c9:

c818: mov dx,03c8h
c81b: mov al,[bp+0c]
c81e: out dx,al
c81f: inc dx
c820: mov al,[bp+0a]
c823: out dx,al
c824: mov al,[bp+08]
c827: out dx,al
c828: mov al,[bp+06]
c82b: out dx,al

Keyboard polling uses BIOS int 16h, and the IRQ path at 0xc871 reads port 0x60, updates a key-state table, and acknowledges the PIC through port 0x20. That is how ENTER can skip parts and ESC can leave the demo without waiting for a part script to finish.

Gravis UltraSound Detection

The GUS setup starts at 0xaf19. It gets the PSP with DOS AH=62h, follows the environment segment from PSP offset 0x2c, and scans strings for ULTRASND=2...:

af19: mov word [10f2],0200h
af1f: mov ah,62h
af21: int 21h
af28: mov ax,es:[di]
af2b: mov es,ax
...
af3b: cmp dword es:[di],52544c55h ; "ULTR"
af45: cmp dword es:[di+04],444e5341h ; "ASND"
af50: cmp word es:[di+08],323dh ; "=2"

It converts the next digit to a port delta and adds that delta to every GUS port variable:

af5f: mov bl,es:[di+01]
af63: sub bl,30h
af66: shl bl,04h
af6b: add [10f2],bx
af83: add [10fe],bx
af8f: add [1104],bx

The following hardware test writes GF1 register numbers to the select port, writes data, and uses repeated reads from the base port as delay. For example, registers 0x4c, 0x41, 0x45, 0x49, and 0x0e are touched during reset and memory-bank probing. The detection routine eventually writes test bytes to GUS DRAM and reads them back to estimate usable memory.

S3M Loader And Sample Upload

The music loader at 0xb0a9 accepts either an already loaded module segment or a filename. In the file path it opens, seeks to the end to get size, allocates DOS memory, and reads the file in chunks no larger than 0xfff0 bytes:

b0b8: mov ax,3d00h
b0c0: int 21h
b0cc: mov ax,4202h
b0d3: int 21h
b0f6: mov ah,48h
b0f8: int 21h
b115: mov cx,0fff0h
b11d: mov ah,3fh
b11f: int 21h

It verifies an S3M module by checking SCRM at offset 0x2c:

b139: mov ax,[779a]
b13c: mov es,ax
b13e: cmp dword es:[002c],4d524353h
b148: jne b287

It then reads S3M header fields:

ES:0020  order count
ES:0022  sample/instrument count
ES:0024  pattern count
ES:0030  global volume-ish field copied to 0x7b81
ES:0031  initial speed-ish field copied to 0x7b7b
ES:0032  tempo-ish byte passed to 0xb32c
ES:0033  high bit copied to 0x7b87

The order list is copied from ES:0060 into 0x77a0, padded with 0xff, and sample headers are walked through the parapointer table.

The sample upload byte loop at 0xb2fe is very compact:

b2fe: mov dx,[10fe]
b302: mov al,43h
b304: out dx,al
b305: mov dx,[1100]
b309: mov ax,si
b30b: out dx,ax
b30c: mov dx,[10fe]
b310: mov al,44h
b312: out dx,al
b313: mov dx,[1102]
b317: mov al,bl
b319: out dx,al
b31a: mov dx,[1104]
b31e: mov al,gs:[di]
b321: add al,80h
b323: out dx,al
b324: inc di
b325: add si,1
b328: adc bl,0

It sets the GF1 DRAM pointer low and high registers, converts signed sample data to unsigned by adding 0x80, writes the byte, then advances the 24-bit-ish GUS DRAM pointer held in BL:SI.

Timer Player

The timer/IRQ handler begins at 0xb54d. It saves state, sends EOI to the PIC, switches to the player data segment, increments counters, and loops over three logical streams:

b54d: pushf
b54e: cli
b54f: pushad
b553: mov al,20h
b555: out 20h,al
b559: mov ax,10a3h
b55c: mov ds,ax
b564: inc dword [7496]
b569: inc dword [749a]
b56e: xor bx,bx

Each active stream updates a fractional tick accumulator:

b584: mov ax,[bx+7b59]
b588: add [bx+7b65],ax
b58c: mov ax,[bx+7b57]
b590: adc [bx+7b63],ax
b594: jae b59b
b596: call b7c9

On carry it steps the pattern interpreter. On first and second ticks it calls voice update routines instead. This is a typical tracker replay shape: pattern rows on accumulated tempo, per-tick effects in between.

The voice update code at 0xb616 writes GF1 voice registers. It sets start, end, loop, current position, frequency, volume, and control bytes. The volume path clamps to 0..0x3f, multiplies by a global volume byte, and looks up a hardware volume value at 0x11c6:

b76a: mov al,[di+16]
b76d: add al,[di+17]
b772: xor al,al
b778: mov al,3fh
b780: mul byte [bx+7b81]
b784: shr ax,06h
b789: add bx,bx
b78b: mov ax,[bx+11c6]
b78f: out dx,ax

The pattern interpreter at 0xb7c9 dispatches effects through a jump table at CS:1282:

b80b: mov ax,[di+1a]
b80e: mov bl,al
b812: add bx,bx
b814: jmp word cs:[bx+1282]

Recovered effects include:

The period-to-GUS-frequency helper at 0xc068 is called after period changes. I did not fully annotate that conversion in this pass, but the call sites and dirty flags make the role clear.

What Is Proven Versus Inferred

Proven by code:

Inferred from code plus the NFO:

The result is a good example of mid-1995 DOS demo engineering: a small loader front, a big self-read tail, XMS staging, GUS-only music, fixed-point 3D, and multiple VGA paths tuned around what a fast 486/Pentium-era machine could do.