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; 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); }
void reset() { eepromReset(game.getEEPROMSize()); flashReset(game.getFlashSize()); rtcReset(); rtcEnable(game.hasRTC()); }
static void blink(void) { enablePin(1, 0, GPIO_OUT_PP); // LED enablePin(1, 1, GPIO_OUT_PP); // LED setPin(1, 0); // Request periodic (per second) RTC events. rtcEnable(2015, 1, 1, 9, 0, 0); rtcSetPeriodicEvent(MSKSR_MPSE); }
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; }
void Window::vApplyPerGameConfig() { std::string sRDBFile = PKGDATADIR "/vba-over.ini"; if (!Glib::file_test(sRDBFile, Glib::FILE_TEST_EXISTS)) return; char csGameID[5]; csGameID[0] = rom[0xac]; csGameID[1] = rom[0xad]; csGameID[2] = rom[0xae]; csGameID[3] = rom[0xaf]; csGameID[4] = '\0'; Glib::KeyFile oKeyFile; oKeyFile.load_from_file(sRDBFile); if (!oKeyFile.has_group(csGameID)) return; if (oKeyFile.has_key(csGameID, "rtcEnabled")) { bool bRTCEnabled = oKeyFile.get_boolean(csGameID, "rtcEnabled"); rtcEnable(bRTCEnabled); } if (oKeyFile.has_key(csGameID, "flashSize")) { Glib::ustring sFlashSize = oKeyFile.get_string(csGameID, "flashSize"); int iFlashSize = atoi(sFlashSize.c_str()); if (iFlashSize == 0x10000 || iFlashSize == 0x20000) flashSetSize(iFlashSize); } if (oKeyFile.has_key(csGameID, "saveType")) { int iSaveType = oKeyFile.get_integer(csGameID, "saveType"); if (iSaveType >= 0 && iSaveType <= 5) cpuSaveType = iSaveType; } if (oKeyFile.has_key(csGameID, "mirroringEnabled")) { mirroringEnable = oKeyFile.get_boolean(csGameID, "mirroringEnabled"); } }
extern "C" void ispcEnable (RTCScene scene, unsigned geomID) { rtcEnable(scene,geomID); }
void Window::vApplyConfigGBARTC() { bool iRTC = m_poCoreConfig->oGetKey<bool>("enable_rtc"); rtcEnable(iRTC); }
bool MainWnd::FileRun() { // save battery file before we change the filename... if(rom != NULL || gbRom != NULL) { if(theApp.autoSaveLoadCheatList) winSaveCheatListDefault(); writeBatteryFile(); cheatSearchCleanup(&cheatSearchData); theApp.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; } theApp.cartridgeType = (int)type; if(type == IMAGE_GB) { if(!gbLoadRom(theApp.szFile)) return false; theApp.emuWriteState = gbWriteSaveState; theApp.emuWriteMemState = gbWriteMemSaveState; theApp.emuReadState = gbReadSaveState; theApp.emuReadMemState = gbReadMemSaveState; theApp.emuWriteBattery = gbWriteBatteryFile; theApp.emuReadBattery = gbReadBatteryFile; theApp.emuReset = gbReset; theApp.emuCleanUp = gbCleanUp; theApp.emuWritePNG = gbWritePNGFile; theApp.emuWriteBMP = gbWriteBMPFile; theApp.emuMain = gbEmulate; #ifdef FINAL_VERSION theApp.emuCount = 70000/4; #else theApp.emuCount = 1000; #endif gbBorderOn = theApp.winGbBorderOn; if(theApp.autoIPS) { int size = gbRomSize; utilApplyIPS(ipsname, &gbRom, &size); if(size != gbRomSize) { extern bool gbUpdateSizes(); gbUpdateSizes(); gbReset(); } } } else { int size = CPULoadRom(theApp.szFile); if(!size) return false; 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; theApp.emuWriteState = CPUWriteState; theApp.emuWriteMemState = CPUWriteMemState; theApp.emuReadState = CPUReadState; theApp.emuReadMemState = CPUReadMemState; theApp.emuWriteBattery = CPUWriteBatteryFile; theApp.emuReadBattery = CPUReadBatteryFile; theApp.emuReset = CPUReset; theApp.emuCleanUp = CPUCleanUp; theApp.emuWritePNG = CPUWritePNGFile; theApp.emuWriteBMP = CPUWriteBMPFile; theApp.emuMain = CPULoop; #ifdef FINAL_VERSION theApp.emuCount = 250000; #else theApp.emuCount = 5000; #endif 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; theApp.disablePowerManagement(); return true; }
void rtcEnableWarioRumble(bool e) { if (e) rtcEnable(true); rtcWarioRumbleEnabled = e; }
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; }
void LoadConfig() { agbPrint = ReadPrefHex("agbPrint"); autoFireMaxCount = fromDec(ReadPrefString("autoFireMaxCount")); autoFrameSkip = ReadPref("autoFrameSkip", 0); autoLoadMostRecent = ReadPref("autoLoadMostRecent", 0); autoPatch = ReadPref("autoPatch", 1); autoSaveLoadCheatList = ReadPref("autoSaveCheatList", 1); aviRecordDir = ReadPrefString("aviRecordDir"); batteryDir = ReadPrefString("batteryDir"); biosFileNameGB = ReadPrefString("biosFileGB"); biosFileNameGBA = ReadPrefString("biosFileGBA"); biosFileNameGBC = ReadPrefString("biosFileGBC"); captureFormat = ReadPref("captureFormat", 0); cheatsEnabled = ReadPref("cheatsEnabled", 0); cpuDisableSfx = ReadPref("disableSfx", 0); cpuSaveType = ReadPrefHex("saveType"); disableMMX = ReadPref("disableMMX", 0); disableStatusMessages = ReadPrefHex("disableStatus"); filterMT = ReadPref("filterEnableMultiThreading", 0); filter = ReadPref("filter", 0); frameSkip = ReadPref("frameSkip", 0); fsAdapter = ReadPref("fsAdapter", 0); fsColorDepth = ReadPref("fsColorDepth", 32); fsFrequency = ReadPref("fsFrequency", 60); fsHeight = ReadPref("fsHeight", 600); fsWidth = ReadPref("fsWidth", 800); fullScreen = ReadPrefHex("fullScreen"); fullScreenStretch = ReadPref("stretch", 0); gbBorderAutomatic = ReadPref("borderAutomatic", 0); gbBorderOn = ReadPrefHex("borderOn"); gbColorOption = ReadPref("colorOption", 0); gbEmulatorType = ReadPref("emulatorType", 1); gbFrameSkip = ReadPref("gbFrameSkip", 0); gbPaletteOption = ReadPref("gbPaletteOption", 0); gbSoundSetDeclicking(ReadPref("gbSoundDeclicking", 1)); gb_effects_config.echo = (float)ReadPref("gbSoundEffectsEcho", 20) / 100.0f; gb_effects_config.enabled = ReadPref("gbSoundEffectsEnabled", 0); gb_effects_config.stereo = (float)ReadPref("gbSoundEffectsStereo", 15) / 100.0f; gb_effects_config.surround = ReadPref("gbSoundEffectsSurround", 0); gdbBreakOnLoad = ReadPref("gdbBreakOnLoad", 0); gdbPort = ReadPref("gdbPort", 55555); glFilter = ReadPref("glFilter", 1); ifbType = ReadPref("ifbType", 0); joypadDefault = ReadPref("joypadDefault", 0); languageOption = ReadPref("language", 1); linkAuto = ReadPref("LinkAuto", 1); linkHacks = ReadPref("LinkHacks", 0); linkHostAddr = ReadPrefString("LinkHostAddr", "localhost"); linkMode = ReadPref("LinkMode", 0); // LINK_DISCONNECTED = 0 linkNumPlayers = ReadPref("LinkNumPlayers", 2); linkTimeout = ReadPref("LinkTimeout", 1); loadDotCodeFile = ReadPrefString("loadDotCodeFile"); maxScale = ReadPref("maxScale", 0); movieRecordDir = ReadPrefString("movieRecordDir"); openGL = ReadPrefHex("openGL"); optFlashSize = ReadPrefHex("flashSize"); pauseWhenInactive = ReadPref("pauseWhenInactive", 1); recentFreeze = ReadPref("recentFreeze", 0); rewindTimer = ReadPref("rewindTimer", 0); romDirGB = ReadPrefString("romDirGB"); romDirGBA = ReadPrefString("romDirGBA"); romDirGBC = ReadPrefString("romDirGBC"); rtcEnabled = ReadPref("rtcEnabled", 0); saveDir = ReadPrefString("saveDir"); saveDotCodeFile = ReadPrefString("saveDotCodeFile"); screenShotDir = ReadPrefString("screenShotDir"); showSpeed = ReadPref("showSpeed", 0); showSpeedTransparent = ReadPref("showSpeedTransparent", 1); skipBios = ReadPref("skipBios", 0); skipSaveGameBattery = ReadPref("skipSaveGameBattery", 0); skipSaveGameCheats = ReadPref("skipSaveGameCheats", 0); soundFiltering = (float)ReadPref("gbaSoundFiltering", 50) / 100.0f; soundInterpolation = ReadPref("gbaSoundInterpolation", 1); soundRecordDir = ReadPrefString("soundRecordDir"); threadPriority = ReadPref("priority", 2); throttle = ReadPref("throttle", 100); tripleBuffering = ReadPref("tripleBuffering", 0); useBios = ReadPrefHex("useBiosGBA"); useBiosFileGB = ReadPref("useBiosGB", 0); useBiosFileGBA = ReadPref("useBiosGBA", 0); useBiosFileGBC = ReadPref("useBiosGBC", 0); videoOption = ReadPref("video", 2); // VIDEO_3X = 2 vsync = ReadPref("vsync", false); windowPositionX = ReadPref("windowX", 0); windowPositionY = ReadPref("windowY", 0); winFlashSize = ReadPref("flashSize", 0x10000); winGbBorderOn = ReadPref("borderOn", 0); winGbPrinterEnabled = ReadPref("gbPrinter", 0); int soundQuality = (ReadPrefHex("soundQuality")); switch (soundQuality) { case 1: case 2: case 4: break; default: log("Unknown sound quality %d. Defaulting to 22Khz\n", soundQuality); soundQuality = 2; break; } soundSetSampleRate(44100 / soundQuality); int volume = ReadPref("soundVolume", 100); float volume_percent = volume / 100.0f; if (volume_percent < 0.0 || volume_percent > SOUND_MAX_VOLUME) volume_percent = 1.0; soundSetVolume(volume_percent); soundSetEnable((ReadPrefHex("soundEnable", 0x30f)) & 0x30f); if ((ReadPrefHex("soundStereo"))) { gb_effects_config.enabled = true; } if ((ReadPrefHex("soundEcho"))) { gb_effects_config.enabled = true; } if ((ReadPrefHex("soundSurround"))) { gb_effects_config.surround = true; gb_effects_config.enabled = true; } if (optFlashSize == 0) flashSetSize(0x10000); else flashSetSize(0x20000); rtcEnable(rtcEnabled ? true : false); agbPrintEnable(agbPrint ? true : false); for (int i = 0; i < 24;) { systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10); systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10); systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10); systemGbPalette[i++] = 0; } systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; optPrintUsage = 0; // TODO //int s = ReadPref("mapViewStretch", 0); //m_size = ReadPref("memViewerDataSize", 0); //m_stretch = ReadPref("GBOamViewStretch", 0); //m_stretch = ReadPref("tileViewStretch", 0); //numberType = ReadPref("cheatsNumberType", 2); //numberType = ReadPref("gbCheatsNumberType", 2); //restoreValues = ReadPref("cheatsRestore", 0) ? //scale = ReadPref("printerScale", 0); //searchType = ReadPref("cheatsSearchType", SEARCH_EQ); //searchType = ReadPref("gbCheatsSearchType", //selectedFilter = ReadPref(("selectedFilter"), 0); //sizeType = ReadPref("cheatsSizeType", 0); //sizeType = ReadPref("gbCheatsSizeType", 0); //updateValues = ReadPref("cheatsUpdate", 0); //updateValues = ReadPref("gbCheatsUpdate", 0); //valueType = ReadPref("cheatsValueType", 0); //valueType = ReadPref("gbCheatsValueType", 0); ValidateConfig(); }