mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-10 16:25:05 +00:00
Removed poke16
This commit is contained in:
parent
c4746c2601
commit
0ee477615b
7 changed files with 69 additions and 33 deletions
|
@ -144,12 +144,35 @@ file_delete(void)
|
|||
void
|
||||
file_deo(Device *d, Uint8 port)
|
||||
{
|
||||
Uint16 a, b, res;
|
||||
switch(port) {
|
||||
case 0x1: d->vector = peek16(d->dat, 0x0); break;
|
||||
case 0x9: poke16(d->dat, 0x2, file_init(&d->mem[peek16(d->dat, 0x8)])); break;
|
||||
case 0xd: poke16(d->dat, 0x2, file_read(&d->mem[peek16(d->dat, 0xc)], peek16(d->dat, 0xa))); break;
|
||||
case 0xf: poke16(d->dat, 0x2, file_write(&d->mem[peek16(d->dat, 0xe)], peek16(d->dat, 0xa), d->dat[0x7])); break;
|
||||
case 0x5: poke16(d->dat, 0x2, file_stat(&d->mem[peek16(d->dat, 0x4)], peek16(d->dat, 0xa))); break;
|
||||
case 0x6: poke16(d->dat, 0x2, file_delete()); break;
|
||||
case 0x9:
|
||||
DEVPEEK16(a, 0x8);
|
||||
res = file_init(&d->mem[a]);
|
||||
DEVPOKE16(0x2, res);
|
||||
break;
|
||||
case 0xd:
|
||||
DEVPEEK16(a, 0xc);
|
||||
DEVPEEK16(b, 0xa);
|
||||
res = file_read(&d->mem[a], b);
|
||||
DEVPOKE16(0x2, res);
|
||||
break;
|
||||
case 0xf:
|
||||
DEVPEEK16(a, 0xe);
|
||||
DEVPEEK16(b, 0xa);
|
||||
res = file_write(&d->mem[a], b, d->dat[0x7]);
|
||||
DEVPOKE16(0x2, res);
|
||||
break;
|
||||
case 0x5:
|
||||
DEVPEEK16(a, 0x4);
|
||||
DEVPEEK16(b, 0xa);
|
||||
res = file_stat(&d->mem[a], b);
|
||||
DEVPOKE16(0x2, res);
|
||||
break;
|
||||
case 0x6:
|
||||
res = file_delete();
|
||||
DEVPOKE16(0x2, res);
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -30,17 +30,17 @@ mouse_up(Device *d, Uint8 mask)
|
|||
void
|
||||
mouse_pos(Device *d, Uint16 x, Uint16 y)
|
||||
{
|
||||
poke16(d->dat, 0x2, x);
|
||||
poke16(d->dat, 0x4, y);
|
||||
DEVPOKE16(0x2, x);
|
||||
DEVPOKE16(0x4, y);
|
||||
uxn_eval(d->u, d->vector);
|
||||
}
|
||||
|
||||
void
|
||||
mouse_scroll(Device *d, Uint16 x, Uint16 y)
|
||||
{
|
||||
poke16(d->dat, 0xa, x);
|
||||
poke16(d->dat, 0xc, -y);
|
||||
DEVPOKE16(0xa, x);
|
||||
DEVPOKE16(0xc, -y);
|
||||
uxn_eval(d->u, d->vector);
|
||||
poke16(d->dat, 0xa, 0);
|
||||
poke16(d->dat, 0xc, 0);
|
||||
DEVPOKE16(0xa, 0);
|
||||
DEVPOKE16(0xc, 0);
|
||||
}
|
||||
|
|
|
@ -172,29 +172,36 @@ void
|
|||
screen_deo(Device *d, Uint8 port)
|
||||
{
|
||||
switch(port) {
|
||||
case 0x1: d->vector = peek16(d->dat, 0x0); break;
|
||||
case 0x1: DEVPEEK16(d->vector, 0x0); break;
|
||||
case 0x5:
|
||||
if(!FIXED_SIZE) set_size(peek16(d->dat, 0x2), peek16(d->dat, 0x4), 1);
|
||||
if(!FIXED_SIZE) {
|
||||
Uint16 w, h;
|
||||
DEVPEEK16(w, 0x2);
|
||||
DEVPEEK16(h, 0x4);
|
||||
set_size(w, h, 1);
|
||||
}
|
||||
break;
|
||||
case 0xe: {
|
||||
Uint16 x = peek16(d->dat, 0x8);
|
||||
Uint16 y = peek16(d->dat, 0xa);
|
||||
Uint16 x, y;
|
||||
Uint8 layer = d->dat[0xe] & 0x40;
|
||||
DEVPEEK16(x, 0x8);
|
||||
DEVPEEK16(y, 0xa);
|
||||
screen_write(&uxn_screen, layer ? &uxn_screen.fg : &uxn_screen.bg, x, y, d->dat[0xe] & 0x3);
|
||||
if(d->dat[0x6] & 0x01) poke16(d->dat, 0x8, x + 1); /* auto x+1 */
|
||||
if(d->dat[0x6] & 0x02) poke16(d->dat, 0xa, y + 1); /* auto y+1 */
|
||||
if(d->dat[0x6] & 0x01) DEVPOKE16(0x8, x + 1); /* auto x+1 */
|
||||
if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 1); /* auto y+1 */
|
||||
break;
|
||||
}
|
||||
case 0xf: {
|
||||
Uint16 x = peek16(d->dat, 0x8);
|
||||
Uint16 y = peek16(d->dat, 0xa);
|
||||
Layer *layer = (d->dat[0xf] & 0x40) ? &uxn_screen.fg : &uxn_screen.bg;
|
||||
Uint8 *addr = &d->mem[peek16(d->dat, 0xc)];
|
||||
Uint16 x, y, addr;
|
||||
Uint8 twobpp = !!(d->dat[0xf] & 0x80);
|
||||
screen_blit(&uxn_screen, layer, x, y, addr, d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20, twobpp);
|
||||
if(d->dat[0x6] & 0x04) poke16(d->dat, 0xc, peek16(d->dat, 0xc) + 8 + twobpp * 8); /* auto addr+8 / auto addr+16 */
|
||||
if(d->dat[0x6] & 0x01) poke16(d->dat, 0x8, x + 8); /* auto x+8 */
|
||||
if(d->dat[0x6] & 0x02) poke16(d->dat, 0xa, y + 8); /* auto y+8 */
|
||||
Layer *layer = (d->dat[0xf] & 0x40) ? &uxn_screen.fg : &uxn_screen.bg;
|
||||
DEVPEEK16(x, 0x8);
|
||||
DEVPEEK16(y, 0xa);
|
||||
DEVPEEK16(addr, 0xc);
|
||||
screen_blit(&uxn_screen, layer, x, y, &d->mem[addr], d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20, twobpp);
|
||||
if(d->dat[0x6] & 0x04) DEVPOKE16(0xc, addr + 8 + twobpp * 8); /* auto addr+length */
|
||||
if(d->dat[0x6] & 0x01) DEVPOKE16(0x8, x + 8); /* auto x+8 */
|
||||
if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 8); /* auto y+8 */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ WITH REGARD TO THIS SOFTWARE.
|
|||
#define DEVW(d, x, y) { dev = (d); if(bs) { DEVW8((x), (y) >> 8); DEVW8((x) + 1, (y)); } else { DEVW8((x), (y)) } }
|
||||
#define WARP(x) { if(bs) u->ram.ptr = (x); else u->ram.ptr += (Sint8)(x); }
|
||||
|
||||
void poke16(Uint8 *m, Uint16 a, Uint16 b) { m[a] = b >> 8; m[a + 1] = b; }
|
||||
Uint16 peek16(Uint8 *m, Uint16 a) { Uint16 r = m[a] << 8; return r + m[a + 1]; }
|
||||
|
||||
int
|
||||
|
|
|
@ -17,6 +17,13 @@ typedef unsigned int Uint32;
|
|||
|
||||
#define PAGE_PROGRAM 0x0100
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
#define DEVPEEK16(o, x) { (o) = (d->dat[(x)] << 8) + d->dat[(x) + 1]; }
|
||||
#define DEVPOKE16(x, y) { d->dat[(x)] = (y) >> 8; d->dat[(x) + 1] = (y); }
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
typedef struct {
|
||||
Uint8 ptr;
|
||||
Uint8 dat[256];
|
||||
|
@ -41,7 +48,6 @@ typedef struct Uxn {
|
|||
Device dev[16];
|
||||
} Uxn;
|
||||
|
||||
void poke16(Uint8 *m, Uint16 a, Uint16 b);
|
||||
Uint16 peek16(Uint8 *m, Uint16 a);
|
||||
|
||||
int uxn_boot(Uxn *c, Uint8 *memory);
|
||||
|
|
|
@ -72,7 +72,7 @@ static void
|
|||
console_deo(Device *d, Uint8 port)
|
||||
{
|
||||
if(port == 0x1)
|
||||
d->vector = peek16(d->dat, 0x0);
|
||||
DEVPEEK16(d->vector, 0x0);
|
||||
if(port > 0x7)
|
||||
write(port - 0x7, (char *)&d->dat[port], 1);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ nil_dei(Device *d, Uint8 port)
|
|||
static void
|
||||
nil_deo(Device *d, Uint8 port)
|
||||
{
|
||||
if(port == 0x1) d->vector = peek16(d->dat, 0x0);
|
||||
if(port == 0x1) DEVPEEK16(d->vector, 0x0);
|
||||
}
|
||||
|
||||
#pragma mark - Generics
|
||||
|
@ -135,8 +135,9 @@ static void
|
|||
run(Uxn *u)
|
||||
{
|
||||
Uint16 vec;
|
||||
Device *d = devconsole;
|
||||
while((!u->dev[0].dat[0xf]) && (read(0, &devconsole->dat[0x2], 1) > 0)) {
|
||||
vec = peek16(devconsole->dat, 0);
|
||||
DEVPEEK16(vec, 0);
|
||||
if(!vec) vec = u->ram.ptr; /* continue after last BRK */
|
||||
uxn_eval(u, vec);
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ static void
|
|||
console_deo(Device *d, Uint8 port)
|
||||
{
|
||||
if(port == 0x1)
|
||||
d->vector = peek16(d->dat, 0x0);
|
||||
DEVPEEK16(d->vector, 0x0);
|
||||
if(port > 0x7)
|
||||
write(port - 0x7, (char *)&d->dat[port], 1);
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ audio_dei(Device *d, Uint8 port)
|
|||
if(!audio_id) return d->dat[port];
|
||||
switch(port) {
|
||||
case 0x4: return audio_get_vu(c);
|
||||
case 0x2: poke16(d->dat, 0x2, c->i); /* fall through */
|
||||
case 0x2: DEVPOKE16(0x2, c->i); /* fall through */
|
||||
default: return d->dat[port];
|
||||
}
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ nil_dei(Device *d, Uint8 port)
|
|||
static void
|
||||
nil_deo(Device *d, Uint8 port)
|
||||
{
|
||||
if(port == 0x1) d->vector = peek16(d->dat, 0x0);
|
||||
if(port == 0x1) DEVPEEK16(d->vector, 0x0);
|
||||
}
|
||||
|
||||
/* Boot */
|
||||
|
|
Loading…
Reference in a new issue