Prev: DAC4 Up: Map Next: DB05
DAC5: Animate Pendulum
Used by the routine at Handler_PendulumRooms.
Steps the pendulum sprite IDs for rooms 0A and 0B.
Reset after a room change.
Handler_Pendulum DAC5 LD A,($DAC3) Jump to Handler_Pendulum_Step unless the position is FF.
DAC8 CP $FF
DACA JR NZ,Handler_Pendulum_Step
DACC LD A,$D8 Write D8 to *Pendulum_Position and 02 to *Pendulum_Delta.
DACE LD ($DAC3),A
DAD1 LD A,$02
DAD3 LD ($DAC4),A
Advance the position.
Handler_Pendulum_Step DAD6 LD A,($DAC3) Add *Pendulum_Delta to *Pendulum_Position.
DAD9 LD C,A
DADA LD A,($DAC4)
DADD ADD A,C
DADE LD ($DAC3),A
Keep the new position as both sprite IDs.
DAE1 LD C,A Copy the position into B and C.
DAE2 LD B,A
Bounce at the end-stops.
DAE3 CP $D6 Jump to Handler_Pendulum_Bounce if the position is D6 or E2.
DAE5 JR Z,Handler_Pendulum_Bounce
DAE7 CP $E2
DAE9 JR Z,Handler_Pendulum_Bounce
Use the same frame for both sprites in room 0A.
DAEB LD A,($64A2) Jump to Draw_Pendulum if the room is 0A.
DAEE CP $0A
DAF0 JR Z,Draw_Pendulum
Mirror the first sprite in room 0B.
DAF2 LD A,$DC Mirror the first sprite around DC.
DAF4 SUB B
DAF5 ADD A,$DC
DAF7 LD B,A
DAF8 JR Draw_Pendulum Jump to Draw_Pendulum.
Negate the delta and apply it again.
Handler_Pendulum_Bounce DAFA LD A,($DAC4) Decrease the delta by one.
DAFD DEC A
DAFE XOR %11111111 Invert every bit.
DB00 LD ($DAC4),A Write the negated delta to *Pendulum_Delta.
DB03 JR Handler_Pendulum_Step Jump to Handler_Pendulum_Step.
Prev: DAC4 Up: Map Next: DB05