Prev: 59201 Up: Map Next: 59309
59217: Handle Collectable
Handler for the object types 100 to 103 (the four kinds of gem, see Handle_Stalactite) and 127 (an extra life, see Extra_Life_Template).
An object that is in a different room from Sabreman is removed. When Sabreman touches the object (see Check_Sabreman_Contact) it is erased and the pickup sound is played (see SoundsSword). An extra life goes on at Collect_Extra_Life. For a gem the score goes up (see AddPointsToScore) by the type divided by two, as a number of hundreds, plus 153. Sabreman turns cyan, the gem timer at Gem_Timer is set to 80 and printed, and the gem is taken out of the entry of the room in the room visit table (see Set_Up_Stalactites), so that it does not come back when the room is drawn again. Bit 0 of byte 6 of the gem is taken to show which of the two bytes of the entry it came from.
Input
IX Object record of the gem or the extra life
Handle_Collectable 59217 LD A,(36636) Fetch the room x of Sabreman.
59220 CP (IX+2) Jump to Handle_Collectable_Remove to remove the object if it is in a different room x.
59223 JR NZ,Handle_Collectable_Remove
59225 LD A,(36638) Fetch the room y of Sabreman.
59228 CP (IX+4) Jump to Handle_Collectable_Remove to remove the object if it is in a different room y.
59231 JR NZ,Handle_Collectable_Remove
59233 BIT 0,(IX+15) Jump to Update_Object_Sprite if it has not been drawn yet.
59237 JP NZ,Update_Object_Sprite
Handle_Collectable_Check_Contact 59240 CALL Check_Sabreman_Contact Check for contact with Sabreman.
59243 BIT 2,C Jump to Handle_Collectable_Collect if Sabreman touches the object.
59245 JR NZ,Handle_Collectable_Collect
59247 CALL PrepDraw2 Prepare the sprite of the object.
59250 JP ColourEntity Jump to ColourEntity.
Handle_Collectable_Collect 59253 CALL StoreEntity Save the state of the object.
59256 CALL RemoveEntity Erase the sprite of the object.
59259 CALL SoundsSword Play the pickup sound.
59262 LD A,(IX+0) Fetch the type of the object.
59265 CP 127 Jump to Collect_Extra_Life if the object is an extra life.
59267 JR Z,Collect_Extra_Life
59269 LD B,(IX+0) Fetch the type of the object into B.
59272 SRL B Divide it by two.
59274 LD C,0 Clear C, so that BC holds the points for the object.
59276 CALL AddPointsToScore Add to the score.
59279 LD A,69 Set the attribute of Sabreman to cyan (69).
59281 LD (36639),A
59284 LD A,80 Set the gem timer to 80.
59286 LD (36590),A
59289 CALL Print_Status_Panel_Gem_Timer Print the gem timer.
59292 CALL Read_Room_State Read the entry of the room in the room visit table. HL holds the address of the first byte.
59295 BIT 0,(IX+6) Jump to Handle_Collectable_Clear_Gem if the gem came from the first stalactite.
59299 JR NZ,Handle_Collectable_Clear_Gem
59301 INC HL Move on to the second byte of the entry.
Handle_Collectable_Clear_Gem 59302 RES 3,(HL) Reset bit 3 of the byte, so that the stalactite has no gem in it any more.
This entry point is used by the routines at Collect_Extra_Life, Handle_Plain_Decoration, Handle_Coloured_Decoration and Handle_Guardian.
Handle_Collectable_Remove 59304 LD (IX+0),0 Remove the object.
59308 RET Return.
Prev: 59201 Up: Map Next: 59309