From: notaz Date: Mon, 5 Nov 2012 01:11:29 +0000 (+0200) Subject: sort out 32/64bit savestate compat issues X-Git-Tag: r16~7 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e1040b6a82ee1802fda83d4de84290a02656cc0;p=pcsx_rearmed.git sort out 32/64bit savestate compat issues --- diff --git a/configure b/configure index 0f0308b3..42ab9f5c 100755 --- a/configure +++ b/configure @@ -246,13 +246,6 @@ if [ "x$builtin_gpu" = "x" ]; then builtin_gpu="peops" fi -#if [ "$ARCH" = "x86_64" ]; then - # currently we are full of 32bit assumptions, - # at least savestate compatibility will break without these -# CFLAGS="$CFLAGS -m32" -# LDFLAGS="$LDFLAGS -m32" -#fi - # supposedly we can avoid -fPIC on armv5 for slightly better performace? if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC" diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index 3bf3e033..1aa958b0 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -26,6 +26,7 @@ #include "psxdma.h" cdrStruct cdr; +static unsigned char *pTransfer; /* CD-ROM magic numbers */ #define CdlSync 0 @@ -1832,7 +1833,7 @@ unsigned char cdrRead2(void) { if (cdr.Readed == 0) { ret = 0; } else { - ret = *cdr.pTransfer++; + ret = *pTransfer++; } #ifdef CDR_LOG @@ -1948,16 +1949,16 @@ void cdrWrite3(unsigned char rt) { if (rt == 0x80 && !(cdr.Ctrl & 0x3) && cdr.Readed == 0) { cdr.Readed = 1; - cdr.pTransfer = cdr.Transfer; + pTransfer = cdr.Transfer; switch (cdr.Mode & 0x30) { case MODE_SIZE_2328: case 0x00: - cdr.pTransfer += 12; + pTransfer += 12; break; case MODE_SIZE_2340: - cdr.pTransfer += 0; + pTransfer += 0; break; default: @@ -2013,16 +2014,16 @@ void psxDma3(u32 madr, u32 bcr, u32 chcr) { - CdlPlay - Spams DMA3 and gets buffer overrun */ - size = CD_FRAMESIZE_RAW - (cdr.pTransfer - cdr.Transfer); + size = CD_FRAMESIZE_RAW - (pTransfer - cdr.Transfer); if (size > cdsize) size = cdsize; if (size > 0) { - memcpy(ptr, cdr.pTransfer, size); + memcpy(ptr, pTransfer, size); } psxCpu->Clear(madr, cdsize / 4); - cdr.pTransfer += cdsize; + pTransfer += cdsize; // burst vs normal @@ -2059,6 +2060,7 @@ void cdrReset() { cdr.CurTrack = 1; cdr.File = 1; cdr.Channel = 1; + pTransfer = cdr.Transfer; // BIOS player - default values cdr.AttenuatorLeft[0] = 0x80; @@ -2068,8 +2070,7 @@ void cdrReset() { } int cdrFreeze(gzFile f, int Mode) { - uintptr_t tmp; - + u32 tmp; if( Mode == 0 ) { StopCdda(); @@ -2078,12 +2079,12 @@ int cdrFreeze(gzFile f, int Mode) { gzfreeze(&cdr, sizeof(cdr)); if (Mode == 1) - tmp = cdr.pTransfer - cdr.Transfer; + tmp = pTransfer - cdr.Transfer; gzfreeze(&tmp, sizeof(tmp)); if (Mode == 0) { - cdr.pTransfer = cdr.Transfer + tmp; + pTransfer = cdr.Transfer + tmp; if (cdr.Play && !Config.Cdda) CDR_play(cdr.SetSectorPlay); diff --git a/libpcsxcore/cdrom.h b/libpcsxcore/cdrom.h index 772e3cab..fde7f219 100644 --- a/libpcsxcore/cdrom.h +++ b/libpcsxcore/cdrom.h @@ -52,7 +52,7 @@ typedef struct { unsigned char StatP; unsigned char Transfer[CD_FRAMESIZE_RAW]; - unsigned char *pTransfer; + unsigned int pad1; unsigned char Prev[4]; unsigned char Param[8]; diff --git a/libpcsxcore/mdec.c b/libpcsxcore/mdec.c index 6cf28865..cd8d3bf0 100644 --- a/libpcsxcore/mdec.c +++ b/libpcsxcore/mdec.c @@ -672,7 +672,30 @@ void mdec1Interrupt() { } int mdecFreeze(gzFile f, int Mode) { - gzfreeze(&mdec, sizeof(mdec)); + u8 *base = (u8 *)&psxM[0x100000]; + u32 v; + + gzfreeze(&mdec.reg0, sizeof(mdec.reg0)); + gzfreeze(&mdec.reg1, sizeof(mdec.reg1)); + + // old code used to save raw pointers.. + v = (u8 *)mdec.rl - base; + gzfreeze(&v, sizeof(v)); + mdec.rl = (u16 *)(base + (v & 0xffffe)); + v = (u8 *)mdec.rl_end - base; + gzfreeze(&v, sizeof(v)); + mdec.rl_end = (u16 *)(base + (v & 0xffffe)); + + v = 0; + if (mdec.block_buffer_pos) + v = mdec.block_buffer_pos - base; + gzfreeze(&v, sizeof(v)); + mdec.block_buffer_pos = 0; + if (v) + mdec.block_buffer_pos = base + (v & 0xfffff); + + gzfreeze(&mdec.block_buffer, sizeof(mdec.block_buffer)); + gzfreeze(&mdec.pending_dma1, sizeof(mdec.pending_dma1)); gzfreeze(iq_y, sizeof(iq_y)); gzfreeze(iq_uv, sizeof(iq_uv)); diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index ec097c5b..58a83476 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -58,9 +58,9 @@ typedef struct int SB[32+32]; // Pete added another 32 dwords in 1.6 ... prevents overflow issues with gaussian/cubic interpolation (thanx xodnizel!), and can be used for even better interpolations, eh? :) int sval; - unsigned char * pStart; // start ptr into sound mem - unsigned char * pCurr; // current pos in sound mem - unsigned char * pLoop; // loop ptr in sound mem + int iStart; // start ptr into sound mem + int iCurr; // current pos in sound mem + int iLoop; // loop ptr in sound mem int bOn; // is channel active (sample playing?) int bStop; // is channel stopped (sample _can_ still be playing, ADSR Release phase) @@ -128,9 +128,9 @@ static void save_channel(SPUCHAN_orig *d, const SPUCHAN *s, int ch) d->spos = s->spos; d->sinc = s->sinc; memcpy(d->SB, s->SB, sizeof(d->SB)); - d->pStart = (unsigned char *)((regAreaGet(ch,6)&~1)<<3); - d->pCurr = s->pCurr; - d->pLoop = s->pLoop; + d->iStart = (regAreaGet(ch,6)&~1)<<3; + d->iCurr = 0; // set by the caller + d->iLoop = 0; // set by the caller d->bOn = !!(dwChannelOn & (1<bStop = s->bStop; d->bReverb = s->bReverb; @@ -168,8 +168,8 @@ static void load_channel(SPUCHAN *d, const SPUCHAN_orig *s, int ch) d->spos = s->spos; d->sinc = s->sinc; memcpy(d->SB, s->SB, sizeof(d->SB)); - d->pCurr = (void *)((long)s->pCurr & 0x7fff0); - d->pLoop = (void *)((long)s->pLoop & 0x7fff0); + d->pCurr = (void *)((long)s->iCurr & 0x7fff0); + d->pLoop = (void *)((long)s->iLoop & 0x7fff0); if (s->bOn) dwChannelOn |= 1<bStop = s->bStop; d->bReverb = s->bReverb; @@ -238,10 +238,10 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) dwChannelOn&=~(1<s_chan[i],&s_chan[i],i); - if(pFO->s_chan[i].pCurr) - pFO->s_chan[i].pCurr-=(unsigned long)spuMemC; - if(pFO->s_chan[i].pLoop) - pFO->s_chan[i].pLoop-=(unsigned long)spuMemC; + if(s_chan[i].pCurr) + pFO->s_chan[i].iCurr=s_chan[i].pCurr-spuMemC; + if(s_chan[i].pLoop) + pFO->s_chan[i].iLoop=s_chan[i].pLoop-spuMemC; } return 1;