Transforms 2 pixel colour values [0-15] into a byte value in the video memory pixel format for Mode 0.
u8 cpct_px2byteM0 (u8 px0, u8 px1);
(1B H) px0 | Firmware colour value for left pixel (pixel 0) [0-15] |
(1B L) px1 | Firmware colour value for right pixel (pixel 1) [0-15] |
u8 | byte with px0 and px1 colour information in screen pixel format. |
call cpct_px2byteM0_asm
Converts 2 firmware colour values for 2 consecutive pixels into a byte value in the video memory pixel format for Mode 0. This video memory pixel format is the way pixel colour values are encoded in video memory. Concretely, in Mode 0, each byte contains 2 consecutive pixels formatted as follows:
______________________________________________________________________ <---- 1 byte ----> Screen => [...[pixelX ][ pixelY ]...] (2 pixels, consecutive) ====================================================================== Video Memory => [...[ X Y X Y X Y X Y ]...] (1 byte, 8 bits) Pixel X (3210) => [...[ 0 · 2 · 1 · 3 · ]...] (4 bits) Pixel Y (dcba) => [...[ · a · c · b · d ]...] (4 bits) ---------------------------------------------------------------------- Scheme 1. Screen pixel format and video memory
This function uses a 16-byte conversion table to get screen formatted values for each one of the two pixels given. These formatted values are then OR’ed to get the final byte that you may use to draw on screen.
AF, BC, DE, HL
C-bindings | 47 bytes (31 bytes code, 16 bytes colour conversion table) |
ASM-bindings | 42 bytes (26 bytes code, 16 bytes colour conversion table) |
Note | Colour conversion table is shared with cpct_drawCharM0. If you use both functions, only one copy of the colour table is loaded into memory. |
Case | microSecs (us) | CPU Cycles ------------------------------------------ Any | 40 | 160 ------------------------------------------ ASM-saving | -11 | -44 ------------------------------------------
NC=Number of colours to convert