// dvx_video.c — Layer 1: Video backend for DV/X GUI // // Platform-independent video utilities. The actual VESA/VBE code // now lives in dvxPlatformDos.c (or the platform file for whatever // OS we're targeting). #include "dvxVideo.h" #include "platform/dvxPlatform.h" #include "dvxPalette.h" #include // ============================================================ // packColor // ============================================================ uint32_t packColor(const DisplayT *d, uint8_t r, uint8_t g, uint8_t b) { if (d->format.bitsPerPixel == 8) { return dvxNearestPalEntry(d->palette, r, g, b); } uint32_t rv = ((uint32_t)r >> (8 - d->format.redBits)) << d->format.redShift; uint32_t gv = ((uint32_t)g >> (8 - d->format.greenBits)) << d->format.greenShift; uint32_t bv = ((uint32_t)b >> (8 - d->format.blueBits)) << d->format.blueShift; return rv | gv | bv; } // ============================================================ // resetClipRect // ============================================================ void resetClipRect(DisplayT *d) { d->clipX = 0; d->clipY = 0; d->clipW = d->width; d->clipH = d->height; } // ============================================================ // setClipRect // ============================================================ void setClipRect(DisplayT *d, int32_t x, int32_t y, int32_t w, int32_t h) { int32_t x2 = x + w; int32_t y2 = y + h; if (x < 0) { x = 0; } if (y < 0) { y = 0; } if (x2 > d->width) { x2 = d->width; } if (y2 > d->height) { y2 = d->height; } d->clipX = x; d->clipY = y; d->clipW = (x2 > x) ? x2 - x : 0; d->clipH = (y2 > y) ? y2 - y : 0; } // ============================================================ // videoInit // ============================================================ int32_t videoInit(DisplayT *d, int32_t requestedW, int32_t requestedH, int32_t preferredBpp) { return platformVideoInit(d, requestedW, requestedH, preferredBpp); } // ============================================================ // videoShutdown // ============================================================ void videoShutdown(DisplayT *d) { platformVideoShutdown(d); }