Removed indirections in uxn11
This commit is contained in:
parent
3135f61e02
commit
8281131422
|
@ -116,26 +116,26 @@ draw_byte(Uint8 b, Uint16 x, Uint16 y, Uint8 color)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
screen_debugger(Uxn *u)
|
screen_debugger(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < 0x08; i++) {
|
for(i = 0; i < 0x08; i++) {
|
||||||
Uint8 pos = u->wst.ptr - 4 + i;
|
Uint8 pos = uxn.wst.ptr - 4 + i;
|
||||||
Uint8 color = i > 4 ? 0x01 : !pos ? 0xc :
|
Uint8 color = i > 4 ? 0x01 : !pos ? 0xc :
|
||||||
i == 4 ? 0x8 :
|
i == 4 ? 0x8 :
|
||||||
0x2;
|
0x2;
|
||||||
draw_byte(u->wst.dat[pos], i * 0x18 + 0x8, uxn_screen.height - 0x18, color);
|
draw_byte(uxn.wst.dat[pos], i * 0x18 + 0x8, uxn_screen.height - 0x18, color);
|
||||||
}
|
}
|
||||||
for(i = 0; i < 0x08; i++) {
|
for(i = 0; i < 0x08; i++) {
|
||||||
Uint8 pos = u->rst.ptr - 4 + i;
|
Uint8 pos = uxn.rst.ptr - 4 + i;
|
||||||
Uint8 color = i > 4 ? 0x01 : !pos ? 0xc :
|
Uint8 color = i > 4 ? 0x01 : !pos ? 0xc :
|
||||||
i == 4 ? 0x8 :
|
i == 4 ? 0x8 :
|
||||||
0x2;
|
0x2;
|
||||||
draw_byte(u->rst.dat[pos], i * 0x18 + 0x8, uxn_screen.height - 0x10, color);
|
draw_byte(uxn.rst.dat[pos], i * 0x18 + 0x8, uxn_screen.height - 0x10, color);
|
||||||
}
|
}
|
||||||
screen_1bpp(uxn_screen.fg, &arrow[0], 0x68, uxn_screen.height - 0x20, 3, 1, 1);
|
screen_1bpp(uxn_screen.fg, &arrow[0], 0x68, uxn_screen.height - 0x20, 3, 1, 1);
|
||||||
for(i = 0; i < 0x20; i++)
|
for(i = 0; i < 0x20; i++)
|
||||||
draw_byte(u->ram[i], (i & 0x7) * 0x18 + 0x8, ((i >> 3) << 3) + 0x8, 1 + !!u->ram[i]);
|
draw_byte(uxn.ram[i], (i & 0x7) * 0x18 + 0x8, ((i >> 3) << 3) + 0x8, 1 + !!uxn.ram[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -205,7 +205,7 @@ screen_resize(Uint16 width, Uint16 height, int scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
screen_redraw(Uxn *u)
|
screen_redraw(void)
|
||||||
{
|
{
|
||||||
int i, x, y, k, l, s = uxn_screen.scale;
|
int i, x, y, k, l, s = uxn_screen.scale;
|
||||||
Uint8 *fg = uxn_screen.fg, *bg = uxn_screen.bg;
|
Uint8 *fg = uxn_screen.fg, *bg = uxn_screen.bg;
|
||||||
|
@ -215,8 +215,8 @@ screen_redraw(Uxn *u)
|
||||||
Uint32 palette[16], *pixels = uxn_screen.pixels;
|
Uint32 palette[16], *pixels = uxn_screen.pixels;
|
||||||
uxn_screen.x1 = uxn_screen.y1 = 9000;
|
uxn_screen.x1 = uxn_screen.y1 = 9000;
|
||||||
uxn_screen.x2 = uxn_screen.y2 = 0;
|
uxn_screen.x2 = uxn_screen.y2 = 0;
|
||||||
if(u->dev[0x0e])
|
if(uxn.dev[0x0e])
|
||||||
screen_debugger(u);
|
screen_debugger();
|
||||||
for(i = 0; i < 16; i++)
|
for(i = 0; i < 16; i++)
|
||||||
palette[i] = uxn_screen.palette[(i >> 2) ? (i >> 2) : (i & 3)];
|
palette[i] = uxn_screen.palette[(i >> 2) ? (i >> 2) : (i & 3)];
|
||||||
for(y = y1; y < y2; y++) {
|
for(y = y1; y < y2; y++) {
|
||||||
|
@ -238,7 +238,7 @@ screen_redraw(Uxn *u)
|
||||||
static int rX, rY, rA, rMX, rMY, rMA, rML, rDX, rDY;
|
static int rX, rY, rA, rMX, rMY, rMA, rML, rDX, rDY;
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
screen_dei(Uxn *u, Uint8 addr)
|
screen_dei(Uint8 addr)
|
||||||
{
|
{
|
||||||
switch(addr) {
|
switch(addr) {
|
||||||
case 0x22: return uxn_screen.width >> 8;
|
case 0x22: return uxn_screen.width >> 8;
|
||||||
|
@ -251,12 +251,12 @@ screen_dei(Uxn *u, Uint8 addr)
|
||||||
case 0x2b: return rY;
|
case 0x2b: return rY;
|
||||||
case 0x2c: return rA >> 8;
|
case 0x2c: return rA >> 8;
|
||||||
case 0x2d: return rA;
|
case 0x2d: return rA;
|
||||||
default: return u->dev[addr];
|
default: return uxn.dev[addr];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
|
screen_deo(Uint8 *d, Uint8 port)
|
||||||
{
|
{
|
||||||
switch(port) {
|
switch(port) {
|
||||||
case 0x3: screen_resize(PEEK2(d + 2), uxn_screen.height, uxn_screen.scale); return;
|
case 0x3: screen_resize(PEEK2(d + 2), uxn_screen.height, uxn_screen.scale); return;
|
||||||
|
@ -308,10 +308,10 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
|
||||||
int dxy = rDX * fy, dyx = rDY * fx, addr_incr = rMA << (1 + twobpp);
|
int dxy = rDX * fy, dyx = rDY * fx, addr_incr = rMA << (1 + twobpp);
|
||||||
if(twobpp)
|
if(twobpp)
|
||||||
for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr)
|
for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr)
|
||||||
screen_2bpp(layer, &ram[rA], x, y, color, fx, fy);
|
screen_2bpp(layer, &uxn.ram[rA], x, y, color, fx, fy);
|
||||||
else
|
else
|
||||||
for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr)
|
for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr)
|
||||||
screen_1bpp(layer, &ram[rA], x, y, color, fx, fy);
|
screen_1bpp(layer, &uxn.ram[rA], x, y, color, fx, fy);
|
||||||
if(fx < 0)
|
if(fx < 0)
|
||||||
x1 = x, x2 = rX;
|
x1 = x, x2 = rX;
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,10 +9,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
WITH REGARD TO THIS SOFTWARE.
|
WITH REGARD TO THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SCREEN_VERSION 1
|
|
||||||
#define SCREEN_DEIMASK 0x003c
|
|
||||||
#define SCREEN_DEOMASK 0xc028
|
|
||||||
|
|
||||||
typedef struct UxnScreen {
|
typedef struct UxnScreen {
|
||||||
int width, height, x1, y1, x2, y2, scale;
|
int width, height, x1, y1, x2, y2, scale;
|
||||||
Uint32 palette[4], *pixels;
|
Uint32 palette[4], *pixels;
|
||||||
|
@ -27,9 +23,9 @@ void screen_fill(Uint8 *layer, int color);
|
||||||
void screen_rect(Uint8 *layer, Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, int color);
|
void screen_rect(Uint8 *layer, Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, int color);
|
||||||
void screen_palette(Uint8 *addr);
|
void screen_palette(Uint8 *addr);
|
||||||
void screen_resize(Uint16 width, Uint16 height, int scale);
|
void screen_resize(Uint16 width, Uint16 height, int scale);
|
||||||
void screen_redraw(Uxn *u);
|
void screen_redraw();
|
||||||
|
|
||||||
Uint8 screen_dei(Uxn *u, Uint8 addr);
|
Uint8 screen_dei(Uint8 addr);
|
||||||
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
|
void screen_deo(Uint8 *d, Uint8 port);
|
||||||
|
|
||||||
#define twos(v) (v & 0x8000 ? (int)v - 0x10000 : (int)v)
|
#define twos(v) (v & 0x8000 ? (int)v - 0x10000 : (int)v)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2022-2023 Devine Lu Linvega, Andrew Alderwick
|
Copyright (c) 2022-2024 Devine Lu Linvega, Andrew Alderwick
|
||||||
|
|
||||||
Permission to use, copy, modify, and distribute this software for any
|
Permission to use, copy, modify, and distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -67,13 +67,6 @@ system_inspect(Uxn *u)
|
||||||
fprintf(stderr, "RST "), system_print(&u->rst);
|
fprintf(stderr, "RST "), system_print(&u->rst);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
system_version(char *name, char *date)
|
|
||||||
{
|
|
||||||
printf("%s, %s.\n", name, date);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
system_reboot(Uxn *u, char *rom, int soft)
|
system_reboot(Uxn *u, char *rom, int soft)
|
||||||
{
|
{
|
||||||
|
@ -84,12 +77,12 @@ system_reboot(Uxn *u, char *rom, int soft)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
system_boot(Uxn *u, Uint8 *ram, char *rom)
|
system_boot(Uint8 *ram, char *rom)
|
||||||
{
|
{
|
||||||
u->ram = ram;
|
uxn.ram = ram;
|
||||||
system_zero(u, 0);
|
system_zero(&uxn, 0);
|
||||||
if(!system_load(u, rom))
|
if(!system_load(&uxn, rom))
|
||||||
if(!system_load(u, "boot.rom"))
|
if(!system_load(&uxn, "boot.rom"))
|
||||||
return system_error("Could not load rom", rom);
|
return system_error("Could not load rom", rom);
|
||||||
boot_rom = rom;
|
boot_rom = rom;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick
|
Copyright (c) 2024 Devine Lu Linvega, Andrew Alderwick
|
||||||
|
|
||||||
Permission to use, copy, modify, and distribute this software for any
|
Permission to use, copy, modify, and distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -14,9 +14,8 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
|
|
||||||
void system_reboot(Uxn *u, char *rom, int soft);
|
void system_reboot(Uxn *u, char *rom, int soft);
|
||||||
void system_inspect(Uxn *u);
|
void system_inspect(Uxn *u);
|
||||||
int system_version(char *emulator, char *date);
|
|
||||||
int system_error(char *msg, const char *err);
|
int system_error(char *msg, const char *err);
|
||||||
int system_boot(Uxn *u, Uint8 *ram, char *rom);
|
int system_boot(Uint8 *ram, char *rom);
|
||||||
|
|
||||||
Uint8 system_dei(Uxn *u, Uint8 addr);
|
Uint8 system_dei(Uxn *u, Uint8 addr);
|
||||||
void system_deo(Uxn *u, Uint8 *d, Uint8 port);
|
void system_deo(Uxn *u, Uint8 *d, Uint8 port);
|
||||||
|
|
62
src/uxn11.c
62
src/uxn11.c
|
@ -50,7 +50,7 @@ emu_dei(Uint8 addr)
|
||||||
switch(addr & 0xf0) {
|
switch(addr & 0xf0) {
|
||||||
case 0x00: return system_dei(&uxn, addr);
|
case 0x00: return system_dei(&uxn, addr);
|
||||||
case 0x10: return console_dei(&uxn, addr);
|
case 0x10: return console_dei(&uxn, addr);
|
||||||
case 0x20: return screen_dei(&uxn, addr);
|
case 0x20: return screen_dei(addr);
|
||||||
case 0xc0: return datetime_dei(addr);
|
case 0xc0: return datetime_dei(addr);
|
||||||
}
|
}
|
||||||
return uxn.dev[addr];
|
return uxn.dev[addr];
|
||||||
|
@ -68,7 +68,7 @@ emu_deo(Uint8 addr, Uint8 value)
|
||||||
screen_palette(&uxn.dev[0x8]);
|
screen_palette(&uxn.dev[0x8]);
|
||||||
break;
|
break;
|
||||||
case 0x10: console_deo(&uxn, &uxn.dev[d], p); break;
|
case 0x10: console_deo(&uxn, &uxn.dev[d], p); break;
|
||||||
case 0x20: screen_deo(uxn.ram, &uxn.dev[d], p); break;
|
case 0x20: screen_deo(&uxn.dev[d], p); break;
|
||||||
case 0xa0: file_deo(0, uxn.ram, &uxn.dev[d], p); break;
|
case 0xa0: file_deo(0, uxn.ram, &uxn.dev[d], p); break;
|
||||||
case 0xb0: file_deo(1, uxn.ram, &uxn.dev[d], p); break;
|
case 0xb0: file_deo(1, uxn.ram, &uxn.dev[d], p); break;
|
||||||
}
|
}
|
||||||
|
@ -89,23 +89,23 @@ emu_resize(int w, int h)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
emu_restart(Uxn *u, char *rom, int soft)
|
emu_restart(char *rom, int soft)
|
||||||
{
|
{
|
||||||
screen_resize(WIDTH, HEIGHT, uxn_screen.scale);
|
screen_resize(WIDTH, HEIGHT, uxn_screen.scale);
|
||||||
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(&uxn, rom, soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
emu_end(Uxn *u)
|
emu_end(void)
|
||||||
{
|
{
|
||||||
free(u->ram);
|
free(uxn.ram);
|
||||||
XDestroyImage(ximage);
|
XDestroyImage(ximage);
|
||||||
XDestroyWindow(display, window);
|
XDestroyWindow(display, window);
|
||||||
XCloseDisplay(display);
|
XCloseDisplay(display);
|
||||||
exit(0);
|
exit(0);
|
||||||
return u->dev[0x0f] & 0x7f;
|
return uxn.dev[0x0f] & 0x7f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Uint8
|
static Uint8
|
||||||
|
@ -134,7 +134,7 @@ toggle_scale(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
emu_event(Uxn *u)
|
emu_event(void)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
XNextEvent(display, &ev);
|
XNextEvent(display, &ev);
|
||||||
|
@ -146,7 +146,7 @@ emu_event(Uxn *u)
|
||||||
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, PAD, PAD, w, h);
|
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, PAD, PAD, w, h);
|
||||||
} break;
|
} break;
|
||||||
case ClientMessage:
|
case ClientMessage:
|
||||||
u->dev[0x0f] = 0x80;
|
uxn.dev[0x0f] = 0x80;
|
||||||
break;
|
break;
|
||||||
case KeyPress: {
|
case KeyPress: {
|
||||||
KeySym sym;
|
KeySym sym;
|
||||||
|
@ -154,41 +154,41 @@ emu_event(Uxn *u)
|
||||||
XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
|
XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
|
||||||
switch(sym) {
|
switch(sym) {
|
||||||
case XK_F1: toggle_scale(); break;
|
case XK_F1: toggle_scale(); break;
|
||||||
case XK_F2: u->dev[0x0e] = !u->dev[0x0e]; break;
|
case XK_F2: uxn.dev[0x0e] = !uxn.dev[0x0e]; break;
|
||||||
case XK_F4: emu_restart(u, boot_rom, 0); break;
|
case XK_F4: emu_restart(boot_rom, 0); break;
|
||||||
case XK_F5: emu_restart(u, boot_rom, 1); break;
|
case XK_F5: emu_restart(boot_rom, 1); break;
|
||||||
}
|
}
|
||||||
controller_down(&u->dev[0x80], get_button(sym));
|
controller_down(&uxn.dev[0x80], get_button(sym));
|
||||||
controller_key(&u->dev[0x80], sym < 0x80 ? sym : (Uint8)buf[0]);
|
controller_key(&uxn.dev[0x80], sym < 0x80 ? sym : (Uint8)buf[0]);
|
||||||
} break;
|
} break;
|
||||||
case KeyRelease: {
|
case KeyRelease: {
|
||||||
KeySym sym;
|
KeySym sym;
|
||||||
char buf[7];
|
char buf[7];
|
||||||
XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
|
XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
|
||||||
controller_up(&u->dev[0x80], get_button(sym));
|
controller_up(&uxn.dev[0x80], get_button(sym));
|
||||||
} break;
|
} break;
|
||||||
case ButtonPress: {
|
case ButtonPress: {
|
||||||
XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
|
XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
|
||||||
if(e->button == 4)
|
if(e->button == 4)
|
||||||
mouse_scroll(&u->dev[0x90], 0, 1);
|
mouse_scroll(&uxn.dev[0x90], 0, 1);
|
||||||
else if(e->button == 5)
|
else if(e->button == 5)
|
||||||
mouse_scroll(&u->dev[0x90], 0, -1);
|
mouse_scroll(&uxn.dev[0x90], 0, -1);
|
||||||
else if(e->button == 6)
|
else if(e->button == 6)
|
||||||
mouse_scroll(&u->dev[0x90], 1, 0);
|
mouse_scroll(&uxn.dev[0x90], 1, 0);
|
||||||
else if(e->button == 7)
|
else if(e->button == 7)
|
||||||
mouse_scroll(&u->dev[0x90], -1, 0);
|
mouse_scroll(&uxn.dev[0x90], -1, 0);
|
||||||
else
|
else
|
||||||
mouse_down(&u->dev[0x90], 0x1 << (e->button - 1));
|
mouse_down(&uxn.dev[0x90], 0x1 << (e->button - 1));
|
||||||
} break;
|
} break;
|
||||||
case ButtonRelease: {
|
case ButtonRelease: {
|
||||||
XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
|
XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
|
||||||
mouse_up(&u->dev[0x90], 0x1 << (e->button - 1));
|
mouse_up(&uxn.dev[0x90], 0x1 << (e->button - 1));
|
||||||
} break;
|
} break;
|
||||||
case MotionNotify: {
|
case MotionNotify: {
|
||||||
XMotionEvent *e = (XMotionEvent *)&ev;
|
XMotionEvent *e = (XMotionEvent *)&ev;
|
||||||
int x = clamp((e->x - PAD) / uxn_screen.scale, 0, uxn_screen.width - 1);
|
int x = clamp((e->x - PAD) / uxn_screen.scale, 0, uxn_screen.width - 1);
|
||||||
int y = clamp((e->y - PAD) / uxn_screen.scale, 0, uxn_screen.height - 1);
|
int y = clamp((e->y - PAD) / uxn_screen.scale, 0, uxn_screen.height - 1);
|
||||||
mouse_pos(&u->dev[0x90], x, y);
|
mouse_pos(&uxn.dev[0x90], x, y);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ display_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
emu_run(Uxn *u)
|
emu_run(void)
|
||||||
{
|
{
|
||||||
int i = 1, n;
|
int i = 1, n;
|
||||||
char expirations[8];
|
char expirations[8];
|
||||||
|
@ -241,18 +241,18 @@ emu_run(Uxn *u)
|
||||||
fds[2].fd = STDIN_FILENO;
|
fds[2].fd = STDIN_FILENO;
|
||||||
fds[0].events = fds[1].events = fds[2].events = POLLIN;
|
fds[0].events = fds[1].events = fds[2].events = POLLIN;
|
||||||
/* main loop */
|
/* main loop */
|
||||||
while(!u->dev[0x0f]) {
|
while(!uxn.dev[0x0f]) {
|
||||||
if(poll(fds, 3, 1000) <= 0)
|
if(poll(fds, 3, 1000) <= 0)
|
||||||
continue;
|
continue;
|
||||||
while(XPending(display))
|
while(XPending(display))
|
||||||
emu_event(u);
|
emu_event();
|
||||||
if(poll(&fds[1], 1, 0)) {
|
if(poll(&fds[1], 1, 0)) {
|
||||||
read(fds[1].fd, expirations, 8);
|
read(fds[1].fd, expirations, 8);
|
||||||
uxn_eval(u, u->dev[0x20] << 8 | u->dev[0x21]);
|
uxn_eval(&uxn, uxn.dev[0x20] << 8 | uxn.dev[0x21]);
|
||||||
if(screen_changed()) {
|
if(screen_changed()) {
|
||||||
int x = uxn_screen.x1 * uxn_screen.scale, y = uxn_screen.y1 * uxn_screen.scale;
|
int x = uxn_screen.x1 * uxn_screen.scale, y = uxn_screen.y1 * uxn_screen.scale;
|
||||||
int w = uxn_screen.x2 * uxn_screen.scale - x, h = uxn_screen.y2 * uxn_screen.scale - y;
|
int w = uxn_screen.x2 * uxn_screen.scale - x, h = uxn_screen.y2 * uxn_screen.scale - y;
|
||||||
screen_redraw(u);
|
screen_redraw();
|
||||||
XPutImage(display, window, DefaultGC(display, 0), ximage, x, y, x + PAD, y + PAD, w, h);
|
XPutImage(display, window, DefaultGC(display, 0), ximage, x, y, x + PAD, y + PAD, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ emu_run(Uxn *u)
|
||||||
n = read(fds[2].fd, coninp, CONINBUFSIZE - 1);
|
n = read(fds[2].fd, coninp, CONINBUFSIZE - 1);
|
||||||
coninp[n] = 0;
|
coninp[n] = 0;
|
||||||
for(i = 0; i < n; i++)
|
for(i = 0; i < n; i++)
|
||||||
console_input(u, coninp[i], CONSOLE_STD);
|
console_input(&uxn, coninp[i], CONSOLE_STD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -276,7 +276,7 @@ main(int argc, char **argv)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
rom = i == argc ? "boot.rom" : argv[i++];
|
rom = i == argc ? "boot.rom" : argv[i++];
|
||||||
if(!system_boot(&uxn, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), rom)) {
|
if(!system_boot((Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), rom)) {
|
||||||
fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
|
fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ main(int argc, char **argv)
|
||||||
uxn.dev[0x17] = argc - i;
|
uxn.dev[0x17] = argc - i;
|
||||||
if(uxn_eval(&uxn, PAGE_PROGRAM)) {
|
if(uxn_eval(&uxn, PAGE_PROGRAM)) {
|
||||||
console_listen(&uxn, i, argc, argv);
|
console_listen(&uxn, i, argc, argv);
|
||||||
emu_run(&uxn);
|
emu_run();
|
||||||
}
|
}
|
||||||
return emu_end(&uxn);
|
return emu_end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,8 +72,8 @@ main(int argc, char **argv)
|
||||||
return system_error("usage", "uxncli [-v] file.rom [args..]");
|
return system_error("usage", "uxncli [-v] file.rom [args..]");
|
||||||
/* Read flags */
|
/* Read flags */
|
||||||
if(argv[i][0] == '-' && argv[i][1] == 'v')
|
if(argv[i][0] == '-' && argv[i][1] == 'v')
|
||||||
return system_version("Uxncli - Console Varvara Emulator", "29 Jun 2024");
|
return !printf("Uxncli - Console Varvara Emulator, 29 Jun 2024\n");
|
||||||
if(!system_boot(&uxn, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
|
if(!system_boot((Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
|
||||||
return system_error("Init", "Failed to initialize uxn.");
|
return system_error("Init", "Failed to initialize uxn.");
|
||||||
/* Game Loop */
|
/* Game Loop */
|
||||||
uxn.dev[0x17] = argc - i;
|
uxn.dev[0x17] = argc - i;
|
||||||
|
|
Loading…
Reference in New Issue