Map Location Data (5) Metal Doors - HoraceAndTheSpider/Bloodwych-68k GitHub Wiki

A Metal Door is 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 '5'.

To best understand the definition of the metal door, we can translate the two bytes (AB) and (CD) to binary, and consider which binary bits (right to left) contain defining information.

Open or Closed

Whether a door is currently open or closed, is defined in bit 0 of the (AB) byte. If the bit is 'off' the door is open, and if the bit is 'on' the door is closed.

The type of Metal Door

The type of Metal Door, is changeable between the ornate, decorated metal door and the portcullis style. This is defined in bit 1 of the (AB) byte. If the bit is 'off' the door is the decorated type, and if the bit is 'on' the door is of the Portcullis type.

The direction of the Metal Door

Whether a Metal Door is facing East/West or North/South is defined in bit 2 of the (AB) byte. If the bit is 'off' the door is facing North/South, and if the bit is 'on' the door is facing East/West.

Locked Doors

Metal Doors can be locked in a variety of ways. To lock a door in such a way that a Key or other unlocking method is required, it is required that bit 4 of the (CD) byte is switched to the 'on' position first.

Once a door is locked, the type of lock will be determined by bits 4-6 of the (AB) byte. These bits can be converted to a number, from 0-7, which will determine this as follows;

0 = Magelock 1 = Bronze lock (Unlock with Object $50) 2 = Iron lock (Unlock with Object $51) 3 = Serpent lock (Unlock with Object $52) 4 = Chaos lock (Unlock with Object $53) 5 = Dragon lock (Unlock with Object $54) 6 = Moon lock (Unlock with Object $55) 7 = Chromatic lock (Unlock with Object $56)

'Void' Locked Doors

Metal Doors can also be locked in a special way, depicted as a 'black' lock, which is only released via a switch / trigger. By setting bit 3 of byte (AB) to 'on' the door will be locked in this way.

Special consideration should be given to the 'general' lock setting when using void locks. In order to ensure that the door is correctly unlocked after activation of a trigger, the normal lock settings - i.e. bit 4 of the (CD) byte, should be set to 'off' and bits 4-6 of (AB) cleared.

It may be possible by leaving these standard locking options in place, and additionally including a void lock option, that once the void lock is 'cleared' by a trap/trigger, the door is left as a standard locked door. However, this is untested.

Location Occupancy

The value of C determines the current occupancy of this location, as previously defined in: Map-Location Data - (0) Spaces

Locks

The colours of the locks (in the order in which the keys are listed)

In BEXT:

adrB_00C16C:
	dc.b	1	;01 - Grey
	dc.b	9	;09 - Brown
	dc.b	4	;04 - Grey
	dc.b	6	;06 - Green
	dc.b	D	;0D - Yellow
	dc.b	C	;0C - Red
	dc.b	7	;07 - Blue
	dc.b	E	;0E - White