Housekeeping
This commit is contained in:
parent
93430aebf0
commit
909cc1b480
24
src/uxn11.c
24
src/uxn11.c
|
@ -75,12 +75,12 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 value)
|
||||||
int
|
int
|
||||||
emu_resize(int w, int h)
|
emu_resize(int w, int h)
|
||||||
{
|
{
|
||||||
int s = uxn_screen.scale;
|
|
||||||
static Visual *visual;
|
|
||||||
if(window) {
|
if(window) {
|
||||||
|
static Visual *visual;
|
||||||
|
w *= uxn_screen.scale, h *= uxn_screen.scale;
|
||||||
visual = DefaultVisual(display, 0);
|
visual = DefaultVisual(display, 0);
|
||||||
ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, w * s, h * s, 32, 0);
|
ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, w, h, 32, 0);
|
||||||
XResizeWindow(display, window, w * s, h * s);
|
XResizeWindow(display, window, w, h);
|
||||||
XMapWindow(display, window);
|
XMapWindow(display, window);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -93,7 +93,6 @@ emu_restart(Uxn *u, char *rom, int soft)
|
||||||
screen_rect(uxn_screen.bg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
|
screen_rect(uxn_screen.bg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
|
||||||
screen_rect(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
|
screen_rect(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
|
||||||
system_reboot(u, rom, soft);
|
system_reboot(u, rom, soft);
|
||||||
/* set window title */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -135,11 +134,10 @@ static void
|
||||||
emu_event(Uxn *u)
|
emu_event(Uxn *u)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
int s = uxn_screen.scale;
|
|
||||||
XNextEvent(display, &ev);
|
XNextEvent(display, &ev);
|
||||||
switch(ev.type) {
|
switch(ev.type) {
|
||||||
case Expose:
|
case Expose:
|
||||||
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, PAD, PAD, uxn_screen.width * s, uxn_screen.height * s);
|
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, PAD, PAD, uxn_screen.width * uxn_screen.scale, uxn_screen.height * uxn_screen.scale);
|
||||||
break;
|
break;
|
||||||
case ClientMessage: {
|
case ClientMessage: {
|
||||||
emu_end(u);
|
emu_end(u);
|
||||||
|
@ -180,8 +178,8 @@ emu_event(Uxn *u)
|
||||||
} break;
|
} break;
|
||||||
case MotionNotify: {
|
case MotionNotify: {
|
||||||
XMotionEvent *e = (XMotionEvent *)&ev;
|
XMotionEvent *e = (XMotionEvent *)&ev;
|
||||||
int ex = (e->x - PAD) / s;
|
int ex = (e->x - PAD) / uxn_screen.scale;
|
||||||
int ey = (e->y - PAD) / s;
|
int ey = (e->y - PAD) / uxn_screen.scale;
|
||||||
int x = clamp(ex, 0, uxn_screen.width - 1);
|
int x = clamp(ex, 0, uxn_screen.width - 1);
|
||||||
int y = clamp(ey, 0, uxn_screen.height - 1);
|
int y = clamp(ey, 0, uxn_screen.height - 1);
|
||||||
mouse_pos(u, &u->dev[0x90], x, y);
|
mouse_pos(u, &u->dev[0x90], x, y);
|
||||||
|
@ -201,12 +199,12 @@ display_init(void)
|
||||||
display = XOpenDisplay(NULL);
|
display = XOpenDisplay(NULL);
|
||||||
if(!display)
|
if(!display)
|
||||||
return system_error("init", "Display failed");
|
return system_error("init", "Display failed");
|
||||||
/* default size */
|
|
||||||
screen_resize(WIDTH, HEIGHT, 1);
|
screen_resize(WIDTH, HEIGHT, 1);
|
||||||
|
/* start window */
|
||||||
visual = DefaultVisual(display, 0);
|
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);
|
|
||||||
if(visual->class != TrueColor)
|
if(visual->class != TrueColor)
|
||||||
return system_error("init", "True-color visual failed");
|
return system_error("init", "True-color visual failed");
|
||||||
|
window = XCreateSimpleWindow(display, RootWindow(display, 0), 0, 0, uxn_screen.width + PAD * 2, uxn_screen.height + PAD * 2, 1, 0, 0);
|
||||||
XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask);
|
XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask);
|
||||||
wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", True);
|
wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", True);
|
||||||
XSetWMProtocols(display, window, &wmDelete, 1);
|
XSetWMProtocols(display, window, &wmDelete, 1);
|
||||||
|
@ -243,8 +241,8 @@ emu_run(Uxn *u, char *rom)
|
||||||
while(XPending(display))
|
while(XPending(display))
|
||||||
emu_event(u);
|
emu_event(u);
|
||||||
if(poll(&fds[1], 1, 0)) {
|
if(poll(&fds[1], 1, 0)) {
|
||||||
read(fds[1].fd, expirations, 8); /* Indicate we handled the timer */
|
read(fds[1].fd, expirations, 8);
|
||||||
uxn_eval(u, u->dev[0x20] << 8 | u->dev[0x21]); /* Call the vector once, even if the timer fired multiple times */
|
uxn_eval(u, u->dev[0x20] << 8 | u->dev[0x21]);
|
||||||
if(uxn_screen.x2) {
|
if(uxn_screen.x2) {
|
||||||
int s = uxn_screen.scale;
|
int s = uxn_screen.scale;
|
||||||
int x1 = uxn_screen.x1 * s, y1 = uxn_screen.y1 * s, x2 = uxn_screen.x2 * s, y2 = uxn_screen.y2 * s;
|
int x1 = uxn_screen.x1 * s, y1 = uxn_screen.y1 * s, x2 = uxn_screen.x2 * s, y2 = uxn_screen.y2 * s;
|
||||||
|
|
Loading…
Reference in New Issue