Prev: 55153 Up: Map Next: 55271
55160: Handler: Sea Creatures
Used by the routine at GoldfishGame.
The sea is always the paper colour.
Handler_SeaCreatures 55160 LD A,17 Set PAPER: BLUE (1).
55162 RST 16
55163 LD A,1
55165 RST 16
55166 LD IX,56134 IX=Data_SeaCreatures.
Handler_SeaCreatures_Loop 55170 PUSH BC Stash BC on the stack.
Should we deal with an existing creature or generate a new one?
55171 LD A,(IX+10) If *IX+10 is equal to 0 this is a "free-slot" so jump to Handler_SeaCreatures_Chooser.
55174 CP 0
55176 JP Z,Handler_SeaCreatures_Chooser
The sea creature for this slot is already set, so update it.
55179 LD L,(IX+16) Fetch the UDG graphics pointer for this sea creature and store it in HL.
55182 LD H,(IX+17)
55185 LD (23606),HL Write the UDG graphics pointer to *CHARS.
55188 LD A,16 Set the INK value for this sea creature using *IX+9.
55190 RST 16
55191 LD A,(IX+9)
55194 RST 16
55195 LD A,(IX+6) Get the current sprite/ frame ID from *IX+6.
The sprite increment number is held by *IX+18, it varies between creatures as obviously they are different sizes.
55198 ADD A,(IX+18) Add on the sprite increment number.
55201 CP (IX+19) Jump to Handler_SeaCreatures_SetFrameId if A is not yet equal to the maximum value held by *IX+19.
55204 JR NZ,Handler_SeaCreatures_SetFrameId
55206 LD A,32 Reset the sprite/ frame ID back to 32 which is always the first frame.
Handler_SeaCreatures_SetFrameId 55208 LD (IX+6),A Update the current sprite/ frame ID back to *IX+6.
55211 CALL Handler_SeaCreatureMovement Call Handler_SeaCreatureMovement.
55214 LD (IX+0),C Write the updated co-ordinates to *IX+0/ *IX+1.
55217 LD (IX+1),B
55220 LD (IX+2),E Write the updated block position offsets to *IX+2/ *IX+3.
55223 LD (IX+3),D
55226 CALL Handler_SeaCreatureAnimation Call Handler_SeaCreatureAnimation.
55229 LD A,C Jump to SeaCreature_FreeSlot if the current creature is now off-screen.
55230 CP 1
55232 JP Z,SeaCreature_FreeSlot
55235 CALL 54855 Call 54855.
55238 LD A,(IX+0) Stash the current co-ordinates at *IX+13/ *IX+14.
55241 LD (IX+13),A
55244 LD A,(IX+1)
55247 LD (IX+14),A
55250 LD A,(IX+2) Stash the current block position offsets at *IX+11/ *IX+15.
55253 LD (IX+11),A
55256 LD A,(IX+3)
55259 LD (IX+15),A
This entry point is used by the routines at SeaCreature_FreeSlot and Handler_SeaCreatures_Chooser.
Handler_SeaCreatures_Next 55262 LD DE,24 IX+=0024.
55265 ADD IX,DE
55267 POP BC Restore BC from the stack.
55268 DJNZ Handler_SeaCreatures_Loop Decrease counter by one and loop back to Handler_SeaCreatures_Loop until counter is zero.
55270 RET Return.
Prev: 55153 Up: Map Next: 55271