Prev: D771 Up: Map Next: D7E7
D778: Handler: Sea Creatures
Used by the routine at GoldfishGame.
The sea is always the paper colour.
Handler_SeaCreatures D778 LD A,$11 Set PAPER: BLUE (01).
D77A RST $10
D77B LD A,$01
D77D RST $10
D77E LD IX,$DB46 Point IX at Data_SeaCreatures.
Handler_SeaCreatures_Loop D782 PUSH BC Stash the remaining-slot count on the stack.
Use a free slot to spawn; otherwise animate the occupant.
D783 LD A,(IX+$0A) Jump to Handler_SeaCreatures_Chooser if this slot is free.
D786 CP $00
D788 JP Z,Handler_SeaCreatures_Chooser
Animate and move the creature already in this slot.
D78B LD L,(IX+$10) Fetch this creature's UDG graphics pointer.
D78E LD H,(IX+$11)
D791 LD ($5C36),HL Write it to *CHARS.
D794 LD A,$10 Set INK from the creature attribute.
D796 RST $10
D797 LD A,(IX+$09)
D79A RST $10
D79B LD A,(IX+$06) Fetch the current creature frame ID.
The frame step in the slot varies with creature size.
D79E ADD A,(IX+$12) Add one animation step.
D7A1 CP (IX+$13) Jump to Handler_SeaCreatures_SetFrameId if the walk cycle has not wrapped.
D7A4 JR NZ,Handler_SeaCreatures_SetFrameId
D7A6 LD A,$20 Reset to the first creature frame.
Handler_SeaCreatures_SetFrameId D7A8 LD (IX+$06),A Write the frame ID back to the creature.
D7AB CALL Handler_SeaCreatureMovement Apply the creature's movement deltas.
D7AE LD (IX+$00),C Write the new co-ordinates back to the creature.
D7B1 LD (IX+$01),B
D7B4 LD (IX+$02),E Write the new offsets back to the creature.
D7B7 LD (IX+$03),D
D7BA CALL Handler_SeaCreatureAnimation Animate the creature's extra frames.
D7BD LD A,C Jump to SeaCreature_FreeSlot if the creature swam off-screen.
D7BE CP $01
D7C0 JP Z,SeaCreature_FreeSlot
D7C3 CALL GoldfishGame_PrintShiftedSprite Print the shifted creature sprite.
D7C6 LD A,(IX+$00) Copy the co-ordinates to the previous-position slots.
D7C9 LD (IX+$0D),A
D7CC LD A,(IX+$01)
D7CF LD (IX+$0E),A
D7D2 LD A,(IX+$02) Copy the offsets to the previous-offset slots.
D7D5 LD (IX+$0B),A
D7D8 LD A,(IX+$03)
D7DB LD (IX+$0F),A
This entry point is used by the routines at SeaCreature_FreeSlot and Handler_SeaCreatures_Chooser.
Handler_SeaCreatures_Next D7DE LD DE,$0018 Move IX on to the next twenty-four-byte creature slot.
D7E1 ADD IX,DE
D7E3 POP BC Restore the remaining-slot count from the stack.
D7E4 DJNZ Handler_SeaCreatures_Loop Decrease the slot count by one and loop back to Handler_SeaCreatures_Loop until every slot has been processed.
D7E6 RET Return.
Prev: D771 Up: Map Next: D7E7