void ConvertMCM(HWND hWnd){ char szChoice[MAX_PATH]={0}; OPENFILENAME ofn; soundDriver->pause(); // browse button ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hWnd; ofn.lpstrFilter = "Mednafen Movie File (*.mcm)\0*.mcm\0All files(*.*)\0*.*\0\0"; ofn.lpstrFile = (LPSTR)szChoice; ofn.lpstrTitle = "Select a movie to convert"; ofn.lpstrDefExt = "mcm"; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; if(GetOpenFileName(&ofn)) { LoadMCM(szChoice, false); if(pcejin.romLoaded) { osd->addLine("Check that directory"); osd->addLine("for an .mc2 file"); } else MessageBox(hWnd, "Check that directory for an .mc2 file", "Conversion", NULL); } pcejin.tempUnPause(); }
void PlayMovie(HWND hWnd){ char szChoice[MAX_PATH]={0}; OPENFILENAME ofn; soundDriver->pause(); // browse button ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hWnd; ofn.lpstrFilter = "Movie File (*.mc2, *.mcm)\0*.mc2;*.mcm\0All files(*.*)\0*.*\0\0"; ofn.lpstrFile = (LPSTR)szChoice; ofn.lpstrTitle = "Play a movie"; ofn.lpstrDefExt = "mc2"; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; if(GetOpenFileName(&ofn)) { if(toupper(strright(szChoice,4)) == ".MC2") LoadMovie(szChoice, 1, 0, 0); else if(toupper(strright(szChoice,4)) == ".MCM") LoadMCM(szChoice, true); } pcejin.tempUnPause(); }
void RecordMovie(HWND hWnd){ char szChoice[MAX_PATH]={0}; soundDriver->pause(); OPENFILENAME ofn; // browse button ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hWnd; ofn.lpstrFilter = "Movie File (*.mc2)\0*.mc2\0All files(*.*)\0*.*\0\0"; ofn.lpstrFile = (LPSTR)szChoice; ofn.lpstrTitle = "Record a new movie"; ofn.lpstrDefExt = "mc2"; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; if(GetSaveFileName(&ofn)) SaveMovie(szChoice, a, 1); //If user did not specify an extension, add .dsm for them // fname = szChoice; // x = fname.find_last_of("."); // if (x < 0) // fname.append(".mc2"); // SetDlgItemText(hwndDlg, IDC_EDIT_FILENAME, fname.c_str()); //if(GetSaveFileName(&ofn)) // UpdateRecordDialogPath(hwndDlg,szChoice); pcejin.tempUnPause(); }
LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; HWND hDlg; switch(Message) { case WM_KEYDOWN: if(wParam != VK_PAUSE) break; // case WM_SYSKEYDOWN: case WM_CUSTKEYDOWN: { int modifiers = GetModifiers(wParam); if(!HandleKeyMessage(wParam,lParam, modifiers)) return 0; break; } case WM_KEYUP: if(wParam != VK_PAUSE) break; case WM_SYSKEYUP: case WM_CUSTKEYUP: { int modifiers = GetModifiers(wParam); HandleKeyUp(wParam, lParam, modifiers); } break; case WM_SIZE: switch(wParam) { case SIZE_MINIMIZED: break; case SIZE_MAXIMIZED: pcejin.maximized = true; break; case SIZE_RESTORED: pcejin.maximized = false; break; default: break; } return 0; case WM_MOVE: RECT rect; GetWindowRect(hWnd,&rect); WndX = rect.left; WndY = rect.top; return 0; case WM_DROPFILES: { char filename[MAX_PATH] = ""; DragQueryFile((HDROP)wParam,0,filename,MAX_PATH); DragFinish((HDROP)wParam); std::string fileDropped = filename; //------------------------------------------------------- //Check if mcm file, if so auto-convert and play //------------------------------------------------------- if (!(fileDropped.find(".mcm") == std::string::npos) && (fileDropped.find(".mcm") == fileDropped.length()-4)) { if (!pcejin.romLoaded) //If no ROM is loaded, prompt for one { soundDriver->pause(); LoadGame(); pcejin.tempUnPause(); } if (pcejin.romLoaded && !(fileDropped.find(".mcm") == std::string::npos)) LoadMCM(fileDropped.c_str(), true); } //------------------------------------------------------- //Check if Movie file //------------------------------------------------------- else if (!(fileDropped.find(".mc2") == std::string::npos) && (fileDropped.find(".mc2") == fileDropped.length()-4)) { if (!pcejin.romLoaded) //If no ROM is loaded, prompt for one { soundDriver->pause(); LoadGame(); pcejin.tempUnPause(); } if (pcejin.romLoaded && !(fileDropped.find(".mc2") == std::string::npos)) { LoadMovie(fileDropped.c_str(), 1, false, false); RecentMovies.UpdateRecentItems(fileDropped); } } //------------------------------------------------------- //Check if Savestate file //------------------------------------------------------- else if (!(fileDropped.find(".nc") == std::string::npos)) { if (fileDropped.find(".nc") == fileDropped.length()-4) { if ((fileDropped[fileDropped.length()-1] >= '0' && fileDropped[fileDropped.length()-1] <= '9')) { MDFNSS_Load(filename, NULL); UpdateToolWindows(); } } } //------------------------------------------------------- //Check if Lua script file //------------------------------------------------------- else if (!(fileDropped.find(".lua") == std::string::npos) && (fileDropped.find(".lua") == fileDropped.length()-4)) //ROM is already loaded and .dsm in filename { if(LuaScriptHWnds.size() < 16) { char temp [1024]; strcpy(temp, fileDropped.c_str()); HWND IsScriptFileOpen(const char* Path); RecentLua.UpdateRecentItems(fileDropped); if(!IsScriptFileOpen(temp)) { HWND hDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_LUA), hWnd, (DLGPROC) LuaScriptProc); SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)temp); } } } //------------------------------------------------------- //Check if watchlist file //------------------------------------------------------- else if (!(fileDropped.find(".wch") == std::string::npos) && (fileDropped.find(".wch") == fileDropped.length()-4)) //ROM is already loaded and .dsm in filename { if(!RamWatchHWnd) { RamWatchHWnd = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), hWnd, (DLGPROC) RamWatchProc); } else SetForegroundWindow(RamWatchHWnd); Load_Watches(true, fileDropped.c_str()); } //------------------------------------------------------- //Else load it as a ROM //------------------------------------------------------- else { ALoad(fileDropped.c_str()); } } return 0; case WM_ENTERMENULOOP: soundDriver->pause(); EnableMenuItem(GetMenu(hWnd), IDM_RECORD_MOVIE, MF_BYCOMMAND | (movieMode == MOVIEMODE_INACTIVE && pcejin.romLoaded) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), IDM_PLAY_MOVIE, MF_BYCOMMAND | (movieMode == MOVIEMODE_INACTIVE && pcejin.romLoaded) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), IDM_STOPMOVIE, MF_BYCOMMAND | (movieMode != MOVIEMODE_INACTIVE) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), IDM_RESTARTMOVIE, MF_BYCOMMAND | (movieMode != MOVIEMODE_INACTIVE) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), IDM_FILE_STOPAVI, MF_BYCOMMAND | (DRV_AviIsRecording()) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), IDM_FILE_RECORDAVI, MF_BYCOMMAND | (!DRV_AviIsRecording()) ? MF_ENABLED : MF_GRAYED); //Window Size checkMenu(IDC_WINDOW1X, ((pcejin.windowSize==1))); checkMenu(IDC_WINDOW2X, ((pcejin.windowSize==2))); checkMenu(IDC_WINDOW3X, ((pcejin.windowSize==3))); checkMenu(IDC_WINDOW4X, ((pcejin.windowSize==4))); checkMenu(IDC_ASPECT, ((pcejin.aspectRatio))); checkMenu(ID_VIEW_FRAMECOUNTER,Hud.FrameCounterDisplay); checkMenu(ID_VIEW_DISPLAYINPUT,Hud.ShowInputDisplay); checkMenu(ID_VIEW_DISPLAYSTATESLOTS,Hud.DisplayStateSlots); checkMenu(ID_VIEW_DISPLAYLAG,Hud.ShowLagFrameCounter); checkMenu(IDM_MUTE,soundDriver->userMute); break; case WM_EXITMENULOOP: pcejin.tempUnPause(); break; case WM_CLOSE: { SaveIniSettings(); PostQuitMessage(0); } case WM_DESTROY: { PostQuitMessage(0); } // HANDLE_MSG(hWnd, WM_DESTROY, OnDestroy); // HANDLE_MSG(hWnd, WM_PAINT, OnPaint); // HANDLE_MSG(hwnd, WM_COMMAND, OnCommand); case WM_COMMAND: //Recent ROMs if(wParam >= RECENTROM_START && wParam <= RECENTROM_START + RecentROMs.MAX_RECENT_ITEMS - 1) { ALoad(RecentROMs.GetRecentItem(wParam - RECENTROM_START).c_str()); break; } else if (wParam == RecentROMs.GetClearID()) { RecentROMs.ClearRecentItems(); break; } else if (wParam == RecentROMs.GetAutoloadID()) { RecentROMs.FlipAutoLoad(); break; } //Recent Movies if(wParam >= RECENTMOVIE_START && wParam <= RECENTMOVIE_START + RecentMovies.MAX_RECENT_ITEMS - 1) { strcpy(Tmp_Str, RecentMovies.GetRecentItem(wParam - RECENTMOVIE_START).c_str()); RecentMovies.UpdateRecentItems(Tmp_Str); //WIN32_StartMovieReplay(Str_Tmp); break; } else if (wParam == RecentMovies.GetClearID()) { RecentMovies.ClearRecentItems(); break; } else if (wParam == RecentMovies.GetAutoloadID()) { RecentMovies.FlipAutoLoad(); break; } //Recent Lua if(wParam >= RECENTLUA_START && wParam <= RECENTLUA_START + RecentLua.MAX_RECENT_ITEMS - 1) { if(LuaScriptHWnds.size() < 16) { char temp [1024]; strcpy(temp, RecentLua.GetRecentItem(wParam - RECENTLUA_START).c_str()); HWND IsScriptFileOpen(const char* Path); RecentLua.UpdateRecentItems(temp); if(!IsScriptFileOpen(temp)) { HWND hDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_LUA), hWnd, (DLGPROC) LuaScriptProc); SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)temp); } } break; } else if (wParam == RecentLua.GetClearID()) { RecentLua.ClearRecentItems(); break; } else if (wParam == RecentLua.GetAutoloadID()) { RecentLua.FlipAutoLoad(); break; } wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDC_WINDOW1X: pcejin.windowSize=1; ScaleScreen(pcejin.windowSize); break; case IDC_WINDOW2X: pcejin.windowSize=2; ScaleScreen(pcejin.windowSize); break; case IDC_WINDOW3X: pcejin.windowSize=3; ScaleScreen(pcejin.windowSize); break; case IDC_WINDOW4X: pcejin.windowSize=4; ScaleScreen(pcejin.windowSize); break; case IDC_ASPECT: pcejin.aspectRatio ^= 1; ScaleScreen(pcejin.windowSize); break; case IDM_EXIT: SaveIniSettings(); PostQuitMessage(0); break; case IDM_RESET: PCE_Power(); break; case IDM_OPEN_ROM: soundDriver->pause(); LoadGame(); pcejin.tempUnPause(); break; case IDM_RECORD_MOVIE: soundDriver->pause(); MovieRecordTo(); pcejin.tempUnPause(); return 0; case IDM_PLAY_MOVIE: soundDriver->pause(); Replay_LoadMovie(); pcejin.tempUnPause(); return 0; case IDM_INPUT_CONFIG: soundDriver->pause(); DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_INPUTCONFIG), hWnd, DlgInputConfig); pcejin.tempUnPause(); // RunInputConfig(); break; case IDM_HOTKEY_CONFIG: { soundDriver->pause(); DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_KEYCUSTOM), hWnd, DlgHotkeyConfig); pcejin.tempUnPause(); } break; case IDM_BIOS_CONFIG: soundDriver->pause(); DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_BIOS), hWnd, (DLGPROC) BiosSettingsDlgProc); // DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_KEYCUSTOM), hWnd, BiosSettingsDlgProc); pcejin.tempUnPause(); break; case ID_VIEW_FRAMECOUNTER: Hud.FrameCounterDisplay ^= true; WritePrivateProfileBool("Display", "FrameCounter", Hud.FrameCounterDisplay, IniName); return 0; case ID_VIEW_DISPLAYINPUT: Hud.ShowInputDisplay ^= true; WritePrivateProfileBool("Display", "Display Input", Hud.ShowInputDisplay, IniName); osd->clear(); return 0; case ID_VIEW_DISPLAYSTATESLOTS: Hud.DisplayStateSlots ^= true; WritePrivateProfileBool("Display", "Display State Slots", Hud.DisplayStateSlots, IniName); osd->clear(); return 0; case ID_VIEW_DISPLAYLAG: Hud.ShowLagFrameCounter ^= true; WritePrivateProfileBool("Display", "Display Lag Counter", Hud.ShowLagFrameCounter, IniName); osd->clear(); return 0; case IDC_NEW_LUA_SCRIPT: if(LuaScriptHWnds.size() < 16) { CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_LUA), g_hWnd, (DLGPROC) LuaScriptProc); } break; case IDM_CONVERT_MCM: ConvertMCM(hWnd); break; case IDM_MUTE: soundDriver->doUserMute(); break; case IDM_STOPMOVIE: StopMovie(); return 0; break; case IDM_RESTARTMOVIE: PCE_Power(); ResetFrameCount(); movieMode = MOVIEMODE_PLAY; movie_readonly = true; return 0; break; case ID_RAM_SEARCH: if(!RamSearchHWnd) { InitRamSearch(); RamSearchHWnd = CreateDialog(winClass.hInstance, MAKEINTRESOURCE(IDD_RAMSEARCH), hWnd, (DLGPROC) RamSearchProc); } else SetForegroundWindow(RamSearchHWnd); break; case ID_RAM_WATCH: if(!RamWatchHWnd) { RamWatchHWnd = CreateDialog(winClass.hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), hWnd, (DLGPROC) RamWatchProc); } else SetForegroundWindow(RamWatchHWnd); return 0; case IDM_MEMORY: if (!RegWndClass("MemView_ViewBox", MemView_ViewBoxProc, 0, sizeof(CMemView*))) return 0; OpenToolWindow(new CMemView()); return 0; case IDM_ABOUT: soundDriver->pause(); DialogBox(winClass.hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); pcejin.tempUnPause(); break; case IDM_FILE_RECORDAVI: soundDriver->pause(); RecordAvi(); pcejin.tempUnPause(); break; case IDM_FILE_STOPAVI: StopAvi(); break; } break; } return DefWindowProc(hWnd, Message, wParam, lParam); }
void emulate(){ if(!pcejin.started || !pcejin.romLoaded) return; if (startPaused) { pcejin.pause(); startPaused = false; //This should never be set true except from ParseCmdLine! } pcejin.isLagFrame = true; S9xUpdateJoypadButtons(); pcejin.pads[0] = joypads [0]; pcejin.pads[1] = joypads [1]; pcejin.pads[2] = joypads [2]; pcejin.pads[3] = joypads [3]; pcejin.pads[4] = joypads [4]; VTLineWidths[VTBackBuffer][0].w = ~0; memset(&espec, 0, sizeof(EmulateSpecStruct)); espec.pixels = (uint32 *)VTBuffer[VTBackBuffer]; espec.LineWidths = (MDFN_Rect *)VTLineWidths[VTBackBuffer]; espec.SoundBuf = &sound; espec.SoundBufSize = &ssize; espec.soundmultiplier = 1; if(pcejin.fastForward && currFrameCounter%30 && !DRV_AviIsRecording()) espec.skip = 1; else espec.skip = 0; CallRegisteredLuaFunctions(LUACALL_BEFOREEMULATION); MOV_AddInputState(); MDFNGameInfo->Emulate(&espec); CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION); UpdateToolWindows(); soundDriver->write((u16*)*espec.SoundBuf, *espec.SoundBufSize); DRV_AviSoundUpdate(*espec.SoundBuf, *espec.SoundBufSize); DRV_AviVideoUpdate((uint16*)espec.pixels, &espec); if (pcejin.frameAdvance) { pcejin.frameAdvance = false; pcejin.started = false; } if (pcejin.isLagFrame) pcejin.lagFrameCounter++; if(pcejin.slow && !pcejin.fastForward) while(SpeedThrottle()) { } //adelikat: For commandline loadstate, I know this is a hacky place to do it, but 1 frame needs to be emulated before loadstates are possible if (stateToLoad != -1) { HK_StateLoadSlot(stateToLoad); stateToLoad = -1; //Never set this other than from ParseCmdLine } }
LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; switch(Message) { case WM_INITMENU: recentromsmenu = LoadMenu(g_hInstance, "RECENTROMS"); GetRecentRoms(); break; case WM_KEYDOWN: if(wParam != VK_PAUSE) break; // case WM_SYSKEYDOWN: case WM_CUSTKEYDOWN: { int modifiers = GetModifiers(wParam); if(!HandleKeyMessage(wParam,lParam, modifiers)) return 0; break; } case WM_KEYUP: if(wParam != VK_PAUSE) break; case WM_SYSKEYUP: case WM_CUSTKEYUP: { int modifiers = GetModifiers(wParam); HandleKeyUp(wParam, lParam, modifiers); } break; case WM_SIZE: switch(wParam) { case SIZE_MINIMIZED: break; case SIZE_MAXIMIZED: pcejin.maximized = true; break; case SIZE_RESTORED: pcejin.maximized = false; break; default: break; } return 0; case WM_MOVE: RECT rect; GetWindowRect(hWnd,&rect); WndX = rect.left; WndY = rect.top; return 0; case WM_DROPFILES: { char filename[MAX_PATH] = ""; DragQueryFile((HDROP)wParam,0,filename,MAX_PATH); DragFinish((HDROP)wParam); std::string fileDropped = filename; //------------------------------------------------------- //Check if Movie file //------------------------------------------------------- if (!(fileDropped.find(".mc2") == std::string::npos) && (fileDropped.find(".mc2") == fileDropped.length()-4)) { if (!pcejin.romLoaded) //If no ROM is loaded, prompt for one { soundDriver->pause(); LoadGame(); pcejin.tempUnPause(); } if (pcejin.romLoaded && !(fileDropped.find(".mc2") == std::string::npos)) FCEUI_LoadMovie(fileDropped.c_str(), 1, false, false); } //------------------------------------------------------- //Check if Savestate file //------------------------------------------------------- else if (!(fileDropped.find(".mc") == std::string::npos)) //Note: potential clash, mc2 will be loaded a movie file first { if (fileDropped.find(".mc") == fileDropped.length()-4) { if ((fileDropped[fileDropped.length()-1] >= '0' && fileDropped[fileDropped.length()-1] <= '9')) { extern int MDFNSS_Load(const char *fname, const char *suffix); MDFNSS_Load(filename, NULL); ClearDirectDrawOutput(); UpdateToolWindows(); } } } //------------------------------------------------------- //Check if Lua script file //------------------------------------------------------- else if (!(fileDropped.find(".lua") == std::string::npos) && (fileDropped.find(".lua") == fileDropped.length()-4)) //ROM is already loaded and .dsm in filename { if(LuaScriptHWnds.size() < 16) { char temp [1024]; strcpy(temp, fileDropped.c_str()); HWND IsScriptFileOpen(const char* Path); if(!IsScriptFileOpen(temp)) { HWND hDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_LUA), hWnd, (DLGPROC) LuaScriptProc); SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)temp); } } } //------------------------------------------------------- //Check if watchlist file //------------------------------------------------------- else if (!(fileDropped.find(".wch") == std::string::npos) && (fileDropped.find(".wch") == fileDropped.length()-4)) //ROM is already loaded and .dsm in filename { if(!RamWatchHWnd) { RamWatchHWnd = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), hWnd, (DLGPROC) RamWatchProc); } else SetForegroundWindow(RamWatchHWnd); Load_Watches(true, fileDropped.c_str()); } //------------------------------------------------------- //Else load it as a ROM //------------------------------------------------------- else if(MDFNI_LoadGame(NULL,filename)) { pcejin.romLoaded = true; pcejin.started = true; //TODO: adelikat: This code is copied directly from the LoadGame() function, it should be come a separate function and called in both places //////////////////////////////// if (AutoRWLoad) { //Open Ram Watch if its auto-load setting is checked OpenRWRecentFile(0); RamWatchHWnd = CreateDialog(winClass.hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), g_hWnd, (DLGPROC) RamWatchProc); } UpdateRecentRoms(filename); //////////////////////////////// } } return 0; case WM_ENTERMENULOOP: soundDriver->pause(); EnableMenuItem(GetMenu(hWnd), IDM_RECORD_MOVIE, MF_BYCOMMAND | (movieMode == MOVIEMODE_INACTIVE && pcejin.romLoaded) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), ID_RAM_WATCH, MF_BYCOMMAND | (movieMode == MOVIEMODE_INACTIVE && pcejin.romLoaded) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), ID_RAM_SEARCH, MF_BYCOMMAND | (movieMode == MOVIEMODE_INACTIVE && pcejin.romLoaded) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), IDM_MEMORY, MF_BYCOMMAND | (movieMode == MOVIEMODE_INACTIVE && pcejin.romLoaded) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), IDM_PLAY_MOVIE, MF_BYCOMMAND | (movieMode == MOVIEMODE_INACTIVE && pcejin.romLoaded) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), IDM_STOPMOVIE, MF_BYCOMMAND | (movieMode != MOVIEMODE_INACTIVE) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), IDM_FILE_STOPAVI, MF_BYCOMMAND | (DRV_AviIsRecording()) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), IDM_FILE_RECORDAVI, MF_BYCOMMAND | (!DRV_AviIsRecording()) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), IDM_FILE_STOPWAV, MF_BYCOMMAND | (DRV_WaveRecordActive()) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(GetMenu(hWnd), IDM_FILE_RECORDWAV, MF_BYCOMMAND | (!DRV_WaveRecordActive()) ? MF_ENABLED : MF_GRAYED); //Window Size checkMenu(IDC_WINDOW1X, ((pcejin.windowSize==1))); checkMenu(IDC_WINDOW15X, ((pcejin.windowSize==65535))); checkMenu(IDC_WINDOW2X, ((pcejin.windowSize==2))); checkMenu(IDC_WINDOW25X, ((pcejin.windowSize==65534))); checkMenu(IDC_WINDOW3X, ((pcejin.windowSize==3))); checkMenu(IDC_WINDOW4X, ((pcejin.windowSize==4))); checkMenu(IDC_ASPECT, ((pcejin.aspectRatio))); checkMenu(ID_VIEW_MIXLEFTRIGHT,MixVideoOutput); checkMenu(ID_COLOR_MODE_REDBLUE, ((MDFN_IEN_VB::GetColorMode()==0))); checkMenu(ID_COLOR_MODE_REDCYAN, ((MDFN_IEN_VB::GetColorMode()==1))); checkMenu(ID_COLOR_MODE_REDELECTRICCYAN, ((MDFN_IEN_VB::GetColorMode()==2))); checkMenu(ID_COLOR_MODE_REDGREEN, ((MDFN_IEN_VB::GetColorMode()==3))); checkMenu(ID_COLOR_MODE_GREENMAGENTA, ((MDFN_IEN_VB::GetColorMode()==4))); checkMenu(ID_COLOR_MODE_YELLOWBLUE, ((MDFN_IEN_VB::GetColorMode()==5))); checkMenu(ID_COLOR_MODE_GREYSCALE, ((MDFN_IEN_VB::GetColorMode()==6))); checkMenu(ID_SPLIT_MODE_ANAGLYPH, ((MDFN_IEN_VB::GetSplitMode()==MDFN_IEN_VB::VB3DMODE_ANAGLYPH))); checkMenu(ID_SPLIT_MODE_CSCOPE, ((MDFN_IEN_VB::GetSplitMode()==MDFN_IEN_VB::VB3DMODE_CSCOPE))); checkMenu(ID_SPLIT_MODE_SIDEBYSIDE, ((MDFN_IEN_VB::GetSplitMode()==MDFN_IEN_VB::VB3DMODE_SIDEBYSIDE))); checkMenu(ID_SPLIT_MODE_PBARRIER, ((MDFN_IEN_VB::GetSplitMode()==MDFN_IEN_VB::VB3DMODE_PBARRIER))); checkMenu(ID_VIEW_DISP_BOTH, ((DisplayLeftRightOutput==0))); checkMenu(ID_VIEW_DISP_LEFT, ((DisplayLeftRightOutput==1))); checkMenu(ID_VIEW_DISP_RIGHT, ((DisplayLeftRightOutput==2))); checkMenu(ID_VIEW_DISP_DISABLE, ((DisplayLeftRightOutput==3))); checkMenu(ID_VIEW_FRAMECOUNTER,Hud.FrameCounterDisplay); checkMenu(ID_VIEW_DISPLAYINPUT,Hud.ShowInputDisplay); checkMenu(ID_VIEW_OPENCONSOLE,OpenConsoleWindow); checkMenu(ID_VIEW_DISPLAYSTATESLOTS,Hud.DisplayStateSlots); checkMenu(ID_VIEW_DISPLAYLAG,Hud.ShowLagFrameCounter); checkMenu(IDM_MUTE,soundDriver->userMute); break; case WM_EXITMENULOOP: pcejin.tempUnPause(); break; case WM_CLOSE: { SaveIniSettings(); PostQuitMessage(0); } case WM_DESTROY: { PostQuitMessage(0); } // HANDLE_MSG(hWnd, WM_DESTROY, OnDestroy); // HANDLE_MSG(hWnd, WM_PAINT, OnPaint); // HANDLE_MSG(hwnd, WM_COMMAND, OnCommand); case WM_COMMAND: if(wParam >= baseid && wParam <= baseid + MAX_RECENT_ROMS - 1) { int x = wParam - baseid; soundDriver->resume(); OpenRecentROM(x); } else if(wParam == clearid) { /* Clear all the recent ROMs */ if(IDOK == MessageBox(g_hWnd, "OK to clear recent ROMs list?","VBJin",MB_OKCANCEL)) ClearRecentRoms(); } wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDC_WINDOW1X: pcejin.windowSize=1; ScaleScreen((float)pcejin.windowSize); break; case IDC_WINDOW15X: pcejin.windowSize=65535; ScaleScreen((float)pcejin.windowSize); break; case IDC_WINDOW2X: pcejin.windowSize=2; ScaleScreen((float)pcejin.windowSize); break; case IDC_WINDOW25X: pcejin.windowSize=65534; ScaleScreen((float)pcejin.windowSize); break; case IDC_WINDOW3X: pcejin.windowSize=3; ScaleScreen((float)pcejin.windowSize); break; case IDC_WINDOW4X: pcejin.windowSize=4; ScaleScreen((float)pcejin.windowSize); break; case IDC_ASPECT: pcejin.aspectRatio ^= 1; ScaleScreen((float)pcejin.windowSize); break; case IDM_EXIT: SaveIniSettings(); PostQuitMessage(0); break; case IDM_RESET: //NEWTODO PCE_Power(); OpenRecentROM(0); break; case IDM_OPEN_ROM: soundDriver->pause(); LoadGame(); pcejin.tempUnPause(); break; case IDM_RECORD_MOVIE: soundDriver->pause(); MovieRecordTo(); pcejin.tempUnPause(); return 0; case IDM_PLAY_MOVIE: soundDriver->pause(); Replay_LoadMovie(); pcejin.tempUnPause(); return 0; case IDM_INPUT_CONFIG: soundDriver->pause(); DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_INPUTCONFIG), hWnd, DlgInputConfig); pcejin.tempUnPause(); // RunInputConfig(); break; case IDM_HOTKEY_CONFIG: { soundDriver->pause(); DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_KEYCUSTOM), hWnd, DlgHotkeyConfig); pcejin.tempUnPause(); } break; case ID_VIEW_MIXLEFTRIGHT: MixVideoOutput ^= true; MDFN_IEN_VB::SetMixVideoOutput(MixVideoOutput); WritePrivateProfileBool("Display", "MixLeftRight", MixVideoOutput, IniName); return 0; case ID_SPLIT_MODE_ANAGLYPH: MDFN_IEN_VB::SetSplitMode(MDFN_IEN_VB::VB3DMODE_ANAGLYPH); WritePrivateProfileInt("Display", "SplitMode", MDFN_IEN_VB::VB3DMODE_ANAGLYPH, IniName); break; case ID_SPLIT_MODE_CSCOPE: MDFN_IEN_VB::SetSplitMode(MDFN_IEN_VB::VB3DMODE_CSCOPE); WritePrivateProfileInt("Display", "SplitMode", MDFN_IEN_VB::VB3DMODE_CSCOPE, IniName); //Clear the DirectDraw buffers ClearDirectDrawOutput(); break; case ID_SPLIT_MODE_SIDEBYSIDE: MDFN_IEN_VB::SetSplitMode(MDFN_IEN_VB::VB3DMODE_SIDEBYSIDE); WritePrivateProfileInt("Display", "SplitMode", MDFN_IEN_VB::VB3DMODE_SIDEBYSIDE, IniName); //Clear the DirectDraw buffers ClearDirectDrawOutput(); break; case ID_SPLIT_MODE_PBARRIER: MDFN_IEN_VB::SetSplitMode(MDFN_IEN_VB::VB3DMODE_PBARRIER); WritePrivateProfileInt("Display", "SplitMode", MDFN_IEN_VB::VB3DMODE_PBARRIER, IniName); break; case ID_PIXEL_SEP_16: SideBySidePixels = 16; MDFN_IEN_VB::SetSideBySidePixels(SideBySidePixels); ClearDirectDrawOutput(); WritePrivateProfileInt("Display", "SideBySidePixels", SideBySidePixels, IniName); break; case ID_PIXEL_SEP_32: SideBySidePixels = 32; MDFN_IEN_VB::SetSideBySidePixels(SideBySidePixels); ClearDirectDrawOutput(); WritePrivateProfileInt("Display", "SideBySidePixels", SideBySidePixels, IniName); break; case ID_PIXEL_SEP_48: SideBySidePixels = 48; MDFN_IEN_VB::SetSideBySidePixels(SideBySidePixels); ClearDirectDrawOutput(); WritePrivateProfileInt("Display", "SideBySidePixels", SideBySidePixels, IniName); break; case ID_PIXEL_SEP_64: SideBySidePixels = 64; MDFN_IEN_VB::SetSideBySidePixels(SideBySidePixels); ClearDirectDrawOutput(); WritePrivateProfileInt("Display", "SideBySidePixels", SideBySidePixels, IniName); break; case ID_PIXEL_SEP_80: SideBySidePixels = 80; MDFN_IEN_VB::SetSideBySidePixels(SideBySidePixels); ClearDirectDrawOutput(); WritePrivateProfileInt("Display", "SideBySidePixels", SideBySidePixels, IniName); break; case ID_PIXEL_SEP_96: SideBySidePixels = 96; MDFN_IEN_VB::SetSideBySidePixels(SideBySidePixels); ClearDirectDrawOutput(); WritePrivateProfileInt("Display", "SideBySidePixels", SideBySidePixels, IniName); break; case ID_COLOR_MODE_REDBLUE: MDFN_IEN_VB::SetColorMode(0); WritePrivateProfileInt("Display", "ColorMode", 0, IniName); break; case ID_COLOR_MODE_REDCYAN: MDFN_IEN_VB::SetColorMode(1); WritePrivateProfileInt("Display", "ColorMode", 1, IniName); break; case ID_COLOR_MODE_REDELECTRICCYAN: MDFN_IEN_VB::SetColorMode(2); WritePrivateProfileInt("Display", "ColorMode", 2, IniName); break; case ID_COLOR_MODE_REDGREEN: MDFN_IEN_VB::SetColorMode(3); WritePrivateProfileInt("Display", "ColorMode", 3, IniName); break; case ID_COLOR_MODE_GREENMAGENTA: MDFN_IEN_VB::SetColorMode(4); WritePrivateProfileInt("Display", "ColorMode", 4, IniName); break; case ID_COLOR_MODE_YELLOWBLUE: MDFN_IEN_VB::SetColorMode(5); WritePrivateProfileInt("Display", "ColorMode", 5, IniName); break; case ID_COLOR_MODE_GREYSCALE: MDFN_IEN_VB::SetColorMode(6); WritePrivateProfileInt("Display", "ColorMode", 6, IniName); break; case ID_VIEW_DISP_BOTH: DisplayLeftRightOutput = 0; MDFN_IEN_VB::SetViewDisp(DisplayLeftRightOutput); WritePrivateProfileInt("Display", "ViewDisplay", DisplayLeftRightOutput, IniName); return 0; case ID_VIEW_DISP_LEFT: DisplayLeftRightOutput = 1; MDFN_IEN_VB::SetViewDisp(DisplayLeftRightOutput); WritePrivateProfileInt("Display", "ViewDisplay", DisplayLeftRightOutput, IniName); return 0; case ID_VIEW_DISP_RIGHT: DisplayLeftRightOutput = 2; MDFN_IEN_VB::SetViewDisp(DisplayLeftRightOutput); WritePrivateProfileInt("Display", "ViewDisplay", DisplayLeftRightOutput, IniName); return 0; case ID_VIEW_DISP_DISABLE: DisplayLeftRightOutput = 3; MDFN_IEN_VB::SetViewDisp(DisplayLeftRightOutput); // We're not saving this. Too many people would set it and forget it, then compain. // Someone can still set it manually in the ini file though. return 0; case ID_VIEW_FRAMECOUNTER: Hud.FrameCounterDisplay ^= true; WritePrivateProfileBool("Display", "FrameCounter", Hud.FrameCounterDisplay, IniName); return 0; case ID_VIEW_DISPLAYINPUT: Hud.ShowInputDisplay ^= true; WritePrivateProfileBool("Display", "Display Input", Hud.ShowInputDisplay, IniName); osd->clear(); return 0; case ID_VIEW_OPENCONSOLE: OpenConsoleWindow ^= true; WritePrivateProfileBool("Display", "OpenConsoleWindow", OpenConsoleWindow, IniName); return 0; case ID_VIEW_DISPLAYSTATESLOTS: Hud.DisplayStateSlots ^= true; WritePrivateProfileBool("Display", "Display State Slots", Hud.DisplayStateSlots, IniName); osd->clear(); return 0; case ID_VIEW_DISPLAYLAG: Hud.ShowLagFrameCounter ^= true; WritePrivateProfileBool("Display", "Display Lag Counter", Hud.ShowLagFrameCounter, IniName); osd->clear(); return 0; case IDC_NEW_LUA_SCRIPT: if(LuaScriptHWnds.size() < 16) { CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_LUA), g_hWnd, (DLGPROC) LuaScriptProc); } break; break; case IDM_MUTE: soundDriver->doUserMute(); break; case IDM_STOPMOVIE: FCEUI_StopMovie(); return 0; break; case ID_RAM_SEARCH: if(!RamSearchHWnd) { if (pcejin.romLoaded) { InitRamSearch(false); RamSearchHWnd = CreateDialog(winClass.hInstance, MAKEINTRESOURCE(IDD_RAMSEARCH), hWnd, (DLGPROC) RamSearchProc); } } else SetForegroundWindow(RamSearchHWnd); break; case ID_RAM_WATCH: if(!RamWatchHWnd) { if(pcejin.romLoaded) RamWatchHWnd = CreateDialog(winClass.hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), hWnd, (DLGPROC) RamWatchProc); } else SetForegroundWindow(RamWatchHWnd); return 0; case IDM_MEMORY: if (!RegWndClass("MemView_ViewBox", MemView_ViewBoxProc, 0, sizeof(CMemView*))) return 0; OpenToolWindow(new CMemView()); return 0; case IDM_ABOUT: soundDriver->pause(); DialogBox(winClass.hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); pcejin.tempUnPause(); break; case IDM_FILE_RECORDAVI: soundDriver->pause(); RecordAvi(); pcejin.tempUnPause(); break; case IDM_FILE_STOPAVI: StopAvi(); break; case IDM_FILE_RECORDWAV: soundDriver->pause(); CreateSoundSave(); pcejin.tempUnPause(); break; case IDM_FILE_STOPWAV: DRV_EndWaveRecord(); break; } break; } return DefWindowProc(hWnd, Message, wParam, lParam); }
void emulate(){ /* //NEWTODO fix these pcejin.pads[0] = joypads [0]; vbjinEmulate(); */ if(!pcejin.started || !pcejin.romLoaded) return; if (startPaused) { pcejin.pause(); startPaused = false; //This should never be set true except from ParseCmdLine! } pcejin.isLagFrame = true; S9xUpdateJoypadButtons(); pcejin.pads[0] = joypads [0]; // pcejin.pads[1] = joypads [1]; // pcejin.pads[2] = joypads [2]; // pcejin.pads[3] = joypads [3]; // pcejin.pads[4] = joypads [4]; FCEUMOV_AddInputState(); VTLineWidths[VTBackBuffer][0].w = ~0; memset(&espec, 0, sizeof(EmulateSpecStruct)); espec.surface = (MDFN_Surface *)VTBuffer[VTBackBuffer]; //espec.surface->pixels = (uint32 *)VTBuffer[VTBackBuffer]; espec.LineWidths = (MDFN_Rect *)VTLineWidths[VTBackBuffer]; //espec.SoundBuf = sound; //espec.SoundBufSize = ssize; espec.soundmultiplier = 1; espec.SoundBuf = EmuModBuffer; espec.SoundBufMaxSize = EmuModBufferSize; if(pcejin.fastForward && currFrameCounter%30 && !DRV_AviIsRecording()) espec.skip = 1; else espec.skip = 0; CallRegisteredLuaFunctions(LUACALL_BEFOREEMULATION); MDFNGameInfo->Emulate(&espec); CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION); UpdateToolWindows(); //NEWTODO soundDriver->write((u16*)espec.SoundBuf, espec.SoundBufSize); DRV_AviSoundUpdate((u16*)espec.SoundBuf, espec.SoundBufSize); DRV_AviVideoUpdate((uint16*)espec.surface->pixels, &espec); // espec.SoundBufSize is a count of the 16 bit channel pairs. // Casting to uint32* cycles through all the data accurately. DRV_WriteWaveData((uint32*)espec.SoundBuf, espec.SoundBufSize); if (pcejin.frameAdvance) { pcejin.frameAdvance = false; pcejin.started = false; } if (pcejin.isLagFrame) pcejin.lagFrameCounter++; if(!pcejin.fastForward)//pcejin.slow && while(SpeedThrottle()) { } //adelikat: For commandline loadstate, I know this is a hacky place to do it, but 1 frame needs to be emulated before loadstates are possible if (stateToLoad != -1) { HK_StateLoadSlot(stateToLoad); stateToLoad = -1; //Never set this other than from ParseCmdLine } }