Prev: 27708 Up: Map Next: 27770
27736: Set Up Level
Used by the routines at StartGame, HandleCake and NextLevel.
Sets up the active player for the level in ActivePlayer_Level. The number of ingredients needed (in BCD) is 16 for the first set of five levels, 32 for the second set, and so on. An actor with ID 10 is created in the first of the six slots, with a horizontal co-ordinate of 32; it is the timer which is handled by HandleLevelTimer. The level number which is shown on the screen (in BCD, up to a maximum of 153) is also increased.
SetUpLevel 27736 LD A,(24365) Fetch the level.
27739 RLCA Rotate A left.
27740 AND %01110000 Keep only bits 4-6, which is the set (from bits 3-5 of the level) multiplied by 16.
27742 ADD A,16 Add 16.
27744 LD (24367),A Set the number of ingredients needed (ActivePlayer_IngredientsNeeded).
27747 LD HL,24405 Write 10 to the actor ID of ActorSpawnSlots.
27750 LD (HL),10
27752 INC HL Write 32 to the horizontal co-ordinate of the actor.
27753 LD (HL),32
The level number (in BCD) maxes out at 153.
27755 LD HL,24368 Point HL at the level number (ActivePlayer_LevelNumber).
27758 LD A,(HL) Fetch the level number.
27759 ADD A,1 Add 1 to the level number.
27761 DAA Adjust A to BCD.
27762 CP 153 Jump to SetUpLevel_Return if the level number is less than 153.
27764 JR C,SetUpLevel_Return
27766 LD A,153 Set the level number to the maximum, 153.
SetUpLevel_Return 27768 LD (HL),A Update the level number.
27769 RET Return.
Prev: 27708 Up: Map Next: 27770