| Routines

790D: Display a cutscene

Used by the routine at 7AB6. Displays a cutscene, and then enters demo mode or resumes the game in the next mode.
Input
A | Cutscene message number
790D | LD ($7FD2),A | Store the cutscene message number at 7FD2 so that it can be monitored
7910 | CALL $6EC5 | Add the message to the message queue
7913 | XOR A | A=0
7914 | LD ($7FC9),A | Set Sam's disguise ID (stored at 7FC9) to 0 (none)
7917 | LD ($7F9A),A | Disconnect any phone call Sam may be making by setting 7F9A to 0
791A | LD ($7FFC),A | Clear all of Sam's status flags at 7FFC
791D | CALL $F969 | Update Sam's sprite and the disguise icon now that Sam's wearing no disguise
The loop that follows makes Sam pace up and down until the cutscene is over.
7920 | LD HL,$E609 | Reset the midstride/mid-action timer in byte 0x09 of Sam's buffer
7923 | XOR A
7924 | LD (HL),A
7925 | LD L,A | L=0x00
7926 | BIT 0,(HL) | Is Sam midstride?
7928 | JR Z,$7952 | Jump if not
792A | CALL $E9C8 | Update the SRB for Sam's current animatory state and location
792D | DEC E | Set E to Sam's next x-coordinate (immediately in front of him)
792E | BIT 7,A
7930 | JR Z,$7934
7932 | INC E
7933 | INC E
7934 | INC A | Set A to Sam's new animatory state
7935 | AND $FB
7937 | CALL $E9D5 | Update Sam's animatory state and location and update the SRB
793A | CALL $EC69 | Make a walking sound effect
793D | CALL $EA80 | Update the display
7940 | CALL $6EF4 | Update the message line
7943 | LD HL,$7FC8 | 7FC8 holds the value of the LSB of the system variable FRAMES as it was at the end of the last pass through the main loop (or this routine)
7946 | LD A,($5C78) | Wait about 240ms
7949 | SUB (HL)
794A | CP $0C
794C | JR C,$7946
794E | ADD A,(HL) | Store the current value of the LSB of the system variable FRAMES at 7FC8 for comparison next time
794F | LD (HL),A
7950 | JR $7920 | Jump back to the beginning of this loop
Sam is not midstride at the moment.
7952 | CALL $73E4 | Show or hide the fuse, door, light bulb or phone in the icon panel
7955 | CALL $78FC | Has the entire cutscene message been displayed yet?
7958 | JP NZ,$F0BE | Jump if so to end the cutscene
The cutscene is not over yet. Check whether Sam should turn round before pacing up or down again.
795B | LD HL,$E601 | Point HL at byte 0x01 of Sam's buffer
795E | LD A,(HL) | A=Sam's x-coordinate
795F | DEC L | L=0x00
7960 | AND $07 | Is Sam's x-coordinate exactly divisible by 8?
7962 | JR NZ,$796F | Jump if not
7964 | BIT 7,(HL) | Is Sam facing right?
7966 | JR NZ,$7977 | Jump if so
7968 | CALL $E9C8 | Update the SRB for Sam's current animatory state and location
796B | XOR $80 | Flip bit 7 of Sam's animatory state, thus turning him round
796D | JR $7937 | Jump back to update Sam's animatory state and the SRB
796F | CP $05 | Is Sam's x-coordinate congruent to 5 mod 8?
7971 | JR NZ,$7977 | Jump if not
7973 | BIT 7,(HL) | Is Sam facing right?
7975 | JR NZ,$7968 | Jump back to turn Sam round if so
7977 | CALL $E9C8 | Update the SRB for Sam's current animatory state and location
797A | JR $7934 |