Minor cleanup

This commit is contained in:
neauoire 2021-04-04 20:35:52 -07:00
parent 7529e119cd
commit 3dafa868cb
4 changed files with 9 additions and 9 deletions

View File

@ -28,7 +28,7 @@ else
fi
echo "Assembling.."
./bin/assembler projects/examples/dev.audio.usm bin/boot.rom
./bin/assembler projects/examples/dev.controller.usm bin/boot.rom
echo "Running.."
if [ "${2}" = '--cli' ];

View File

@ -99,6 +99,12 @@ setflag(Uint8 *a, char flag, int b)
*a &= (~flag);
}
int
getflag(Uint8 *a, char flag)
{
return *a & flag;
}
#pragma mark - Paint
void

View File

@ -16,15 +16,12 @@ WITH REGARD TO THIS SOFTWARE.
#pragma mark - Operations
/* clang-format off */
int getflag(Uint8 *a, char flag) { return *a & flag; }
Uint8 devpoke8(Uxn *u, Uint8 id, Uint8 b0, Uint8 b1){ return id < 0x10 ? u->dev[id].poke(u, PAGE_DEVICE + id * 0x10, b0, b1) : b1; }
void push8(Stack *s, Uint8 a) { if (s->ptr == 0xff) { s->error = 2; return; } s->dat[s->ptr++] = a; }
Uint8 pop8(Stack *s) { if (s->ptr == 0) { s->error = 1; return 0; } return s->dat[--s->ptr]; }
Uint8 peek8(Stack *s, Uint8 a) { if (s->ptr < a + 1) s->error = 1; return s->dat[s->ptr - a - 1]; }
void mempoke8(Uxn *u, Uint16 a, Uint8 b) { u->ram.dat[a] = (a & 0xff00) == PAGE_DEVICE ? devpoke8(u, (a & 0xff) >> 4, a & 0xf, b) : b; }
Uint8 mempeek8(Uxn *u, Uint16 a) { return u->ram.dat[a]; }
void push16(Stack *s, Uint16 a) { push8(s, a >> 8); push8(s, a); }
Uint16 pop16(Stack *s) { return pop8(s) + (pop8(s) << 8); }
Uint16 peek16(Stack *s, Uint8 a) { return peek8(s, a * 2) + (peek8(s, a * 2 + 1) << 8); }
@ -118,6 +115,7 @@ int
haltuxn(Uxn *u, char *name, int id)
{
printf("Halted: %s#%04x, at 0x%04x\n", name, id, u->ram.ptr);
u->ram.ptr = 0;
return 0;
}
@ -148,8 +146,7 @@ evaluxn(Uxn *u, Uint16 vec)
u->wst.error = 0;
u->rst.error = 0;
while(u->ram.ptr) {
Uint8 instr = u->ram.dat[u->ram.ptr++];
if(!stepuxn(u, instr))
if(!stepuxn(u, u->ram.dat[u->ram.ptr++]))
return 0;
}
return 1;

View File

@ -16,8 +16,6 @@ typedef signed char Sint8;
typedef unsigned short Uint16;
typedef signed short Sint16;
#define FLAG_LIT1 0x04
#define FLAG_LIT2 0x08
#define PAGE_DEVICE 0x0100
#define PAGE_VECTORS 0x0200
@ -44,7 +42,6 @@ typedef struct Uxn {
Device dev[16];
} Uxn;
int getflag(Uint8 *status, char flag);
int loaduxn(Uxn *c, char *filepath);
int bootuxn(Uxn *c);
int evaluxn(Uxn *u, Uint16 vec);