return res;
if(memcmp(&rom[0xa0], romname, 16) != 0) { romname[16]=0; for(int i = 0; i < 16; i++) if(romname[i] < 32) romname[i] = 32; systemMessage(MSG_CANNOT_LOAD_SGM, N_("Cannot load save game for %s"), romname); return false; }  bool ub = utilReadInt(gzFile) ? true : false;  if(ub != useBios) { if(useBios) systemMessage(MSG_SAVE_GAME_NOT_USING_BIOS, N_("Save game is not using the BIOS files")); else systemMessage(MSG_SAVE_GAME_USING_BIOS, N_("Save game is using the BIOS file")); return false; }  utilGzRead(gzFile, &reg[0], sizeof(reg));  utilReadData(gzFile, saveGameStruct);  if(version < SAVE_GAME_VERSION_3) stopState = false; else stopState = utilReadInt(gzFile) ? true : false;  if(version < SAVE_GAME_VERSION_4) intState = false; else intState = utilReadInt(gzFile) ? true : false;  utilGzRead(gzFile, internalRAM, 0x8000); utilGzRead(gzFile, paletteRAM, 0x400); utilGzRead(gzFile, workRAM, 0x40000); utilGzRead(gzFile, vram, 0x20000); utilGzRead(gzFile, oam, 0x400); if(version < SAVE_GAME_VERSION_6) utilGzRead(gzFile, pix, 4*240*160); else utilGzRead(gzFile, pix, 4*241*162); utilGzRead(gzFile, ioMem, 0x400);  eepromReadGame(gzFile, version); flashReadGame(gzFile, version); soundReadGame(gzFile, version);  if(version > SAVE_GAME_VERSION_1) { cheatsReadGame(gzFile); } if(version > SAVE_GAME_VERSION_6) { rtcReadGame(gzFile); }  if(version <= SAVE_GAME_VERSION_7) { u32 temp; #define SWAP(a,b,c) \ temp = (a);\ (a) = (b)<<16|(c);\ (b) = (temp) >> 16;\ (c) = (temp) & 0xFFFF;  SWAP(dma0Source, DM0SAD_H, DM0SAD_L); SWAP(dma0Dest,   DM0DAD_H, DM0DAD_L); SWAP(dma1Source, DM1SAD_H, DM1SAD_L); SWAP(dma1Dest,   DM1DAD_H, DM1DAD_L); SWAP(dma2Source, DM2SAD_H, DM2SAD_L); SWAP(dma2Dest,   DM2DAD_H, DM2DAD_L); SWAP(dma3Source, DM3SAD_H, DM3SAD_L); SWAP(dma3Dest,   DM3DAD_H, DM3DAD_L); }   layerEnable = layerSettings & DISPCNT;  CPUUpdateRender(); CPUUpdateRenderBuffers(true); CPUUpdateWindow0(); CPUUpdateWindow1(); gbaSaveType = 0; switch(saveType) { case 0: cpuSaveGameFunc = flashSaveDecide; break; case 1: cpuSaveGameFunc = sramWrite; gbaSaveType = 1; break; case 2: cpuSaveGameFunc = flashWrite; gbaSaveType = 2; break; default: systemMessage(MSG_UNSUPPORTED_SAVE_TYPE, N_("Unsupported save type %d"), saveType); break; } if(eepromInUse) gbaSaveType = 3;  systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;  return true;
bool CPUReadState(const char * file){  gzFile gzFile = utilGzOpen(file, "rb");  if(gzFile == NULL)    return false;    bool res = CPUReadState(gzFile);  utilGzClose(gzFile);  return res;}