void apm_suspend(int state) { extern int perflevel; int s; #if NWSDISPLAY > 0 wsdisplay_suspend(); #endif /* NWSDISPLAY > 0 */ stop_periodic_resettodr(); config_suspend_all(DVACT_QUIESCE); bufq_quiesce(); s = splhigh(); intr_disable(); cold = 2; config_suspend_all(DVACT_SUSPEND); suspend_randomness(); /* XXX * Flag to disk drivers that they should "power down" the disk * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; config_suspend_all(DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; /* Send machine to sleep */ apm_set_powstate(APM_DEV_ALLDEVS, state); /* Wake up */ /* They say that some machines may require reinitializing the clocks */ i8254_startclock(); if (initclock_func == i8254_initclocks) rtcstart(); /* in i8254 mode, rtc is profclock */ inittodr(time_second); config_suspend_all(DVACT_RESUME); cold = 0; intr_enable(); splx(s); resume_randomness(NULL, 0); /* force RNG upper level reseed */ bufq_restart(); config_suspend_all(DVACT_WAKEUP); start_periodic_resettodr(); #if NWSDISPLAY > 0 wsdisplay_resume(); #endif /* NWSDISPLAY > 0 */ /* restore hw.setperf */ if (cpu_setperf != NULL) cpu_setperf(perflevel); }
//Record movie dialog static INT_PTR CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static struct CreateMovieParameters* p = NULL; std::wstring author = L""; std::string fname; SYSTEMTIME systime; switch(uMsg) { case WM_INITDIALOG: { CheckDlgButton(hwndDlg, IDC_START_FROM_SRAM, ((flag == 1) ? BST_CHECKED : BST_UNCHECKED)); SetFocus(GetDlgItem(hwndDlg, IDC_EDIT_FILENAME)); DateTime t = FCEUI_MovieGetRTCDefault(); ZeroMemory(&systime, sizeof(SYSTEMTIME)); systime.wYear = t.get_Year(); systime.wMonth = t.get_Month(); systime.wDay = t.get_Day(); systime.wDayOfWeek = t.get_DayOfWeek(); systime.wHour = t.get_Hour(); systime.wMinute = t.get_Minute(); systime.wSecond = t.get_Second(); systime.wMilliseconds = t.get_Millisecond(); DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_DTP_DATE), GDT_VALID, &systime); DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_DTP_TIME), GDT_VALID, &systime); union { struct { SYSTEMTIME rtcMin, rtcMax; }; SYSTEMTIME rtcMinMax[2]; }; ZeroMemory(&rtcMin, sizeof(SYSTEMTIME)); ZeroMemory(&rtcMax, sizeof(SYSTEMTIME)); rtcMin.wYear = 2000; rtcMin.wMonth = 1; rtcMin.wDay = 1; rtcMin.wDayOfWeek = 6; rtcMax.wYear = 2099; rtcMax.wMonth = 12; rtcMax.wDay = 31; rtcMax.wDayOfWeek = 4; DateTime_SetRange(GetDlgItem(hwndDlg, IDC_DTP_DATE), GDTR_MIN, &rtcMinMax); DateTime_SetRange(GetDlgItem(hwndDlg, IDC_DTP_DATE), GDTR_MAX, &rtcMinMax); return false; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: { author = GetDlgItemTextW<500>(hwndDlg,IDC_EDIT_AUTHOR); fname = GetDlgItemText<MAX_PATH>(hwndDlg,IDC_EDIT_FILENAME); std::string sramfname = GetDlgItemText<MAX_PATH>(hwndDlg,IDC_EDIT_SRAMFILENAME); if (fname.length()) { struct tm t; DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_DTP_DATE), &systime); t.tm_year = systime.wYear; t.tm_mon = systime.wMonth; t.tm_mday = systime.wDay; t.tm_wday = systime.wDayOfWeek; DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_DTP_TIME), &systime); t.tm_hour = systime.wHour; t.tm_min = systime.wMinute; t.tm_sec = systime.wSecond; DateTime rtcstart(t.tm_year,t.tm_mon,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec); FCEUI_SaveMovie(fname.c_str(), author, flag, sramfname, rtcstart); EndDialog(hwndDlg, 0); } return true; } case IDCANCEL: EndDialog(hwndDlg, 0); return true; case IDC_BUTTON_BROWSEFILE: { OPENFILENAME ofn; char szChoice[MAX_PATH]={0}; GetDlgItemText(hwndDlg,IDC_EDIT_FILENAME,szChoice,MAX_PATH); // browse button ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndDlg; ofn.lpstrFilter = "Desmume Movie File (*.dsm)\0*.dsm\0All files(*.*)\0*.*\0\0"; ofn.lpstrFile = szChoice; ofn.lpstrTitle = "Record a new movie"; ofn.lpstrDefExt = "dsm"; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; if(GetSaveFileName(&ofn)) { fname = szChoice; /* // windows does this automatically, since lpstrDefExt is set //If user did not specify an extension, add .dsm for them x = fname.find_last_of("."); if (x < 0) fname.append(".dsm"); */ SetDlgItemText(hwndDlg, IDC_EDIT_FILENAME, fname.c_str()); } //if(GetSaveFileName(&ofn)) // UpdateRecordDialogPath(hwndDlg,szChoice); return true; } case IDC_BUTTON_BROWSESRAM: { OPENFILENAME ofn; char szChoice[MAX_PATH]={0}; // browse button ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndDlg; ofn.lpstrFilter = "Desmume SRAM File (*.dsv)\0*.dsv\0All files(*.*)\0*.*\0\0"; ofn.lpstrFile = szChoice; ofn.lpstrTitle = "Choose SRAM"; ofn.lpstrDefExt = "dsv"; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; if(GetOpenFileName(&ofn)) { fname = szChoice; /* // windows does this automatically, since lpstrDefExt is set //If user did not specify an extension, add .dsv for them x = fname.find_last_of("."); if (x < 0) fname.append(".dsv"); */ SetDlgItemText(hwndDlg, IDC_EDIT_SRAMFILENAME, fname.c_str()); } //if(GetSaveFileName(&ofn)) // UpdateRecordDialogPath(hwndDlg,szChoice); return true; } case IDC_EDIT_FILENAME: switch(HIWORD(wParam)) { case EN_CHANGE: { FixRelativeMovieFilename(hwndDlg, IDC_EDIT_FILENAME); // disable the OK button if we can't write to the file char filename [MAX_PATH]; GetDlgItemText(hwndDlg,IDC_EDIT_FILENAME,filename,MAX_PATH); EnableWindow(GetDlgItem(hwndDlg, IDOK), IsFileWritable(filename)); } break; } break; } } HWND cur = GetDlgItem(hwndDlg, IDC_EDIT_SRAMFILENAME); IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? flag=1 : flag=0; IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? EnableWindow(cur, TRUE) : EnableWindow(cur, FALSE); cur = GetDlgItem(hwndDlg, IDC_BUTTON_BROWSESRAM); IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? EnableWindow(cur, TRUE) : EnableWindow(cur, FALSE); return false; }