Prev: B9F4 Up: Map Next: BC3E
BB69: Handle exiting from a road fork
Used by the routine at main_loop.
When fork_distance exceeds 255 we can proceed.
exit_fork BB69 LD A,($A268) Return if (fork_distance & $FF00) is zero
BB6C AND A
BB6D RET Z
Reset road setup back to a single road now that the forked road has completed.
BB6E LD A,($A249) A = fork_taken - 1
BB71 DEC A
BB72 JR Z,ef_right Jump if A is zero (right fork taken)
Set up left route.
ef_left BB74 LD DE,$FC01 D,E = $FC,$01 (curvature byte -4 => super hard (?) left turn, lanes byte = 1)
BB77 PUSH DE Save for later
BB78 LD HL,$E2D9 road_leftside_ptr = $E2D9
BB7B LD ($A276),HL
BB7E LD HL,$E2D5 road_rightside_ptr = $E2D5
BB81 LD ($A274),HL
BB84 LD HL,$E2E7 road_lanes_ptr = $E2E7
BB87 LD ($A272),HL
BB8A LD HL,$0000 Self modified by C035 to be the left route's hazards data
BB8D LD DE,$0000 Self modified by BF73 to be the left route's rightside data
BB90 LD BC,$0000 Self modified by BFBC to be the left route's leftside data
BB93 EXX Bank
BB94 LD HL,$0000 Self modified by BE5C to be the left route's curvature data
BB97 LD DE,$0000 Self modified by BEAE to be the left route's height data
BB9A LD BC,$0000 Self modified by BEF9 to be the left route's lanes data
BB9D LD A,$40 A = 64 -- additional offset into road buffer (presumably left objects)
BB9F JR ef_set_handlers Jump to ef_set_handlers
Set up right route.
ef_right BBA1 LD DE,$0403 D,E = $04,$03 (curvature byte +4 => super hard (?) right turn, lanes byte = 3)
BBA4 PUSH DE Save for later
Note the switch around here.
BBA5 LD HL,$E2D5 road_leftside_ptr = $E2D5
BBA8 LD ($A276),HL
BBAB LD HL,$E2D9 road_rightside_ptr = $E2D9
BBAE LD ($A274),HL
BBB1 LD HL,$E2F3 road_lanes_ptr = $E2F3
BBB4 LD ($A272),HL
BBB7 LD HL,$0000 Self modified by C03D to be the right route's hazards data
BBBA LD DE,$0000 Self modified by BF73 to be the right route's rightside data
BBBD LD BC,$0000 Self modified by BFC4 to be the right route's leftside data
BBC0 EXX Bank
BBC1 LD HL,$0000 Self modified by BE62 to be the right route's curvature data
BBC4 LD DE,$0000 Self modified by BEB6 to be the right route's height data
BBC7 LD BC,$0000 Self modified by BF01 to be the right route's lanes data
BBCA LD A,$20 A = 32 -- additional offset into road buffer (presumably right objects)
ef_set_handlers BBCC LD ($BE6D),HL Self modify rm_curvature_one_command handler
BBCF LD ($BEBF),DE Self modify rm_height_one_command handler
BBD3 LD ($BF0A),BC Self modify rm_lanes_one_command handler
BBD7 EXX Unbank
BBD8 LD ($BFCD),BC Self modify rm_leftside_one_command handler
BBDC LD ($BF84),DE Self modify rm_rightside_one_command handler
BBE0 LD ($C046),HL Self modify rm_hazards_one_command handler
BBE3 LD HL,$E2DD road_curvature_ptr = $E2DD
BBE6 LD ($A26E),HL
BBE9 LD HL,$E2E2 road_height_ptr = $E2E2
BBEC LD ($A270),HL
BBEF LD HL,$E2D2 road_hazard_ptr = $E2D2
BBF2 LD ($A278),HL
BBF5 POP DE Suspected road curve type left/right
BBF6 LD C,A Copy road buffer additional offset
The code commonly loads the byte at road_buffer_offset and merges it with $EE00, yet road_buffer_offset already contains a whole word with the right value.
BBF7 LD A,($A240) Load road_buffer_offset into A [as byte]
BBFA LD L,A Point HL at road buffer curvature data
BBFB LD H,$EE
Set the 32 bytes at HL to the road curvature type in D.
BBFD LD B,$20 32 iterations
ef_set_curvature_loop BBFF LD (HL),D Store
BC00 INC L Advance
BC01 DJNZ ef_set_curvature_loop Loop
Set the 32 bytes at HL + 64 to the lane type in E.
BC03 ADD A,$40 A = road_buffer_offset + 64
BC05 LD L,A Point HL at lane bytes
BC06 LD B,$20 32 iterations
ef_set_lanes_loop BC08 LD (HL),E Store
BC09 INC L Advance
BC0A DJNZ ef_set_lanes_loop Loop
Zero the 32 bytes at HL + 64 + C (the additional offset that was setup earlier). This seems to be objects.
BC0C ADD A,C get offset
BC0D LD L,A Point HL at (?) bytes
BC0E LD E,B E = 0, since B is zero
BC0F LD B,$20 32 iterations
ef_set_objects_loop BC11 LD (HL),E Store
BC12 INC L Advance
BC13 DJNZ ef_set_objects_loop Loop
BC15 XOR A curvature_byte = 0
BC16 LD C,A
BC17 LD ($A242),A
BC1A LD ($A243),A height_byte = 0
BC1D LD ($A244),A leftside_byte = 0
BC20 LD ($A245),A rightside_byte = 0
BC23 LD ($A246),A hazards_byte = 0
BC26 LD ($A247),A lanes_counter_byte = 0
BC29 LD ($A269),A fork_in_progress = 0
BC2C LD ($A249),A fork_taken = 0
BC2F LD ($A265),A fork_visible = 0
BC32 INC A no_objects_counter = 1
BC33 LD ($A185),A
BC36 LD ($A16D),A var_a16d = 1
BC39 LD ($A267),BC fork_distance = 0 [B & C are zero here]
BC3D RET Return
Prev: B9F4 Up: Map Next: BC3E