(Screen) Cached row only written when visible
This commit is contained in:
parent
0536b821dc
commit
ee7a69c8b4
|
@ -49,28 +49,28 @@ screen_fill(Uint8 *layer, int color)
|
|||
void
|
||||
screen_rect(Uint8 *layer, Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, int color)
|
||||
{
|
||||
int x, y, w, h;
|
||||
int row, x, y, w, h;
|
||||
if(!x1 && !y1) {
|
||||
screen_fill(layer, color);
|
||||
return;
|
||||
}
|
||||
w = uxn_screen.width, h = uxn_screen.height;
|
||||
for(y = y1; y < y2 && y < h; y++)
|
||||
for(x = x1; x < x2 && x < w; x++)
|
||||
layer[x + y * w] = color;
|
||||
for(x = x1, row = y * w; x < x2 && x < w; x++)
|
||||
layer[x + row] = color;
|
||||
}
|
||||
|
||||
static void
|
||||
screen_2bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16 color, int fx, int fy)
|
||||
{
|
||||
int w = uxn_screen.width, h = uxn_screen.height, opaque = (color % 5);
|
||||
int row, w = uxn_screen.width, h = uxn_screen.height, opaque = (color % 5);
|
||||
Uint8 *ch1 = &ram[addr], *ch2 = ch1 + 8;
|
||||
Uint16 y, ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 8;
|
||||
Uint16 x, xmod = (fx > 0 ? 7 : 0), xmax = x1 + xmod - fx * 8;
|
||||
for(y = y1 + ymod; y != ymax; y += fy) {
|
||||
int row = y * w, c = *ch1++ | (*ch2++ << 8);
|
||||
int c = *ch1++ | (*ch2++ << 8);
|
||||
if(y < h)
|
||||
for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) {
|
||||
for(x = x1 + xmod, row = y * w; x != xmax; x -= fx, c >>= 1) {
|
||||
Uint8 ch = (c & 1) | ((c >> 7) & 2);
|
||||
if((opaque || ch) && x < w)
|
||||
layer[x + row] = blending[ch][color];
|
||||
|
@ -81,14 +81,14 @@ screen_2bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16
|
|||
static void
|
||||
screen_1bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16 color, int fx, int fy)
|
||||
{
|
||||
int w = uxn_screen.width, h = uxn_screen.height, opaque = (color % 5);
|
||||
int row, w = uxn_screen.width, h = uxn_screen.height, opaque = (color % 5);
|
||||
Uint8 *ch1 = &ram[addr];
|
||||
Uint16 y, ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 8;
|
||||
Uint16 x, xmod = (fx > 0 ? 7 : 0), xmax = x1 + xmod - fx * 8;
|
||||
for(y = y1 + ymod; y != ymax; y += fy) {
|
||||
int row = y * w, c = *ch1++;
|
||||
int c = *ch1++;
|
||||
if(y < h)
|
||||
for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) {
|
||||
for(x = x1 + xmod, row = y * w; x != xmax; x -= fx, c >>= 1) {
|
||||
Uint8 ch = c & 1;
|
||||
if((opaque || ch) && x < w)
|
||||
layer[x + row] = blending[ch][color];
|
||||
|
|
Loading…
Reference in New Issue