X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fcarthw%2Fsvp%2Fssp16.c;h=2fb400152c0a44cdb94f642cab20d3fbfc9ca0b5;hb=8baf63e2eb38af5c2e661feea2935d0455193ed8;hp=1d594062d83d858cc8bae410252d752a95c3a49d;hpb=1cfc5cc4ce06642b9bc45ca3b9d32793718e9455;p=picodrive.git diff --git a/pico/carthw/svp/ssp16.c b/pico/carthw/svp/ssp16.c index 1d59406..2fb4001 100644 --- a/pico/carthw/svp/ssp16.c +++ b/pico/carthw/svp/ssp16.c @@ -1,11 +1,31 @@ -// basic, incomplete SSP160x (SSP1601?) interpreter -// with SVP memory controller emu - -// (c) Copyright 2008, Grazvydas "notaz" Ignotas -// Free for non-commercial use. - -// For commercial use, separate licencing terms must be obtained. - +/* + * basic, incomplete SSP160x (SSP1601?) interpreter + * with SVP memory controller emu + * + * Copyright (c) Gražvydas "notaz" Ignotas, 2008 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the organization nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ //#define USE_DEBUGGER /* detect ops with unimplemented/invalid fields. @@ -213,7 +233,7 @@ #define IJind (((op>>6)&4)|(op&3)) #define GET_PC() (PC - (unsigned short *)svp->iram_rom) -#define GET_PPC_OFFS() ((unsigned int)PC - (unsigned int)svp->iram_rom - 2) +#define GET_PPC_OFFS() ((unsigned char *)PC - svp->iram_rom - 2) #define SET_PC(d) PC = (unsigned short *)svp->iram_rom + d #define REG_READ(r) (((r) <= 4) ? ssp->gr[r].h : read_handlers[r]()) @@ -454,6 +474,8 @@ static int get_inc(int mode) static u32 pm_io(int reg, int write, u32 d) { + unsigned int *pmac; + if (ssp->emu_status & SSP_PMC_SET) { // this MUST be blind r or w @@ -464,7 +486,8 @@ static u32 pm_io(int reg, int write, u32 d) return 0; } elprintf(EL_SVP, "PM%i (%c) set to %08x @ %04x", reg, write ? 'w' : 'r', rPMC.v, GET_PPC_OFFS()); - ssp->pmac_read[write ? reg + 6 : reg] = rPMC.v; + pmac = write ? ssp->pmac_write : ssp->pmac_read; + pmac[reg] = rPMC.v; ssp->emu_status &= ~SSP_PMC_SET; if ((rPMC.v & 0x7fffff) == 0x1c8000 || (rPMC.v & 0x7fffff) == 0x1c8240) { elprintf(EL_SVP, "ssp IRAM copy from %06x to %04x", (ssp->RAM1[0]-1)<<1, (rPMC.v&0x7fff)<<1); @@ -553,7 +576,8 @@ static u32 pm_io(int reg, int write, u32 d) } // PMC value corresponds to last PMR accessed (not sure). - rPMC.v = ssp->pmac_read[write ? reg + 6 : reg]; + pmac = write ? ssp->pmac_write : ssp->pmac_read; + rPMC.v = pmac[reg]; return d; } @@ -647,12 +671,14 @@ static void write_XST(u32 d) static u32 read_PM4(void) { u32 d = pm_io(4, 0, 0); + if (d == 0) { switch (GET_PPC_OFFS()) { case 0x0854: ssp->emu_status |= SSP_WAIT_30FE08; elprintf(EL_SVP, "det TIGHT loop: [30fe08]"); break; case 0x4f12: ssp->emu_status |= SSP_WAIT_30FE06; elprintf(EL_SVP, "det TIGHT loop: [30fe06]"); break; } } + if (d != (u32)-1) return d; // can be removed? elprintf(EL_SVP|EL_ANOMALY, "PM4 raw r %04x @ %04x", rPM4, GET_PPC_OFFS());