Skip to main content

ADL field reference

File page · Format catalogue · Schema source

This page is generated from the Kaitai schema ADL.ksy each time the site is built. The schema is the authoritative description; statements are established unless marked inferred or unknown, and the evidence is listed on the file page (see the reading guide).

  • Schema: Eye of the Beholder II DOS AdLib sound file (ADL)
  • Byte order: little-endian
  • File extension: adl
  • Schema license: MIT

Description​

Music and sound effects for the AdLib sound driver (driver 1). The game loads one file at a time: the sound file named by the current level, or INTRO and FINALE1/FINALE2 for the introduction and the ending.

The first 120 bytes are the sound-effect table, which the game keeps for itself; the rest of the file is copied to the driver unchanged. It starts with two tables of 250 pointers each, to programs and to instruments. A program is a command stream for one of the ten driver channels; a sound is started by queueing a program number. Instrument data is last. All pointers count from byte 120, the end of the sound-effect table; 0 means that the entry is absent.

In the original files the program data starts right after the pointer tables, at pointer value 1000 (byte 1120), and the last instrument ends on the last byte of the file. The driver accepts at most 15,120 bytes after the sound-effect table. See the format overview.

File structure​

FieldTypeSize, repetition and constraints
sound_effect_tableu1repeated 120 times
program_offsetsu2repeated 250 times
instrument_offsetsu2repeated 250 times

sound_effect_table

Program number to start for each game sound number 0-119; 255 means that the sound plays nothing. Game sound n reads entry n. See the sound-effect table.

program_offsets

Offset of each program from byte 120 of the file; 0 when the program is absent. Several numbers may share one program. In the original files the numbers used run from 0 without gaps, up to between 10 (FINALE2.ADL) and 210 (AZURE.ADL).

instrument_offsets

Offset of each instrument from byte 120 of the file; 0 when the instrument is absent. Every instrument selected by a program of the original files is present.

Derived values and positioned data:

FieldTypeSize, repetition and constraints
programsprogram_slot(_index)repeated 250 times
instrumentsinstrument_slot(_index)repeated 250 times

programs

The 250 program entries, in number order.

instruments

The 250 instrument entries, in number order.

Type program_slot​

Parameters: index (u1)

Derived values and positioned data:

FieldTypeSize, repetition and constraints
offsetcomputed: _root.program_offsets[index]—
bodyprogramonly if offset != 0; at position 120 + offset; in stream _root._io

body

The program, absent when the offset is 0.

Type instrument_slot​

Parameters: index (u1)

Derived values and positioned data:

FieldTypeSize, repetition and constraints
offsetcomputed: _root.instrument_offsets[index]—
bodyinstrumentonly if offset != 0; at position 120 + offset; in stream _root._io

body

The instrument, absent when the offset is 0.

Type program​

A command stream for one channel. When a program is started, it replaces the program running on its channel only if its priority is at least that of the running one; the channel is then reset and runs its first commands on the next driver tick.

Commands run until one sets a non-zero duration; the channel then waits that many steps before running the next ones. A channel takes a step each time its tempo, added to an 8-bit counter on every driver tick (about 72.8 per second), carries past 255.

This schema reads commands in sequence up to the first stop, jump or return. In the original files every program ends with a stop and contains no jump, call or return; repeat loops jump backwards inside the program.

FieldTypeSize, repetition and constraints
channelu1—
priorityu1—
commandscommandrepeated until _.is_end

channel

Channel 0-9. Channels 0-8 are the nine AdLib voices; channel 9 has no voice. In the original files, channel-9 programs start the other channels of a tune, fade them out or silence them.

priority

Priority against the program already running on the channel. In the original files 0-55; tunes are started by a channel-9 program of priority 4.

Type command​

A note (first byte 0x00-0x7f) or a command (0x80-0xc9). Bytes 0xca-0xff are not valid commands: 0xf1-0xff stop the channel, and the driver does not handle 0xca-0xf0; no original file contains one.

FieldTypeSize, repetition and constraints
codeu1—
argsswitch on code: 128 → op_byte, 129 → op_rel_jump, 130 → op_byte, 131 → op_byte, 132 → op_rel_jump, 133 → op_call, 135 → op_byte, 137 → op_byte, 138 → op_byte_pair, 139 → op_byte_pair, 140 → op_byte, 141 → op_secondary_effect, 142 → op_byte, 144 → op_byte, 145 → op_slide, 147 → op_byte, 149 → op_vibrato, 154 → op_byte, 156 → op_byte, 157 → op_byte, 158 → op_byte, 160 → op_byte, 161 → op_byte, 164 → op_byte, 166 → op_byte, 169 → op_byte, 171 → op_byte, 172 → op_byte_pair, 173 → op_byte_pair, 174 → op_byte, 175 → op_byte, 176 → op_byte, 179 → op_byte, 181 → op_word_be, 185 → op_byte, 188 → op_byte, 189 → op_byte, 191 → op_byte_pair, 193 → op_rhythm_setup, 194 → op_byte, 196 → op_byte_pair, 197 → op_byte_pair, 198 → op_byte_pair, 199 → op_byte, 200 → op_byte, 201 → op_byte_pair, _ → op_note_or_none(code < 0x80)—

code

For a note: low 4 bits the note within the octave, 0-11, added to the channel's base note; bits 4-6 the octave, added to the channel's base octave. For a command: the opcode.

args

Operands; their number depends on the opcode. A note is followed by its duration. See the opcode enum for each command.

Derived values and positioned data:

FieldTypeSize, repetition and constraints
opcodecomputed: codeonly if code >= 0x80; values: opcode
is_endcomputed: code == 0x84 or code == 0x86 or code == 0x88 or code == 0x8f or code == 0x94 or (code >= 0x96 and code <= 0x99) or code == 0x9b or code == 0x9f or code == 0xa2 or code == 0xa3 or code == 0xa5 or code == 0xa8 or code == 0xaa or code == 0xb1 or code == 0xb2 or code == 0xb4 or code == 0xb7 or code == 0xb8 or code == 0xbe or code >= 0xca—

opcode

The command, for codes 0x80 and above.

is_end

True for a stop, an unconditional jump or a return.

Type op_note_or_none​

Parameters: is_note (bool)

FieldTypeSize, repetition and constraints
durationu1only if is_note

duration

Note duration in channel steps; 0 runs the next command at once. A note takes a third byte, a velocity that adjusts the operator levels, while the channel's velocity shifts set by 0xc9, or the last velocity read, are non-zero; no original file uses 0xc9, so every note of these files is two bytes.

Type op_byte​

FieldTypeSize, repetition and constraints
valueu1—

Type op_byte_pair​

FieldTypeSize, repetition and constraints
firstu1—
secondu1—

Type op_word_be​

FieldTypeSize, repetition and constraints
valueu2be—

Type op_rel_jump​

FieldTypeSize, repetition and constraints
displacements2—

displacement

Signed distance from the byte after this command.

Type op_call​

FieldTypeSize, repetition and constraints
targetu2—

target

Absolute address in the driver's memory: the file byte at 120 + target - 710. Not used in the original files.

Type op_secondary_effect​

FieldTypeSize, repetition and constraints
rateu1—
last_indexu1—
registeru1—
tableu2—

rate

Added to an 8-bit counter every tick; each carry advances the effect by one value.

last_index

The values used are entries last_index - 1 down to 0 of the table, then last_index, and so on.

register

AdLib register written, added to the channel's first operator offset (32 is the register of tremolo, vibrato, envelope type and frequency multiplier).

table

Absolute address of the value table in the driver's memory, like the call target: the file byte at 120 + table - 710. In the original files (rate 47, last_index 3, register 32) it points into the bytes of a program, which serve as the values.

Type op_slide​

FieldTypeSize, repetition and constraints
rateu1—
steps2be—

rate

Added to an 8-bit counter every tick; each carry applies one step.

step

Signed change of the 10-bit frequency number per step, high byte first. Above 733 (rising) the number is halved and the octave raised; at 388 or below (falling) it is doubled and the octave lowered.

Type op_vibrato​

FieldTypeSize, repetition and constraints
rateu1—
depthu1—
half_periodu1—
delayu1—

rate

Added to an 8-bit counter every tick; each carry moves the frequency by one step.

depth

The step is the note's 10-bit frequency number shifted right by 9 - depth; above 9 the step is 0 and nothing moves.

half_period

The direction reverses after half_period + 1 steps, then every 2 * half_period steps.

delay

Ticks after each note before the vibrato starts.

Type op_rhythm_setup​

FieldTypeSize, repetition and constraints
instrumentsu1repeated 3 times
frequenciesu1repeated 6 times

instruments

Instruments for channels 6, 7 and 8.

frequencies

For channels 6, 7 and 8 in turn, the block and frequency-high byte (masked with 0x2f) and the frequency-low byte.

Type instrument​

Eleven AdLib register values, written to the channel's two operators (operator 1, operator 2) when a program selects the instrument.

FieldTypeSize, repetition and constraints
op1_characteristicu1—
op2_characteristicu1—
feedback_connectionu1—
op1_waveformu1—
op2_waveformu1—
op1_levelu1—
op2_levelu1—
op1_attack_decayu1—
op2_attack_decayu1—
op1_sustain_releaseu1—
op2_sustain_releaseu1—

op1_characteristic

Register 0x20 of operator 1 (tremolo, vibrato, sustain, scaling, multiplier).

op2_characteristic

Register 0x20 of operator 2.

feedback_connection

Register 0xc0 of the channel (feedback, connection in bit 0).

op1_waveform

Register 0xe0 of operator 1.

op2_waveform

Register 0xe0 of operator 2.

op1_level

Register 0x40 of operator 1 (key scale level, output level). The driver adds the channel's level offsets to the output level when operator 1 is audible (connection bit 1).

op2_level

Register 0x40 of operator 2. The driver adds the channel's level offsets to the output level.

op1_attack_decay

Register 0x60 of operator 1.

op2_attack_decay

Register 0x60 of operator 2.

op1_sustain_release

Register 0x80 of operator 1.

op2_sustain_release

Register 0x80 of operator 2.

Enumerations​

Enumeration opcode​

ValueNameMeaning
128set_repeatSet the repeat counter (1 byte).
129repeat_jumpDecrement the repeat counter; while it is not 0, jump by the signed displacement.
130start_programStart a program now, with the same priority rule as a queued one; 255 starts nothing.
131set_note_spacingRemaining steps of a note at which it is released.
132jumpJump by the signed displacement.
133callCall commands at an absolute driver address; not used.
134return_from_callReturn from a call; not used.
135set_base_octaveOctave added to every note.
136stopStop the channel and release its note. Every original program ends with it.
137restWait the given number of steps.
138write_registerWrite an AdLib register (register, value).
139note_with_durationPlay a note (note byte, duration).
140set_base_noteSemitones added to every note.
141secondary_effectStart the channel's second effect, which writes values from a table into one AdLib register of the channel.
142stop_channelStop another channel.
143stop_8fSame as stop.
144set_instrumentLoad an instrument into the channel.
145slideStart a frequency slide; replaces a vibrato.
146end_primary_effectEnd the slide or vibrato.
147set_base_frequencyValue added to every note frequency.
148stop_94Same as stop.
149vibratoStart a vibrato; replaces a slide.
150stop_96Same as stop.
151stop_97Same as stop.
152stop_98Same as stop.
153stop_99Same as stop.
154set_priorityChange the channel's priority.
155stop_9bSame as stop.
156set_beatStart the shared beat counter: it counts one beat every (operand / 2) carries of a counter that adds the global tempo every tick (256 carries when operand / 2 is 0). Not used by the original files.
157wait_for_beatWait, one step at a time, until the bits of the beat counter selected by the operand change from all clear to not all clear; if they are set when the wait begins, it first waits for them to clear. Not used by the original files.
158set_level_offsetLevel offset of the channel, added to its output levels.
159stop_9fSame as stop.
160waitWait the given number of steps without a new note.
161note_on_with_durationWait the given number of steps after the note-on routine; not used.
162stop_a2Same as stop.
163stop_a3Same as stop.
164set_fractional_spacingRelease notes when their remaining steps equal this many eighths of their duration, 0-7; not used.
165stop_a5Same as stop.
166set_global_tempoTempo followed by every channel that has tempo reset set.
167end_secondary_effectEnd the second effect.
168stop_a8Same as stop.
169set_channel_tempoTempo of this channel.
170stop_aaSame as stop.
171set_level_offset_3Third level offset of the channel. Most sound effects start with this command, and the game rewrites its operand for a sound played from a block; see a sound at a distance.
172set_channel_level_offsetSet the level offset of another channel (channel, value).
173change_channel_level_offsetAdd to the level offset of another channel (channel, value).
174set_tremolo_depthAdLib deep-tremolo bit (0 or 1).
175set_vibrato_depthAdLib deep-vibrato bit (0 or 1).
176change_level_offsetAdd to the channel's level offset.
177stop_b1Same as stop.
178stop_b2Same as stop.
179clear_channelStop a channel and silence its voice.
180stop_b4Same as stop.
181random_frequencyAdd a random amount, masked by the word (high byte first), to the note's block and frequency number; only the sound registers change, not the stored frequency. The random sequence restarts at the same value every time the driver starts and is shared by all channels; see how a note sounds. In the original files only programs 3-6 of INTRO.ADL use it, with the mask 0x03ff.
182end_primary_effect_b6Same as 0x92.
183stop_b7Same as stop.
184stop_b8Same as stop.
185pitch_bendSigned pitch bend applied to later notes.
186reset_to_global_tempoSet the channel tempo to the global tempo.
187nopNothing.
188set_duration_randomnessMask of a random amount added to every later duration; while it is non-zero, the note-off fraction set by 0xa4 is not applied. In the original files only programs 165 and 198 of AZURE.ADL (values 4 and 3) and 146 and 159 of CATACOMB.ADL (values 2 to 6) use it.
189change_channel_tempoAdd a signed amount to the channel tempo, kept within 1-255.
190stop_beSame as stop.
191command_bfStart switching channel 0's note on and off from the system timer. The first operand enables it when non-zero; the second selects a pair of driver tables (rate and frequency); with a first operand of 2, channel 0 at once takes the first rate and frequency of the pair. Not used by the original files.
192command_c0Stops the switching started by 0xbf; not used.
193rhythm_setupPrepare the percussion voices on channels 6-8.
194rhythm_playStrike percussion instruments (bit mask).
195rhythm_offLeave percussion mode.
196rhythm_set_levelOperands: instrument mask, value. Each percussion level is the sum of three bytes, added in one byte and kept within 0-63; this command sets the third byte of every instrument in the mask and writes the new level. Mask bits: 0 hi-hat, 1 cymbal, 2 tom-tom, 3 snare drum, 4 bass drum, the order of the percussion bits of AdLib register 0xbd. Not used by the original files.
197rhythm_change_levelOperands: instrument mask, value. Adds the value to the level of each instrument in the mask, keeps it within 0-63, writes it and stores it as the second of the three bytes. Not used by the original files.
198rhythm_set_level_2Operands: instrument mask, value. Sets the second of the three bytes of each instrument in the mask and writes the new level. Not used by the original files.
199set_music_markerSet the music marker that the introduction and the ending wait for. Used only in INTRO.ADL (markers 0-8) and FINALE1.ADL (0-5).
200set_tempo_resetWhen non-zero, the channel follows the global tempo on every tick.
201set_velocity_shiftsVelocity shifts for operators 1 and 2; non-zero values add a velocity byte to each note. Not used.