Added on-screen debugger
This commit is contained in:
parent
cb1dcd12eb
commit
9fd8b1709e
|
@ -24,7 +24,7 @@ static Uint8 blending[4][16] = {
|
||||||
{1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1},
|
{1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1},
|
||||||
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}};
|
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}};
|
||||||
|
|
||||||
static void
|
void
|
||||||
screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2)
|
screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2)
|
||||||
{
|
{
|
||||||
if(x1 > uxn_screen.width && x2 > x1) return;
|
if(x1 > uxn_screen.width && x2 > x1) return;
|
||||||
|
@ -129,6 +129,40 @@ screen_redraw(void)
|
||||||
uxn_screen.x1 = uxn_screen.y1 = uxn_screen.x2 = uxn_screen.y2 = 0;
|
uxn_screen.x1 = uxn_screen.y1 = uxn_screen.x2 = uxn_screen.y2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
|
Uint8 icons[] = {
|
||||||
|
0x00, 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10,
|
||||||
|
0x10, 0x00, 0x7c, 0x82, 0x02, 0x7c, 0x80, 0x80, 0xfe, 0x00, 0x7c, 0x82, 0x02, 0x1c, 0x02,
|
||||||
|
0x82, 0x7c, 0x00, 0x0c, 0x14, 0x24, 0x44, 0x84, 0xfe, 0x04, 0x00, 0xfe, 0x80, 0x80, 0x7c,
|
||||||
|
0x02, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x80, 0xfc, 0x82, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x02,
|
||||||
|
0x1e, 0x02, 0x02, 0x02, 0x00, 0x7c, 0x82, 0x82, 0x7c, 0x82, 0x82, 0x7c, 0x00, 0x7c, 0x82,
|
||||||
|
0x82, 0x7e, 0x02, 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x02, 0x7e, 0x82, 0x82, 0x7e, 0x00, 0xfc,
|
||||||
|
0x82, 0x82, 0xfc, 0x82, 0x82, 0xfc, 0x00, 0x7c, 0x82, 0x80, 0x80, 0x80, 0x82, 0x7c, 0x00,
|
||||||
|
0xfc, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x82, 0x7c,
|
||||||
|
0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x80, 0x80};
|
||||||
|
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
|
void
|
||||||
|
draw_byte(Uint8 v, Uint16 x, Uint16 y, Uint8 color)
|
||||||
|
{
|
||||||
|
screen_blit(uxn_screen.fg, icons, v >> 4 << 3, x, y, color, 0, 0, 0);
|
||||||
|
screen_blit(uxn_screen.fg, icons, (v & 0xf) << 3, x + 8, y, color, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
screen_debugger(Uxn *u)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < u->wst.ptr; i++)
|
||||||
|
draw_byte(u->wst.dat[i], i * 0x18 + 0x8, uxn_screen.height - 0x18, 0x2);
|
||||||
|
for(i = 0; i < u->rst.ptr; i++)
|
||||||
|
draw_byte(u->rst.dat[i], i * 0x18 + 0x8, uxn_screen.height - 0x10, 0x3);
|
||||||
|
for(i = 0; i < 0x40; i++)
|
||||||
|
draw_byte(u->ram[i], (i & 0x7) * 0x18 + 0x8, ((i >> 3) << 3) + 0x8, 1 + !!u->ram[i]);
|
||||||
|
}
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
screen_dei(Uxn *u, Uint8 addr)
|
screen_dei(Uxn *u, Uint8 addr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,8 @@ extern int emu_resize(int width, int height);
|
||||||
|
|
||||||
void screen_palette(Uint8 *addr);
|
void screen_palette(Uint8 *addr);
|
||||||
void screen_resize(Uint16 width, Uint16 height);
|
void screen_resize(Uint16 width, Uint16 height);
|
||||||
|
void screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2);
|
||||||
void screen_redraw(void);
|
void screen_redraw(void);
|
||||||
|
void screen_debugger(Uxn *u);
|
||||||
Uint8 screen_dei(Uxn *u, Uint8 addr);
|
Uint8 screen_dei(Uxn *u, Uint8 addr);
|
||||||
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
|
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
|
||||||
|
|
|
@ -12,7 +12,7 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define HALT(c) { return emu_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 FLIP { s = ins & 0x40 ? &u->wst : &u->rst; }
|
||||||
#define JUMP(x) { if(m2) pc = (x); else pc += (Sint8)(x); }
|
#define JUMP(x) { if(m2) pc = (x); else pc += (Sint8)(x); }
|
||||||
#define POKE(x, y) { if(m2) { POKE2(ram + x, y) } else { ram[(x)] = (y); } }
|
#define POKE(x, y) { if(m2) { POKE2(ram + x, y) } else { ram[(x)] = (y); } }
|
||||||
#define PEEK(o, x) { if(m2) { o = PEEK2(ram + x); } else o = ram[(x)]; }
|
#define PEEK(o, x) { if(m2) { o = PEEK2(ram + x); } else o = ram[(x)]; }
|
||||||
|
@ -23,7 +23,7 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
#define POP2(o) { if((tsp = *sp) <= 0x01) HALT(1) o = PEEK2(&s->dat[tsp - 2]); *sp = tsp - 2; }
|
#define POP2(o) { if((tsp = *sp) <= 0x01) HALT(1) o = PEEK2(&s->dat[tsp - 2]); *sp = tsp - 2; }
|
||||||
#define POPx(o) { if(m2) { POP2(o) } else { POP1(o) } }
|
#define POPx(o) { if(m2) { POP2(o) } else { POP1(o) } }
|
||||||
#define DEVW(p, y) { if(m2) { DEO(p, y >> 8) DEO((p + 1), y) } else { DEO(p, y) } }
|
#define DEVW(p, y) { if(m2) { DEO(p, y >> 8) DEO((p + 1), y) } else { DEO(p, y) } }
|
||||||
#define DEVR(o, p) { if(m2) { o = ((DEI(p) << 8) + DEI(p + 1)); } else { o = DEI(p); } }
|
#define DEVR(o, p) { if(m2) { o = DEI(p) << 8 | DEI(p + 1); } else { o = DEI(p); } }
|
||||||
|
|
||||||
int
|
int
|
||||||
uxn_eval(Uxn *u, Uint16 pc)
|
uxn_eval(Uxn *u, Uint16 pc)
|
||||||
|
@ -47,7 +47,7 @@ uxn_eval(Uxn *u, Uint16 pc)
|
||||||
case -0x2: /* JMI */ pc += PEEK2(ram + pc) + 2; break;
|
case -0x2: /* JMI */ pc += PEEK2(ram + pc) + 2; break;
|
||||||
case -0x3: /* JSI */ PUSH2(pc + 2) pc += PEEK2(ram + pc) + 2; break;
|
case -0x3: /* JSI */ PUSH2(pc + 2) pc += PEEK2(ram + pc) + 2; break;
|
||||||
case -0x4: /* LIT */
|
case -0x4: /* LIT */
|
||||||
case -0x6: /* LITr */ a = ram[pc++]; PUSH1(a) break;
|
case -0x6: /* LITr */ PUSH1(ram[pc++]) break;
|
||||||
case -0x5: /* LIT2 */
|
case -0x5: /* LIT2 */
|
||||||
case -0x7: /* LIT2r */ PUSH2(PEEK2(ram + pc)) pc += 2; break;
|
case -0x7: /* LIT2r */ PUSH2(PEEK2(ram + pc)) pc += 2; break;
|
||||||
/* ALU */
|
/* ALU */
|
||||||
|
|
|
@ -15,7 +15,7 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
|
|
||||||
#define POKE2(d, v) { (d)[0] = (v) >> 8; (d)[1] = (v); }
|
#define POKE2(d, v) { (d)[0] = (v) >> 8; (d)[1] = (v); }
|
||||||
#define PEEK2(d) ((d)[0] << 8 | (d)[1])
|
#define PEEK2(d) ((d)[0] << 8 | (d)[1])
|
||||||
#define DEO(p, value) { u->dev[p] = value; if((deo_mask[p >> 4] >> (p & 0xf)) & 0x1) emu_deo(u, p); }
|
#define DEO(p, v) { u->dev[p] = v; if((deo_mask[p >> 4] >> (p & 0xf)) & 0x1) emu_deo(u, p); }
|
||||||
#define DEI(p) ((dei_mask[(p) >> 4] >> ((p) & 0xf)) & 0x1 ? emu_dei(u, (p)) : u->dev[(p)])
|
#define DEI(p) ((dei_mask[(p) >> 4] >> ((p) & 0xf)) & 0x1 ? emu_dei(u, (p)) : u->dev[(p)])
|
||||||
|
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
|
@ -143,7 +143,7 @@ emu_event(Uxn *u)
|
||||||
char buf[7];
|
char buf[7];
|
||||||
XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
|
XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
|
||||||
if(sym == XK_F2)
|
if(sym == XK_F2)
|
||||||
system_inspect(u);
|
u->dev[0x0e] = !u->dev[0x0e];
|
||||||
if(sym == XK_F4)
|
if(sym == XK_F4)
|
||||||
if(!emu_start(u, "boot.rom"))
|
if(!emu_start(u, "boot.rom"))
|
||||||
emu_start(u, rom_path);
|
emu_start(u, rom_path);
|
||||||
|
@ -247,6 +247,8 @@ main(int argc, char **argv)
|
||||||
if(uxn_screen.x2) {
|
if(uxn_screen.x2) {
|
||||||
int x1 = uxn_screen.x1, y1 = uxn_screen.y1, x2 = uxn_screen.x2, y2 = uxn_screen.y2;
|
int x1 = uxn_screen.x1, y1 = uxn_screen.y1, x2 = uxn_screen.x2, y2 = uxn_screen.y2;
|
||||||
screen_redraw();
|
screen_redraw();
|
||||||
|
if(u.dev[0x0e])
|
||||||
|
screen_debugger(&u);
|
||||||
XPutImage(display, window, DefaultGC(display, 0), ximage, x1, y1, x1 + PAD, y1 + PAD, x2 - x1, y2 - y1);
|
XPutImage(display, window, DefaultGC(display, 0), ximage, x1, y1, x1 + PAD, y1 + PAD, x2 - x1, y2 - y1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue