Browse Source

fix for load-state-after-load crash

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@563 be3aeb3a-fb24-0410-a615-afba39da0efa
notaz 16 years ago
parent
commit
58b75cc51a
3 changed files with 7 additions and 4 deletions
  1. 3 3
      Pico/Area.c
  2. 3 1
      Pico/cd/Pico.s
  3. 1 0
      platform/base_readme.txt

+ 3 - 3
Pico/Area.c

@@ -62,7 +62,7 @@ PICO_INTERNAL void PicoAreaPackCpu(unsigned char *cpu, int is_sub)
   memcpy(cpu,m68ki_cpu_p->dar,0x40);
   pc=m68ki_cpu_p->pc;
   *(unsigned int  *)(cpu+0x44)=m68k_get_reg(NULL, M68K_REG_SR);
-  *(unsigned int  *)(cpu+0x48)=m68ki_cpu_p->sp[0];
+  *(unsigned int  *)(cpu+0x48)=m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET];
   cpu[0x4c] = CPU_INT_LEVEL>>8;
   cpu[0x4d] = CPU_STOPPED;
   m68k_set_context(oldcontext);
@@ -95,10 +95,10 @@ PICO_INTERNAL void PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)
 #elif defined(EMU_M68K)
   void *oldcontext = m68ki_cpu_p;
   m68k_set_context(is_sub ? &PicoCpuMS68k : &PicoCpuMM68k);
+  m68k_set_reg(M68K_REG_SR, *(unsigned int *)(cpu+0x44));
   memcpy(m68ki_cpu_p->dar,cpu,0x40);
   m68ki_cpu_p->pc=*(unsigned int *)(cpu+0x40);
-  m68k_set_reg(M68K_REG_SR, *(unsigned int *)(cpu+0x44));
-  m68ki_cpu_p->sp[0]=*(unsigned int *)(cpu+0x48);
+  m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET]=*(unsigned int *)(cpu+0x48);
   CPU_INT_LEVEL = cpu[0x4c] << 8;
   CPU_STOPPED = cpu[0x4d];
   m68k_set_context(oldcontext);

+ 3 - 1
Pico/cd/Pico.s

@@ -49,9 +49,11 @@ SekRunPS:
     str     r2, [r8]
     str     r3, [r10]
 
+    ldr     r6, =CycloneJumpTab
     ldr     r1, =SekCycleCnt
     ldr     r0, =((488<<16)-PS_STEP_M68K)
-    ldr     r6, =CycloneJumpTab
+    str     r6, [r7,#0x54]
+    str     r6, [lr,#0x54]            @ make copies to avoid literal pools
 
     @ schedule m68k for the first time..
     ldr     r1, [r1]

+ 1 - 0
platform/base_readme.txt

@@ -648,6 +648,7 @@ Changelog
 1.51a
   * Fixed a sync problem between main and sub 68k. Should fix the hanging
     problem for some games.
+  * ARM: fixed a crash when CD savestate is loaded just after loading ROM.
 
 1.51
   * Improved bin_to_cso_mp3 tool, it should no longer complain about