DSA Cellflag manipulation
The dungeon's smallest physical units are the cells. A single cell can be a stone wall, a teleporter, a pit, etc. Many of the cell types are modified by the presence of flags (cellflags). One of these flags, for example, causes a teleproter to be either visible or invisible. Some of the cell types also contain integer variables that modify the state of the cell. For example, a teleporter can teleport only monsters, people and objects, etc. To examine these flags and variables you can use the DSA command '&CELL@' (pronounced 'cell-fetch'). To modify them you can use the command '&CELL!' (pronounced 'cell-store').
Communication between your DSA and the Cellflag data takes place in the static array that you reference with the '&@' and the '&!' commands. You specify where in that array the data is located and how many words in that array are to be used. You also specify the location of the cell in which you are interested. So a typical request to fetch information about a cell might look as follows:
`
LA L10 L3 &CELL@`
First we fetched parameter A as the location of the cell in question, then we put the integer 10 on the stack to say that the data should be put in the array starting at index 10, then the 3 says that 3 words of data are to be obtained. Finally we issue the '&CELL@' command to transfer 3 words of cell data to array[10].
The first word of data transfered is always the cell type and cannot be modified. Up to 10 words will be transferred to your array. Unused words will be set to zero to help us deal with any future enhancements to this capability. Data after the first word is dependent on the cell type: (an asterisk means the data cannot be modified).
Cell Type 0 - A Stone wall
`[0] The cell type. 0.*
[1]` `bit flags for random decorations
01 north
02 east
04 south
08 west
`
Cell Type 1 - An open Room`
[0] The cell type. 1.*
[1]` `bit flags
01 - random floor decorations
` Cell Type 2 - A Pit
`[0] The cell type. 2.*
[1] Bit flags
` `01 False Pit - Cannot fall through this pit.
04 Obscure - Hard to see even when open.
08 Open - The pit is open.
` Cell Type 3 - Stairs
`[0] The cell type. 3.*`
`[1] Bit flags
04 Up* - The stairs lead to the floor above.
08 north/south* - Enter the stairs from the north or south direction.
` Cell Type 4 - A Door
`[0] The cell type. 4.*`
`[1] Bit Flags
01 north/south*
02 opends up/down
04 switch
08 can destroy with fireball
16 can destroy with axe
` `[2] Current open/closed state*
Note: Actually, you are allowed to change the state of a door in these cases:
If a door is 'closed' you can set it to 'bashed'.
If a door is 'bashed' you can set it to 'open'.
0 open
1 almost open
2 half open
3 almost closed
4 closed
5 bashed
` `[3] Door Type index
` `[4] Door Decoration ordinal (zero means none).
` Cell Type 5 - A Teleporter
`[0] The cell type. 5.*`
`[1]``Bit flags
04 Visible
08 Active
[2]``How the teleporter re-orients the teleported object
0 no change
1 face right
2 face back
3 face left
4 face north
5 face east
6 face south
7 face west
[3]` `What gets teleported
0 objects only
1 monsters only
2 party/objects
3 anything``
[4]` `destination*
` Cell Type 6 - A Removable Wall
`[0] The cell type. 6.*
[1] Bit flags. Note that the wall is passable if 'Invisible' OR 'Trick'
01 'Trick wall'. Passable.
04 Invisible
` ``