Prev: 55787 Up: Map Next: 55930
55808: Update Player Body
Used by the routine at UpdateBumpingBody.
The routine for objects of type 32 to 47, the body of the player. The body follows the legs (the object before it), and has the same sprite number as the legs. A sound is played when the legs bump into something, and the body then changes to the bumping pose. When the player is standing still, the body occasionally looks around.
UpdatePlayerBody 55808 PUSH IX Use the position of the body as the destination of the copy (using the stack).
55810 POP DE
55811 INC DE
55812 LD HL,65520 Use the position of the legs as the source of the copy.
55815 ADD HL,DE
55816 LD BC,5 Copy the position and the speed of the legs.
55819 LDIR
55821 LD A,(IX-10) Jump to UpdatePlayerBody_Idle if the turn counter of the legs is zero.
55824 AND 7
55826 JR Z,UpdatePlayerBody_Idle
UpdatePlayerBody_Copy 55828 LD A,(IX-16) Make the type of the body from the type of the legs.
55831 AND 15
55833 OR 32
55835 LD (IX+0),A
55838 LD (IX+6),0 Clear the direction and timer of the body.
55842 LD A,(IX-9) Copy the flags of the legs.
55845 LD (IX+7),A
UpdatePlayerBody_Bump 55848 BIT 0,(IX-9) Return if the legs have not bumped into something.
55852 RET Z
55853 LD A,(IX+0) Play the sound for a bump, unless the body is in the bumping pose already.
55856 AND 7
55858 CP 6
55860 CALL NZ,PlayBumpSound
55863 LD A,(IX-16) Make the type of the body from the type of the legs, but with the lowest three bits set to 6 for the bumping pose.
55866 AND 248
55868 OR 6
55870 LD (IX+0),A
55873 LD (IX+6),0 Clear the direction and timer of the body.
55877 RET Return.
The player is standing still, so the body looks around from time to time.
UpdatePlayerBody_Idle 55878 LD A,(IX+6) Jump to UpdatePlayerBody_Timer if the timer of the body has not run out.
55881 AND A
55882 JR NZ,UpdatePlayerBody_Timer
55884 LD A,(48042) Jump to UpdatePlayerBody_Copy unless the random seed is less than 8.
55887 CP 8
55889 JR NC,UpdatePlayerBody_Copy
55891 AND 1 Choose between two poses from the random seed.
55893 LD C,A
55894 LD A,(IX-16) Set the type of the body to one of the poses for looking around.
55897 AND 8
55899 OR 38
55901 OR C
55902 LD (IX+0),A
55905 LD A,R Set the timer of the body to a random time of two to nine frames.
55907 AND 7
55909 ADD A,2
55911 LD (IX+6),A
55914 LD A,(IX-9) Copy the flags of the legs.
55917 LD (IX+7),A
55920 JR UpdatePlayerBody_Bump Jump to UpdatePlayerBody_Bump.
UpdatePlayerBody_Timer 55922 DEC A Count down the timer of the body.
55923 LD (IX+6),A
55926 JR Z,UpdatePlayerBody_Copy Jump to UpdatePlayerBody_Copy if the timer has run out.
55928 JR UpdatePlayerBody_Bump Jump to UpdatePlayerBody_Bump.
Prev: 55787 Up: Map Next: 55930