Prev: A97E Up: Map Next: AA38
A9DE: Draws one stone or dirt particle
Draws one stone or dirt particle a call, from the positions layout_dirt_and_stones worked out. Returns at once when the self modified enable flag is zero, which is what stops stones and dirt from rendering.
It reads the current entry through the particle pointer. A zero type byte means the slot is inactive and only advances the pointer. Otherwise the type byte picks the stones or the dust sprite table, B is clamped to 10 and halved for a level of detail index, and the particle is drawn at the x position in the entry.
Used by the routine at draw_scene_objects.
Input
B Distance counter, clamped to 10 and halved to pick the level of detail
draw_dirt_and_stones A9DE LD A,$00 A = <self modified> Self modified by A97A, A9A3
A9E0 AND A Set flags
A9E1 RET Z Return if zero
A9E2 LD HL,$ED28 Point HL at <self modified>
A9E5 LD A,(HL) A = *HL; HL += 2
A9E6 INC HL
A9E7 INC HL
A9E8 AND A Set flags
A9E9 JR NZ,dss_lods Jump to dss_lods if non-zero
Otherwise skip the next two bytes.
A9EB INC HL HL += 2
A9EC INC HL
A9ED LD ($A9E3),HL Self modify 'LD HL,x' @ A9E2 (above) to load HL
A9F0 RET Return
dss_lods A9F1 LD DE,($5D0C) Load contents of stones_lods
A9F5 DEC A A--
A9F6 JR Z,dss_a9fc If non-zero load contents of dust_lods
A9F8 LD DE,($5D0E)
dss_a9fc A9FC LD C,(HL) C = *HL++
A9FD INC HL
A9FE LD A,(HL) A = *HL
A9FF EX AF,AF'
AA00 INC HL HL++
AA01 LD ($A9E3),HL Self modify 'LD HL,x' @ A9E2 to load HL
AA04 XOR A A = 0
AA05 LD ($933E),A Self modify 'LD D,x' @ doc_loop to load zero
AA08 LD H,A H = 0
AA09 LD A,B A = B - 1
AA0A DEC A
AA0B CP $0B If A > 10 A = 10
AA0D JR C,dss_aa11
AA0F LD A,$0A
dss_aa11 AA11 SRL A A >>= 1
AA13 LD L,A L = A * 7
AA14 RLCA
AA15 RLCA
AA16 RLCA
AA17 SUB L
AA18 LD L,A
AA19 ADD HL,DE HL += DE -- find graphic definition entry
AA1A LD E,(HL) Fetch byte width
AA1B RLC E Multiply it by 8 yielding the pixel width
AA1D RLC E
AA1F RLC E
AA21 EX AF,AF'
AA22 AND A Set flags
AA23 LD A,C A = C
AA24 LD C,$00 C = $00 [not self modified]
AA26 JP M,dss_aa33 Jump to dss_aa33 if negative
AA29 RET NZ Return if non-zero
AA2A CP $80 Exit via draw_object_right_width_entrypt if A >= 128
AA2C JP NC,draw_object_right_width_entrypt
AA2F ADD A,E Add pixel width
AA30 JP draw_object_left_width_entrypt Exit via draw_object_left_width_entrypt
dss_aa33 AA33 ADD A,E Add pixel width
AA34 RET NC Return if no carry
AA35 JP draw_object_left_width_entrypt Exit via draw_object_left_width_entrypt
Prev: A97E Up: Map Next: AA38