| ... | ... |
@@ -22,7 +22,7 @@ static Uint8 blending[5][16] = {
|
| 22 | 22 |
static void |
| 23 | 23 |
ppu_clear(Ppu *p) |
| 24 | 24 |
{
|
| 25 |
- int i; |
|
| 25 |
+ unsigned int i; |
|
| 26 | 26 |
for(i = 0; i < p->stride * p->height; ++i) |
| 27 | 27 |
p->dat[i] = 0; |
| 28 | 28 |
} |
| ... | ... |
@@ -30,8 +30,10 @@ ppu_clear(Ppu *p) |
| 30 | 30 |
unsigned int |
| 31 | 31 |
ppu_pixel(Ppu *p, int fg, Uint16 x, Uint16 y, Uint8 color) |
| 32 | 32 |
{
|
| 33 |
- unsigned int i = x / PPW + y * p->stride, shift = x % PPW * 4; |
|
| 34 |
- unsigned int ret = p->dat[i]; |
|
| 33 |
+ unsigned int ret, i = x / PPW + y * p->stride, shift = x % PPW * 4; |
|
| 34 |
+ if(x >= p->width || y >= p->height) |
|
| 35 |
+ return 0; |
|
| 36 |
+ ret = p->dat[i]; |
|
| 35 | 37 |
if(fg) shift += 2; |
| 36 | 38 |
p->dat[i] &= ~(3 << shift); |
| 37 | 39 |
p->dat[i] |= color << shift; |