![]() |
Routines |
| Prev: 7038 | Up: Map | Next: 7097 |
|
Used by the routine at HandlerCar.
Sets the attributes under a sprite to the attribute of the actor. The sprite is coloured from the bottom upwards and the attributes of the top row of the screen and of the border (76) are left alone. Entering at ColouriseSprite_Position (D is the attribute and HL is the position of the bottom left of the sprite in pixels) or at ColouriseSprite_Block (B is the width and C is the height in attribute cells, D is the attribute and HL is the attribute buffer address of the bottom left) uses the normal registers instead of the shadow registers.
|
||||||||
| ColouriseSprite | 704B | EXX | Switch to the shadow registers. | |||||
| 704C | LD HL,($5E27) | Fetch the position of the sprite (ActorScreenPosition). | ||||||
| 704F | LD D,(IX+$03) | D'=the attribute of the actor. | ||||||
|
This entry point is used by the routine at PlaceObject.
Work out the size of the sprite in attribute cells.
|
||||||||
| ColouriseSprite_Position | 7052 | CALL AttributeAddress | Call AttributeAddress to convert the pixel co-ordinates into an attribute buffer address. | |||||
| 7055 | LD A,($5E24) | A=WidthBytes (the width of the sprite in bytes). | ||||||
| 7058 | LD B,A | Keep the width in B. | ||||||
| 7059 | LD A,($5E23) | A=HeightPixels (the height of the sprite in pixels). | ||||||
| 705C | RRCA | A=A / 04. | ||||||
| 705D | RRCA | |||||||
| 705E | INC A | Increment A by one. | ||||||
| 705F | RRCA | A=A / 02. | ||||||
| 7060 | AND %00011111 | Keep only bits 0-4. | ||||||
| 7062 | INC A | Increment A by one. | ||||||
| 7063 | LD C,A | C=A (the number of rows). | ||||||
|
This entry point is used by the routine at HandlerPlayer.
Colour each of the rows, going upwards.
|
||||||||
| ColouriseSprite_Block | 7064 | LD E,B | Keep the width in E. | |||||
| ColouriseSprite_Loop1 | 7065 | PUSH HL | Stash the address of the start of the row on the stack. | |||||
| ColouriseSprite_Loop2 | 7066 | LD A,H | A=H. | |||||
| 7067 | CP $5B | Jump to ColouriseSprite_NextRow if the address is beyond the end of the attribute buffer. | ||||||
| 7069 | JR NC,ColouriseSprite_NextRow | |||||||
| 706B | PUSH HL | Stash HL and BC on the stack. | ||||||
| 706C | PUSH BC | |||||||
| 706D | LD BC,$5820 | BC=5820 (the start of the second row of attributes). | ||||||
| 7070 | AND A | HL=HL - BC. | ||||||
| 7071 | SBC HL,BC | |||||||
| 7073 | POP BC | Restore BC and HL from the stack. | ||||||
| 7074 | POP HL | |||||||
| 7075 | JR C,ColouriseSprite_NextRow | Jump to ColouriseSprite_NextRow if the address is in the top row of attributes. | ||||||
| 7077 | LD A,(HL) | Fetch the current attribute of the cell. | ||||||
| 7078 | CP $76 | Jump to ColouriseSprite_NextColumn if this is a border attribute (76). | ||||||
| 707A | JR Z,ColouriseSprite_NextColumn | |||||||
| 707C | LD (HL),D | Write the attribute of the actor. | ||||||
| ColouriseSprite_NextColumn | 707D | INC L | Move onto the next column. | |||||
| 707E | LD A,L | A=L. | ||||||
| 707F | AND %00011111 | Keep only bits 0-4. | ||||||
| 7081 | JR NZ,ColouriseSprite_Next | Jump to ColouriseSprite_Next if the address is still in the same row. | ||||||
| 7083 | LD A,L | Move back to the start of the row (this is for when the actor is partly off the right of the screen). | ||||||
| 7084 | SUB $20 | |||||||
| 7086 | LD L,A | |||||||
| ColouriseSprite_Next | 7087 | DJNZ ColouriseSprite_Loop2 | Decrease the column counter by one and loop back to ColouriseSprite_Loop2 until the whole row has been coloured. | |||||
| ColouriseSprite_NextRow | 7089 | POP HL | Restore the address of the start of the row from the stack. | |||||
| 708A | PUSH BC | Stash BC on the stack. | ||||||
| 708B | AND A | Clear the carry flag. | ||||||
| 708C | LD BC,$0020 | Set the size of a row, 0020. | ||||||
| 708F | SBC HL,BC | Move up a row. | ||||||
| 7091 | POP BC | Restore BC from the stack. | ||||||
| 7092 | LD B,E | Reset the width counter. | ||||||
| 7093 | DEC C | Decrease the row counter by one. | ||||||
| 7094 | JR NZ,ColouriseSprite_Loop1 | Loop back to ColouriseSprite_Loop1 until all of the rows have been coloured. | ||||||
| 7096 | RET | Return. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: 7038 | Up: Map | Next: 7097 |