Esempio n. 1
0
static void AddCheatParam(uint32 A, uint64 V, unsigned int bytelen, bool bigendian)
{
 MemoryPatch patch;

 patch.addr = A;
 patch.val = V;
 patch.length = bytelen;
 patch.bigendian = bigendian;
 patch.type = 'R';
 patch.status = true;

 patch = GetCheatFields(patch);

 CHEAT_printf("Add cheat \"%s\" for address $%08x with value %llu?", patch.name.c_str(), (unsigned int)patch.addr, (unsigned long long)patch.val);
 if(GetYN(true))
 {
  try
  {
   MDFNI_AddCheat(patch);
  }
  catch(std::exception &e)
  {
   CHEAT_printf("Error adding cheat: %s", e.what());
   return;
  }
  CHEAT_puts("Cheat added.");
 }
}
Esempio n. 2
0
static void AddCheatParam(uint32 A, uint64 V, unsigned int bytelen, bool bigendian)
{
 char name[256];

 CHEAT_printf("Name: ");
 GetString(name,256);

 CHEAT_printf("Address [$%08x]: ", A);
 A=GetUI(A);

 CHEAT_printf("Byte length [%d]: ", bytelen);
 bytelen = GetUI(bytelen);

 if(bytelen > 1)
 {
  CHEAT_printf("Big endian? [%c]: ", bigendian ? 'Y' : 'N');
  bigendian = GetYN(bigendian);
 }
 else
  bigendian = 0;

 CHEAT_printf("Value [%llu]: ", V);
 V=GetUI(V);

 CHEAT_printf("Add cheat \"%s\" for address $%08x with value %llu?",name,(unsigned int)A,(unsigned long long)V);
 if(GetYN(0))
 {
  if(MDFNI_AddCheat(name,A,V,0, 'R', bytelen, bigendian))
   CHEAT_puts("Cheat added.");
  else
   CHEAT_puts("Error adding cheat.");
 }
}
Esempio n. 3
0
static void AddCheatGGPAR(int which)
{
 uint32 A;
 uint8 V;
 uint8 C;
 char type;
 char name[256],code[256];

 CHEAT_printf("Name: ");
 GetString(name,256); 
 
 CHEAT_printf("Code: ");
 GetString(code,256);

 CHEAT_printf("Add cheat \"%s\" for code \"%s\"?",name,code);
 if(GetYN(0))
 {
  if(which)
  {
   if(!MDFNI_DecodePAR(code,&A,&V,&C,&type))
   {
    CHEAT_puts("Invalid Game Genie code.");
    return;
   }
  }
  else 
  {
   if(!strcmp(CurGame->shortname, "gb"))
   {
    if(!MDFNI_DecodeGBGG(code, &A, &V, &C, &type))
    {
     CHEAT_puts("Invalid Game Genie code.");
     return;
    }
   }
   else
   {
    if(!MDFNI_DecodeGG(code,&A,&V,&C, &type))
    {
     CHEAT_puts("Invalid Game Genie code.");
     return;
    }
   }
  }

  if(MDFNI_AddCheat(name,A,V,C,type, 1, 0))
   CHEAT_puts("Cheat added.");
  else
   CHEAT_puts("Error adding cheat.");
 }
}
Esempio n. 4
0
static void AddCodeCheat(void* data)
{
 const CheatFormatStruct* cf = (CheatFormatStruct*)data;
 char name[256],code[256];
 MemoryPatch patch;
 unsigned iter = 0;

 while(1)
 {
  if(iter == 0)
   CHEAT_printf("%s Code: ", cf->FullName);
  else
   CHEAT_printf("%s Code(part %u): ", cf->FullName, iter + 1);

  GetString(code, 256);

  if(code[0] == 0)
  {
   CHEAT_printf("Aborted.");
   return;
  }

  try
  {
   if(!cf->DecodeCheat(std::string(code), &patch))
    break;

   iter++;
  }
  catch(std::exception &e)
  {
   CHEAT_printf("Decode error: %s", e.what());
  }
 }

 if(patch.name.size() == 0)
  patch.name = std::string(code);

 CHEAT_printf("Name[%s]: ", patch.name.c_str());
 GetString(name, 256); 

 if(name[0] != 0)
  patch.name = std::string(name);

 patch.status = true;

 CHEAT_printf("Add cheat?");
 if(GetYN(true))
 {
  try
  {
   MDFNI_AddCheat(patch);
  }
  catch(std::exception &e)
  {
   CHEAT_printf("Error adding cheat: %s", e.what());
   return;
  }
  CHEAT_puts("Cheat added.");
 }
}