sort out 32/64bit savestate compat issues
authornotaz <notasas@gmail.com>
Mon, 5 Nov 2012 01:11:29 +0000 (03:11 +0200)
committernotaz <notasas@gmail.com>
Mon, 5 Nov 2012 01:12:26 +0000 (03:12 +0200)
configure
libpcsxcore/cdrom.c
libpcsxcore/cdrom.h
libpcsxcore/mdec.c
plugins/dfsound/freeze.c

index 0f0308b..42ab9f5 100755 (executable)
--- 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"
index 3bf3e03..1aa958b 100644 (file)
@@ -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);
index 772e3ca..fde7f21 100644 (file)
@@ -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];
index 6cf2886..cd8d3bf 100644 (file)
@@ -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));
 
index ec097c5..58a8347 100644 (file)
@@ -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? :)\r
  int               sval;\r
 \r
unsigned char *   pStart;                             // start ptr into sound mem\r
unsigned char *   pCurr;                              // current pos in sound mem\r
unsigned char *   pLoop;                              // loop ptr in sound mem\r
int               iStart;                             // start ptr into sound mem\r
int               iCurr;                              // current pos in sound mem\r
int               iLoop;                              // loop ptr in sound mem\r
 \r
  int               bOn;                                // is channel active (sample playing?)\r
  int               bStop;                              // is channel stopped (sample _can_ still be playing, ADSR Release phase)\r
@@ -128,9 +128,9 @@ static void save_channel(SPUCHAN_orig *d, const SPUCHAN *s, int ch)
  d->spos = s->spos;\r
  d->sinc = s->sinc;\r
  memcpy(d->SB, s->SB, sizeof(d->SB));\r
- d->pStart = (unsigned char *)((regAreaGet(ch,6)&~1)<<3);\r
- d->pCurr = s->pCurr;\r
- d->pLoop = s->pLoop;\r
+ d->iStart = (regAreaGet(ch,6)&~1)<<3;\r
+ d->iCurr = 0; // set by the caller\r
+ d->iLoop = 0; // set by the caller\r
  d->bOn = !!(dwChannelOn & (1<<ch));\r
  d->bStop = s->bStop;\r
  d->bReverb = s->bReverb;\r
@@ -168,8 +168,8 @@ static void load_channel(SPUCHAN *d, const SPUCHAN_orig *s, int ch)
  d->spos = s->spos;\r
  d->sinc = s->sinc;\r
  memcpy(d->SB, s->SB, sizeof(d->SB));\r
- d->pCurr = (void *)((long)s->pCurr & 0x7fff0);\r
- d->pLoop = (void *)((long)s->pLoop & 0x7fff0);\r
+ d->pCurr = (void *)((long)s->iCurr & 0x7fff0);\r
+ d->pLoop = (void *)((long)s->iLoop & 0x7fff0);\r
  if (s->bOn) dwChannelOn |= 1<<ch;\r
  d->bStop = s->bStop;\r
  d->bReverb = s->bReverb;\r
@@ -238,10 +238,10 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF)
       dwChannelOn&=~(1<<i);\r
 \r
      save_channel(&pFO->s_chan[i],&s_chan[i],i);\r
-     if(pFO->s_chan[i].pCurr)\r
-      pFO->s_chan[i].pCurr-=(unsigned long)spuMemC;\r
-     if(pFO->s_chan[i].pLoop)\r
-      pFO->s_chan[i].pLoop-=(unsigned long)spuMemC;\r
+     if(s_chan[i].pCurr)\r
+      pFO->s_chan[i].iCurr=s_chan[i].pCurr-spuMemC;\r
+     if(s_chan[i].pLoop)\r
+      pFO->s_chan[i].iLoop=s_chan[i].pLoop-spuMemC;\r
     }\r
 \r
    return 1;\r