Prev: DC53 Up: Map Next: DCF5
DC62: Handler: Enemies
Used by the routine at Dispatch_Handlers.
Animates the 0E-byte records at *ReferenceEnemies.
Point at the enemy list.
Handler_Enemies DC62 LD HL,$9070 Write Graphics_TileFont to *CHARS.
DC65 LD ($5C36),HL
DC68 LD IX,($6432) Point IX at *ReferenceEnemies.
Walk each enemy record.
Handler_Enemies_Loop DC6C LD A,(IX+$00) Return if the terminator FF is reached.
DC6F INC A
DC70 RET Z
DC71 BIT 7,A Pause and skip this enemy if it is inactive.
DC73 CALL NZ,Pause_LeavingRoom
DC76 JP NZ,Handler_Enemies_Next
Skip the walk-frame wrap for high sprite IDs.
DC79 LD A,(IX+$06) Jump to Handler_Enemies_Probe if the sprite ID is E2 or higher.
DC7C CP $E2
DC7E JR NC,Handler_Enemies_Probe
Advance the walking frame.
DC80 ADD A,$06 Add 06 to the sprite ID and set the wrap to 24.
DC82 LD C,A
DC83 LD B,$24
Handler_Enemies_WrapLoop DC85 SUB B Subtract 24 until the frame is in range.
DC86 JR Z,Handler_Enemies_WrapExact
DC88 JR C,Handler_Enemies_CommitFrame
DC8A JR Handler_Enemies_WrapLoop
Wrap an exact multiple of 24.
Handler_Enemies_WrapExact DC8C LD A,C Subtract one more span of 24.
DC8D SUB B
DC8E LD C,A
Handler_Enemies_CommitFrame DC8F LD (IX+$06),C Write the wrapped sprite ID.
Only probe when the enemy is cell-aligned.
Handler_Enemies_Probe DC92 LD A,(IX+$02) Jump to Handler_Enemies_Update unless the fine-X is 07.
DC95 CP $07
DC97 JR NZ,Handler_Enemies_Update
DC99 BIT 7,(IX+$07) Jump to Handler_Enemies_ProbeLeft if the enemy is facing left.
DC9D JR Z,Handler_Enemies_ProbeLeft
Probe the cell ahead on the right.
DC9F LD C,(IX+$00) Set the probe to the top row, one column right.
DCA2 LD A,(IX+$01)
DCA5 SUB (IX+$05)
DCA8 LD B,A
DCA9 INC C
DCAA CALL JumpTable_SetPrintPosition Call JumpTable_SetPrintPosition.
DCAD LD HL,($6412) Point HL at that Buffer_RoomTiles tile.
DCB0 LD DE,$5DCE
DCB3 ADD HL,DE
DCB4 LD A,(HL) Call Reverse_Direction if the tile is solid.
DCB5 CP $10
DCB7 CALL NC,Reverse_Direction
DCBA JR Handler_Enemies_Update Jump to Handler_Enemies_Update.
Probe ahead on the left.
Handler_Enemies_ProbeLeft DCBC LD A,(IX+$01) Set the probe row to the top of the enemy.
DCBF SUB (IX+$05)
DCC2 LD B,A
DCC3 LD A,(IX+$00) Jump to Handler_Enemies_Update if the column is 23 or higher.
DCC6 CP $23
DCC8 JR NC,Handler_Enemies_Update
DCCA SUB (IX+$04) Set the probe column to the left of the enemy.
DCCD LD C,A
DCCE CALL JumpTable_SetPrintPosition Call JumpTable_SetPrintPosition.
DCD1 LD HL,($6412) Point HL at that Buffer_RoomTiles tile.
DCD4 LD DE,$5DCE
DCD7 ADD HL,DE
DCD8 LD A,(HL) Call Reverse_Direction if the tile is solid.
DCD9 CP $10
DCDB CALL NC,Reverse_Direction
Store, move, draw and erase the enemy.
Handler_Enemies_Update DCDE CALL JumpTable_AdvanceEntity Call JumpTable_AdvanceEntity.
DCE1 CALL JumpTable_StorePosition Call JumpTable_StorePosition.
DCE4 CALL JumpTable_MoveEntity Call JumpTable_MoveEntity.
DCE7 CALL JumpTable_DrawEntity Call JumpTable_DrawEntity.
DCEA CALL JumpTable_EraseEntity Call JumpTable_EraseEntity.
Step to the next record.
Handler_Enemies_Next DCED LD DE,$000E IX+=000E.
DCF0 ADD IX,DE
DCF2 JP Handler_Enemies_Loop Jump to Handler_Enemies_Loop.
View the equivalent code in Booty.
Prev: DC53 Up: Map Next: DCF5