Timing data
Data · Routines · Address index
The timed-callback table, counters and step pacing, script timers, and the state of sound effects and the sound driver. The data page explains how the entries are written.
DS:0x5bfc — Timed-callback table
-
Layout: 16 records of 16 bytes; entry count word at
DS:0x5cfc(16 in the executable's data). Record: far handler (+0), interval dword (+4), deadline dword (+8), argument word (+0xc), byte+0xe(0 in every entry; written only by set a timed callback, which nothing calls, and never read), enabled byte (+0xf). -
Role: The fixed set of periodic updates processed by timed callbacks. Intervals are in shared-counter ticks. In the executable's data:
| Entry | Handler | Interval | Enabled | Argument | |-------|-------------------------------------------|---------:|:-------:|----------| | 0 |
0x27b7f| 9 | no | — | | 1 |0x27e31| 3 | yes | — | | 2–5 |0x28218| 20 | yes | 0–3 | | 6–11 |0x283f5| 50 | no | 0–5 | | 12 |0x27f68| 5 | yes | — | | 13 |0x2807e| 10 | yes | — | | 14 |0x2893f| 1080 | yes | — | | 15 |0x2899c| 25 | yes | — |The stored first deadlines of entries 2–5 are 0, 7, 14 and 14; all the others are 0. Nothing resets them when a game starts: a deadline is written only after a run of its entry (
0x2816e–0x28172), by set a timed callback and, for entries 2–5, by the monster-timer loader (overlay code at file offsets0x48c62–0x48c8a). An enabled entry runs when its deadline is below the counter (0x2813b–0x28147), so one with deadline 0 runs at the first pass after the counter has started. The monster-timer loader replaces the intervals of entries 2–5 when a level is loaded. The interval 50 of entries 6–11 is replaced by set a character timer and by each run of the timer handler, which make the entry fire at the character's earliest timer deadline. -
Comparative source: REF-SCUMM-014,
setupTimers. -
Used by: Character record › Character timers, Monsters › How a monster acts, Timed updates › The table of timed updates, Timed updates › The table of timed updates, Level data (INF), Tools
DS:0x6676 — State of the drawing generator
- Layout: 3 bytes, initially
0x34,0x12,0x76 - Role: State of
0x33dc4; nothing else uses it, so the sequence depends only on how often the routine has run. - Used by: Drawing helpers
DS:0xf16c — Screen refresh wait mode
- Layout: word
- Role: Set at start-up by
0x2f7a3and passed to0x34059by each wait: 1 waits for a retrace to start, 0 for one to end. - Used by: Wait for screen refreshes
DS:0x667c — Free-running counter
- Layout: dword
- Role: Advanced by one on every tick of the
timer interrupt, 18.2 times per second, and never
stopped. Waits read it: the script wait, the
wait routine and the overlay 248 helper
0x4646aeach loop until it has advanced by the number of ticks requested. - Comparative source: REF-SCUMM-022.
- Used by: The game clock › Ticks and the two counters, Wait › Behavior, The ending, The introduction
DS:0xdf2c — Step pacing flag
- Layout: byte
- Role: Set to 1 by the step and turn commands (
0x1c003,0x1c048,0x1c073,0x1c096,0x1c0ce,0x1c116), cleared at game start (0x1cb4f) and by the party path of move the party or an object at0x25f89. While it is set, the scene redraw waits for the free-running counter to reach the next step time; after drawing, it clears the flag. Role (pacing steps and turns to one redraw per 4 ticks) inferred. - Used by: Move the party, monsters or items › Moving the party
DS:0xdf24 — Keyboard pick-up zone
- Layout: byte
- Role: Current zone of the keyboard pick-up cycle, advanced by
0x1c6d9; set to0xff, restarting the cycle, by the turn and step commands, by move the party or an object and by turn the party (0x27547). - Used by:
DS:0xe442 — First item of a keyboard take
- Layout: word
- Role: The first item taken since the zone last changed, −1 when
none, used by the keyboard take. While it is set the
zone does not advance (
0x1c72a), so repeated presses of G walk through a pile, each one taking the top item and appending the one held. When the top item is that first item again, it is put back; that case and an empty zone clear the variable (0x1c79f,0x1c88d–0x1c8b7), and a press with nothing taken tries the next zone, up to five tries over the four zones (0x1c8c3). - Used by:
DS:0xeef2 — Next step time
- Layout: dword
- Role: Value of the free-running counter before which a paced
redraw waits. Set to the counter at game start (
0x1cb41–0x1cb4b) and to the counter plus 4 by the scene redraw after each paced redraw (0x3f7df–0x3f7fb). See the step pacing flag. - Used by:
DS:0x6684 — Shared counter
- Layout: dword; 0 in the executable's data
- Role: Advanced by one on each tick of the
timer interrupt, 18.2 times per second, while bit 1
of the counter switches is set. Every game deadline is a value
of it: the timed callbacks, the character timers, the
script timers and the temporary walls. The
rest adds 32 760 to it per hour (
0x45687). - Used by: Resting: special cases › Anomalies while resting, Resting › Every hour and every eight hours, Resting › When the rest ends, Run a special event › Lightning (event 0), The game clock › Ticks and the two counters, Timed scripts › Timed block scripts
DS:0x6690 — Counter switches
- Layout: word; 0 in the executable's data
- Role: Bit 0 lets the timer interrupt advance the
dword DS:
0x6680, bit 1 the shared counter. Only restart and stop a counter write it, always for bit 1; bit 0 is never set, so DS:0x6680never advances, and no reader of it was found. - Used by: The game clock › Pauses
DS:0x668c — Flash countdown
- Layout: dword
- Role: Decreased by one on each tick of the
timer interrupt while it is not zero. The
close-range action sets it to 0 and then 8 around
a monster's attack frame, flash a damaged monster
to 0 and then 1, and finish deferred damage to 1;
the scene redraw reads it at
0x3f753. - Comparative source: REF-SCUMM-022,
flashMonsterShapeandupdateMonsterTryCloseAttack(_flashShapeTimer). - Used by: —
DS:0xcbc8 — Script timers
- Layout: 8-byte records: target block, period, deadline
- Role: Timers loaded by overlay routine
0x486e9, which multiplies their periods by 18, and processed by the script timers routine, which passes the block word with event0x80to the block event dispatcher (0x24efb–0x24f01). Their count is DS:0xe4c8; no limit is checked. The next data the code addresses is at DS:0xcc14, which leaves room for nine records. - Used by: Timed scripts › Timed block scripts, Level data (INF), Level 4: reference tables › Wolves, Level 10: reference tables › Level data, Level 11: reference tables › The moving pit
DS:0xef2a — Ambient-sound deadline
- Layout: dword
- Role: Shared-counter value after which the
game loop queues sound 27 or 28 (1d2) as an
environmental sound from the block whose index is
the party's plus 1d12 − 1 (
0x1ca67–0x1cae5); reset to the counter plus 18 × (1d10 + 3) each time. - Comparative source: REF-SCUMM-014,
runLoop(_envAudioTimer). - Used by: The game loop › One pass of the game loop
DS:0xef58 — Sound-effect table
- Layout: 120 bytes, one per sound-effect number
- Role: Filled with the first 120 bytes of the current sound file by
load the sound file, at start-up and at every level
load. The sound-effect player reads entry n for
sound effect n (
0x2cadb): 255 plays nothing, any other value is passed to the sound driver. No other reader or writer was found, apart fromSCRIPT_MODIFY_CHARACTER_HP: character record 7, past the end of the characters, would start atDS:0xef77, so entry 32 is the status byte that it reads for slot 7. - Used by: Play a sound › The sound-effect table, Level 4: reference tables › Sounds, Change hit points › Edge cases
DS:0x638a, DS:0x638c — Sound driver
- Layout: word
0x638a, byte0x638c - Role:
0x638ais the sound driver: 1 AdLib (the.ADLfiles), 2 PC speaker and 3 Tandy sound chip (the.SNDfiles), 0 none. The start-up reads it as the second word ofEOSPREFS.DAT(0x18912–0x18921), sets the "Sounds" option when it is not 0, and starts the driver.0x638cis 1 for driver 3 and 0 for driver 2. The devices follow from the ports each driver writes:0x388–0x389for driver 1, the speaker ports0x42and0x61for driver 2, port0xc0for driver 3.SETUP.EXEwrites the value as the second of the three words ofEOSPREFS.DAT(image offsets0x485–0x4f0): its sound menu stores 1 for "Adlib or Sound Blaster", 2 for "Built in speaker" and 0 for "No Sound" (0x10b9,0x10f9,0x111d). Its summary screen also names a value of 3 "Tandy speaker" (0x14da), but no store of 3 was found in the program, so driver 3 is reached only with anEOSPREFS.DATwritten otherwise. The referenceEOSPREFS.DATholds 1. - Used by: PC speaker and Tandy sounds (SND) › In brief, Sound and music, From files to the game, Settings (EOSPREFS.DAT)
DS:0x6a80–DS:0x6c48 — Speaker and Tandy sound state
-
Layout: the data of the speaker and Tandy sound routines, which address it with segment
0x31be, that isDS:0x6a80+ offset. The main fields, as data-segment offsets:Offset Size Content 0x6a84,0x6a862 words Reload, 15, and countdown of the interrupts before the BIOS handler is called. 0x6a88far pointer The program playing. 0x6a8c4 words Position of each voice in the program. 0x6a94far pointer The program requested. 0x6a9896 words Speaker note table: system timer divisors, 0 for note 0 (a rest), 65 023 for note 1 to 285 for note 95. 0x6b5896 words Tandy note table: chip divisors, 0 for note 0, 1023 for notes 1–31, down to 27 for note 95. 0x6c18byte Port 0x61as saved at start-up.0x6c19word Voice count, 1 or 3. 0x6c1b–0x6c1d3 bytes Playing, start request, stop request. 0x6c1e–0x6c293 × 4 bytes Per voice: stop, waiting for an element, ended. 0x6c2a4 words Per voice: countdown. 0x6c324 bytes Per voice: level, 15, 10, 5 and 0 in the file image. 0x6c36–0x6c413 × 4 bytes Per voice: tempo factor, loop counters A and B. 0x6c42,0x6c432 bytes Start delays of voices 1 and 2. 0x6c44byte Busy while a sound plays. 0x6c45byte Tandy flag: the output goes to the Tandy chip when 1, to the speaker otherwise. 0x6c46,0x6c48word, byte Interrupt count within the second, 0–291, and a count of seconds, 0–59; only the interrupt handler uses them. -
Role: Written and read by the timer interrupt, the sound run, the output and voice routines; the Tandy flag also by the sound-effect player and the driver start. The note tables are not changed at run time: notes follow an equal-tempered scale, the speaker table within 14 cents of it.
-
Comparative source: REF-SCUMM-023,
_periodsPCSpkand_periodsPCjr. -
Used by: Playing speaker and Tandy programs › How a program plays