Prev: 96D1 Up: Map Next: 9797
96D9: Animate the rolling minecart in room 10
Used by the routine at 940C.
96D9 LD A,($5C7C) Is Monty at the bottom of the screen?
96DC CP $41
96DE JP NC,$943C Jump back to the main loop if not.
96E1 LD HL,$2F02 Initialize the minecart's position to X=02 y=2F
96E4 LD ($9797),HL Store this
96E7 LD HL,$3702 Initialize Monty's position to X=02 y=37
96EA LD ($5C7B),HL Store this.
96ED LD B,$80 Run for 80 times.
96EF PUSH BC Store BC
96F0 LD HL,$5C7B Increment Monty's x co-ordinate.
96F3 INC (HL)
96F4 LD HL,$9797 Increment the minecart's x co-ordinate.
96F7 INC (HL)
96F8 LD HL,($5C7B) Set Monty's co-ordinates as the location to print.
96FB LD ($ECDE),HL
96FE LD HL,$861C Set the graphic to Monty right (861C).
9701 LD ($ECE0),HL
9704 CALL $EBE0 Print the graphic.
9707 LD HL,($9797) Set the minecart's co-ordinates as the location to print.
970A LD ($ECDE),HL
970D LD HL,$6F80 Set the graphic to the minecart (6F80).
9710 LD A,($848E) Cycle Monty's current frame from 0 to 7. This is used in the animation cycle for the minecart.
9713 INC A
9714 AND $07
9716 LD ($848E),A
9719 RRCA Put the lowest 3 bits in B.
971A AND $03
971C LD B,A
971D LD DE,$0020 Set DE to move forward a graphic frame with each iteration.
9720 OR A If the frame is 0, skip ahead.
9721 JR Z,$9726
9723 ADD HL,DE Move to the next row.
9724 DJNZ $9723
9726 LD ($ECE0),HL Set the graphic frame as the one to draw.
9729 CALL $EBE0 Draw the minecart.
972C POP BC Restore BC and loop if there is more to do.
972D DJNZ $96EF
The minecart has now hit the buffers. Tip it.
972F LD HL,$7780 7780 is the empty graphic.
9732 LD ($ECE0),HL Set the graphic to draw.
9735 LD HL,($5C7B) Set at the current position.
9738 LD ($ECDE),HL
973B CALL $EBE0 Draw the graphic.
973E LD HL,$3F98 Set a new position to 98 3F.
9741 LD ($5C7B),HL
9744 LD B,$20 Run for 20 times.
9746 PUSH BC Remember BC.
9747 LD A,B Put the next frame in DE.
9748 DEC A
9749 AND $18
974B ADD A,A
974C ADD A,A
974D LD E,A
974E LD D,$00
9750 PUSH DE Remember this.
9751 LD HL,$7000 Add to the base offset of the tipping minecart graphic (7000).
9754 ADD HL,DE
9755 LD ($ECE0),HL Set this as the graphic to print.
9758 LD HL,($9797) Set the location to be X = 97 Y = 97.
975B LD ($ECDE),HL
975E CALL $EBE0 Draw the graphic.
9761 LD HL,($5C7B) Get Monty's position.
9764 LD ($ECDE),HL Set this as the position of the next sprite to update. (ECDE).
9767 POP DE Restore DE.
9768 ADD HL,DE No effect, HL is overwritten in the next instruction.
9769 LD HL,$9799 Set the location to be X = 97 Y = 99.
976C LD ($ECE0),HL
976F CALL $EBE0 Draw the graphic.
9772 LD IX,$5C7B Move monty 1 to the right and 1 down.
9776 INC (IX+$00)
9779 DEC (IX+$01)
977C POP BC Restore BC.
977D DJNZ $9746 Loop while there is still more to draw.
Monty has fallen off the edge, put him in the next room.
977F LD A,$11 Set A to 11 to set up some flags.
9781 LD HL,$A1C0 Set the position to X = C0 Y = A1.
9784 LD ($5C7B),HL
9787 LD ($964B),HL
978A LD ($9649),A Set the current room to 11.
978D XOR A Reset distance fallen.
978E LD ($8D58),A
9791 LD ($8498),A Reset time jumping.
9794 JP $940C Enter the new room.
Prev: 96D1 Up: Map Next: 9797