...
|
...
|
@@ -25,27 +25,27 @@ static Uint8 blending[4][16] = {
|
25
|
25
|
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}};
|
26
|
26
|
|
27
|
27
|
static void
|
28
|
|
-screen_fill(UxnScreen *p, Layer *layer, Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, Uint8 color)
|
|
28
|
+screen_fill(UxnScreen *s, Uint8 *pixels, Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, Uint8 color)
|
29
|
29
|
{
|
30
|
|
- int x, y;
|
31
|
|
- for(y = y1; y < y2 && y < p->height; y++)
|
32
|
|
- for(x = x1; x < x2 && x < p->width; x++)
|
33
|
|
- layer->pixels[x + y * p->width] = color;
|
|
30
|
+ int x, y, width = s->width, height = s->height;
|
|
31
|
+ for(y = y1; y < y2 && y < height; y++)
|
|
32
|
+ for(x = x1; x < x2 && x < width; x++)
|
|
33
|
+ pixels[x + y * width] = color;
|
34
|
34
|
}
|
35
|
35
|
|
36
|
36
|
static void
|
37
|
|
-screen_blit(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy, Uint8 twobpp)
|
|
37
|
+screen_blit(UxnScreen *p, Uint8 *pixels, Uint16 x1, Uint16 y1, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy, Uint8 twobpp)
|
38
|
38
|
{
|
39
|
|
- int v, h, opaque = (color % 5) || !color;
|
|
39
|
+ int v, h, width = p->width, height = p->height, opaque = (color % 5) || !color;
|
40
|
40
|
for(v = 0; v < 8; v++) {
|
41
|
41
|
Uint16 c = sprite[v] | (twobpp ? (sprite[v + 8] << 8) : 0);
|
|
42
|
+ Uint16 y = y1 + (flipy ? 7 - v : v);
|
42
|
43
|
for(h = 7; h >= 0; --h, c >>= 1) {
|
43
|
44
|
Uint8 ch = (c & 1) | ((c >> 7) & 2);
|
44
|
45
|
if(opaque || ch) {
|
45
|
|
- Uint16 xx = x + (flipx ? 7 - h : h);
|
46
|
|
- Uint16 yy = y + (flipy ? 7 - v : v);
|
47
|
|
- if(xx < p->width && yy < p->height)
|
48
|
|
- layer->pixels[xx + yy * p->width] = blending[ch][color];
|
|
46
|
+ Uint16 x = x1 + (flipx ? 7 - h : h);
|
|
47
|
+ if(x < width && y < height)
|
|
48
|
+ pixels[x + y * width] = blending[ch][color];
|
49
|
49
|
}
|
50
|
50
|
}
|
51
|
51
|
}
|
...
|
...
|
@@ -83,18 +83,19 @@ screen_resize(UxnScreen *p, Uint16 width, Uint16 height)
|
83
|
83
|
p->pixels = pixels;
|
84
|
84
|
p->width = width;
|
85
|
85
|
p->height = height;
|
86
|
|
- screen_fill(p, &p->bg, 0, 0, p->width, p->height, 0);
|
87
|
|
- screen_fill(p, &p->fg, 0, 0, p->width, p->height, 0);
|
|
86
|
+ screen_fill(p, p->bg.pixels, 0, 0, p->width, p->height, 0);
|
|
87
|
+ screen_fill(p, p->fg.pixels, 0, 0, p->width, p->height, 0);
|
88
|
88
|
}
|
89
|
89
|
|
90
|
90
|
void
|
91
|
91
|
screen_redraw(UxnScreen *p)
|
92
|
92
|
{
|
93
|
|
- Uint32 i, size = p->width * p->height, palette[16];
|
|
93
|
+ Uint32 i, size = p->width * p->height, palette[16], *pixels = p->pixels;
|
|
94
|
+ Uint8 *fg = p->fg.pixels, *bg = p->bg.pixels;
|
94
|
95
|
for(i = 0; i < 16; i++)
|
95
|
96
|
palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)];
|
96
|
97
|
for(i = 0; i < size; i++)
|
97
|
|
- p->pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]];
|
|
98
|
+ pixels[i] = palette[fg[i] << 2 | bg[i]];
|
98
|
99
|
p->fg.changed = p->bg.changed = 0;
|
99
|
100
|
}
|
100
|
101
|
|
...
|
...
|
@@ -132,7 +133,7 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
|
132
|
133
|
Uint16 y2 = uxn_screen.height;
|
133
|
134
|
if(ctrl & 0x10) x2 = x, x = 0;
|
134
|
135
|
if(ctrl & 0x20) y2 = y, y = 0;
|
135
|
|
- screen_fill(&uxn_screen, layer, x, y, x2, y2, color);
|
|
136
|
+ screen_fill(&uxn_screen, layer->pixels, x, y, x2, y2, color);
|
136
|
137
|
layer->changed = 1;
|
137
|
138
|
}
|
138
|
139
|
/* pixel mode */
|
...
|
...
|
@@ -164,9 +165,9 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
|
164
|
165
|
for(i = 0; i <= length; i++) {
|
165
|
166
|
if(!(ctrl & 0xf)) {
|
166
|
167
|
Uint16 ex = x + dy * i, ey = y + dx * i;
|
167
|
|
- screen_fill(&uxn_screen, layer, ex, ey, ex + 8, ey + 8, 0);
|
|
168
|
+ screen_fill(&uxn_screen, layer->pixels, ex, ey, ex + 8, ey + 8, 0);
|
168
|
169
|
} else {
|
169
|
|
- screen_blit(&uxn_screen, layer, x + dy * i, y + dx * i, &ram[addr], ctrl & 0xf, ctrl & 0x10, ctrl & 0x20, twobpp);
|
|
170
|
+ screen_blit(&uxn_screen, layer->pixels, x + dy * i, y + dx * i, &ram[addr], ctrl & 0xf, ctrl & 0x10, ctrl & 0x20, twobpp);
|
170
|
171
|
addr += (move & 0x04) << (1 + twobpp);
|
171
|
172
|
}
|
172
|
173
|
}
|