(Screen) Cache row during sprite drawing

This commit is contained in:
neauoire 2023-11-12 16:45:55 -08:00
parent a4ff15e668
commit 0536b821dc
2 changed files with 5 additions and 5 deletions

View File

@ -68,12 +68,12 @@ screen_2bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16
Uint16 y, ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 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; Uint16 x, xmod = (fx > 0 ? 7 : 0), xmax = x1 + xmod - fx * 8;
for(y = y1 + ymod; y != ymax; y += fy) { for(y = y1 + ymod; y != ymax; y += fy) {
Uint16 c = *ch1++ | (*ch2++ << 8); int row = y * w, c = *ch1++ | (*ch2++ << 8);
if(y < h) if(y < h)
for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) { for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) {
Uint8 ch = (c & 1) | ((c >> 7) & 2); Uint8 ch = (c & 1) | ((c >> 7) & 2);
if((opaque || ch) && x < w) if((opaque || ch) && x < w)
layer[x + y * w] = blending[ch][color]; layer[x + row] = blending[ch][color];
} }
} }
} }
@ -86,12 +86,12 @@ screen_1bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16
Uint16 y, ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 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; Uint16 x, xmod = (fx > 0 ? 7 : 0), xmax = x1 + xmod - fx * 8;
for(y = y1 + ymod; y != ymax; y += fy) { for(y = y1 + ymod; y != ymax; y += fy) {
Uint16 c = *ch1++; int row = y * w, c = *ch1++;
if(y < h) if(y < h)
for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) { for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) {
Uint8 ch = c & 1; Uint8 ch = c & 1;
if((opaque || ch) && x < w) if((opaque || ch) && x < w)
layer[x + y * w] = blending[ch][color]; layer[x + row] = blending[ch][color];
} }
} }
} }

View File

@ -258,7 +258,7 @@ main(int argc, char **argv)
return system_error("usage", "uxn11 [-v] file.rom [args...]"); return system_error("usage", "uxn11 [-v] file.rom [args...]");
/* Read flags */ /* Read flags */
if(argv[i][0] == '-' && argv[i][1] == 'v') if(argv[i][0] == '-' && argv[i][1] == 'v')
return system_version("Uxn11 - Graphical Varvara Emulator", "11 Nov 2023"); return system_version("Uxn11 - Graphical Varvara Emulator", "12 Nov 2023");
if(!emu_init()) if(!emu_init())
return system_error("Init", "Failed to initialize varvara."); return system_error("Init", "Failed to initialize varvara.");
if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++])) if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))