Ejemplo n.º 1
0
void UIHexEditorWnd::overwrite(s64 index, char ch)
{
   u8 data = MappedMemoryReadByte(index / 2);
   char str[2] = { ch, '\0' };
   ch = strtol(str, NULL, 16);
   if (index % 2 == 0)
      MappedMemoryWriteByte(index / 2, data & 0xF | (ch << 4));
   else
      MappedMemoryWriteByte(index / 2, data & 0xF0 | ch);
   resetSelection();
}
Ejemplo n.º 2
0
int MappedMemoryLoad(const char *filename, u32 addr)
{
   FILE *fp;
   u32 filesize;
   u8 *buffer;
   u32 i;

   if (!filename)
      return -1;

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

   // Calculate file size
   fseek(fp, 0, SEEK_END);
   filesize = ftell(fp);
   fseek(fp, 0, SEEK_SET);

   if ((buffer = (u8 *)malloc(filesize)) == NULL)
   {
      fclose(fp);
      return -2;
   }

   fread((void *)buffer, 1, filesize, fp);
   fclose(fp);

   for (i = 0; i < filesize; i++)
      MappedMemoryWriteByte(addr+i, buffer[i]);

   free(buffer);

   return 0;
}
Ejemplo n.º 3
0
void CheatDoPatches(void)
{
   int i;

   for (i = 0; ; i++)
   {
      switch (cheatlist[i].type)
      {
         case CHEATTYPE_NONE:
            return;
         case CHEATTYPE_ENABLE:
            if (cheatlist[i].enable == 0)
               continue;
            if (MappedMemoryReadWord(cheatlist[i].addr) != cheatlist[i].val)
               return;
            break;
         case CHEATTYPE_BYTEWRITE:
            if (cheatlist[i].enable == 0)
               continue;
            MappedMemoryWriteByte(cheatlist[i].addr, (u8)cheatlist[i].val);
            SH2WriteNotify(cheatlist[i].addr, 1);
            break;
         case CHEATTYPE_WORDWRITE:
            if (cheatlist[i].enable == 0)
               continue;
            MappedMemoryWriteWord(cheatlist[i].addr, (u16)cheatlist[i].val);
            SH2WriteNotify(cheatlist[i].addr, 2);
            break;
         case CHEATTYPE_LONGWRITE:
            if (cheatlist[i].enable == 0)
               continue;
            MappedMemoryWriteLong(cheatlist[i].addr, cheatlist[i].val);
            SH2WriteNotify(cheatlist[i].addr, 4);
            break;            
      }
   }
}
Ejemplo n.º 4
0
void UIHexEditorWnd::overwrite(u32 addr, u8 data)
{
   MappedMemoryWriteByte(addr, data);
   resetSelection();
}
Ejemplo n.º 5
0
void UIHexEditorWnd::clear(u32 index, int len)
{
   for (int i=0; i < len; i++)
      MappedMemoryWriteByte(index+i, 0);
}