(screen) cache elements of the auto byte
This commit is contained in:
parent
163d48ec34
commit
011662e1dd
|
@ -200,7 +200,7 @@ screen_redraw(Uxn *u)
|
||||||
|
|
||||||
/* cache */
|
/* cache */
|
||||||
|
|
||||||
static Uint16 rX, rY, rA;
|
static Uint16 rX, rY, rA, rMX, rMY, rMA, rML;
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
screen_dei(Uxn *u, Uint8 addr)
|
screen_dei(Uxn *u, Uint8 addr)
|
||||||
|
@ -227,6 +227,7 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
|
||||||
switch(port) {
|
switch(port) {
|
||||||
case 0x3: screen_resize(PEEK2(d + 2), uxn_screen.height); break;
|
case 0x3: screen_resize(PEEK2(d + 2), uxn_screen.height); break;
|
||||||
case 0x5: screen_resize(uxn_screen.width, PEEK2(d + 4)); break;
|
case 0x5: screen_resize(uxn_screen.width, PEEK2(d + 4)); break;
|
||||||
|
case 0x6: rMX = d[0x6] & 0x1, rMY = d[0x6] & 0x2, rMA = d[0x6] & 0x4, rML = d[0x6] >> 4; break;
|
||||||
case 0x8:
|
case 0x8:
|
||||||
case 0x9: rX = (d[0x8] << 8) | d[0x9]; break;
|
case 0x9: rX = (d[0x8] << 8) | d[0x9]; break;
|
||||||
case 0xa:
|
case 0xa:
|
||||||
|
@ -253,43 +254,40 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
|
||||||
}
|
}
|
||||||
/* pixel mode */
|
/* pixel mode */
|
||||||
else {
|
else {
|
||||||
Uint8 move = d[0x6];
|
|
||||||
Uint16 w = uxn_screen.width;
|
Uint16 w = uxn_screen.width;
|
||||||
if(rX < w && rY < uxn_screen.height)
|
if(rX < w && rY < uxn_screen.height)
|
||||||
layer[rX + rY * w] = color;
|
layer[rX + rY * w] = color;
|
||||||
screen_change(rX, rY, rX + 1, rY + 1);
|
screen_change(rX, rY, rX + 1, rY + 1);
|
||||||
if(move & 0x1) rX++;
|
if(rMX) rX++;
|
||||||
if(move & 0x2) rY++;
|
if(rMY) rY++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0xf: {
|
case 0xf: {
|
||||||
Uint8 i;
|
Uint8 i;
|
||||||
Uint8 ctrl = d[0xf];
|
Uint8 ctrl = d[0xf];
|
||||||
Uint8 move = d[0x6];
|
|
||||||
Uint8 length = move >> 4;
|
|
||||||
Uint8 twobpp = !!(ctrl & 0x80);
|
Uint8 twobpp = !!(ctrl & 0x80);
|
||||||
Uint8 color = ctrl & 0xf;
|
Uint8 color = ctrl & 0xf;
|
||||||
Uint8 *layer = ctrl & 0x40 ? uxn_screen.fg : uxn_screen.bg;
|
Uint8 *layer = ctrl & 0x40 ? uxn_screen.fg : uxn_screen.bg;
|
||||||
int fx = ctrl & 0x10 ? -1 : 1;
|
int fx = ctrl & 0x10 ? -1 : 1;
|
||||||
int fy = ctrl & 0x20 ? -1 : 1;
|
int fy = ctrl & 0x20 ? -1 : 1;
|
||||||
dx = (move & 0x1) << 3, dxy = dx * fy;
|
dx = rMX << 3, dxy = dx * fy;
|
||||||
dy = (move & 0x2) << 2, dyx = dy * fx;
|
dy = rMY << 2, dyx = dy * fx;
|
||||||
addr_incr = (move & 0x4) << (1 + twobpp);
|
addr_incr = rMA << (1 + twobpp);
|
||||||
if(twobpp) {
|
if(twobpp) {
|
||||||
for(i = 0; i <= length; i++) {
|
for(i = 0; i <= rML; i++) {
|
||||||
screen_2bpp(layer, &ram[rA], rX + dyx * i, rY + dxy * i, color, fx, fy);
|
screen_2bpp(layer, &ram[rA], rX + dyx * i, rY + dxy * i, color, fx, fy);
|
||||||
rA += addr_incr;
|
rA += addr_incr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(i = 0; i <= length; i++) {
|
for(i = 0; i <= rML; i++) {
|
||||||
screen_1bpp(layer, &ram[rA], rX + dyx * i, rY + dxy * i, color, fx, fy);
|
screen_1bpp(layer, &ram[rA], rX + dyx * i, rY + dxy * i, color, fx, fy);
|
||||||
rA += addr_incr;
|
rA += addr_incr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
screen_change(rX, rY, rX + dyx * length + 8, rY + dxy * length + 8);
|
screen_change(rX, rY, rX + dyx * rML + 8, rY + dxy * rML + 8);
|
||||||
if(move & 0x1) rX += dx * fx;
|
if(rMX) rX += dx * fx;
|
||||||
if(move & 0x2) rY += dy * fy;
|
if(rMY) rY += dy * fy;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue