Removed device vector variable
This commit is contained in:
parent
180984f8fb
commit
f5278f3a13
|
@ -18,7 +18,7 @@ controller_down(Device *d, Uint8 mask)
|
||||||
{
|
{
|
||||||
if(mask) {
|
if(mask) {
|
||||||
d->dat[2] |= 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) {
|
if(mask) {
|
||||||
d->dat[2] &= (~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) {
|
if(key) {
|
||||||
d->dat[3] = key;
|
d->dat[3] = key;
|
||||||
uxn_eval(d->u, d->vector);
|
uxn_eval(d->u, GETVECTOR(d));
|
||||||
d->dat[3] = 0x00;
|
d->dat[3] = 0x00;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ controller_special(Device *d, Uint8 key)
|
||||||
{
|
{
|
||||||
if(key) {
|
if(key) {
|
||||||
d->dat[4] = key;
|
d->dat[4] = key;
|
||||||
uxn_eval(d->u, d->vector);
|
uxn_eval(d->u, GETVECTOR(d));
|
||||||
d->dat[4] = 0x00;
|
d->dat[4] = 0x00;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -146,9 +146,6 @@ file_deo(Device *d, Uint8 port)
|
||||||
{
|
{
|
||||||
Uint16 a, b, res;
|
Uint16 a, b, res;
|
||||||
switch(port) {
|
switch(port) {
|
||||||
case 0x1:
|
|
||||||
DEVPEEK16(d->vector, 0x0);
|
|
||||||
break;
|
|
||||||
case 0x5:
|
case 0x5:
|
||||||
DEVPEEK16(a, 0x4);
|
DEVPEEK16(a, 0x4);
|
||||||
DEVPEEK16(b, 0xa);
|
DEVPEEK16(b, 0xa);
|
||||||
|
|
|
@ -17,14 +17,14 @@ void
|
||||||
mouse_down(Device *d, Uint8 mask)
|
mouse_down(Device *d, Uint8 mask)
|
||||||
{
|
{
|
||||||
d->dat[6] |= mask;
|
d->dat[6] |= mask;
|
||||||
uxn_eval(d->u, d->vector);
|
uxn_eval(d->u, GETVECTOR(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mouse_up(Device *d, Uint8 mask)
|
mouse_up(Device *d, Uint8 mask)
|
||||||
{
|
{
|
||||||
d->dat[6] &= (~mask);
|
d->dat[6] &= (~mask);
|
||||||
uxn_eval(d->u, d->vector);
|
uxn_eval(d->u, GETVECTOR(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -32,7 +32,7 @@ mouse_pos(Device *d, Uint16 x, Uint16 y)
|
||||||
{
|
{
|
||||||
DEVPOKE16(0x2, x);
|
DEVPOKE16(0x2, x);
|
||||||
DEVPOKE16(0x4, y);
|
DEVPOKE16(0x4, y);
|
||||||
uxn_eval(d->u, d->vector);
|
uxn_eval(d->u, GETVECTOR(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -40,7 +40,7 @@ mouse_scroll(Device *d, Uint16 x, Uint16 y)
|
||||||
{
|
{
|
||||||
DEVPOKE16(0xa, x);
|
DEVPOKE16(0xa, x);
|
||||||
DEVPOKE16(0xc, -y);
|
DEVPOKE16(0xc, -y);
|
||||||
uxn_eval(d->u, d->vector);
|
uxn_eval(d->u, GETVECTOR(d));
|
||||||
DEVPOKE16(0xa, 0);
|
DEVPOKE16(0xa, 0);
|
||||||
DEVPOKE16(0xc, 0);
|
DEVPOKE16(0xc, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,6 @@ void
|
||||||
screen_deo(Device *d, Uint8 port)
|
screen_deo(Device *d, Uint8 port)
|
||||||
{
|
{
|
||||||
switch(port) {
|
switch(port) {
|
||||||
case 0x1: DEVPEEK16(d->vector, 0x0); break;
|
|
||||||
case 0x5:
|
case 0x5:
|
||||||
if(!FIXED_SIZE) {
|
if(!FIXED_SIZE) {
|
||||||
Uint16 w, h;
|
Uint16 w, h;
|
||||||
|
|
|
@ -28,12 +28,14 @@ int
|
||||||
uxn_halt(Uxn *u, Uint8 error, Uint16 addr)
|
uxn_halt(Uxn *u, Uint8 error, Uint16 addr)
|
||||||
{
|
{
|
||||||
Device *d = &u->dev[0];
|
Device *d = &u->dev[0];
|
||||||
Uint16 vec = d->vector;
|
Uint16 vec = GETVECTOR(d);
|
||||||
DEVPOKE16(0x4, addr);
|
DEVPOKE16(0x4, addr);
|
||||||
d->dat[0x6] = error;
|
d->dat[0x6] = error;
|
||||||
uxn_eval(&supervisor, supervisor.dev[0].vector);
|
uxn_eval(&supervisor, GETVECTOR(&supervisor.dev[0]));
|
||||||
if(vec) {
|
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 */
|
if(error != 2) /* working stack overflow has special treatment */
|
||||||
vec += 0x0004;
|
vec += 0x0004;
|
||||||
return uxn_eval(u, vec);
|
return uxn_eval(u, vec);
|
||||||
|
@ -58,7 +60,6 @@ void
|
||||||
system_deo(Device *d, Uint8 port)
|
system_deo(Device *d, Uint8 port)
|
||||||
{
|
{
|
||||||
switch(port) {
|
switch(port) {
|
||||||
case 0x1: DEVPEEK16(d->vector, 0x0); break;
|
|
||||||
case 0x2: d->u->wst->ptr = d->dat[port]; break;
|
case 0x2: d->u->wst->ptr = d->dat[port]; break;
|
||||||
case 0x3: d->u->rst->ptr = d->dat[port]; break;
|
case 0x3: d->u->rst->ptr = d->dat[port]; break;
|
||||||
default: system_deo_special(d, port);
|
default: system_deo_special(d, port);
|
||||||
|
|
|
@ -27,6 +27,7 @@ typedef unsigned int Uint32;
|
||||||
|
|
||||||
#define DEVPEEK16(o, x) { (o) = (d->dat[(x)] << 8) + d->dat[(x) + 1]; }
|
#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 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 */
|
/* clang-format on */
|
||||||
|
|
||||||
|
@ -37,7 +38,6 @@ typedef struct {
|
||||||
typedef struct Device {
|
typedef struct Device {
|
||||||
struct Uxn *u;
|
struct Uxn *u;
|
||||||
Uint8 *dat, *mem;
|
Uint8 *dat, *mem;
|
||||||
Uint16 vector;
|
|
||||||
Uint8 (*dei)(struct Device *d, Uint8);
|
Uint8 (*dei)(struct Device *d, Uint8);
|
||||||
void (*deo)(struct Device *d, Uint8);
|
void (*deo)(struct Device *d, Uint8);
|
||||||
} Device;
|
} Device;
|
||||||
|
|
|
@ -60,8 +60,6 @@ system_deo_special(Device *d, Uint8 port)
|
||||||
static void
|
static void
|
||||||
console_deo(Device *d, Uint8 port)
|
console_deo(Device *d, Uint8 port)
|
||||||
{
|
{
|
||||||
if(port == 0x1)
|
|
||||||
DEVPEEK16(d->vector, 0x0);
|
|
||||||
if(port > 0x7)
|
if(port > 0x7)
|
||||||
write(port - 0x7, (char *)&d->dat[port], 1);
|
write(port - 0x7, (char *)&d->dat[port], 1);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +73,8 @@ nil_dei(Device *d, Uint8 port)
|
||||||
static void
|
static void
|
||||||
nil_deo(Device *d, Uint8 port)
|
nil_deo(Device *d, Uint8 port)
|
||||||
{
|
{
|
||||||
if(port == 0x1) DEVPEEK16(d->vector, 0x0);
|
(void)d;
|
||||||
|
(void)port;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Generics
|
#pragma mark - Generics
|
||||||
|
@ -84,7 +83,7 @@ static int
|
||||||
console_input(Uxn *u, char c)
|
console_input(Uxn *u, char c)
|
||||||
{
|
{
|
||||||
devconsole->dat[0x2] = c;
|
devconsole->dat[0x2] = c;
|
||||||
return uxn_eval(u, devconsole->vector);
|
return uxn_eval(u, GETVECTOR(devconsole));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
11
src/uxnemu.c
11
src/uxnemu.c
|
@ -180,8 +180,6 @@ system_deo_special(Device *d, Uint8 port)
|
||||||
static void
|
static void
|
||||||
console_deo(Device *d, Uint8 port)
|
console_deo(Device *d, Uint8 port)
|
||||||
{
|
{
|
||||||
if(port == 0x1)
|
|
||||||
DEVPEEK16(d->vector, 0x0);
|
|
||||||
if(port > 0x7)
|
if(port > 0x7)
|
||||||
write(port - 0x7, (char *)&d->dat[port], 1);
|
write(port - 0x7, (char *)&d->dat[port], 1);
|
||||||
}
|
}
|
||||||
|
@ -228,7 +226,8 @@ nil_dei(Device *d, Uint8 port)
|
||||||
static void
|
static void
|
||||||
nil_deo(Device *d, Uint8 port)
|
nil_deo(Device *d, Uint8 port)
|
||||||
{
|
{
|
||||||
if(port == 0x1) DEVPEEK16(d->vector, 0x0);
|
(void)d;
|
||||||
|
(void)port;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Boot */
|
/* Boot */
|
||||||
|
@ -409,7 +408,7 @@ static int
|
||||||
console_input(Uxn *u, char c)
|
console_input(Uxn *u, char c)
|
||||||
{
|
{
|
||||||
devconsole->dat[0x2] = c;
|
devconsole->dat[0x2] = c;
|
||||||
return uxn_eval(u, devconsole->vector);
|
return uxn_eval(u, GETVECTOR(devconsole));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -483,8 +482,8 @@ run(Uxn *u)
|
||||||
console_input(u, event.cbutton.button);
|
console_input(u, event.cbutton.button);
|
||||||
}
|
}
|
||||||
if(devsystem->dat[0xe])
|
if(devsystem->dat[0xe])
|
||||||
uxn_eval(&supervisor, supervisor.dev[2].vector);
|
uxn_eval(&supervisor, GETVECTOR(&supervisor.dev[2]));
|
||||||
uxn_eval(u, devscreen->vector);
|
uxn_eval(u, GETVECTOR(devscreen));
|
||||||
if(uxn_screen.fg.changed || uxn_screen.bg.changed || devsystem->dat[0xe])
|
if(uxn_screen.fg.changed || uxn_screen.bg.changed || devsystem->dat[0xe])
|
||||||
redraw();
|
redraw();
|
||||||
if(!BENCH) {
|
if(!BENCH) {
|
||||||
|
|
Loading…
Reference in New Issue