Prev: 893B Up: Map Next: 8959
8940: Flip a height's bit in a map cell
Used by the routine at MOVE_ANT.
How the ants become solid: MOVE_ANT takes an ant out of the map before moving it and puts it back after, so everything else collides with it. This is why the city map changes during play. Nothing outside the walls is written.
It is an XOR, so the map and the ant's record have to agree: an ant moved without its bit leaves a phantom block behind and puts one in its own cell, where it is promptly "bitten" and pushed up a block. Seen in a scene that did exactly that.
Input
A The height
DE The cell: E is x, D is y
TOGGLE_MAP_BIT 8940 CP $06
8942 RET NC
8943 INC A
8944 LD B,A
8945 BIT 7,D
8947 RET Z
8948 LD A,E
8949 RLA
894A RET NC
894B RR D
894D RRA
894E LD E,A
894F LD A,$80
TOGGLE_MAP_BIT_0 8951 RLCA
8952 DJNZ TOGGLE_MAP_BIT_0
8954 LD B,A
8955 LD A,(DE)
8956 XOR B
8957 LD (DE),A
8958 RET
Prev: 893B Up: Map Next: 8959