Prev: 9052 Up: Map Next: 924D
916C: Draws stretchy objects, such as trees.
Used by the routine at draw_overhead.
Input
B ? value that affects scaling
DE Address of graphic data [structure type yet to be named] (e.g. stretchy_shortpole/stretchy_shortpole)
Entry point for left hand objects.
draw_stretchy_object_left 916C LD HL,$9293 HL = $9293 -- callback address
916F JR dso_common
Entry point for right hand objects.
draw_stretchy_object_right 9171 LD HL,$92FC HL = $92FC -- callback address
dso_common 9174 LD ($91CE),HL Self modify CALL at $91CD to call HL
9177 LD ($9244),HL Self modify CALL at $9243 to call HL
917A LD A,($A23F) A = fast_counter & $E0
917D AND $E0
Reduces A by 31.25%. A = 0..224 (in steps of 16) becomes 0..154.
917F LD L,A L = A -- nothing will rotate out due to AND $E0
9180 RRC L L >>= 2
9182 RRC L
9184 SUB L A -= L
9185 RRC L L >>= 2
9187 RRC L
9189 SUB L A -= L
918A ADD A,B B is the value passed in
Look up that value in $E600[].
918B LD L,A HL = $E600 + L
918C LD H,$E6
918E LD A,(HL) A = *HL
918F LD ($91DC),A Self modify 'LD A,x' at 91DB to load A
9192 EX DE,HL Swap
9193 LD A,B A = min(B,10)
9194 CP $0A
9196 JR C,draw_stretchy_object_left_0
9198 LD A,$0A
draw_stretchy_object_left_0 919A RLCA DE = A * 2 - 1 -- the -1 accounts for later pointer position
919B DEC A
919C LD E,A
919D LD D,$00
919F LD C,D C = 0
91A0 LD ($91BB),DE Self modify 'LD BC,xxxx' at 91BA to load DE
dso_loop 91A4 LD A,C A = -C
91A5 NEG
91A7 LD ($933E),A Self modify 'LD D,x' @ draw_object_right_8 to load A
91AA LD B,(HL) B = *HL - 1 -- read count byte from graphic stream, e.g. stretchy_shortpole + 0
91AB DEC B
91AC RET Z Return if count byte was 1 (terminator)
91AD INC HL Advance past count byte
91AE LD E,(HL) Read address of ? data to DE, e.g. shortpole_7e0c
91AF INC HL
91B0 LD D,(HL)
91B1 INC HL
91B2 PUSH HL Preserve HL, IX, BC
91B3 PUSH IX
91B5 PUSH BC
91B6 EX DE,HL Swap
91B7 LD E,(HL) DE = wordat(HL); HL++ -- this is the LOD pointer e.g. streetlampbody_lods
91B8 INC HL
91B9 LD D,(HL)
This seems to be a 0..9 value that selects from the table.
91BA LD BC,$0000 HL += <self modified> -- by 91A0, this is the table offset from earlier
91BD ADD HL,BC
HL now points to an entry in the table. Load it.
91BE LD A,(HL) A = *HL++ -- e.g. 0
91BF INC HL
91C0 LD L,(HL) HL = *HL -- e.g. $56
91C1 LD H,$00
91C3 ADD HL,DE HL += DE -- so HL's an offset from streetlampbody_lods
91C4 POP BC Restore BC
91C5 DEC B B-- -- e.g. cmd byte 2 would be 0 after this
91C6 JR NZ,dso_dispatch Jump to dispatch for cmd bytes 3+
Zero path => command byte was 2
91C8 LD B,(HL) B = *HL
91C9 DEC HL HL -= 2
91CA DEC HL
91CB PUSH BC Preserve BC
91CC LD B,A B = A
91CD CALL draw_object_left_stretchy_entrypt Call <self modified> -- callback
dso_loop_perhaps 91D0 POP BC Restore BC
91D1 LD A,C C += B
91D2 ADD A,B
91D3 LD C,A
91D4 POP IX Restore IX, HL
91D6 POP HL
91D7 JP dso_loop Loop dso_loop
Non-zero path
dso_dispatch 91DA EX AF,AF' Bank <byte[0] of table entry, loaded at 91BE>
91DB LD A,$00 A = <self modified>
Dispatch ladder
91DD DEC B Jump if 3
91DE JR Z,dso_case_3
91E0 DEC B Jump if 4
91E1 JR Z,dso_case_4
91E3 DEC B Jump if 5
91E4 JR Z,dso_case_5
91E6 DEC B Jump if 6
91E7 JR Z,dso_case_6
91E9 DEC B Jump if 7
91EA JR Z,dso_case_7
91EC DEC B Jump if 8
91ED JR Z,dso_case_8
91EF DEC B Jump to continue if 9
91F0 JR Z,dso_continue
91F2 ADD A,A A += A
91F3 JR dso_continue Continue
dso_case_8 91F5 SRL A A >>= 2
91F7 SRL A
91F9 JR dso_continue Continue
dso_case_7 91FB SRL A
91FD LD B,A B = A
91FE SRL B
9200 ADD A,B A += B
9201 JR dso_continue Continue
dso_case_6 9203 SRL A
9205 LD B,A B = A
9206 SRL B B >>= 2
9208 SRL B
920A SUB B A -= B
920B JR dso_continue Continue
dso_case_5 920D LD B,A B = A
920E SRL B B >>= 3
9210 SRL B
9212 SRL B
9214 ADD A,B A += B
9215 JR dso_continue Continue
dso_case_4 9217 SRL A
9219 JR dso_continue Continue
dso_case_3 921B LD B,A B = A
921C SRL B
921E ADD A,B A += B
dso_continue 921F SUB C A -= C
9220 JR Z,draw_stretchy_object_left_1
9222 JR NC,draw_stretchy_object_left_2 C was >= A
draw_stretchy_object_left_1 9224 LD A,$01 A = 1
draw_stretchy_object_left_2 9226 LD B,A B = A
9227 PUSH BC
9228 LD A,(IY+$35) A = IY[$35] + 1 - C - B
922B INC A
922C SUB C
922D SUB B
922E JR NC,draw_stretchy_object_left_3
9230 ADD A,B B += A
9231 LD B,A
draw_stretchy_object_left_3 9232 LD A,B A = B
9233 LD ($9405),A *$9405 = A
9236 LD A,(HL) A = *HL
9237 DEC HL HL -= 2
9238 DEC HL
9239 LD ($9416),A *$9416 = A
923C LD A,$02 A = $02
923E LD ($93C1),A Self modify 'LD A,x' @ 93C0 to load 2
9241 EX AF,AF'
9242 LD B,A B = A
9243 CALL draw_object_left_stretchy_entrypt Call <self modified>
9246 XOR A Self modify 'LD A,x' @ 93C0 to load 0
9247 LD ($93C1),A
924A JP dso_loop_perhaps Loop to dso_loop_perhaps
Prev: 9052 Up: Map Next: 924D