| ... | ... |
@@ -19,6 +19,24 @@ static Uint8 blending[5][16] = {
|
| 19 | 19 |
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2},
|
| 20 | 20 |
{1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0}};
|
| 21 | 21 |
|
| 22 |
+static Uint8 font[][8] = {
|
|
| 23 |
+ {0x00, 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c},
|
|
| 24 |
+ {0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
|
|
| 25 |
+ {0x00, 0x7c, 0x82, 0x02, 0x7c, 0x80, 0x80, 0xfe},
|
|
| 26 |
+ {0x00, 0x7c, 0x82, 0x02, 0x1c, 0x02, 0x82, 0x7c},
|
|
| 27 |
+ {0x00, 0x0c, 0x14, 0x24, 0x44, 0x84, 0xfe, 0x04},
|
|
| 28 |
+ {0x00, 0xfe, 0x80, 0x80, 0x7c, 0x02, 0x82, 0x7c},
|
|
| 29 |
+ {0x00, 0x7c, 0x82, 0x80, 0xfc, 0x82, 0x82, 0x7c},
|
|
| 30 |
+ {0x00, 0x7c, 0x82, 0x02, 0x1e, 0x02, 0x02, 0x02},
|
|
| 31 |
+ {0x00, 0x7c, 0x82, 0x82, 0x7c, 0x82, 0x82, 0x7c},
|
|
| 32 |
+ {0x00, 0x7c, 0x82, 0x82, 0x7e, 0x02, 0x82, 0x7c},
|
|
| 33 |
+ {0x00, 0x7c, 0x82, 0x02, 0x7e, 0x82, 0x82, 0x7e},
|
|
| 34 |
+ {0x00, 0xfc, 0x82, 0x82, 0xfc, 0x82, 0x82, 0xfc},
|
|
| 35 |
+ {0x00, 0x7c, 0x82, 0x80, 0x80, 0x80, 0x82, 0x7c},
|
|
| 36 |
+ {0x00, 0xfc, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfc},
|
|
| 37 |
+ {0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x82, 0x7c},
|
|
| 38 |
+ {0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x80, 0x80}};
|
|
| 39 |
+ |
|
| 22 | 40 |
void |
| 23 | 41 |
ppu_set_size(Ppu *p, Uint16 width, Uint16 height) |
| 24 | 42 |
{
|
| ... | ... |
@@ -94,3 +112,32 @@ ppu_2bpp(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Ui |
| 94 | 112 |
blending[ch][color]); |
| 95 | 113 |
} |
| 96 | 114 |
} |
| 115 |
+ |
|
| 116 |
+void |
|
| 117 |
+ppu_debug(Ppu *p, Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory) |
|
| 118 |
+{
|
|
| 119 |
+ Uint8 i, x, y, b; |
|
| 120 |
+ for(i = 0; i < 0x20; ++i) {
|
|
| 121 |
+ x = ((i % 8) * 3 + 1) * 8, y = (i / 8 + 1) * 8, b = stack[i]; |
|
| 122 |
+ /* working stack */ |
|
| 123 |
+ ppu_1bpp(p, 1, x, y, font[(b >> 4) & 0xf], 1 + (wptr == i) * 0x7, 0, 0); |
|
| 124 |
+ ppu_1bpp(p, 1, x + 8, y, font[b & 0xf], 1 + (wptr == i) * 0x7, 0, 0); |
|
| 125 |
+ y = 0x28 + (i / 8 + 1) * 8; |
|
| 126 |
+ b = memory[i]; |
|
| 127 |
+ /* return stack */ |
|
| 128 |
+ ppu_1bpp(p, 1, x, y, font[(b >> 4) & 0xf], 3, 0, 0); |
|
| 129 |
+ ppu_1bpp(p, 1, x + 8, y, font[b & 0xf], 3, 0, 0); |
|
| 130 |
+ } |
|
| 131 |
+ /* return pointer */ |
|
| 132 |
+ ppu_1bpp(p, 1, 0x8, y + 0x10, font[(rptr >> 4) & 0xf], 0x2, 0, 0); |
|
| 133 |
+ ppu_1bpp(p, 1, 0x10, y + 0x10, font[rptr & 0xf], 0x2, 0, 0); |
|
| 134 |
+ /* guides */ |
|
| 135 |
+ for(x = 0; x < 0x10; ++x) {
|
|
| 136 |
+ ppu_write(p, 1, x, p->height / 2, 2); |
|
| 137 |
+ ppu_write(p, 1, p->width - x, p->height / 2, 2); |
|
| 138 |
+ ppu_write(p, 1, p->width / 2, p->height - x, 2); |
|
| 139 |
+ ppu_write(p, 1, p->width / 2, x, 2); |
|
| 140 |
+ ppu_write(p, 1, p->width / 2 - 0x10 / 2 + x, p->height / 2, 2); |
|
| 141 |
+ ppu_write(p, 1, p->width / 2, p->height / 2 - 0x10 / 2 + x, 2); |
|
| 142 |
+ } |
|
| 143 |
+} |
| ... | ... |
@@ -29,3 +29,4 @@ void ppu_write(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 color); |
| 29 | 29 |
void ppu_frame(Ppu *p); |
| 30 | 30 |
void ppu_1bpp(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy); |
| 31 | 31 |
void ppu_2bpp(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy); |
| 32 |
+void ppu_debug(Ppu *p, Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory); |
| ... | ... |
@@ -40,24 +40,6 @@ static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0, *devconso |
| 40 | 40 |
static Uint8 zoom = 1; |
| 41 | 41 |
static Uint32 *ppu_screen, stdin_event, audio0_event, palette[16]; |
| 42 | 42 |
|
| 43 |
-static Uint8 font[][8] = {
|
|
| 44 |
- {0x00, 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c},
|
|
| 45 |
- {0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
|
|
| 46 |
- {0x00, 0x7c, 0x82, 0x02, 0x7c, 0x80, 0x80, 0xfe},
|
|
| 47 |
- {0x00, 0x7c, 0x82, 0x02, 0x1c, 0x02, 0x82, 0x7c},
|
|
| 48 |
- {0x00, 0x0c, 0x14, 0x24, 0x44, 0x84, 0xfe, 0x04},
|
|
| 49 |
- {0x00, 0xfe, 0x80, 0x80, 0x7c, 0x02, 0x82, 0x7c},
|
|
| 50 |
- {0x00, 0x7c, 0x82, 0x80, 0xfc, 0x82, 0x82, 0x7c},
|
|
| 51 |
- {0x00, 0x7c, 0x82, 0x02, 0x1e, 0x02, 0x02, 0x02},
|
|
| 52 |
- {0x00, 0x7c, 0x82, 0x82, 0x7c, 0x82, 0x82, 0x7c},
|
|
| 53 |
- {0x00, 0x7c, 0x82, 0x82, 0x7e, 0x02, 0x82, 0x7c},
|
|
| 54 |
- {0x00, 0x7c, 0x82, 0x02, 0x7e, 0x82, 0x82, 0x7e},
|
|
| 55 |
- {0x00, 0xfc, 0x82, 0x82, 0xfc, 0x82, 0x82, 0xfc},
|
|
| 56 |
- {0x00, 0x7c, 0x82, 0x80, 0x80, 0x80, 0x82, 0x7c},
|
|
| 57 |
- {0x00, 0xfc, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfc},
|
|
| 58 |
- {0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x82, 0x7c},
|
|
| 59 |
- {0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x80, 0x80}};
|
|
| 60 |
- |
|
| 61 | 43 |
static int |
| 62 | 44 |
clamp(int val, int min, int max) |
| 63 | 45 |
{
|
| ... | ... |
@@ -182,41 +164,12 @@ capture_screen(void) |
| 182 | 164 |
fprintf(stderr, "Saved %s\n", fname); |
| 183 | 165 |
} |
| 184 | 166 |
|
| 185 |
-static void |
|
| 186 |
-draw_inspect(Ppu *p, Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory) |
|
| 187 |
-{
|
|
| 188 |
- Uint8 i, x, y, b; |
|
| 189 |
- for(i = 0; i < 0x20; ++i) {
|
|
| 190 |
- x = ((i % 8) * 3 + 1) * 8, y = (i / 8 + 1) * 8, b = stack[i]; |
|
| 191 |
- /* working stack */ |
|
| 192 |
- ppu_1bpp(p, 1, x, y, font[(b >> 4) & 0xf], 1 + (wptr == i) * 0x7, 0, 0); |
|
| 193 |
- ppu_1bpp(p, 1, x + 8, y, font[b & 0xf], 1 + (wptr == i) * 0x7, 0, 0); |
|
| 194 |
- y = 0x28 + (i / 8 + 1) * 8; |
|
| 195 |
- b = memory[i]; |
|
| 196 |
- /* return stack */ |
|
| 197 |
- ppu_1bpp(p, 1, x, y, font[(b >> 4) & 0xf], 3, 0, 0); |
|
| 198 |
- ppu_1bpp(p, 1, x + 8, y, font[b & 0xf], 3, 0, 0); |
|
| 199 |
- } |
|
| 200 |
- /* return pointer */ |
|
| 201 |
- ppu_1bpp(p, 1, 0x8, y + 0x10, font[(rptr >> 4) & 0xf], 0x2, 0, 0); |
|
| 202 |
- ppu_1bpp(p, 1, 0x10, y + 0x10, font[rptr & 0xf], 0x2, 0, 0); |
|
| 203 |
- /* guides */ |
|
| 204 |
- for(x = 0; x < 0x10; ++x) {
|
|
| 205 |
- ppu_write(p, 1, x, p->height / 2, 2); |
|
| 206 |
- ppu_write(p, 1, p->width - x, p->height / 2, 2); |
|
| 207 |
- ppu_write(p, 1, p->width / 2, p->height - x, 2); |
|
| 208 |
- ppu_write(p, 1, p->width / 2, x, 2); |
|
| 209 |
- ppu_write(p, 1, p->width / 2 - 0x10 / 2 + x, p->height / 2, 2); |
|
| 210 |
- ppu_write(p, 1, p->width / 2, p->height / 2 - 0x10 / 2 + x, 2); |
|
| 211 |
- } |
|
| 212 |
-} |
|
| 213 |
- |
|
| 214 | 167 |
static void |
| 215 | 168 |
redraw(Uxn *u) |
| 216 | 169 |
{
|
| 217 | 170 |
Uint16 x, y; |
| 218 | 171 |
if(devsystem->dat[0xe]) |
| 219 |
- draw_inspect(&ppu, u->wst.dat, u->wst.ptr, u->rst.ptr, u->ram.dat); |
|
| 172 |
+ ppu_debug(&ppu, u->wst.dat, u->wst.ptr, u->rst.ptr, u->ram.dat); |
|
| 220 | 173 |
for(y = 0; y < ppu.height; ++y) |
| 221 | 174 |
for(x = 0; x < ppu.width; ++x) |
| 222 | 175 |
ppu_screen[x + y * ppu.width] = palette[ppu_read(&ppu, x, y)]; |