Map Location Data (2) Wooden Walls - HoraceAndTheSpider/Bloodwych-68k GitHub Wiki
Wooden Walls and Doors are identified within the map data, in the second byte within the location's map data word (AB CD), whereby the final digit (D) is equal to '2'.
To understand this data block, it is necessary to translate the map data word (AB CD) into a wall-data parameter by taking the first byte (AB) alone.
The value of (AB) should then be split into 4 items of data, which are read in "base 4". However, it is much easier to look at this data in Binary (base 2) in order to break it down and translate it.
So, any given number for (AB) should be represented as an 8 bit binary value, and spaced into 4 blocks, each of which represent the possible wooden walls in the North, East, South and West directions of the floor-space.
- Bits 0/1 define what is present in the "north" of the location.
- Bits 2/3 define what is present in the "east" of the location.
- Bits 4/5 define what is present in the "south" of the location.
- Bits 6/7 define what is present in the "west" of the location.
Each N/E/S/W location can then be defined as one of 4 possibilities;
00 = No wall or Door Present.
01 = Wooden Wall
10 = Wooden Door (open)
11 = Wooden Door (closed)
The status of a wooden door, as to whether or not it is locked, is defined bit 0 of the (C) parameter of the map-data. If the bit is set (i.e. true) then all wooden doors within this location are locked with a common key.
Because all doors in the location are locked by setting a single bit, there is no data within the original game maps which defines two wooden doors from a single piece of map data. Adjacent doors are always defined on separate map-data entries.
Example Data
Map-Data value $00 02 = %00 00 00 00 = No walls / doors defined Map-Data value $41 02 = %01 00 00 01 = Wall to the North, Wall to the West Map-Data value $0C 12 = %00 10 11 00 = Closed door to the East, Locked.
Location Occupancy
The value of C determines the current occupancy of this location, as previously defined in: Map-Location Data - (0) Spaces
How the walls are drawn
Unlike a stone block, a wooden-wall location draws only the N/E/S/W sides whose two-bit values are non-zero. The wall-face lookup still supplies the projected slot for each side. A solid wall uses the first half of Wooden_Wall.gfx; an open door uses its second $2498-byte set, and a closed door adds the selected Wooden_Doors.gfx picture.
See Dungeon Graphics Renderer for the shared face-selection, transform, position and occlusion tables.
The player-square view cell is also significant. Its north edge uses the same projected wall-face slot as the south edge of the immediately adjacent square, while its east and west sides use dedicated near-side slots. Consequently, wooden walls surrounding the player's current location must be processed as part of the 19-cell traversal rather than discarded as an invisible centre point.