From 1e6b5e39f45341524d90a4c71776e92a6d2d6fe5 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 7 May 2008 21:37:51 +0000 Subject: [PATCH] Pico version reg, irq3 handling changed git-svn-id: file:///home/notaz/opt/svn/PicoDrive@443 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/Pico.c | 55 +++++++++++++++++++++++-------------------- Pico/Pico.h | 1 + Pico/Pico/Memory.c | 2 ++ Pico/Pico/Pico.c | 35 ++++++++++++++++++++------- Pico/PicoInt.h | 3 ++- platform/linux/gp2x.c | 5 ++++ 6 files changed, 67 insertions(+), 34 deletions(-) diff --git a/Pico/Pico.c b/Pico/Pico.c index 4e34e51..2a18818 100644 --- a/Pico/Pico.c +++ b/Pico/Pico.c @@ -80,39 +80,19 @@ void PicoPower(void) PicoReset(); } -int PicoReset(void) +PICO_INTERNAL void PicoDetectRegion(void) { - unsigned int region=0; - int support=0,hw=0,i=0; + int support=0, hw=0, i; unsigned char pal=0; - unsigned char sram_reg=Pico.m.sram_reg; // must be preserved - - if (Pico.romsize<=0) return 1; - - /* must call now, so that banking is reset, and correct vectors get fetched */ - if (PicoResetHook) PicoResetHook(); - - PicoMemReset(); - SekReset(); - // s68k doesn't have the TAS quirk, so we just globally set normal TAS handler in MCD mode (used by Batman games). - SekSetRealTAS(PicoAHW & PAHW_MCD); - SekCycleCntT=0; - if (PicoAHW & PAHW_MCD) - // needed for MCD to reset properly, probably some bug hides behind this.. - memset(Pico.ioports,0,sizeof(Pico.ioports)); - emustatus = 0; - - Pico.m.dirtyPal = 1; - - if(PicoRegionOverride) + if (PicoRegionOverride) { support = PicoRegionOverride; } else { // Read cartridge region data: - region=PicoRead32(0x1f0); + int region=PicoRead32(0x1f0); for (i=0;i<4;i++) { @@ -153,7 +133,32 @@ int PicoReset(void) Pico.m.hardware=(unsigned char)(hw|0x20); // No disk attached Pico.m.pal=pal; - Pico.video.status = 0x3408 | pal; // 'always set' bits | vblank | pal +} + +int PicoReset(void) +{ + unsigned char sram_reg=Pico.m.sram_reg; // must be preserved + + if (Pico.romsize<=0) return 1; + + /* must call now, so that banking is reset, and correct vectors get fetched */ + if (PicoResetHook) PicoResetHook(); + + PicoMemReset(); + SekReset(); + // s68k doesn't have the TAS quirk, so we just globally set normal TAS handler in MCD mode (used by Batman games). + SekSetRealTAS(PicoAHW & PAHW_MCD); + SekCycleCntT=0; + + if (PicoAHW & PAHW_MCD) + // needed for MCD to reset properly, probably some bug hides behind this.. + memset(Pico.ioports,0,sizeof(Pico.ioports)); + emustatus = 0; + + Pico.m.dirtyPal = 1; + + PicoDetectRegion(); + Pico.video.status = 0x3408 | Pico.m.pal; // 'always set' bits | vblank | pal PsndReset(); // pal must be known here diff --git a/Pico/Pico.h b/Pico/Pico.h index be3015a..8398e74 100644 --- a/Pico/Pico.h +++ b/Pico/Pico.h @@ -78,6 +78,7 @@ typedef struct // internal int fifo_bytes; int line_counter; + unsigned int r1, r12; } picohw_state; extern picohw_state PicoPicohw; diff --git a/Pico/Pico/Memory.c b/Pico/Pico/Memory.c index 2995c0e..2216691 100644 --- a/Pico/Pico/Memory.c +++ b/Pico/Pico/Memory.c @@ -31,6 +31,7 @@ static u32 PicoReadPico8(u32 a) { switch (a & 0x1f) { + case 0x01: d = PicoPicohw.r1; break; case 0x03: d = PicoPad[0]&0x1f; // d-pad d |= (PicoPad[0]&0x20) << 2; // red button -> C @@ -143,6 +144,7 @@ static void PicoWritePico16(u32 a,u16 d) // if (a == 0x800010) dump(d); if (a == 0x800010) PicoPicohw.fifo_bytes += 2; + if (a == 0x800012) PicoPicohw.r12 = d; elprintf(EL_UIO, "w16: %06x, %04x", a&0xffffff, d); } diff --git a/Pico/Pico/Pico.c b/Pico/Pico/Pico.c index fdd5f44..e1133c0 100644 --- a/Pico/Pico/Pico.c +++ b/Pico/Pico/Pico.c @@ -9,23 +9,32 @@ static int prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0; static void PicoLineHookPico(int count) { - PicoPicohw.line_counter += count; - if ((PicoPicohw.line_counter & 0xf) == 0 || count > 10) - { - if (PicoPicohw.fifo_bytes > 0) - PicoPicohw.fifo_bytes--; - } -#if 0 - if (PicoPicohw.line_counter - prev_line_cnt_irq3 > 200) { +#if 1 + if ((PicoPicohw.r12 & 0x4003) && PicoPicohw.line_counter - prev_line_cnt_irq3 > 200) { prev_line_cnt_irq3 = PicoPicohw.line_counter; // just a guess/hack, allows 101 Dalmantians to boot elprintf(EL_ANOMALY, "irq3"); SekInterrupt(3); + return; + } + + if (PicoPicohw.fifo_bytes == 16) { + prev_line_cnt_irq3 = PicoPicohw.line_counter; + elprintf(EL_ANOMALY, "irq3, fb=%i", PicoPicohw.fifo_bytes); + SekInterrupt(3); + PicoPicohw.fifo_bytes--; + return; } #endif + if ((PicoPicohw.line_counter & 3) == 0 || count > 10) + { + if (PicoPicohw.fifo_bytes > 0) + PicoPicohw.fifo_bytes--; + } + #if 0 if (PicoPicohw.line_counter - prev_line_cnt_irq5 > 512) { prev_line_cnt_irq5 = PicoPicohw.line_counter; @@ -46,6 +55,16 @@ PICO_INTERNAL int PicoInitPico(void) PicoPicohw.pen_pos[1] = 0x200 + 252/2; prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0; + // map version register + PicoDetectRegion(); + elprintf(EL_STATUS, "a %x", Pico.m.hardware); + switch (Pico.m.hardware >> 6) { + case 0: PicoPicohw.r1 = 0x00; break; + case 1: PicoPicohw.r1 = 0x00; break; + case 2: PicoPicohw.r1 = 0x40; break; + case 3: PicoPicohw.r1 = 0x20; break; + } + return 0; } diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index 5bc463d..b5cb06d 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -431,7 +431,8 @@ extern int emustatus; extern int z80startCycle, z80stopCycle; // in 68k cycles extern void (*PicoResetHook)(void); extern void (*PicoLineHook)(int count); -PICO_INTERNAL int CheckDMA(void); +PICO_INTERNAL int CheckDMA(void); +PICO_INTERNAL void PicoDetectRegion(void); // cd/Pico.c PICO_INTERNAL int PicoInitMCD(void); diff --git a/platform/linux/gp2x.c b/platform/linux/gp2x.c index 4a7c556..c552ad1 100644 --- a/platform/linux/gp2x.c +++ b/platform/linux/gp2x.c @@ -71,6 +71,11 @@ static gint key_press_event (GtkWidget *widget, GdkEventKey *event) case 0x19: current_keys |= GP2X_VOL_UP;break; // w case 0x2d: log_io_clear(); break; // k case 0x2e: log_io_dump(); break; // l + case 0x17: { // tab + extern int PicoReset(void); + PicoReset(); + break; + } } return 0; -- 2.39.2