A remake of the classic Wizardry video games

Copyright Eric Pietrocupo


E-Mail: ericp[AT]lariennalibrary.com


Wizardry Legacy

WL Adventures

Maze Data Structure

Filed in: Development.DVmazedata · Modified on : Sun, 12 May 13 - Visits 747

The data structure of the maze in wizardry is pretty ingenious. The structure currently used will probably be changed in later version of the programm to be able to handle more features. Surprisingly, my engine is has much more stronger capabilities than the NES and SNES ports.

Thin Walls

Wizardry use a map system that allow to create thin walls. It took me a lot of time to know how to program these kind of walls. The first thing people are thinking about is to use a grid in indicate which square is solid or not, but that does not allow to have thin walls. The way to do it is to keep the information about the surrounding wall within the square.

So each square of the grid will record which sides are walled if the player was located in the middle of the square. This has the advantage of creating thin walls, but also have the disadvantage of creating 1 sided wall bugs. Still, Wizardry made it a feature rather than a bug.

The 1 sided wall or door bug is created if 2 adjacent square does not hold the same information about wall positions. For example, the left square could say that there is a wall to the right, but the right square could say that there is no wall to the left, allowing a player to move from right to left, but not other wise

Current Structure

1st Byte (bit 0-7): Solid

0-12-34-56-7
NorthEastSouthWest

The first byte is divided in 4 sections of 2 bits. Each section represent one of the 4 walls. With 2 bits, there are 4 possible values

Wall encoding

BitsMeaning
0-0Nothing
0-1Wall
1-0Grid
1-1Door

2nd Byte (bit 8-15): Walltex

ID of the masked texture to place on any of the wall. Masked texture can be overlapped above regular wall texture.

3rd Byte (bit 16-23): Floortex

Same thing as for wall tex but placed on the floors instead.

4th Byte (bit 24-31): Objectimg

ID of the picture of an object to be displayed inside the room.

5th Byte (bit 32-39): Event

ID of the event in the database, 0 means there is no events.

6th Byte (bit 40-47): Special

The 5 fist bits are flags and the 3 last bit are used to determine room filling.

012345-7
UndefinedLightSolidMagic BounceDarknessRoom Filling

Room Filling table

ValueMeaning
0Nothing
1Water
2Fizzle Field
3Fog
4Poison Gas
5Heat
6Noise
7Undefined

7-8th Byte (bit 48-63): Textures

0-12-56-910-15
Mask Floor/CeilingMask WallObject positionTileset ID
  • Mask Floor/Ceiling: Determines where masked texture is going to be displayed, on the floor, on the ceiling or both. There is a bit for each of them.
  • Mask Wall: Determine on which wall is the masked texture going to be drawn. There is 1 bit for each wall.
  • Tileset ID: Determine which texture set is going to be used. There can be up to 64 texture set where each of them contains 4 textures: Wall, Floor, Ceiling and Door. This is like a primitive texture palette system that is going to be expanded in the new structure.
  • Object position: This field determine how the Object picture is going to be placed inside the room:

Object placement

ValuePlacement
0None
1Center
2North
3East
4South
5West
6Pair on north
7Pair on east
8Pair on south
9Pair on west
104 corners
114 sides
12Square
13Undefined
14Undefined
15Undefined

New Structure

This is a proposed structure for the new maze system in order to support more features and possibilities in how to display the maze. The main changes is that the maze can support up to 16 different texture palettes which should been sections or areas of the maze. Each palette would have a shorter set of masked texture for example that would require less bits in the tile to be able to reference them.

1st Byte : Solid

Used to keep track of the location of wall, grids and doors. Works the same as the original structure.

2nd Byte : Event

Used to keep track of special events in the maze. Contains the key of the event. If more than 256 events are required for the whole adventure, I could make it palette or floor specific giving me 256*16 or 256*20 events. Or I could use less bits and use the extra bits for other event purposes.

3rd Byte : Special

This will work almost as the original except the size will be different. There would now be 4 bits for the filling, where darkness is actually a filling.

01234-7
UndefinedLightSolidMagic BounceRoom Filling

The room fillings are to be redefined.

4th Byte: Floor and Ceiling Objects

Each tile can now have a different Floor, Ceiling and Wall object. Each texture palette can hold up to 16 different object pictures for floors, Ceiling and walls objects requiring only the use of 4 bits to reference them.

0-34-7
Floor ObjectCeiling Object

5th Byte: Palette ID and Wall objects

The palette ID is used to identify which one of the 32 texture palette is going to be used. Wall objects are all thin objects like torches and chains that can be drawn above the wall from any direction and still look good (because objects are always facing the player).

0-23-7
Wall ObjectsPalette ID

6th Byte: Object Positions

Objects can be placed in various positions on the ceiling and the walls, this byte is used to keep track of these positions. Individual Objects can have 9 different position arranged as a 3x3 grid.

0-12-34-7
Wall ObjectCeiling ObjectFloor Objects

Wall Object placement

ValuePlacement
0None
1Center
2Pair top of wall
3Pair center of wall (or bottom)

Ceiling Object placement

ValuePlacement
0None
1Center
24 corners
34 sides

Floor object placement should be the same, or very similar to the original structure (see above).

7th Byte: Masked Texture for Floors/Ceiling and Walls

Masked texture are special textures added over the regular wall texture to identify certain areas as different from the others (for example stairs down). Each palette has a selection of 16 textures for walls and for floor/ceiling that the player can use.

0-34-7
Floor/Ceiling Texture IDWall Texture ID

8th Byte: Grid Texture, Masked Floor/Ceiling and Wall texture position

The first 2 bits are used to reference the grid textures. Each palette can have up to 4 different grid and these 2 bits are used to select the right grid to display. The other bits are flags that determine where the masked texture selected in the previous byte is going to be displayed.

0-12-34-7
Grid Texture IDFloor/CeilingWall

Floor/Ceiling texture placement

BitsPlacement
0-0None
0-1Floor
1-0Ceiling
1-1Both

Wall texture placement

BitPlacement
0North
1East
2South
3West

Other Maze information

The structures above are not the only place where information about the maze are stored. There are data structure for each floor, the new structure will contain data for the texture palette and the database contains a list of events that can be triggered inside the maze.

The importance of having a compact tile structure is because it gets repeated thousands of time. It is important to be able to fit the most information possible in the least amount of space. THis is why each bit must be used to it maximum capacity.

File Size

The maze size can be estimated the following way:

Width (100) x Length (100) x Depth (20 levels) x Tile Size (8 byte ) = 1600000 bytes.

1600000 / 1024 = 1562.5 K / 1024 = 1.52 Meg

This means that each adventure will have a minimum size of 1.5 Meg. Then you add the pictures, the database and the text to get the final adventure size.

<< Discussion Threads | Table of contents | Maze Events system >>

new structure notes: search in details in notes. From what I remember.

- Use 16 texture palette (4bit) - Objects could be split in wall, ceiling and floor objects which can each have a 4 or 6 bit lookup inside the palette. Placement problem since need 3 times the placement bits (Wall, Ceiling, Floor). - Wall and floor tex will probably use 4 bit each - I remember there was a leftover 2 bits for grid model selection. - The solid byte will probably stay the same. - Special and maze filling will have to be redefined. Probably darkness goes into filling.

Powered by PmWiki and the Green skin