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