The screen width/height ports can be written to
This commit is contained in:
parent
3d8cf7c257
commit
bca5562eec
|
@ -54,6 +54,9 @@
|
||||||
;on-mouse .Mouse/vector DEO2
|
;on-mouse .Mouse/vector DEO2
|
||||||
;on-message .Console/vector DEO2
|
;on-message .Console/vector DEO2
|
||||||
|
|
||||||
|
#0160 .Screen/width DEO2
|
||||||
|
#0100 .Screen/height DEO2
|
||||||
|
|
||||||
( find center )
|
( find center )
|
||||||
.Screen/width DEI2 2// .center/x STZ2
|
.Screen/width DEI2 2// .center/x STZ2
|
||||||
.Screen/height DEI2 2// .center/y STZ2
|
.Screen/height DEI2 2// .center/y STZ2
|
||||||
|
|
|
@ -62,6 +62,9 @@
|
||||||
#0fc5 .System/g DEO2
|
#0fc5 .System/g DEO2
|
||||||
#0f25 .System/b DEO2
|
#0f25 .System/b DEO2
|
||||||
|
|
||||||
|
#0100 .Screen/width DEO2
|
||||||
|
#0160 .Screen/height DEO2
|
||||||
|
|
||||||
( center )
|
( center )
|
||||||
.Screen/width DEI2 2// .center/x STZ2
|
.Screen/width DEI2 2// .center/x STZ2
|
||||||
.Screen/height DEI2 2// .center/y STZ2
|
.Screen/height DEI2 2// .center/y STZ2
|
||||||
|
|
|
@ -78,5 +78,15 @@ ppu_init(Ppu *p, Uint8 hor, Uint8 ver)
|
||||||
p->height = 8 * ver;
|
p->height = 8 * ver;
|
||||||
p->bg = calloc(1, p->width / 4 * p->height * sizeof(Uint8));
|
p->bg = calloc(1, p->width / 4 * p->height * sizeof(Uint8));
|
||||||
p->fg = calloc(1, p->width / 4 * p->height * sizeof(Uint8));
|
p->fg = calloc(1, p->width / 4 * p->height * sizeof(Uint8));
|
||||||
return 1;
|
return p->bg && p->fg;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ppu_resize(Ppu *p, Uint8 hor, Uint8 ver)
|
||||||
|
{
|
||||||
|
p->width = 8 * hor;
|
||||||
|
p->height = 8 * ver;
|
||||||
|
p->bg = realloc(p->bg, p->width / 4 * p->height * sizeof(Uint8));
|
||||||
|
p->fg = realloc(p->fg, p->width / 4 * p->height * sizeof(Uint8));
|
||||||
|
return p->bg && p->fg;
|
||||||
}
|
}
|
|
@ -23,6 +23,7 @@ typedef struct Ppu {
|
||||||
} Ppu;
|
} Ppu;
|
||||||
|
|
||||||
int ppu_init(Ppu *p, Uint8 hor, Uint8 ver);
|
int ppu_init(Ppu *p, Uint8 hor, Uint8 ver);
|
||||||
|
int ppu_resize(Ppu *p, Uint8 hor, Uint8 ver);
|
||||||
void ppu_pixel(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 color);
|
void ppu_pixel(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 color);
|
||||||
void ppu_1bpp(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy);
|
void ppu_1bpp(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy);
|
||||||
void ppu_2bpp(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy);
|
void ppu_2bpp(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy);
|
||||||
|
|
25
src/uxnemu.c
25
src/uxnemu.c
|
@ -298,6 +298,21 @@ update_palette(Uint8 *addr)
|
||||||
reqdraw = 1;
|
reqdraw = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_size(Uxn *u, Uint16 width, Uint16 height)
|
||||||
|
{
|
||||||
|
ppu_resize(&ppu, width / 8, height / 8);
|
||||||
|
gRect.w = ppu.width;
|
||||||
|
gRect.h = ppu.height;
|
||||||
|
if(!(ppu_screen = realloc(ppu_screen, ppu.width * ppu.height * sizeof(Uint32))))
|
||||||
|
return;
|
||||||
|
SDL_DestroyTexture(gTexture);
|
||||||
|
SDL_RenderSetLogicalSize(gRenderer, ppu.width + PAD * 2, ppu.height + PAD * 2);
|
||||||
|
gTexture = SDL_CreateTexture(gRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, ppu.width + PAD * 2, ppu.height + PAD * 2);
|
||||||
|
SDL_SetWindowSize(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom);
|
||||||
|
redraw(u);
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Devices
|
#pragma mark - Devices
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -331,7 +346,13 @@ console_talk(Device *d, Uint8 b0, Uint8 w)
|
||||||
static int
|
static int
|
||||||
screen_talk(Device *d, Uint8 b0, Uint8 w)
|
screen_talk(Device *d, Uint8 b0, Uint8 w)
|
||||||
{
|
{
|
||||||
if(w && b0 == 0xe) {
|
if(!w)
|
||||||
|
return 1;
|
||||||
|
if(b0 == 0x3)
|
||||||
|
set_size(d->u, peek16(d->dat, 0x2), ppu.height);
|
||||||
|
else if(b0 == 0x5)
|
||||||
|
set_size(d->u, ppu.width, peek16(d->dat, 0x4));
|
||||||
|
else if(b0 == 0xe) {
|
||||||
Uint16 x = peek16(d->dat, 0x8);
|
Uint16 x = peek16(d->dat, 0x8);
|
||||||
Uint16 y = peek16(d->dat, 0xa);
|
Uint16 y = peek16(d->dat, 0xa);
|
||||||
Uint8 layer = d->dat[0xe] & 0x40;
|
Uint8 layer = d->dat[0xe] & 0x40;
|
||||||
|
@ -339,7 +360,7 @@ screen_talk(Device *d, Uint8 b0, Uint8 w)
|
||||||
if(d->dat[0x6] & 0x01) poke16(d->dat, 0x8, x + 1); /* auto x+1 */
|
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] & 0x02) poke16(d->dat, 0xa, y + 1); /* auto y+1 */
|
||||||
reqdraw = 1;
|
reqdraw = 1;
|
||||||
} else if(w && b0 == 0xf) {
|
} else if(b0 == 0xf) {
|
||||||
Uint16 x = peek16(d->dat, 0x8);
|
Uint16 x = peek16(d->dat, 0x8);
|
||||||
Uint16 y = peek16(d->dat, 0xa);
|
Uint16 y = peek16(d->dat, 0xa);
|
||||||
Uint8 layer = d->dat[0xf] & 0x40;
|
Uint8 layer = d->dat[0xf] & 0x40;
|
||||||
|
|
Loading…
Reference in New Issue