| ... | ... |
@@ -82,25 +82,25 @@ screen_resize(UxnScreen *p, Uint16 width, Uint16 height) |
| 82 | 82 |
Uint32 *pixels; |
| 83 | 83 |
if(width < 0x8 || height < 0x8 || width >= 0x400 || height >= 0x400) |
| 84 | 84 |
return; |
| 85 |
- bg = realloc(p->bg.pixels, width * height), |
|
| 86 |
- fg = realloc(p->fg.pixels, width * height); |
|
| 85 |
+ bg = realloc(p->bg, width * height), |
|
| 86 |
+ fg = realloc(p->fg, width * height); |
|
| 87 | 87 |
pixels = realloc(p->pixels, width * height * sizeof(Uint32)); |
| 88 | 88 |
if(!bg || !fg || !pixels) |
| 89 | 89 |
return; |
| 90 |
- p->bg.pixels = bg; |
|
| 91 |
- p->fg.pixels = fg; |
|
| 90 |
+ p->bg = bg; |
|
| 91 |
+ p->fg = fg; |
|
| 92 | 92 |
p->pixels = pixels; |
| 93 | 93 |
p->width = width; |
| 94 | 94 |
p->height = height; |
| 95 |
- screen_fill(p, p->bg.pixels, 0, 0, p->width, p->height, 0); |
|
| 96 |
- screen_fill(p, p->fg.pixels, 0, 0, p->width, p->height, 0); |
|
| 95 |
+ screen_fill(p, p->bg, 0, 0, p->width, p->height, 0); |
|
| 96 |
+ screen_fill(p, p->fg, 0, 0, p->width, p->height, 0); |
|
| 97 | 97 |
} |
| 98 | 98 |
|
| 99 | 99 |
void |
| 100 | 100 |
screen_redraw(UxnScreen *p) |
| 101 | 101 |
{
|
| 102 | 102 |
Uint32 i, x, y, w = p->width, palette[16], *pixels = p->pixels; |
| 103 |
- Uint8 *fg = p->fg.pixels, *bg = p->bg.pixels; |
|
| 103 |
+ Uint8 *fg = p->fg, *bg = p->bg; |
|
| 104 | 104 |
int x1 = p->x1, y1 = p->y1; |
| 105 | 105 |
int x2 = p->x2 > p->width ? p->width : p->x2, y2 = p->y2 > p->height ? p->height : p->y2; |
| 106 | 106 |
for(i = 0; i < 16; i++) |
| ... | ... |
@@ -141,14 +141,14 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port) |
| 141 | 141 |
Uint8 color = ctrl & 0x3; |
| 142 | 142 |
Uint16 x = PEEK2(d + 0x8); |
| 143 | 143 |
Uint16 y = PEEK2(d + 0xa); |
| 144 |
- Layer *layer = (ctrl & 0x40) ? &uxn_screen.fg : &uxn_screen.bg; |
|
| 144 |
+ Uint8 *layer = (ctrl & 0x40) ? uxn_screen.fg : uxn_screen.bg; |
|
| 145 | 145 |
/* fill mode */ |
| 146 | 146 |
if(ctrl & 0x80) {
|
| 147 | 147 |
Uint16 x2 = uxn_screen.width; |
| 148 | 148 |
Uint16 y2 = uxn_screen.height; |
| 149 | 149 |
if(ctrl & 0x10) x2 = x, x = 0; |
| 150 | 150 |
if(ctrl & 0x20) y2 = y, y = 0; |
| 151 |
- screen_fill(&uxn_screen, layer->pixels, x, y, x2, y2, color); |
|
| 151 |
+ screen_fill(&uxn_screen, layer, x, y, x2, y2, color); |
|
| 152 | 152 |
screen_change(&uxn_screen, x, y, x2, y2); |
| 153 | 153 |
} |
| 154 | 154 |
/* pixel mode */ |
| ... | ... |
@@ -156,7 +156,7 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port) |
| 156 | 156 |
Uint16 width = uxn_screen.width; |
| 157 | 157 |
Uint16 height = uxn_screen.height; |
| 158 | 158 |
if(x < width && y < height) |
| 159 |
- layer->pixels[x + y * width] = color; |
|
| 159 |
+ layer[x + y * width] = color; |
|
| 160 | 160 |
screen_change(&uxn_screen, x, y, x + 1, y + 1); |
| 161 | 161 |
if(d[0x6] & 0x1) POKE2(d + 0x8, x + 1); /* auto x+1 */ |
| 162 | 162 |
if(d[0x6] & 0x2) POKE2(d + 0xa, y + 1); /* auto y+1 */ |
| ... | ... |
@@ -174,9 +174,9 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port) |
| 174 | 174 |
Uint16 addr = PEEK2(d + 0xc); |
| 175 | 175 |
Uint16 dx = (move & 0x1) << 3; |
| 176 | 176 |
Uint16 dy = (move & 0x2) << 2; |
| 177 |
- Layer *layer = (ctrl & 0x40) ? &uxn_screen.fg : &uxn_screen.bg; |
|
| 177 |
+ Uint8 *layer = (ctrl & 0x40) ? uxn_screen.fg : uxn_screen.bg; |
|
| 178 | 178 |
for(i = 0; i <= length; i++) {
|
| 179 |
- screen_blit(&uxn_screen, layer->pixels, x + dy * i, y + dx * i, ram, addr, ctrl & 0xf, ctrl & 0x10, ctrl & 0x20, twobpp); |
|
| 179 |
+ screen_blit(&uxn_screen, layer, x + dy * i, y + dx * i, ram, addr, ctrl & 0xf, ctrl & 0x10, ctrl & 0x20, twobpp); |
|
| 180 | 180 |
addr += (move & 0x04) << (1 + twobpp); |
| 181 | 181 |
} |
| 182 | 182 |
screen_change(&uxn_screen, x, y, x + dy * length + 8, y + dx * length + 8); |
| ... | ... |
@@ -10,14 +10,10 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | 10 |
WITH REGARD TO THIS SOFTWARE. |
| 11 | 11 |
*/ |
| 12 | 12 |
|
| 13 |
-typedef struct Layer {
|
|
| 14 |
- Uint8 *pixels; |
|
| 15 |
-} Layer; |
|
| 16 |
- |
|
| 17 | 13 |
typedef struct UxnScreen {
|
| 18 | 14 |
Uint32 palette[4], *pixels; |
| 19 | 15 |
Uint16 width, height, x1, y1, x2, y2; |
| 20 |
- Layer fg, bg; |
|
| 16 |
+ Uint8 *fg, *bg; |
|
| 21 | 17 |
} UxnScreen; |
| 22 | 18 |
|
| 23 | 19 |
extern UxnScreen uxn_screen; |