Emulator functions prefixed with emu_ instead of uxn_
This commit is contained in:
parent
ec973c2ea6
commit
867883409e
|
@ -96,27 +96,6 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port)
|
|||
}
|
||||
}
|
||||
|
||||
/* Errors */
|
||||
|
||||
int
|
||||
uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr)
|
||||
{
|
||||
Uint8 *d = &u->dev[0];
|
||||
Uint16 handler = PEEK2(d);
|
||||
if(handler) {
|
||||
u->wst.ptr = 4;
|
||||
u->wst.dat[0] = addr >> 0x8;
|
||||
u->wst.dat[1] = addr & 0xff;
|
||||
u->wst.dat[2] = instr;
|
||||
u->wst.dat[3] = err;
|
||||
return uxn_eval(u, handler);
|
||||
} else {
|
||||
system_inspect(u);
|
||||
fprintf(stderr, "%s %s, by %02x at 0x%04x.\n", (instr & 0x40) ? "Return-stack" : "Working-stack", errors[err - 1], instr, addr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Console */
|
||||
|
||||
int
|
||||
|
@ -142,3 +121,24 @@ console_deo(Uint8 *d, Uint8 port)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Errors */
|
||||
|
||||
int
|
||||
emu_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr)
|
||||
{
|
||||
Uint8 *d = &u->dev[0];
|
||||
Uint16 handler = PEEK2(d);
|
||||
if(handler) {
|
||||
u->wst.ptr = 4;
|
||||
u->wst.dat[0] = addr >> 0x8;
|
||||
u->wst.dat[1] = addr & 0xff;
|
||||
u->wst.dat[2] = instr;
|
||||
u->wst.dat[3] = err;
|
||||
return uxn_eval(u, handler);
|
||||
} else {
|
||||
system_inspect(u);
|
||||
fprintf(stderr, "%s %s, by %02x at 0x%04x.\n", (instr & 0x40) ? "Return-stack" : "Working-stack", errors[err - 1], instr, addr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -25,13 +25,13 @@ WITH REGARD TO THIS SOFTWARE.
|
|||
#define N2 PEEK2(s->dat + s->ptr - 4)
|
||||
#define L2 PEEK2(s->dat + s->ptr - 6)
|
||||
|
||||
#define HALT(c) { return uxn_halt(u, ins, (c), pc - 1); }
|
||||
#define HALT(c) { return emu_halt(u, ins, (c), pc - 1); }
|
||||
#define FLIP { s = ins & 0x40 ? &u->wst : &u->rst; }
|
||||
#define SET(x, y) { if(x > s->ptr) HALT(1) tmp = (x & k) + y + s->ptr; if(tmp > 254) HALT(2) s->ptr = tmp; }
|
||||
#define PUT(o, v) { s->dat[(s->ptr - 1 - (o))] = (v); }
|
||||
#define PUT2(o, v) { tmp = (v); POKE2(s->dat + (s->ptr - o - 2), tmp); }
|
||||
#define DEO(a, b) { u->dev[(a)] = (b); if((deo_mask[(a) >> 4] >> ((a) & 0xf)) & 0x1) uxn_deo(u, (a)); }
|
||||
#define DEI(a, b) { PUT((a), ((dei_mask[(b) >> 4] >> ((b) & 0xf)) & 0x1) ? uxn_dei(u, (b)) : u->dev[(b)]) }
|
||||
#define DEO(a, b) { u->dev[(a)] = (b); if((deo_mask[(a) >> 4] >> ((a) & 0xf)) & 0x1) emu_deo(u, (a)); }
|
||||
#define DEI(a, b) { PUT((a), ((dei_mask[(b) >> 4] >> ((b) & 0xf)) & 0x1) ? emu_dei(u, (b)) : u->dev[(b)]) }
|
||||
|
||||
int
|
||||
uxn_eval(Uxn *u, Uint16 pc)
|
||||
|
|
|
@ -37,9 +37,9 @@ typedef struct Uxn {
|
|||
|
||||
/* required functions */
|
||||
|
||||
extern Uint8 uxn_dei(Uxn *u, Uint8 addr);
|
||||
extern void uxn_deo(Uxn *u, Uint8 addr);
|
||||
extern int uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr);
|
||||
extern Uint8 emu_dei(Uxn *u, Uint8 addr);
|
||||
extern void emu_deo(Uxn *u, Uint8 addr);
|
||||
extern int emu_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr);
|
||||
extern Uint16 dei_mask[];
|
||||
extern Uint16 deo_mask[];
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Uint16 deo_mask[] = {0xc028, 0x0300, 0xc028, 0x8000, 0x8000, 0x8000, 0x8000, 0x0
|
|||
Uint16 dei_mask[] = {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07ff, 0x0000, 0x0000, 0x0000};
|
||||
|
||||
Uint8
|
||||
uxn_dei(Uxn *u, Uint8 addr)
|
||||
emu_dei(Uxn *u, Uint8 addr)
|
||||
{
|
||||
switch(addr & 0xf0) {
|
||||
case 0xc0: return datetime_dei(u, addr);
|
||||
|
@ -30,7 +30,7 @@ uxn_dei(Uxn *u, Uint8 addr)
|
|||
}
|
||||
|
||||
void
|
||||
uxn_deo(Uxn *u, Uint8 addr)
|
||||
emu_deo(Uxn *u, Uint8 addr)
|
||||
{
|
||||
Uint8 p = addr & 0x0f, d = addr & 0xf0;
|
||||
switch(d) {
|
||||
|
|
|
@ -84,7 +84,7 @@ audio_deo(int instance, Uint8 *d, Uint8 port, Uxn *u)
|
|||
}
|
||||
|
||||
Uint8
|
||||
uxn_dei(Uxn *u, Uint8 addr)
|
||||
emu_dei(Uxn *u, Uint8 addr)
|
||||
{
|
||||
Uint8 p = addr & 0x0f, d = addr & 0xf0;
|
||||
switch(d) {
|
||||
|
@ -99,7 +99,7 @@ uxn_dei(Uxn *u, Uint8 addr)
|
|||
}
|
||||
|
||||
void
|
||||
uxn_deo(Uxn *u, Uint8 addr)
|
||||
emu_deo(Uxn *u, Uint8 addr)
|
||||
{
|
||||
Uint8 p = addr & 0x0f, d = addr & 0xf0;
|
||||
switch(d) {
|
||||
|
@ -165,7 +165,9 @@ set_window_size(SDL_Window *window, int w, int h)
|
|||
SDL_SetWindowSize(window, w, h);
|
||||
}
|
||||
|
||||
int emu_resize(void){
|
||||
int
|
||||
emu_resize(void)
|
||||
{
|
||||
if(emu_texture != NULL)
|
||||
SDL_DestroyTexture(emu_texture);
|
||||
SDL_RenderSetLogicalSize(emu_renderer, uxn_screen.width, uxn_screen.height);
|
||||
|
|
Loading…
Reference in New Issue