Prev: 41741 Up: Map Next: 41947
41883: Restore Bottles
Used by the routine at RunGame.
Copies the saved state of each bottle in the level (see BottleStates) back into the objects of the level. Each entry in the list of the level selects a group of objects, and the objects with the type 1 or 2 in bits 0-3 (and bit 7 set) are the bottles.
RestoreBottles 41883 CALL StartLevel Call StartLevel to find the data of the level and place the player.
41886 LD IY,57057 Point IY at BottleStates.
41890 LD B,(IX-1) Fetch the number of entries in the list of the level.
RestoreBottles_NextEntry 41893 PUSH BC Save the count of entries.
41894 PUSH IX Save the address of the entry.
41896 CALL FindGroupObjects Call FindGroupObjects to find the objects in the group of the entry.
41899 LD A,B Fetch the number of objects.
41900 AND A Test it.
41901 JR Z,RestoreBottles_NextGroup Jump to RestoreBottles_NextGroup if there are no objects.
RestoreBottles_NextObject 41903 LD A,(IX+1) Fetch the type of the next object.
41906 AND %10001111 Keep bit 7 and bits 0-3.
41908 CP 129 Jump to RestoreBottles_Restore if it is a bottle of type 1.
41910 JR Z,RestoreBottles_Restore
41912 CP 130 Jump to RestoreBottles_Skip unless it is a bottle of type 2.
41914 JR NZ,RestoreBottles_Skip
RestoreBottles_Restore 41916 LD A,(IX+1) Fetch the type of the object again.
41919 AND %01110000 Use bits 4-6.
41921 OR (IY+0) Combine them with the saved state of the bottle.
41924 LD (IX+1),A Store the new type of the object.
41927 INC IY Move onto the saved state of the next bottle.
RestoreBottles_Skip 41929 INC IX Move onto the next object...
41931 INC IX ...which is three bytes...
41933 INC IX ...along.
41935 DJNZ RestoreBottles_NextObject Jump back until all of the objects have been looked at.
RestoreBottles_NextGroup 41937 POP IX Restore the address of the entry.
41939 INC IX Move onto the next entry...
41941 INC IX ...which is two bytes along.
41943 POP BC Restore the count of entries.
41944 DJNZ RestoreBottles_NextEntry Jump back until all of the entries have been looked at.
41946 RET Return.
Prev: 41741 Up: Map Next: 41947