static void gba_init(void) { cpuSaveType = 0; flashSize = 0x10000; enableRtc = false; mirroringEnable = false; load_image_preferences(); if(flashSize == 0x10000 || flashSize == 0x20000) flashSetSize(flashSize); if(enableRtc) rtcEnable(enableRtc); doMirroring(mirroringEnable); soundSetSampleRate(32000); CPUInit(0, false); CPUReset(); soundReset(); uint8_t * state_buf = (uint8_t*)malloc(2000000); serialize_size = CPUWriteState(state_buf, 2000000); free(state_buf); }
static void gba_init(void) { //default values cpuSaveType = 0; flashSize = 0x10000; enableRtc = false; mirroringEnable = false; LoadImagePreferences(); utilUpdateSystemColorMaps(); if(flashSize == 0x10000 || flashSize == 0x20000) flashSetSize(flashSize); if(rtcEnable) rtcEnable(enableRtc); doMirroring(mirroringEnable); soundInit(); soundSetSampleRate(32000); CPUInit(0, false); CPUReset(); soundReset(); soundResume(); uint8_t *state_buf = new uint8_t[2000000]; serialize_size = CPUWriteState_libgba(state_buf, 2000000); delete[] state_buf; }
static void gba_init(void) { cpuSaveType = 0; flashSize = 0x10000; enableRtc = false; mirroringEnable = false; #ifdef FRONTEND_SUPPORTS_RGB565 systemColorDepth = 16; systemRedShift = 11; systemGreenShift = 6; systemBlueShift = 0; #else systemColorDepth = 32; systemRedShift = 19; systemGreenShift = 11; systemBlueShift = 3; #endif utilUpdateSystemColorMaps(false); if (cpuSaveType == 0) utilGBAFindSave(size); else saveType = cpuSaveType; load_image_preferences(); if(flashSize == 0x10000 || flashSize == 0x20000) flashSetSize(flashSize); if(enableRtc) rtcEnable(enableRtc); doMirroring(mirroringEnable); soundInit(); soundSetSampleRate(32000); CPUInit(0, false); CPUReset(); soundReset(); uint8_t * state_buf = (uint8_t*)malloc(2000000); serialize_size = CPUWriteState(state_buf, 2000000); free(state_buf); emulating = 1; }
bool MainWnd::FileRun() { // save battery file before we change the filename... if(rom != NULL || gbRom != NULL) { if(theApp.autoSaveLoadCheatList) winSaveCheatListDefault(); writeBatteryFile(); cheatSearchCleanup(&cheatSearchData); theApp.emulator.emuCleanUp(); remoteCleanUp(); emulating = false; #ifdef APU_LOGGER_H end_apu_log(); #endif } char tempName[2048]; char file[2048]; CString oldFile = theApp.filename; utilStripDoubleExtension(theApp.szFile, tempName); _fullpath(file, tempName, 2048); theApp.filename = file; int index = theApp.filename.ReverseFind('.'); if(index != -1) theApp.filename = theApp.filename.Left(index); if( theApp.filename != oldFile ) { // clear cheat list when another game is loaded cheatsDeleteAll( false ); gbCheatRemoveAll(); } CString patchName; patchName.Format("%s.ips", theApp.filename); if( !fileExists( patchName ) ) { patchName.Format("%s.ups", theApp.filename); if( !fileExists( patchName ) ) { patchName.Format("%s.ppf", theApp.filename); if( !fileExists( patchName ) ) { // don't use any patches patchName.Empty(); } } } if(!theApp.dir.GetLength()) { int index = theApp.filename.ReverseFind('\\'); if(index != -1) { theApp.dir = theApp.filename.Left(index-1); } } IMAGE_TYPE type = utilFindType(theApp.szFile); if(type == IMAGE_UNKNOWN) { systemMessage(IDS_UNSUPPORTED_FILE_TYPE, "Unsupported file type: %s", theApp.szFile); return false; } systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; theApp.cartridgeType = type; if(type == IMAGE_GB) { if(!gbLoadRom(theApp.szFile)) return false; gbGetHardwareType(); // used for the handling of the gb Boot Rom if (gbHardware & 5) { skipBios = theApp.skipBiosFile; gbCPUInit(theApp.biosFileNameGB, theApp.useBiosFileGB); } gbReset(); theApp.emulator = GBSystem; gbBorderOn = theApp.winGbBorderOn; theApp.romSize = gbRomSize; if(theApp.autoPatch && !patchName.IsEmpty()) { int size = gbRomSize; applyPatch(patchName, &gbRom, &size); if(size != gbRomSize) { extern bool gbUpdateSizes(); gbUpdateSizes(); gbReset(); theApp.romSize = size; } } } else { int size = CPULoadRom(theApp.szFile); if(!size) return false; theApp.romSize = size; flashSetSize(theApp.winFlashSize); rtcEnable(theApp.winRtcEnable); cpuSaveType = theApp.winSaveType; GetModuleFileName(NULL, tempName, 2048); char *p = strrchr(tempName, '\\'); if(p) *p = 0; char buffer[5]; strncpy(buffer, (const char *)&rom[0xac], 4); buffer[4] = 0; strcat(tempName, "\\vba-over.ini"); UINT i = GetPrivateProfileInt(buffer, "rtcEnabled", -1, tempName); if(i != (UINT)-1) rtcEnable(i == 0 ? false : true); i = GetPrivateProfileInt(buffer, "flashSize", -1, tempName); if(i != (UINT)-1 && (i == 0x10000 || i == 0x20000)) flashSetSize((int)i); i = GetPrivateProfileInt(buffer, "saveType", -1, tempName); if(i != (UINT)-1 && (i <= 5)) cpuSaveType = (int)i; i = GetPrivateProfileInt(buffer, "mirroringEnabled", -1, tempName); if(i != (UINT)-1) doMirroring (i == 0 ? false : true); theApp.emulator = GBASystem; /* disabled due to problems if(theApp.removeIntros && rom != NULL) { *((u32 *)rom)= 0xea00002e; } */ if(theApp.autoPatch && !patchName.IsEmpty()) { int size = 0x2000000; applyPatch(patchName, &rom, &size); if(size != 0x2000000) { CPUReset(); } } } if(theApp.soundInitialized) { if(theApp.cartridgeType == 1) gbSoundReset(); else soundReset(); } else { soundInit(); theApp.soundInitialized = true; } #ifdef APU_LOGGER_H begin_apu_log("apu_log.txt"); #endif if(type == IMAGE_GBA) { skipBios = theApp.skipBiosFile; CPUInit(theApp.biosFileNameGBA.GetString(), theApp.useBiosFileGBA); CPUReset(); } readBatteryFile(); if(theApp.autoSaveLoadCheatList) winLoadCheatListDefault(); theApp.addRecentFile(theApp.szFile); theApp.updateWindowSize(theApp.videoOption); theApp.updateFrameSkip(); emulating = true; if(theApp.autoLoadMostRecent) OnFileLoadgameMostrecent(); theApp.frameskipadjust = 0; theApp.renderedFrames = 0; theApp.autoFrameSkipLastTime = systemGetClock(); theApp.rewindCount = 0; theApp.rewindCounter = 0; theApp.rewindSaveNeeded = false; toolsClearLog(); return true; }
bool MainWnd::FileRun() { // save battery file before we change the filename... if(rom != NULL || gbRom != NULL) { if(theApp.autoSaveLoadCheatList) winSaveCheatListDefault(); writeBatteryFile(); cheatSearchCleanup(&cheatSearchData); theApp.emulator.emuCleanUp(); remoteCleanUp(); emulating = false; } char tempName[2048]; char file[2048]; utilGetBaseName(theApp.szFile, tempName); _fullpath(file, tempName, 1024); theApp.filename = file; int index = theApp.filename.ReverseFind('.'); if(index != -1) theApp.filename = theApp.filename.Left(index); CString ipsname; ipsname.Format("%s.ips", theApp.filename); if(!theApp.dir.GetLength()) { int index = theApp.filename.ReverseFind('\\'); if(index != -1) { theApp.dir = theApp.filename.Left(index-1); } } IMAGE_TYPE type = utilFindType(theApp.szFile); if(type == IMAGE_UNKNOWN) { systemMessage(IDS_UNSUPPORTED_FILE_TYPE, "Unsupported file type: %s", theApp.szFile); return false; } systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; theApp.cartridgeType = (int)type; if(type == IMAGE_GB) { if(!gbLoadRom(theApp.szFile)) return false; theApp.emulator = GBSystem; gbBorderOn = theApp.winGbBorderOn; theApp.romSize = gbRomSize; if(theApp.autoIPS) { int size = gbRomSize; utilApplyIPS(ipsname, &gbRom, &size); if(size != gbRomSize) { extern bool gbUpdateSizes(); gbUpdateSizes(); gbReset(); theApp.romSize = size; } } } else { int size = CPULoadRom(theApp.szFile); if(!size) return false; theApp.romSize = size; flashSetSize(theApp.winFlashSize); rtcEnable(theApp.winRtcEnable); cpuSaveType = theApp.winSaveType; // if(cpuEnhancedDetection && winSaveType == 0) { // utilGBAFindSave(rom, size); // } GetModuleFileName(NULL, tempName, 2048); char *p = strrchr(tempName, '\\'); if(p) *p = 0; char buffer[5]; strncpy(buffer, (const char *)&rom[0xac], 4); buffer[4] = 0; strcat(tempName, "\\vba-over.ini"); UINT i = GetPrivateProfileInt(buffer, "rtcEnabled", -1, tempName); if(i != (UINT)-1) rtcEnable(i == 0 ? false : true); i = GetPrivateProfileInt(buffer, "flashSize", -1, tempName); if(i != (UINT)-1 && (i == 0x10000 || i == 0x20000)) flashSetSize((int)i); i = GetPrivateProfileInt(buffer, "saveType", -1, tempName); if(i != (UINT)-1 && (i <= 5)) cpuSaveType = (int)i; i = GetPrivateProfileInt(buffer, "mirroringEnabled", -1, tempName); if(i != (UINT)-1) doMirroring (i == 0 ? false : true); theApp.emulator = GBASystem; /* disabled due to problems if(theApp.removeIntros && rom != NULL) { *((u32 *)rom)= 0xea00002e; } */ if(theApp.autoIPS) { int size = 0x2000000; utilApplyIPS(ipsname, &rom, &size); if(size != 0x2000000) { CPUReset(); } } } if(theApp.soundInitialized) { if(theApp.cartridgeType == 1) gbSoundReset(); else soundReset(); } else { if(!soundOffFlag) soundInit(); theApp.soundInitialized = true; } if(type == IMAGE_GBA) { skipBios = theApp.skipBiosFile ? true : false; CPUInit((char *)(LPCTSTR)theApp.biosFileName, theApp.useBiosFile ? true : false); CPUReset(); } readBatteryFile(); if(theApp.autoSaveLoadCheatList) winLoadCheatListDefault(); theApp.addRecentFile(theApp.szFile); theApp.updateWindowSize(theApp.videoOption); theApp.updateFrameSkip(); if(theApp.autoHideMenu && theApp.videoOption > VIDEO_4X && theApp.menuToggle) OnFileTogglemenu(); emulating = true; if(theApp.autoLoadMostRecent) OnFileLoadgameMostrecent(); theApp.frameskipadjust = 0; theApp.renderedFrames = 0; theApp.autoFrameSkipLastTime = theApp.throttleLastTime = systemGetClock(); theApp.rewindCount = 0; theApp.rewindCounter = 0; theApp.rewindSaveNeeded = false; return true; }