A remake of the classic Wizardry video games

Copyright Eric Pietrocupo


E-Mail: ericp@lariennalibrary.com


Wizardry Legacy

WL Adventures

Maze Data Structure

Filed in: Development.DVmazedata · Modified on : March 17, 2018, at 01:43 AM - Visits 2778

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

Mazetile 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

7-65-43-21-0
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 : 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.

76543-0
UndefinedLightSolidMagic BounceRoom Filling

The room filling goes as follow. New filling could be added or

Room Filling table

ValueMeaning
0Nothing
1Water
2Fizzle Field
3Fog
4Poison Gas
9Darkness

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 floor objects requiring only the use of 4 bits to reference them.

7-43-0
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).

7-54-0
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.

7-65-43-0
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

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

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.

7-43-0
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.

7-65-43-0
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