Prev: 56004 Up: Map Next: 56069
56005: Animate Pendulum
Used by the routine at Handler_PendulumRooms.
Steps the pendulum sprite IDs for rooms 10 and 11.
Reset after a room change.
Handler_Pendulum 56005 LD A,(56003) Jump to Handler_Pendulum_Step unless the position is 255.
56008 CP 255
56010 JR NZ,Handler_Pendulum_Step
56012 LD A,216 Write 216 to *Pendulum_Position and 2 to *Pendulum_Delta.
56014 LD (56003),A
56017 LD A,2
56019 LD (56004),A
Advance the position.
Handler_Pendulum_Step 56022 LD A,(56003) Add *Pendulum_Delta to *Pendulum_Position.
56025 LD C,A
56026 LD A,(56004)
56029 ADD A,C
56030 LD (56003),A
Keep the new position as both sprite IDs.
56033 LD C,A Copy the position into B and C.
56034 LD B,A
Bounce at the end-stops.
56035 CP 214 Jump to Handler_Pendulum_Bounce if the position is 214 or 226.
56037 JR Z,Handler_Pendulum_Bounce
56039 CP 226
56041 JR Z,Handler_Pendulum_Bounce
Use the same frame for both sprites in room 10.
56043 LD A,(25762) Jump to Draw_Pendulum if the room is 10.
56046 CP 10
56048 JR Z,Draw_Pendulum
Mirror the first sprite in room 11.
56050 LD A,220 Mirror the first sprite around 220.
56052 SUB B
56053 ADD A,220
56055 LD B,A
56056 JR Draw_Pendulum Jump to Draw_Pendulum.
Negate the delta and apply it again.
Handler_Pendulum_Bounce 56058 LD A,(56004) Decrease the delta by one.
56061 DEC A
56062 XOR %11111111 Invert every bit.
56064 LD (56004),A Write the negated delta to *Pendulum_Delta.
56067 JR Handler_Pendulum_Step Jump to Handler_Pendulum_Step.
Prev: 56004 Up: Map Next: 56069