![]() |
Routines |
| Prev: 45696 | Up: Map | Next: 45801 |
|
Used by the routine at DrawWideSprites.
Draws a sprite which is eight rows high and four bytes wide into a buffer which has twenty four bytes in each row. The pixels are combined with what is already in the buffer. The horizontal pixel position is in SpriteHorizontalPosition: if it is not a multiple of eight, the sprite data is a list of indexes into the tables which shift a byte by two, four or six pixels, and the sprite takes five bytes in each row of the buffer. The routine takes the data from the stack to make it faster.
|
||||||||||
|
Find the data of the sprite.
|
||||||||||
| DrawWideSprite | 45708 | EX DE,HL | Swap the address in the buffer into DE. | |||||||
| 45709 | LD BC,27334 | Point BC at PosterImagePointers. | ||||||||
| 45712 | CALL GetTableEntry | Point HL at the data of the sprite. | ||||||||
| 45715 | LD (41501),SP | Save the stack pointer. | ||||||||
| 45719 | LD SP,HL | Point the stack pointer at the data. | ||||||||
| 45720 | EX DE,HL | Swap the address in the buffer back into HL. | ||||||||
| 45721 | LD A,(41504) | Fetch the horizontal pixel position. | ||||||||
| 45724 | AND %00000110 | Keep the offset within the byte. | ||||||||
| 45726 | JR Z,DrawWideSprite_Aligned | Jump to DrawWideSprite_Aligned if the sprite is on a byte boundary. | ||||||||
|
The sprite is not on a byte boundary, so shift it using the shift tables.
|
||||||||||
| 45728 | OR %11111000 | Make the offset the high byte of the address of a shift table. | ||||||||
| 45730 | LD D,A | Point D at the shift table. | ||||||||
| 45731 | LD A,8 | Set the number of rows to eight. | ||||||||
| DrawWideSprite_ShiftedRow | 45733 | EX AF,AF' | Keep the number of rows in the alternate accumulator. | |||||||
| 45734 | POP BC | Fetch the indexes for the first two bytes of a row. | ||||||||
| 45735 | LD E,C | Copy the first index into E. | ||||||||
| 45736 | LD A,(DE) | Fetch the shifted first byte. | ||||||||
| 45737 | OR (HL) | Combine it with the buffer. | ||||||||
| 45738 | LD (HL),A | Write it to the buffer. | ||||||||
| 45739 | INC HL | Move on to the second byte. | ||||||||
| 45740 | INC D | Point D at the overflow table. | ||||||||
| 45741 | LD A,(DE) | Fetch the overflow of the first byte. | ||||||||
| 45742 | DEC D | Point D back at the shift table. | ||||||||
| 45743 | LD E,B | Copy the second index into E. | ||||||||
| 45744 | EX DE,HL | Swap the buffer address into DE. | ||||||||
| 45745 | OR (HL) | Combine the overflow with the shifted second byte. | ||||||||
| 45746 | LD (DE),A | Write it to the buffer. | ||||||||
| 45747 | INC DE | Move on to the third byte. | ||||||||
| 45748 | INC H | Point H at the overflow table. | ||||||||
| 45749 | LD A,(HL) | Fetch the overflow of the second byte. | ||||||||
| 45750 | DEC H | Point H back at the shift table. | ||||||||
| 45751 | POP BC | Fetch the indexes for the next two bytes of the row. | ||||||||
| 45752 | LD L,C | Copy the third index into L. | ||||||||
| 45753 | OR (HL) | Combine the third byte with the buffer. | ||||||||
| 45754 | LD (DE),A | Write it to the buffer. | ||||||||
| 45755 | INC DE | Move on to the fourth byte. | ||||||||
| 45756 | INC H | Point H at the overflow table. | ||||||||
| 45757 | LD A,(HL) | Fetch the overflow of the third byte. | ||||||||
| 45758 | DEC H | Point H back at the shift table. | ||||||||
| 45759 | LD L,B | Copy the fourth index into L. | ||||||||
| 45760 | OR (HL) | Combine it with the shifted fourth byte. | ||||||||
| 45761 | LD (DE),A | Write it to the buffer. | ||||||||
| 45762 | INC DE | Move on to the fifth byte. | ||||||||
| 45763 | INC H | Point H at the overflow table. | ||||||||
| 45764 | EX DE,HL | Swap the buffer address into HL. | ||||||||
| 45765 | LD A,(DE) | Fetch the overflow of the fourth byte. | ||||||||
| 45766 | OR (HL) | Combine it with the buffer. | ||||||||
| 45767 | LD (HL),A | Write it to the buffer. | ||||||||
| 45768 | DEC D | Point D back at the shift table. | ||||||||
| 45769 | LD BC,20 | Set the distance to the next row of the buffer. | ||||||||
| 45772 | ADD HL,BC | Move on to the next row. | ||||||||
| 45773 | EX AF,AF' | Fetch the number of rows. | ||||||||
| 45774 | DEC A | Count down the rows. | ||||||||
| 45775 | JR NZ,DrawWideSprite_ShiftedRow | Loop back until all eight rows have been drawn. | ||||||||
| DrawWideSprite_Done | 45777 | LD SP,(41501) | Restore the stack pointer. | |||||||
| 45781 | RET | Return. | ||||||||
|
The sprite is on a byte boundary, so copy the bytes straight to the buffer.
|
||||||||||
| DrawWideSprite_Aligned | 45782 | LD B,8 | Set the number of rows to eight. | |||||||
| DrawWideSprite_AlignedRow | 45784 | POP DE | Fetch two bytes of the row. | |||||||
| 45785 | LD (HL),E | Write the first to the buffer. | ||||||||
| 45786 | INC HL | Move on to the second byte. | ||||||||
| 45787 | LD (HL),D | Write the second to the buffer. | ||||||||
| 45788 | INC HL | Move on to the third byte. | ||||||||
| 45789 | POP DE | Fetch two more bytes of the row. | ||||||||
| 45790 | LD (HL),E | Write the third to the buffer. | ||||||||
| 45791 | INC HL | Move on to the fourth byte. | ||||||||
| 45792 | LD (HL),D | Write the fourth to the buffer. | ||||||||
| 45793 | LD DE,21 | Set the distance to the next row of the buffer. | ||||||||
| 45796 | ADD HL,DE | Move on to the next row. | ||||||||
| 45797 | DJNZ DrawWideSprite_AlignedRow | Loop back until all eight rows have been drawn. | ||||||||
| 45799 | JR DrawWideSprite_Done | Jump to DrawWideSprite_Done. | ||||||||
| Prev: 45696 | Up: Map | Next: 45801 |