| ... | ... |
@@ -56,9 +56,9 @@ file_poke(Uxn *u, Uint8 *m, Uint8 b0, Uint8 b1) |
| 56 | 56 |
{
|
| 57 | 57 |
Uint8 read = b0 == 0xd; |
| 58 | 58 |
if(read || b0 == 0xf) {
|
| 59 |
- char *name = (char *)&u->ram.dat[genpeek16(m, 0x8)]; |
|
| 60 |
- Uint16 result = 0, length = genpeek16(m, 0xa); |
|
| 61 |
- Uint16 offset = genpeek16(m, 0x4); |
|
| 59 |
+ char *name = (char *)&u->ram.dat[mempeek16(m, 0x8)]; |
|
| 60 |
+ Uint16 result = 0, length = mempeek16(m, 0xa); |
|
| 61 |
+ Uint16 offset = mempeek16(m, 0x4); |
|
| 62 | 62 |
Uint16 addr = (m[b0 - 1] << 8) | b1; |
| 63 | 63 |
FILE *f = fopen(name, read ? "r" : (offset ? "a" : "w")); |
| 64 | 64 |
if(f) {
|
| ... | ... |
@@ -66,7 +66,7 @@ file_poke(Uxn *u, Uint8 *m, Uint8 b0, Uint8 b1) |
| 66 | 66 |
printf("%s %d bytes, at %04x from %s\n", read ? "Loaded" : "Saved", length, addr, name);
|
| 67 | 67 |
fclose(f); |
| 68 | 68 |
} |
| 69 |
- genpoke16(m, 0x2, result); |
|
| 69 |
+ mempoke16(m, 0x2, result); |
|
| 70 | 70 |
} |
| 71 | 71 |
return b1; |
| 72 | 72 |
} |
| ... | ... |
@@ -49,7 +49,7 @@ audio_callback(void *u, Uint8 *stream, int len) |
| 49 | 49 |
void |
| 50 | 50 |
redraw(Uint32 *dst, Uxn *u) |
| 51 | 51 |
{
|
| 52 |
- drawppu(&ppu); |
|
| 52 |
+ draw(&ppu); |
|
| 53 | 53 |
if(debug) |
| 54 | 54 |
drawdebugger(&ppu, u->wst.dat, u->wst.ptr); |
| 55 | 55 |
SDL_UpdateTexture(gTexture, NULL, dst, ppu.width * sizeof(Uint32)); |
| ... | ... |
@@ -130,8 +130,8 @@ domouse(SDL_Event *event) |
| 130 | 130 |
Uint8 flag = 0x00; |
| 131 | 131 |
Uint16 x = clamp(event->motion.x / zoom - ppu.pad, 0, ppu.hor * 8 - 1); |
| 132 | 132 |
Uint16 y = clamp(event->motion.y / zoom - ppu.pad, 0, ppu.ver * 8 - 1); |
| 133 |
- genpoke16(devmouse->dat, 0x2, x); |
|
| 134 |
- genpoke16(devmouse->dat, 0x4, y); |
|
| 133 |
+ mempoke16(devmouse->dat, 0x2, x); |
|
| 134 |
+ mempoke16(devmouse->dat, 0x4, y); |
|
| 135 | 135 |
devmouse->dat[7] = 0x00; |
| 136 | 136 |
switch(event->button.button) {
|
| 137 | 137 |
case SDL_BUTTON_LEFT: flag = 0x01; break; |
| ... | ... |
@@ -184,8 +184,7 @@ doctrl(Uxn *u, SDL_Event *event, int z) |
| 184 | 184 |
Uint8 |
| 185 | 185 |
system_poke(Uxn *u, Uint8 *m, Uint8 b0, Uint8 b1) |
| 186 | 186 |
{
|
| 187 |
- getcolors(&ppu, &m[0x8]); |
|
| 188 |
- printf("%02x%02x %02x%02x %02x%02x\n", m[0x8], m[0x9], m[0xa], m[0xb], m[0xc], m[0xd]);
|
|
| 187 |
+ putcolors(&ppu, &m[0x8]); |
|
| 189 | 188 |
reqdraw = 1; |
| 190 | 189 |
(void)u; |
| 191 | 190 |
(void)b0; |
| ... | ... |
@@ -209,9 +208,9 @@ Uint8 |
| 209 | 208 |
screen_poke(Uxn *u, Uint8 *m, Uint8 b0, Uint8 b1) |
| 210 | 209 |
{
|
| 211 | 210 |
if(b0 == 0xe) {
|
| 212 |
- Uint16 x = genpeek16(m, 0x8); |
|
| 213 |
- Uint16 y = genpeek16(m, 0xa); |
|
| 214 |
- Uint8 *addr = &u->ram.dat[genpeek16(m, 0xc)]; |
|
| 211 |
+ Uint16 x = mempeek16(m, 0x8); |
|
| 212 |
+ Uint16 y = mempeek16(m, 0xa); |
|
| 213 |
+ Uint8 *addr = &u->ram.dat[mempeek16(m, 0xc)]; |
|
| 215 | 214 |
Uint8 *layer = b1 >> 4 & 0x1 ? ppu.fg : ppu.bg; |
| 216 | 215 |
switch(b1 >> 5) {
|
| 217 | 216 |
case 0: putpixel(&ppu, layer, x, y, b1 & 0x3); break; |
| ... | ... |
@@ -228,9 +227,9 @@ file_poke(Uxn *u, Uint8 *m, Uint8 b0, Uint8 b1) |
| 228 | 227 |
{
|
| 229 | 228 |
Uint8 read = b0 == 0xd; |
| 230 | 229 |
if(read || b0 == 0xf) {
|
| 231 |
- char *name = (char *)&u->ram.dat[genpeek16(m, 0x8)]; |
|
| 232 |
- Uint16 result = 0, length = genpeek16(m, 0xa); |
|
| 233 |
- Uint16 offset = genpeek16(m, 0x4); |
|
| 230 |
+ char *name = (char *)&u->ram.dat[mempeek16(m, 0x8)]; |
|
| 231 |
+ Uint16 result = 0, length = mempeek16(m, 0xa); |
|
| 232 |
+ Uint16 offset = mempeek16(m, 0x4); |
|
| 234 | 233 |
Uint16 addr = (m[b0 - 1] << 8) | b1; |
| 235 | 234 |
FILE *f = fopen(name, read ? "r" : (offset ? "a" : "w")); |
| 236 | 235 |
if(f) {
|
| ... | ... |
@@ -238,7 +237,7 @@ file_poke(Uxn *u, Uint8 *m, Uint8 b0, Uint8 b1) |
| 238 | 237 |
printf("%s %d bytes, at %04x from %s\n", read ? "Loaded" : "Saved", length, addr, name);
|
| 239 | 238 |
fclose(f); |
| 240 | 239 |
} |
| 241 |
- genpoke16(m, 0x2, result); |
|
| 240 |
+ mempoke16(m, 0x2, result); |
|
| 242 | 241 |
} |
| 243 | 242 |
return b1; |
| 244 | 243 |
} |
| ... | ... |
@@ -249,16 +248,16 @@ audio_poke(Uxn *u, Uint8 *m, Uint8 b0, Uint8 b1) |
| 249 | 248 |
if(b0 == 0xa) {
|
| 250 | 249 |
if(b1 >= apu.n_notes) apu.notes = SDL_realloc(apu.notes, (b1 + 1) * sizeof(Note)); |
| 251 | 250 |
while(b1 >= apu.n_notes) SDL_zero(apu.notes[apu.n_notes++]); |
| 252 |
- apu_play_note(&apu.notes[b1], genpeek16(m, 0x0), genpeek16(m, 0x2), m[0x8], m[0x9] & 0x7f, m[0x9] > 0x7f); |
|
| 251 |
+ apu_play_note(&apu.notes[b1], mempeek16(m, 0x0), mempeek16(m, 0x2), m[0x8], m[0x9] & 0x7f, m[0x9] > 0x7f); |
|
| 253 | 252 |
} else if(b0 == 0xe && apu.queue != NULL) {
|
| 254 | 253 |
if(apu.queue->n == apu.queue->sz) {
|
| 255 | 254 |
apu.queue->sz = apu.queue->sz < 4 ? 4 : apu.queue->sz * 2; |
| 256 | 255 |
apu.queue->dat = SDL_realloc(apu.queue->dat, apu.queue->sz * sizeof(*apu.queue->dat)); |
| 257 | 256 |
} |
| 258 | 257 |
if(apu.queue->is_envelope) |
| 259 |
- apu.queue->dat[apu.queue->n++] = genpeek16(m, 0xb) >> 1; |
|
| 258 |
+ apu.queue->dat[apu.queue->n++] = mempeek16(m, 0xb) >> 1; |
|
| 260 | 259 |
else |
| 261 |
- apu.queue->dat[apu.queue->n++] = genpeek16(m, 0xb) + 0x8000; |
|
| 260 |
+ apu.queue->dat[apu.queue->n++] = mempeek16(m, 0xb) + 0x8000; |
|
| 262 | 261 |
apu.queue->dat[apu.queue->n++] = (m[0xd] << 8) + b1; |
| 263 | 262 |
} else if(b0 == 0xf && apu.queue != NULL) |
| 264 | 263 |
apu.queue->finishes = 1; |
| ... | ... |
@@ -281,14 +280,14 @@ datetime_poke(Uxn *u, Uint8 *m, Uint8 b0, Uint8 b1) |
| 281 | 280 |
time_t seconds = time(NULL); |
| 282 | 281 |
struct tm *t = localtime(&seconds); |
| 283 | 282 |
t->tm_year += 1900; |
| 284 |
- genpoke16(m, 0x0, t->tm_year); |
|
| 283 |
+ mempoke16(m, 0x0, t->tm_year); |
|
| 285 | 284 |
m[0x2] = t->tm_mon; |
| 286 | 285 |
m[0x3] = t->tm_mday; |
| 287 | 286 |
m[0x4] = t->tm_hour; |
| 288 | 287 |
m[0x5] = t->tm_min; |
| 289 | 288 |
m[0x6] = t->tm_sec; |
| 290 | 289 |
m[0x7] = t->tm_wday; |
| 291 |
- genpoke16(m, 0x08, t->tm_yday); |
|
| 290 |
+ mempoke16(m, 0x08, t->tm_yday); |
|
| 292 | 291 |
m[0xa] = t->tm_isdst; |
| 293 | 292 |
(void)u; |
| 294 | 293 |
(void)b0; |
| ... | ... |
@@ -327,14 +326,14 @@ start(Uxn *u) |
| 327 | 326 |
case SDL_KEYDOWN: |
| 328 | 327 |
case SDL_KEYUP: |
| 329 | 328 |
doctrl(u, &event, event.type == SDL_KEYDOWN); |
| 330 |
- evaluxn(u, genpeek16(devctrl->dat, 0)); |
|
| 329 |
+ evaluxn(u, mempeek16(devctrl->dat, 0)); |
|
| 331 | 330 |
devctrl->dat[3] = 0; |
| 332 | 331 |
break; |
| 333 | 332 |
case SDL_MOUSEBUTTONUP: |
| 334 | 333 |
case SDL_MOUSEBUTTONDOWN: |
| 335 | 334 |
case SDL_MOUSEMOTION: |
| 336 | 335 |
domouse(&event); |
| 337 |
- evaluxn(u, genpeek16(devmouse->dat, 0)); |
|
| 336 |
+ evaluxn(u, mempeek16(devmouse->dat, 0)); |
|
| 338 | 337 |
break; |
| 339 | 338 |
case SDL_WINDOWEVENT: |
| 340 | 339 |
if(event.window.event == SDL_WINDOWEVENT_EXPOSED) |
| ... | ... |
@@ -342,7 +341,7 @@ start(Uxn *u) |
| 342 | 341 |
break; |
| 343 | 342 |
} |
| 344 | 343 |
} |
| 345 |
- evaluxn(u, genpeek16(devscreen->dat, 0)); |
|
| 344 |
+ evaluxn(u, mempeek16(devscreen->dat, 0)); |
|
| 346 | 345 |
SDL_UnlockAudioDevice(audio_id); |
| 347 | 346 |
if(reqdraw) |
| 348 | 347 |
redraw(ppu.output, u); |
| ... | ... |
@@ -387,8 +386,8 @@ main(int argc, char **argv) |
| 387 | 386 |
apu.channel_ptr = &devapu->dat[0xa]; |
| 388 | 387 |
|
| 389 | 388 |
/* Write screen size to dev/screen */ |
| 390 |
- genpoke16(devscreen->dat, 2, ppu.hor * 8); |
|
| 391 |
- genpoke16(devscreen->dat, 4, ppu.ver * 8); |
|
| 389 |
+ mempoke16(devscreen->dat, 2, ppu.hor * 8); |
|
| 390 |
+ mempoke16(devscreen->dat, 4, ppu.ver * 8); |
|
| 392 | 391 |
|
| 393 | 392 |
start(&u); |
| 394 | 393 |
quit(); |
| ... | ... |
@@ -44,10 +44,16 @@ clear(Ppu *p) |
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 | 46 |
void |
| 47 |
-drawpixel(Ppu *p, Uint16 x, Uint16 y, Uint8 color) |
|
| 47 |
+putcolors(Ppu *p, Uint8 *addr) |
|
| 48 | 48 |
{
|
| 49 |
- if(x >= p->pad && x <= p->width - p->pad - 1 && y >= p->pad && y <= p->height - p->pad - 1) |
|
| 50 |
- p->output[y * p->width + x] = p->colors[color]; |
|
| 49 |
+ int i; |
|
| 50 |
+ for(i = 0; i < 4; ++i) {
|
|
| 51 |
+ Uint8 |
|
| 52 |
+ r = (*(addr + i / 2) >> (!(i % 2) << 2)) & 0x0f, |
|
| 53 |
+ g = (*(addr + 2 + i / 2) >> (!(i % 2) << 2)) & 0x0f, |
|
| 54 |
+ b = (*(addr + 4 + i / 2) >> (!(i % 2) << 2)) & 0x0f; |
|
| 55 |
+ p->colors[i] = (r << 20) + (r << 16) + (g << 12) + (g << 8) + (b << 4) + b; |
|
| 56 |
+ } |
|
| 51 | 57 |
} |
| 52 | 58 |
|
| 53 | 59 |
void |
| ... | ... |
@@ -91,6 +97,15 @@ putchr(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color) |
| 91 | 97 |
} |
| 92 | 98 |
} |
| 93 | 99 |
|
| 100 |
+/* output */ |
|
| 101 |
+ |
|
| 102 |
+void |
|
| 103 |
+drawpixel(Ppu *p, Uint16 x, Uint16 y, Uint8 color) |
|
| 104 |
+{
|
|
| 105 |
+ if(x >= p->pad && x <= p->width - p->pad - 1 && y >= p->pad && y <= p->height - p->pad - 1) |
|
| 106 |
+ p->output[y * p->width + x] = p->colors[color]; |
|
| 107 |
+} |
|
| 108 |
+ |
|
| 94 | 109 |
void |
| 95 | 110 |
drawdebugger(Ppu *p, Uint8 *stack, Uint8 ptr) |
| 96 | 111 |
{
|
| ... | ... |
@@ -111,20 +126,7 @@ drawdebugger(Ppu *p, Uint8 *stack, Uint8 ptr) |
| 111 | 126 |
} |
| 112 | 127 |
|
| 113 | 128 |
void |
| 114 |
-getcolors(Ppu *p, Uint8 *addr) |
|
| 115 |
-{
|
|
| 116 |
- int i; |
|
| 117 |
- for(i = 0; i < 4; ++i) {
|
|
| 118 |
- Uint8 |
|
| 119 |
- r = (*(addr + i / 2) >> (!(i % 2) << 2)) & 0x0f, |
|
| 120 |
- g = (*(addr + 2 + i / 2) >> (!(i % 2) << 2)) & 0x0f, |
|
| 121 |
- b = (*(addr + 4 + i / 2) >> (!(i % 2) << 2)) & 0x0f; |
|
| 122 |
- p->colors[i] = (r << 20) + (r << 16) + (g << 12) + (g << 8) + (b << 4) + b; |
|
| 123 |
- } |
|
| 124 |
-} |
|
| 125 |
- |
|
| 126 |
-void |
|
| 127 |
-drawppu(Ppu *p) |
|
| 129 |
+draw(Ppu *p) |
|
| 128 | 130 |
{
|
| 129 | 131 |
Uint16 x, y; |
| 130 | 132 |
for(y = 0; y < p->ver; ++y) |
| ... | ... |
@@ -24,9 +24,9 @@ typedef struct Ppu {
|
| 24 | 24 |
} Ppu; |
| 25 | 25 |
|
| 26 | 26 |
int initppu(Ppu *p, Uint8 hor, Uint8 ver, Uint8 pad); |
| 27 |
-void drawppu(Ppu *p); |
|
| 28 |
-void drawdebugger(Ppu *p, Uint8 *stack, Uint8 ptr); |
|
| 29 |
-void getcolors(Ppu *p, Uint8 *addr); |
|
| 27 |
+void putcolors(Ppu *p, Uint8 *addr); |
|
| 30 | 28 |
void putpixel(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 color); |
| 31 | 29 |
void puticn(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color); |
| 32 |
-void putchr(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color); |
|
| 33 | 30 |
\ No newline at end of file |
| 31 |
+void putchr(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color); |
|
| 32 |
+void draw(Ppu *p); |
|
| 33 |
+void drawdebugger(Ppu *p, Uint8 *stack, Uint8 ptr); |
|
| 34 | 34 |
\ No newline at end of file |
| ... | ... |
@@ -19,21 +19,21 @@ WITH REGARD TO THIS SOFTWARE. |
| 19 | 19 |
void push8(Stack *s, Uint8 a) { if (s->ptr == 0xff) { s->error = 2; return; } s->dat[s->ptr++] = a; }
|
| 20 | 20 |
Uint8 pop8(Stack *s) { if (s->ptr == 0) { s->error = 1; return 0; } return s->dat[--s->ptr]; }
|
| 21 | 21 |
Uint8 peek8(Stack *s, Uint8 a) { if (s->ptr < a + 1) s->error = 1; return s->dat[s->ptr - a - 1]; }
|
| 22 |
-void mempoke8(Uxn *u, Uint16 a, Uint8 b) { u->ram.dat[a] = b; }
|
|
| 23 |
-Uint8 mempeek8(Uxn *u, Uint16 a) { return u->ram.dat[a]; }
|
|
| 22 |
+void mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; }
|
|
| 23 |
+Uint8 mempeek8(Uint8 *m, Uint16 a) { return m[a]; }
|
|
| 24 | 24 |
void devpoke8(Uxn *u, Uint8 a, Uint8 b) { Device *dev = &u->dev[a >> 4]; dev->dat[a & 0xf] = b; dev->poke(u, dev->dat, a & 0x0f, b); }
|
| 25 | 25 |
Uint8 devpeek8(Uxn *u, Uint8 a) { return u->dev[a >> 4].dat[a & 0xf]; }
|
| 26 | 26 |
void push16(Stack *s, Uint16 a) { push8(s, a >> 8); push8(s, a); }
|
| 27 | 27 |
Uint16 pop16(Stack *s) { return pop8(s) + (pop8(s) << 8); }
|
| 28 | 28 |
Uint16 peek16(Stack *s, Uint8 a) { return peek8(s, a * 2) + (peek8(s, a * 2 + 1) << 8); }
|
| 29 |
-void mempoke16(Uxn *u, Uint16 a, Uint16 b) { mempoke8(u, a, b >> 8); mempoke8(u, a + 1, b); }
|
|
| 30 |
-Uint16 mempeek16(Uxn *u, Uint16 a) { return (mempeek8(u, a) << 8) + mempeek8(u, a + 1); }
|
|
| 29 |
+void mempoke16(Uint8 *m, Uint16 a, Uint16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); }
|
|
| 30 |
+Uint16 mempeek16(Uint8 *m, Uint16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); }
|
|
| 31 | 31 |
void devpoke16(Uxn *u, Uint8 a, Uint16 b) { devpoke8(u, a, b >> 8); devpoke8(u, a + 1, b); }
|
| 32 | 32 |
Uint16 devpeek16(Uxn *u, Uint16 a) { return (devpeek8(u, a) << 8) + devpeek8(u, a + 1); }
|
| 33 | 33 |
/* Stack */ |
| 34 | 34 |
void op_brk(Uxn *u) { u->ram.ptr = 0; }
|
| 35 | 35 |
void op_nop(Uxn *u) { (void)u; }
|
| 36 |
-void op_lit(Uxn *u) { push8(u->src, mempeek8(u, u->ram.ptr++)); }
|
|
| 36 |
+void op_lit(Uxn *u) { push8(u->src, mempeek8(&u->ram.dat[0], u->ram.ptr++)); }
|
|
| 37 | 37 |
void op_pop(Uxn *u) { pop8(u->src); }
|
| 38 | 38 |
void op_dup(Uxn *u) { push8(u->src, peek8(u->src, 0)); }
|
| 39 | 39 |
void op_swp(Uxn *u) { Uint8 b = pop8(u->src), a = pop8(u->src); push8(u->src, b); push8(u->src, a); }
|
| ... | ... |
@@ -49,10 +49,10 @@ void op_lts(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, (S
|
| 49 | 49 |
void op_ior(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, devpeek8(u, a)); }
|
| 50 | 50 |
void op_iow(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); devpoke8(u, a, b); }
|
| 51 | 51 |
/* Memory */ |
| 52 |
-void op_pek(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, mempeek8(u, a)); }
|
|
| 53 |
-void op_pok(Uxn *u) { Uint8 a = pop8(u->src); Uint8 b = pop8(u->src); mempoke8(u, a, b); }
|
|
| 54 |
-void op_ldr(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, mempeek16(u, a)); }
|
|
| 55 |
-void op_str(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); mempoke16(u, a, b); }
|
|
| 52 |
+void op_pek(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, mempeek8(&u->ram.dat[0], a)); }
|
|
| 53 |
+void op_pok(Uxn *u) { Uint8 a = pop8(u->src); Uint8 b = pop8(u->src); mempoke8(&u->ram.dat[0], a, b); }
|
|
| 54 |
+void op_ldr(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, mempeek16(&u->ram.dat[0], a)); }
|
|
| 55 |
+void op_str(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); mempoke16(&u->ram.dat[0], a, b); }
|
|
| 56 | 56 |
void op_jmp(Uxn *u) { Uint8 a = pop8(u->src); u->ram.ptr += (Sint8)a; }
|
| 57 | 57 |
void op_jnz(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); if (b) u->ram.ptr += (Sint8)a; }
|
| 58 | 58 |
void op_jsr(Uxn *u) { Uint8 a = pop8(u->src); push16(u->dst, u->ram.ptr); u->ram.ptr += (Sint8)a; }
|
| ... | ... |
@@ -67,7 +67,7 @@ void op_ora(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b
|
| 67 | 67 |
void op_eor(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b ^ a); }
|
| 68 | 68 |
void op_sft(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b >> (a & 0x07) << ((a & 0x70) >> 4)); }
|
| 69 | 69 |
/* Stack */ |
| 70 |
-void op_lit16(Uxn *u) { push16(u->src, mempeek16(u, u->ram.ptr++)); u->ram.ptr++; }
|
|
| 70 |
+void op_lit16(Uxn *u) { push16(u->src, mempeek16(&u->ram.dat[0], u->ram.ptr++)); u->ram.ptr++; }
|
|
| 71 | 71 |
void op_pop16(Uxn *u) { pop16(u->src); }
|
| 72 | 72 |
void op_dup16(Uxn *u) { push16(u->src, peek16(u->src, 0)); }
|
| 73 | 73 |
void op_swp16(Uxn *u) { Uint16 b = pop16(u->src), a = pop16(u->src); push16(u->src, b); push16(u->src, a); }
|
| ... | ... |
@@ -83,10 +83,10 @@ void op_lts16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push8(u->sr
|
| 83 | 83 |
void op_ior16(Uxn *u) { Uint8 a = pop8(u->src); push16(u->src, devpeek16(u, a)); }
|
| 84 | 84 |
void op_iow16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); devpoke16(u, a, b); }
|
| 85 | 85 |
/* Memory(16-bits) */ |
| 86 |
-void op_pek16(Uxn *u) { Uint16 a = pop16(u->src); push8(u->src, mempeek8(u, a)); }
|
|
| 87 |
-void op_pok16(Uxn *u) { Uint16 a = pop16(u->src); Uint8 b = pop8(u->src); mempoke8(u, a, b); }
|
|
| 88 |
-void op_ldr16(Uxn *u) { Uint16 a = pop16(u->src); push16(u->src, mempeek16(u, a)); }
|
|
| 89 |
-void op_str16(Uxn *u) { Uint16 a = pop16(u->src); Uint16 b = pop16(u->src); mempoke16(u, a, b); }
|
|
| 86 |
+void op_pek16(Uxn *u) { Uint16 a = pop16(u->src); push8(u->src, mempeek8(&u->ram.dat[0], a)); }
|
|
| 87 |
+void op_pok16(Uxn *u) { Uint16 a = pop16(u->src); Uint8 b = pop8(u->src); mempoke8(&u->ram.dat[0], a, b); }
|
|
| 88 |
+void op_ldr16(Uxn *u) { Uint16 a = pop16(u->src); push16(u->src, mempeek16(&u->ram.dat[0], a)); }
|
|
| 89 |
+void op_str16(Uxn *u) { Uint16 a = pop16(u->src); Uint16 b = pop16(u->src); mempoke16(&u->ram.dat[0], a, b); }
|
|
| 90 | 90 |
void op_jmp16(Uxn *u) { u->ram.ptr = pop16(u->src); }
|
| 91 | 91 |
void op_jnz16(Uxn *u) { Uint16 a = pop16(u->src); Uint8 b = pop8(u->src); if (b) u->ram.ptr = a; }
|
| 92 | 92 |
void op_jsr16(Uxn *u) { push16(u->dst, u->ram.ptr); u->ram.ptr = pop16(u->src); }
|
| ... | ... |
@@ -18,13 +18,6 @@ typedef signed short Sint16; |
| 18 | 18 |
|
| 19 | 19 |
#define PAGE_PROGRAM 0x0100 |
| 20 | 20 |
|
| 21 |
-#define genpeek16(ptr, i) ((ptr[i] << 8) + ptr[i + 1]) |
|
| 22 |
-#define genpoke16(ptr, i, v) \ |
|
| 23 |
- do { \
|
|
| 24 |
- ptr[i] = v >> 8; \ |
|
| 25 |
- ptr[i + 1] = v & 0xff; \ |
|
| 26 |
- } while(0) |
|
| 27 |
- |
|
| 28 | 21 |
typedef struct {
|
| 29 | 22 |
Uint8 ptr, error; |
| 30 | 23 |
Uint8 dat[256]; |
| ... | ... |
@@ -38,7 +31,7 @@ typedef struct {
|
| 38 | 31 |
struct Uxn; |
| 39 | 32 |
|
| 40 | 33 |
typedef struct Device {
|
| 41 |
- Uint8 addr, dat[16]; |
|
| 34 |
+ Uint8 addr, dat[16], *mem; |
|
| 42 | 35 |
Uint8 (*poke)(struct Uxn *u, Uint8 *devmem, Uint8, Uint8); |
| 43 | 36 |
} Device; |
| 44 | 37 |
|
| ... | ... |
@@ -51,7 +44,7 @@ typedef struct Uxn {
|
| 51 | 44 |
int loaduxn(Uxn *c, char *filepath); |
| 52 | 45 |
int bootuxn(Uxn *c); |
| 53 | 46 |
int evaluxn(Uxn *u, Uint16 vec); |
| 54 |
-void mempoke16(Uxn *u, Uint16 a, Uint16 b); |
|
| 55 |
-Uint16 mempeek16(Uxn *u, Uint16 a); |
|
| 47 |
+void mempoke16(Uint8 *m, Uint16 a, Uint16 b); |
|
| 48 |
+Uint16 mempeek16(Uint8 *m, Uint16 a); |
|
| 56 | 49 |
|
| 57 | 50 |
Device *portuxn(Uxn *u, Uint8 id, char *name, Uint8 (*pofn)(Uxn *, Uint8 *, Uint8, Uint8)); |
| 58 | 51 |
\ No newline at end of file |