Prev: 6D87 Up: Map Next: 6E11
6D89: Handle Level Introduction
The handler for the actors in the introduction to a level; the ingredient (ID 06) and Charlie (ID 07). While they are handled the ID is changed to the sprite which is in byte 04 of the actor. Byte 05 of the actor is zero until it has been drawn for the first time. The actors move left two pixels each pass, and change to their other frame every four passes.
Charlie waits (and is not drawn) until the ingredient has gone past the point at which CharlieRunningFlag is set by StartCharlieRunning. When an actor goes off the left side of the screen it is removed; and if it was Charlie then the level is started. A tone is played by LevelStartJingle every eight frames for Charlie.
Input
IX Actor
HandleLevelIntroduction 6D89 LD A,(IX+$00) Fetch the actor ID.
6D8C PUSH AF Stash the actor ID on the stack.
6D8D CP $07 Jump to HandleLevelIntroduction_Draw if this is the ingredient.
6D8F JR NZ,HandleLevelIntroduction_Draw
6D91 LD A,($5F29) Fetch the flag which says whether Charlie is running.
6D94 AND A Has Charlie started to run yet?
6D95 JR Z,HandleLevelIntroduction_Finish Jump to HandleLevelIntroduction_Finish if he has not.
HandleLevelIntroduction_Draw 6D97 LD A,(IX+$05) Fetch the flag which says whether the actor has been drawn.
6D9A AND A Has the actor been drawn?
6D9B JR NZ,HandleLevelIntroduction_Animate Jump to HandleLevelIntroduction_Animate if it has.
6D9D INC (IX+$05) Flag that the actor has been drawn.
6DA0 LD A,(IX+$04) Fetch the sprite ID (byte 04 of the actor).
6DA3 LD (IX+$00),A Update the actor ID.
6DA6 CALL DrawEntity Draw the sprite using DrawEntity.
6DA9 POP AF Restore the actor ID from the stack.
6DAA LD (IX+$00),A Update the actor ID.
6DAD RET Return.
Charlie changes to his second frame.
HandleLevelIntroduction_SecondFrame 6DAE LD A,$02 Set the sprite ID for Charlie's second frame, 02.
6DB0 JR HandleLevelIntroduction_SetFrame Jump to HandleLevelIntroduction_SetFrame.
Charlie changes to his first frame.
HandleLevelIntroduction_FirstFrame 6DB2 LD A,$01 Set the sprite ID for Charlie's first frame, 01.
6DB4 JR HandleLevelIntroduction_SetFrame Jump to HandleLevelIntroduction_SetFrame.
The actor has been drawn already.
HandleLevelIntroduction_Animate 6DB6 LD A,(IX+$04) Fetch the sprite ID (byte 04 of the actor).
6DB9 LD (IX+$00),A Update the actor ID.
6DBC CALL StoreEntity Record the position of the sprite using StoreEntity.
6DBF LD A,($5F1D) Fetch the frame counter.
6DC2 AND %00000011 Keep only bits 0-1.
6DC4 JR NZ,HandleLevelIntroduction_Move Jump to HandleLevelIntroduction_Move if the frame counter is not a multiple of 04.
6DC6 LD A,(IX+$04) Fetch the sprite ID (byte 04 of the actor).
6DC9 CP $01 Jump to HandleLevelIntroduction_SecondFrame if the sprite is Charlie's first frame.
6DCB JR Z,HandleLevelIntroduction_SecondFrame
6DCD CP $02 Jump to HandleLevelIntroduction_FirstFrame if the sprite is Charlie's second frame.
6DCF JR Z,HandleLevelIntroduction_FirstFrame
6DD1 XOR %00000001 Flip bit 0, to change to the other frame of the ingredient.
HandleLevelIntroduction_SetFrame 6DD3 LD (IX+$04),A Update the sprite ID (byte 04 of the actor).
6DD6 LD (IX+$00),A Update the actor ID.
HandleLevelIntroduction_Move 6DD9 LD A,(IX+$01) Fetch the horizontal co-ordinate.
6DDC SUB $02 Subtract 02 to move the actor to the left.
6DDE LD (IX+$01),A Update the horizontal co-ordinate.
6DE1 CP $90 Compare with 90 (the point at which Charlie starts to run).
6DE3 CALL C,StartCharlieRunning Call StartCharlieRunning if the actor is to the left of 90.
6DE6 CP $F8 Jump to HandleLevelIntroduction_Remove if the actor has gone off the left of the screen.
6DE8 JR NC,HandleLevelIntroduction_Remove
6DEA CALL DisplayEntity Erase the sprite and draw it in its new position using DisplayEntity.
6DED CALL ColourSprite Colour the sprite using ColourSprite.
Put the actor ID back, and play the tone if this is Charlie.
HandleLevelIntroduction_Finish 6DF0 POP AF Restore the actor ID from the stack.
6DF1 LD (IX+$00),A Update the actor ID.
6DF4 LD A,($5C78) Fetch the first byte of FRAMES.
6DF7 AND %00000111 Keep only bits 0-2.
6DF9 RET NZ Return if the frame counter is not a multiple of 08.
6DFA LD A,(IX+$03) Fetch the actor colour.
6DFD CP $47 Compare with 47 (white, the colour of Charlie).
6DFF RET NZ Return if this is not Charlie.
6E00 JP LevelStartJingle Jump to LevelStartJingle to play the tone.
The actor has gone off the left of the screen.
HandleLevelIntroduction_Remove 6E03 CALL RemoveEntity Erase the sprite using RemoveEntity.
6E06 LD (IX+$00),$00 Write 00 to the actor ID.
6E0A POP AF Restore the original actor ID from the stack.
6E0B CP $07 Jump to StartLevel to start the level if this was Charlie.
6E0D JP Z,StartLevel
6E10 RET Return.
Prev: 6D87 Up: Map Next: 6E11