diff --git a/include/gint/display-cg.h b/include/gint/display-cg.h index 6b5fbf2..4130ddb 100644 --- a/include/gint/display-cg.h +++ b/include/gint/display-cg.h @@ -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 diff --git a/include/gint/display.h b/include/gint/display.h index 8c224ca..8b21e3e 100644 --- a/include/gint/display.h +++ b/include/gint/display.h @@ -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); diff --git a/src/render-cg/dpixel.c b/src/render-cg/dpixel.c index 34b40de..ca34af8 100644 --- a/src/render-cg/dpixel.c +++ b/src/render-cg/dpixel.c @@ -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; } diff --git a/src/render-cg/drect.c b/src/render-cg/drect.c index 7556082..248fe5c 100644 --- a/src/render-cg/drect.c +++ b/src/render-cg/drect.c @@ -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;