From 89fa852dce08d9aab0f19458a4afa246e9839e9e Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 25 Mar 2007 00:08:03 +0000 Subject: [PATCH] 1.30 release git-svn-id: file:///home/notaz/opt/svn/PicoDrive@78 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/Cart.c | 2 ++ Pico/PicoInt.h | 5 +++- Pico/cd/Memory.c | 12 +++++++--- Pico/cd/Memory.s | 4 ++-- Pico/cd/Pico.c | 45 ++++++++++++++++++++++++++++++++---- Pico/cd/gfx_cd.c | 4 +--- platform/gp2x/menu.c | 2 +- platform/linux/port_config.h | 5 ++-- 8 files changed, 63 insertions(+), 16 deletions(-) diff --git a/Pico/Cart.c b/Pico/Cart.c index 07ced8c..3954670 100644 --- a/Pico/Cart.c +++ b/Pico/Cart.c @@ -79,8 +79,10 @@ zip_failed: f = fopen(path, "rb"); if (f == NULL) return NULL; +#ifndef NO_IONBF /* we use our own buffering */ setvbuf(f, NULL, _IONBF, 0); +#endif file = malloc(sizeof(*file)); if (file == NULL) { diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index 6caff48..5c71f8a 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -12,6 +12,9 @@ #include #include "Pico.h" +// +#define USE_POLL_DETECT + // to select core, define EMU_C68K, EMU_M68K or EMU_A68K in your makefile or project @@ -210,7 +213,7 @@ struct mcd_misc unsigned short hint_vector; unsigned char busreq; unsigned char s68k_pend_ints; - unsigned int state_flags; // 04: emu state: reset_pending, + unsigned int state_flags; // 04: emu state: reset_pending, dmna_pending unsigned int counter75hz; unsigned short audio_offset; // 0c: for savestates: play pointer offset (0-1023) unsigned char audio_track; // playing audio track # (zero based) diff --git a/Pico/cd/Memory.c b/Pico/cd/Memory.c index fdbf316..fc25081 100644 --- a/Pico/cd/Memory.c +++ b/Pico/cd/Memory.c @@ -34,7 +34,6 @@ typedef unsigned int u32; // ----------------------------------------------------------------- // poller detection -#define USE_POLL_DETECT #define POLL_LIMIT 16 #define POLL_CYCLES 124 // int m68k_poll_addr, m68k_poll_cnt; @@ -53,7 +52,7 @@ static u32 m68k_reg_read16(u32 a) goto end; case 2: d = (Pico_mcd->s68k_regs[a]<<8) | (Pico_mcd->s68k_regs[a+1]&0xc7); - dprintf("m68k_regs r3: %02x @%06x", (u8)d, SekPcS68k); + dprintf("m68k_regs r3: %02x @%06x", (u8)d, SekPc); goto end; case 4: d = Pico_mcd->s68k_regs[4]<<8; @@ -129,7 +128,14 @@ void m68k_reg_write8(u32 a, u32 d) d ^= 2; // writing 0 to DMNA actually sets it, 1 does nothing } else { //dold &= ~2; // ?? +#if 1 + if ((d & 2) && !(dold & 2)) { + Pico_mcd->m.state_flags |= 2; // we must delay setting DMNA bit (needed for Silpheed) + d &= ~2; + } +#else if (d & 2) dold &= ~1; // return word RAM to s68k in 2M mode +#endif } Pico_mcd->s68k_regs[3] = d | dold; // really use s68k side register #ifdef USE_POLL_DETECT @@ -273,7 +279,7 @@ void s68k_reg_write8(u32 a, u32 d) return; // only m68k can change WP case 3: { int dold = Pico_mcd->s68k_regs[3]; - dprintf("s68k_regs w3: %02x @%06x", (u8)d, SekPc); + dprintf("s68k_regs w3: %02x @%06x", (u8)d, SekPcS68k); d &= 0x1d; d |= dold&0xc2; if (d&4) { diff --git a/Pico/cd/Memory.s b/Pico/cd/Memory.s index 8c360f8..8e1c0a4 100644 --- a/Pico/cd/Memory.s +++ b/Pico/cd/Memory.s @@ -201,8 +201,8 @@ PicoMemResetCD: @ r3 bx lr -PicoMemResetCDdecode: @r3 - tst r3, #4 +PicoMemResetCDdecode: @reg3 + tst r0, #4 bxeq lr @ we should not be called in 2M mode ldr r1, =m_s68k_write8_table ldr r3, =m_s68k_decode_write_table diff --git a/Pico/cd/Pico.c b/Pico/cd/Pico.c index acfe5e8..c1c4421 100644 --- a/Pico/cd/Pico.c +++ b/Pico/cd/Pico.c @@ -12,6 +12,28 @@ extern unsigned char formatted_bram[4*0x10]; +extern unsigned int s68k_poll_adclk; + + +#define dump_ram(ram,fname) \ +{ \ + int i, d; \ + FILE *f; \ +\ + for (i = 0; i < sizeof(ram); i+=2) { \ + d = (ram[i]<<8) | ram[i+1]; \ + *(unsigned short *)(ram+i) = d; \ + } \ + f = fopen(fname, "wb"); \ + if (f) { \ + fwrite(ram, 1, sizeof(ram), f); \ + fclose(f); \ + } \ + for (i = 0; i < sizeof(ram); i+=2) { \ + d = (ram[i]<<8) | ram[i+1]; \ + *(unsigned short *)(ram+i) = d; \ + } \ +} int PicoInitMCD(void) @@ -26,6 +48,9 @@ int PicoInitMCD(void) void PicoExitMCD(void) { End_CD_Driver(); + + //dump_ram(Pico_mcd->prg_ram, "prg.bin"); + //dump_ram(Pico.ram, "ram.bin"); } int PicoResetMCD(int hard) @@ -185,6 +210,18 @@ static __inline void update_chips(void) // update gfx chip if (Pico_mcd->rot_comp.Reg_58 & 0x8000) gfx_cd_update(); + + // delayed setting of DMNA bit (needed for Silpheed) + if (Pico_mcd->m.state_flags & 2) { + Pico_mcd->m.state_flags &= ~2; + Pico_mcd->s68k_regs[3] |= 2; + Pico_mcd->s68k_regs[3] &= ~1; +#ifdef USE_POLL_DETECT + if ((s68k_poll_adclk&0xfe) == 2) { + SekSetStopS68k(0); s68k_poll_adclk = 0; + } +#endif + } } @@ -284,8 +321,8 @@ static int PicoFrameHintsMCD(void) // Run scanline: //dprintf("m68k starting exec @ %06x", SekPc); - if(Pico.m.dma_bytes) SekCycleCnt+=CheckDMA(); - if((PicoOpt & 0x2000) && (Pico_mcd->m.busreq&3) == 1) { + if (Pico.m.dma_bytes) SekCycleCnt+=CheckDMA(); + if ((PicoOpt & 0x2000) && (Pico_mcd->m.busreq&3) == 1) { SekRunPS(cycles_68k, cycles_s68k); // "better/perfect sync" } else { SekRun(cycles_68k); @@ -293,7 +330,7 @@ static int PicoFrameHintsMCD(void) SekRunS68k(cycles_s68k); } - if((PicoOpt&4) && Pico.m.z80Run) { + if ((PicoOpt&4) && Pico.m.z80Run) { Pico.m.z80Run|=2; z80CycleAim+=cycles_z80; total_z80+=z80_run(z80CycleAim-total_z80); @@ -303,7 +340,7 @@ static int PicoFrameHintsMCD(void) } // draw a frame just after vblank in alternative render mode - if(!PicoSkipFrame && (PicoOpt&0x10)) + if (!PicoSkipFrame && (PicoOpt&0x10)) PicoFrameFull(); return 0; diff --git a/Pico/cd/gfx_cd.c b/Pico/cd/gfx_cd.c index db2a406..f902235 100644 --- a/Pico/cd/gfx_cd.c +++ b/Pico/cd/gfx_cd.c @@ -1,6 +1,4 @@ -// TODO... -// #include #include "../PicoInt.h" #define rot_comp Pico_mcd->rot_comp @@ -359,7 +357,7 @@ unsigned int gfx_cd_read(unsigned int a) dprintf("gfx_cd_read(%02x) = %04x", a, d); - return 0; + return d; } void gfx_cd_write16(unsigned int a, unsigned int d) diff --git a/platform/gp2x/menu.c b/platform/gp2x/menu.c index d424152..47b91b1 100644 --- a/platform/gp2x/menu.c +++ b/platform/gp2x/menu.c @@ -799,7 +799,7 @@ static void cd_menu_loop_options(void) } else { if (PicoCDBuffers < 64) PicoCDBuffers = 64; else PicoCDBuffers <<= 1; - if (PicoCDBuffers > 4096) PicoCDBuffers = 4096; + if (PicoCDBuffers > 8*1024) PicoCDBuffers = 8*1024; // 16M } break; case 7: currentConfig.PicoOpt^=0x1000; break; diff --git a/platform/linux/port_config.h b/platform/linux/port_config.h index a0a855a..42be264 100644 --- a/platform/linux/port_config.h +++ b/platform/linux/port_config.h @@ -4,6 +4,7 @@ #define PORT_CONFIG_H #define CPU_CALL +#define NO_IONBF // draw2.c #define START_ROW 0 // which row of tiles to start rendering at? @@ -12,8 +13,8 @@ // pico.c #define CAN_HANDLE_240_LINES 1 -//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) -#define dprintf(x...) +#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) +//#define dprintf(x...) #endif //PORT_CONFIG_H -- 2.39.2