![]() |
Routines |
| Prev: ABF5 | Up: Map | Next: AC6B |
|
Used by the routines at HandleEndingRobotTop, HandleEndingRobotBottom, HandleAttackingTool and HandleAlarm.
Colours the attribute cells covered by an object, using the colour in the object record. Cells which already have the colour 44 are left alone.
|
||||||||
|
Work out the cells covered by the sprite.
|
||||||||
| ColourCells | AC21 | LD A,(IX+$18) | Return if the sprite has no width and no height. | |||||
| AC24 | OR (IX+$19) | |||||||
| AC27 | RET Z | |||||||
| AC28 | LD L,(IX+$1A) | Fetch the pixel x position. | ||||||
| AC2B | LD B,(IX+$18) | Fetch the width in cells. | ||||||
| AC2E | LD A,L | Copy the pixel x position to A. | ||||||
| AC2F | AND %00000111 | Keep bits 0 to 2. | ||||||
| AC31 | JR Z,ColourCells_FindRows | Jump to ColourCells_FindRows if the sprite starts on a cell edge. | ||||||
| AC33 | INC B | Increment the width. | ||||||
| ColourCells_FindRows | AC34 | LD H,(IX+$1B) | Fetch the pixel y position. | |||||
| AC37 | LD A,H | Divide the pixel y position by eight. | ||||||
| AC38 | RRCA | |||||||
| AC39 | RRCA | |||||||
| AC3A | RRCA | |||||||
| AC3B | AND %00011111 | Keep bits 0 to 4. | ||||||
| AC3D | LD C,A | Keep the first row in C. | ||||||
| AC3E | LD A,(IX+$19) | Find the pixel y of the other end. | ||||||
| AC41 | DEC A | |||||||
| AC42 | ADD A,H | |||||||
| AC43 | RRCA | Divide it by eight. | ||||||
| AC44 | RRCA | |||||||
| AC45 | RRCA | |||||||
| AC46 | AND %00011111 | Keep bits 0 to 4. | ||||||
| AC48 | SUB C | Work out the number of rows. | ||||||
| AC49 | INC A | |||||||
| AC4A | LD C,A | |||||||
| AC4B | CALL CalculateAttributeAddress | Call CalculateAttributeAddress. | ||||||
| AC4E | EX DE,HL | Copy the address to HL. | ||||||
| AC4F | LD A,(IX+$10) | Fetch the colour of the object. | ||||||
| AC52 | LD DE,$0020 | Set DE to 0020. | ||||||
|
Colour each row of cells.
|
||||||||
| ColourCells_ColourRow | AC55 | PUSH BC | Stash the counters and the address on the stack. | |||||
| AC56 | PUSH HL | |||||||
| AC57 | LD C,A | Keep the colour in C. | ||||||
| ColourCells_ColourCell | AC58 | LD A,(HL) | Jump to ColourCells_NextCell if the cell is already 44. | |||||
| AC59 | CP $44 | |||||||
| AC5B | JR Z,ColourCells_NextCell | |||||||
| AC5D | LD (HL),C | Colour the cell. | ||||||
| ColourCells_NextCell | AC5E | INC L | Move on to the next cell in the row. | |||||
| AC5F | DJNZ ColourCells_ColourCell | Jump to ColourCells_ColourCell until the row is done. | ||||||
| AC61 | LD A,C | Put the colour back in A. | ||||||
| AC62 | POP HL | Restore the address and the counters from the stack. | ||||||
| AC63 | POP BC | |||||||
| AC64 | AND A | Move to the next row, which is above this one. | ||||||
| AC65 | SBC HL,DE | |||||||
| AC67 | DEC C | Jump to ColourCells_ColourRow until all of the rows are done. | ||||||
| AC68 | JR NZ,ColourCells_ColourRow | |||||||
| AC6A | RET | Return. | ||||||
| Prev: ABF5 | Up: Map | Next: AC6B |