Removing uxn core indirection in mouse, datetime
This commit is contained in:
parent
eff62461a4
commit
3135f61e02
|
@ -9,8 +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 CONSOLE_VERSION 1
|
|
||||||
|
|
||||||
#define CONSOLE_STD 0x1
|
#define CONSOLE_STD 0x1
|
||||||
#define CONSOLE_ARG 0x2
|
#define CONSOLE_ARG 0x2
|
||||||
#define CONSOLE_EOA 0x3
|
#define CONSOLE_EOA 0x3
|
||||||
|
|
|
@ -13,29 +13,29 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
controller_down(Uxn *u, Uint8 *d, Uint8 mask)
|
controller_down(Uint8 *d, Uint8 mask)
|
||||||
{
|
{
|
||||||
if(mask) {
|
if(mask) {
|
||||||
d[2] |= mask;
|
d[2] |= mask;
|
||||||
uxn_eval(u, PEEK2(d));
|
uxn_eval(&uxn, PEEK2(d));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
controller_up(Uxn *u, Uint8 *d, Uint8 mask)
|
controller_up(Uint8 *d, Uint8 mask)
|
||||||
{
|
{
|
||||||
if(mask) {
|
if(mask) {
|
||||||
d[2] &= (~mask);
|
d[2] &= (~mask);
|
||||||
uxn_eval(u, PEEK2(d));
|
uxn_eval(&uxn, PEEK2(d));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
controller_key(Uxn *u, Uint8 *d, Uint8 key)
|
controller_key(Uint8 *d, Uint8 key)
|
||||||
{
|
{
|
||||||
if(key) {
|
if(key) {
|
||||||
d[3] = key;
|
d[3] = key;
|
||||||
uxn_eval(u, PEEK2(d));
|
uxn_eval(&uxn, PEEK2(d));
|
||||||
d[3] = 0x00;
|
d[3] = 0x00;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,6 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
|
|
||||||
#define CONTROL_VERSION 1
|
#define CONTROL_VERSION 1
|
||||||
|
|
||||||
void controller_down(Uxn *u, Uint8 *d, Uint8 mask);
|
void controller_down(Uint8 *d, Uint8 mask);
|
||||||
void controller_up(Uxn *u, Uint8 *d, Uint8 mask);
|
void controller_up(Uint8 *d, Uint8 mask);
|
||||||
void controller_key(Uxn *u, Uint8 *d, Uint8 key);
|
void controller_key(Uint8 *d, Uint8 key);
|
||||||
|
|
|
@ -15,7 +15,7 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
datetime_dei(Uxn *u, Uint8 addr)
|
datetime_dei(Uint8 addr)
|
||||||
{
|
{
|
||||||
time_t seconds = time(NULL);
|
time_t seconds = time(NULL);
|
||||||
struct tm zt = {0};
|
struct tm zt = {0};
|
||||||
|
@ -34,6 +34,6 @@ datetime_dei(Uxn *u, Uint8 addr)
|
||||||
case 0xc8: return t->tm_yday >> 8;
|
case 0xc8: return t->tm_yday >> 8;
|
||||||
case 0xc9: return t->tm_yday;
|
case 0xc9: return t->tm_yday;
|
||||||
case 0xca: return t->tm_isdst;
|
case 0xca: return t->tm_isdst;
|
||||||
default: return u->dev[addr];
|
default: return uxn.dev[addr];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,4 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
|
|
||||||
#define DATETIME_VERSION 1
|
#define DATETIME_VERSION 1
|
||||||
|
|
||||||
Uint8 datetime_dei(Uxn *u, Uint8 addr);
|
Uint8 datetime_dei(Uint8 addr);
|
||||||
|
|
|
@ -13,33 +13,33 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
mouse_down(Uxn *u, Uint8 *d, Uint8 mask)
|
mouse_down(Uint8 *d, Uint8 mask)
|
||||||
{
|
{
|
||||||
d[6] |= mask;
|
d[6] |= mask;
|
||||||
uxn_eval(u, PEEK2(d));
|
uxn_eval(&uxn, PEEK2(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mouse_up(Uxn *u, Uint8 *d, Uint8 mask)
|
mouse_up(Uint8 *d, Uint8 mask)
|
||||||
{
|
{
|
||||||
d[6] &= (~mask);
|
d[6] &= (~mask);
|
||||||
uxn_eval(u, PEEK2(d));
|
uxn_eval(&uxn, PEEK2(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mouse_pos(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
|
mouse_pos(Uint8 *d, Uint16 x, Uint16 y)
|
||||||
{
|
{
|
||||||
*(d + 2) = x >> 8, *(d + 3) = x;
|
*(d + 2) = x >> 8, *(d + 3) = x;
|
||||||
*(d + 4) = y >> 8, *(d + 5) = y;
|
*(d + 4) = y >> 8, *(d + 5) = y;
|
||||||
uxn_eval(u, PEEK2(d));
|
uxn_eval(&uxn, PEEK2(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mouse_scroll(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
|
mouse_scroll(Uint8 *d, Uint16 x, Uint16 y)
|
||||||
{
|
{
|
||||||
*(d + 0xa) = x >> 8, *(d + 0xb) = x;
|
*(d + 0xa) = x >> 8, *(d + 0xb) = x;
|
||||||
*(d + 0xc) = -y >> 8, *(d + 0xd) = -y;
|
*(d + 0xc) = -y >> 8, *(d + 0xd) = -y;
|
||||||
uxn_eval(u, PEEK2(d));
|
uxn_eval(&uxn, PEEK2(d));
|
||||||
*(d + 0xa) = 0, *(d + 0xb) = 0;
|
*(d + 0xa) = 0, *(d + 0xb) = 0;
|
||||||
*(d + 0xc) = 0, *(d + 0xd) = 0;
|
*(d + 0xc) = 0, *(d + 0xd) = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
WITH REGARD TO THIS SOFTWARE.
|
WITH REGARD TO THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MOUSE_VERSION 1
|
void mouse_down(Uint8 *d, Uint8 mask);
|
||||||
|
void mouse_up(Uint8 *d, Uint8 mask);
|
||||||
void mouse_down(Uxn *u, Uint8 *d, Uint8 mask);
|
void mouse_pos(Uint8 *d, Uint16 x, Uint16 y);
|
||||||
void mouse_up(Uxn *u, Uint8 *d, Uint8 mask);
|
void mouse_scroll(Uint8 *d, Uint16 x, Uint16 y);
|
||||||
void mouse_pos(Uxn *u, Uint8 *d, Uint16 x, Uint16 y);
|
|
||||||
void mouse_scroll(Uxn *u, Uint8 *d, Uint16 x, Uint16 y);
|
|
||||||
|
|
22
src/uxn11.c
22
src/uxn11.c
|
@ -51,7 +51,7 @@ emu_dei(Uint8 addr)
|
||||||
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(&uxn, addr);
|
||||||
case 0xc0: return datetime_dei(&uxn, addr);
|
case 0xc0: return datetime_dei(addr);
|
||||||
}
|
}
|
||||||
return uxn.dev[addr];
|
return uxn.dev[addr];
|
||||||
}
|
}
|
||||||
|
@ -158,37 +158,37 @@ emu_event(Uxn *u)
|
||||||
case XK_F4: emu_restart(u, boot_rom, 0); break;
|
case XK_F4: emu_restart(u, boot_rom, 0); break;
|
||||||
case XK_F5: emu_restart(u, boot_rom, 1); break;
|
case XK_F5: emu_restart(u, boot_rom, 1); break;
|
||||||
}
|
}
|
||||||
controller_down(u, &u->dev[0x80], get_button(sym));
|
controller_down(&u->dev[0x80], get_button(sym));
|
||||||
controller_key(u, &u->dev[0x80], sym < 0x80 ? sym : (Uint8)buf[0]);
|
controller_key(&u->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, &u->dev[0x80], get_button(sym));
|
controller_up(&u->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, &u->dev[0x90], 0, 1);
|
mouse_scroll(&u->dev[0x90], 0, 1);
|
||||||
else if(e->button == 5)
|
else if(e->button == 5)
|
||||||
mouse_scroll(u, &u->dev[0x90], 0, -1);
|
mouse_scroll(&u->dev[0x90], 0, -1);
|
||||||
else if(e->button == 6)
|
else if(e->button == 6)
|
||||||
mouse_scroll(u, &u->dev[0x90], 1, 0);
|
mouse_scroll(&u->dev[0x90], 1, 0);
|
||||||
else if(e->button == 7)
|
else if(e->button == 7)
|
||||||
mouse_scroll(u, &u->dev[0x90], -1, 0);
|
mouse_scroll(&u->dev[0x90], -1, 0);
|
||||||
else
|
else
|
||||||
mouse_down(u, &u->dev[0x90], 0x1 << (e->button - 1));
|
mouse_down(&u->dev[0x90], 0x1 << (e->button - 1));
|
||||||
} break;
|
} break;
|
||||||
case ButtonRelease: {
|
case ButtonRelease: {
|
||||||
XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
|
XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
|
||||||
mouse_up(u, &u->dev[0x90], 0x1 << (e->button - 1));
|
mouse_up(&u->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, &u->dev[0x90], x, y);
|
mouse_pos(&u->dev[0x90], x, y);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,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 0xc0: return datetime_dei(&uxn, addr);
|
case 0xc0: return datetime_dei(addr);
|
||||||
}
|
}
|
||||||
return uxn.dev[addr];
|
return uxn.dev[addr];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue