示例#1
0
文件: m68kq68.c 项目: ptitSeb/yabause
static void m68kq68_save_state(FILE * fp)
{
   int i = 0;
   u32 val = 0;
   IOCheck_struct check = { 0, 0 };

   for (i = 0; i < 8; i++)
   {
      val = q68_get_dreg(state, i);
      ywrite(&check, (void *)&val, sizeof(u32), 1, fp);
   }

   for (i = 0; i < 8; i++)
   {
      val = q68_get_areg(state, i/*, val*/);
      ywrite(&check, (void *)&val, sizeof(u32), 1, fp);
   }

   val = q68_get_pc(state/*, val*/);
   ywrite(&check, (void *)&val, sizeof(u32), 1, fp);
   
   val = q68_get_sr(state/*, val*/);
   ywrite(&check, (void *)&val, sizeof(u32), 1, fp);
   
   val = q68_get_usp(state/*, val*/);
   ywrite(&check, (void *)&val, sizeof(u32), 1, fp);
   
   val = q68_get_ssp(state/*, val*/);
   ywrite(&check, (void *)&val, sizeof(u32), 1, fp);
}
示例#2
0
文件: cheat.c 项目: Amon-X/yabause
int CheatSave(const char *filename)
{
   FILE *fp;
   int i;
   int num;
   IOCheck_struct check = { 0, 0 };

   if (!filename)
      return -1;

   if ((fp = fopen(filename, "wb")) == NULL)
      return -1;

   fprintf(fp, "YCHT");
   num = numcheats;
#ifndef WORDS_BIGENDIAN
   DoubleWordSwap(num);
#endif
   ywrite(&check, (void *)&num, sizeof(int), 1, fp);

   for(i = 0; i < numcheats; i++)
   {
      u8 descsize;
      cheatlist_struct cheat;

      memcpy(&cheat, &cheatlist[i], sizeof(cheatlist_struct));
#ifndef WORDS_BIGENDIAN
      DoubleWordSwap(cheat.type);
      DoubleWordSwap(cheat.addr);
      DoubleWordSwap(cheat.val);
      DoubleWordSwap(cheat.enable);
#endif
      ywrite(&check, (void *)&cheat.type, sizeof(int), 1, fp);
      ywrite(&check, (void *)&cheat.addr, sizeof(u32), 1, fp);
      ywrite(&check, (void *)&cheat.val, sizeof(u32), 1, fp);
      descsize = (u8)strlen(cheatlist[i].desc)+1;
      ywrite(&check, (void *)&descsize, sizeof(u8), 1, fp);
      ywrite(&check, (void *)cheatlist[i].desc, sizeof(char), descsize, fp);
      ywrite(&check, (void *)&cheat.enable, sizeof(int), 1, fp);
   }

   fclose (fp);

   return 0;
}
示例#3
0
int YabSaveState(const char *filename)
{
   u32 i;
   FILE *fp;
   int offset;
   IOCheck_struct check;
   u8 *buf;
   int totalsize;
   int outputwidth;
   int outputheight;
   int movieposition;
   int temp;
   u32 temp32;

   check.done = 0;
   check.size = 0;

   //use a second set of savestates for movies
   filename = MakeMovieStateName(filename);
   if (!filename)
      return -1;

   if ((fp = fopen(filename, "wb")) == NULL)
      return -1;

   // Write signature
   fprintf(fp, "YSS");

   // Write endianness byte
#ifdef WORDS_BIGENDIAN
   fputc(0x00, fp);
#else
   fputc(0x01, fp);
#endif

   // Write version(fix me)
   i = 2;
   ywrite(&check, (void *)&i, sizeof(i), 1, fp);

   // Skip the next 4 bytes for now
   i = 0;
   ywrite(&check, (void *)&i, sizeof(i), 1, fp);

   //write frame number
   ywrite(&check, (void *)&framecounter, 4, 1, fp);

   //this will be updated with the movie position later
   ywrite(&check, (void *)&framecounter, 4, 1, fp);

   // Go through each area and write each state
   i += CartSaveState(fp);
   i += Cs2SaveState(fp);
   i += SH2SaveState(MSH2, fp);
   i += SH2SaveState(SSH2, fp);
   i += SoundSaveState(fp);
   i += ScuSaveState(fp);
   i += SmpcSaveState(fp);
   i += Vdp1SaveState(fp);
   i += Vdp2SaveState(fp);

   offset = StateWriteHeader(fp, "OTHR", 1);

   // Other data
   ywrite(&check, (void *)BupRam, 0x10000, 1, fp); // do we really want to save this?
   ywrite(&check, (void *)HighWram, 0x100000, 1, fp);
   ywrite(&check, (void *)LowWram, 0x100000, 1, fp);

   ywrite(&check, (void *)&yabsys.DecilineCount, sizeof(int), 1, fp);
   ywrite(&check, (void *)&yabsys.LineCount, sizeof(int), 1, fp);
   ywrite(&check, (void *)&yabsys.VBlankLineCount, sizeof(int), 1, fp);
   ywrite(&check, (void *)&yabsys.MaxLineCount, sizeof(int), 1, fp);
   temp = yabsys.DecilineStop >> YABSYS_TIMING_BITS;
   ywrite(&check, (void *)&temp, sizeof(int), 1, fp);
   temp = (yabsys.CurSH2FreqType == CLKTYPE_26MHZ) ? 268 : 286;
   ywrite(&check, (void *)&temp, sizeof(int), 1, fp);
   temp32 = (yabsys.UsecFrac * temp / 10) >> YABSYS_TIMING_BITS;
   ywrite(&check, (void *)&temp32, sizeof(u32), 1, fp);
   ywrite(&check, (void *)&yabsys.CurSH2FreqType, sizeof(int), 1, fp);
   ywrite(&check, (void *)&yabsys.IsPal, sizeof(int), 1, fp);

   VIDCore->GetGlSize(&outputwidth, &outputheight);

   totalsize=outputwidth * outputheight * sizeof(u32);

   if ((buf = (u8 *)malloc(totalsize)) == NULL)
   {
      return -2;
   }

   YuiSwapBuffers();
   #ifdef USE_OPENGL
   glPixelZoom(1,1);
   glReadBuffer(GL_BACK);
   glReadPixels(0, 0, outputwidth, outputheight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
   #endif
   YuiSwapBuffers();

   ywrite(&check, (void *)&outputwidth, sizeof(outputwidth), 1, fp);
   ywrite(&check, (void *)&outputheight, sizeof(outputheight), 1, fp);

   ywrite(&check, (void *)buf, totalsize, 1, fp);

   movieposition=ftell(fp);
   //write the movie to the end of the savestate
   SaveMovieInState(fp, check);

   i += StateFinishHeader(fp, offset);

   // Go back and update size
   fseek(fp, 8, SEEK_SET);
   ywrite(&check, (void *)&i, sizeof(i), 1, fp);
   fseek(fp, 16, SEEK_SET);
   ywrite(&check, (void *)&movieposition, sizeof(movieposition), 1, fp);

   fclose(fp);

   OSDPushMessage(OSDMSG_STATUS, 150, "STATE SAVED");

   return 0;
}
示例#4
0
文件: m68kc68k.c 项目: Amon-X/yabause
static void C68k_Save_State(c68k_struc *mcpu, FILE * fp)
{
   IOCheck_struct check = { 0, 0 };
   int i = 0;
   u32 pc = 0;

   for (i = 0; i < 8; i++)
      ywrite(&check, (void *)&mcpu->D[i], sizeof(u32), 1, fp);

   for (i = 0; i < 8; i++)
      ywrite(&check, (void *)&mcpu->A[i], sizeof(u32), 1, fp);

   ywrite(&check, (void *)&mcpu->flag_C, sizeof(u32), 1, fp);
   ywrite(&check, (void *)&mcpu->flag_V, sizeof(u32), 1, fp);
   ywrite(&check, (void *)&mcpu->flag_notZ, sizeof(u32), 1, fp);
   ywrite(&check, (void *)&mcpu->flag_N, sizeof(u32), 1, fp);

   ywrite(&check, (void *)&mcpu->flag_X, sizeof(u32), 1, fp);
   ywrite(&check, (void *)&mcpu->flag_I, sizeof(u32), 1, fp);
   ywrite(&check, (void *)&mcpu->flag_S, sizeof(u32), 1, fp);

   ywrite(&check, (void *)&mcpu->USP, sizeof(u32), 1, fp);

   pc = C68k_Get_PC(&C68K);

   ywrite(&check, (void *)&pc, sizeof(u32), 1, fp);

   ywrite(&check, (void *)&mcpu->Status, sizeof(u32), 1, fp);
   ywrite(&check, (void *)&mcpu->IRQLine, sizeof(s32), 1, fp);

   ywrite(&check, (void *)&mcpu->CycleToDo, sizeof(s32), 1, fp);
   ywrite(&check, (void *)&mcpu->CycleIO, sizeof(s32), 1, fp);
   ywrite(&check, (void *)&mcpu->CycleSup, sizeof(s32), 1, fp);
   ywrite(&check, (void *)&mcpu->dirty1, sizeof(u32), 1, fp);
}