// Drawing primitives. // // All primitives clip to the surface rectangle. Out-of-bounds draws are // silent no-ops, not errors. samplePixel returns 0 for off-surface reads. // Primitives operate on color indices; per-scanline palette resolution // happens only at display time. #ifndef JOEYLIB_DRAW_H #define JOEYLIB_DRAW_H #include "asset.h" #include "platform.h" #include "surface.h" #include "types.h" // Fill the entire surface with a single color index. Writes color 0 is // a legitimate clear-to-black and does not skip. void surfaceClear(SurfaceT *s, uint8_t colorIndex); // Plot a single pixel. Off-surface coordinates are no-ops. void drawPixel(SurfaceT *s, int16_t x, int16_t y, uint8_t colorIndex); // Read a pixel value. Off-surface coordinates return 0. uint8_t samplePixel(const SurfaceT *s, int16_t x, int16_t y); // Fill a solid rectangle. Negative or zero dimensions are no-ops. void fillRect(SurfaceT *s, int16_t x, int16_t y, uint16_t w, uint16_t h, uint8_t colorIndex); // Blit an asset onto the surface at (x, y). Source nibbles overwrite // destination nibbles verbatim -- the caller is responsible for // matching the asset's palette to the destination palette (typically // via joeyAssetApplyPalette). Clipped to the surface; off-surface // rows / columns are skipped. void surfaceBlit(SurfaceT *dst, const JoeyAssetT *src, int16_t x, int16_t y); // Like surfaceBlit, but source pixels equal to transparentIndex are // skipped, leaving the destination pixel unchanged at that position. // The standard convention is transparentIndex = 0. void surfaceBlitMasked(SurfaceT *dst, const JoeyAssetT *src, int16_t x, int16_t y, uint8_t transparentIndex); #endif