Prev: 44867 Up: Map Next: 44935
44872: Animate Entity
Used by the routines at RunFrame and UpdateEntities.
Moves the entity on to the next frame of its animation every other frame. The counter in field 28 controls the speed, and field 29 holds the first and last frame numbers.
Input
IX The entity
AnimateEntity 44872 LD A,(41693) Fetch the frame counter.
44875 RRA Move its low bit into the carry flag.
44876 RET NC Return on every other frame.
44877 LD A,(IX+28) Fetch the animation counter and keep it in B.
44880 LD B,A
44881 SUB 64 Count it down by 64.
44883 JR NC,AnimateEntity_Store Jump to AnimateEntity_Store if it had not yet reached the next frame.
44885 LD A,(IX+1) Fetch the frame of the entity.
44888 AND %00001111 Keep the frame number.
44890 INC A Move on to the next frame.
44891 LD E,A Keep the next frame in E.
44892 LD A,(IX+29) Fetch the first and last frame numbers and keep them in D.
44895 LD D,A
44896 RRCA Move the last frame number down to bits 0-3.
44897 RRCA
44898 RRCA
44899 RRCA
44900 AND %00001111 Keep the last frame number.
44902 CP E Compare it with the next frame.
44903 JR NC,AnimateEntity_Frame Jump to AnimateEntity_Frame if the next frame is still within the animation.
44905 LD A,D Fetch the first and last frame numbers again.
44906 AND %00001111 Keep the first frame number.
44908 LD E,A Use the first frame, so that the animation repeats.
AnimateEntity_Frame 44909 LD A,(IX+1) Fetch the frame of the entity.
44912 AND %11110000 Keep the flags in bits 4-7.
44914 OR E Combine them with the new frame number.
44915 LD (IX+1),A Store the new frame.
44918 LD A,B Move bits 4-5 of the animation counter up to bits 6-7.
44919 ADD A,A
44920 ADD A,A
44921 AND %11000000 Keep those bits.
44923 OR (IX+28) Combine them with the animation counter.
44926 EX AF,AF' Save it.
44927 CALL SetEntitySize Set the sprite size for the new frame.
44930 EX AF,AF' Restore the animation counter.
AnimateEntity_Store 44931 LD (IX+28),A Store the animation counter.
44934 RET Return.
Prev: 44867 Up: Map Next: 44935