Prev: A7E7 Up: Map Next: A89C
A7F3: Spawns cars
Used by the routines at main_loop and cpu_driver.
spawn_cars A7F3 LD A,($A230) Return if perp_caught_stage or stop_car_spawning flags are set
A7F6 LD C,A
A7F7 LD A,($A225)
A7FA OR C
A7FB RET NZ
A7FC LD A,($A254) Load another_spawning_flag
A7FF AND A Return if another_spawning_flag was zero
A800 RET Z
A801 NEG A = <self modified> - another_spawning_flag
A803 ADD A,$14
A805 LD ($A804),A Self modify above
A808 RET C Return if carry?
Start spawning cars.
A809 CALL rng Call rng
A80C AND $0F C = A & 15
A80E LD C,A
A80F LD A,($A22E) Load sighted_flag
A812 AND A Set flags
A813 LD A,($5D1A) Load car_spawn_rate
A816 JR Z,spawn_cars_0 Jump to spawn_cars_0 if sighted_flag was zero
A818 ADD A,$19 A += 25 -- boost factor/rate when perp sighted
spawn_cars_0 A81A ADD A,C A += C -- add random factor (0..15)
A81B LD ($A804),A Self modify above
A81E LD BC,$0500 BC = $0500
A821 LD IX,$A19C IX = &hazards[1]
A825 LD DE,$0014 DE = 20 -- stride of hazards
sc_loop A828 RLC (IX+$00) If the hazard is not active jump to sc_fill_in
A82C JR NC,sc_fill_in
A82E LD A,(IX+$0F) A = IX[15]
A831 RLA
A832 JP NC,spawn_cars_1
A835 RL C
spawn_cars_1 A837 ADD IX,DE IX += DE
A839 DJNZ sc_loop Loop to sc_loop while B
A83B RET Return
sc_fill_in A83C BIT 2,C
A83E RET NZ
A83F PUSH IX DE = IX
A841 POP DE
A842 LD BC,$0014 BC = 20
A845 LD HL,$A623 Point HL at hazard_template
A848 LDIR Copy hazard_template
A84A LD C,$14 Buffer offset of 20 for get_spawn_lanes
A84C CALL get_spawn_lanes Call get_spawn_lanes -- Gets car spawning positions (B = min, C = max?)
A84F CALL rng Call rng
A852 AND $03 A = (A & 3) + B
A854 ADD A,B
A855 CP C If A >= C A = C
A856 JR C,spawn_cars_2
A858 LD A,C
spawn_cars_2 A859 LD (IX+$11),A IX[17] = A
A85C LD (IX+$12),A IX[18] = A
A85F LD HL,$A7E6 A = $A7E6[A]
A862 LD B,$00
A864 LD C,A
A865 ADD HL,BC
A866 LD A,(HL)
A867 LD (IX+$05),A IX[5] = A
A86A LD A,($A22E) Load sighted_flag
A86D AND A Set flags
A86E LD A,$04 A = 4
A870 JR Z,spawn_cars_3
A872 ADD A,A A <<= 1
spawn_cars_3 A873 LD C,A HL += A
A874 ADD HL,BC
A875 LD A,(HL) IX[13] = *HL
A876 LD (IX+$0D),A
A879 CALL rng Call rng
A87C AND $06 C = A & 6
A87E LD C,A
A87F LD A,($A22E) Load sighted_flag
A882 AND A Set flags
A883 JR Z,spawn_cars_4
A885 LD A,$06 A = 6
A887 CP C
A888 JR NZ,spawn_cars_4
A88A DEC C C--
A88B DEC C
spawn_cars_4 A88C LD B,$00 B = 0
A88E LD HL,$5D12 HL = &lods_vehicles (first of the generic car LODs)
A891 ADD HL,BC HL += BC
A892 LD A,(HL) wordat(IX+9) = HL
A893 INC HL
A894 LD (IX+$09),A
A897 LD A,(HL)
A898 LD (IX+$0A),A
A89B RET Return
Prev: A7E7 Up: Map Next: A89C