From 656d36ed6971d12c668b19e609e8f25aba49cb88 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Thu, 27 Oct 2022 20:44:48 +0200 Subject: Update screen_talk to handle screen_dei events --- src/main.c | 11 +++++++++-- src/ppu.c | 7 +++---- src/ppu.h | 4 ++-- 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) { IWRAM_CODE void screen_talk(Device *d, u8 b0, u8 w) { - if (w) { + if (!w) { + switch(b0) { + case 0x2: d->dat[b0] = (SCREEN_WIDTH >> 8); break; + case 0x3: d->dat[b0] = (SCREEN_WIDTH); break; + case 0x4: d->dat[b0] = (SCREEN_HEIGHT >> 8); break; + case 0x5: d->dat[b0] = (SCREEN_HEIGHT); break; + } + } else { switch (b0) { case 0x1: { d->vector = mempeek16(d->dat, 0x0); @@ -269,7 +276,7 @@ file_talk(Device *d, u8 b0, u8 w) { void init_uxn(Uxn *u) { // Initialize PPU. - initppu(&ppu, 30, 20, 0); + initppu(&ppu, 30, 20); // Enable sound. 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) { } int -initppu(Ppu *p, u8 hor, u8 ver, u8 pad) { +initppu(Ppu *p, u8 hor, u8 ver) { p->hor = hor; p->ver = ver; - p->pad = pad; - p->width = (8 * p->hor + p->pad * 2); - p->height = (8 * p->ver + p->pad * 2); + p->width = (8 * p->hor); + p->height = (8 * p->ver); // Initialize display mode and bg palette. 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. typedef struct Ppu { u32 *bg, *fg; - u16 hor, ver, pad, width, height; + u16 hor, ver, width, height; } Ppu; -int initppu(Ppu *p, u8 hor, u8 ver, u8 pad); +int initppu(Ppu *p, u8 hor, u8 ver); void putcolors(u8 *addr); void ppu_pixel(u32 *layer, u16 x, u16 y, u8 color); void ppu_1bpp(u32 *layer, u16 x, u16 y, u8 *sprite, u8 color, u8 flipx, u8 flipy); -- cgit v1.2.1