Prev: D9EB Up: Map Next: DA7A
DA00: Update Player Body
Used by the routine at UpdateBumpingBody.
The routine for objects of type 20 to 2F, 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 DA00 PUSH IX Use the position of the body as the destination of the copy (using the stack).
DA02 POP DE
DA03 INC DE
DA04 LD HL,$FFF0 Use the position of the legs as the source of the copy.
DA07 ADD HL,DE
DA08 LD BC,$0005 Copy the position and the speed of the legs.
DA0B LDIR
DA0D LD A,(IX-$0A) Jump to UpdatePlayerBody_Idle if the turn counter of the legs is zero.
DA10 AND $07
DA12 JR Z,UpdatePlayerBody_Idle
UpdatePlayerBody_Copy DA14 LD A,(IX-$10) Make the type of the body from the type of the legs.
DA17 AND $0F
DA19 OR $20
DA1B LD (IX+$00),A
DA1E LD (IX+$06),$00 Clear the direction and timer of the body.
DA22 LD A,(IX-$09) Copy the flags of the legs.
DA25 LD (IX+$07),A
UpdatePlayerBody_Bump DA28 BIT 0,(IX-$09) Return if the legs have not bumped into something.
DA2C RET Z
DA2D LD A,(IX+$00) Play the sound for a bump, unless the body is in the bumping pose already.
DA30 AND $07
DA32 CP $06
DA34 CALL NZ,PlayBumpSound
DA37 LD A,(IX-$10) Make the type of the body from the type of the legs, but with the lowest three bits set to 06 for the bumping pose.
DA3A AND $F8
DA3C OR $06
DA3E LD (IX+$00),A
DA41 LD (IX+$06),$00 Clear the direction and timer of the body.
DA45 RET Return.
The player is standing still, so the body looks around from time to time.
UpdatePlayerBody_Idle DA46 LD A,(IX+$06) Jump to UpdatePlayerBody_Timer if the timer of the body has not run out.
DA49 AND A
DA4A JR NZ,UpdatePlayerBody_Timer
DA4C LD A,($BBAA) Jump to UpdatePlayerBody_Copy unless the random seed is less than 08.
DA4F CP $08
DA51 JR NC,UpdatePlayerBody_Copy
DA53 AND $01 Choose between two poses from the random seed.
DA55 LD C,A
DA56 LD A,(IX-$10) Set the type of the body to one of the poses for looking around.
DA59 AND $08
DA5B OR $26
DA5D OR C
DA5E LD (IX+$00),A
DA61 LD A,R Set the timer of the body to a random time of two to nine frames.
DA63 AND $07
DA65 ADD A,$02
DA67 LD (IX+$06),A
DA6A LD A,(IX-$09) Copy the flags of the legs.
DA6D LD (IX+$07),A
DA70 JR UpdatePlayerBody_Bump Jump to UpdatePlayerBody_Bump.
UpdatePlayerBody_Timer DA72 DEC A Count down the timer of the body.
DA73 LD (IX+$06),A
DA76 JR Z,UpdatePlayerBody_Copy Jump to UpdatePlayerBody_Copy if the timer has run out.
DA78 JR UpdatePlayerBody_Bump Jump to UpdatePlayerBody_Bump.
Prev: D9EB Up: Map Next: DA7A