Prev: A399 Up: Map Next: A60E
A579: Routine at A579
Used by the routines at main_loop, cpu_driver and escape_scene.
main_loop_14 A579 LD HL,$E34F HL = $E34F -- somewhere in data block $E34B
A57C LD B,$15 B = 21 -- iterations
A57E XOR A A = 0
ml14_loop1 A57F ADD A,(HL) A += *HL
A580 LD (HL),A *HL++ = A
A581 INC L
A582 DJNZ ml14_loop1 Loop ml14_loop1 while B
A584 LD ($A60B),SP Self modify 'LD SP' @ ml14_return to restore SP
A588 LD SP,$EB00 SP = $EB00
A58B LD D,$EE D = $EE
A58D LD A,($A240) Load road_buffer_offset into A
A590 ADD A,$40 Add 64 so it's the lanes data offset
A592 LD E,A E = calculated offset
A593 LD IY,$E34F IY = $E34F
A597 LD B,$15 B = 21
A599 LD A,($A265) A = split_road -- split road flag
A59C AND A Set flags
A59D JP Z,ml14_loop2 Jump to ml14_loop2 if zero [not in road split]
A5A0 LD A,($A266) A = split_road_countdown
A5A3 AND A Set flags
A5A4 JR Z,main_loop_14_4 [not about to road split]
A5A6 LD B,A B = A
ml14_loop2 A5A7 LD A,(DE) A = *DE
A5A8 EXX
A5A9 LD E,A E = A
A5AA LD A,(IY+$00) A = ~(IY[0] * 2)
A5AD ADD A,A
A5AE CPL
A5AF LD L,A L = A
A5B0 LD A,E A = E & 3
A5B1 AND $03
A5B3 JR NZ,main_loop_14_1
A5B5 LD H,$E8 H = $E8
A5B7 LD B,(HL) B = *HL
A5B8 DEC L L--
A5B9 LD C,(HL) C = *HL
A5BA PUSH BC
main_loop_14_0 A5BB LD H,$EC H = $EC
A5BD JR ml14_a5da Jump to ml14_a5da
main_loop_14_1 A5BF ADD A,$E7 H = A + $E7
A5C1 LD H,A
Sampled HL = E869 E865 E863 E861
A5C2 LD B,(HL) B = *HL
A5C3 DEC L L--
A5C4 LD C,(HL) C = *HL
A5C5 PUSH BC
A5C6 RL E
A5C8 BIT 7,E
A5CA JP Z,main_loop_14_2
A5CD JR C,main_loop_14_0
A5CF LD A,$03 A = 3
A5D1 JR main_loop_14_3
main_loop_14_2 A5D3 LD A,$03 A = 3
A5D5 JR C,main_loop_14_3
A5D7 DEC A A--
main_loop_14_3 A5D8 ADD A,H H += A
A5D9 LD H,A
ml14_a5da A5DA LD C,(HL) C = *HL
A5DB INC L L++
A5DC LD B,(HL) B = *HL
A5DD PUSH BC
A5DE EXX
A5DF INC IY IY++
A5E1 INC E E++
A5E2 DJNZ ml14_loop2 Loop to ml14_loop2 while B
A5E4 LD A,($A266) A = split_road_countdown
A5E7 AND A Set flags
A5E8 JP Z,ml14_return Jump to ml14_return if zero
main_loop_14_4 A5EB LD A,($A266) A = ~split_road_countdown + 22
A5EE CPL
A5EF ADD A,$16
A5F1 JR Z,ml14_return Jump to ml14_return if zero
A5F3 LD B,A B = A
A5F4 LD H,$EB H = $EB
ml14_loop3 A5F6 LD A,(IY+$00) L = ~(IY[0] * 2)
A5F9 ADD A,A
A5FA CPL
A5FB LD L,A
A5FC DEC H H--
A5FD LD D,(HL) D = *HL
A5FE DEC L L--
A5FF LD E,(HL) E = *HL
A600 PUSH DE
A601 INC H H++
A602 LD E,(HL) E = *HL
A603 INC L L++
A604 LD D,(HL) D = *HL
A605 PUSH DE
A606 INC IY IY++
A608 DJNZ ml14_loop3 Loop ml14_loop3 while B
ml14_return A60A LD SP,$0000 Restore stack pointer -- Self modified above on entry
A60D RET Return
Prev: A399 Up: Map Next: A60E