Documentation développeur en anglais

- TECHNIQUE.en.md, ANALYSE.en.md : documentation technique et analyse du jeu
- SETTINGS.en.md, MODS.en.md : réglages et format des mods (les versions
  françaises restent la référence)
- liens anglais (README, guide, textures, feuille de route) vers ces pages,
  pages wiki Technical, Game-analysis, Settings, Modding

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
linkatplugandClaude Opus 5.5 committed 2026-12-05 07:27:25 +01:00
1 parent 74566648ea
commit 5f85902675
12 files changed
+1348 -13

No files matched your search

+3 -3
View File
@@ -40,10 +40,10 @@ troubleshooting.
The full roadmap is in [docs/ROADMAP.en.md](docs/ROADMAP.en.md).
### 🔍 [Technical documentation: what we know about the game](docs/TECHNIQUE.md) (in French)
### 🔍 [Technical documentation: what we know about the game](docs/TECHNIQUE.en.md)
The executable, the game loop, file formats, the cutscene language, game versions and how the
recompilation works. The full reverse-engineering notebook: [docs/ANALYSE.md](docs/ANALYSE.md).
recompilation works. The full reverse-engineering notebook: [docs/ANALYSE.en.md](docs/ANALYSE.en.md).
## How it works
@@ -134,7 +134,7 @@ build\tucker.exe --son
| `-v` | verbose log |
**F11** or **Alt+Enter**: toggle fullscreen. **F12**: settings menu. All options and settings
keys: [docs/SETTINGS.md](docs/SETTINGS.md). Mods and HD pack: [docs/TEXTURES.en.md](docs/TEXTURES.en.md) (tutorial) and [docs/MODS.md](docs/MODS.md) (format, in French).
keys: [docs/SETTINGS.en.md](docs/SETTINGS.en.md). Mods and HD pack: [docs/TEXTURES.en.md](docs/TEXTURES.en.md) (tutorial) and [docs/MODS.en.md](docs/MODS.en.md) (format).
## Layout
+1 -1
View File
@@ -44,7 +44,7 @@ La feuille de route complète est dans [docs/ROADMAP.md](docs/ROADMAP.md).
L'exécutable, la boucle de jeu, les formats de fichiers, le langage des cinématiques, les versions du
jeu et le fonctionnement de la recompilation. Le carnet de rétro-ingénierie complet :
[docs/ANALYSE.md](docs/ANALYSE.md).
[docs/ANALYSE.md](docs/ANALYSE.md). 🇺🇸 Toute la documentation technique existe aussi en anglais.
## Fonctionnement
+786
View File
@@ -0,0 +1,786 @@
# Game analysis: TUCKER.EXE and its files
🇺🇸 English · 🇫🇷 [Français](ANALYSE.md) · Overview: [technical documentation](TECHNIQUE.en.md)
> **Where this document comes from.** It is the reverse-engineering notebook kept while studying the
> game, before and during the recompilation: disassembly of `TUCKER.EXE` (Ghidra, a home-made
> disassembler), reading the data files, comparison with the original game under DOSBox. It is published
> as is, with a few corrections. This is a translation of the French original ([ANALYSE.md](ANALYSE.md)),
> which remains the reference.
>
> - When it talks about **"the engine"** (Bud's walk, x86 interpreter in Python, `tucker/core/…`), it
> means the **`tucker-viewer` prototype**, a Python reimplementation written first to understand the
> game. The current recompilation, on the other hand, **runs the original code**: it does not need to
> reproduce these behaviours, they come straight from `TUCKER.EXE`.
> - The addresses are those of the **French version** of the CD. The other versions have a `TUCKER.EXE`
> whose code is shifted (see [technical documentation, § Versions](TECHNIQUE.en.md#7-game-versions)).
> - The files cited in `extracted\pe\` (disassembly, call graph, tools) are local working files, **not
> published**: they are derived from the game's executable.
> - No game code, image or sound is reproduced here: only addresses, formats, behaviours and short
> quotes of text, useful for interoperability and preservation.
> - Game text is quoted from the French version, with an English gloss.
The addresses are **LE linear addresses**: object 1 (code) is at 0x10000 and object 2 (data) at 0x40000.
They are also the addresses of `extracted\pe\TUCKER_flat.exe` in Ghidra.
Conventions: names in quotes ("loadFile") are mine. Arguments follow the Watcom convention **EAX, EDX,
EBX, ECX**. Ghidra wrongly shows them as `param_n` and `extraout_ECX`.
## 1. CD contents
The CD (591 MB ISO image) holds 5,841 files, mostly in `TUCKER\`.
| Ext. | Count | Role |
|---|---|---|
| WAV | 4,758 | voices `SPEECH\SAM####.WAV` (4,196), music `MUSIC\`, effects `FX\` |
| SPR | 654 | sprites `SPRITES\A##_##` (Bud), `C##_##` (characters), others |
| PCX | 317 | backgrounds, walk masks, interface: all 320×200, 8-bit |
| C | 28 | **not C code**: tables and text scripts (see §4.5) |
| FLC/FLR/PIC | 16 | intro animations (`INTRO.EXE`) |
| DIG | 9 | Miles AIL 3.02 sound drivers (SB, SB Pro, SB16, GUS…) |
| EXE | 5 | `TUCKER.EXE` (the game), `INTRO.EXE`, `SETSOUND.EXE`, `INSTALL.EXE`, `DOS4GW.EXE` |
| DTA/DAT/CFG/INI/TXT | 7 | `CHARSIZE.DTA`, `TUCKER.CFG`, `DIG.INI`, `INFOBAR.TXT`… |
The main executable is **`TUCKER\TUCKER.EXE`** (284,677 bytes). `TUCK.BAT` and `BUD.BAT` start it after
`INTRO.EXE`.
## 2. Binary format and REA/Ghidra setup
- It starts with an MZ header whose `e_lfanew` is 0x2A50. At that offset is an **LE (Linear
Executable)** header: 32-bit protected mode, started by the **DOS/4GW** extender. The compiler is
**Watcom C/C++32**: the string "WATCOM C/C++32 Run-Time system … 1988-1994" follows the entry point.
- The LE header describes 53 pages of 4 KB, with no name table and no debug info.
- Object 1: code, base 0x10000, size 0x2DA9A, 32-bit.
- Object 2: data, base 0x40000, size 0x12330. The stack is at the top of this object (ESP =
obj2:0x12330).
- **Entry point: obj1:0x1E318, i.e. 0x2E318** (Watcom's `_cstart_`).
- 8,389 relocations, all of type "internal 32-bit offset".
- **REA rejects the LE** (`unsupported LE executable in MZ image`), even though Ghidra 12.2 is available
in REA. So I wrote `extracted\pe\outils\le2pe.py`. It rebuilds the memory image, applies the
relocations and wraps everything in a flat PE32. REA/Ghidra always load it at base 0x1000, so I placed
the sections at RVA = LE base − 0x1000: Ghidra addresses are then equal to LE addresses.
## 3. Architecture
```
_cstart_ 0x2E318 ──► __CMain 0x37474 ──► main 0x12300 (EAX=argc, EDX=argv) ──► exit 0x28892
main 0x12300
├─ mouse(0) 0x113E0 ............. int386(0x33) fn 0: missing → "NO MOUSE DRIVER DETECTED"
├─ malloc(0x563650) 0x10010 ..... a single 5.6 MB block, split into ~18 fixed areas
│ (+0x15E00 load buffer [0x46858], background buffers, sprites…)
├─ initSound 0x114D4 / timer 0x12274: AIL_register_timer(0x12250) + AIL_set_timer_frequency(46 Hz)
├─ getVideoMode 0x10098 ......... int386(0x10) AH=0Fh, stored in [0x4FD0C]
├─ initGame 0x12528 ............. tucker.cfg, infobar.txt, .enc/.c texts, nofiles.dta
├─ setVideoMode(0x13) 0x10064 ... int386(0x10) AH=0: VGA 320×200×256
├─ gameLoop 0x129DC
└─ stop timer 0x122C8, restore video mode, stop sound 0x11598, free 0x10040
```
The **game code** spans roughly 0x10010–0x27200. Beyond that are the Watcom C library and **Miles AIL
3.02**. All the hard-coded `int 21h` (48 sites) and `int 31h` (DPMI, 30 sites) are **in these
libraries** (addresses ≥ 0x27D98). The game code contains no `int` instruction: it goes through
**`int386(n, &in, &out)` at 0x27D03**, which ends in the `_DoINTR` dispatcher (0x377CC, one `int`
instruction for each of the 256 values), or through the C library.
| Service | Function | Detail |
|---|---|---|
| Mouse int 33h | `0x113E0`(fn=EAX, &x=EDX, &y=EBX, &buttons=ECX) | fn 0 = reset/detection, 3 = position+buttons, 4 = set cursor. `0x113A8` checks the 33h vector (int 21h AX=3533h). |
| Keyboard | `0x10D30` → `_bios_keybrd` 0x28B43 (int 16h) | returns the *scancode* (AX>>8) |
| Video int 10h | `0x10064` (mode), `0x10098` (read mode) | |
| VGA palette | `0x10204` | `outp(0x3C6,0xFF)`, `outp(0x3C8,i)`, `outp(0x3C9,r/g/b)` |
| Whole palette | `0x10CCC` | 256 entries from R `0x46010`, G `0x46210`, B `0x46410` |
| Fades | `0x1053C` (in), `0x1062C` (out) | ±5 per step and per component |
| Video memory 0xA0000 | `0x10D88` (display), `0x10820` (clear) | copies 200 lines × 320 from a **work buffer 640 px wide** (pitch 0x280) |
| Rectangle copy | `0x112DC`, `0x1133C` | destination or source with pitch 640 |
| RLE sprite | `0x10F18`(dst=EAX, src=EDX, w=EBX, h=ECX) | see §4.4 |
| Timer | callback `0x12250` | `[0x46634]++` (frame pacing), `[0x46804]++` |
### Main loop `0x129DC`
An inner loop runs once per logical "tick", and an outer loop handles rendering and input:
1. **Pacing**: `[0x46808]` counts the ticks. After `[0x4228C]` ticks, the loop waits for the 46 Hz
timer `[0x46634]` to catch up.
2. **Input**: mouse `0x13560` (int 33h fn 3), scrolling and cursor.
3. **Logic**:
- opening fades (`[0x4ECB8]`);
- cutscene script if `[0x4FB34]` (`0x21BA8` then the interpreter `0x20A00`);
- Bud's animation `0x17B80`, characters `0x19200` and `0x19100`, objects `0x200E4` and `0x16C78`;
- location change `0x178C4` if `[0x47A24]` changed;
- interface panel in mode 0x8C (game area 140 lines high).
4. **Rendering**: copy of the background (`[0x46890]`, animated image if `[0x42290+loc*4]` ≥ 4), objects
`0x16DE0`, sprites `0x1A4A8` into the 640 px buffer, cursor, texts, then `0x10D88` which sends it
all to 0xA0000.
5. **Keyboard** `0x10D30`:
- P (0x19) → pause (`0x25CC0` and `0x25D20`). It ends on a new press of P; keys 1 to 5 are read
during it.
- In debug mode (`[0x46714]` ≠ 0):
- F1 "next location";
- F2: displays;
- F3 "object number";
- F4: quit;
- F5 to F10: force Bud's animation no. 1 to 6;
- Esc: `0x2693C`, then exit.
6. Ends when `[0x4681C]` is 1 (quit) or `[0x47990]` is 1 (victory: `congrat.pcx`).
## 4. File loading and formats
### 4.1 Generic loading: loadFile `0x100CC` (dest=EAX, level=EDX)
- The name is prepared beforehand in the global buffer **`0x41F68`** by `strcpy` (0x27D1E). The digits
in it are often rewritten byte by byte.
- If `level > [0x46718]` (the first byte of `tucker.cfg`), the path is prefixed with the CD path
`[0x46720]` = "X:\tucker\", with X = `tucker.cfg[1]` + 0x40.
- The function chains `open(O_BINARY)` 0x27D74, `read` 0x27FC2 (int 21h) and `close` 0x280D5. It
returns the size read, also stored in `[0x46614]`.
- Writing is `0x10184`(src=EAX, size=EDX).
### 4.2 PCX: loadPCX `0x10864` (dest=EAX, mode=EDX)
- `fopen(name,"rb")`, then the **128 header bytes are skipped without being read**. The format is ZSoft
v5, 8-bit, 1 plane, **always 320×200** (checked on all 317 PCX files).
- PCX RLE: a byte ≥ 0xC0 gives `n = byte − 0xC0` repetitions of the next byte, otherwise it is a literal
pixel. Decoding stops at 64,001 bytes (0xFA01).
- If `mode ≠ 0`: `fseek(-768, SEEK_END)`, then 256 × 8-bit RGB are read and reduced to 6 bits (`>>2`)
for the DAC in `0x46010/0x46210/0x46410`. The 0x0C marker before the palette is ignored. With
`mode = 2`, the sound is kept fed during the read (`0x12208`).
- On failure: black screen, then "READ ERROR READING FILE:" followed by the name, then `exit`.
### 4.3 Backgrounds: `0x1383C` and `0x13A28` (x=EAX, type=EDX)
- `[0x42290 + loc*4]` gives the number of images of the location (1 to 4). The names are
**`locNN.pcx`** or **`locNNa/b/c/d.pcx`**, plus the masks **`pathNN[a|b].pcx`**.
- Each PCX is decoded into the load buffer, then copied line by line (`[0x4FD04]` = 140 lines, or 200
beyond location 0x48) into the **640 px work buffer** `[0x4685C]` at x = 0 or 320. The `path` masks go
to `[0x4689C]`.
- Each 320×140 panel (0xAF00 bytes) is then stored in `[0x4688C]` at positions +0, +0xAF00, +0x15E00
and +0x20D00. These are the images the loop alternates for animated backgrounds.
- **Role of the layers (checked in `0x1383C` and `0x129DC`)**:
- 1 image: `locNN.pcx` + `pathNN.pcx`, 320 px room;
- 2 images: `a` at x=0 and `b` at x=320, 640 px room, with `pathNNa/b`. Scrolling is only allowed in
this case (`0x19100`);
- 4 images (locations 15, 22, 40, 46, 52, 63, 64, 70): 320 px room; a counter 0..39 `[0x4FCE0]` picks
image `counter/10`, so a→b→c→d every 10 frames;
- no location has 3 images. `LOC15.PCX` exists next to `LOC15A..D` but is never loaded.
- **`path` mask: `0x17310`(x, y)** answers "walkable" if the mask byte is > 0, or if a script forces the
walk (`[0x4F050]`, `[0x4FBA4]`). In locations 0x1A and 0x20, it tests y−3.
- Values 1, 2 and 255 are therefore equivalent for walking.
- The 150 pixels at 255 in `PATH09B.PCX` (x 307–319, y 116–135) form a walkable strip on the right
edge, with no special handling.
- **`ROCHPATH.PCX`** (location 1 only) is loaded in place of the 3rd panel (`[0x46800]`). It is not used
for Bud: `0x221A8` moves small creatures over its pixels > 0, trying 8 directions (`0x2206C`) and
avoiding the other positions in `0x420E4…`. The code never distinguishes 2 from 1.
### 4.4 Sprites (`.SPR`)
- Loading Bud's animations: `0x19F98`. For `aLL_NN.spr` (location LL, animation NN =
1..`[0x44414+loc]`), all the files are concatenated into `[0x4ED14]`, with their offsets in
`0x4ECC4[]`.
- Characters use `cLL_NN.spr`.
- The format was **checked on all 654 files: 17,021 frames out of 17,022 decode exactly**. The only
exception is frame 19 of `C24_09.SPR`: a final transparent run overflows by 51 pixels (2,781 instead
of 2,730) and spills 3 bytes into the next frame. It has no visible effect.
```
uint32 frameCount
uint32 offset[frameCount] ; from the start of the file, offset[0] = 4 + 4*n
for each frame, at offset[i]:
+0 uint16 width (w)
+2 uint16 height (h)
+4 int16 ax ; offset from the animation's anchor point: IGNORED by the engine
+6 int16 ay ; same, IGNORED
+8 int16 x ; absolute position of the top-left corner (0..319, or x in the 640 px room)
+10 int16 y ; absolute position of the top-left corner (0..199)
+12 RLE data: 0x00, n → n transparent pixels
other b → 1 pixel of colour b
```
- **Role of the 4 fields (checked)**:
- The engine reads `x`/`y` (+8/+10) only in the two drawing routines.
- `0x1A4A8` (characters, `cLL_NN.spr`): destination = `y*640 + x + 0x4F1A8[i]`, where `0x4F1A8[i]`
is a per-character offset, advanced on each frame by `0x4F228[i]` (speed). Clipping takes the
scroll `[0x46854]` into account.
- `0x1A0A4` (Bud's special animations, `aLL_NN.spr`): destination = `[0x4685C] + y*640 + x +
[0x4ED24]`. 320 is added if Bud is in the right half, plus three hard-coded corrections: location
0x1D, location 0x3A and location 0x16 (for the latter, y += `[0x4B558]`).
- `ax`/`ay` (+4/+6) are read into local variables (`[ebp-0x10]`/`[ebp-0xC]` in 0x1A0A4,
`[ebp-0x20]`/`[ebp-0x1C]` in 0x1A4A8) and then **never read again**. No other code reads bytes
+4..+7.
- Check against the data: in the 455 files where `ax`/`ay` are not zero, `(x − ax, y − ay)` is
**constant over every frame of the file**. They are therefore offsets from an anchor point specific
to the animation, left by the cutting tool, and the engine uses the absolute positions directly.
- No collision box is stored in the SPR files. Clickable areas come from `CHARPOS.C` and `DATA4.C`.
- Across the 17,022 frames, `x + w ≤ 320` and `y + h ≤ 200`.
- Display: `0x10F18`(dst, src = frame + 12, w, h) as a plain copy. The variant `0x11038` is used if
`0x4F94C[i] == 99`, and the mirrored version `0x11168` otherwise (flip `0x4F96C[i]`).
- Bud's walk **does not use SPR files**. It cuts rectangles out of `bud_N.pcx`, `peg_N.pcx` or
`mac_N.pcx`, described by `CTABLE01.C` (see 4.9). `0x17B80` is Bud's state machine: direction,
CTABLE sequence or special animation.
### 4.5 Text files (`.C` and `.ENC`)
- For each file, the game first tries `xxx.enc`, then `xxx.c`. Decoding `0x124E0`(buf=EAX, len=EDX)
subtracts 0x80 from each byte if `[0x41FBC]` is set. The French CD only has `.c` files, so plain text;
the English, German and Spanish versions ship `.enc` files (same text, each byte + 0x80).
- Common structure:
- **`!!NN`** sections (location number), found by `0x15ED8`;
- **`dw a,b,c,…`** lines, found by `0x15F70`, which searches for "dw" up to 110,000 bytes;
- fixed-width decimal numbers read by `0x15DC0`(buf=EAX, offset=EDX, digitCount=BX). The function
reads exactly 2, 3 or 4 characters:
- a `-` gives −1;
- a space in the last position counts as 9;
- a result outside 0..10000 gives −2.
- The loaders **advance by a fixed number of characters** (width + 1) without looking at the
separator. `,`, `-`, `.` or `;` are therefore equivalent: the file contains `dw 04-178,040` or
`bus,014;wa+;`. A modern parser must read **by fixed columns**, not with `split(',')`.
- Everything after the last field read is ignored (`;` and `//` comments, free text).
- The text is in **CP437** (é = 0x82, à = 0x85…).
Loaders, found through the references to the file names:
| File | Loader | Contents |
|---|---|---|
| `INFOBAR.TXT`, `DATA5.C`, `BGTEXT.C`, `CHARNAME.C`, `CSDATA.C` | `0x12528` (init) | loaded raw into memory |
| `OBJTXTn.C`, `PTnTEXT.C` | `0x12858` | texts of part n (the digit is replaced in the name) |
| `DATA.C` | `0x16654` | rectangles of the scenery objects in `scrobjNN.pcx` |
| `DATA3.C` | `0x168F4` | pick-up objects per location |
| `DATA4.C` | `0x15FDC` | clickable areas without an object, and exits |
| `CTABLE01.C` | `0x17690` | rectangles of Bud's frames in `bud/peg/mac_N.pcx` |
| `CTABLE02.C` | `0x17A00` | Bud's standard animation sequences |
| `ACTION1/2/3.C` | `0x18594` | "verb + target → result" rules |
| `CHARPOS.C` | `0x20354` | characters per location, plus their animation lists |
| `FX.C` (named `fx.enc`) | `0x2578C` | per-location sound ambience |
| `CHARSIZE.DTA` | `0x270EC` | 256 character widths, into `0x42408[]` |
| `CREDITS.TXT` | `0x2693C` | credits |
- Files **not referenced** by the executable: `ACTION.C`, `DATA2.C`, `EXIT.C`, `COMMON.C`, `PT1.C`,
`TEST.C`, `OBJTXT.C`, `CSDATA1.C`. They are development leftovers or earlier versions. The engine only
loads `csdata.c`.
- Free-text files, one entry per `\r\n` line: `0x140A4`(n, buf) returns the start of the n-th line.
Lines of dialogue are located by `tpo` (base) + number (see 4.8). The matching voice is
`SPEECH\SAMxxxx.WAV`, with xxxx = `(part−1)*3000 + base + n − 1`.
- `INFOBAR.TXT` holds the verbs of the bar (in the French version: Aller, Regarder, Parler, Ouvrir,
Fermer, Donner, Prendre, Déplacer, Utiliser, "avec", "à" = Go, Look, Talk, Open, Close, Give, Take,
Move, Use, "with", "to"), followed by the location names.
- The cutscene interpreter is **`0x20A00`** (see 4.8). `0x21BA8` finds the `!!NN` table, advances to the
n-th `dw` line (n = `[0x4FB34]`), then calls `0x20A00` as long as it returns 0. It prints "Table not
found", "dw not found" or "Instruction not recognised" on error.
### 4.6 Saved games: `0x25424` (slot=EAX)
- **`savegm.NN`** is 2,000 bytes, i.e. 500 dwords:
- [0..299]: game flags `0x47800[300]`;
- [300..339]: copy of `0x4B5E8` (40 dwords);
- [340..459]: copy of `0x4B3C8` (120 dwords);
- +0x730: location number `[0x4680C]`;
- +0x734 and +0x738: Bud's position `[0x43F0C]` and `[0x43F10]`;
- +0x73C and +0x740: `[0x4B688]`.
- **`nofiles.dta`** is 10 bytes: byte 0 is the highest save number, byte 4 the last one used.
- Loading `0x255D0` then `0x2572E`: flags, inventory, object state, location `[0x468C8]` and Bud's
position, then the location is loaded. The format is reused as is by `tucker/core/savegame.py`, and
the files stay readable by the game under DOS.
- Menu: click on inventory object 30 (`0x15C56`, `[0x468D4] = 2`), then LOAD / SAVE / play / QUIT
(CHARGER / SAUVEGARDER / jouer / QUITTER in the French version) and choice of the number (mode 3,
`0x1524C`). Detail of the areas in `tucker/core/savemenu.py`.
### 4.7 Sound
- Voices: `0x11F64`(n=EAX). The file is `X:\tucker\speech\samNNNN.wav`, where X is the CD drive and
NNNN is written at positions 0x14 to 0x17. It is opened in binary mode, its WAV header is read, then
it is streamed by AIL.
- Music `music\musN.wav` (`0x11AE8`), effects `fx\fxN.wav` (`0x11784`), driver chosen in `DIG.INI`
(Miles AIL 3.02). AIL volumes from 0 to 127.
- **`FX.C`, read by `0x2578E`** on each location change. Section `!!NN`, first `dw` line:
- `count(2)`, then count entries `fx(3) volume(3) type(2)` into `0x46CE4`, `0x46D5C`, `0x46DD4`, plus
fields depending on the type:
- type 5: `x(3) slope(3)` into `0x46838`, `0x4683C` (the slot is noted in `0x46830`);
- types 6 and 8: `anim(2) frame(3) source(2)` into `0x46F3C`, `0x46FB4`, `0x46EC4`;
- type 7: like 6, then `flag(3) value(2) anim2(2) frame2(3) value2(2)` into `0x4702C`, `0x470A4`,
`0x47194`, `0x4711C`, `0x4720C`.
- Between two entries, control characters are skipped (`0x25AA4`): the list can continue on the
following lines (location 40: 26 effects over 13 lines).
- Type 8: no file; the slot reuses the sound of slot number `fx`, already loaded, then becomes type 6.
- Next `dw` line (`0x25B56`), **music**: `count(2)`, then count entries `flag(3) value(2) music(3)
volume(3) type(2)`. Only those where `0x47800[flag] == value` are loaded, into `0x47288`, `0x47298`,
`0x472A8` (count in `0x47284`). Example in location 2: `mus9` once while flag 195 is 0, then
`mus51` looping.
- Data errors kept as they are: location 40, slot 12 of type 8 pointing to slot 16, not loaded yet;
location 68, `///122`; `fx226.wav` missing (location 54).
- **Effect types**:
- playback `0x118B0`(sound, slot, volume): looped for types 2, 5 and 7 (type of the slot played),
once otherwise;
- on arrival (`0x25D20`, first 29 slots): types 1, 2, 5, and 7 if `flag == value`; then the loaded
music with type > 0 (`0x11C14`, looped if type 2);
- types 3 and 4, on each tick (`0x25E28`), if slot 0 is not playing (`[0x46644]`): each type 3 (or 4)
effect plays in slot 0 if `rand() > 0x7E2C` (or `> 0x7FFB`), only one per tick. These draws use
the same `rand()` as the characters;
- type 5, on each tick (`0x25EEC`): volume = volume − |Bud's x − x| × slope / 10, at least 0;
- types 6 and 7: sound tied to an animation frame. Source 0: Bud's special animation (`[0x4ED18]` =
number, `[0x4ED1C]` = frame, `0x25F74`); source 1: any character (`0x4F104[j]` = state,
`0x4F144[j]` = frame, `0x260C4`). Type 7 sets `flag := value` when the sound starts, and on
`(anim2, frame2)` sets `flag := value2` and stops it (location 8: `fx186` looping until frame 22 of
special animation 2). The EXE restarts the sound on every tick while the frame stays on screen; the
engine only triggers it once per arrival on the frame;
- type 0: played only on request (`fx,NN` in scripts, `fx` column of `ACTIONn.C`).
- Location change: `0x25CC0` stops all the effects (`0x11614`) and all the music (`0x115DC`).
- Order within a tick: characters (`0x200E4`), character sounds (`0x260C4`), camera (`0x19100`), Bud's
sounds (`0x25F74`), …, random ambience (`0x25E28`), type 5 volume (`0x25EEC`).
### 4.8 Cutscene instruction set (`CSDATA.C`, `0x20A00`)
Mechanism:
- Decoding tests `P[0]`, then `P[1]` or `P[2]`, against the letter table `0x44790`
(`a b c d e f g h l m n o p r s t v w x +`).
- `N` is a character digit (0 to 5), `NNN` a 3-digit number, `NN` a 2-digit number. The width is
imposed by how far the pointer `[0x4FB40]` advances.
- Return code:
- 0: next instruction in the same tick;
- 1: yields until the next tick, or until the wait is over;
- 2: end;
- 3: jump (`sse`).
| Instr. | Format | Effect | Var. |
|---|---|---|---|
| `pan` | `pan,NN` | interface panel mode (00 = bar hidden during the scene) | `0x468D4`, `0x468D8=1` |
| `bua` | `bua,NNN` | Bud plays special animation NNN (`aLL_NNN.spr`) from the 1st frame | `0x4ED18` |
| `bub` | `bub,NNN` | Bud plays standard sequence NNN of `CTABLE02` | `0x4D7D4=0x4CE04[NNN]` |
| `buc` | `buc,NNN` | plays list NNN (counted from 0) of Bud's lists in `CHARPOS`: 1st number = `aLL_NN.spr` file, then the frames (from 1), 99 = end | `0x2084C` |
| `b?d` | `bsd,NN` (`bcd`) | Bud's direction: 1 = frame 0x11, 2 = 0x10, 4 = 0xF, other = 0x10 mirrored | `0x4D7D8` |
| `bof` / `bon` | — | hides / shows Bud again | `0x4FB48=1/0` |
| `buh` | `buh,NN` | if ≠ 0, freezes the special animation | `0x4FCE8` |
| `bso` | `bso,NNN` | X offset of the special animation (used by `0x1A0A4`) | `0x4ED24` |
| `bus` | `bus,NNN` | Bud says line `tpo+NNN−1` of `PTnTEXT.C` (colour 1); voice `samMMMM.wav` with MMMM = (part−1)·3000 + tpo + NNN − 1; bubble at (xBud, yBud−64) | `0x11F64`, `0x4EC98` (duration) |
| `buv` | `buv,NNN` | volume of Bud's voice (127 by default, 2nd argument of `0x11F64`) | `0x4214C` |
| `buw` | `buw,XXX,YYY` | Bud walks to (X,Y) | `0x4B564/68`, `0x4B56C=1` |
| `bux` | `bux,XXX,YYY` | puts Bud at (X,Y) without walking | `0x43F0C/10` |
| `cNa` | `c0a,NNN` | character N: animation list NNN, 999 = none (−1). Without `cNa`, the active list is set by the per-location code (`0x1A78F`…) | `0x4F104[N]` |
| `cNc` | `c0c,NNN` | character N: restarts its animation list (`CHARPOS`, ended by 99) | `0x208B8` |
| `cNs` | `c0s,NNN` | character N says line `tpo+NNN−1`, in colour 0xB5+N; bubble at `ssp`, or at `sNp` if `[0x4FBA8]` ≠ 0 | `0x4FBEC`, `0x4FBF0=N` |
| `cNv` | `c0v,NNN` | volume of character N's voice | `0x42150[N]` |
| `end` | — | end of the script | returns 2 |
| `fad` | `fad,NN` | fade counter: 20 = fade to black in 14 steps, 00 = opening fade (see 4.18) | `0x4ECB8` |
| `fx` | `fx,NN` | plays slot NN (counted from 0) of the location's `FX.C` list: `fxF.wav`, F = `0x46CE4[NN]` | `0x118B0`, `0x4FD08` |
| `flx` | `flx,NN` | effect NN looped (type 2) | `0x46DD4[NN]=2` |
| `f?x` | `fsx,NN` | stops effect NN if it is playing | `0x11614` |
| `fm` | — | makes the inventory flash | `0x4FBE0=50` |
| `fw` | `fw,NN` | Bud goes to area NN of the location (`0x14798`); if it is an exit, he takes it | `0x477F8` |
| `gfg` | `gfg,NNN,VV` | game flag `[NNN] = VV` (300 flags, saved) | `0x47800[]` |
| `gv` | `gv,NN` | chains `CTABLE02` sequence NN at the end of the current sequence | `0x467DC` |
| `loc` | `loc,NN` | changes location on the next tick; the script **continues** in the new location (loading `0x136DC` does not reset `[0x4FB34]` to 0), e.g. `bof,loc,70` then `loc,36,bon,…` | `0x468C8`, returns 1 |
| `ofg` | `ofg,NNN,VV` | VV ≠ 0: adds object NNN to the inventory (`0x16F94`); VV = 0: removes it (`0x17008`) | `0x4B5E8[]` |
| `opt` | `opt,NN,{TTT,EEE}×NN` | dialogue menu: NN choices; text = line `tpo+TTT−1`; leads to `dw` entry EEE (counted from 1) | `0x4FB64/68/84` |
| `opf` | `opf,NN,{FFF,VV,TTT,EEE}×NN` | same, but a choice only appears if flag FFF equals VV | same |
| `sse` | `sse,NNN` | jumps to `dw` entry NNN of the current table | `0x4FB34`, returns 3 |
| `ssp` | `ssp,XXX,YYY` | bubble position for all characters | `0x4FB5C/60` |
| `sNp` | `s0p,XXX,YYY` | bubble position for character N | `0x4FBAC/C4[N]` |
| `sp` | — | special pose of Bud: while his sequence has 2 parts, a counter goes up to 121, then back to 0, and picks frames 0x77 to 0x7A by direction (`0x17B80`) | `0x467D4=1` |
| `s?c` | — | `0x4F2E8=0`; never used | — |
| `tpo` | `tpo,NNNN` | base for lines of dialogue (line number in `PTnTEXT`) | `0x4FCD0` |
| `wa+` | — | waits for the end of the line, then 20 ticks | `0x4FB4C`, `0x4FB44=20` |
| `was` | — | waits for the end of the line | `0x4FB4C` |
| `wat` | `wat,NNN` | waits NNN ticks | `0x4FB44` |
| `wsm` | — | waits until Bud has finished walking | `0x4FBA0` |
| `wfx` | — | waits for the end of the last slot played by `fx` (`[0x4FD08]`) | `0x467D8` |
| `wNa`/`wba` | — | waits for the end of the animation of character N or of Bud. The pointer does not advance, so the instruction is unusable and absent from the data | `0x4FB54` |
| `xhr` / `xhm` | — | camera follows Bud (scroll = xBud − 200) / normal camera | `0x4FCE4` |
Frequencies found in `CSDATA.C` (42 different mnemonics): `wa+` 1,866, `bus` 1,054, `c0s` 796, `sse`
271, `was` 247, `c1s` 174, `gfg` 147, `opt` 146, `wat` 124… All these instructions are covered by the
table.
Anomalies in the data:
- `CSDATA.C` line 500 contains `bud,004`. The name is recognised as `b?d`, but the argument has 3 digits
instead of 2: the pointer lands on `,` and the engine prints "Instruction not recognised".
- `CSDATA1.C`, not loaded, also contains `c0+` and `cos`.
- A modern engine must report these cases without crashing.
### 4.9 Structure of the `!!NN` tables (widths in digits)
- **`DATA.C`** (`!!NN` = number of `scrobjNN.pcx`): `id(3) xs(3) ys(3) w(3) h(3) xd(3) yd(3)`.
- Destinations: `0x4AB94[id] = ys*320+xs`, `0x49424 = w`, `0x49BF4 = h`, `0x48484 = xd`,
`0x48C54 = yd`.
- The two trailing `0` are ignored.
- **`DATA3.C`** (`!!NN` = location): `graphic(3) sequence(3) takeable(2) inventoryNo(2) flag(3)
value(2) textNo(3) xStand(3) yStand(3)`.
- Destinations: `0x474D4`, local, `0x475C4`, `0x47614`, `0x47664`, `0x476B4`, `0x4B378`, `0x47758`,
`0x477A8`.
- The sequence (0 = none) refers to a run of the EXE's animation table `0x4260C` (§4.11). The code
handles neither flipping nor the value 999: the file's comment "High=Flip, Low=Seq" matches nothing
in the EXE.
- "At most 19 objects": the loader stops when the index reaches 0x13 (`0x16B8A`).
- Mistyped lines (`w 220,…`, `d 007,…`) are skipped, because `0x15F70` looks for "dw".
- **`DATA4.C`**:
- Header: `dw NN,NN`, into `0x46714` and `0x46798`.
- Then, per location, up to 10 areas ended by `dw -1`: `x(3) y(3) w(3) h(3) xStand(3) yStand(3)
textNo(3) cursor(2) destLoc(2) x1(3) y1(3) x2(3) y2(3) xWalk2(3) ?(3)`.
- 10-entry arrays, from `0x472F4` to `0x474AC`.
- **`CTABLE01.C`** (`!!00`):
- `dw 999,file,loc` selects the `bud_N.pcx` sheet;
- then `xs(3) ys(3) w(3) h(3) xOff(3) yOff(3)`, into `0x4B694 = ys*320+xs`, `0x4B9B4`, `0x4BCD4`,
`0x4BFF4`, `0x4C314`. A value > 300 means `value − 500`.
- **`CTABLE02.C`** (no section, one line per sequence):
- `partCount(2) rotation(2) loc(2)`, then the frame numbers in 4 columns, ended by 999;
- destinations: `0x4D124`, `0x4D444`, then the list `0x4C634[]`; the start of each sequence is in
`0x4CE04[seq]`.
- **`ACTION1/2/3.C`** (`!!NN` = location), in two parts:
- key: `verb(2) targetType1(2) target1(3) targetType2(2) target2(3)`, encoded as `type*1000 + no`;
- result: `flag1(3) val1(2) flag2(3) val2(2) budSeq(3) ?(2) line(3) duration(2) flagToSet(3)
value(2) fx(2) fxDelay(2)`, into `0x4D9A4 … 0x4EAD4` (100-entry arrays).
- **`CHARPOS.C`** (`!!NN` = location):
- up to 8 characters: `x(3) y(3) w(3) h(3) xWalk(3) yWalk(3) flag(3) value(2) direction(2)
nameNo(3) descriptionNo(2)`, into `0x4F9D0 … 0x4FB10`;
- then two blocks of animation lists, each ended by `dw -1` (loader `0x20354`):
- Bud's special animations go, flattened, into `0x4ED2C[]` (one list per line, end = 99);
- the characters' ones go into `0x4F2EC[]`. A line ends with 99 (end of list) or with **98, which
means "the list continues on the next line"**: the 98 is overwritten (index decremented), then
reading resumes at the next `dw` line. Example: the dentist in location 13 has a 91-frame list
over 4 lines.
- List format: `nSPR, frame1, frame2, …`, with frame numbers counted from 1.
- **`FX.C`** (`!!NN` = location): see §4.7 (read by `0x2578E`).
### 4.10 Interface: panel, verbs, font, sentence
- **Font**:
- `0x13FC0` cuts `CHARSET.PCX` into 10×10 cells (32 per row, 7 rows, codes 0x20..0xFF in CP437
order: é = 0x82, à = 0x85, ç = 0x87…). Each glyph is compressed (`0x10DF0`) into `[0x46868]`, with
the offsets in `0x468DC[]`.
- Drawing a character `0x141B0`(dst, code, pitch, colour): 0 = transparent, 0x80 = outline kept as
is, any other value takes the requested colour.
- `0x14384` draws a line of text advancing by `width[code]`. `CHARSIZE.DTA` contains 256 2-digit
widths, read by `0x270EC` into `0x42408[]`; `0x14144` measures a line.
- **Panel**: `0x13BCC` loads `PANEL1.PCX` (written verbs) if `[0x468D0]` = 0, otherwise `PANEL2.PCX`
(icons). Initialisation (`0x12554`) sets `[0x468D0]` to 1: the game therefore starts with the icons.
F1 (code 0x3B, `0x18FED`) toggles between the two. `0x13D8C` fills the 320×60 bar `[0x46864]`,
displayed at y = 140, according to the `pan` mode `[0x468D4]`:
- 0: lines 0..49 to 10..59, then the inventory (`0x1716C`);
- 1: lines 51..110 to 0..59;
- 2: like 1, plus lines 172..187 to 20..35 (LOAD / SAVE / PLAY / QUIT);
- 3: lines 110..169 to 0..59 (OK / CANCEL).
- **Verb under the mouse** (`0x15A14`, screen coordinates):
- y < 150: 0 (Go); x > 195: 1;
- with `PANEL1`, `((y−150) div 17)·3 + x div 67`, which gives the grid Go to / Look / Talk to //
Open / Close / Give // Take / Move / Use;
- `PANEL2` has irregular areas.
- **Sentence** (`0x14404`) on lines 0..9 of the bar, colour 1:
- verb = line `verb+1` of `INFOBAR.TXT`;
- then the object name = line `n+1` of the file chosen by `[0x472DC]`: 0 = `DATA5.C` (DATA4 areas),
1 = `BGTEXT.C` (scenery objects), 2 = `CHARNAME.C` (characters), 3 = `OBJTXTn.C` (inventory);
- where relevant, "with" or "to" (line 11, or line 12 for Give), then the second object;
- words 4 px apart, the whole centred: `x = 0x9F − width/2`.
### 4.11 Scenery objects and inventory
- **Game part** `[0x46814]` (`0x12858`):
- locations 1–23 → 1;
- 24–40, 70–72 and 79–82 → 2;
- 41–69 and 73–78 → 3.
- It selects the `DATA.C` sections, the `OBJTXTn.C`, `PTnTEXT.C` and `PANOBJSn.PCX` files, and the
base of the object descriptions `[0x4FD00]` (0xA4F, 0xA77 or 0xA9F).
- **`DATA.C`** (`0x16654`):
- sections `!!P0`, `!!P1`… read up to the first missing one; section k describes the
`scrobjPk.pcx` sheet;
- the id is global to the part, and `0x4A3C4[id]` gives its sheet;
- `0x16598` recompresses each rectangle as RLE (0 = transparent).
- **Starting inventory** (`0x2624C`, on each part change `0x128EF`): if flag 219 is 1 (new game
`0x1280E`, or `gfg,219,01` in scripts), it resets it to 0, empties the inventory and
`0x4B3C8[0..49]`, gives the floppy disk (object 30), then in part 1 or 3 the map (1) and the matches
(0). A new game also sets flag 105 to 1.
- **Visibility** (`0x16BA8`):
- hidden if `flag > 0` and `flags[flag] ≠ value`;
- otherwise, a takeable object is only visible if `0x4B3C8[inventoryNo] = 0`;
- otherwise visible.
- **Animation** (`0x16C78`, once per pass through the loop):
- the EXE table `0x4260C` contains 169 runs ended by 999 (1,323 dwords);
- on each tick, the position advances by 1 and goes back to the start after the end;
- the value **998, f, v** does `flags[f] = v`, goes back to the start and hides the object;
- any other value read becomes the object's graphic.
- **Drawing** (`0x16DE0`): transparent copy into the room (pitch 640) at (xdest, ydest), after the
background and before the characters.
- **Hover** (`0x16450`):
- objects are tested from last to first;
- if the mouse is inside the rectangle of a visible object, its text number is returned (`BGTEXT.C`,
line n+1);
- an object with text 0 stops the search among objects, but the `DATA4` areas are still tested.
- Full order in `0x15670`: characters `0x206DC`, objects `0x16450`, areas `0x1631C`, inventory
`0x15BA0`.
- **Verb rules** (`0x15670`):
- the right button moves to the next verb (0..8) and locks it; otherwise the verb follows the mouse
(`0x15A14`);
- "Talk" only accepts characters; "Give" only accepts the inventory for the first object;
- verb not locked and mouse over a character (except no. 0x15) → "Talk";
- in location 63, "Go" becomes "Use".
- **Inventory**:
- list `0x4B5E8`, count `0x4B688`, scroll `0x4B68C` (a word) in steps of 3. The arrows are at x
200–211: click up if y < 175, down otherwise;
- at the start: object 30 (the options floppy disk), plus objects 1 and 0 in part 3 (`0x2629D`);
- 32×24 icons in `PANOBJSn.PCX`, 10 per row (`0x16EB4`);
- 2 × 3 slots drawn at (212 + 34c, 150 + 26r) (`0x1716C`); the clickable area has a 36 × 25 pitch
(`0x15BA0`).
- **"Look"** (`0x18920`, `0x150F0`): the line is spoken by Bud, and its voice has the same number.
- `DATA4` area: line 0x749 + textNo. If that line starts with `*E`, `*M` or `*R`, Bud says a generic
line 0x749 + 0x106 (resp. 0x10C, 0x119) + k, with a shared counter `0x47B20` (1..6 or 1..10).
- Takeable object or inventory object: `[0x4FD00]` + inventoryNo.
- Character: 0x87F + `CHARPOS` description number (0 = no line).
- Other cases: `ACTIONn.C` table.
### 4.12 Speech bubbles, voices and dialogue menu
- **Voice** `0x11F64`(n, volume): `speech\samNNNN.wav`. The bubble lasts `[0x4EC98]` = `[0x420E0]` = 1
tick, extended while the voice is playing (`0x19056` → `0x12208`).
- **Line breaking** `0x19C8C`(text, start, maxWidth):
- characters are added while `width ≤ max`, and each space remembers (count, width);
- CR or LF ends the text;
- if the text overflows, it is cut at the last space, and the next line starts after it.
- **Placement** `0x19D74`(x, y, text, colour):
- max width = 2·min(x − scroll, scroll + 320 − x), replaced by 220 outside [150, 180];
- at most 4 lines, each centred on x and clamped to the screen; if 10·count > y, then y = 10·count;
line i is at y − 10·(count − i);
- colours: 1 for Bud, 0xB5 + N for character N.
- **Dialogue menu** `0x21EB4`, active when `[0x4FB64]` > 0:
- drawn on the bar, after the panel copy;
- choices from y = 141, x = 0, max width 319, lines going down;
- colour 0x6C, and 0x6A for the hovered choice;
- a click jumps to entry `0x4FB84[i]` (`0x21DFB`).
### 4.13 Bud
- **`CTABLE01.C`** (`0x176A0`, section `!!00`): 172 frames. `dw 999,FF,LL` opens the `bud_FF.pcx` sheet.
- **`CTABLE02.C`** (`0x17A00`): frame numbers read as 3 digits every 5 characters. The few truncated
lines of the file give −2 values.
- Base sequences: 0 walk right, 1 stand right, 2 walk up, 3 stand back, 4 walk down, 5 stand front.
- Left is right mirrored (`[0x4D7F0]`).
- **Drawing** `0x12E74` → `0x11168`:
- position x + xOff − 14, or mirrored x − w − xOff + 14; line y − 54 + yOff (+ `[0x4B558]`); two
frames stacked for 2-part sequences;
- a pixel is not written if the background under it is ≥ 0xF8, nor if it is ≥ 0xE0 on lines where
`line + yOff ≥ 0x442D4[loc]` (Bud's top goes in front, his bottom behind; test at `0x11293`) (60 in
locations 2, 3, 9, 16, 18, 51, 54; 28 in location 1; 48 in location 64);
- the high colours of the palette therefore act as a depth layer.
- **Pose when Bud is not walking** (`0x17B80`): `[0x4D7E4]` is 0 when stopped, 1..4 while walking, 5
during an action, 6 when Bud talks; the orientation is `[0x4D7D8]` (1 up, 2 right, 3 left, 4 down).
The pose is chosen again when `[0x4D7E4]` changes or when the sequence ends (999). `[0x4D7DC]` is 1
during a CSDATA script (`0x21CB6`, reset to 0 at `0x21E80`):
- stopped outside a script, random front pose: `rand() < 2000` → 0xD; otherwise `rand() < 3000` → 0xE
(0x12 in location 57); otherwise `rand() < 20000` → 0x12; otherwise 6. Checked under DOSBox: Bud
turns to face the player as soon as he stops, even after walking in profile;
- stopped within a script, pose by orientation: 3 (up), 1 (right), 1 mirrored (left), 5 (down);
- when Bud talks: 0xF outside a script; within a script 0x11 (up), 0x10 (right), 0xF (down), 0x10
mirrored (left).
- The original walk (`0x17B80`: speeds, choice of direction, detours) is not reproduced. The engine
runs a breadth-first path search on the mask (2 px grid, no corner cutting), smooths it with lines of
sight, then Bud follows the segments (at most 4 px in x and 2 px in y per tick).
### 4.14 Actions (ACTIONn.C), exits, Bud's special animations
- **Camera** (`0x19100`, called every frame at `0x12B8D`; scroll `[0x46854]`, reset to 0 on entering a
location at `0x194FF`):
- single-background room (`0x42290[loc]` ≠ 2): scroll 0;
- `xhr` (`[0x4FCE4]` = 1): scroll = Bud's x − 200, unclamped;
- location 16 with special animation 6: +1 px per frame while scroll + 200 < x, at most 320;
- otherwise dead zone: if scroll + 120 > x, scroll = x − 120 (at least 0); if scroll + 200 < x, scroll
= x − 200 (at most 320). The adjustment is immediate. Example checked under DOSBox: arrival in
location 3 at x = 496, scroll 296.
- **Loading** `0x18594`: `ACTIONn.C` (n = part), section `!!LL` of the location, at most 100 lines, into
the arrays `0x4D9A4…0x4EAD4`.
- A line contains: verb(2) type1(2) target1(3) type2(2) target2(3), then flag1(3) val1(2) flag2(3)
val2(2) budSeq(3) mirror(2) csdataEntry(3) delay(2) flag(3) value(2) fx(2) fxDelay(2).
- Key: `type1·1000 + target1 + verb·10000 + type2·100000 + target2·1000000`.
- Target types: 0 = DATA4 area (text number), 1 = DATA3 object (text number), 2 = character (CHARPOS
name number), 3 = inventory object.
- **Execution** `0x18BC4`: the first line with the same key whose two conditions hold is kept. A
condition `d < 500` requires `flags[d] == v`, a condition `d ≥ 500` requires `0x4B3C8[d − 500] == v`,
and `d = 0` requires nothing.
- budSeq 6: nothing;
- budSeq < 100: CTABLE02 sequence, the next field giving the mirroring;
- budSeq ≥ 100: special animation `[0x4ED18] = budSeq − 100`.
- The deferred result is stored at `0x4EC68…0x4EC80`.
- **No line**: default answer `0x14B94(verb)`.
- The first lines are at `0x447E0` (0, 2235, 2235, 2251, 2261, 2276, 2294, 2312, 2235) and the number
of variants at `0x423E4`.
- A counter per verb rotates: the line spoken is `base + counter`.
- "Use" on inventory object 6 gives 0x95B.
- **Deferred result** `0x18EDC`, called when `[0x4D7E0] == 0`, i.e. one loop pass out of 4:
- after "delay" passes, verbs 2, 3, 4 and 8 do `flags[d] = v`; verb 6 with v = 1 adds object `d` to
the inventory (`0x16F94`);
- then, if the CSDATA entry is > 0, `[0x4FB34]` starts the script.
- **FX** `0x18E84`: after "fxDelay" passes (0 = never), plays slot `fx` of `FX.C` (same arrays
`0x46D5C` and `0x46E4C` as the `fx` script instruction).
- **What happens on a click** (`0x14B20`, `0x14798`, `0x14FC4`):
- On a scenery target, Bud first walks to the target's point: the area's `stand` (the clicked point if
its text is 0), the object's `stand_x/y`, the character's `walk_x/y`, or the clicked point if y = 0.
- "Go" only walks.
- On the inventory, there is no walking: "Look" describes, "Give" and "Use" open the two-object
sentence, and the other verbs give the default answer.
- "Look" (`0x18920`) answers without walking: description of the area, takeable object, inventory
object or character; failing that, the ACTION table (verb 1).
- **Characters**: a CHARPOS character can only be hovered if `flags[flag] == value` (`0x206DC`).
- **Exits** `0x14864` / `0x19299`: "Go" (or "Use") on an area whose `dest_loc > 0`. Bud goes to
`stand`, then:
1. he walks to (`walk_x2`, `unk`), or plays special animation `walk_x2 − 900` if the value is above
800;
2. location `dest_loc` is loaded and Bud is placed at (`to_x`, `to_y`);
3. he walks to (`to_x2`, `to_y2`), or plays animation `to_x2 − 900`;
4. destination 99 is the map (`0x195C4`, not reproduced).
- **Special animations**:
- `0x19F98` loads `aLL_01.SPR … aLL_nn.SPR` (n = byte `0x44414[loc]`) into a bank; `0x4ECC4[k]`
gives the offset of file k, and k = 0 falls on the first file;
- `0x17B80` / `0x1A0A4` play every frame of the file once, in place of Bud. The coordinates are those
of the sprite, with +320 if `320 < Bud's x < 640` (hard-coded exceptions in locations 22, 29 and
58);
- examples: location 1, `A01_02` (Bud climbs over the window sill); location 2, `A02_01` (he climbs
down the drainpipe).
### 4.15 Animated characters (per-location routines)
- **Fields per character i** (dword arrays):
- `0x4F104` state = number of the `CLL_ss.SPR` file played (−1: none), `0x4F188` previous state;
- `0x4F144` current frame (1..n), `0x4F124` frame count (first word of the file);
- `0x4F1C8` wait before deciding, `0x4F268` ticks per frame, `0x4F1E8` reverse playback, `0x4F208`
ping-pong;
- `0x4F248` "change when speech starts or ends", `0x4F92C` position in the CHARPOS lists, `0x4F1A8` x
offset (0 or 320).
- **`0x200E4`, every tick**, for each character:
- a running CHARPOS list advances, and 99 ends it;
- otherwise, `0x1F594` is called if the state is −1, if the character starts talking (`[0x4EC98] > 0`
and `[0x4FBF0] == i`) or if speech has ended while `0x4F248 > 0`;
- otherwise, the frame advances (wait, speed, ping-pong) and `0x1F594` is called at the end of the
animation.
- **`0x1F594`** resets these fields, then calls the routine of the location and the character:
- location 2: `0x1A770`;
- location 3: `0x1AA60` (Vera, the bouncer), `0x1AB58` (Tony, offset 320), `0x1C160` (Dave);
- these routines pick the next state from the flags, `rand()` (`0x2E2E2`, Watcom) and speech.
- **Link with the scripts**:
- `cNa,NNN` (`0x20F05`) sets state NNN (999 = none);
- `cNc,NNN` (`0x20FA9` → `0x208B8`) plays list NNN of `CHARPOS.C` (file, frames…, 99).
- The CHARPOS lists are therefore not the default animation. The engine could not draw Vera, the
bouncer of location 3 (`C03_01…05`), who does not appear in them.
- **Peculiarities**:
- `[0x4D7DC]` = conversation in progress, set to 1 and 0 by the dialogue menu;
- `0x47B1C…0x47B3C` are flags (199, 203, 205, 207);
- flag `0x4F98C` makes the EXE write the frame count into the *state* (`0x200A3`). The engine
reproduces this behaviour as is.
- **Number of animated characters**: `0x44600[loc]` (`0x1A3E5`). The fields are reset on loading
(`0x1A3F0`, including `0x4F228`, `0x4F94C` and `0x4F9B0`).
- **Execution rather than translation**: the dispatcher `0x1F594` and the hundred or so routines from
`0x1A770` to `0x1F594` are run as they are.
- `tucker/core/x86.py` is a 32-bit interpreter limited to the instructions of this Watcom code. Its
decoding was compared with the disassembly: same length for the 4,898 instructions of the area.
- The code comes from the user's EXE, relocated at startup by `LEImage.relocated()`.
- `tucker/core/exe_routines.py` copies the engine state into the emulated memory before the call,
then reads it back after:
- copied: flags `0x47800[300]`, inventory `0x4B3C8`, location, Bud's position, speech
`0x4EC98`/`0x4FBF0`, running script `0x4D7DC`, special animation `0x4ED18`, character fields;
- read back: the same, plus `0x4FCD8`, `0x4F98C` and the requested script `0x4FB34`.
- Intercepted calls: `0x208B8` (CHARPOS list, in Python) and the sound driver (`0x118B0` play,
`0x11614` stop, `0x11D78` volume), turned into events. `[0x41F90] = 0` disables the native part.
- `rand()` (`0x2E2E2`) runs natively (Watcom LCG ×0x41C64E6D + 0x3039).
- **Validation**: the routines of locations 2 and 3, translated by hand, give exactly the same states as
the emulated execution over 1,000 ticks, with the same seed. All 82 locations run without errors.
- Characters absent at the start of the game are absent because of their flags (example: location 4,
Mr Pastry only if flag 9 is 2).
- **Comparison with the game under DOSBox (locations 1 to 3)**: a game played from the bedroom to Seedy
street. DOSBox's native captures (Ctrl+F5, indexed 320×200 PNG) are compared with the engine's
rendering, pixel by pixel. Characters are identified by counting only the sprite pixels that differ
from the bare background (some frames, like `C03_14` no. 2, are already painted into the background).
- Location 1: same start (160, 125) and same stopping points ("Go bed"; washbasin at 115, 101).
Differences fixed: the standing pose (4.13) and the starting panel (4.10).
- Location 2: arrival at (220, 112); background, animated laundry and Mr Pastry (`C02_01`) identical to
the pixel. Frames 7 = 1 and 5 = 3 of `C02_01` are the same: frame 7 is never shown (end of
animation at `num_frames − 1`, 0x200E4).
- Location 3: Bud arrives at x = 496, feet at y = 120 in both versions. Difference fixed: the camera
(4.14). Vera (`C03_01…05`, mostly state 5), Tony (+320, states 6, 10 and 11) and Dave (`C03_14` /
`C03_15`, about 60/40) have the same states and the same proportions as the emulated execution.
- DOSBox mouse (mouse not captured, `autolock=false`): absolute position, x_game = 10 + 1.754·(x −
170) and y_game = 3 + 0.882·(y − 182), in the tool's screen coordinates. A click must last about
0.25 s to be seen by the game.
### 4.16 Town map (`0x195C4`)
- Opening:
- exit to location 99 (`0x19411`, with `[0x4FCF8] = 1`: "from an exit"); locations 3, 9, 16, 19, 20
and their equivalents 65, 66, 61, 62, 68;
- "Use" object 1 (the map) in the inventory (`0x15CE8`), if the table `0x42170[loc]` is 1. Locations
41 to 52 are added when flag 223 is set (`0x23F95`, and on loading a save). Otherwise Bud answers
with line `0x8BB` (2235).
- Image: `map2.pcx` (blank map), onto which `0x19530`(x, y, w, h) copies rectangles of `map1.pcx`:
- flag 7 > 0: (0, 0, 140, 86); > 1: (0, 60, 122, 120); > 2: (122, 114, 97, 86); = 4: (140, 0, 88,
125);
- flag 120 = 1: (220, 0, 100, 180).
- Areas (strict bounds, screen coordinates), name = line of `INFOBAR.TXT` in colour 0x60, placed like a
bubble (`0x19D74`) at (mouse x + 8, mouse y − 10):
| Area | Condition | Line | Location (part 1 / 2-3) | Bud |
|---|---|---|---|---|
| 30 < x < 86, 36 < y < 86 | flag 7 > 0 | 13 Seedy street | 3 / 65 | (620, 130) |
| 60 < x < 120, 120 < y < 170 | flag 7 > 1 | 14 shopping centre | 9 / 66 | (344, 120) |
| 160 < x < 210, 110 < y < 160 | flag 7 > 2 | 15 Park | 16 / 61 | (590, 130) |
| 150 < x < 200, 20 < y < 70 | flag 7 = 4 or 6 | 16 Museum | 20 / 68 | (20, 130) |
| 240 < x < 290, 35 < y < 90 | flag 120 = 1 | 17 Docks | 19 / 62 | (20, 124) |
| 135 < x < 185, 170 < y < 200 | always | 18 Go back | current location | see below |
- "Go back": from an exit, Bud is placed according to the location he left (3/65: (620, 130); 9/66:
(344, 120); 16/61: (590, 130); 20/68: (20, 130); otherwise (20, 124)). From the inventory, he keeps
his position. In both cases the location is reloaded (`[0x468C8]`).
- Arriving from an exit in location 9: Bud's special animation 2; in location 66: animation 1
(`0x19B7E`).
- While the map is open the game stops running: opening fade in 14 steps (`0x1053C`), loop until a
click on an area, closing fade.
### 4.17 Per-location code (`0x24C8C`)
- Called every tick from the loop (`0x12DF7`): a chain of `cmp [0x4680C], n` leads to 46 routines, for
locations 1-6, 9-16, 19, 21, 22, 24-36, 38, 41-44, 49, 52, 53, 57, 58, 61, 63-66 and 70. Location 14
is called conditionally.
- These routines read and write the game variables directly:
- flags `0x47800 + 4n` (many "globals" are flags: `0x47A3C` = flag 143);
- areas (`0x472F4`…, 10 per location);
- FX slots (volume `0x46D5C`, type `0x46DD4`);
- Bud's depth table `0x442D4` and the map table `0x42170`;
- walk target `[0x4B56C]`; requested script `[0x4FB34]`;
- DAC (`0x10270`, `0x103F8`) and walk mask (`0x13A28`, e.g. `PATH02B` in location 2);
- location init `[0x4FBF4]`, reset to 0 on loading.
- Some draw directly into the 640 buffer `[0x4685C]` from the `DATA.C` graphics:
- buffer `[0x48480]` filled by `0x16598`, sheet by sheet and by increasing id; each rectangle is
compressed by `0x10DF0` (byte ≠ 0 copied, run of 0 → `0, n`, split beyond 200);
- tables per id (`0x16654`): offset `0x4AB94`, x `0x48484`, y `0x48C54`, width `0x49424`, height
`0x49BF4`, sheet `0x4A3C4`;
- location 6: the stage curtain (graphic 238, 8 × 51 with no transparent pixel) is copied strip by
strip by `0x2279C` and `0x22880` according to flag 27.
- The modern engine runs them as they are in its x86 emulator (`tucker/core/x86.py`, memory shared
with the characters `0x1F594`); graphics and sound calls are intercepted and handed to the engine.
- Location 70, terminal:
- scancode `[0x4EC8C]` translated by the table `0x41FF8`, at most 19 characters, Backspace
`0x0E`/`0x53`, Enter `0x1C`;
- the first 16 characters are compared with line 24 of `INFOBAR.TXT` (in the French version
"GRAND PANTALON JAUNE", "big yellow trousers");
- result in flag 143 (1 = right, lines 25-26; 2 = wrong, lines 27-28), then script 1.
### 4.18 Fades, pause and help
- Fades (`0x12A5B`, steps `0x1053C` / `0x1062C`): counter `[0x4ECB8]`, + 1 per tick.
- c < 16 and c > 1: each DAC component + 5 (6-bit) towards the target colour; loading a location sets
c = 0, i.e. 14 steps.
- 19 < c < 34: − 5 per component. An exit fades to black before loading; the map opens and closes
the same way.
- Pause: P key (except in location 70), `[0x467B0]`.
- All sounds stop and the bar shows line 36 ("EN PAUSE", "paused").
- Keys 1 to 5 replay Bud's last 5 `bus` lines (history `0x467B8`…).
- P resumes the game and the sounds.
- F3 help (`0x26ECC`): active only if the 2nd number of the `DATA4.C` header is ≠ 0. The shipped
version has `dw 00,00`, so no help.
- Steps: 0 → 1 (flag 3), → 2 (12), → 3 (20), → 4 (9), → 5 (23); flag 19 → 6 (end).
- Help is ready after 1,500 ticks in the step. If the mouse has not moved for 1,000 ticks, the bar
shows line 29 ("Press F3").
- F3 shows line 30 + step.
## 5. Limitations
- Ghidra's decompiler does not know the Watcom convention: the arguments were re-read in the assembly,
provided in `extracted\pe\dis.txt`. REA is read-only under Windows, so no function could be renamed in
Ghidra.
- `fw` and `sp` are now described; the behaviour of `sp` was re-read in `0x17B80`, that of `fw` in
`0x14798`.
Working files produced locally in `extracted\pe\` (not published): `TUCKER_flat.exe`, `dis.txt` (full
disassembly), `callgraph.txt`, `procs.txt`, `strings.txt`, `decompile\*.c` (Ghidra output via REA),
`rea_evidence.json` (REA evidence), `outils\` (le2pe.py, dis.py, show.py, pseudo.py).
+1 -1
View File
@@ -1,6 +1,6 @@
# Analyse du jeu : TUCKER.EXE et ses fichiers
🇫🇷 Français (pas encore traduit) · Vue d'ensemble : [documentation technique](TECHNIQUE.md)
🇫🇷 Français · 🇺🇸 [English](ANALYSE.en.md) · Vue d'ensemble : [documentation technique](TECHNIQUE.md)
> **D'où vient ce document.** C'est le carnet de rétro-ingénierie tenu pendant l'étude du jeu, avant et
> pendant la recompilation : désassemblage de `TUCKER.EXE` (Ghidra, désassembleur maison), lecture des
+3 -3
View File
@@ -200,7 +200,7 @@ Result: `build\tucker.exe`. To play:
.\build\tucker.exe --cd C:\Games\TUCKER --hd C:\Games\TUCKER --root C:\Games --son
```
Main options (the option names are French; full list in [SETTINGS.md](SETTINGS.md)):
Main options (the option names are French; full list in [SETTINGS.en.md](SETTINGS.en.md)):
| Option | Effect |
|---|---|
@@ -299,7 +299,7 @@ Picture rules:
- RGB or RGBA PNG (alpha is ignored), non-interlaced;
- a partial pack works: a background without a PNG stays at 320×200.
Step by step, retouching and troubleshooting: [TEXTURES.en.md](TEXTURES.en.md). Technical details: [MODS.md](MODS.md) (in French).
Step by step, retouching and troubleshooting: [TEXTURES.en.md](TEXTURES.en.md). Technical details: [MODS.en.md](MODS.en.md).
## 10. Mods
@@ -328,7 +328,7 @@ author=Me
description=What the mod does
```
Full format: [MODS.md](MODS.md).
Full format: [MODS.en.md](MODS.en.md).
## 11. Saved games
+127
View File
@@ -0,0 +1,127 @@
# Mods and HD pack
🇺🇸 English · 🇫🇷 [Français](MODS.md) (reference) · Step-by-step tutorial: [HD textures](TEXTURES.en.md)
Mods add or replace content **without modifying the game files**: the engine reads a mod's files instead
of the originals during play. Nothing is redistributed with the project. The `mods/` folder is excluded
from the git repository, because the HD images are derived from each player's game files.
## Location
By default, the game looks for `mods/` next to the executable, then in the parent folder (the case of
`build\tucker.exe`: `mods/` at the root of the project), then in the current folder. The `[mods] dir`
key of `settings.ini` or the `--mods FOLDER` option point to another folder (see
[SETTINGS.en.md](SETTINGS.en.md)).
```
mods/
hd_upscayl/ one mod = one folder (its name is its identifier)
mod.ini optional: name, author, description (read by the launcher)
hd/
LOC01.png HD background for LOC01.PCX
LOC03A.png room in several pieces: one PNG per piece
LOC03B.png
voix_fr/
files/
SPEECH/SAM0001.WAV replaces the game file with the same path
```
- `files/`: each file replaces the game file with the same relative path. Case does not matter. Any
file the game opens for reading can be replaced: images, sounds, texts, etc.
- `hd/`: HD images of the backgrounds (see below). The name is that of the original PCX, with the
`.png` extension.
- Mods are applied in alphabetical order of their folder name. For the same file, **the last one
wins**. Prefix them, for example `10_`, `20_`, to set the order.
- A folder whose name starts with `_` or `.` is ignored, which lets you set a mod aside.
- `[mods] disabled=name1,name2` disables mods without moving them. `[mods] enabled=0` or `--sans-mods`
disables them all.
The log (standard error) lists the mods found (`actif` = active, `fichier(s) remplacé(s)` = replaced
file(s), `image(s) HD` = HD image(s)):
```
[mods] hd_upscayl : actif
[mods] 0 fichier(s) remplacé(s), 122 image(s) HD
```
### `mod.ini` (optional)
The game does not read this file. It is reserved for the launcher, to display the mods:
```ini
[mod]
name=HD backgrounds (Upscayl)
author=…
description=Backgrounds upscaled ×4 with Real-ESRGAN
```
## HD pack
The HD pack replaces the game's **backgrounds** on screen with high-definition images, at any
resolution. The game keeps running at 320×200: characters, animated objects, cursor, action panel and
texts remain the game's own and are laid over the HD background.
### How it works
1. When the game opens a background `LOCxx.PCX` for which a mod provides `hd/LOCxx.png`, the engine
decodes the original PCX. Rooms in several pieces (`LOC03A`, `LOC03B`…), opened one after the other,
form a strip 640, 960 or 1280 pixels wide.
2. On each frame, the engine looks for this background, and its scroll offset, in the game's 320×200
screen.
3. Every screen pixel identical to the pixel of the original background lets the HD image show through.
The other pixels (characters, objects, panel) stay the game's own.
4. Palette fades (entering and leaving a room, night…) are applied to the HD image.
The engine needs no knowledge of the game, and an incomplete pack works: a background without a PNG
stays at 320×200. The `nearest`, `smooth` and `xbr` filters apply to the game layer. The `crt` filter
shows the original picture, without the HD pack. The "Décors HD (mods)" (HD backgrounds) option of the
F12 menu (key `hd_pack`) turns the pack on or off during play.
### Rules for the images
- One image per PCX, **same framing** as the original: the whole 320×200 picture, including the bottom
part.
- Any size, 16:10 ratio: 1280×800 (×4) is a good choice, 2560×1600 works too. All the images of the
same room must have the same size.
- 8- or 16-bit PNG: RGB, RGBA, greyscale or palette, non-interlaced. The alpha channel is ignored.
- If a mod replaces a PCX through `files/`, the HD image with the same name is matched against the
replaced PCX: a mod that redraws a background must also provide its HD PNG, or be used without the HD
pack.
- The areas where the game draws animated objects with their own background (clock, lamp…) stay in low
resolution: the game draws there itself.
### Creating a pack with Upscayl
[Upscayl](https://upscayl.org) (Real-ESRGAN) upscales the backgrounds ×4 in a few seconds. If Upscayl
is installed, one command creates a complete pack from the game files:
```
python tools/hd_export.py ..\extracted\iso\TUCKER mods\hd_upscayl\hd --upscayl
```
- `--upscayl MODEL` picks the model. Default `digital-art-4x`, suited to drawn backgrounds. Other
models: `ultrasharp-4x`, `remacri-4x`, `high-fidelity-4x`, `upscayl-standard-4x`, `upscayl-lite-4x`,
`ultramix-balanced-4x`.
- Upscayl is looked for in `Program Files`, in `%LOCALAPPDATA%\Programs`, or at the location given by
`UPSCAYL_BIN` or `--upscayl-bin PATH`.
- To compare two models, generate them into two mods and disable one with `[mods] disabled=`.
### Creating a pack with another tool
```
python tools/hd_export.py ..\extracted\iso\TUCKER export_png
```
This command exports the backgrounds as 320×200 PNGs. Upscale them with the tool of your choice
(retouching by hand, waifu2x, ESRGAN…), then put them in `mods/<name>/hd/` under the same name.
`--echelle 2` or `--echelle 4` (scale) directly produces a Scale2x upscale, without blur, to try a pack
right away. `--motif` (pattern) selects the files (default `LOC*`).
## For the launcher
- Listing the mods: subfolders of `mods/` whose name starts with neither `_` nor `.`, with `mod.ini` for
the displayed name. A mod has HD backgrounds if it contains `hd/*.png`.
- Enabling or disabling a mod: write the list into `[mods] disabled` in `settings.ini`. The list is
taken into account on the next launch.
- HD pack on/off: `[display] hd_pack` key, also adjustable in game (F12).
- Options for a single session: `--mods FOLDER`, `--sans-mods`, `--sans-hd`.
+2 -2
View File
@@ -87,7 +87,7 @@ INTRO.EXE stays local (`build/`). Mods replace files at runtime, never touching
- [ ] Developer mode (on another key: F12 opens the settings): hotspots and walk paths, variables, jump to any location, captures
(building on `tucker-viewer`)
- [ ] Access to game functions in C, following the `overrides.txt` / `overrides.c` model
- [x] Mod format documentation ([MODS.md](MODS.md), in French)
- [x] Mod format documentation ([MODS.en.md](MODS.en.md))
## 6. Preservation and distribution
@@ -96,7 +96,7 @@ INTRO.EXE stays local (`build/`). Mods replace files at runtime, never touching
- [x] Strict `.gitignore`: `build/`, `frames*/`, `saves/`, `third_party/dl/`, anything from the ISO
- [ ] Web version (Emscripten), playable with the player's own files
- [x] User wiki: illustrated [complete guide](GUIDE.en.md), in French and English
- [x] Technical wiki based on `ANALYSE_TUCKER.md`: [technical documentation](TECHNIQUE.md) and [game analysis](ANALYSE.md) (in French) (formats, cutscene language, structures)
- [x] Technical wiki based on `ANALYSE_TUCKER.md`: [technical documentation](TECHNIQUE.en.md) and [game analysis](ANALYSE.en.md) (formats, cutscene language, structures)
- [ ] README with a before/after gallery (slider, GIF or video)
## 7. Linux, Steam Deck and resource use
+142
View File
@@ -0,0 +1,142 @@
# Settings: `settings.ini` and command-line options
🇺🇸 English · 🇫🇷 [Français](SETTINGS.md) (reference) · Overview: [technical documentation](TECHNIQUE.en.md)
The game (`build\tucker.exe`), its in-game menu (**F12** key) and the launcher all read and write **the
same file**.
> The command-line options have French names (`--plein` = fullscreen, `--fenetre` = window,
> `--echelle` = scale, `--filtre` = filter…). They are translated in the tables below.
## File location
| System | Default path |
|---|---|
| Windows | `%APPDATA%\DoubleTroubleRecomp\settings.ini` |
| Linux / macOS | `$XDG_CONFIG_HOME/DoubleTroubleRecomp/settings.ini`, otherwise `~/.config/DoubleTroubleRecomp/settings.ini` |
`--config FILE` replaces this path. The folder is created on the first save.
## Format
- UTF-8 text, one key per line: `key=value`.
- Sections: `[display]`, `[audio]`, `[mods]`. A key is only recognised in its own section. On the
command line (`--set`), you can write `key` or `section.key` (for example `mods.dir`).
- Lines starting with `#` or `;` are comments.
- When the game saves, it only rewrites the values of its own keys. The order, the comments and the
keys it does not know stay intact. The launcher can therefore add its own keys without them being
erased.
- A missing or invalid key takes its default value. An out-of-range numeric value is clamped.
- The game saves when the F12 menu is closed and after switching to fullscreen with F11.
Example:
```ini
[display]
fullscreen=0
window_scale=3
filter=xbr
aspect_43=1
vsync=0
hd_pack=1
[audio]
master_volume=100
music_volume=80
voice_volume=100
sfx_volume=90
[mods]
enabled=1
dir=
disabled=
```
## Keys
### `[display]`
| Key | Values | Default | Effect |
|---|---|---|---|
| `fullscreen` | `0` / `1` | `0` | Fullscreen at desktop resolution (without changing the video mode) |
| `window_scale` | `1` to `16` | `3` | Window of `320 × N` by `240 × N` (or `200 × N`) pixels. Reduced to the largest size that fits on the screen |
| `filter` | `nearest`, `smooth`, `xbr`, `crt` | `nearest` | Picture filter (see below) |
| `aspect_43` | `0` / `1` | `1` | `1`: 320×200 picture stretched to 4:3, as on a VGA monitor. `0`: square pixels (16:10) |
| `vsync` | `0` / `1` | `0` | Vertical sync |
| `hd_pack` | `0` / `1` | `1` | HD backgrounds provided by mods (see [MODS.en.md](MODS.en.md)). No effect if no mod provides HD images, nor with the `crt` filter |
Filters:
- `nearest`: "Net" (sharp) in the menu. Raw pixels, enlarged without interpolation.
- `smooth`: "Lissé" (smooth). Integer scaling, then interpolation limited to the border between two
pixels. The picture stays sharp, without pixels of uneven sizes.
- `xbr`: "xBR". Edges softened by xBR-style edge detection (shader written for this project, rendered
×4 then scaled).
- `crt`: "CRT". Simulated cathode-ray tube: scanlines, aperture grille, slight curvature.
Booleans also accept `true`/`false` and `on`/`off`. The game always writes back `0`/`1`.
### `[audio]`
| Key | Values | Default | Effect |
|---|---|---|---|
| `master_volume` | `0` to `100` | `100` | Overall volume |
| `music_volume` | `0` to `100` | `100` | Music |
| `voice_volume` | `0` to `100` | `100` | Voices (dialogue, intro narration) |
| `sfx_volume` | `0` to `100` | `100` | Sound effects and ambience |
Volumes are slider percentages. The mixer applies a quadratic curve so that the slider sounds even to
the ear.
### `[mods]`
| Key | Values | Default | Effect |
|---|---|---|---|
| `enabled` | `0` / `1` | `1` | `0`: no mod is loaded (no replaced files, no HD backgrounds) |
| `dir` | path | empty | Mods folder. Empty: `mods` next to the executable, otherwise `mods` in the parent folder (the case of `build\tucker.exe`), otherwise `mods` in the current folder |
| `disabled` | comma-separated names | empty | Mods (folder names) to ignore, for example `disabled=hd_upscayl,voix_fr` |
Mods are read at startup: a change to `[mods]` takes effect on the next launch. `hd_pack`, however,
applies immediately from the F12 menu. The mod format is described in [MODS.en.md](MODS.en.md).
## Command line
Display options apply **to the current session only**. They are not written to the file, unless the
player then changes that setting in the F12 menu. The launcher can therefore force a value at launch
without overwriting the choice made in game. To change a setting permanently, it must write to
`settings.ini`.
| Option | Equivalent to |
|---|---|
| `--config FILE` | Use this settings file |
| `--plein` (fullscreen) | `fullscreen=1` |
| `--fenetre` (window) | `fullscreen=0` |
| `--echelle N` (scale) | `window_scale=N` |
| `--filtre NAME` (filter) | `filter=NAME` |
| `--format43 0\|1` | `aspect_43=0\|1` |
| `--vsync 0\|1` | `vsync=0\|1` |
| `--mods FOLDER` | `[mods] dir=FOLDER` (`--mods ""`: automatic detection) |
| `--sans-mods` (no mods) | `[mods] enabled=0` |
| `--sans-hd` (no HD) | `hd_pack=0` |
| `--set key=value` | Any key in the tables, for example `--set music_volume=50` or `--set mods.disabled=hd_upscayl` |
An option with an invalid value is ignored, and a message goes to standard error.
Other game options, unchanged:
- `--cd`, `--exe`, `--hd`, `--root`, `--saves`: game folders and files (`--hd` is the game's install
folder, unrelated to the HD pack);
- `--son` (sound);
- `--sans-intro` (skip the intro);
- `--intro`;
- `-v`: detailed log on standard error, including the path of the settings file in use.
## Building
`build.bat` accepts the folder that contains `TUCKER.EXE` and `INTRO.EXE`:
```
build.bat folder taken from TUCKER_CD, otherwise ..\extracted\iso\TUCKER
build.bat D:\TUCKER folder given as a parameter
build.bat nogen compiles the C already generated in build\gen_tucker and build\gen_intro
```
+270
View File
@@ -0,0 +1,270 @@
# Technical documentation: what we know about the game, how the recomp works
🇺🇸 English · 🇫🇷 [Français](TECHNIQUE.md) · To play: [complete guide](GUIDE.en.md)
This page gathers what studying the game and recompiling it taught us about *Bud Tucker in Double
Trouble*: its executable, its files, its game loop, and how the project runs it natively. It is the
starting point for anyone who wants to work on the project: the full detail of the formats and routines
is in **[the game analysis](ANALYSE.en.md)** (the reverse-engineering notebook), the detail of the code
is in the comments of `runtime/` and `tools/`.
> No game code, image or sound is published: only addresses, formats and behaviours. The translated C
> is generated on the player's PC, from **their own** copy, and stays in `build/`.
> **French names in the code.** The project was written in French: many identifiers
> (`FN_VOIX_JOUE` = "play voice", `ADR_DEFILEMENT` = "scroll"), command-line options (`--sans-intro`,
> `--charger`) and file names (`attentes_intro.txt` = "intro waits") are French. This page translates
> them where it helps.
## Contents
- [1. Where to find what](#1-where-to-find-what)
- [2. The executable](#2-the-executable)
- [3. How does the game run?](#3-how-does-the-game-run)
- [4. The game files](#4-the-game-files)
- [5. How the recompilation works](#5-how-the-recompilation-works)
- [6. Named addresses](#6-named-addresses)
- [7. Game versions](#7-game-versions)
- [8. What the project adds on top](#8-what-the-project-adds-on-top)
- [9. Curiosities found along the way](#9-curiosities-found-along-the-way)
- [10. What remains to be understood](#10-what-remains-to-be-understood)
---
## 1. Where to find what
| I am looking for… | Where |
|---|---|
| The format of a file (PCX, SPR, `.C`, saves, sounds) | [ANALYSE.en.md, § 4](ANALYSE.en.md#4-file-loading-and-formats) |
| The cutscene language (`CSDATA.C`, 42 instructions) | [ANALYSE.en.md, § 4.8](ANALYSE.en.md#48-cutscene-instruction-set-csdatac-0x20a00) |
| What a game address does | [ANALYSE.en.md](ANALYSE.en.md) (search by address) and `runtime/addr_fr.h` |
| How x86 becomes C | `tools/recomp.py` (header), [§ 5](#5-how-the-recompilation-works) |
| The emulated CPU, DOS, sound | `runtime/cpu.h`, `dos.c`, `machine.c`, `ail.c`, `audio.c` |
| The HD pack and mods | [MODS.en.md](MODS.en.md), [TEXTURES.en.md](TEXTURES.en.md), `runtime/hd.h`, `runtime/sprites.h` |
| `settings.ini`, command-line options | [SETTINGS.en.md](SETTINGS.en.md) |
| What is planned | [Roadmap](ROADMAP.en.md) |
---
## 2. The executable
| | |
|---|---|
| File | `TUCKER\TUCKER.EXE`, 284,677 bytes (French version); `INTRO.EXE` for the intro |
| Format | MZ + **LE** (*Linear Executable*): 32-bit protected-mode program, started by the **DOS/4GW** extender |
| Compiler | **Watcom C/C++32** (1988-1994 library); arguments passed in EAX, EDX, EBX, ECX |
| Memory | flat model: code at `0x10000` (object 1), data at `0x40000` (object 2), VGA screen at `0xA0000` |
| Entry point | `0x2E318` (Watcom's `_cstart_`) → `main` at `0x12300` |
| Relocations | 8,389, all "internal 32-bit offset": every absolute code address is a relocation |
| Libraries | Watcom C and **Miles AIL 3.02** (sound), beyond `0x27200`; the game code has no `int` instruction |
| Translated size | `TUCKER.EXE`: 960 functions; `INTRO.EXE`: 540 |
The game wants 320×200 VGA in 256 colours (mode 13h), a mouse (int 33h), and reads its voices straight
from the CD (`X:\tucker\speech\`).
Details: [ANALYSE.en.md, § 2 and 3](ANALYSE.en.md#2-binary-format-and-reaghidra-setup).
---
## 3. How does the game run?
```
main 0x12300
├─ mouse, a single 5.6 MB malloc split into ~18 fixed areas
├─ sound (Miles AIL) + 46 Hz timer (callback 0x12250: tick counter)
├─ tucker.cfg, infobar.txt, .c/.enc texts, nofiles.dta
├─ VGA mode 13h (320×200×256)
├─ game loop 0x129DC ◄── everything happens here
└─ stop the timer and the sound, back to text mode
```
One game frame, in the `0x129DC` loop:
1. **Pacing**: the loop waits until the 46 Hz timer has advanced by enough ticks (a busy-wait in the
original: see [§ 5](#busy-waits-the-game-sleeps-instead-of-spinning)).
2. **Input**: mouse (int 33h), keyboard.
3. **Logic**: fades, current cutscene (interpreter `0x20A00`), Bud (`0x17B80`), characters
(`0x200E4`), animated objects, location change, per-location code (`0x24C8C`).
4. **Rendering** into a buffer **640 pixels wide** (the whole room): background, objects, characters,
Bud, cursor, texts; then a 320×200 window of it is copied to the screen, scrolling included.
A few mechanisms worth knowing:
- **Depth through the palette**: Bud goes behind a part of the background when the background pixel
under him has a colour index ≥ `0xF8` (or ≥ `0xE0` below a line specific to each location). The high
colours of the palette act as a depth layer. ([§ 4.13](ANALYSE.en.md#413-bud))
- **Walk masks**: `pathNN.pcx`, same size as the background; a byte > 0 = walkable.
- **Wide rooms**: two backgrounds side by side (`LOCxxA` + `LOCxxB`, 640 px) with scrolling; locations
with **4 images** (`A` to `D`) are **animated** backgrounds, not wide rooms.
([§ 4.3](ANALYSE.en.md#43-backgrounds-0x1383c-and-0x13a28-xeax-typeedx))
- **300 game flags** (`0x47800`): the whole state of the adventure, saved as is.
- **Three parts**: locations 1–23; then 24–40, 70–72 and 79–82; then 41–69 and 73–78. Each part has
its own text, object and action files.
---
## 4. The game files
| Files | What they are | Details |
|---|---|---|
| `LOCnn[a-d].PCX` (122) | room backgrounds, 320×200, 8-bit, PCX RLE | [§ 4.2, 4.3](ANALYSE.en.md#42-pcx-loadpcx-0x10864-desteax-modeedx) |
| `PATHnn.PCX` | walk masks | [§ 4.3](ANALYSE.en.md#43-backgrounds-0x1383c-and-0x13a28-xeax-typeedx) |
| `SPRITES\*.SPR` (654, 17,022 frames) | animations: `Ann_nn` (Bud, scenes), `Cnn_nn` (characters); RLE, absolute position | [§ 4.4](ANALYSE.en.md#44-sprites-spr) |
| `BUD_n`, `PEG_n`, `MAC_n.PCX` | sheets for Bud's walk (cut out using `CTABLE01.C`) | [§ 4.13](ANALYSE.en.md#413-bud) |
| `SCROBJnn.PCX`, `PANOBJSn.PCX` | scenery objects, inventory icons | [§ 4.11](ANALYSE.en.md#411-scenery-objects-and-inventory) |
| `*.C` (28) / `*.ENC` | **not C code**: **fixed-column** tables (`!!NN`, `dw …`) and CP437 texts | [§ 4.5, 4.9](ANALYSE.en.md#45-text-files-c-and-enc) |
| `CSDATA.C` | every cutscene and dialogue, in a small scripting language | [§ 4.8](ANALYSE.en.md#48-cutscene-instruction-set-csdatac-0x20a00) |
| `PTnTEXT.C`, `OBJTXTn.C`, `BGTEXT.C`, `INFOBAR.TXT` | lines of dialogue, object names, verbs | [§ 4.5, 4.10](ANALYSE.en.md#410-interface-panel-verbs-font-sentence) |
| `ACTIONn.C` | "verb + target → result" rules | [§ 4.14](ANALYSE.en.md#414-actions-actionnc-exits-buds-special-animations) |
| `SPEECH\SAMnnnn.WAV` (4,196) | voices; number = (part − 1) × 3000 + `tpo` base + line number − 1 | [§ 4.7](ANALYSE.en.md#47-sound) |
| `MUSIC\`, `FX\`, `FX.C` | music, sound effects, per-location ambience (7 effect types) | [§ 4.7](ANALYSE.en.md#47-sound) |
| `SAVEGM.nn`, `NOFILES.DTA` | saves: 2,000 bytes (flags, inventory, location, Bud's position) | [§ 4.6](ANALYSE.en.md#46-saved-games-0x25424-sloteax) |
| `CHARSET.PCX`, `CHARSIZE.DTA` | 10×10 font and character widths | [§ 4.10](ANALYSE.en.md#410-interface-panel-verbs-font-sentence) |
The trap with the `.C` files: the game reads them **by fixed-width columns** and ignores the separator.
`dw 04-178,040` and `bus,014;wa+;` are therefore valid. A tool that splits on commas gets it wrong.
---
## 5. How the recompilation works
The game is **neither emulated nor rewritten**: its x86 code is **translated to C**, then compiled for
Windows.
```
TUCKER.EXE (player's) ──► tools/le.py: reads the LE, relocations
──► tools/recomp.py: disassembly (Capstone), one C function per x86 function
──► build/gen_*/*.c (never distributed)
──► MSVC + runtime/ ──► build/tucker.exe
```
### The translator (`tools/recomp.py`)
- **Code discovery** by recursive descent from the entry point, the call targets and **every relocated
code address**. In an LE, a function pointer is necessarily a relocation: coverage is therefore
complete, with no heuristics.
- **One C function per x86 function**. A jump into another function becomes a tail call; a block shared
by two functions is duplicated in each.
- **Faithfulness**: each instruction becomes C acting on the state of the emulated CPU. `call` really
pushes the return address, `ret` pops it: the game's stack is the real one.
- **Lazy flags**: an instruction that changes CF, ZF… only records (operation, size, operands, result);
the flags are computed only if an instruction reads them.
### The runtime (`runtime/`)
| File | Role |
|---|---|
| `cpu.h`, `cpu.c`, `fpu.c` | registers, single flat memory, flags, x87 (the subset Watcom uses) |
| `loader.c` | loads the player's LE into memory and applies the relocations |
| `dos.c` | DOS/4GW (int 21h), DPMI (31h), BIOS (10h, 16h), mouse (33h), CD (2Fh); redirects files to the game, the mods and `saves/` |
| `machine.c` | VGA, PIT timer, PIC, keyboard; hardware interrupts |
| `ail.c`, `audio.c` | Miles AIL replaced by a modern mixer |
| `overrides.c` | game functions rewritten by hand (sound, timer, `int386x`, intercepted drawing) |
| `host_sdl.c`, `gfx_gl.c` | SDL2 window, OpenGL 3.3 rendering and filters (sharp, smooth, xBR, CRT) |
| `menu.c` | F12 menu and `settings.ini` |
| `mods.c`, `hd.c`, `sprites.c`, `hd_sprites.c`, `png.c` | mods, HD background pack, HD sprites (in progress) |
| `main.c` | runs `INTRO.EXE` then `TUCKER.EXE`, like the original `BUD.BAT` |
### Overrides
`runtime/overrides_tucker.txt` and `overrides_intro.txt` list the game functions replaced by hand-written
C. The original stays callable (`ORIG(FN_xxx)`). This is how the modern sound is plugged in instead of
Miles AIL, how sprite drawing is intercepted for HD, and it is the future hook point for code mods.
### Busy-waits: the game sleeps instead of spinning
In 1996, a DOS game waited in a loop: `while (ticks < ticks_per_frame) ;`. Translated as is, this loop
kept a CPU core busy for nothing (about 20 % of a core for the game, 55 % for the intro).
- The translator **recognises pure wait loops by itself** (loops that only re-read memory without
changing anything): 7 in `TUCKER.EXE`, all on the tick counter.
- The ones that call a function on each pass (the intro keeps the sound fed while waiting) are listed by
hand in `runtime/attentes_intro.txt` (14 loops).
- On each pass, the runtime **sleeps until the next event** (clock, timer, frame): the only thing that
can end the loop. The game's pace does not change.
- Result: 1 to 3 % of a core for the game, 1.1 % for the intro. Nothing is redrawn when the screen does
not change or the window is minimised.
---
## 6. Named addresses
Every address of the French version that the runtime uses is in **`runtime/addr_fr.h`**, with a name and
a comment. Elsewhere in `runtime/`, a raw address is never written.
| Prefix | Meaning | Examples |
|---|---|---|
| `FN_` | function of `TUCKER.EXE` (generated name `F_` + address) | `FN_VOIX_JOUE` (play voice, `0x11F64`), `FN_SPR_DESSINE` (draw sprite, `0x10F18`), `FN_COPIE_ECRAN` (copy to screen, `0x10D88`) |
| `ADR_` | variable or point in the code | `ADR_SOUND_ON` (`0x41F90`), `ADR_TICS` (`0x46634`), `ADR_LECTEUR_CD` (CD drive, `0x4671C`), `ADR_DEFILEMENT` (scroll, `0x46854`) |
| `INTRO_` | same thing for `INTRO.EXE` | the 18 emulated Miles AIL API functions, the intro's sound channels |
This is what will make the other versions of the game possible: write an `addr_xx.h` with the same
names, without touching the rest of the code.
---
## 7. Game versions
Survey of the available versions, 2026-12-05:
| Version | `TUCKER.EXE` | Texts | Voices | Status |
|---|---|---|---|---|
| **French** (reference) | 284,677 bytes | plain `.C`; partial translation: verbs, objects and voices in French, ~80 % of the dialogue lines in English | 4,196 | ✅ supported |
| English | 283,861 bytes | `.ENC` | 4,048 | to do |
| German | 285,277 bytes | `.ENC`, names ending in `…GR` (`PT1TXTGR.ENC`) | 4,154 | to do |
| Spanish | 285,149 bytes | `.ENC` | **none** (text only) | to do |
| Polish | (ISO image) | not studied | | to do |
- **`.ENC`** = the same text as `.C`, each byte increased by `0x80` (the game tries `.enc` then `.c`, and
subtracts `0x80` on reading). Same format.
- **Each language has its own `TUCKER.EXE`**, rebuilt by the publisher: the code is shifted, so the
addresses change. `DOS4GW.EXE` and `SETSOUND.EXE` are identical everywhere; `INTRO.EXE` is identical
between the French, English and Spanish versions, different in the German one.
- Plan: one address table per version (`addr_xx.h`), found by byte signatures, and version detection at
install time. No fork. See the [roadmap](ROADMAP.en.md).
---
## 8. What the project adds on top
| Addition | How | Docs |
|---|---|---|
| Modern rendering and filters | the game's 320×200 screen becomes an OpenGL texture, filtered by a shader | [Guide § 8](GUIDE.en.md#8-a-great-picture-on-a-big-screen) |
| HD background pack | the engine recognises the displayed background (and its scroll) in the game screen, and shows the HD image wherever the game has drawn nothing on top; fades carried over | [TEXTURES.en.md](TEXTURES.en.md), [MODS.en.md](MODS.en.md) |
| HD sprites (in progress) | the 3 RLE drawing routines and the sheet cutting are intercepted: for each frame we know which sprite is drawn, where it comes from and where it goes | `runtime/sprites.h` |
| Mods | `dos.c` serves a mod's files instead of the originals (`files/`) | [MODS.en.md](MODS.en.md) |
| Sound | SDL2 mixer instead of Miles AIL, separate volumes | `runtime/audio.c` |
| Settings | F12 menu, `settings.ini` shared with the launcher | [SETTINGS.en.md](SETTINGS.en.md) |
---
## 9. Curiosities found along the way
- **A debug mode** exists (`[0x46714]` ≠ 0, set by the header of `DATA4.C`): F1 next location, F3 object
number, F5 to F10 Bud's animations. The shipped version has it disabled.
- **An F3 hint system** is coded (steps, "Press F3" after 1,000 idle ticks) but switched off in the
shipped version (`dw 00,00`).
- **Pause (P)** lets you replay Bud's last 5 lines with keys 1 to 5.
- **Files never read**: `ACTION.C`, `DATA2.C`, `EXIT.C`, `COMMON.C`, `PT1.C`, `TEST.C`, `OBJTXT.C`,
`CSDATA1.C`: development leftovers.
- **Errors in the data**, kept as they are: `bud,004` in `CSDATA.C` (argument too long, "Instruction not
recognised"), a missing `fx226.wav` sound effect, an FX slot pointing to a slot not loaded yet.
- **The `ax`/`ay` fields of sprites** are read and never used: the engine takes the absolute position.
Leftovers of the cutting tool.
- **A single frame out of 17,022** overflows (frame 19 of `C24_09.SPR`, 3 bytes): no visible effect.
- **The terminal in location 70** compares the input with a line of `INFOBAR.TXT`: the password
therefore depends on the language.
All of this is detailed, with the addresses, in [ANALYSE.en.md](ANALYSE.en.md).
---
## 10. What remains to be understood
- The **town map** and **Bud's walk** are understood, but only by reading the code: the recomp runs them
as they are, without having reimplemented them.
- The **`INTRO.EXE` cutscenes** (FLC): translated and run, little documented.
- The **other versions**: only the file differences are surveyed ([§ 7](#7-game-versions)).
- The **HD sprites**: capture is done and checked to the pixel; rendering is in progress.
A question, a discovery? Open an issue on the repository.
+1 -1
View File
@@ -1,6 +1,6 @@
# Documentation technique : ce qu'on sait du jeu, comment marche la recomp
🇫🇷 Français (pas encore traduit) · Pour jouer : [guide complet](GUIDE.md)
🇫🇷 Français · 🇺🇸 [English](TECHNIQUE.en.md) · Pour jouer : [guide complet](GUIDE.md)
Cette page rassemble ce que l'étude du jeu et la recompilation ont appris de *Bud Tucker in Double
Trouble* : son exécutable, ses fichiers, sa boucle de jeu, et la façon dont le projet le fait tourner
+1 -1
View File
@@ -332,7 +332,7 @@ The **CRT** filter always shows the original image (it simulates a 1996 screen):
| I want the original back | Untick **HD backgrounds** (or F12 in game); or rename the mod folder with a leading `_`. |
For everything else: [complete guide, Troubleshooting](GUIDE.en.md#13-troubleshooting) and [mod
technical details](MODS.md) (in French).
technical details](MODS.en.md).
---
+11 -1
View File
@@ -17,11 +17,15 @@ PAGES = {
"GUIDE.md": "Guide",
"GUIDE.en.md": "Guide-EN",
"SETTINGS.md": "Reglages",
"SETTINGS.en.md": "Settings",
"MODS.md": "Mods",
"MODS.en.md": "Modding",
"TEXTURES.md": "Textures-HD",
"TEXTURES.en.md": "HD-Textures",
"TECHNIQUE.md": "Technique",
"ANALYSE.md": "Analyse-du-jeu",
"TECHNIQUE.en.md": "Technical",
"ANALYSE.en.md": "Game-analysis",
"ROADMAP.md": "Feuille-de-route",
"ROADMAP.en.md": "Roadmap",
}
@@ -53,7 +57,9 @@ an HD background pack and mods.*
- **[Complete guide](Guide-EN)**: tools to install, launcher, build, playing, filters, HD pack,
mods, saved games, troubleshooting.
- **[HD textures](HD-Textures)**: install Upscayl, export the backgrounds, upscale them, retouch them.
- [Settings](Reglages) and [Mods](Mods) reference pages, [technical documentation](Technique) and [game analysis](Analyse-du-jeu) (in French).
- [Settings](Settings): `settings.ini`, F12 menu, command-line options.
- [Mods and HD pack](Modding): mod format and HD backgrounds.
- [Technical documentation](Technical): what we know about the game, how the recomp works; [detailed analysis](Game-analysis).
- [Roadmap](Roadmap)
## En bref / In short
@@ -84,6 +90,10 @@ SIDEBAR = """**DoubleTroubleRecomp**
🇺🇸
- [Complete guide](Guide-EN)
- [HD textures](HD-Textures)
- [Settings](Settings)
- [Mods and HD pack](Modding)
- [Technical documentation](Technical)
- [Game analysis](Game-analysis)
- [Roadmap](Roadmap)
[Code source]({repo})