Prev: 8A36 Up: Map Next: 8C3A
8A57: Handle perp caught
This handles slowing cars down to a stop and calculating and displaying the bonus score when the perp has been caught.
handle_perp_caught 8A57 LD A,($A230) Return if perp_caught_stage is zero
8A5A AND A
8A5B RET Z
8A5C DEC A Jump to hpc_stage1 if it's one
8A5D JP Z,hpc_stage1
8A60 DEC A Jump to hpc_stage2 if it's two
8A61 JR Z,hpc_stage2
8A63 DEC A Jump to hpc_stage3 if it's three
8A64 JR Z,hpc_stage3
8A66 DEC A Jump to hpc_stage4 if it's four
8A67 JR Z,hpc_stage4
8A69 EX AF,AF' Bank
8A6A LD A,($A231) Return if transition_control != 0
8A6D AND A
8A6E RET NZ
8A6F EX AF,AF' Unbank
8A70 DEC A Jump to hpc_start_stage_6 if perp_caught_stage is five
8A71 JR Z,hpc_start_stage_6
Otherwise all of the caught stages are complete and we can move on to the next stage.
8A73 POP HL Throw away the return address to bypass the remainder of main_loop
8A74 CALL silence_audio_hook Call silence_audio_hook
8A77 LD HL,$8007 Increment wanted_stage_number
8A7A INC (HL)
8A7B JP main_loop Jump to main_loop
hpc_start_stage_6 8A7E LD A,$06 perp_caught_stage = 6
8A80 LD ($A230),A
8A83 LD A,$08 A = 8 -- transition type
8A85 JP setup_transition Jump to setup_transition
hpc_stage2 8A88 LD A,($A22A) A = var_a22a
8A8B CP $10 Jump to handle_perp_caught_1 if A >= 16
8A8D JR NC,handle_perp_caught_1
8A8F ADD A,$04 var_a22a = A + 4
8A91 LD ($A22A),A
8A94 LD HL,($A26C) HL = road_pos + 12
8A97 LD DE,$000C
8A9A ADD HL,DE
8A9B PUSH HL
8A9C LD DE,$0126 HL -= $126
8A9F SBC HL,DE
8AA1 POP HL
8AA2 JR C,handle_perp_caught_0 Jump to handle_perp_caught_0 if HL < $126 -- Suspect this is driving the car to stop the perp
8AA4 EX DE,HL
handle_perp_caught_0 8AA5 LD ($A26C),HL road_pos = HL
8AA8 LD A,($A23F) A = fast_counter + 32
8AAB ADD A,$20
8AAD RET C Return if carry
8AAE LD ($A23F),A fast_counter = A
8AB1 RET Return
handle_perp_caught_1 8AB2 LD A,$03 perp_caught_stage = 3
8AB4 LD ($A230),A
8AB7 INC A $8ABF = 4
8AB8 LD ($8ABF),A
8ABB JP fill_attributes Call fill_attributes
hpc_stage3 8ABE LD A,$00 Self modified by 8AB8
8AC0 DEC A A--
8AC1 LD ($8ABF),A Self modify 'LD A' @ hpc_stage3 to load A
8AC4 RET NZ Return if A != 0
8AC5 LD A,$04 perp_caught_stage = 4
8AC7 LD ($A230),A
8ACA LD HL,($5D06) Point HL at addrof_arrest_messages
8ACD LD A,$01 A = 1 -- transition_control byte
8ACF JP j_8e80 Jump to j_8e80 -- inside message_printing_related
hpc_stage4 8AD2 LD A,($A139) Call relocated f39f_128k if in 128K mode
8AD5 AND A
8AD6 CALL NZ,$8193
8AD9 LD A,($A231) Return if transition_control != 0
8ADC AND A
8ADD RET NZ
8ADE LD A,($A139) Call relocated f39f_128k if in 128K mode
8AE1 AND A
8AE2 CALL NZ,$8193
8AE5 LD A,$05 perp_caught_stage = 5
8AE7 LD ($A230),A
Calculate clear bonus.
8AEA LD H,$30 '0'
8AEC LD A,($8007) D = wanted_stage_number
8AEF LD D,A
8AF0 ADD A,H L = D + '0'
8AF1 LD L,A
8AF2 LD A,($8006) Load retry_count
8AF5 AND A Jump to hpc_8b03 if zero
8AF6 JR Z,hpc_8b03
8AF8 RLC D D <<= 4? or make BCD?
8AFA RLC D
8AFC RLC D
8AFE RLC D
8B00 LD H,L H = L
8B01 LD L,$20 L = ' '
hpc_8b03 8B03 LD ($8C6F),HL Set first two digits of the clear bonus to HL, "LH0,000"
8B06 RLC D Set score
8B08 RLC D
8B0A RLC D
8B0C RLC D
8B0E XOR A
8B0F LD E,A
8B10 CALL increment_score Call increment_score
8B13 LD A,($A17E) Get time remaining (BCD)
8B16 LD ($8C8A),A Set A in "TIME BONUS A X 5000"
8B19 LD C,A C = A
8B1A RLCA A <<= 4?
8B1B RLCA
8B1C RLCA
8B1D RLCA
8B1E AND $0F A &= $F
8B20 JR NZ,handle_perp_caught_2
8B22 LD A,$20 A = ' '
8B24 EX AF,AF'
8B25 JR handle_perp_caught_3
handle_perp_caught_2 8B27 LD B,A B = A -- iterations
8B28 ADD A,$30 A += '0'
8B2A EX AF,AF'
8B2B LD DE,$0500 DE = $0500
hpc_increment_score_loop_1 8B2E XOR A A = 0
8B2F CALL increment_score Call increment_score
8B32 DJNZ hpc_increment_score_loop_1 Loop while B > 0
handle_perp_caught_3 8B34 EX AF,AF'
8B35 LD ($8C8A),A Set A in "TIME BONUS A X 5000"
8B38 LD A,C A = C & 15
8B39 AND $0F
8B3B JR Z,handle_perp_caught_4
8B3D EX AF,AF'
8B3E LD B,A B = A -- iterations
8B3F LD DE,$0050 DE = $0050
hpc_increment_score_loop_2 8B42 XOR A A = 0
8B43 CALL increment_score Call increment_score
8B46 DJNZ hpc_increment_score_loop_2 Loop while B > 0
handle_perp_caught_4 8B48 EX AF,AF'
8B49 ADD A,$30 A += '0'
8B4B LD ($8C8B),A Set A in "TIME BONUS xA X 5000"
8B4E LD BC,$0400
8B51 LD DE,$8005 Point DE at last digit of score_bcd (big end)
8B54 LD HL,$8CA8 Point HL at x in "SCORE x " - the ten millions?
hpc_loop_3 8B57 LD A,(DE) A = *DE -- fetch digits
8B58 RLCA A = (A << 4) & 15 -- extract first digit
8B59 RLCA
8B5A RLCA
8B5B RLCA
8B5C AND $0F
8B5E JR NZ,handle_perp_caught_5
8B60 RLC C
8B62 JR C,handle_perp_caught_5
8B64 LD A,$20 A = ' '
8B66 JR handle_perp_caught_6
handle_perp_caught_5 8B68 LD C,$FF C = $FF
8B6A ADD A,$30 A += '0'
handle_perp_caught_6 8B6C LD (HL),A *HL++ = A
8B6D INC HL
8B6E LD A,(DE) A = *DE & 15
8B6F AND $0F
8B71 JR NZ,handle_perp_caught_7
8B73 RLC C
8B75 JR C,handle_perp_caught_7
8B77 LD A,$20 A = ' '
8B79 JR handle_perp_caught_8
handle_perp_caught_7 8B7B LD C,$FF C = $FF
8B7D ADD A,$30 A += '0'
handle_perp_caught_8 8B7F LD (HL),A *HL = A
8B80 INC HL HL++
8B81 DEC DE DE--
8B82 DJNZ hpc_loop_3 Loop hpc_loop_3 while B
8B84 DEC HL HL--
8B85 SET 7,(HL) *HL |= 1<<7
8B87 LD HL,$8C58 Point at "CLEAR BONUS - TIME BONUS - SCORE" messages
8B8A JP message_printing_related Call message_printing_related
hpc_stage1 8B8D LD A,($A18D) A = *$A18D -- hazards[0].something perp car's current hz pos? byte only? i thought it was a word
8B90 LD C,$23 C = 45 -- likely where the perp car should stop (horizontally)
8B92 CP C Compare
8B93 LD B,$05 B = 5
8B95 JR Z,handle_perp_caught_10 -- no change required
8B97 JR C,handle_perp_caught_9 -- change by 5
8B99 LD B,$FB B = -5 -- change by -5
handle_perp_caught_9 8B9B ADD A,B C = A + B
8B9C LD C,A
handle_perp_caught_10 8B9D LD A,C *$A18D = C -- hazards[0].something perp car hz pos
8B9E LD ($A18D),A
8BA1 LD HL,($A26C) HL = road_pos
8BA4 PUSH HL Stack it
8BA5 LD DE,$0105 DE = $0105 -- centre road position
8BA8 SBC HL,DE HL -= DE
8BAA POP HL Unstack read_pos
8BAB LD A,$09 A = 9
8BAD JR NC,handle_perp_caught_11 Jump to handle_perp_caught_11 if HL >= DE
8BAF LD DE,$00F5
8BB2 SBC HL,DE HL -= DE
8BB4 LD A,$0A A = 10
8BB6 JR C,handle_perp_caught_11
8BB8 LD A,$08 A = 8
handle_perp_caught_11 8BBA LD C,A C = A
8BBB AND $03 A &= 3
8BBD JR NZ,handle_perp_caught_12
8BBF LD A,($A189) A = *$A189 -- hazards[0].<distance related>
8BC2 CP $03
8BC4 JR NC,handle_perp_caught_12
8BC6 LD HL,$A173
8BC9 DEC (HL)
8BCA JR NZ,handle_perp_caught_12
8BCC XOR A speed = 0
8BCD LD D,A
8BCE LD E,A
8BCF LD ($A24A),DE
8BD3 LD ($A18C),A *$A18C = 0 -- hazards[0].something
8BD6 INC A *$A189 = 1 -- hazards[0].<distance related>
8BD7 LD ($A189),A
8BDA INC A perp_caught_stage = 2
8BDB LD ($A230),A
8BDE INC A smoke = 3
8BDF LD ($A24F),A
8BE2 JP hpc_set_perp_pos Jump to hpc_set_perp_pos
handle_perp_caught_12 8BE5 LD A,($A189) A = *$A189 -- hazards[0].<distance related>
8BE8 LD HL,$015E
8BEB CP $0F
8BED JR NC,handle_perp_caught_14
8BEF CPL A = ~A + $F
8BF0 ADD A,$0F
8BF2 LD DE,$0014 DE = 20
8BF5 LD B,A B = A -- iterations
handle_perp_caught_13 8BF6 SBC HL,DE HL -= DE
8BF8 DJNZ handle_perp_caught_13 Loop while B > 0
handle_perp_caught_14 8BFA EX DE,HL
8BFB LD HL,($A24A) HL = speed
8BFE PUSH HL
8BFF SBC HL,DE Jump if HL < DE
8C01 JR C,handle_perp_caught_15
8C03 RES 3,C Clear Up, i.e. stop accelerating
8C05 LD DE,$0032 Jump if HL < 50
8C08 SBC HL,DE
8C0A JR C,handle_perp_caught_15
8C0C SET 2,C Set Down bit, i.e. brake
handle_perp_caught_15 8C0E POP HL
8C0F LD DE,$0096 DE = 150
8C12 SBC HL,DE HL -= DE
8C14 LD A,($A253) A = gear
8C17 SBC A,$00 -- must be removing carry from calc above?
8C19 JR NZ,handle_perp_caught_16
8C1B SET 4,C Set Fire
handle_perp_caught_16 8C1D LD A,C user_input = C
8C1E LD ($A0D5),A
8C21 LD HL,($A195) A195 is horz position of perp car
8C24 PUSH HL Jump to hpc_set_perp_pos if HL <= $46
8C25 LD DE,$0046
8C28 SBC HL,DE
8C2A POP HL
8C2B JR Z,hpc_set_perp_pos
8C2D JR C,hpc_set_perp_pos
8C2F LD DE,$0005 HL -= 5
8C32 SBC HL,DE
8C34 EX DE,HL
This entry point is used by the routine at fully_smashed.
hpc_set_perp_pos 8C35 LD ($A195),DE $A195 = DE (position)
8C39 RET Return
Prev: 8A36 Up: Map Next: 8C3A