From: notaz Date: Sun, 8 Sep 2013 23:59:44 +0000 (+0300) Subject: cd: delay gfx ops again X-Git-Tag: v1.90~14 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=picodrive.git;a=commitdiff_plain;h=87650acd75bc29d6b5a6dca6647545b043403d23 cd: delay gfx ops again --- diff --git a/pico/cd/gfx_cd.c b/pico/cd/gfx_cd.c index 96d44f2..085c5e3 100644 --- a/pico/cd/gfx_cd.c +++ b/pico/cd/gfx_cd.c @@ -10,6 +10,8 @@ #undef dprintf #define dprintf(...) +#define UPDATE_CYCLES 20000 + #define _rot_comp Pico_mcd->rot_comp static void gfx_do_line(unsigned int func, unsigned short *stamp_base, @@ -17,7 +19,8 @@ static void gfx_do_line(unsigned int func, unsigned short *stamp_base, static void gfx_cd_start(void) { - int w, h; + int w, h, cycles; + int y_step; w = _rot_comp.Reg_62; h = _rot_comp.Reg_64; @@ -34,10 +37,6 @@ static void gfx_cd_start(void) _rot_comp.YD = (_rot_comp.Reg_60 >> 3) & 7; _rot_comp.Vector_Adr = (_rot_comp.Reg_66 & 0xfffe) << 2; - _rot_comp.Reg_58 |= 0x8000; // Stamp_Size, we start a new GFX operation - - pcd_event_schedule_s68k(PCD_EVENT_GFX, 5 * w * h); - switch (_rot_comp.Reg_58 & 6) // Scr_16? { case 0: // ? @@ -54,17 +53,57 @@ static void gfx_cd_start(void) break; } + _rot_comp.Reg_58 |= 0x8000; // Stamp_Size, we start a new GFX operation + + cycles = 5 * w * h; + if (cycles > UPDATE_CYCLES) + y_step = (UPDATE_CYCLES + 5 * w - 1) / (5 * w); + else + y_step = h; + + _rot_comp.y_step = y_step; + pcd_event_schedule_s68k(PCD_EVENT_GFX, 5 * w * y_step); +} + +void gfx_cd_update(unsigned int cycles) +{ + int w = _rot_comp.Reg_62; + int h, next; + + if (!(Pico_mcd->rot_comp.Reg_58 & 0x8000)) + return; + + h = _rot_comp.Reg_64; + _rot_comp.Reg_64 -= _rot_comp.y_step; + + if ((int)_rot_comp.Reg_64 <= 0) { + Pico_mcd->rot_comp.Reg_58 &= 0x7fff; + Pico_mcd->rot_comp.Reg_64 = 0; + if (Pico_mcd->s68k_regs[0x33] & PCDS_IEN1) { + elprintf(EL_INTS |EL_CD, "s68k: gfx_cd irq 1"); + SekInterruptS68k(1); + } + } + else { + next = _rot_comp.Reg_64; + if (next > _rot_comp.y_step) + next = _rot_comp.y_step; + + pcd_event_schedule(cycles, PCD_EVENT_GFX, 5 * w * next); + h = _rot_comp.y_step; + } + if (PicoOpt & POPT_EN_MCD_GFX) { unsigned int func = _rot_comp.Function; - unsigned short *stamp_base = (unsigned short *) (Pico_mcd->word_ram2M + _rot_comp.Stamp_Map_Adr); + unsigned short *stamp_base = (unsigned short *) + (Pico_mcd->word_ram2M + _rot_comp.Stamp_Map_Adr); while (h--) gfx_do_line(func, stamp_base, w); } } - PICO_INTERNAL_ASM unsigned int gfx_cd_read(unsigned int a) { unsigned int d = 0; @@ -76,12 +115,7 @@ PICO_INTERNAL_ASM unsigned int gfx_cd_read(unsigned int a) case 0x5E: d = _rot_comp.Reg_5E; break; case 0x60: d = _rot_comp.Reg_60; break; case 0x62: d = _rot_comp.Reg_62; break; - case 0x64: - d = _rot_comp.Reg_64; - if (_rot_comp.Reg_64 > 1) - // fudge.. - _rot_comp.Reg_64--; - break; + case 0x64: d = _rot_comp.Reg_64; break; case 0x66: break; default: dprintf("gfx_cd_read FIXME: unexpected address: %02x", a); break; } diff --git a/pico/cd/gfx_cd.h b/pico/cd/gfx_cd.h index a80b2ec..20cc9ae 100644 --- a/pico/cd/gfx_cd.h +++ b/pico/cd/gfx_cd.h @@ -20,12 +20,14 @@ typedef struct unsigned int Draw_Speed; unsigned int YD; - int pad[10]; + unsigned int y_step; + int pad[9]; } Rot_Comp; PICO_INTERNAL_ASM unsigned int gfx_cd_read(unsigned int a); PICO_INTERNAL_ASM void gfx_cd_write16(unsigned int a, unsigned int d); +void gfx_cd_update(unsigned int cycles); PICO_INTERNAL void gfx_cd_reset(void); diff --git a/pico/cd/mcd.c b/pico/cd/mcd.c index 0824ec0..323d482 100644 --- a/pico/cd/mcd.c +++ b/pico/cd/mcd.c @@ -127,19 +127,6 @@ static void pcd_int3_timer_event(unsigned int now) Pico_mcd->s68k_regs[0x31] * 384); } -static void pcd_gfx_event(unsigned int now) -{ - // update gfx chip - if (Pico_mcd->rot_comp.Reg_58 & 0x8000) { - Pico_mcd->rot_comp.Reg_58 &= 0x7fff; - Pico_mcd->rot_comp.Reg_64 = 0; - if (Pico_mcd->s68k_regs[0x33] & PCDS_IEN1) { - elprintf(EL_INTS |EL_CD, "s68k: gfx_cd irq 1"); - SekInterruptS68k(1); - } - } -} - static void pcd_dma_event(unsigned int now) { int ddx = Pico_mcd->s68k_regs[4] & 7; @@ -154,7 +141,7 @@ static unsigned int event_time_next; static event_cb *pcd_event_cbs[PCD_EVENT_COUNT] = { [PCD_EVENT_CDC] = pcd_cdc_event, [PCD_EVENT_TIMER3] = pcd_int3_timer_event, - [PCD_EVENT_GFX] = pcd_gfx_event, + [PCD_EVENT_GFX] = gfx_cd_update, [PCD_EVENT_DMA] = pcd_dma_event, };