Prev: 25784 Up: Map Next: 25918
25789: 'S' pressed - somersault
The address of this routine is found in the table of keypress handling routines at 60672. It is called from the main loop at 61483 when 'S' is pressed.
25789 LD HL,25748 The animation phase table for Sam when somersaulting is at 25748
This entry point is used by the routine at 25784 with HL=25724.
25792 PUSH HL Save the address of the animation phase table
25793 CALL 25918 Return to the main loop if Sam cannot roll or somersault from his current location
25796 LD A,8 Set bit 3 of Sam's status flags at 32764
25798 LD (32764),A
25801 POP HL Restore the address of the animation phase table to HL
25802 LD (58892),HL Copy the address of the animation phase table into bytes 12 and 13 of Sam's buffer
This entry point is used by the routine at 29912 when bit 3 at 32764 is set (by this routine - see above).
25805 LD HL,58888 Reset Sam's main action timer (in byte 8 of his buffer) to 6
25808 LD (HL),6
25810 CALL 59848 Update the SRB for Sam's current animatory state and location
25813 LD HL,(58892) Point HL at the first byte of the current entry in the animation phase table
25816 AND 128 Set the zero flag if Sam is facing left
25818 LD B,A B=0 if Sam is facing left, 128 if facing right
25819 LD A,(HL) A=first byte of the animation phase table entry
25820 INC HL Point HL at the second byte in the entry
25821 JR Z,25824 Jump if Sam is facing left
25823 LD A,(HL) A=second byte of the animation phase table entry
25824 ADD A,E Add Sam's current x-coordinate
25825 LD E,A E=Sam's next x-coordinate
25826 INC HL A=third byte of the animation phase table entry
25827 LD A,(HL)
25828 ADD A,D Add Sam's current y-coordinate
25829 LD D,A D=Sam's next y-coordinate
25830 INC HL A=fourth byte of the animation phase table entry
25831 LD A,(HL)
25832 INC HL Point HL at the first byte of the next entry
25833 LD (58892),HL Store this address in bytes 12 and 13 of Sam's buffer
25836 RLCA C=Sam's next base animatory state (bit 7 reset)
25837 AND A
25838 RRA
25839 LD C,A
25840 JR NC,25877 Jump unless it's time to check whether Sam has landed
It's time to check whether Sam has landed on his feet yet.
25842 PUSH DE Save Sam's new coordinates briefly
25843 AND A Is Sam's next animatory state 0 or 128 (standing upright)?
25844 JR Z,25853 Jump if so
25846 DEC E Subtract 1 from Sam's new x-coordinate
25847 BIT 7,B Is Sam facing left?
25849 JR Z,25853 Jump if so
25851 INC E Add 1 to Sam's new x-coordinate
25852 INC E
25853 CALL 60159 Has Sam landed on the sidewalk or the road yet?
25856 JR NC,25866 Jump if so
25858 LD A,E A=Sam's adjusted new x-coordinate
25859 POP DE Restore Sam's new x-coordinate to E
25860 INC D Add 1 to Sam's new y-coordinate (move him down a level)
25861 PUSH DE Save Sam's adjusted new coordinates briefly
25862 LD E,A E=Sam's adjusted new x-coordinate
25863 CALL 60159 Set the carry flag unless Sam has landed on the sidewalk or road
25866 POP DE Restore Sam's adjusted new y-coordinate to D, and his new x-coordinate to E
25867 JR C,25876 Jump if Sam has not landed yet
25869 LD A,C A=Sam's next base animatory state (bit 7 reset)
25870 AND A Is it 0 or 128 (standing upright)?
25871 JR NZ,25876 Jump if not
25873 LD (32764),A Clear all of Sam's status flags at 32764 (Sam has landed)
25876 LD A,C A=Sam's next base animatory state (bit 7 reset)
25877 CP 9 Is the new base animatory state < 9 (meaning Sam has just started or is just finishing a roll or somersault)?
25879 JR C,25893 Jump if so
25881 PUSH BC Save Sam's direction indicator and next base animatory state
25882 PUSH DE Save Sam's next x- and y-coordinates
25883 CP 15 Is the new base animatory state 15 (meaning Sam is going to rotate 90 degrees for the first part of the roll or somersault)?
25885 CALL Z,25618 If so, prepare sprite tiles 239-247 for this animatory state
25888 CALL NZ,25672 Otherwise, rotate sprite tiles 239-247 for animatory state 9, 31 or 10
25891 POP DE Restore Sam's next x- and y-coordinates to E and D
25892 POP BC Restore Sam's direction indicator and next base animatory state to B and C
25893 LD H,230 230=Sam
25895 LD A,B A=Sam's new animatory state
25896 OR C
25897 CALL 59861 Update Sam's animatory state and location and update the SRB
25900 LD A,(32764) Collect Sam's status flags from 32764
25903 AND A Has Sam landed yet?
25904 RET NZ Return if not
25905 CALL 60521 Make a sound effect
25908 LD L,12 Point HL at byte 12 of Sam's buffer
25910 CALL 25539 Check whether Sam has somersaulted onto a banknote
25913 LD H,230 230=Sam
25915 JP 60547 Now that Sam has landed, scroll the screen left or right if necessary
Prev: 25784 Up: Map Next: 25918