CPUUpdateRenderBuffers();
CPUUpdateRenderBuffers(true);
bool CPUReadState(char * file){  gzFile gzFile = gzopen(file, "rb");  if(gzFile == NULL)    return false;  int version = utilReadInt(gzFile);  if(version > SAVE_GAME_VERSION || version < SAVE_GAME_VERSION_1) {    systemMessage(MSG_UNSUPPORTED_VBA_SGM,                  "Unsupported VisualBoyAdvance save game version %d",                  version);    gzclose(gzFile);    return false;  }    u8 romname[17];  gzread(gzFile, romname, 16);  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,"Cannot load save game for %s", romname);    gzclose(gzFile);    return false;  }  bool ub = utilReadInt(gzFile) ? true : false;  if(ub != useBios) {    if(useBios)      systemMessage(MSG_SAVE_GAME_NOT_USING_BIOS,                    "Save game is not using the BIOS files");    else      systemMessage(MSG_SAVE_GAME_USING_BIOS,                    "Save game is using the BIOS file");    gzclose(gzFile);    return false;  }  gzread(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;    gzread(gzFile, internalRAM, 0x8000);  gzread(gzFile, paletteRAM, 0x400);  gzread(gzFile, workRAM, 0x40000);  gzread(gzFile, vram, 0x20000);  gzread(gzFile, oam, 0x400);  if(version < SAVE_GAME_VERSION_6)    gzread(gzFile, pix, 4*240*160);  else    gzread(gzFile, pix, 4*241*162);  gzread(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);  }  gzclose(gzFile);  // set pointers!  layerEnable = layerSettings & DISPCNT;    CPUUpdateRender();  CPUUpdateRenderBuffers();  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,                  "Unsupported save type %d", saveType);    break;  }  if(eepromInUse)    gbaSaveType = 3;    return true;  }