Prev: 919E Up: Map Next: 91E2
91BB: Read Terrain Cell
Return the two terrain bytes under the current actor.
Input
IX Actor slot
Output
D First terrain byte
E Second terrain byte
HL Terrain cell index
Return the two terrain bytes under the current actor.
ReadTerrainCell 91BB LD H,(IX+$03) Fetch the high byte of the world X.
91BE LD L,(IX+$02) Fetch the low byte of the world X.
91C1 LD A,H Fetch the high byte.
91C2 AND %00011111 Keep only bits 0-4.
91C4 LD H,A Write it back to H.
91C5 SRA H Divide the world position by 08.
91C7 RR L
91C9 SRA H
91CB RR L
91CD SRA H
91CF RR L
Read the first terrain byte from the cell.
91D1 PUSH HL Stash the cell index on the stack.
91D2 LD BC,$7000 Point HL at that terrain cell, offset from TerrainData_Active.
91D5 ADD HL,BC
91D6 LD D,(HL) Fetch the first terrain byte.
91D7 POP HL Restore the cell index from the stack, but stash a copy of it on the stack again.
91D8 PUSH HL
Step to the next cell, wrapping the index, and read the second terrain byte.
91D9 INC HL Move onto the next cell.
91DA LD A,H Fetch the high byte.
91DB AND %00000011 Keep only bits 0-1.
91DD LD H,A Write it back to H.
91DE ADD HL,BC Point HL at that terrain cell.
91DF LD E,(HL) Fetch the second terrain byte.
91E0 POP HL Restore the cell index from the stack.
91E1 RET Return.
Prev: 919E Up: Map Next: 91E2