X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fpico.c;h=302cc699215a78278e67a3902e3d3e097e34c515;hb=fc1874de8af2fb53449bcfa931e025071f188b3e;hp=f900dfee3072e9cefce8b64bcbc333611f647a9b;hpb=3e49ffd0bf13f3a889cfb5196c2a61962dff6d0b;p=picodrive.git diff --git a/pico/pico.c b/pico/pico.c index f900dfe..302cc69 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -40,8 +40,7 @@ void PicoInit(void) PicoInitMCD(); PicoSVPInit(); - - SRam.data=0; + Pico32xInit(); } // to be called once on emu exit @@ -52,13 +51,12 @@ void PicoExit(void) PicoCartUnload(); z80_exit(); - if (SRam.data) free(SRam.data); SRam.data=0; + if (SRam.data) + free(SRam.data); } void PicoPower(void) { - unsigned char sram_reg=Pico.m.sram_reg; // must be preserved - Pico.m.frame_count = 0; // clear all memory of the emulated machine @@ -78,7 +76,9 @@ void PicoPower(void) if (PicoAHW & PAHW_MCD) PicoPowerMCD(); - Pico.m.sram_reg=sram_reg; + if (!(PicoOpt & POPT_DIS_32X)) + PicoPower32x(); + PicoReset(); } @@ -94,14 +94,16 @@ PICO_INTERNAL void PicoDetectRegion(void) else { // Read cartridge region data: - int region=PicoRead32(0x1f0); + unsigned short *rd = (unsigned short *)(Pico.rom + 0x1f0); + int region = (rd[0] << 16) | rd[1]; - for (i=0;i<4;i++) + for (i = 0; i < 4; i++) { - int c=0; + int c; - c=region>>(i<<3); c&=0xff; - if (c<=' ') continue; + c = region >> (i<<3); + c &= 0xff; + if (c <= ' ') continue; if (c=='J') support|=1; else if (c=='U') support|=4; @@ -139,16 +141,22 @@ PICO_INTERNAL void PicoDetectRegion(void) int PicoReset(void) { - unsigned char sram_reg=Pico.m.sram_reg; // must be preserved - - if (Pico.romsize<=0) return 1; + if (Pico.romsize <= 0) + return 1; /* must call now, so that banking is reset, and correct vectors get fetched */ - if (PicoResetHook) PicoResetHook(); + if (PicoResetHook) + PicoResetHook(); - PicoMemReset(); - SekReset(); memset(&PicoPadInt,0,sizeof(PicoPadInt)); + emustatus = 0; + + if (PicoAHW & PAHW_SMS) { + PicoResetMS(); + return 0; + } + + 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; @@ -156,11 +164,11 @@ int PicoReset(void) 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; Pico.m.z80_bank68k = 0; + Pico.m.z80_reset = 1; memset(Pico.zram, 0, sizeof(Pico.zram)); // ?? PicoDetectRegion(); @@ -169,7 +177,7 @@ int PicoReset(void) PsndReset(); // pal must be known here // create an empty "dma" to cause 68k exec start at random frame location - if (Pico.m.dma_xfers == 0 && !(PicoOpt&POPT_DIS_VDP_FIFO)) + if (Pico.m.dma_xfers == 0 && !(PicoOpt & POPT_DIS_VDP_FIFO)) Pico.m.dma_xfers = rand() & 0x1fff; SekFinishIdleDet(); @@ -183,12 +191,19 @@ int PicoReset(void) if (!(PicoOpt & POPT_DIS_IDLE_DET)) SekInitIdleDet(); + if (!(PicoOpt & POPT_DIS_32X)) { + PicoReset32x(); + return 0; + } + // reset sram state; enable sram access by default if it doesn't overlap with ROM - Pico.m.sram_reg=sram_reg&0x14; - if (!(Pico.m.sram_reg&4) && Pico.romsize <= SRam.start) Pico.m.sram_reg |= 1; + Pico.m.sram_reg = 0; + if ((SRam.flags & SRF_EEPROM) || Pico.romsize <= SRam.start) + Pico.m.sram_reg |= SRR_MAPPED; - elprintf(EL_STATUS, "sram: det: %i; eeprom: %i; start: %06x; end: %06x", - (Pico.m.sram_reg>>4)&1, (Pico.m.sram_reg>>2)&1, SRam.start, SRam.end); + if (SRam.flags & SRF_ENABLED) + elprintf(EL_STATUS, "sram: %06x - %06x; eeprom: %i", SRam.start, SRam.end, + !!(SRam.flags & SRF_EEPROM)); return 0; } @@ -285,27 +300,36 @@ void PicoFrame(void) { Pico.m.frame_count++; + if (PicoAHW & PAHW_SMS) { + PicoFrameMS(); + return; + } + + // TODO: MCD+32X if (PicoAHW & PAHW_MCD) { PicoFrameMCD(); return; } - else if (PicoAHW & PAHW_SMS) { - PicoFrameMS(); + + if (PicoAHW & PAHW_32X) { + PicoFrame32x(); return; } //if(Pico.video.reg[12]&0x2) Pico.video.status ^= 0x10; // change odd bit in interlace mode - if (!(PicoOpt&POPT_ALT_RENDERER)) - PicoFrameStart(); - + PicoFrameStart(); PicoFrameHints(); } void PicoFrameDrawOnly(void) { - PicoFrameStart(); - PicoDrawSync(223, 0); + if (!(PicoAHW & PAHW_SMS)) { + PicoFrameStart(); + PicoDrawSync(223, 0); + } else { + PicoFrameDrawOnlyMS(); + } } void PicoGetInternal(pint_t which, pint_ret_t *r)