aboutsummaryrefslogtreecommitdiffstats
path: root/src/uxn/devices/ppu.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-05-20 22:18:28 +0200
committerBad Diode <bd@badd10de.dev>2021-05-20 22:18:28 +0200
commitab6fdd0347920cdcda9c4c3c9c3f01996adc48db (patch)
tree02f714fdf9a10be96e1eb82b5ebc5834d04c9259 /src/uxn/devices/ppu.c
parent1d6395f1b6aafce4e2e05bcf60f335bec0a8d4b3 (diff)
downloaduxngba-ab6fdd0347920cdcda9c4c3c9c3f01996adc48db.tar.gz
uxngba-ab6fdd0347920cdcda9c4c3c9c3f01996adc48db.zip
Apply asie's first performance patch
Diffstat (limited to 'src/uxn/devices/ppu.c')
-rw-r--r--src/uxn/devices/ppu.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/uxn/devices/ppu.c b/src/uxn/devices/ppu.c
index e9a94a6..60ede0a 100644
--- a/src/uxn/devices/ppu.c
+++ b/src/uxn/devices/ppu.c
@@ -142,8 +142,10 @@ static Uint32 unpack_icon_lut_flipx[256] = {
142 0x11111111 142 0x11111111
143}; 143};
144 144
145u32 *backbuffer_bg0; 145EWRAM_BSS
146u32 *backbuffer_bg1; 146static u32 *backbuffer_bg0[30 * 20 * sizeof(Tile) / 4];
147EWRAM_BSS
148static u32 *backbuffer_bg1[30 * 20 * sizeof(Tile) / 4];
147static u32 dirty_tiles[20] = {0}; 149static u32 dirty_tiles[20] = {0};
148 150
149void 151void
@@ -161,6 +163,7 @@ putcolors(Ppu *p, Uint8 *addr) {
161 } 163 }
162} 164}
163 165
166IWRAM_CODE
164void 167void
165putpixel(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 color) { 168putpixel(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 color) {
166 if(x >= 30 * 8 || y >= 20 * 8) { 169 if(x >= 30 * 8 || y >= 20 * 8) {
@@ -176,6 +179,7 @@ putpixel(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 color) {
176 dirty_tiles[tile_y] |= 1 << tile_x; 179 dirty_tiles[tile_y] |= 1 << tile_x;
177} 180}
178 181
182IWRAM_CODE
179void 183void
180puticn(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, 184puticn(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color,
181 Uint8 flipx, Uint8 flipy) { 185 Uint8 flipx, Uint8 flipy) {
@@ -230,6 +234,7 @@ puticn(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color,
230 } 234 }
231} 235}
232 236
237IWRAM_CODE
233void 238void
234putchr(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, 239putchr(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color,
235 Uint8 flipx, Uint8 flipy) { 240 Uint8 flipx, Uint8 flipy) {
@@ -249,6 +254,7 @@ putchr(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color,
249 } 254 }
250} 255}
251 256
257IWRAM_CODE
252void 258void
253flipbuf(Ppu *p) { 259flipbuf(Ppu *p) {
254 Tile *mem_fg = &TILE_MEM[0]; 260 Tile *mem_fg = &TILE_MEM[0];
@@ -289,9 +295,6 @@ initppu(Ppu *p, Uint8 hor, Uint8 ver, Uint8 pad) {
289 BG_CTRL(0) = BG_CHARBLOCK(cb_fg) | BG_SCREENBLOCK(sb_idx) | BG_PRIORITY(1); 295 BG_CTRL(0) = BG_CHARBLOCK(cb_fg) | BG_SCREENBLOCK(sb_idx) | BG_PRIORITY(1);
290 BG_CTRL(1) = BG_CHARBLOCK(cb_bg) | BG_SCREENBLOCK(sb_idx) | BG_PRIORITY(2); 296 BG_CTRL(1) = BG_CHARBLOCK(cb_bg) | BG_SCREENBLOCK(sb_idx) | BG_PRIORITY(2);
291 297
292 backbuffer_bg0 = malloc(30 * 20 * sizeof(Tile));
293 backbuffer_bg1 = malloc(30 * 20 * sizeof(Tile));
294
295 // Clear tile memory. 298 // Clear tile memory.
296 p->fg = backbuffer_bg0; 299 p->fg = backbuffer_bg0;
297 p->bg = backbuffer_bg1; 300 p->bg = backbuffer_bg1;