Prev: 64331 Up: Map Next: 64512
64338: Deal with a character who is about to step off the roof of a building
Used by the routine at 60347. On entry, B holds the value of the third byte of the character's location descriptor (see 60179), 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 50165)
(206,6,1)=right edge of the roof of the apartment building next to no. 19 (see 50165)
(223,6,1)=left edge of the roof of no. 17 (see 50048)
3 (175,6,1)=left edge of the roof of the apartment building next to no. 19 (see 49876)
(175,11,2)=left edge of the fire escape on the top floor of the apartment building next to no. 19 (see 49876)
(175,17,2)=left edge of the fire escape on the 3rd floor of the apartment building next to no. 19 (see 49876)
(175,23,2)=left edge of the fire escape on the 2nd floor of the apartment building next to no. 19 (see 49876)
4 (124,5,1)=left edge of the roof of the police station (see 48507)
5 (118,11,1)=right edge of the roof of no. 31 (see 48501)
6 (177,28,2)=left edge of the fire escape on the 1st floor of the apartment building next to no. 19 (see 49898)
Input
B Location indicator (2-6)
H Character number (215-230)
64338 CALL 64512 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 31476 with H=230 (Sam) and B=1.
64341 LD L,13 Initialise byte 13 of the character's buffer to 0 on the assumption that he will land safely
64343 LD (HL),0
64345 BIT 0,B Does B=2, 4 or 6 (in which case the character will definitely land safely)?
64347 JR Z,64354 Jump if so
64349 LD A,H A=character number
64350 CP 230 Are we dealing with Sam?
64352 RET NZ Return if not (characters other than Sam don't attempt dangerous leaps from the roofs of tall buildings)
64353 INC (HL) Set byte 13 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)
64354 DEC B Are we dealing with Sam being dropped off the roof of a building?
64355 JR Z,64368 Jump if so
64357 LD A,B Point DE at the appropriate landing y-coordinate in the data table at 64326
64358 ADD A,69
64360 LD E,A
64361 LD D,251
64363 LD A,(DE) Collect the landing y-coordinate in A
64364 LD B,7 Prepare to initialise byte 20 of the character's buffer to 7
64366 JR 64377
We are dealing with Sam being dropped off the roof of a building.
64368 LD L,1 A=Sam's x-coordinate
64370 LD A,(HL)
64371 CALL 60165 Set the carry flag if there is no sidewalk beneath Sam
64374 LD A,34 A=34 if Sam is above the sidewalk, 35 if he's above the road
64376 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).
64377 LD L,20 Set byte 20 of the character's buffer to 0 or 7
64379 LD (HL),B
64380 INC L Store the character's landing y-coordinate in byte 21 of his buffer
64381 LD (HL),A
64382 LD A,H A=character number
64383 CP 230 Are we dealing with Sam?
64385 JR Z,64398 Jump if so
64387 LD L,15 Remove the address of any interruptible subcommand routine from bytes 14 and 15 of the character's buffer
64389 LD (HL),0
64391 LD BC,64331 Set the character's uninterruptible subcommand routine to 64331 and jump to it now
64394 PUSH BC
64395 JP 63981
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).
64398 LD A,128 Set bit 7 of Sam's status flags at 32764, indicating that he's falling from the roof of a building
64400 LD (32764),A
This entry point is used by the routine at 29912 when bit 7 at 32764 is set (by this routine - see above).
64403 CALL 60521 Make a sound effect
64406 LD L,20 Collect byte 20 of Sam's buffer
64408 LD A,(HL)
64409 AND A Is Sam falling straight downwards now?
64410 JR NZ,64413 Jump if not
64412 INC A A=1
64413 LD L,8 Set Sam's main action timer (in byte 8 of his buffer) to 1 if he's falling straight downwards now, or to the value of byte 20 of his buffer (1-7) if he's still moving left or right at the beginning of his descent
64415 LD (HL),A
64416 CALL 64227 Move Sam to the next point in his descent
64419 JP C,60547 Scroll the screen if necessary if Sam is still falling
64422 LD HL,0 Set Sam's post-midstride y-coordinate (in byte 7 of his buffer) to 0 to indicate that he is neither midstride nor mid-action, and his main action timer (in byte 8) to 0 to indicate to the routine at 29912 that Sam has finished falling
64425 LD (58887),HL
64428 RET Z Return if Sam landed safely (without being knocked out)
Sam has landed, and been knocked out by the fall.
64429 CALL 60032 Update the display
64432 CALL 64618 Scroll the screen up and down a row 7 times (with accompanying sound effects)
64435 LD H,230 230=Sam
64437 CALL 60300 Make Sam stand up
64440 CALL 64599 Hide the play area and clear the SRB
64443 CALL 61823 Get a random number between 50 and 57 (ASCII codes for the digits 2-9) in A
64446 AND 7
64448 ADD A,50
64450 LD (32720),A Store this at 32720
64453 SUB 48 A=N/10 (where N is the number of bucks Sam lost)
64455 CALL 28295 Adjust Sam's cash supply and print the new amount
64458 LD A,35 Message 35: ' WHEN I CAME TO MY WALLET WAS GONE...'
64460 JP Z,31445 Queue this message and show the ending cutscene if Sam has run out of money
64463 INC A A=36: ' WHEN I CAME TO SOMEONE HAD TAKEN ${tens digit}0'
64464 CALL 28357 Queue this message
64467 CALL 31960 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.
64470 LD HL,32608 Point HL at one byte past the end of the screen refresh buffer (SRB), which is currently clear
64473 LD C,20 There are 20 rows of the screen to reveal
64475 LD B,4 Set every bit in a group of 4 bytes of the SRB, corresponding to one row of the screen
64477 DEC L
64478 LD (HL),255
64480 DJNZ 64477
64482 PUSH BC Save the screen row counter (in C)
64483 PUSH HL Save the SRB pointer
64484 LD A,100 E=100-L (where L is the LSB of the SRB address); this value determines the pitch of the sound effect
64486 SUB L
64487 LD E,A
64488 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)
64489 ADD A,A
64490 ADD A,A
64491 ADD A,A
64492 LD C,A
64493 XOR 16 Make a sound effect with pitch and duration determined by the row of the screen that is being revealed
64495 OUT (254),A
64497 LD B,E
64498 DJNZ 64498
64500 DEC C
64501 JR NZ,64493
64503 CALL 60032 Reveal a row of the play area
64506 POP HL Restore the SRB pointer to HL
64507 POP BC Restore the screen row counter to C
64508 DEC C Have we revealed all 20 rows yet?
64509 JR NZ,64475 Jump back to reveal the next row if not
64511 RET
Prev: 64331 Up: Map Next: 64512