Copies a 2x8-byte sprite to video memory (or screen buffer), assuming that the sprite lines are grey-code ordered and the location to be copied is Pixel Line 0 of a character line.
void cpct_drawTileGrayCode2x8_af (void* pvideomem, void* sprite) __z88dk_callee;
(2B HL) sprite end | Pointer to the end of the sprite array (Sprite in Gray Code format) |
(2B DE) pvideomem | Pointer (aligned) to the first byte in video memory where the sprite will be copied. |
call cpct_drawTileGrayCode2x8_af_asm
BYTE: [0,1,2,3,6,7,4,5,12,13,14,15,10,11,8,9] --- --- --- --- ----- ----- ----- --- LINE: 0 1 3 2 6 7 5 4
This function does the same as cpct_drawTileAligned2x8_f, but using a Gray Code Line Order for the screen lines (0-1-3-2-6-7-5-4), and getting bytes from memory in pairs, using POP instruction.
Copies a 2x8-byte sprite from an array with 16 screen pixel format bytes, and Grey Code Line Order (0-1-3-2-6-7-5-4) to video memory or a screen buffer. This function is tagged aligned, meaning that the destination byte must be character aligned. Being character aligned means that the 8 lines of the sprite will coincide with the 8 lines of a character line in video memory (or in the screen buffer). For more details about video memory character and pixel lines check table 1 at cpct_drawSprite.
As the 8 lines of the sprite must go to a character line on video memory (or screen buffer), memory destination pointer must point to a the first line (Pixel Line 0) of a character line. If hardware scrolling has not been used, all pixel lines 0 are contained inside one of these 4 ranges:
[ 0xC000 -- 0xC7FF ] | RAM Bank 3 (Default Video Memory Bank) |
[ 0x8000 -- 0x87FF ] | RAM Bank 2 |
[ 0x4000 -- 0x47FF ] | RAM Bank 1 |
[ 0x0000 -- 0x07FF ] | RAM Bank 0 |
All of them have 3 bits in common: bits 5, 4 and 3 are always 0 (--000---). Any address not having all these 3 bits set to 0 does not refer to a Pixel Line 0 and is not considered to be aligned.
This function will just copy bytes, not taking care of colours or transparencies. If you wanted to copy a sprite without erasing the background just check for masked sprites and <cpct_drawMaskedSprite>.
HL, DE, F
C-bindings | 61 bytes |
ASM-bindings | 58 bytes |
Case | microSecs (us) | CPU Cycles ------------------------------------------ Any | 103 | 412 ------------------------------------------ Asm saving | -12 | -48 ------------------------------------------