| ... | ... |
@@ -38,6 +38,14 @@ screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2) |
| 38 | 38 |
if(y2 > uxn_screen.y2) uxn_screen.y2 = y2; |
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 |
+void |
|
| 42 |
+screen_fill(Uint8 *layer, int color) |
|
| 43 |
+{
|
|
| 44 |
+ int i, length = uxn_screen.width * uxn_screen.height; |
|
| 45 |
+ for(i = 0; i < length; i++) |
|
| 46 |
+ layer[i] = color; |
|
| 47 |
+} |
|
| 48 |
+ |
|
| 41 | 49 |
void |
| 42 | 50 |
screen_rect(Uint8 *layer, int x1, int y1, int x2, int y2, int color) |
| 43 | 51 |
{
|
| ... | ... |
@@ -137,24 +145,18 @@ screen_resize(Uint16 width, Uint16 height) |
| 137 | 145 |
return; |
| 138 | 146 |
if(uxn_screen.width == width && uxn_screen.height == height) |
| 139 | 147 |
return; |
| 140 |
- bg = malloc(width * height), |
|
| 141 |
- fg = malloc(width * height); |
|
| 148 |
+ bg = malloc(width * height), fg = malloc(width * height); |
|
| 142 | 149 |
if(bg && fg) |
| 143 | 150 |
pixels = realloc(uxn_screen.pixels, width * height * sizeof(Uint32)); |
| 144 | 151 |
if(!bg || !fg || !pixels) {
|
| 145 |
- free(bg); |
|
| 146 |
- free(fg); |
|
| 152 |
+ free(bg), free(fg); |
|
| 147 | 153 |
return; |
| 148 | 154 |
} |
| 149 |
- free(uxn_screen.bg); |
|
| 150 |
- free(uxn_screen.fg); |
|
| 151 |
- uxn_screen.bg = bg; |
|
| 152 |
- uxn_screen.fg = fg; |
|
| 155 |
+ free(uxn_screen.bg), free(uxn_screen.fg); |
|
| 156 |
+ uxn_screen.bg = bg, uxn_screen.fg = fg; |
|
| 153 | 157 |
uxn_screen.pixels = pixels; |
| 154 |
- uxn_screen.width = width; |
|
| 155 |
- uxn_screen.height = height; |
|
| 156 |
- screen_rect(uxn_screen.bg, 0, 0, width, height, 0); |
|
| 157 |
- screen_rect(uxn_screen.fg, 0, 0, width, height, 0); |
|
| 158 |
+ uxn_screen.width = width, uxn_screen.height = height; |
|
| 159 |
+ screen_fill(uxn_screen.bg, 0), screen_fill(uxn_screen.fg, 0); |
|
| 158 | 160 |
emu_resize(width, height); |
| 159 | 161 |
screen_change(0, 0, width, height); |
| 160 | 162 |
} |
| ... | ... |
@@ -194,13 +196,13 @@ screen_dei(Uxn *u, Uint8 addr) |
| 194 | 196 |
void |
| 195 | 197 |
screen_deo(Uint8 *ram, Uint8 *d, Uint8 port) |
| 196 | 198 |
{
|
| 197 |
- Uint8 *port_width, *port_height, *port_x, *port_y, *port_addr; |
|
| 199 |
+ Uint8 *port_height, *port_x, *port_y, *port_addr; |
|
| 198 | 200 |
Uint16 x, y, dx, dy, dxy, dyx, addr, addr_incr; |
| 199 | 201 |
switch(port) {
|
| 200 |
- case 0x3: |
|
| 201 |
- port_width = d + 0x2; |
|
| 202 |
+ case 0x3: {
|
|
| 203 |
+ Uint8 *port_width = d + 0x2; |
|
| 202 | 204 |
screen_resize(PEEK2(port_width), uxn_screen.height); |
| 203 |
- break; |
|
| 205 |
+ } break; |
|
| 204 | 206 |
case 0x5: |
| 205 | 207 |
port_height = d + 0x4; |
| 206 | 208 |
screen_resize(uxn_screen.width, PEEK2(port_height)); |
| ... | ... |
@@ -22,6 +22,7 @@ typedef struct UxnScreen {
|
| 22 | 22 |
extern UxnScreen uxn_screen; |
| 23 | 23 |
extern int emu_resize(int width, int height); |
| 24 | 24 |
|
| 25 |
+void screen_fill(Uint8 *layer, int color); |
|
| 25 | 26 |
void screen_rect(Uint8 *layer, int x1, int y1, int x2, int y2, int color); |
| 26 | 27 |
void screen_palette(Uint8 *addr); |
| 27 | 28 |
void screen_resize(Uint16 width, Uint16 height); |
| ... | ... |
@@ -178,7 +178,7 @@ static void |
| 178 | 178 |
set_debugger(Uxn *u, int value) |
| 179 | 179 |
{
|
| 180 | 180 |
u->dev[0x0e] = value; |
| 181 |
- screen_rect(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0); |
|
| 181 |
+ screen_fill(uxn_screen.fg, 0); |
|
| 182 | 182 |
screen_redraw(u); |
| 183 | 183 |
} |
| 184 | 184 |
|
| ... | ... |
@@ -253,8 +253,8 @@ static void |
| 253 | 253 |
emu_restart(Uxn *u, char *rom, int soft) |
| 254 | 254 |
{
|
| 255 | 255 |
screen_resize(WIDTH, HEIGHT); |
| 256 |
- screen_rect(uxn_screen.bg, 0, 0, uxn_screen.width, uxn_screen.height, 0); |
|
| 257 |
- screen_rect(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0); |
|
| 256 |
+ screen_fill(uxn_screen.bg, 0); |
|
| 257 |
+ screen_fill(uxn_screen.fg, 0); |
|
| 258 | 258 |
system_reboot(u, rom, soft); |
| 259 | 259 |
SDL_SetWindowTitle(emu_window, boot_rom); |
| 260 | 260 |
} |