Prev: A955 Up: Map Next: A9DE
A97E: Lays out dirt and stones
This seems to calculate the position of stones on the dirt track section.
Used by the routines at main_loop and cpu_driver.
layout_dirt_and_stones A97E LD A,$00 A = <self modified> -- Self modified by A974
A980 AND A Return if A is zero
A981 RET Z
A982 LD IYh,$E3 IY = $E361
A985 LD IYl,$61
A988 LD BC,$1400 BC = $1400
A98B LD HL,$ED28 Point HL at (something above the stack)
Scan through whatever-it-is for a non-zero byte. Move 4 bytes per iteration.
ldas_loop1 A98E LD A,(HL) A = *HL++
A98F AND A Set flags
A990 INC HL
A991 JR NZ,layout_dirt_and_stones_0 Jump to A9A7 if non-zero
A993 INC HL HL += 3
A994 INC HL
A995 INC HL
ldas_loop1_continue A996 DEC IY IY--
A998 DJNZ ldas_loop1 Loop to ldas_loop1 while B > 0
A99A LD A,C A = C
A99B AND A Set flags
A99C RET NZ Return if non-zero
A99D LD ($A97F),A Self modify LD A @ layout_dirt_and_stones
A9A0 LD ($C0BC),A Self modify LD A @ rm_c0bb
A9A3 LD ($A9DF),A Self modify LD A @ dust_stones_stuff
A9A6 RET Return
layout_dirt_and_stones_0 A9A7 LD A,(HL) A = *HL++
A9A8 INC HL
A9A9 INC C C++
A9AA EXX
A9AB EX AF,AF' Bank A
A9AC LD A,(IY+$01) L = ~(IY[1] * 2)
A9AF ADD A,A
A9B0 CPL
A9B1 LD L,A
A9B2 LD H,$E8 H = $E8 -- road drawing (left)
A9B4 LD D,(HL) D = *HL
A9B5 DEC L L--
A9B6 LD E,(HL) E = *HL
A9B7 LD H,$EC H = $EC
A9B9 LD A,(HL) A = *HL
A9BA INC L L++
A9BB LD H,(HL) H = *HL
A9BC LD L,A L = A
A9BD AND A Set flags
A9BE PUSH DE
A9BF SBC HL,DE HL -= DE
A9C1 EX DE,HL
A9C2 LD HL,$0000 HL = $0000 [not self modified]
A9C5 EX AF,AF' Unbank A
Multiplier.
A9C6 LD B,$08 B = 8
ldas_loop2 A9C8 RLA
A9C9 JR NC,layout_dirt_and_stones_1 If carry HL += DE
A9CB ADD HL,DE
layout_dirt_and_stones_1 A9CC ADD HL,HL HL <<= 1
A9CD DJNZ ldas_loop2 Loop to ldas_loop2 while B > 0
A9CF LD A,H A = H
A9D0 RRA
A9D1 LD C,A C = A
A9D2 POP HL
A9D3 ADD HL,BC HL += BC
A9D4 PUSH HL
A9D5 EXX
A9D6 POP DE
A9D7 LD (HL),E DE = wordat(HL); HL += 2
A9D8 INC HL
A9D9 LD (HL),D
A9DA INC HL
A9DB JP ldas_loop1_continue Jump to ldas_loop1_continue
Prev: A955 Up: Map Next: A9DE