| ... | ... |
@@ -58,11 +58,15 @@ ppu_resize(Ppu *p, Uint16 width, Uint16 height) |
| 58 | 58 |
Uint8 |
| 59 | 59 |
*bg = realloc(p->bg.pixels, width * height), |
| 60 | 60 |
*fg = realloc(p->fg.pixels, width * height); |
| 61 |
+ Uint32 |
|
| 62 |
+ *screen = realloc(p->screen, width * height * sizeof(Uint32)); |
|
| 61 | 63 |
if(bg) p->bg.pixels = bg; |
| 62 | 64 |
if(fg) p->fg.pixels = fg; |
| 63 |
- if(bg && fg) {
|
|
| 65 |
+ if(screen) p->screen = screen; |
|
| 66 |
+ if(bg && fg && screen) {
|
|
| 64 | 67 |
p->width = width; |
| 65 | 68 |
p->height = height; |
| 69 |
+ p->screen = screen; |
|
| 66 | 70 |
ppu_clear(p, &p->bg); |
| 67 | 71 |
ppu_clear(p, &p->fg); |
| 68 | 72 |
} |
| ... | ... |
@@ -44,7 +44,7 @@ static Ppu ppu; |
| 44 | 44 |
static Apu apu[POLYPHONY]; |
| 45 | 45 |
static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0, *devconsole; |
| 46 | 46 |
static Uint8 zoom = 1; |
| 47 |
-static Uint32 *ppu_screen, stdin_event, audio0_event; |
|
| 47 |
+static Uint32 stdin_event, audio0_event; |
|
| 48 | 48 |
|
| 49 | 49 |
static int |
| 50 | 50 |
clamp(int val, int min, int max) |
| ... | ... |
@@ -118,15 +118,12 @@ set_size(Uint16 width, Uint16 height, int is_resize) |
| 118 | 118 |
gRect.y = PAD; |
| 119 | 119 |
gRect.w = ppu.width; |
| 120 | 120 |
gRect.h = ppu.height; |
| 121 |
- if(!(ppu_screen = realloc(ppu_screen, ppu.width * ppu.height * sizeof(Uint32)))) |
|
| 122 |
- return error("ppu_screen", "Memory failure");
|
|
| 123 |
- memset(ppu_screen, 0, ppu.width * ppu.height * sizeof(Uint32)); |
|
| 124 | 121 |
if(gTexture != NULL) SDL_DestroyTexture(gTexture); |
| 125 | 122 |
SDL_RenderSetLogicalSize(gRenderer, ppu.width + PAD * 2, ppu.height + PAD * 2); |
| 126 | 123 |
gTexture = SDL_CreateTexture(gRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, ppu.width + PAD * 2, ppu.height + PAD * 2); |
| 127 | 124 |
if(gTexture == NULL || SDL_SetTextureBlendMode(gTexture, SDL_BLENDMODE_NONE)) |
| 128 | 125 |
return error("gTexture", SDL_GetError());
|
| 129 |
- if(SDL_UpdateTexture(gTexture, NULL, ppu_screen, sizeof(Uint32)) != 0) |
|
| 126 |
+ if(SDL_UpdateTexture(gTexture, NULL, ppu.screen, sizeof(Uint32)) != 0) |
|
| 130 | 127 |
return error("SDL_UpdateTexture", SDL_GetError());
|
| 131 | 128 |
if(is_resize) |
| 132 | 129 |
set_window_size(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom); |
| ... | ... |
@@ -155,8 +152,8 @@ redraw(Uxn *u) |
| 155 | 152 |
{
|
| 156 | 153 |
if(devsystem->dat[0xe]) |
| 157 | 154 |
ppu_debug(&ppu, u->wst.dat, u->wst.ptr, u->rst.ptr, u->ram.dat); |
| 158 |
- ppu_redraw(&ppu, ppu_screen); |
|
| 159 |
- if(SDL_UpdateTexture(gTexture, &gRect, ppu_screen, ppu.width * sizeof(Uint32)) != 0) |
|
| 155 |
+ ppu_redraw(&ppu, ppu.screen); |
|
| 156 |
+ if(SDL_UpdateTexture(gTexture, &gRect, ppu.screen, ppu.width * sizeof(Uint32)) != 0) |
|
| 160 | 157 |
error("SDL_UpdateTexture", SDL_GetError());
|
| 161 | 158 |
SDL_RenderClear(gRenderer); |
| 162 | 159 |
SDL_RenderCopy(gRenderer, gTexture, NULL, NULL); |