Prev: 38881 Up: Map Next: 39048
39015: 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 39015 LD L,(IX+1) Fetch the x position of the object into L.
39018 LD H,(IX+3) Fetch the y position of the object into H.
39021 LD D,(IX+5) Fetch the attribute of the object into D.
39024 LD A,H Copy the y position to A and flip the bits.
39025 CPL
39026 AND %00000111 Keep only the pixel line within the character cell.
39028 LD B,A Store it in B.
39029 LD A,(36583) Fetch the height of the sprite from New_Sprite_Height.
39032 ADD A,8 Add 8.
39034 ADD A,B Add the pixel line.
39035 RRCA Divide by eight.
39036 RRCA
39037 RRCA
39038 AND %00011111 Keep only the low five bits.
39040 LD C,A Store the number of rows of cells in C.
39041 LD A,(36582) Fetch the width of the sprite in cells from New_Sprite_Width.
39044 LD B,A Store it in B.
39045 CALL AttributeAddress Convert the position into the address in the attribute buffer.
View the equivalent code in;
Continue on to ColourRows.
Prev: 38881 Up: Map Next: 39048