More selective redraw

This commit is contained in:
neauoire 2023-06-05 08:55:21 -07:00
parent 5a8ee380fe
commit 1892352885
2 changed files with 8 additions and 12 deletions

View File

@ -23,4 +23,4 @@ void screen_redraw(void);
Uint8 screen_dei(Uxn *u, Uint8 addr); Uint8 screen_dei(Uxn *u, Uint8 addr);
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port); void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
#define SCALE 3 #define SCALE 1

View File

@ -35,7 +35,7 @@ char *rom_path;
#define WIDTH (64 * 8) #define WIDTH (64 * 8)
#define HEIGHT (40 * 8) #define HEIGHT (40 * 8)
#define PAD 4 #define PAD 0
#define CONINBUFSIZE 256 #define CONINBUFSIZE 256
Uint16 deo_mask[] = {0xff28, 0x0300, 0xc028, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0xa260, 0xa260, 0x0000, 0x0000, 0x0000, 0x0000}; Uint16 deo_mask[] = {0xff28, 0x0300, 0xc028, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0xa260, 0xa260, 0x0000, 0x0000, 0x0000, 0x0000};
@ -68,13 +68,6 @@ uxn_deo(Uxn *u, Uint8 addr)
} }
} }
static void
emu_draw(void)
{
screen_redraw();
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, PAD, PAD, uxn_screen.width * SCALE, uxn_screen.height * SCALE);
}
static int static int
emu_start(Uxn *u, char *rom) emu_start(Uxn *u, char *rom)
{ {
@ -125,7 +118,7 @@ emu_event(Uxn *u)
XNextEvent(display, &ev); XNextEvent(display, &ev);
switch(ev.type) { switch(ev.type) {
case Expose: case Expose:
emu_draw(); XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, 0, 0, uxn_screen.width, uxn_screen.height);
break; break;
case ClientMessage: { case ClientMessage: {
XDestroyImage(ximage); XDestroyImage(ximage);
@ -237,8 +230,11 @@ main(int argc, char **argv)
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
console_input(&u, coninp[i], CONSOLE_STD); console_input(&u, coninp[i], CONSOLE_STD);
} }
if(uxn_screen.x2) if(uxn_screen.x2) {
emu_draw(); int x1 = uxn_screen.x1, y1 = uxn_screen.y1, x2 = uxn_screen.x2, y2 = uxn_screen.y2;
screen_redraw();
XPutImage(display, window, DefaultGC(display, 0), ximage, x1, y1, x1, y1, x2 - x1, y2 - y1);
}
} }
XDestroyImage(ximage); XDestroyImage(ximage);
return 0; return 0;