Prev: 56403 Up: Map Next: 56565
56418: Handler: Enemies
Used by the routine at Dispatch_Handlers.
Animates the 14-byte records at *ReferenceEnemies.
Point at the enemy list.
Handler_Enemies 56418 LD HL,36976 Write Graphics_TileFont to *CHARS.
56421 LD (23606),HL
56424 LD IX,(25650) Point IX at *ReferenceEnemies.
Walk each enemy record.
Handler_Enemies_Loop 56428 LD A,(IX+0) Return if the terminator 255 is reached.
56431 INC A
56432 RET Z
56433 BIT 7,A Pause and skip this enemy if it is inactive.
56435 CALL NZ,Pause_LeavingRoom
56438 JP NZ,Handler_Enemies_Next
Skip the walk-frame wrap for high sprite IDs.
56441 LD A,(IX+6) Jump to Handler_Enemies_Probe if the sprite ID is 226 or higher.
56444 CP 226
56446 JR NC,Handler_Enemies_Probe
Advance the walking frame.
56448 ADD A,6 Add 6 to the sprite ID and set the wrap to 36.
56450 LD C,A
56451 LD B,36
Handler_Enemies_WrapLoop 56453 SUB B Subtract 36 until the frame is in range.
56454 JR Z,Handler_Enemies_WrapExact
56456 JR C,Handler_Enemies_CommitFrame
56458 JR Handler_Enemies_WrapLoop
Wrap an exact multiple of 36.
Handler_Enemies_WrapExact 56460 LD A,C Subtract one more span of 36.
56461 SUB B
56462 LD C,A
Handler_Enemies_CommitFrame 56463 LD (IX+6),C Write the wrapped sprite ID.
Only probe when the enemy is cell-aligned.
Handler_Enemies_Probe 56466 LD A,(IX+2) Jump to Handler_Enemies_Update unless the fine-X is 7.
56469 CP 7
56471 JR NZ,Handler_Enemies_Update
56473 BIT 7,(IX+7) Jump to Handler_Enemies_ProbeLeft if the enemy is facing left.
56477 JR Z,Handler_Enemies_ProbeLeft
Probe the cell ahead on the right.
56479 LD C,(IX+0) Set the probe to the top row, one column right.
56482 LD A,(IX+1)
56485 SUB (IX+5)
56488 LD B,A
56489 INC C
56490 CALL JumpTable_SetPrintPosition Call JumpTable_SetPrintPosition.
56493 LD HL,(25618) Point HL at that Buffer_RoomTiles tile.
56496 LD DE,24014
56499 ADD HL,DE
56500 LD A,(HL) Call Reverse_Direction if the tile is solid.
56501 CP 16
56503 CALL NC,Reverse_Direction
56506 JR Handler_Enemies_Update Jump to Handler_Enemies_Update.
Probe ahead on the left.
Handler_Enemies_ProbeLeft 56508 LD A,(IX+1) Set the probe row to the top of the enemy.
56511 SUB (IX+5)
56514 LD B,A
56515 LD A,(IX+0) Jump to Handler_Enemies_Update if the column is 35 or higher.
56518 CP 35
56520 JR NC,Handler_Enemies_Update
56522 SUB (IX+4) Set the probe column to the left of the enemy.
56525 LD C,A
56526 CALL JumpTable_SetPrintPosition Call JumpTable_SetPrintPosition.
56529 LD HL,(25618) Point HL at that Buffer_RoomTiles tile.
56532 LD DE,24014
56535 ADD HL,DE
56536 LD A,(HL) Call Reverse_Direction if the tile is solid.
56537 CP 16
56539 CALL NC,Reverse_Direction
Store, move, draw and erase the enemy.
Handler_Enemies_Update 56542 CALL JumpTable_AdvanceEntity Call JumpTable_AdvanceEntity.
56545 CALL JumpTable_StorePosition Call JumpTable_StorePosition.
56548 CALL JumpTable_MoveEntity Call JumpTable_MoveEntity.
56551 CALL JumpTable_DrawEntity Call JumpTable_DrawEntity.
56554 CALL JumpTable_EraseEntity Call JumpTable_EraseEntity.
Step to the next record.
Handler_Enemies_Next 56557 LD DE,14 IX+=0014.
56560 ADD IX,DE
56562 JP Handler_Enemies_Loop Jump to Handler_Enemies_Loop.
View the equivalent code in Booty.
Prev: 56403 Up: Map Next: 56565