Jet Set Willy: Routine at 94F9

| Routines

94F9: Move the conveyor in the current room

Used by the routine at 89AD.
94F9 | LD HL,($80D7) | Pick up the address of the conveyor's location in the attribute buffer at 5E00 from 80D7
94FC | LD A,H | Point DE and HL at the location of the left end of the conveyor in the screen buffer at 7000
94FD | AND $01
94FF | RLCA
9500 | RLCA
9501 | RLCA
9502 | ADD A,$70
9504 | LD H,A
9505 | LD E,L
9506 | LD D,H
9507 | LD A,($80D9) | Pick up the length of the conveyor from 80D9
950A | OR A | Is there a conveyor in the room?
950B | RET Z | Return if not
950C | LD B,A | B will count the conveyor tiles
950D | LD A,($80D6) | Pick up the direction of the conveyor from 80D6 (0=left, 1=right)
9510 | OR A | Is the conveyor moving right?
9511 | JR NZ,$9526 | Jump if so
The conveyor is moving left.
9513 | LD A,(HL) | Copy the first pixel row of the conveyor tile to A
9514 | RLC A | Rotate it left twice
9516 | RLC A
9518 | INC H | Point HL at the third pixel row of the conveyor tile
9519 | INC H
951A | LD C,(HL) | Copy this pixel row to C
951B | RRC C | Rotate it right twice
951D | RRC C
951F | LD (DE),A | Update the first and third pixel rows of every conveyor tile in the screen buffer at 7000
9520 | LD (HL),C
9521 | INC L
9522 | INC E
9523 | DJNZ $951F
9525 | RET |
The conveyor is moving right.
9526 | LD A,(HL) | Copy the first pixel row of the conveyor tile to A
9527 | RRC A | Rotate it right twice
9529 | RRC A
952B | INC H | Point HL at the third pixel row of the conveyor tile
952C | INC H
952D | LD C,(HL) | Copy this pixel row to C
952E | RLC C | Rotate it left twice
9530 | RLC C
9532 | JR $951F | Jump back to update the first and third pixel rows of every conveyor tile