Added ZOOM support
This commit is contained in:
parent
855b63b1ef
commit
55178e8347
|
@ -75,7 +75,7 @@ screen_resize(UxnScreen *p, Uint16 width, Uint16 height)
|
|||
return;
|
||||
bg = realloc(p->bg.pixels, width * height),
|
||||
fg = realloc(p->fg.pixels, width * height);
|
||||
pixels = realloc(p->pixels, width * height * sizeof(Uint32));
|
||||
pixels = realloc(p->pixels, width * height * sizeof(Uint32) * ZOOM * ZOOM);
|
||||
if(!bg || !fg || !pixels)
|
||||
return;
|
||||
p->bg.pixels = bg;
|
||||
|
@ -90,12 +90,15 @@ screen_resize(UxnScreen *p, Uint16 width, Uint16 height)
|
|||
void
|
||||
screen_redraw(UxnScreen *p)
|
||||
{
|
||||
Uint32 i, size = p->width * p->height, palette[16], *pixels = p->pixels;
|
||||
Uint8 *fg = p->fg.pixels, *bg = p->bg.pixels;
|
||||
Uint32 i, j, x, y, w = p->width * ZOOM, h = p->height * ZOOM, palette[16], *pixels = p->pixels;
|
||||
for(i = 0; i < 16; i++)
|
||||
palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)];
|
||||
for(i = 0; i < size; i++)
|
||||
pixels[i] = palette[fg[i] << 2 | bg[i]];
|
||||
for(y = 0; y < h; y++)
|
||||
for(x = 0; x < w; x++) {
|
||||
j = ((x / ZOOM) + (y / ZOOM) * p->width);
|
||||
pixels[x + y * w] = palette[fg[j] << 2 | bg[j]];
|
||||
}
|
||||
p->fg.changed = p->bg.changed = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|||
WITH REGARD TO THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define ZOOM 2
|
||||
|
||||
typedef struct Layer {
|
||||
Uint8 *pixels, changed;
|
||||
} Layer;
|
||||
|
|
|
@ -72,7 +72,7 @@ static void
|
|||
emu_draw(void)
|
||||
{
|
||||
screen_redraw(&uxn_screen);
|
||||
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, PAD, PAD, uxn_screen.width, uxn_screen.height);
|
||||
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, PAD, PAD, uxn_screen.width * ZOOM, uxn_screen.height * ZOOM);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -166,7 +166,7 @@ emu_event(Uxn *u)
|
|||
} break;
|
||||
case MotionNotify: {
|
||||
XMotionEvent *e = (XMotionEvent *)&ev;
|
||||
mouse_pos(u, &u->dev[0x90], e->x - PAD, e->y - PAD);
|
||||
mouse_pos(u, &u->dev[0x90], (e->x - PAD) / ZOOM, (e->y - PAD) / ZOOM);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ display_start(char *title)
|
|||
Atom wmDelete;
|
||||
display = XOpenDisplay(NULL);
|
||||
visual = DefaultVisual(display, 0);
|
||||
window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width + PAD * 2, uxn_screen.height + PAD * 2, 1, 0, 0);
|
||||
window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width * ZOOM + PAD * 2, uxn_screen.height * ZOOM + PAD * 2, 1, 0, 0);
|
||||
if(visual->class != TrueColor)
|
||||
return system_error("init", "True-color visual failed");
|
||||
XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask);
|
||||
|
@ -185,7 +185,7 @@ display_start(char *title)
|
|||
XSetWMProtocols(display, window, &wmDelete, 1);
|
||||
XStoreName(display, window, title);
|
||||
XMapWindow(display, window);
|
||||
ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width, uxn_screen.height, 32, 0);
|
||||
ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width * ZOOM, uxn_screen.height * ZOOM, 32, 0);
|
||||
hide_cursor();
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue