... | ... |
@@ -12,8 +12,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
12 | 12 |
WITH REGARD TO THIS SOFTWARE. |
13 | 13 |
*/ |
14 | 14 |
|
15 |
-/* byte: p0-bg | p0-fg | p1-bg | p1-fg */ |
|
16 |
- |
|
17 | 15 |
static Uint8 blending[5][16] = { |
18 | 16 |
{0, 0, 0, 0, 1, 0, 1, 1, 2, 2, 0, 2, 3, 3, 3, 0}, |
19 | 17 |
{0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3}, |
... | ... |
@@ -58,10 +56,10 @@ ppu_palette(Ppu *p, Uint8 *addr) |
58 | 56 |
void |
59 | 57 |
ppu_resize(Ppu *p, Uint16 width, Uint16 height) |
60 | 58 |
{ |
61 |
- Uint8 *bg, *fg; |
|
62 |
- if(!(bg = realloc(p->bg, width * height))) |
|
63 |
- return; |
|
64 |
- if(!(fg = realloc(p->fg, width * height))) |
|
59 |
+ Uint8 |
|
60 |
+ *bg = realloc(p->bg, width * height), |
|
61 |
+ *fg = realloc(p->fg, width * height); |
|
62 |
+ if(!bg || !fg) |
|
65 | 63 |
return; |
66 | 64 |
p->bg = bg; |
67 | 65 |
p->fg = fg; |
... | ... |
@@ -82,13 +80,9 @@ ppu_clear(Ppu *p, Uint8 *layer) |
82 | 80 |
void |
83 | 81 |
ppu_redraw(Ppu *p, Uint32 *screen) |
84 | 82 |
{ |
85 |
- Uint16 x, y; |
|
86 |
- for(y = 0; y < p->height; ++y) |
|
87 |
- for(x = 0; x < p->width; ++x) { |
|
88 |
- Uint32 row = (x + y * p->width); |
|
89 |
- Uint8 color = p->fg[row] ? p->fg[row] : p->bg[row]; |
|
90 |
- screen[x + y * p->width] = p->palette[color]; |
|
91 |
- } |
|
83 |
+ Uint32 i, size = p->width * p->height; |
|
84 |
+ for(i = 0; i < size; ++i) |
|
85 |
+ screen[i] = p->palette[p->fg[i] ? p->fg[i] : p->bg[i]]; |
|
92 | 86 |
p->reqdraw = 0; |
93 | 87 |
} |
94 | 88 |
|
... | ... |
@@ -30,7 +30,7 @@ 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 | 32 |
void ppu_redraw(Ppu *p, Uint32 *screen); |
33 |
-Uint8 ppu_read(Ppu *p, Uint16 x, Uint16 y); |
|
33 |
+ |
|
34 | 34 |
void ppu_write(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 color); |
35 | 35 |
void ppu_1bpp(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy); |
36 | 36 |
void ppu_2bpp(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy); |