Housekeeping

This commit is contained in:
Devine Lu Linvega 2023-01-01 13:40:58 -08:00
parent bf4ee03d27
commit 794ce1bdfd
4 changed files with 4 additions and 21 deletions

View File

@ -41,14 +41,10 @@ int
uxn_eval(Uxn *u, Uint16 pc) uxn_eval(Uxn *u, Uint16 pc)
{ {
unsigned int a, b, c, j, k, bs, instr, errcode; unsigned int a, b, c, j, k, bs, instr, errcode;
unsigned int limit = LIMIT;
Uint8 kptr, *sp; Uint8 kptr, *sp;
Stack *src, *dst; Stack *src, *dst;
if(!pc || u->devold[0].dat[0xf]) return 0; if(!pc || u->dev[0x0f]) return 0;
while((instr = u->ram[pc++])) { while((instr = u->ram[pc++])) {
if(!limit--) {
limit = LIMIT;
}
/* Return Mode */ /* Return Mode */
if(instr & 0x40) { if(instr & 0x40) {
src = u->rst; dst = u->wst; src = u->rst; dst = u->wst;
@ -125,13 +121,3 @@ uxn_boot(Uxn *u, Uint8 *ram, Dei *dei, Deo *deo)
u->deo = deo; u->deo = deo;
return 1; return 1;
} }
Device *
uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *d, Uint8 port), void (*deofn)(Device *d, Uint8 port))
{
Device *d = &u->devold[id];
d->u = u;
d->dei = deifn;
d->deo = deofn;
return d;
}

View File

@ -53,7 +53,6 @@ typedef struct {
typedef struct Uxn { typedef struct Uxn {
Uint8 *ram, *dev; Uint8 *ram, *dev;
Stack *wst, *rst; Stack *wst, *rst;
Device devold[16];
Uint8 (*dei)(struct Uxn *u, Uint8 addr); Uint8 (*dei)(struct Uxn *u, Uint8 addr);
void (*deo)(struct Uxn *u, Uint8 addr, Uint8 value); void (*deo)(struct Uxn *u, Uint8 addr, Uint8 value);
} Uxn; } Uxn;

View File

@ -451,12 +451,12 @@ review(char *filename)
static void static void
writesym(char *filename) writesym(char *filename)
{ {
int i;
char symdst[0x60]; char symdst[0x60];
FILE *fp; FILE *fp;
if(slen(filename) > 0x60 - 5) if(slen(filename) > 0x60 - 5)
return; return;
fp = fopen(scat(scpy(filename, symdst, slen(filename) + 1), ".sym"), "w"); fp = fopen(scat(scpy(filename, symdst, slen(filename) + 1), ".sym"), "w");
int i;
if(fp != NULL) { if(fp != NULL) {
for(i = 0; i < p.llen; i++) { for(i = 0; i < p.llen; i++) {
fwrite(&p.labels[i].addr + 1, 1, 1, fp); fwrite(&p.labels[i].addr + 1, 1, 1, fp);

View File

@ -48,7 +48,7 @@ static SDL_Thread *stdin_thread;
/* devices */ /* devices */
static Device *devscreen, *devaudio0; static Device *devaudio0;
static Uint8 zoom = 1; static Uint8 zoom = 1;
static Uint32 stdin_event, audio0_event; static Uint32 stdin_event, audio0_event;
static Uint64 exec_deadline, deadline_interval, ms_interval; static Uint64 exec_deadline, deadline_interval, ms_interval;
@ -213,7 +213,6 @@ static void
emu_deo(Uxn *u, Uint8 addr, Uint8 v) emu_deo(Uxn *u, Uint8 addr, Uint8 v)
{ {
Uint8 p = addr & 0x0f, d = addr & 0xf0; Uint8 p = addr & 0x0f, d = addr & 0xf0;
Uint16 mask = 0x1 << (d >> 4);
u->dev[addr] = v; u->dev[addr] = v;
switch(d) { switch(d) {
case 0x00: case 0x00:
@ -450,11 +449,10 @@ handle_events(Uxn *u)
static int static int
run(Uxn *u) run(Uxn *u)
{ {
Device *devsys = &u->devold[0];
Uint64 now = SDL_GetPerformanceCounter(), frame_end, frame_interval = SDL_GetPerformanceFrequency() / 60; Uint64 now = SDL_GetPerformanceCounter(), frame_end, frame_interval = SDL_GetPerformanceFrequency() / 60;
for(;;) { for(;;) {
/* .System/halt */ /* .System/halt */
if(devsys->dat[0xf]) if(u->dev[0x0f])
return error("Run", "Ended."); return error("Run", "Ended.");
frame_end = now + frame_interval; frame_end = now + frame_interval;
exec_deadline = now + deadline_interval; exec_deadline = now + deadline_interval;