Prev: 44021 Up: Map Next: 44139
44065: Colour Cells
Colours the attribute cells covered by an object, using the colour in the object record. Cells which already have the colour 68 are left alone.
Input
IX The address of the object
Work out the cells covered by the sprite.
ColourCells 44065 LD A,(IX+24) Return if the sprite has no width and no height.
44068 OR (IX+25)
44071 RET Z
44072 LD L,(IX+26) Fetch the pixel x position.
44075 LD B,(IX+24) Fetch the width in cells.
44078 LD A,L Copy the pixel x position to A.
44079 AND %00000111 Keep bits 0 to 2.
44081 JR Z,ColourCells_FindRows Jump to ColourCells_FindRows if the sprite starts on a cell edge.
44083 INC B Increment the width.
ColourCells_FindRows 44084 LD H,(IX+27) Fetch the pixel y position.
44087 LD A,H Divide the pixel y position by eight.
44088 RRCA
44089 RRCA
44090 RRCA
44091 AND %00011111 Keep bits 0 to 4.
44093 LD C,A Keep the first row in C.
44094 LD A,(IX+25) Find the pixel y of the other end.
44097 DEC A
44098 ADD A,H
44099 RRCA Divide it by eight.
44100 RRCA
44101 RRCA
44102 AND %00011111 Keep bits 0 to 4.
44104 SUB C Work out the number of rows.
44105 INC A
44106 LD C,A
44107 CALL CalculateAttributeAddress Call CalculateAttributeAddress.
44110 EX DE,HL Copy the address to HL.
44111 LD A,(IX+16) Fetch the colour of the object.
44114 LD DE,32 Set DE to 0032.
Colour each row of cells.
ColourCells_ColourRow 44117 PUSH BC Stash the counters and the address on the stack.
44118 PUSH HL
44119 LD C,A Keep the colour in C.
ColourCells_ColourCell 44120 LD A,(HL) Jump to ColourCells_NextCell if the cell is already 68.
44121 CP 68
44123 JR Z,ColourCells_NextCell
44125 LD (HL),C Colour the cell.
ColourCells_NextCell 44126 INC L Move on to the next cell in the row.
44127 DJNZ ColourCells_ColourCell Jump to ColourCells_ColourCell until the row is done.
44129 LD A,C Put the colour back in A.
44130 POP HL Restore the address and the counters from the stack.
44131 POP BC
44132 AND A Move to the next row, which is above this one.
44133 SBC HL,DE
44135 DEC C Jump to ColourCells_ColourRow until all of the rows are done.
44136 JR NZ,ColourCells_ColourRow
44138 RET Return.
Prev: 44021 Up: Map Next: 44139