Moved inspect in uxnemu.c

This commit is contained in:
neauoire 2021-07-30 14:38:08 -07:00
parent 616b9445d4
commit 7f345428d6
3 changed files with 45 additions and 46 deletions

View File

@ -12,24 +12,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE. WITH REGARD TO THIS SOFTWARE.
*/ */
static Uint8 font[][8] = {
{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}};
void void
clear(Ppu *p) clear(Ppu *p)
{ {
@ -98,33 +80,6 @@ putchr(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uin
/* output */ /* output */
void
inspect(Ppu *p, Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory)
{
Uint8 i, x, y, b;
for(i = 0; i < 0x20; ++i) { /* stack */
x = ((i % 8) * 3 + 1) * 8, y = (i / 8 + 1) * 8, b = stack[i];
puticn(p, &p->fg, x, y, font[(b >> 4) & 0xf], 1 + (wptr == i) * 0x7, 0, 0);
puticn(p, &p->fg, x + 8, y, font[b & 0xf], 1 + (wptr == i) * 0x7, 0, 0);
}
/* return pointer */
puticn(p, &p->fg, 0x8, y + 0x10, font[(rptr >> 4) & 0xf], 0x2, 0, 0);
puticn(p, &p->fg, 0x10, y + 0x10, font[rptr & 0xf], 0x2, 0, 0);
for(i = 0; i < 0x20; ++i) { /* memory */
x = ((i % 8) * 3 + 1) * 8, y = 0x38 + (i / 8 + 1) * 8, b = memory[i];
puticn(p, &p->fg, x, y, font[(b >> 4) & 0xf], 3, 0, 0);
puticn(p, &p->fg, x + 8, y, font[b & 0xf], 3, 0, 0);
}
for(x = 0; x < 0x10; ++x) { /* guides */
putpixel(p, &p->fg, x, p->height / 2, 2);
putpixel(p, &p->fg, p->width - x, p->height / 2, 2);
putpixel(p, &p->fg, p->width / 2, p->height - x, 2);
putpixel(p, &p->fg, p->width / 2, x, 2);
putpixel(p, &p->fg, p->width / 2 - 0x10 / 2 + x, p->height / 2, 2);
putpixel(p, &p->fg, p->width / 2, p->height / 2 - 0x10 / 2 + x, 2);
}
}
int int
initppu(Ppu *p, Uint8 hor, Uint8 ver) initppu(Ppu *p, Uint8 hor, Uint8 ver)
{ {

View File

@ -31,4 +31,3 @@ void putcolors(Ppu *p, Uint8 *addr);
void putpixel(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color); void putpixel(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color);
void puticn(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy); void puticn(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy);
void putchr(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy); void putchr(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy);
void inspect(Ppu *p, Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory);

View File

@ -35,6 +35,24 @@ static Uint32 stdin_event;
static Uint8 zoom = 0, reqdraw = 0, bench = 0; static Uint8 zoom = 0, reqdraw = 0, bench = 0;
static Uint8 font[][8] = {
{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}};
static int static int
clamp(int val, int min, int max) clamp(int val, int min, int max)
{ {
@ -61,6 +79,33 @@ audio_callback(void *u, Uint8 *stream, int len)
(void)u; (void)u;
} }
static void
inspect(Ppu *p, Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory)
{
Uint8 i, x, y, b;
for(i = 0; i < 0x20; ++i) { /* stack */
x = ((i % 8) * 3 + 1) * 8, y = (i / 8 + 1) * 8, b = stack[i];
puticn(p, &p->fg, x, y, font[(b >> 4) & 0xf], 1 + (wptr == i) * 0x7, 0, 0);
puticn(p, &p->fg, x + 8, y, font[b & 0xf], 1 + (wptr == i) * 0x7, 0, 0);
}
/* return pointer */
puticn(p, &p->fg, 0x8, y + 0x10, font[(rptr >> 4) & 0xf], 0x2, 0, 0);
puticn(p, &p->fg, 0x10, y + 0x10, font[rptr & 0xf], 0x2, 0, 0);
for(i = 0; i < 0x20; ++i) { /* memory */
x = ((i % 8) * 3 + 1) * 8, y = 0x38 + (i / 8 + 1) * 8, b = memory[i];
puticn(p, &p->fg, x, y, font[(b >> 4) & 0xf], 3, 0, 0);
puticn(p, &p->fg, x + 8, y, font[b & 0xf], 3, 0, 0);
}
for(x = 0; x < 0x10; ++x) { /* guides */
putpixel(p, &p->fg, x, p->height / 2, 2);
putpixel(p, &p->fg, p->width - x, p->height / 2, 2);
putpixel(p, &p->fg, p->width / 2, p->height - x, 2);
putpixel(p, &p->fg, p->width / 2, x, 2);
putpixel(p, &p->fg, p->width / 2 - 0x10 / 2 + x, p->height / 2, 2);
putpixel(p, &p->fg, p->width / 2, p->height / 2 - 0x10 / 2 + x, 2);
}
}
static void static void
redraw(Uxn *u) redraw(Uxn *u)
{ {