Browse code

ppu: remove unused "pixels" field from Ppu; reset bg/fg to all zeroes on init

Sigrid Solveig Haflínudóttir authored on 17/09/2021 18:24:50
Showing 2 changed files
... ...
@@ -76,7 +76,7 @@ ppu_init(Ppu *p, Uint8 hor, Uint8 ver)
76 76
 {
77 77
 	p->width = 8 * hor;
78 78
 	p->height = 8 * ver;
79
-	p->bg = malloc(p->width / 4 * p->height * sizeof(Uint8));
80
-	p->fg = malloc(p->width / 4 * p->height * sizeof(Uint8));
79
+	p->bg = calloc(1, p->width / 4 * p->height * sizeof(Uint8));
80
+	p->fg = calloc(1, p->width / 4 * p->height * sizeof(Uint8));
81 81
 	return 1;
82 82
 }
... ...
@@ -19,7 +19,7 @@ typedef unsigned int Uint32;
19 19
 
20 20
 typedef struct Ppu {
21 21
 	Uint16 width, height;
22
-	Uint8 *pixels, *bg, *fg;
22
+	Uint8 *bg, *fg;
23 23
 } Ppu;
24 24
 
25 25
 int ppu_init(Ppu *p, Uint8 hor, Uint8 ver);