Prev: 38098 Up: Map Next: 38196
38137: Move the conveyor in the current room
Used by the routine at 35245.
Input
Output
38137 LD HL,(32983) Pick up the address of the conveyor's location in the attribute buffer at 24064 from 32983
38140 LD A,H Point DE and HL at the location of the left end of the conveyor in the screen buffer at 28672
38141 AND 1
38143 RLCA
38144 RLCA
38145 RLCA
38146 ADD A,112
38148 LD H,A
38149 LD E,L
38150 LD D,H
38151 LD A,(32985) Pick up the length of the conveyor from 32985
38154 OR A Is there a conveyor in the room?
38155 RET Z Return if not
38156 LD B,A B will count the conveyor tiles
38157 LD A,(32982) Pick up the direction of the conveyor from 32982 (0=left, 1=right)
38160 OR A Is the conveyor moving right?
38161 JR NZ,38182 Jump if so
The conveyor is moving left.
38163 LD A,(HL) Copy the first pixel row of the conveyor tile to A
38164 RLC A Rotate it left twice
38166 RLC A
38168 INC H Point HL at the third pixel row of the conveyor tile
38169 INC H
38170 LD C,(HL) Copy this pixel row to C
38171 RRC C Rotate it right twice
38173 RRC C
38175 LD (DE),A Update the first and third pixel rows of every conveyor tile in the screen buffer at 28672
38176 LD (HL),C
38177 INC L
38178 INC E
38179 DJNZ 38175
38181 RET
The conveyor is moving right.
38182 LD A,(HL) Copy the first pixel row of the conveyor tile to A
38183 RRC A Rotate it right twice
38185 RRC A
38187 INC H Point HL at the third pixel row of the conveyor tile
38188 INC H
38189 LD C,(HL) Copy this pixel row to C
38190 RLC C Rotate it left twice
38192 RLC C
38194 JR 38175 Jump back to update the first and third pixel rows of every conveyor tile
Prev: 38098 Up: Map Next: 38196