3.1 Directory files
by Lance Ewing
<be@ihug.co.nz>
Last updated: 31 August 1997
All AGI games have either one directory file, or more
commonly, four. AGI version 2 games will have the files LOGDIR,
PICDIR, VIEWDIR, and SNDDIR. Games that use version 3 of the AGI
interpreter will have a single file called *DIR where the star is
the initials of the game (eg. BC, GR, MH2, MH1, KQ4). This single
file is basically the four version 2 files joined together except
that it has an 8 byte header giving the position of each
directory within the single file.
The directory files give the location of the data types within
the VOL files. The type of directory determines the type of data.
For example, the LOGDIR gives the locations of the LOGIC files.
For a brief introduction to the different data types, read the
AGIDOC.TXT document.
Note: In this description and elsewhere in documents written
by me, the AGI data called LOGIC, PICTURE, VIEW, and SOUND data
are referred to by me as files even though they are part of a
single VOL file. I think of the VOL file as sort of a virtual
storage device in itself that holds many
files. Some documents call the files contains in VOL files
"resources".
Version 2 directories
Each directory file is of the same format. They contain a
finite number of three byte entries, no more than 256. The size
will vary depending on the number of files of the type that the
directory file is pointing to. Dividing the filesize by three
gives the maximum file number of that type of data file. Each
entry is of the following format:
| Byte 1 |
Byte 2 |
Byte 3 |
| 7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
| V |
V |
V |
V |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
P |
V = VOL number.
P = Position (offset into VOL file)
The entry number itself gives the number of the data file that
it is pointing to. For example, if the following three byte entry
is entry number 45 in the SOUND directory file,
12 3D FE
then SOUND.45 is located at position 0x23DFE in the VOL.1
file. The first entry number is entry 0.
If the three bytes contain the value 0xFFFFFF, then the
resource does not exist.
Version 3 directories
In the case of version 3 of the AGI interpreter, the LOGDIR,
PICDIR, VIEWDIR, and SNDDIR are concatenated together in that
order with an eight byte header giving the starting offset of
each directory.
Header
| Byte |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
| |
L |
L |
P |
P |
V |
V |
S |
S |
L = offset of LOGDIR
P = offset of PICDIR
V = offset of VIEWDIR
S = offset of SNDDIR
Each offset is two bytes in length where the first byte is the
low byte and the second byte is the high byte as is the case in
the whole AGI system. For example, the first two bytes will
always be 0x0800 since the header is a fixed size of eight bytes.
The format of each of the individual directory sections then
follows as above for AGI v2.