static void DoSimpleCommand(int cmd) { switch(cmd) { case MDFN_MSC_RESET: PCE_Power(); break; case MDFN_MSC_POWER: PCE_Power(); break; } }
void HES_Draw(MDFN_Surface *surface, MDFN_Rect *DisplayRect, int16 *SoundBuf, int32 SoundBufSize) { extern uint16 pce_jp_data[5]; static uint8 last = 0; bool needreload = 0; uint8 newset = (pce_jp_data[0] ^ last) & pce_jp_data[0]; if(newset & 0x20) { CurrentSong++; needreload = 1; } if(newset & 0x80) { CurrentSong--; needreload = 1; } if(newset & 0x08) needreload = 1; if(newset & 0x10) { CurrentSong += 10; needreload = 1; } if(newset & 0x40) { CurrentSong -= 10; needreload = 1; } last = pce_jp_data[0]; if(needreload) PCE_Power(); Player_Draw(surface, DisplayRect, CurrentSong, SoundBuf, SoundBufSize); }
void HES_Update(EmulateSpecStruct *espec, uint16 jp_data) { static uint8 last = 0; bool needreload = 0; if((jp_data & 0x20) && !(last & 0x20)) { CurrentSong++; needreload = 1; } if((jp_data & 0x80) && !(last & 0x80)) { CurrentSong--; needreload = 1; } if((jp_data & 0x8) && !(last & 0x8)) needreload = 1; if((jp_data & 0x10) && !(last & 0x10)) { CurrentSong += 10; needreload = 1; } if((jp_data & 0x40) && !(last & 0x40)) { CurrentSong -= 10; needreload = 1; } last = jp_data; if(needreload) PCE_Power(); if(!espec->skip) Player_Draw(espec->surface, &espec->DisplayRect, CurrentSong, espec->SoundBuf, espec->SoundBufSize); }
static void LoadCommon(void) { IsSGX |= MDFN_GetSettingB("pce_fast.forcesgx") ? 1 : 0; if(IsHES) IsSGX = 1; // Don't modify IsSGX past this point. VDC_Init(IsSGX); VDC_SetSettings(MDFN_GetSettingB("pce_fast.nospritelimit"), MDFN_GetSettingB("pce_fast.correct_aspect")); if(IsSGX) { MDFN_printf("SuperGrafx Emulation Enabled.\n"); HuCPU.PCERead[0xF8] = HuCPU.PCERead[0xF9] = HuCPU.PCERead[0xFA] = HuCPU.PCERead[0xFB] = BaseRAMReadSGX; HuCPU.PCEWrite[0xF8] = HuCPU.PCEWrite[0xF9] = HuCPU.PCEWrite[0xFA] = HuCPU.PCEWrite[0xFB] = BaseRAMWriteSGX; for(int x = 0xf8; x < 0xfb; x++) HuCPU.FastMap[x] = &BaseRAM[(x & 0x3) * 8192]; HuCPU.PCERead[0xFF] = IOReadSGX; } else { HuCPU.PCERead[0xF8] = BaseRAMRead; HuCPU.PCERead[0xF9] = HuCPU.PCERead[0xFA] = HuCPU.PCERead[0xFB] = BaseRAMRead_Mirrored; HuCPU.PCEWrite[0xF8] = BaseRAMWrite; HuCPU.PCEWrite[0xF9] = HuCPU.PCEWrite[0xFA] = HuCPU.PCEWrite[0xFB] = BaseRAMWrite_Mirrored; for(int x = 0xf8; x < 0xfb; x++) HuCPU.FastMap[x] = &BaseRAM[0]; HuCPU.PCERead[0xFF] = IORead; } MDFNMP_AddRAM(IsSGX ? 32768 : 8192, 0xf8 * 8192, BaseRAM); HuCPU.PCEWrite[0xFF] = IOWrite; psg = new PCEFast_PSG(sbuf); psg->SetVolume(1.0); if(PCE_IsCD) { unsigned int cdpsgvolume = MDFN_GetSettingUI("pce_fast.cdpsgvolume"); if(cdpsgvolume != 100) { MDFN_printf(_("CD PSG Volume: %d%%\n"), cdpsgvolume); } psg->SetVolume(0.678 * cdpsgvolume / 100); } PCEINPUT_Init(); PCE_Power(); MDFNGameInfo->LayerNames = IsSGX ? "BG0\0SPR0\0BG1\0SPR1\0" : "Background\0Sprites\0"; MDFNGameInfo->fps = (uint32)((double)7159090.90909090 / 455 / 263 * 65536 * 256); if(!IsHES) { // Clean this up: if(!MDFN_GetSettingB("pce_fast.correct_aspect")) MDFNGameInfo->fb_width = 682; MDFNGameInfo->nominal_width = MDFN_GetSettingB("pce_fast.correct_aspect") ? 288 : 341; MDFNGameInfo->nominal_height = MDFN_GetSettingUI("pce_fast.slend") - MDFN_GetSettingUI("pce_fast.slstart") + 1; MDFNGameInfo->lcm_width = MDFN_GetSettingB("pce_fast.correct_aspect") ? 1024 : 341; MDFNGameInfo->lcm_height = MDFNGameInfo->nominal_height; } }
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); }
static int LoadCommon(void) { IsSGX |= MDFN_GetSettingB("pce_fast.forcesgx") ? 1 : 0; if(IsHES) IsSGX = 1; // Don't modify IsSGX past this point. VDC_Init(IsSGX); if(IsSGX) { MDFN_printf("SuperGrafx Emulation Enabled.\n"); PCERead[0xF8] = PCERead[0xF9] = PCERead[0xFA] = PCERead[0xFB] = BaseRAMReadSGX; PCEWrite[0xF8] = PCEWrite[0xF9] = PCEWrite[0xFA] = PCEWrite[0xFB] = BaseRAMWriteSGX; for(int x = 0xf8; x < 0xfb; x++) HuCPUFastMap[x] = BaseRAM - 0xf8 * 8192; PCERead[0xFF] = IOReadSGX; } else { PCERead[0xF8] = BaseRAMRead; PCERead[0xF9] = PCERead[0xFA] = PCERead[0xFB] = BaseRAMRead_Mirrored; PCEWrite[0xF8] = BaseRAMWrite; PCEWrite[0xF9] = PCEWrite[0xFA] = PCEWrite[0xFB] = BaseRAMWrite_Mirrored; for(int x = 0xf8; x < 0xfb; x++) HuCPUFastMap[x] = BaseRAM - x * 8192; PCERead[0xFF] = IORead; } MDFNMP_AddRAM(IsSGX ? 32768 : 8192, 0xf8 * 8192, BaseRAM); PCEWrite[0xFF] = IOWrite; HuC6280_Init(); psg = new PCE_PSG(&sbuf[0], &sbuf[1], PCE_PSG::REVISION_ENHANCED); //HUC6280A); //psg->init(&sbuf[0], &sbuf[1], PCE_PSG::REVISION_ENHANCED); psg->SetVolume(1.0); if(PCE_IsCD) { unsigned int cdpsgvolume = MDFN_GetSettingUI("pce_fast.cdpsgvolume"); if(cdpsgvolume != 100) { MDFN_printf(_("CD PSG Volume: %d%%\n"), cdpsgvolume); } psg->SetVolume(0.678 * cdpsgvolume / 100); } PCEINPUT_Init(); PCE_Power(); MDFNGameInfo->LayerNames = IsSGX ? "BG0\0SPR0\0BG1\0SPR1\0" : "Background\0Sprites\0"; MDFNGameInfo->fps = (uint32)((double)7159090.90909090 / 455 / 263 * 65536 * 256); // Clean this up: if(!MDFN_GetSettingB("pce_fast.correct_aspect")) MDFNGameInfo->fb_width = 682; if(!IsHES) { MDFNGameInfo->nominal_width = MDFN_GetSettingB("pce_fast.correct_aspect") ? 320 : 341; MDFNGameInfo->nominal_height = MDFN_GetSettingUI("pce_fast.slend") - MDFN_GetSettingUI("pce_fast.slstart") + 1; MDFNGameInfo->lcm_width = MDFN_GetSettingB("pce_fast.correct_aspect") ? 1024 : 341; MDFNGameInfo->lcm_height = MDFNGameInfo->nominal_height; } return(1); }