... | ... |
@@ -50,23 +50,24 @@ ppu_palette(Ppu *p, Uint8 *addr) |
50 | 50 |
} |
51 | 51 |
for(i = 4; i < 16; ++i) |
52 | 52 |
p->palette[i] = p->palette[i / 4]; |
53 |
- p->fg.reqdraw = p->bg.reqdraw = 1; |
|
53 |
+ p->fg.changed = p->bg.changed = 1; |
|
54 | 54 |
} |
55 | 55 |
|
56 | 56 |
void |
57 | 57 |
ppu_resize(Ppu *p, Uint16 width, Uint16 height) |
58 | 58 |
{ |
59 |
- Uint8 |
|
60 |
- *bg = realloc(p->bg.p, width * height), |
|
61 |
- *fg = realloc(p->fg.p, width * height); |
|
59 |
+ Uint8 |
|
60 |
+ *bg = realloc(p->bg.pixels, width * height), |
|
61 |
+ *fg = realloc(p->fg.pixels, width * height); |
|
62 | 62 |
if(!bg || !fg) |
63 | 63 |
return; |
64 |
- p->bg.p = bg; |
|
65 |
- p->fg.p = fg; |
|
64 |
+ p->bg.pixels = bg; |
|
65 |
+ p->fg.pixels = fg; |
|
66 | 66 |
p->width = width; |
67 | 67 |
p->height = height; |
68 | 68 |
ppu_clear(p, &p->bg); |
69 | 69 |
ppu_clear(p, &p->fg); |
70 |
+ p->fg.changed = p->bg.changed = 1; |
|
70 | 71 |
} |
71 | 72 |
|
72 | 73 |
void |
... | ... |
@@ -74,7 +75,8 @@ ppu_clear(Ppu *p, Layer *layer) |
74 | 75 |
{ |
75 | 76 |
Uint32 i, size = p->width * p->height; |
76 | 77 |
for(i = 0; i < size; ++i) |
77 |
- layer->p[i] = 0x00; |
|
78 |
+ layer->pixels[i] = 0x00; |
|
79 |
+ p->fg.changed = p->bg.changed = 1; |
|
78 | 80 |
} |
79 | 81 |
|
80 | 82 |
void |
... | ... |
@@ -82,8 +84,8 @@ ppu_redraw(Ppu *p, Uint32 *screen) |
82 | 84 |
{ |
83 | 85 |
Uint32 i, size = p->width * p->height; |
84 | 86 |
for(i = 0; i < size; ++i) |
85 |
- screen[i] = p->palette[p->fg.p[i] ? p->fg.p[i] : p->bg.p[i]]; |
|
86 |
- p->fg.reqdraw = p->bg.reqdraw = 0; |
|
87 |
+ screen[i] = p->palette[p->fg.pixels[i] ? p->fg.pixels[i] : p->bg.pixels[i]]; |
|
88 |
+ p->fg.changed = p->bg.changed = 0; |
|
87 | 89 |
} |
88 | 90 |
|
89 | 91 |
void |
... | ... |
@@ -91,10 +93,10 @@ ppu_write(Ppu *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color) |
91 | 93 |
{ |
92 | 94 |
if(x < p->width && y < p->height) { |
93 | 95 |
Uint32 i = (x + y * p->width); |
94 |
- Uint8 prev = layer->p[i]; |
|
96 |
+ Uint8 prev = layer->pixels[i]; |
|
95 | 97 |
if(color != prev) { |
96 |
- layer->p[i] = color; |
|
97 |
- layer->reqdraw = 1; |
|
98 |
+ layer->pixels[i] = color; |
|
99 |
+ layer->changed = 1; |
|
98 | 100 |
} |
99 | 101 |
} |
100 | 102 |
} |
... | ... |
@@ -21,14 +21,14 @@ typedef unsigned short Uint16; |
21 | 21 |
typedef unsigned int Uint32; |
22 | 22 |
|
23 | 23 |
typedef struct Layer { |
24 |
- Uint8 *p; |
|
25 |
- Uint8 reqdraw; |
|
24 |
+ Uint8 *pixels; |
|
25 |
+ Uint8 changed; |
|
26 | 26 |
} Layer; |
27 | 27 |
|
28 | 28 |
typedef struct Ppu { |
29 |
- Layer fg, bg; |
|
30 | 29 |
Uint16 width, height; |
31 | 30 |
Uint32 palette[16]; |
31 |
+ Layer fg, bg; |
|
32 | 32 |
} Ppu; |
33 | 33 |
|
34 | 34 |
void ppu_palette(Ppu *p, Uint8 *addr); |
... | ... |
@@ -105,7 +105,6 @@ set_zoom(Uint8 scale) |
105 | 105 |
if(!gWindow) |
106 | 106 |
return; |
107 | 107 |
set_window_size(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom); |
108 |
- ppu.fg.reqdraw = ppu.bg.reqdraw = 1; |
|
109 | 108 |
} |
110 | 109 |
|
111 | 110 |
static int |
... | ... |
@@ -128,7 +127,6 @@ set_size(Uint16 width, Uint16 height, int is_resize) |
128 | 127 |
return error("SDL_UpdateTexture", SDL_GetError()); |
129 | 128 |
if(is_resize) |
130 | 129 |
set_window_size(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom); |
131 |
- ppu.fg.reqdraw = ppu.bg.reqdraw = 1; |
|
132 | 130 |
return 1; |
133 | 131 |
} |
134 | 132 |
|
... | ... |
@@ -550,7 +548,7 @@ run(Uxn *u) |
550 | 548 |
} |
551 | 549 |
breakout: |
552 | 550 |
uxn_eval(u, devscreen->vector); |
553 |
- if(ppu.fg.reqdraw || ppu.bg.reqdraw || devsystem->dat[0xe]) |
|
551 |
+ if(ppu.fg.changed || ppu.bg.changed || devsystem->dat[0xe]) |
|
554 | 552 |
redraw(u); |
555 | 553 |
if(!BENCH) { |
556 | 554 |
elapsed = (SDL_GetPerformanceCounter() - begin) / (double)SDL_GetPerformanceFrequency() * 1000.0f; |