render: support C_INVERT on fx-CG 50

This commit is contained in:
Lephe 2021-05-11 15:08:42 +02:00
parent 31dcc6fd6c
commit 99403a9504
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
4 changed files with 15 additions and 4 deletions

View File

@ -46,6 +46,7 @@ enum {
C_BLUE = 0x001f,
C_NONE = -1,
C_INVERT = -2,
};
/* RGB color maker. Takes three channels of value 0..31 each (the extra bit of

View File

@ -89,7 +89,7 @@ void dclear(color_t color);
@x1 @y1 Top-left rectangle corner (included)
@x2 @y2 Bottom-right rectangle corner (included)
@color fx-9860G: white light* dark* black none invert lighten* darken*
fx-CG 50: Any R5G6B5 color or C_NONE
fx-CG 50: Any R5G6B5 color, C_NONE or C_INVERT
*: When the gray engine is on, see dgray(). */
void drect(int x1, int y1, int x2, int y2, int color);
@ -122,7 +122,7 @@ void drect_border(int x1, int y1, int x2, int y2,
@x @y Coordinates of the pixel to repaint
@color fx-9860G: white light* dark* black none invert lighten* darken*
fx-CG 50: Any R5G6B5 color or C_NONE
fx-CG 50: Any R5G6B5 color, C_NONE or C_INVERT
*: When the gray engine is on, see dgray(). */
void dpixel(int x, int y, int color);

View File

@ -5,6 +5,8 @@ void dpixel(int x, int y, int color)
{
/* Coordinate checks */
if((uint)x >= 396 || (uint)y >= 224 || color == C_NONE) return;
int index = 396 * y + x;
gint_vram[396 * y + x] = color;
if(color == C_INVERT) gint_vram[index] ^= 0xffff;
else gint_vram[index] = color;
}

View File

@ -31,7 +31,15 @@ void drect(int x1, int y1, int x2, int y2, int color)
uint32_t op = (color << 16) | color;
int width = (ax2 - ax1) >> 1;
for(int h = height; h; h--)
if(color == C_INVERT) for(int h = height; h; h--)
{
base[x1] ^= 0xffff;
base[x2] ^= 0xffff;
for(int w = 0; w < width; w++) v[w] ^= 0xffffffff;
v += 198;
base += 396;
}
else for(int h = height; h; h--)
{
base[x1] = color;
base[x2] = color;