Prev: 58140 Up: Map Next: 58208
58182: Apply Direction Delta
Used by the routine at Spawn_Tracked_Enemy_Entities.
Reads the direction byte from (DE), and uses it as an index into the direction animation table at Direction_Animation_Offset_Table (direction × 4). Adds the Y delta at table[index] to the byte at (DE+1) and the X delta at table[index+1] to the byte at (DE+2), writing the updated coordinates back in place. Called from Spawn_Tracked_Enemy_Entities_Record when building entity records.
Apply_Direction_Delta 58182 EX DE,HL Exchange DE and HL and load the direction table base at Direction_Animation_Offset_Table.
58183 LD HL,59311
58186 LD A,(DE)
58187 AND %00000111 Mask the direction byte to 3 bits.
58189 RLA Double the index (two left shifts) and form the zero-extended byte offset in BC.
58190 RLA
58191 LD C,A
58192 LD B,0
58194 ADD HL,BC
58195 INC DE Apply the Y delta to (DE+1) and the X delta to (DE+2) and write both coordinates back in place.
58196 LD A,(DE)
58197 ADD A,(HL)
58198 LD (DE),A
58199 INC HL
58200 INC DE
58201 LD A,(DE)
58202 ADD A,(HL)
58203 LD (DE),A
58204 DEC DE
58205 DEC DE
58206 EX DE,HL Exchange DE and HL to restore the entity pointer and return.
58207 RET
Prev: 58140 Up: Map Next: 58208