diff options
author | Bad Diode <bd@badd10de.dev> | 2021-05-20 21:45:04 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-05-20 21:45:04 +0200 |
commit | 1d6395f1b6aafce4e2e05bcf60f335bec0a8d4b3 (patch) | |
tree | 8e86d61333826dd2271ab7e997b1578d54f696ec /src/uxn/devices/ppu.c | |
parent | 707b6dac805bcc4f2b5e297ff3ce4b82538bcff0 (diff) | |
download | uxngba-1d6395f1b6aafce4e2e05bcf60f335bec0a8d4b3.tar.gz uxngba-1d6395f1b6aafce4e2e05bcf60f335bec0a8d4b3.zip |
Add datetime and control methods
Diffstat (limited to 'src/uxn/devices/ppu.c')
-rw-r--r-- | src/uxn/devices/ppu.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/uxn/devices/ppu.c b/src/uxn/devices/ppu.c index d70afdd..e9a94a6 100644 --- a/src/uxn/devices/ppu.c +++ b/src/uxn/devices/ppu.c | |||
@@ -163,6 +163,9 @@ putcolors(Ppu *p, Uint8 *addr) { | |||
163 | 163 | ||
164 | void | 164 | void |
165 | putpixel(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 color) { | 165 | putpixel(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 color) { |
166 | if(x >= 30 * 8 || y >= 20 * 8) { | ||
167 | return; | ||
168 | } | ||
166 | size_t tile_x = x / 8; | 169 | size_t tile_x = x / 8; |
167 | size_t tile_y = y / 8; | 170 | size_t tile_y = y / 8; |
168 | size_t start_col = x % 8; | 171 | size_t start_col = x % 8; |
@@ -176,6 +179,9 @@ putpixel(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 color) { | |||
176 | void | 179 | void |
177 | puticn(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, | 180 | puticn(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, |
178 | Uint8 flipx, Uint8 flipy) { | 181 | Uint8 flipx, Uint8 flipy) { |
182 | if(x >= 30 * 8 || y >= 20 * 8) { | ||
183 | return; | ||
184 | } | ||
179 | size_t tile_x = x / 8; | 185 | size_t tile_x = x / 8; |
180 | size_t tile_y = y / 8; | 186 | size_t tile_y = y / 8; |
181 | size_t start_col = x % 8; | 187 | size_t start_col = x % 8; |
@@ -227,6 +233,9 @@ puticn(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, | |||
227 | void | 233 | void |
228 | putchr(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, | 234 | putchr(Ppu *p, Uint32 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, |
229 | Uint8 flipx, Uint8 flipy) { | 235 | Uint8 flipx, Uint8 flipy) { |
236 | if(x >= 30 * 8 || y >= 20 * 8) { | ||
237 | return; | ||
238 | } | ||
230 | Uint16 v, h; | 239 | Uint16 v, h; |
231 | for(v = 0; v < 8; v++) | 240 | for(v = 0; v < 8; v++) |
232 | for(h = 0; h < 8; h++) { | 241 | for(h = 0; h < 8; h++) { |
@@ -284,8 +293,6 @@ initppu(Ppu *p, Uint8 hor, Uint8 ver, Uint8 pad) { | |||
284 | backbuffer_bg1 = malloc(30 * 20 * sizeof(Tile)); | 293 | backbuffer_bg1 = malloc(30 * 20 * sizeof(Tile)); |
285 | 294 | ||
286 | // Clear tile memory. | 295 | // Clear tile memory. |
287 | p->fg = &TILE_MEM[cb_fg]; | ||
288 | p->bg = &TILE_MEM[cb_bg]; | ||
289 | p->fg = backbuffer_bg0; | 296 | p->fg = backbuffer_bg0; |
290 | p->bg = backbuffer_bg1; | 297 | p->bg = backbuffer_bg1; |
291 | for (size_t i = 0; i < 30 * 20 * 8; ++i) { | 298 | for (size_t i = 0; i < 30 * 20 * 8; ++i) { |