... | ... |
@@ -75,6 +75,16 @@ ppu_clear(Ppu *p, Uint8 mask) |
75 | 75 |
p->pixels[i] &= mask; |
76 | 76 |
} |
77 | 77 |
|
78 |
+void |
|
79 |
+ppu_redraw(Ppu *p, Uint32 *screen) |
|
80 |
+{ |
|
81 |
+ Uint16 x, y; |
|
82 |
+ for(y = 0; y < p->height; ++y) |
|
83 |
+ for(x = 0; x < p->width; ++x) |
|
84 |
+ screen[x + y * p->width] = p->palette[ppu_read(p, x, y)]; |
|
85 |
+ p->reqdraw = 0; |
|
86 |
+} |
|
87 |
+ |
|
78 | 88 |
Uint8 |
79 | 89 |
ppu_read(Ppu *p, Uint16 x, Uint16 y) |
80 | 90 |
{ |
... | ... |
@@ -29,6 +29,7 @@ typedef struct Ppu { |
29 | 29 |
void ppu_palette(Ppu *p, Uint8 *addr); |
30 | 30 |
void ppu_resize(Ppu *p, Uint16 width, Uint16 height); |
31 | 31 |
void ppu_clear(Ppu *p, Uint8 layer); |
32 |
+void ppu_redraw(Ppu *p, Uint32 *screen); |
|
32 | 33 |
Uint8 ppu_read(Ppu *p, Uint16 x, Uint16 y); |
33 | 34 |
void ppu_write(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 color); |
34 | 35 |
void ppu_1bpp(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy); |
... | ... |
@@ -152,18 +152,14 @@ capture_screen(void) |
152 | 152 |
static void |
153 | 153 |
redraw(Uxn *u) |
154 | 154 |
{ |
155 |
- Uint16 x, y; |
|
156 | 155 |
if(devsystem->dat[0xe]) |
157 | 156 |
ppu_debug(&ppu, u->wst.dat, u->wst.ptr, u->rst.ptr, u->ram.dat); |
158 |
- for(y = 0; y < ppu.height; ++y) |
|
159 |
- for(x = 0; x < ppu.width; ++x) |
|
160 |
- ppu_screen[x + y * ppu.width] = ppu.palette[ppu_read(&ppu, x, y)]; |
|
157 |
+ ppu_redraw(&ppu, ppu_screen); |
|
161 | 158 |
if(SDL_UpdateTexture(gTexture, &gRect, ppu_screen, ppu.width * sizeof(Uint32)) != 0) |
162 | 159 |
error("SDL_UpdateTexture", SDL_GetError()); |
163 | 160 |
SDL_RenderClear(gRenderer); |
164 | 161 |
SDL_RenderCopy(gRenderer, gTexture, NULL, NULL); |
165 | 162 |
SDL_RenderPresent(gRenderer); |
166 |
- ppu.reqdraw = 0; |
|
167 | 163 |
} |
168 | 164 |
|
169 | 165 |
static void |