Housekeeping
This commit is contained in:
parent
2a179c94de
commit
aed26e5bd0
|
@ -2,8 +2,7 @@
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2021 Devine Lu Linvega
|
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||||
Copyright (c) 2021 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
|
||||||
|
@ -40,13 +39,3 @@ controller_key(Uxn *u, Uint8 *d, Uint8 key)
|
||||||
d[3] = 0x00;
|
d[3] = 0x00;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
controller_special(Uxn *u, Uint8 *d, Uint8 key)
|
|
||||||
{
|
|
||||||
if(key) {
|
|
||||||
d[4] = key;
|
|
||||||
uxn_eval(u, GETVEC(d));
|
|
||||||
d[4] = 0x00;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2021 Devine Lu Linvega
|
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||||
Copyright (c) 2021 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
|
||||||
|
@ -13,4 +12,3 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
void controller_down(Uxn *u, Uint8 *d, Uint8 mask);
|
void controller_down(Uxn *u, Uint8 *d, Uint8 mask);
|
||||||
void controller_up(Uxn *u, Uint8 *d, Uint8 mask);
|
void controller_up(Uxn *u, Uint8 *d, Uint8 mask);
|
||||||
void controller_key(Uxn *u, Uint8 *d, Uint8 key);
|
void controller_key(Uxn *u, Uint8 *d, Uint8 key);
|
||||||
void controller_special(Uxn *u, Uint8 *d, Uint8 key);
|
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
#include "datetime.h"
|
#include "datetime.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2021 Devine Lu Linvega
|
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||||
Copyright (c) 2021 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
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2021 Devine Lu Linvega
|
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||||
Copyright (c) 2021 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
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2021 Devine Lu Linvega
|
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||||
Copyright (c) 2021 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
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2021 Devine Lu Linvega
|
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||||
Copyright (c) 2021 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
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2021 Devine Lu Linvega
|
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||||
Copyright (c) 2021 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
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2021 Devine Lu Linvega
|
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||||
Copyright (c) 2021 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
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2021 Devine Lu Linvega
|
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||||
Copyright (c) 2021 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
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2021 Devine Lu Linvega
|
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||||
Copyright (c) 2021 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
|
||||||
|
|
10
src/uxn.c
10
src/uxn.c
|
@ -24,7 +24,7 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
#define PEEK(o, x) { if(bs) { PEEK16(o, x) } else { o = u->ram[(x)]; } }
|
#define PEEK(o, x) { if(bs) { PEEK16(o, x) } else { o = u->ram[(x)]; } }
|
||||||
#define DEVR(o, x) { o = u->dei(u, x); if (bs) o = (o << 8) + u->dei(u, ((x) + 1) & 0xFF); }
|
#define DEVR(o, x) { o = u->dei(u, x); if (bs) o = (o << 8) + u->dei(u, ((x) + 1) & 0xFF); }
|
||||||
#define DEVW(x, y) { if (bs) { u->deo(u, (x), (y) >> 8); u->deo(u, ((x) + 1) & 0xFF, (y)); } else { u->deo(u, x, (y)); } }
|
#define DEVW(x, y) { if (bs) { u->deo(u, (x), (y) >> 8); u->deo(u, ((x) + 1) & 0xFF, (y)); } else { u->deo(u, x, (y)); } }
|
||||||
#define WARP(x) { if(bs) pc = (x); else pc += (Sint8)(x); }
|
#define JUMP(x) { if(bs) pc = (x); else pc += (Sint8)(x); }
|
||||||
|
|
||||||
int
|
int
|
||||||
uxn_eval(Uxn *u, Uint16 pc)
|
uxn_eval(Uxn *u, Uint16 pc)
|
||||||
|
@ -65,9 +65,9 @@ uxn_eval(Uxn *u, Uint16 pc)
|
||||||
case 0x09: /* NEQ */ POP(a) POP(b) PUSH8(src, b != a) break;
|
case 0x09: /* NEQ */ POP(a) POP(b) PUSH8(src, b != a) break;
|
||||||
case 0x0a: /* GTH */ POP(a) POP(b) PUSH8(src, b > a) break;
|
case 0x0a: /* GTH */ POP(a) POP(b) PUSH8(src, b > a) break;
|
||||||
case 0x0b: /* LTH */ POP(a) POP(b) PUSH8(src, b < a) break;
|
case 0x0b: /* LTH */ POP(a) POP(b) PUSH8(src, b < a) break;
|
||||||
case 0x0c: /* JMP */ POP(a) WARP(a) break;
|
case 0x0c: /* JMP */ POP(a) JUMP(a) break;
|
||||||
case 0x0d: /* JCN */ POP(a) POP8(b) if(b) WARP(a) break;
|
case 0x0d: /* JCN */ POP(a) POP8(b) if(b) JUMP(a) break;
|
||||||
case 0x0e: /* JSR */ POP(a) PUSH16(dst, pc) WARP(a) break;
|
case 0x0e: /* JSR */ POP(a) PUSH16(dst, pc) JUMP(a) break;
|
||||||
case 0x0f: /* STH */ POP(a) PUSH(dst, a) break;
|
case 0x0f: /* STH */ POP(a) PUSH(dst, a) break;
|
||||||
/* Memory */
|
/* Memory */
|
||||||
case 0x10: /* LDZ */ POP8(a) PEEK(b, a) PUSH(src, b) break;
|
case 0x10: /* LDZ */ POP8(a) PEEK(b, a) PUSH(src, b) break;
|
||||||
|
@ -86,7 +86,7 @@ uxn_eval(Uxn *u, Uint16 pc)
|
||||||
case 0x1c: /* AND */ POP(a) POP(b) PUSH(src, b & a) break;
|
case 0x1c: /* AND */ POP(a) POP(b) PUSH(src, b & a) break;
|
||||||
case 0x1d: /* ORA */ POP(a) POP(b) PUSH(src, b | a) break;
|
case 0x1d: /* ORA */ POP(a) POP(b) PUSH(src, b | a) break;
|
||||||
case 0x1e: /* EOR */ POP(a) POP(b) PUSH(src, b ^ a) break;
|
case 0x1e: /* EOR */ POP(a) POP(b) PUSH(src, b ^ a) break;
|
||||||
case 0x1f: /* SFT */ POP8(a) POP(b) c = b >> (a & 0x0f) << ((a & 0xf0) >> 4); PUSH(src, c) break;
|
case 0x1f: /* SFT */ POP8(a) POP(b) PUSH(src, b >> (a & 0x0f) << ((a & 0xf0) >> 4)) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -32,10 +32,10 @@ typedef struct {
|
||||||
typedef struct Uxn {
|
typedef struct Uxn {
|
||||||
Uint8 *ram, *dev;
|
Uint8 *ram, *dev;
|
||||||
Stack *wst, *rst;
|
Stack *wst, *rst;
|
||||||
Uint8 (*dei)(struct Uxn *u, Uint8 address);
|
Uint8 (*dei)(struct Uxn *u, Uint8 addr);
|
||||||
void (*deo)(struct Uxn *u, Uint8 address, Uint8 value);
|
void (*deo)(struct Uxn *u, Uint8 addr, Uint8 value);
|
||||||
} Uxn;
|
} Uxn;
|
||||||
|
|
||||||
int uxn_boot(Uxn *u, Uint8 *ram);
|
int uxn_boot(Uxn *u, Uint8 *ram);
|
||||||
int uxn_eval(Uxn *u, Uint16 pc);
|
int uxn_eval(Uxn *u, Uint16 pc);
|
||||||
int uxn_halt(Uxn *u, Uint8 error, Uint16 addr);
|
int uxn_halt(Uxn *u, Uint8 err, Uint16 addr);
|
||||||
|
|
19
src/uxn11.c
19
src/uxn11.c
|
@ -15,6 +15,17 @@
|
||||||
#include "devices/file.h"
|
#include "devices/file.h"
|
||||||
#include "devices/datetime.h"
|
#include "devices/datetime.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2022 Devine Lu Linvega
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
static XImage *ximage;
|
static XImage *ximage;
|
||||||
static Display *display;
|
static Display *display;
|
||||||
static Visual *visual;
|
static Visual *visual;
|
||||||
|
@ -81,7 +92,7 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
emu_redraw(void)
|
emu_draw(void)
|
||||||
{
|
{
|
||||||
screen_redraw(&uxn_screen, uxn_screen.pixels);
|
screen_redraw(&uxn_screen, uxn_screen.pixels);
|
||||||
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, 0, 0, uxn_screen.width, uxn_screen.height);
|
XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, 0, 0, uxn_screen.width, uxn_screen.height);
|
||||||
|
@ -142,7 +153,7 @@ emu_event(Uxn *u)
|
||||||
XNextEvent(display, &ev);
|
XNextEvent(display, &ev);
|
||||||
switch(ev.type) {
|
switch(ev.type) {
|
||||||
case Expose:
|
case Expose:
|
||||||
emu_redraw();
|
emu_draw();
|
||||||
break;
|
break;
|
||||||
case ClientMessage: {
|
case ClientMessage: {
|
||||||
XDestroyImage(ximage);
|
XDestroyImage(ximage);
|
||||||
|
@ -213,7 +224,6 @@ main(int argc, char **argv)
|
||||||
char expirations[8];
|
char expirations[8];
|
||||||
struct pollfd fds[2];
|
struct pollfd fds[2];
|
||||||
static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
|
static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
|
||||||
/* TODO: Try loading launcher.rom if present */
|
|
||||||
if(argc < 2)
|
if(argc < 2)
|
||||||
return emu_error("Usage", "uxncli game.rom args");
|
return emu_error("Usage", "uxncli game.rom args");
|
||||||
/* start sequence */
|
/* start sequence */
|
||||||
|
@ -227,6 +237,7 @@ main(int argc, char **argv)
|
||||||
while(*p) console_input(&u, *p++);
|
while(*p) console_input(&u, *p++);
|
||||||
console_input(&u, '\n');
|
console_input(&u, '\n');
|
||||||
}
|
}
|
||||||
|
/* timer */
|
||||||
fds[0].fd = XConnectionNumber(display);
|
fds[0].fd = XConnectionNumber(display);
|
||||||
fds[1].fd = timerfd_create(CLOCK_MONOTONIC, 0);
|
fds[1].fd = timerfd_create(CLOCK_MONOTONIC, 0);
|
||||||
timerfd_settime(fds[1].fd, 0, &screen_tspec, NULL);
|
timerfd_settime(fds[1].fd, 0, &screen_tspec, NULL);
|
||||||
|
@ -242,7 +253,7 @@ main(int argc, char **argv)
|
||||||
uxn_eval(&u, GETVEC(&u.dev[0x20])); /* Call the vector once, even if the timer fired multiple times */
|
uxn_eval(&u, GETVEC(&u.dev[0x20])); /* Call the vector once, even if the timer fired multiple times */
|
||||||
}
|
}
|
||||||
if(uxn_screen.fg.changed || uxn_screen.bg.changed)
|
if(uxn_screen.fg.changed || uxn_screen.bg.changed)
|
||||||
emu_redraw();
|
emu_draw();
|
||||||
}
|
}
|
||||||
XDestroyImage(ximage);
|
XDestroyImage(ximage);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue