mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-01-06 08:53:36 +01:00
144ff90e37
Optimized cases for gline() rely on grect() instead of reimplementing the mechanics of the fully-optimized drawing to save some space.
59 lines
1 KiB
C
59 lines
1 KiB
C
#include <gint/gray.h>
|
|
#include <gint/defs/types.h>
|
|
|
|
/* gpixel(): Change a pixel's color */
|
|
void gpixel(int x, int y, color_t color)
|
|
{
|
|
if((uint)x >= 128 || (uint)y >= 64) return;
|
|
|
|
uint32_t *light, *dark;
|
|
gvram(&light, &dark);
|
|
|
|
int offset = (y << 2) + (x >> 5);
|
|
uint32_t mask = 1 << (~x & 31), tmp;
|
|
|
|
switch(color)
|
|
{
|
|
case C_WHITE:
|
|
light[offset] &= ~mask;
|
|
dark [offset] &= ~mask;
|
|
break;
|
|
|
|
case C_LIGHT:
|
|
light[offset] |= mask;
|
|
dark [offset] &= ~mask;
|
|
break;
|
|
|
|
case C_DARK:
|
|
light[offset] &= ~mask;
|
|
dark [offset] |= mask;
|
|
break;
|
|
|
|
case C_BLACK:
|
|
light[offset] |= mask;
|
|
dark [offset] |= mask;
|
|
break;
|
|
|
|
case C_NONE:
|
|
break;
|
|
|
|
case C_INVERT:
|
|
light[offset] ^= mask;
|
|
dark [offset] ^= mask;
|
|
break;
|
|
|
|
case C_LIGHTEN:
|
|
tmp = dark[offset];
|
|
|
|
dark[offset] &= light[offset] | ~mask;
|
|
light[offset] = (light[offset] ^ mask) & (tmp | ~mask);
|
|
break;
|
|
|
|
case C_DARKEN:
|
|
tmp = dark[offset];
|
|
|
|
dark[offset] |= light[offset] & mask;
|
|
light[offset] = (light[offset] ^ mask) | (tmp & mask);
|
|
break;
|
|
}
|
|
}
|