Hard to explain it in a good
way.
If you don't understand all that I'll put here, it's just
normal 
I'll
edit this post later, but for Joel this is a start.
code:
# bytes name description
------- --------------- --------------------------------------------
4 x1 unknown (version ?)
4 w width of map - 1
4 h height of map - 1
(4) act act of the map, from 0 to 4
(4) x2 unknown
4 num_files number of dt1 / tg1 files (unused)
? num_files string (unused)
(4) num_wall number of wall's layers
(4) num_floor number of floor's layers
If x1 = 3, there is NO act data in the header (skip it).
If x1 = 3 or 8, these datas are NOT present in the file (skip
them) :
* x2
*
num_wall
* num_floor
As a general rule, only read ds1 which have x1 different of 3 and
8.
The format when it is 3 or 8 cause problems. It still need to
be learn.
Now follow a variable amount of layers.
Each layers have
(w+1) * (h+1) cells.
Each cell is 4 bytes.
There are 2 layers
by wall in the file !
To compute the total number of layers *in the file* :
if x2 not equal 0
maxlayer = x2 + (num_wall * 2) + num_floor;
else
maxlayer = 1 + x2 + (num_wall * 2) + num_floor;
(but follow this :
if x1 = 3 or 8 or 12
then maxlayer = 6
if x1 = 13 then maxlayer =
7
)
The ds1 format is not really well-known as you see
The cells are in the common way of reading : left to right, then
up to down.
First come num_wall * 2 layers, for walls
Then come num_floor
layers, for floors
Then come the unknown rest (maxlayer - x3*2 -
x4)
After this layers, 4 bytes for number_objects. Each objects in
the map is 5 datas
of 4 bytes each. The 5th seems to always be
zero. The 1st is either 1 or 2.
After, come the paths infos.
First 4 bytes for
npc_path.
then npc_path datas, structured like :
4 bytes for some_number
4 bytes for
?
4 bytes for ?
then
some_number datas structured like :
4 bytes for ?
4 bytes for ?
4
bytes for ?
I never took the time to understand the objetcs or the paths
infos (as you see).
Now, some ds1 / dt1
relations.
==============================
Islveo's ds1 editor
named each 4 bytes of a cell prop1 to prop4.
First, let's draw all the floor layers (num_floor
layers)
---------------------------------------------------------
if
the prop1 of the cell is not 0
draw the tile with
:
orientation = 0
sub_index = prop2
main_index = (prop3 /
16) + ((prop4 & 0x0F) * 16)
The main_index of the dt1 is split in 2 in the ds1.
A nibble
is 4 bits, half of a byte.
The low nibble of main_index in dt1 is
high nibble of prop3 in ds1.
The high nibble of main_index in dt1
is low nibble of prop4 in ds1.
(hence the precedent main_index
formula)
Now let's draw walls (num_wall
layers)
--------------------------------------
There are 2
layers in the file for each layer of walls.
The 2nd is for the
orientation of the dt1
the 1st is for the rest
I'll explain later, too much complex.
Look in my ds1scene.c
programm.