0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-27 16:23:02 +00:00

Removed device vector variable

This commit is contained in:
neauoire 2022-01-07 16:46:50 -08:00
parent 180984f8fb
commit f5278f3a13
8 changed files with 22 additions and 27 deletions

View file

@ -18,7 +18,7 @@ controller_down(Device *d, Uint8 mask)
{
if(mask) {
d->dat[2] |= mask;
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
}
}
@ -27,7 +27,7 @@ controller_up(Device *d, Uint8 mask)
{
if(mask) {
d->dat[2] &= (~mask);
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
}
}
@ -36,7 +36,7 @@ controller_key(Device *d, Uint8 key)
{
if(key) {
d->dat[3] = key;
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
d->dat[3] = 0x00;
}
}
@ -46,7 +46,7 @@ controller_special(Device *d, Uint8 key)
{
if(key) {
d->dat[4] = key;
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
d->dat[4] = 0x00;
}
}

View file

@ -146,9 +146,6 @@ file_deo(Device *d, Uint8 port)
{
Uint16 a, b, res;
switch(port) {
case 0x1:
DEVPEEK16(d->vector, 0x0);
break;
case 0x5:
DEVPEEK16(a, 0x4);
DEVPEEK16(b, 0xa);

View file

@ -17,14 +17,14 @@ void
mouse_down(Device *d, Uint8 mask)
{
d->dat[6] |= mask;
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
}
void
mouse_up(Device *d, Uint8 mask)
{
d->dat[6] &= (~mask);
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
}
void
@ -32,7 +32,7 @@ mouse_pos(Device *d, Uint16 x, Uint16 y)
{
DEVPOKE16(0x2, x);
DEVPOKE16(0x4, y);
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
}
void
@ -40,7 +40,7 @@ mouse_scroll(Device *d, Uint16 x, Uint16 y)
{
DEVPOKE16(0xa, x);
DEVPOKE16(0xc, -y);
uxn_eval(d->u, d->vector);
uxn_eval(d->u, GETVECTOR(d));
DEVPOKE16(0xa, 0);
DEVPOKE16(0xc, 0);
}

View file

@ -127,7 +127,6 @@ void
screen_deo(Device *d, Uint8 port)
{
switch(port) {
case 0x1: DEVPEEK16(d->vector, 0x0); break;
case 0x5:
if(!FIXED_SIZE) {
Uint16 w, h;

View file

@ -28,12 +28,14 @@ int
uxn_halt(Uxn *u, Uint8 error, Uint16 addr)
{
Device *d = &u->dev[0];
Uint16 vec = d->vector;
Uint16 vec = GETVECTOR(d);
DEVPOKE16(0x4, addr);
d->dat[0x6] = error;
uxn_eval(&supervisor, supervisor.dev[0].vector);
uxn_eval(&supervisor, GETVECTOR(&supervisor.dev[0]));
if(vec) {
d->vector = 0; /* need to rearm to run System/vector again */
/* need to rearm to run System/vector again */
d->dat[0] = 0;
d->dat[1] = 0;
if(error != 2) /* working stack overflow has special treatment */
vec += 0x0004;
return uxn_eval(u, vec);
@ -58,7 +60,6 @@ void
system_deo(Device *d, Uint8 port)
{
switch(port) {
case 0x1: DEVPEEK16(d->vector, 0x0); break;
case 0x2: d->u->wst->ptr = d->dat[port]; break;
case 0x3: d->u->rst->ptr = d->dat[port]; break;
default: system_deo_special(d, port);

View file

@ -27,6 +27,7 @@ typedef unsigned int Uint32;
#define DEVPEEK16(o, x) { (o) = (d->dat[(x)] << 8) + d->dat[(x) + 1]; }
#define DEVPOKE16(x, y) { d->dat[(x)] = (y) >> 8; d->dat[(x) + 1] = (y); }
#define GETVECTOR(d) ((d)->dat[0] << 8 | (d)->dat[1])
/* clang-format on */
@ -37,7 +38,6 @@ typedef struct {
typedef struct Device {
struct Uxn *u;
Uint8 *dat, *mem;
Uint16 vector;
Uint8 (*dei)(struct Device *d, Uint8);
void (*deo)(struct Device *d, Uint8);
} Device;

View file

@ -60,8 +60,6 @@ system_deo_special(Device *d, Uint8 port)
static void
console_deo(Device *d, Uint8 port)
{
if(port == 0x1)
DEVPEEK16(d->vector, 0x0);
if(port > 0x7)
write(port - 0x7, (char *)&d->dat[port], 1);
}
@ -75,7 +73,8 @@ nil_dei(Device *d, Uint8 port)
static void
nil_deo(Device *d, Uint8 port)
{
if(port == 0x1) DEVPEEK16(d->vector, 0x0);
(void)d;
(void)port;
}
#pragma mark - Generics
@ -84,7 +83,7 @@ static int
console_input(Uxn *u, char c)
{
devconsole->dat[0x2] = c;
return uxn_eval(u, devconsole->vector);
return uxn_eval(u, GETVECTOR(devconsole));
}
static void

View file

@ -180,8 +180,6 @@ system_deo_special(Device *d, Uint8 port)
static void
console_deo(Device *d, Uint8 port)
{
if(port == 0x1)
DEVPEEK16(d->vector, 0x0);
if(port > 0x7)
write(port - 0x7, (char *)&d->dat[port], 1);
}
@ -228,7 +226,8 @@ nil_dei(Device *d, Uint8 port)
static void
nil_deo(Device *d, Uint8 port)
{
if(port == 0x1) DEVPEEK16(d->vector, 0x0);
(void)d;
(void)port;
}
/* Boot */
@ -409,7 +408,7 @@ static int
console_input(Uxn *u, char c)
{
devconsole->dat[0x2] = c;
return uxn_eval(u, devconsole->vector);
return uxn_eval(u, GETVECTOR(devconsole));
}
static int
@ -483,8 +482,8 @@ run(Uxn *u)
console_input(u, event.cbutton.button);
}
if(devsystem->dat[0xe])
uxn_eval(&supervisor, supervisor.dev[2].vector);
uxn_eval(u, devscreen->vector);
uxn_eval(&supervisor, GETVECTOR(&supervisor.dev[2]));
uxn_eval(u, GETVECTOR(devscreen));
if(uxn_screen.fg.changed || uxn_screen.bg.changed || devsystem->dat[0xe])
redraw();
if(!BENCH) {