aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2022-10-27 20:44:48 +0200
committerBad Diode <bd@badd10de.dev>2022-10-27 20:44:48 +0200
commit656d36ed6971d12c668b19e609e8f25aba49cb88 (patch)
tree507f04ab0266efb5eb570344453b5c0efe9b5003
parent75852933e7739ca726618533a5aa69f2a1d1322e (diff)
downloaduxngba-656d36ed6971d12c668b19e609e8f25aba49cb88.tar.gz
uxngba-656d36ed6971d12c668b19e609e8f25aba49cb88.zip
Update screen_talk to handle screen_dei events
-rw-r--r--src/main.c11
-rw-r--r--src/ppu.c7
-rw-r--r--src/ppu.h4
3 files changed, 14 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index 21bc2a7..06353e0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -133,7 +133,14 @@ system_talk(Device *d, u8 b0, u8 w) {
133IWRAM_CODE 133IWRAM_CODE
134void 134void
135screen_talk(Device *d, u8 b0, u8 w) { 135screen_talk(Device *d, u8 b0, u8 w) {
136 if (w) { 136 if (!w) {
137 switch(b0) {
138 case 0x2: d->dat[b0] = (SCREEN_WIDTH >> 8); break;
139 case 0x3: d->dat[b0] = (SCREEN_WIDTH); break;
140 case 0x4: d->dat[b0] = (SCREEN_HEIGHT >> 8); break;
141 case 0x5: d->dat[b0] = (SCREEN_HEIGHT); break;
142 }
143 } else {
137 switch (b0) { 144 switch (b0) {
138 case 0x1: { 145 case 0x1: {
139 d->vector = mempeek16(d->dat, 0x0); 146 d->vector = mempeek16(d->dat, 0x0);
@@ -269,7 +276,7 @@ file_talk(Device *d, u8 b0, u8 w) {
269void 276void
270init_uxn(Uxn *u) { 277init_uxn(Uxn *u) {
271 // Initialize PPU. 278 // Initialize PPU.
272 initppu(&ppu, 30, 20, 0); 279 initppu(&ppu, 30, 20);
273 280
274 // Enable sound. 281 // Enable sound.
275 init_sound(); 282 init_sound();
diff --git a/src/ppu.c b/src/ppu.c
index e1471ec..91694b7 100644
--- a/src/ppu.c
+++ b/src/ppu.c
@@ -425,12 +425,11 @@ update_cursor(u8 pos) {
425} 425}
426 426
427int 427int
428initppu(Ppu *p, u8 hor, u8 ver, u8 pad) { 428initppu(Ppu *p, u8 hor, u8 ver) {
429 p->hor = hor; 429 p->hor = hor;
430 p->ver = ver; 430 p->ver = ver;
431 p->pad = pad; 431 p->width = (8 * p->hor);
432 p->width = (8 * p->hor + p->pad * 2); 432 p->height = (8 * p->ver);
433 p->height = (8 * p->ver + p->pad * 2);
434 433
435 // Initialize display mode and bg palette. 434 // Initialize display mode and bg palette.
436 DISP_CTRL = DISP_MODE_0 | DISP_BG_0 | DISP_BG_1 | DISP_OBJ; 435 DISP_CTRL = DISP_MODE_0 | DISP_BG_0 | DISP_BG_1 | DISP_OBJ;
diff --git a/src/ppu.h b/src/ppu.h
index b5eb250..f12e1a7 100644
--- a/src/ppu.h
+++ b/src/ppu.h
@@ -19,10 +19,10 @@ WITH REGARD TO THIS SOFTWARE.
19 19
20typedef struct Ppu { 20typedef struct Ppu {
21 u32 *bg, *fg; 21 u32 *bg, *fg;
22 u16 hor, ver, pad, width, height; 22 u16 hor, ver, width, height;
23} Ppu; 23} Ppu;
24 24
25int initppu(Ppu *p, u8 hor, u8 ver, u8 pad); 25int initppu(Ppu *p, u8 hor, u8 ver);
26void putcolors(u8 *addr); 26void putcolors(u8 *addr);
27void ppu_pixel(u32 *layer, u16 x, u16 y, u8 color); 27void ppu_pixel(u32 *layer, u16 x, u16 y, u8 color);
28void ppu_1bpp(u32 *layer, u16 x, u16 y, u8 *sprite, u8 color, u8 flipx, u8 flipy); 28void ppu_1bpp(u32 *layer, u16 x, u16 y, u8 *sprite, u8 color, u8 flipx, u8 flipy);