Prev: 6C3C Up: Map Next: 6C7A
6C58: 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 10 for the first set of five levels, 20 for the second set, and so on. An actor with ID 0A is created in the first of the six slots, with a horizontal co-ordinate of 20; 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 99) is also increased.
SetUpLevel 6C58 LD A,($5F2D) Fetch the level.
6C5B RLCA Rotate A left.
6C5C AND %01110000 Keep only bits 4-6, which is the set (from bits 3-5 of the level) multiplied by 10.
6C5E ADD A,$10 Add 10.
6C60 LD ($5F2F),A Set the number of ingredients needed (ActivePlayer_IngredientsNeeded).
6C63 LD HL,$5F55 Write 0A to the actor ID of ActorSpawnSlots.
6C66 LD (HL),$0A
6C68 INC HL Write 20 to the horizontal co-ordinate of the actor.
6C69 LD (HL),$20
The level number (in BCD) maxes out at 99.
6C6B LD HL,$5F30 Point HL at the level number (ActivePlayer_LevelNumber).
6C6E LD A,(HL) Fetch the level number.
6C6F ADD A,$01 Add 01 to the level number.
6C71 DAA Adjust A to BCD.
6C72 CP $99 Jump to SetUpLevel_Return if the level number is less than 99.
6C74 JR C,SetUpLevel_Return
6C76 LD A,$99 Set the level number to the maximum, 99.
SetUpLevel_Return 6C78 LD (HL),A Update the level number.
6C79 RET Return.
Prev: 6C3C Up: Map Next: 6C7A