Prev: E741 Up: Map Next: E7AD
E751: Handle Collectable
Handler for the object types 64 to 67 (the four kinds of gem, see Handle_Stalactite) and 7F (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 99. Sabreman turns cyan, the gem timer at Gem_Timer is set to 50 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 06 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 E751 LD A,($8F1C) Fetch the room x of Sabreman.
E754 CP (IX+$02) Jump to Handle_Collectable_Remove to remove the object if it is in a different room x.
E757 JR NZ,Handle_Collectable_Remove
E759 LD A,($8F1E) Fetch the room y of Sabreman.
E75C CP (IX+$04) Jump to Handle_Collectable_Remove to remove the object if it is in a different room y.
E75F JR NZ,Handle_Collectable_Remove
E761 BIT 0,(IX+$0F) Jump to Update_Object_Sprite if it has not been drawn yet.
E765 JP NZ,Update_Object_Sprite
Handle_Collectable_Check_Contact E768 CALL Check_Sabreman_Contact Check for contact with Sabreman.
E76B BIT 2,C Jump to Handle_Collectable_Collect if Sabreman touches the object.
E76D JR NZ,Handle_Collectable_Collect
E76F CALL PrepDraw2 Prepare the sprite of the object.
E772 JP ColourEntity Jump to ColourEntity.
Handle_Collectable_Collect E775 CALL StoreEntity Save the state of the object.
E778 CALL RemoveEntity Erase the sprite of the object.
E77B CALL SoundsSword Play the pickup sound.
E77E LD A,(IX+$00) Fetch the type of the object.
E781 CP $7F Jump to Collect_Extra_Life if the object is an extra life.
E783 JR Z,Collect_Extra_Life
E785 LD B,(IX+$00) Fetch the type of the object into B.
E788 SRL B Divide it by two.
E78A LD C,$00 Clear C, so that BC holds the points for the object.
E78C CALL AddPointsToScore Add to the score.
E78F LD A,$45 Set the attribute of Sabreman to cyan (45).
E791 LD ($8F1F),A
E794 LD A,$50 Set the gem timer to 50.
E796 LD ($8EEE),A
E799 CALL Print_Status_Panel_Gem_Timer Print the gem timer.
E79C CALL Read_Room_State Read the entry of the room in the room visit table. HL holds the address of the first byte.
E79F BIT 0,(IX+$06) Jump to Handle_Collectable_Clear_Gem if the gem came from the first stalactite.
E7A3 JR NZ,Handle_Collectable_Clear_Gem
E7A5 INC HL Move on to the second byte of the entry.
Handle_Collectable_Clear_Gem E7A6 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 E7A8 LD (IX+$00),$00 Remove the object.
E7AC RET Return.
Prev: E741 Up: Map Next: E7AD