X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fpico.c;h=9a1facaa8b87bf6773b0274f1d257dce95806ffa;hb=51d86e55f61c9bd989afcde1edc6272842f08d78;hp=f2da10b686df6e95952190085164cb72c307db5f;hpb=45f2f245f51ef0c0d37df3c998595c132bfcaffa;p=picodrive.git diff --git a/pico/pico.c b/pico/pico.c index f2da10b..9a1faca 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -1,26 +1,27 @@ -// PicoDrive - -// (c) Copyright 2004 Dave, All rights reserved. -// (c) Copyright 2006-2008 notaz, All rights reserved. -// Free for non-commercial use. - -// For commercial use, separate licencing terms must be obtained. - +/* + * PicoDrive + * (c) Copyright Dave, 2004 + * (C) notaz, 2006-2010 + * + * This work is licensed under the terms of MAME license. + * See COPYING file in the top-level directory. + */ #include "pico_int.h" #include "sound/ym2612.h" -int PicoVer=0x0133; struct Pico Pico; -int PicoOpt = 0; -int PicoSkipFrame = 0; // skip rendering frame? -int emustatus = 0; // rapid_ym2612, multi_ym_updates +int PicoOpt; +int PicoSkipFrame; // skip rendering frame? int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU int PicoPadInt[2]; // internal copy -int PicoAHW = 0; // active addon hardware: scd_active, 32x_active, svp_active, pico_active -int PicoRegionOverride = 0; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe -int PicoAutoRgnOrder = 0; -struct PicoSRAM SRam = {0,}; +int PicoAHW; // active addon hardware: PAHW_* +int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe +int PicoAutoRgnOrder; + +struct PicoSRAM SRam; +int emustatus; // rapid_ym2612, multi_ym_updates +int scanlines_total; void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware void (*PicoResetHook)(void) = NULL; @@ -40,6 +41,7 @@ void PicoInit(void) PicoInitMCD(); PicoSVPInit(); + Pico32xInit(); } // to be called once on emu exit @@ -59,7 +61,7 @@ void PicoPower(void) Pico.m.frame_count = 0; // clear all memory of the emulated machine - memset(&Pico.ram,0,(unsigned int)&Pico.rom-(unsigned int)&Pico.ram); + memset(&Pico.ram,0,(unsigned char *)&Pico.rom - Pico.ram); memset(&Pico.video,0,sizeof(Pico.video)); memset(&Pico.m,0,sizeof(Pico.m)); @@ -75,6 +77,9 @@ void PicoPower(void) if (PicoAHW & PAHW_MCD) PicoPowerMCD(); + if (PicoOpt & POPT_EN_32X) + PicoPower32x(); + PicoReset(); } @@ -140,6 +145,10 @@ int PicoReset(void) if (Pico.romsize <= 0) return 1; +#ifdef DRC_CMP + PicoOpt |= POPT_DIS_VDP_FIFO|POPT_DIS_IDLE_DET; +#endif + /* must call now, so that banking is reset, and correct vectors get fetched */ if (PicoResetHook) PicoResetHook(); @@ -187,6 +196,9 @@ int PicoReset(void) if (!(PicoOpt & POPT_DIS_IDLE_DET)) SekInitIdleDet(); + if (PicoOpt & POPT_EN_32X) + PicoReset32x(); + // reset sram state; enable sram access by default if it doesn't overlap with ROM Pico.m.sram_reg = 0; if ((SRam.flags & SRF_EEPROM) || Pico.romsize <= SRam.start) @@ -199,6 +211,20 @@ int PicoReset(void) return 0; } +// flush config changes before emu loop starts +void PicoLoopPrepare(void) +{ + if (PicoRegionOverride) + // force setting possibly changed.. + Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0; + + // FIXME: PAL has 313 scanlines.. + scanlines_total = Pico.m.pal ? 312 : 262; + + Pico.m.dirtyPal = 1; + rendstatus_old = -1; +} + // dma2vram settings are just hacks to unglitch Legend of Galahad (needs <= 104 to work) // same for Outrunners (92-121, when active is set to 24) @@ -245,25 +271,6 @@ PICO_INTERNAL int CheckDMA(void) return burn; } -static __inline void SekRunM68k(int cyc) -{ - int cyc_do; - SekCycleAim+=cyc; - if ((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return; -#if defined(EMU_CORE_DEBUG) - // this means we do run-compare - SekCycleCnt+=CM_compareRun(cyc_do, 0); -#elif defined(EMU_C68K) - PicoCpuCM68k.cycles=cyc_do; - CycloneRun(&PicoCpuCM68k); - SekCycleCnt+=cyc_do-PicoCpuCM68k.cycles; -#elif defined(EMU_M68K) - SekCycleCnt+=m68k_execute(cyc_do); -#elif defined(EMU_F68K) - SekCycleCnt+=fm68k_emulate(cyc_do+1, 0, 0); -#endif -} - #include "pico_cmn.c" int z80stopCycle; @@ -279,32 +286,47 @@ PICO_INTERNAL void PicoSyncZ80(int m68k_cycles_done) z80_cycle_aim = cycles_68k_to_z80(m68k_cycles_done); cnt = z80_cycle_aim - z80_cycle_cnt; + pprof_start(z80); + elprintf(EL_BUSREQ, "z80 sync %i (%i|%i -> %i|%i)", cnt, z80_cycle_cnt, z80_cycle_cnt / 228, z80_cycle_aim, z80_cycle_aim / 228); if (cnt > 0) z80_cycle_cnt += z80_run(cnt); + + pprof_end(z80); } void PicoFrame(void) { + pprof_start(frame); + Pico.m.frame_count++; if (PicoAHW & PAHW_SMS) { PicoFrameMS(); - return; + goto end; } + // TODO: MCD+32X if (PicoAHW & PAHW_MCD) { PicoFrameMCD(); - return; + goto end; + } + + if (PicoAHW & PAHW_32X) { + PicoFrame32x(); + goto end; } //if(Pico.video.reg[12]&0x2) Pico.video.status ^= 0x10; // change odd bit in interlace mode PicoFrameStart(); PicoFrameHints(); + +end: + pprof_end(frame); } void PicoFrameDrawOnly(void)