diff options
author | Bad Diode <bd@badd10de.dev> | 2021-05-20 22:18:28 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-05-20 22:18:28 +0200 |
commit | ab6fdd0347920cdcda9c4c3c9c3f01996adc48db (patch) | |
tree | 02f714fdf9a10be96e1eb82b5ebc5834d04c9259 /src/uxn/devices/ppu.c | |
parent | 1d6395f1b6aafce4e2e05bcf60f335bec0a8d4b3 (diff) | |
download | uxngba-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.c | 13 |
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 | ||
145 | u32 *backbuffer_bg0; | 145 | EWRAM_BSS |
146 | u32 *backbuffer_bg1; | 146 | static u32 *backbuffer_bg0[30 * 20 * sizeof(Tile) / 4]; |
147 | EWRAM_BSS | ||
148 | static u32 *backbuffer_bg1[30 * 20 * sizeof(Tile) / 4]; | ||
147 | static u32 dirty_tiles[20] = {0}; | 149 | static u32 dirty_tiles[20] = {0}; |
148 | 150 | ||
149 | void | 151 | void |
@@ -161,6 +163,7 @@ putcolors(Ppu *p, Uint8 *addr) { | |||
161 | } | 163 | } |
162 | } | 164 | } |
163 | 165 | ||
166 | IWRAM_CODE | ||
164 | void | 167 | void |
165 | putpixel(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 color) { | 168 | putpixel(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 | ||
182 | IWRAM_CODE | ||
179 | void | 183 | void |
180 | puticn(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, | 184 | puticn(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 | ||
237 | IWRAM_CODE | ||
233 | void | 238 | void |
234 | putchr(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, | 239 | putchr(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 | ||
257 | IWRAM_CODE | ||
252 | void | 258 | void |
253 | flipbuf(Ppu *p) { | 259 | flipbuf(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; |