Prev: FB4B Up: Map Next: FC00
FB52: Deal with a character who is about to step off the roof of a building
Used by the routine at EBBB. On entry, B holds the value of the third byte of the character's location descriptor (see EB13), which indicates the set of locations the character's current location belongs to:
B Location(s) (x,y,z)
2 (23,6,1)=right edge of the roof of the apartment building next to no. 74 (see C3F5)
(206,6,1)=right edge of the roof of the apartment building next to no. 19 (see C3F5)
(223,6,1)=left edge of the roof of no. 17 (see C380)
3 (175,6,1)=left edge of the roof of the apartment building next to no. 19 (see C2D4)
(175,11,2)=left edge of the fire escape on the top floor of the apartment building next to no. 19 (see C2D4)
(175,17,2)=left edge of the fire escape on the 3rd floor of the apartment building next to no. 19 (see C2D4)
(175,23,2)=left edge of the fire escape on the 2nd floor of the apartment building next to no. 19 (see C2D4)
4 (124,5,1)=left edge of the roof of the police station (see BD7B)
5 (118,11,1)=right edge of the roof of no. 31 (see BD75)
6 (177,28,2)=left edge of the fire escape on the 1st floor of the apartment building next to no. 19 (see C2EA)
Input
B Location indicator (2-6)
H Character number (0xD7-0xE6)
FB52 CALL $FC00 Deal with the case where B=2 and the character is standing on the edge of the roof of no. 17 or the apartment building next to no. 19
This entry point is used by the routine at 7AF4 with H=0xE6 (Sam) and B=1.
FB55 LD L,$0D Initialise byte 0x0D of the character's buffer to 0 on the assumption that he will land safely
FB57 LD (HL),$00
FB59 BIT 0,B Does B=2, 4 or 6 (in which case the character will definitely land safely)?
FB5B JR Z,$FB62 Jump if so
FB5D LD A,H A=character number
FB5E CP $E6 Are we dealing with Sam?
FB60 RET NZ Return if not (characters other than Sam don't attempt dangerous leaps from the roofs of tall buildings)
FB61 INC (HL) Set byte 0x0D of Sam's buffer to 1 to indicate that he's stepping off or being dropped off the roof of a building from a great enough height that he could be knocked out when he lands (B=1, 3 or 5)
FB62 DEC B Are we dealing with Sam being dropped off the roof of a building?
FB63 JR Z,$FB70 Jump if so
FB65 LD A,B Point DE at the appropriate landing y-coordinate in the data table at FB46
FB66 ADD A,$45
FB68 LD E,A
FB69 LD D,$FB
FB6B LD A,(DE) Collect the landing y-coordinate in A
FB6C LD B,$07 Prepare to initialise byte 0x14 of the character's buffer to 7
FB6E JR $FB79
We are dealing with Sam being dropped off the roof of a building.
FB70 LD L,$01 A=Sam's x-coordinate
FB72 LD A,(HL)
FB73 CALL $EB05 Set the carry flag if there is no sidewalk beneath Sam
FB76 LD A,$22 A=34 if Sam is above the sidewalk, 35 if he's above the road
FB78 ADC A,B
At this point A holds the character's landing y-coordinate, and B holds 0 (if the character is Sam and he's been dropped from the roof of a building) or 7 (if the character is voluntarily stepping off the roof).
FB79 LD L,$14 Set byte 0x14 of the character's buffer to 0 or 7
FB7B LD (HL),B
FB7C INC L Store the character's landing y-coordinate in byte 0x15 of his buffer
FB7D LD (HL),A
FB7E LD A,H A=character number
FB7F CP $E6 Are we dealing with Sam?
FB81 JR Z,$FB8E Jump if so
FB83 LD L,$0F Remove the address of any interruptible subcommand routine from bytes 0x0E and 0x0F of the character's buffer
FB85 LD (HL),$00
FB87 LD BC,$FB4B Set the character's uninterruptible subcommand routine to FB4B and jump to it now
FB8A PUSH BC
FB8B JP $F9ED
The remainder of this routine deals with Sam's descent from the roof of the building (either to the ground or to the roof of the neighbouring building).
FB8E LD A,$80 Set bit 7 of Sam's status flags at 7FFC, indicating that he's falling from the roof of a building
FB90 LD ($7FFC),A
This entry point is used by the routine at 74D8 when bit 7 at 7FFC is set (by this routine - see above).
FB93 CALL $EC69 Make a sound effect
FB96 LD L,$14 Collect byte 0x14 of Sam's buffer
FB98 LD A,(HL)
FB99 AND A Is Sam falling straight downwards now?
FB9A JR NZ,$FB9D Jump if not
FB9C INC A A=1
FB9D LD L,$08 Set Sam's main action timer (in byte 0x08 of his buffer) to 1 if he's falling straight downwards now, or to the value of byte 0x14 of his buffer (1-7) if he's still moving left or right at the beginning of his descent
FB9F LD (HL),A
FBA0 CALL $FAE3 Move Sam to the next point in his descent
FBA3 JP C,$EC83 Scroll the screen if necessary if Sam is still falling
FBA6 LD HL,$0000 Set Sam's post-midstride y-coordinate (in byte 0x07 of his buffer) to 0 to indicate that he is neither midstride nor mid-action, and his main action timer (in byte 0x08) to 0 to indicate to the routine at 74D8 that Sam has finished falling
FBA9 LD ($E607),HL
FBAC RET Z Return if Sam landed safely (without being knocked out)
Sam has landed, and been knocked out by the fall.
FBAD CALL $EA80 Update the display
FBB0 CALL $FC6A Scroll the screen up and down a row 7 times (with accompanying sound effects)
FBB3 LD H,$E6 0xE6=Sam
FBB5 CALL $EB8C Make Sam stand up
FBB8 CALL $FC57 Hide the play area and clear the SRB
FBBB CALL $F17F Get a random number between 0x32 and 0x39 (ASCII codes for the digits 2-9) in A
FBBE AND $07
FBC0 ADD A,$32
FBC2 LD ($7FD0),A Store this at 7FD0
FBC5 SUB $30 A=N/10 (where N is the number of bucks Sam lost)
FBC7 CALL $6E87 Adjust Sam's cash supply and print the new amount
FBCA LD A,$23 Message 0x23: ' WHEN I CAME TO MY WALLET WAS GONE...'
FBCC JP Z,$7AD5 Queue this message and show the ending cutscene if Sam has run out of money
FBCF INC A A=0x24: ' WHEN I CAME TO SOMEONE HAD TAKEN ${tens digit}0'
FBD0 CALL $6EC5 Queue this message
FBD3 CALL $7CD8 Take the hook and budgie from Sam (if he has them)
Now we reveal the play area one row of tiles at a time from the bottom up, with accompanying sound effects.
FBD6 LD HL,$7F60 Point HL at one byte past the end of the screen refresh buffer (SRB), which is currently clear
FBD9 LD C,$14 There are 20 rows of the screen to reveal
FBDB LD B,$04 Set every bit in a group of 4 bytes of the SRB, corresponding to one row of the screen
FBDD DEC L
FBDE LD (HL),$FF
FBE0 DJNZ $FBDD
FBE2 PUSH BC Save the screen row counter (in C)
FBE3 PUSH HL Save the SRB pointer
FBE4 LD A,$64 E=0x64-L (where L is the LSB of the SRB address); this value determines the pitch of the sound effect
FBE6 SUB L
FBE7 LD E,A
FBE8 LD A,C Multiply C (the screen row counter) by 8; this value determines the duration of the sound effect, and the border colour (0=black)
FBE9 ADD A,A
FBEA ADD A,A
FBEB ADD A,A
FBEC LD C,A
FBED XOR $10 Make a sound effect with pitch and duration determined by the row of the screen that is being revealed
FBEF OUT ($FE),A
FBF1 LD B,E
FBF2 DJNZ $FBF2
FBF4 DEC C
FBF5 JR NZ,$FBED
FBF7 CALL $EA80 Reveal a row of the play area
FBFA POP HL Restore the SRB pointer to HL
FBFB POP BC Restore the screen row counter to C
FBFC DEC C Have we revealed all 20 rows yet?
FBFD JR NZ,$FBDB Jump back to reveal the next row if not
FBFF RET
Prev: FB4B Up: Map Next: FC00