Prev: 97E1 Up: Map Next: 9888
9867: Colour Entity
Sets the attributes of the character cells that the sprite of the object covers to the attribute of the object. The width in cells and the height in pixels come from New_Sprite_Width and New_Sprite_Height, which are set when the sprite is prepared. It works upwards from the bottom row of cells.
The number of rows of cells is worked out from the number of pixel lines of the sprite and the position of the bottom of the sprite within its character cell.
Input
IX Object record
ColourEntity 9867 LD L,(IX+$01) Fetch the x position of the object into L.
986A LD H,(IX+$03) Fetch the y position of the object into H.
986D LD D,(IX+$05) Fetch the attribute of the object into D.
9870 LD A,H Copy the y position to A and flip the bits.
9871 CPL
9872 AND %00000111 Keep only the pixel line within the character cell.
9874 LD B,A Store it in B.
9875 LD A,($8EE7) Fetch the height of the sprite from New_Sprite_Height.
9878 ADD A,$08 Add 08.
987A ADD A,B Add the pixel line.
987B RRCA Divide by eight.
987C RRCA
987D RRCA
987E AND %00011111 Keep only the low five bits.
9880 LD C,A Store the number of rows of cells in C.
9881 LD A,($8EE6) Fetch the width of the sprite in cells from New_Sprite_Width.
9884 LD B,A Store it in B.
9885 CALL AttributeAddress Convert the position into the address in the attribute buffer.
View the equivalent code in;
Continue on to ColourRows.
Prev: 97E1 Up: Map Next: 9888