Removed screen as Device
This commit is contained in:
parent
ab6ce6ba5a
commit
b0c840437a
|
@ -117,64 +117,64 @@ clamp(int val, int min, int max)
|
|||
/* IO */
|
||||
|
||||
Uint8
|
||||
screen_dei(Device *d, Uint8 port)
|
||||
screen_dei(Uint8 *d, Uint8 port)
|
||||
{
|
||||
switch(port) {
|
||||
case 0x2: return uxn_screen.width >> 8;
|
||||
case 0x3: return uxn_screen.width;
|
||||
case 0x4: return uxn_screen.height >> 8;
|
||||
case 0x5: return uxn_screen.height;
|
||||
default: return d->dat[port];
|
||||
default: return d[port];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
screen_deo(Device *d, Uint8 port)
|
||||
screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
|
||||
{
|
||||
switch(port) {
|
||||
case 0x3:
|
||||
if(!FIXED_SIZE) {
|
||||
Uint16 w;
|
||||
DEVPEEK16(w, 0x2);
|
||||
PEKDEV(w, 0x2);
|
||||
screen_resize(&uxn_screen, clamp(w, 1, 1024), uxn_screen.height);
|
||||
}
|
||||
break;
|
||||
case 0x5:
|
||||
if(!FIXED_SIZE) {
|
||||
Uint16 h;
|
||||
DEVPEEK16(h, 0x4);
|
||||
PEKDEV(h, 0x4);
|
||||
screen_resize(&uxn_screen, uxn_screen.width, clamp(h, 1, 1024));
|
||||
}
|
||||
break;
|
||||
case 0xe: {
|
||||
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) DEVPOKE16(0x8, x + 1); /* auto x+1 */
|
||||
if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 1); /* auto y+1 */
|
||||
Uint8 layer = d[0xe] & 0x40;
|
||||
PEKDEV(x, 0x8);
|
||||
PEKDEV(y, 0xa);
|
||||
screen_write(&uxn_screen, layer ? &uxn_screen.fg : &uxn_screen.bg, x, y, d[0xe] & 0x3);
|
||||
if(d[0x6] & 0x01) POKDEV(0x8, x + 1); /* auto x+1 */
|
||||
if(d[0x6] & 0x02) POKDEV(0xa, y + 1); /* auto y+1 */
|
||||
break;
|
||||
}
|
||||
case 0xf: {
|
||||
Uint16 x, y, dx, dy, addr;
|
||||
Uint8 i, n, twobpp = !!(d->dat[0xf] & 0x80);
|
||||
Layer *layer = (d->dat[0xf] & 0x40) ? &uxn_screen.fg : &uxn_screen.bg;
|
||||
DEVPEEK16(x, 0x8);
|
||||
DEVPEEK16(y, 0xa);
|
||||
DEVPEEK16(addr, 0xc);
|
||||
n = d->dat[0x6] >> 4;
|
||||
dx = (d->dat[0x6] & 0x01) << 3;
|
||||
dy = (d->dat[0x6] & 0x02) << 2;
|
||||
Uint8 i, n, twobpp = !!(d[0xf] & 0x80);
|
||||
Layer *layer = (d[0xf] & 0x40) ? &uxn_screen.fg : &uxn_screen.bg;
|
||||
PEKDEV(x, 0x8);
|
||||
PEKDEV(y, 0xa);
|
||||
PEKDEV(addr, 0xc);
|
||||
n = d[0x6] >> 4;
|
||||
dx = (d[0x6] & 0x01) << 3;
|
||||
dy = (d[0x6] & 0x02) << 2;
|
||||
if(addr > 0x10000 - ((n + 1) << (3 + twobpp)))
|
||||
return;
|
||||
for(i = 0; i <= n; i++) {
|
||||
screen_blit(&uxn_screen, layer, x + dy * i, y + dx * i, &d->u->ram[addr], d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20, twobpp);
|
||||
addr += (d->dat[0x6] & 0x04) << (1 + twobpp);
|
||||
screen_blit(&uxn_screen, layer, x + dy * i, y + dx * i, &ram[addr], d[0xf] & 0xf, d[0xf] & 0x10, d[0xf] & 0x20, twobpp);
|
||||
addr += (d[0x6] & 0x04) << (1 + twobpp);
|
||||
}
|
||||
DEVPOKE16(0xc, addr); /* auto addr+length */
|
||||
DEVPOKE16(0x8, x + dx); /* auto x+8 */
|
||||
DEVPOKE16(0xa, y + dy); /* auto y+8 */
|
||||
POKDEV(0xc, addr); /* auto addr+length */
|
||||
POKDEV(0x8, x + dx); /* auto x+8 */
|
||||
POKDEV(0xa, y + dy); /* auto y+8 */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,6 @@ void screen_resize(UxnScreen *p, Uint16 width, Uint16 height);
|
|||
void screen_clear(UxnScreen *p, Layer *layer);
|
||||
void screen_redraw(UxnScreen *p, Uint32 *pixels);
|
||||
|
||||
Uint8 screen_dei(Device *d, Uint8 port);
|
||||
void screen_deo(Device *d, Uint8 port);
|
||||
Uint8 screen_dei(Uint8 *d, Uint8 port);
|
||||
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
|
||||
int clamp(int val, int min, int max);
|
||||
|
|
|
@ -25,6 +25,7 @@ typedef unsigned int Uint32;
|
|||
|
||||
#define GETVEC(d) ((d)[0] << 8 | (d)[1])
|
||||
#define POKDEV(x, y) { d[(x)] = (y) >> 8; d[(x) + 1] = (y); }
|
||||
#define PEKDEV(o, x) { (o) = (d[(x)] << 8) + d[(x) + 1]; }
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ uxn11_dei(struct Uxn *u, Uint8 addr)
|
|||
Uint8 p = addr & 0x0f;
|
||||
Device *d = &u->dev[addr >> 4];
|
||||
switch(addr & 0xf0) {
|
||||
case 0x20: return screen_dei(d, p); break;
|
||||
case 0x20: return screen_dei(d->dat, p); break;
|
||||
case 0xa0: return file_dei(d, p); break;
|
||||
case 0xb0: return file_dei(d, p); break;
|
||||
case 0xc0: return datetime_dei(d->dat, p); break;
|
||||
|
@ -81,7 +81,7 @@ uxn11_deo(Uxn *u, Uint8 addr, Uint8 v)
|
|||
switch(addr & 0xf0) {
|
||||
case 0x00: system_deo(d, p); break;
|
||||
case 0x10: console_deo(d, p); break;
|
||||
case 0x20: screen_deo(d, p); break;
|
||||
case 0x20: screen_deo(u->ram, d->dat, p); break;
|
||||
case 0xa0: file_deo(d, p); break;
|
||||
case 0xb0: file_deo(d, p); break;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ start(Uxn *u, char *rom)
|
|||
|
||||
/* system */ uxn_port(u, 0x0, nil_dei, system_deo);
|
||||
/* console */ uxn_port(u, 0x1, nil_dei, console_deo);
|
||||
/* screen */ devscreen = uxn_port(u, 0x2, screen_dei, screen_deo);
|
||||
/* screen */ devscreen = uxn_port(u, 0x2, nil_dei, nil_deo);
|
||||
/* empty */ uxn_port(u, 0x3, nil_dei, nil_deo);
|
||||
/* empty */ uxn_port(u, 0x4, nil_dei, nil_deo);
|
||||
/* empty */ uxn_port(u, 0x5, nil_dei, nil_deo);
|
||||
|
|
Loading…
Reference in New Issue