Browse Source

drop legacy save support

the format has been changed like 10 years ago
notaz 6 years ago
parent
commit
e64886365d
2 changed files with 7 additions and 89 deletions
  1. 4 57
      pico/state.c
  2. 3 32
      pico/z80if.c

+ 4 - 57
pico/state.c

@@ -78,54 +78,6 @@ static void *open_save_file(const char *fname, int is_save)
   return afile;
 }
 
-// legacy savestate loading
-#define SCANP(f, x) areaRead(&Pico.x, sizeof(Pico.x), 1, f)
-
-static int state_load_legacy(void *file)
-{
-  unsigned char head[32];
-  unsigned char cpu[0x60];
-  unsigned char cpu_z80[Z80_STATE_SIZE];
-  void *ym2612_regs;
-  int ok;
-
-  memset(&cpu,0,sizeof(cpu));
-  memset(&cpu_z80,0,sizeof(cpu_z80));
-
-  memset(head, 0, sizeof(head));
-  areaRead(head, sizeof(head), 1, file);
-  if (strcmp((char *)head, "Pico") != 0)
-    return -1;
-
-  elprintf(EL_STATUS, "legacy savestate");
-
-  // Scan all the memory areas:
-  SCANP(file, ram);
-  SCANP(file, vram);
-  SCANP(file, zram);
-  SCANP(file, cram);
-  SCANP(file, vsram);
-
-  // Pack, scan and unpack the cpu data:
-  areaRead(cpu, sizeof(cpu), 1, file);
-  SekUnpackCpu(cpu, 0);
-
-  SCANP(file, m);
-  SCANP(file, video);
-
-  ok = areaRead(cpu_z80, sizeof(cpu_z80), 1, file) == sizeof(cpu_z80);
-  // do not unpack if we fail to load z80 state
-  if (!ok) z80_reset();
-  else     z80_unpack(cpu_z80);
-
-  ym2612_regs = YM2612GetRegs();
-  areaRead(sn76496_regs, 28*4, 1, file);
-  areaRead(ym2612_regs, 0x200+4, 1, file);
-  ym2612_unpack_state();
-
-  return 0;
-}
-
 // ---------------------------------------------------------------------------
 
 typedef enum {
@@ -610,6 +562,9 @@ readend:
     pcd_state_loaded();
   }
 
+  Pico.m.dirtyPal = 1;
+  Pico.video.status &= ~(SR_VB | SR_F);
+
   retval = 0;
 
 out:
@@ -679,16 +634,8 @@ static int pico_state_internal(void *afile, int is_save)
 
   if (is_save)
     ret = state_save(afile);
-  else {
+  else
     ret = state_load(afile);
-    if (ret != 0) {
-      areaSeek(afile, 0, SEEK_SET);
-      ret = state_load_legacy(afile);
-    }
-
-    Pico.m.dirtyPal = 1;
-    Pico.video.status &= ~(SR_VB | SR_F);
-  }
 
   return ret;
 }

+ 3 - 32
pico/z80if.c

@@ -119,29 +119,6 @@ void z80_reset(void)
 #endif
 }
 
-/* save state stuff */
-static int z80_unpack_legacy(const void *data)
-{
-#if defined(_USE_DRZ80)
-  if (*(int *)data == 0x015A7244) { // "DrZ" v1 save?
-    u32 pc, sp;
-    memcpy(&drZ80, data+4, 0x54);
-    pc = (drZ80.Z80PC - drZ80.Z80PC_BASE) & 0xffff;
-    sp = (drZ80.Z80SP - drZ80.Z80SP_BASE) & 0xffff;
-    // update bases
-    drz80_load_pcsp(pc, sp);
-    return 0;
-  }
-#elif defined(_USE_CZ80)
-  if (*(int *)data == 0x00007a43) { // "Cz" save?
-    memcpy(&CZ80, data+8, offsetof(cz80_struc, BasePC));
-    Cz80_Set_Reg(&CZ80, CZ80_PC, *(int *)(data+4));
-    return 0;
-  }
-#endif
-  return -1;
-}
-
 struct z80sr_main {
   u8 a, f;
   u8 b, c;
@@ -226,9 +203,7 @@ int z80_unpack(const void *data)
 {
   const struct z80_state *s = data;
   if (strcmp(s->magic, "Z80") != 0) {
-    if (z80_unpack_legacy(data) != 0)
-      goto fail;
-    elprintf(EL_STATUS, "legacy z80 state");
+    elprintf(EL_STATUS, "legacy z80 state - ignored");
     return 0;
   }
 
@@ -278,13 +253,9 @@ int z80_unpack(const void *data)
     Cz80_Set_Reg(&CZ80, CZ80_IRQ, s->irq_pending ? HOLD_LINE : CLEAR_LINE);
     return 0;
   }
+#else
+  return 0;
 #endif
-
-fail:
-  elprintf(EL_STATUS|EL_ANOMALY, "z80_unpack failed");
-  z80_reset();
-  z80_int();
-  return -1;
 }
 
 void z80_exit(void)