2015-12-02 17:12:48 +01:00
# include "stdafx.h"
2014-08-29 00:49:26 +02:00
# include "stdafx_gui.h"
2014-06-02 19:27:24 +02:00
# include "rpcs3.h"
2013-12-08 14:47:54 +01:00
# include "MainFrame.h"
2015-08-23 10:06:15 +02:00
# include "Emu/Memory/Memory.h"
# include "Emu/System.h"
2014-07-26 07:51:45 +02:00
# include "Gui/PADManager.h"
2013-12-08 14:47:54 +01:00
# include "Gui/AboutDialog.h"
2014-05-02 08:30:32 +02:00
# include "Gui/GameViewer.h"
2014-08-14 17:22:13 +02:00
# include "Gui/AutoPauseManager.h"
2014-08-15 13:44:16 +02:00
# include "Gui/SaveDataUtility.h"
2014-07-26 07:51:45 +02:00
# include "Gui/KernelExplorer.h"
# include "Gui/MemoryViewer.h"
# include "Gui/RSXDebugger.h"
2015-08-23 10:06:15 +02:00
# include "Gui/SettingsDialog.h"
2014-12-25 05:39:57 +01:00
# include "Gui/MemoryStringSearcher.h"
2015-02-22 15:47:12 +01:00
# include "Gui/CgDisasm.h"
2015-09-13 00:37:57 +02:00
# include "Crypto/unpkg.h"
2013-12-08 14:47:54 +01:00
2016-04-25 12:49:12 +02:00
# include "Utilities/Thread.h"
2016-07-02 13:19:32 +02:00
# include "Utilities/StrUtil.h"
# include "../Crypto/unself.h"
2016-02-01 22:46:27 +01:00
2016-05-13 16:01:48 +02:00
# include <thread>
2015-09-27 00:36:44 +02:00
# ifndef _WIN32
# include "frame_icon.xpm"
# endif
2013-12-08 14:47:54 +01:00
enum IDs
{
id_boot_elf = 0x555 ,
id_boot_game ,
2014-11-24 19:12:04 +01:00
id_boot_install_pkg ,
id_boot_exit ,
2013-12-08 14:47:54 +01:00
id_sys_pause ,
id_sys_stop ,
id_sys_send_open_menu ,
id_sys_send_exit ,
id_config_emu ,
2013-12-27 11:55:11 +01:00
id_config_pad ,
2013-12-08 14:47:54 +01:00
id_config_vfs_manager ,
id_config_vhdd_manager ,
2014-08-14 17:22:13 +02:00
id_config_autopause_manager ,
2014-08-15 13:44:16 +02:00
id_config_savedata_manager ,
2013-12-08 14:47:54 +01:00
id_tools_compiler ,
2014-07-26 07:51:45 +02:00
id_tools_kernel_explorer ,
2013-12-08 14:47:54 +01:00
id_tools_memory_viewer ,
2013-12-30 23:59:39 +01:00
id_tools_rsx_debugger ,
2014-12-25 05:39:57 +01:00
id_tools_string_search ,
2016-07-02 13:19:32 +02:00
id_tools_decrypt_sprx_libraries ,
2015-02-22 15:47:12 +01:00
id_tools_cg_disasm ,
2013-12-08 14:47:54 +01:00
id_help_about ,
2015-02-22 15:47:12 +01:00
id_update_dbg
2013-12-08 14:47:54 +01:00
} ;
wxString GetPaneName ( )
{
static int pane_num = 0 ;
return wxString : : Format ( " Pane_%d " , pane_num + + ) ;
}
MainFrame : : MainFrame ( )
2014-12-14 07:48:24 +01:00
: FrameBase ( nullptr , wxID_ANY , " " , " MainFrame " , wxSize ( 900 , 600 ) )
2017-02-09 23:51:29 +01:00
, m_timer ( this , id_update_dbg )
2013-12-08 14:47:54 +01:00
, m_aui_mgr ( this )
, m_sys_menu_opened ( false )
{
2016-07-21 00:00:31 +02:00
SetLabel ( " RPCS3 v " + rpcs3 : : version . to_string ( ) ) ;
2013-12-08 14:47:54 +01:00
2014-04-13 03:31:59 +02:00
wxMenuBar * menubar = new wxMenuBar ( ) ;
wxMenu * menu_boot = new wxMenu ( ) ;
2014-11-24 19:12:04 +01:00
menubar - > Append ( menu_boot , " &Boot " ) ;
menu_boot - > Append ( id_boot_elf , " Boot &ELF / SELF file " ) ;
menu_boot - > Append ( id_boot_game , " Boot &game " ) ;
2014-04-13 03:31:59 +02:00
menu_boot - > AppendSeparator ( ) ;
2014-11-24 19:12:04 +01:00
menu_boot - > Append ( id_boot_install_pkg , " &Install PKG " ) ;
menu_boot - > AppendSeparator ( ) ;
menu_boot - > Append ( id_boot_exit , " &Exit " ) ;
2014-04-13 03:31:59 +02:00
wxMenu * menu_sys = new wxMenu ( ) ;
2014-11-24 19:12:04 +01:00
menubar - > Append ( menu_sys , " &System " ) ;
menu_sys - > Append ( id_sys_pause , " &Pause " ) - > Enable ( false ) ;
menu_sys - > Append ( id_sys_stop , " &Stop \t Ctrl + S " ) - > Enable ( false ) ;
2014-04-13 03:31:59 +02:00
menu_sys - > AppendSeparator ( ) ;
2014-11-24 19:12:04 +01:00
menu_sys - > Append ( id_sys_send_open_menu , " Send &open system menu cmd " ) - > Enable ( false ) ;
menu_sys - > Append ( id_sys_send_exit , " Send &exit cmd " ) - > Enable ( false ) ;
2014-04-13 03:31:59 +02:00
wxMenu * menu_conf = new wxMenu ( ) ;
2014-11-24 19:12:04 +01:00
menubar - > Append ( menu_conf , " &Config " ) ;
menu_conf - > Append ( id_config_emu , " &Settings " ) ;
menu_conf - > Append ( id_config_pad , " &PAD Settings " ) ;
2014-04-13 03:31:59 +02:00
menu_conf - > AppendSeparator ( ) ;
2014-11-24 19:12:04 +01:00
menu_conf - > Append ( id_config_autopause_manager , " &Auto Pause Settings " ) ;
2016-02-01 22:46:27 +01:00
//menu_conf->AppendSeparator();
//menu_conf->Append(id_config_vfs_manager, "Virtual &File System Manager");
//menu_conf->Append(id_config_vhdd_manager, "Virtual &HDD Manager");
//menu_conf->Append(id_config_savedata_manager, "Save &Data Utility");
2014-04-13 03:31:59 +02:00
wxMenu * menu_tools = new wxMenu ( ) ;
2014-11-24 19:12:04 +01:00
menubar - > Append ( menu_tools , " &Tools " ) ;
2016-02-01 22:46:27 +01:00
//menu_tools->Append(id_tools_compiler, "&ELF Compiler");
menu_tools - > Append ( id_tools_cg_disasm , " &Cg Disasm " ) - > Enable ( ) ;
2014-11-24 19:12:04 +01:00
menu_tools - > Append ( id_tools_kernel_explorer , " &Kernel Explorer " ) - > Enable ( false ) ;
menu_tools - > Append ( id_tools_memory_viewer , " &Memory Viewer " ) - > Enable ( false ) ;
menu_tools - > Append ( id_tools_rsx_debugger , " &RSX Debugger " ) - > Enable ( false ) ;
2014-12-25 05:39:57 +01:00
menu_tools - > Append ( id_tools_string_search , " &String Search " ) - > Enable ( false ) ;
2016-07-02 13:19:32 +02:00
menu_tools - > AppendSeparator ( ) ;
menu_tools - > Append ( id_tools_decrypt_sprx_libraries , " &Decrypt SPRX libraries " ) ;
2014-04-13 03:31:59 +02:00
wxMenu * menu_help = new wxMenu ( ) ;
2014-11-24 19:12:04 +01:00
menubar - > Append ( menu_help , " &Help " ) ;
menu_help - > Append ( id_help_about , " &About... " ) ;
2014-04-13 03:31:59 +02:00
SetMenuBar ( menubar ) ;
2015-07-08 18:16:18 +02:00
SetIcon ( wxICON ( frame_icon ) ) ;
2013-12-08 14:47:54 +01:00
2014-02-19 05:33:31 +01:00
// Panels
2015-04-25 15:29:05 +02:00
m_log_frame = new LogFrame ( this ) ;
2013-12-08 14:47:54 +01:00
m_game_viewer = new GameViewer ( this ) ;
2014-02-19 05:33:31 +01:00
m_debugger_frame = new DebuggerPanel ( this ) ;
2014-06-07 09:54:02 +02:00
AddPane ( m_game_viewer , " Game List " , wxAUI_DOCK_CENTRE ) ;
2014-06-17 17:44:03 +02:00
AddPane ( m_log_frame , " Log " , wxAUI_DOCK_BOTTOM ) ;
2014-02-19 05:33:31 +01:00
AddPane ( m_debugger_frame , " Debugger " , wxAUI_DOCK_RIGHT ) ;
2013-12-08 14:47:54 +01:00
2014-02-19 05:33:31 +01:00
// Events
2014-07-23 12:38:08 +02:00
Bind ( wxEVT_MENU , & MainFrame : : BootElf , this , id_boot_elf ) ;
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : BootGame , this , id_boot_game ) ;
2014-11-24 19:12:04 +01:00
Bind ( wxEVT_MENU , & MainFrame : : InstallPkg , this , id_boot_install_pkg ) ;
Bind ( wxEVT_MENU , [ ] ( wxCommandEvent & ) { wxGetApp ( ) . Exit ( ) ; } , id_boot_exit ) ;
2013-12-08 14:47:54 +01:00
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : Pause , this , id_sys_pause ) ;
Bind ( wxEVT_MENU , & MainFrame : : Stop , this , id_sys_stop ) ;
Bind ( wxEVT_MENU , & MainFrame : : SendOpenCloseSysMenu , this , id_sys_send_open_menu ) ;
Bind ( wxEVT_MENU , & MainFrame : : SendExit , this , id_sys_send_exit ) ;
2013-12-08 14:47:54 +01:00
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : Config , this , id_config_emu ) ;
Bind ( wxEVT_MENU , & MainFrame : : ConfigPad , this , id_config_pad ) ;
2016-02-01 22:46:27 +01:00
Bind ( wxEVT_MENU , & MainFrame : : ConfigAutoPause , this , id_config_autopause_manager ) ;
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : ConfigVFS , this , id_config_vfs_manager ) ;
Bind ( wxEVT_MENU , & MainFrame : : ConfigVHDD , this , id_config_vhdd_manager ) ;
2014-08-15 13:44:16 +02:00
Bind ( wxEVT_MENU , & MainFrame : : ConfigSaveData , this , id_config_savedata_manager ) ;
2016-07-02 13:19:32 +02:00
Bind ( wxEVT_MENU , & MainFrame : : DecryptSPRXLibraries , this , id_tools_decrypt_sprx_libraries ) ;
2013-12-08 14:47:54 +01:00
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : OpenELFCompiler , this , id_tools_compiler ) ;
2014-07-26 07:51:45 +02:00
Bind ( wxEVT_MENU , & MainFrame : : OpenKernelExplorer , this , id_tools_kernel_explorer ) ;
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : OpenMemoryViewer , this , id_tools_memory_viewer ) ;
Bind ( wxEVT_MENU , & MainFrame : : OpenRSXDebugger , this , id_tools_rsx_debugger ) ;
2014-12-25 05:39:57 +01:00
Bind ( wxEVT_MENU , & MainFrame : : OpenStringSearch , this , id_tools_string_search ) ;
2015-02-22 15:47:12 +01:00
Bind ( wxEVT_MENU , & MainFrame : : OpenCgDisasm , this , id_tools_cg_disasm ) ;
2013-12-08 14:47:54 +01:00
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : AboutDialogHandler , this , id_help_about ) ;
2013-12-08 14:47:54 +01:00
2014-04-13 03:31:59 +02:00
Bind ( wxEVT_MENU , & MainFrame : : UpdateUI , this , id_update_dbg ) ;
2017-02-09 23:51:29 +01:00
Bind ( wxEVT_TIMER , & MainFrame : : UpdateUI , this , id_update_dbg ) ;
Bind ( wxEVT_CLOSE_WINDOW , [ & ] ( wxCloseEvent & )
{
DoSettings ( false ) ;
TheApp - > Exit ( ) ;
} ) ;
2013-12-08 14:47:54 +01:00
2014-05-10 16:00:34 +02:00
wxGetApp ( ) . Bind ( wxEVT_KEY_DOWN , & MainFrame : : OnKeyDown , this ) ;
2017-02-09 23:51:29 +01:00
// Check for updates every ~10 ms
m_timer . Start ( 10 ) ;
2013-12-08 14:47:54 +01:00
}
MainFrame : : ~ MainFrame ( )
{
m_aui_mgr . UnInit ( ) ;
}
void MainFrame : : AddPane ( wxWindow * wind , const wxString & caption , int flags )
{
wind - > SetSize ( - 1 , 300 ) ;
m_aui_mgr . AddPane ( wind , wxAuiPaneInfo ( ) . Name ( GetPaneName ( ) ) . Caption ( caption ) . Direction ( flags ) . CloseButton ( false ) . MaximizeButton ( ) ) ;
}
void MainFrame : : DoSettings ( bool load )
{
2016-02-01 22:46:27 +01:00
auto & & cfg = g_gui_cfg [ ini_name ] [ " aui " ] ;
if ( load )
2013-12-08 14:47:54 +01:00
{
2016-02-01 22:46:27 +01:00
const auto & perspective = fmt : : FromUTF8 ( cfg . Scalar ( ) ) ;
2015-10-26 22:09:31 +01:00
2016-02-01 22:46:27 +01:00
m_aui_mgr . LoadPerspective ( perspective . empty ( ) ? m_aui_mgr . SavePerspective ( ) : perspective ) ;
2013-12-08 14:47:54 +01:00
}
else
{
2016-02-01 22:46:27 +01:00
cfg = fmt : : ToUTF8 ( m_aui_mgr . SavePerspective ( ) ) ;
save_gui_cfg ( ) ;
2013-12-08 14:47:54 +01:00
}
}
void MainFrame : : BootGame ( wxCommandEvent & WXUNUSED ( event ) )
{
bool stopped = false ;
if ( Emu . IsRunning ( ) )
{
Emu . Pause ( ) ;
stopped = true ;
}
wxDirDialog ctrl ( this , L " Select game folder " , wxEmptyString ) ;
if ( ctrl . ShowModal ( ) = = wxID_CANCEL )
{
if ( stopped ) Emu . Resume ( ) ;
return ;
}
Emu . Stop ( ) ;
2016-02-01 22:46:27 +01:00
if ( ! Emu . BootGame ( ctrl . GetPath ( ) . ToStdString ( ) ) )
2013-12-08 17:54:45 +01:00
{
2016-01-12 22:57:16 +01:00
LOG_ERROR ( GENERAL , " PS3 executable not found in selected folder (%s) " , fmt : : ToUTF8 ( ctrl . GetPath ( ) ) ) ; // passing std::string (test)
2013-12-08 14:47:54 +01:00
}
}
2013-12-08 17:54:45 +01:00
void MainFrame : : InstallPkg ( wxCommandEvent & WXUNUSED ( event ) )
2013-12-08 14:47:54 +01:00
{
2016-02-01 22:46:27 +01:00
const bool paused = Emu . Pause ( ) ;
2013-12-08 14:47:54 +01:00
2015-04-19 15:19:24 +02:00
wxFileDialog ctrl ( this , L " Select PKG " , wxEmptyString , wxEmptyString , " PKG files (*.pkg) | * . pkg | All files ( * . * ) | * . * " , wxFD_OPEN | wxFD_FILE_MUST_EXIST) ;
2013-12-08 14:47:54 +01:00
2015-09-13 00:37:57 +02:00
if ( ctrl . ShowModal ( ) = = wxID_CANCEL )
2013-12-08 14:47:54 +01:00
{
2016-02-01 22:46:27 +01:00
if ( paused ) Emu . Resume ( ) ;
2013-12-08 14:47:54 +01:00
return ;
}
Emu . Stop ( ) ;
2014-02-21 02:35:33 +01:00
2015-09-13 00:37:57 +02:00
// Open PKG file
2015-11-01 11:33:28 +01:00
fs : : file pkg_f ( ctrl . GetPath ( ) . ToStdString ( ) ) ;
2015-09-13 00:37:57 +02:00
2016-02-01 22:46:27 +01:00
if ( ! pkg_f | | pkg_f . size ( ) < 64 )
2015-09-13 00:37:57 +02:00
{
LOG_ERROR ( LOADER , " PKG: Failed to open %s " , ctrl . GetPath ( ) . ToStdString ( ) ) ;
return ;
}
2016-02-01 22:46:27 +01:00
// Get title ID
std : : vector < char > title_id ( 9 ) ;
pkg_f . seek ( 55 ) ;
pkg_f . read ( title_id ) ;
pkg_f . seek ( 0 ) ;
// Get full path
2016-06-02 17:16:01 +02:00
const auto & local_path = Emu . GetGameDir ( ) + std : : string ( std : : begin ( title_id ) , std : : end ( title_id ) ) ;
2015-09-13 00:37:57 +02:00
if ( ! fs : : create_dir ( local_path ) )
{
if ( fs : : is_dir ( local_path ) )
{
if ( wxMessageDialog ( this , " Another installation found. Do you want to overwrite it? " , " PKG Decrypter / Installer " , wxYES_NO | wxCENTRE ) . ShowModal ( ) ! = wxID_YES )
{
LOG_ERROR ( LOADER , " PKG: Cancelled installation to existing directory %s " , local_path ) ;
return ;
}
}
else
{
LOG_ERROR ( LOADER , " PKG: Could not create the installation directory %s " , local_path ) ;
return ;
}
}
2016-04-25 12:49:12 +02:00
wxProgressDialog pdlg ( " PKG Installer " , " Please wait, unpacking... " , 1000 , this , wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT ) ;
2015-09-13 00:37:57 +02:00
2016-04-25 12:49:12 +02:00
// Synchronization variable
atomic_t < double > progress ( 0. ) ;
2015-09-13 00:37:57 +02:00
{
2016-04-25 12:49:12 +02:00
// Run PKG unpacking asynchronously
scope_thread worker ( " PKG Installer " , [ & ]
{
if ( pkg_install ( pkg_f , local_path + ' / ' , progress ) )
{
progress = 1. ;
2016-08-12 18:24:29 +02:00
return ;
2016-04-25 12:49:12 +02:00
}
// TODO: Ask user to delete files on cancellation/failure?
2016-07-18 20:28:58 +02:00
progress = - 1. ;
2016-04-25 12:49:12 +02:00
} ) ;
2015-09-13 00:37:57 +02:00
2016-04-25 12:49:12 +02:00
// Wait for the completion
2016-07-18 20:28:58 +02:00
while ( std : : this_thread : : sleep_for ( 5 ms ) , std : : abs ( progress ) < 1. )
2016-04-25 12:49:12 +02:00
{
// Update progress window
if ( ! pdlg . Update ( static_cast < int > ( progress * pdlg . GetRange ( ) ) ) )
{
// Installation cancelled (signal with negative value)
progress - = 1. ;
break ;
}
}
2016-07-18 20:28:58 +02:00
if ( progress > 0. )
{
pdlg . Update ( pdlg . GetRange ( ) ) ;
std : : this_thread : : sleep_for ( 100 ms ) ;
}
2015-09-13 00:37:57 +02:00
}
pdlg . Close ( ) ;
2016-04-25 12:49:12 +02:00
if ( progress > = 1. )
2014-02-06 19:34:05 +01:00
{
2014-08-23 09:50:34 +02:00
// Refresh game list
m_game_viewer - > Refresh ( ) ;
}
2013-12-08 14:47:54 +01:00
}
void MainFrame : : BootElf ( wxCommandEvent & WXUNUSED ( event ) )
{
bool stopped = false ;
if ( Emu . IsRunning ( ) )
{
Emu . Pause ( ) ;
stopped = true ;
}
2013-12-24 05:02:21 +01:00
wxFileDialog ctrl ( this , L " Select (S)ELF " , wxEmptyString , wxEmptyString ,
" (S)ELF files (*BOOT.BIN;*.elf;*.self)|*BOOT.BIN;*.elf;*.self "
" |ELF files (BOOT.BIN;*.elf)|BOOT.BIN;*.elf "
" |SELF files (EBOOT.BIN;*.self)|EBOOT.BIN;*.self "
" |BOOT files (*BOOT.BIN)|*BOOT.BIN "
" |BIN files (*.bin)|*.bin "
" |All files (*.*)|*.* " ,
2013-12-08 14:47:54 +01:00
wxFD_OPEN | wxFD_FILE_MUST_EXIST ) ;
if ( ctrl . ShowModal ( ) = = wxID_CANCEL )
{
if ( stopped ) Emu . Resume ( ) ;
return ;
}
2016-01-12 22:57:16 +01:00
LOG_NOTICE ( LOADER , " (S)ELF: booting... " ) ;
2013-12-08 14:47:54 +01:00
Emu . Stop ( ) ;
2014-04-01 02:33:55 +02:00
Emu . SetPath ( fmt : : ToUTF8 ( ctrl . GetPath ( ) ) ) ;
2013-12-08 14:47:54 +01:00
Emu . Load ( ) ;
2016-01-12 22:57:16 +01:00
LOG_SUCCESS ( LOADER , " (S)ELF: boot done. " ) ;
2013-12-08 14:47:54 +01:00
}
2016-07-02 13:19:32 +02:00
void MainFrame : : DecryptSPRXLibraries ( wxCommandEvent & WXUNUSED ( event ) )
{
wxFileDialog ctrl ( this , L " Select SPRX files " , wxEmptyString , wxEmptyString ,
" SPRX files (*.sprx)|*sprx " ,
wxFD_OPEN | wxFD_MULTIPLE ) ;
if ( ctrl . ShowModal ( ) = = wxID_CANCEL )
{
return ;
}
wxArrayString modules ;
ctrl . GetPaths ( modules ) ;
LOG_NOTICE ( GENERAL , " Decrypting SPRX libraries... " ) ;
for ( const wxString & module : modules )
{
std : : string prx_path = fmt : : ToUTF8 ( module ) ;
const std : : string & prx_dir = fs : : get_parent_dir ( prx_path ) ;
2017-02-11 19:06:57 +01:00
fs : : file elf_file ( prx_path ) ;
if ( elf_file & & elf_file . size ( ) > = 4 & & elf_file . read < u32 > ( ) = = " SCE \0 " _u32 )
2016-07-02 13:19:32 +02:00
{
const std : : size_t prx_ext_pos = prx_path . find_last_of ( ' . ' ) ;
const std : : string & prx_ext = fmt : : to_upper ( prx_path . substr ( prx_ext_pos ! = - 1 ? prx_ext_pos : prx_path . size ( ) ) ) ;
const std : : string & prx_name = prx_path . substr ( prx_dir . size ( ) ) ;
2017-02-11 19:06:57 +01:00
elf_file = decrypt_self ( std : : move ( elf_file ) ) ;
2016-07-02 13:19:32 +02:00
prx_path . erase ( prx_path . size ( ) - 4 , 1 ) ; // change *.sprx to *.prx
2017-02-11 19:06:57 +01:00
if ( elf_file )
2016-07-02 13:19:32 +02:00
{
2017-02-11 19:06:57 +01:00
if ( fs : : file new_file { prx_path , fs : : rewrite } )
{
new_file . write ( elf_file . to_string ( ) ) ;
LOG_SUCCESS ( GENERAL , " Decrypted %s " , prx_dir + prx_name ) ;
}
else
{
LOG_ERROR ( GENERAL , " Failed to create %s " , prx_path ) ;
}
2016-07-02 13:19:32 +02:00
}
else
{
LOG_ERROR ( GENERAL , " Failed to decrypt %s " , prx_dir + prx_name ) ;
}
}
}
LOG_NOTICE ( GENERAL , " Finished decrypting all SPRX libraries. " ) ;
}
2013-12-08 14:47:54 +01:00
void MainFrame : : Pause ( wxCommandEvent & WXUNUSED ( event ) )
{
if ( Emu . IsReady ( ) )
{
Emu . Run ( ) ;
}
else if ( Emu . IsPaused ( ) )
{
Emu . Resume ( ) ;
}
else if ( Emu . IsRunning ( ) )
{
Emu . Pause ( ) ;
}
}
void MainFrame : : Stop ( wxCommandEvent & WXUNUSED ( event ) )
{
Emu . Stop ( ) ;
}
2016-02-01 22:46:27 +01:00
// This is ugly, but PS3 headers shall not be included there.
2016-07-27 23:43:22 +02:00
extern void sysutil_send_system_cmd ( u64 status , u64 param ) ;
2016-02-01 22:46:27 +01:00
2013-12-08 14:47:54 +01:00
void MainFrame : : SendExit ( wxCommandEvent & event )
{
2016-07-27 23:43:22 +02:00
sysutil_send_system_cmd ( 0x0101 /* CELL_SYSUTIL_REQUEST_EXITGAME */ , 0 ) ;
2013-12-08 14:47:54 +01:00
}
void MainFrame : : SendOpenCloseSysMenu ( wxCommandEvent & event )
{
2016-07-27 23:43:22 +02:00
sysutil_send_system_cmd ( m_sys_menu_opened ? 0x0132 /* CELL_SYSUTIL_SYSTEM_MENU_CLOSE */ : 0x0131 /* CELL_SYSUTIL_SYSTEM_MENU_OPEN */ , 0 ) ;
2013-12-08 14:47:54 +01:00
m_sys_menu_opened = ! m_sys_menu_opened ;
wxCommandEvent ce ;
UpdateUI ( ce ) ;
}
void MainFrame : : Config ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-08-23 10:06:15 +02:00
SettingsDialog ( this ) ;
2013-12-27 11:55:11 +01:00
}
void MainFrame : : ConfigPad ( wxCommandEvent & WXUNUSED ( event ) )
{
2014-04-05 16:26:45 +02:00
PADManager ( this ) . ShowModal ( ) ;
2013-12-08 14:47:54 +01:00
}
void MainFrame : : ConfigVFS ( wxCommandEvent & WXUNUSED ( event ) )
{
2016-02-01 22:46:27 +01:00
//VFSManagerDialog(this).ShowModal();
2013-12-08 14:47:54 +01:00
}
void MainFrame : : ConfigVHDD ( wxCommandEvent & WXUNUSED ( event ) )
{
2016-02-01 22:46:27 +01:00
//VHDDManagerDialog(this).ShowModal();
2013-12-08 14:47:54 +01:00
}
2014-08-14 17:22:13 +02:00
void MainFrame : : ConfigAutoPause ( wxCommandEvent & WXUNUSED ( event ) )
{
AutoPauseManagerDialog ( this ) . ShowModal ( ) ;
}
2014-08-15 13:44:16 +02:00
void MainFrame : : ConfigSaveData ( wxCommandEvent & event )
{
SaveDataListDialog ( this , true ) . ShowModal ( ) ;
}
2013-12-08 14:47:54 +01:00
void MainFrame : : OpenELFCompiler ( wxCommandEvent & WXUNUSED ( event ) )
{
2016-02-01 22:46:27 +01:00
//(new CompilerELF(this))->Show();
2013-12-08 14:47:54 +01:00
}
2014-07-26 07:51:45 +02:00
void MainFrame : : OpenKernelExplorer ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-10-04 00:45:26 +02:00
( new KernelExplorer ( this ) ) - > Show ( ) ;
2014-07-26 07:51:45 +02:00
}
2013-12-08 14:47:54 +01:00
void MainFrame : : OpenMemoryViewer ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-10-04 00:45:26 +02:00
( new MemoryViewerPanel ( this ) ) - > Show ( ) ;
2013-12-08 14:47:54 +01:00
}
2013-12-30 23:59:39 +01:00
void MainFrame : : OpenRSXDebugger ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-10-04 00:45:26 +02:00
( new RSXDebugger ( this ) ) - > Show ( ) ;
2013-12-30 23:59:39 +01:00
}
2014-12-25 05:39:57 +01:00
void MainFrame : : OpenStringSearch ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-10-04 00:45:26 +02:00
( new MemoryStringSearcher ( this ) ) - > Show ( ) ;
2014-12-25 05:39:57 +01:00
}
2014-04-09 21:57:26 +02:00
2015-02-22 15:47:12 +01:00
void MainFrame : : OpenCgDisasm ( wxCommandEvent & WXUNUSED ( event ) )
{
( new CgDisasm ( this ) ) - > Show ( ) ;
}
2013-12-08 14:47:54 +01:00
void MainFrame : : AboutDialogHandler ( wxCommandEvent & WXUNUSED ( event ) )
{
AboutDialog ( this ) . ShowModal ( ) ;
}
2017-02-09 23:51:29 +01:00
void MainFrame : : UpdateUI ( wxEvent & event )
2013-12-08 14:47:54 +01:00
{
2017-02-09 23:51:29 +01:00
const bool is_running = Emu . IsRunning ( ) ;
const bool is_stopped = Emu . IsStopped ( ) ;
const bool is_ready = Emu . IsReady ( ) ;
2013-12-08 14:47:54 +01:00
2014-07-06 01:30:28 +02:00
// Update menu items based on the state of the emulator
2013-12-08 14:47:54 +01:00
wxMenuBar & menubar ( * GetMenuBar ( ) ) ;
2014-07-06 01:30:28 +02:00
// Emulation
2015-07-09 19:42:39 +02:00
wxMenuItem & pause = * menubar . FindItem ( id_sys_pause ) ;
wxMenuItem & stop = * menubar . FindItem ( id_sys_stop ) ;
2014-11-24 19:12:04 +01:00
pause . SetItemLabel ( is_running ? " &Pause \t Ctrl + P " : is_ready ? " &Start \t Ctrl + E " : " &Resume \t Ctrl + E " ) ;
2013-12-08 14:47:54 +01:00
pause . Enable ( ! is_stopped ) ;
stop . Enable ( ! is_stopped ) ;
2014-07-06 01:30:28 +02:00
// PS3 Commands
2015-07-09 19:42:39 +02:00
wxMenuItem & send_exit = * menubar . FindItem ( id_sys_send_exit ) ;
wxMenuItem & send_open_menu = * menubar . FindItem ( id_sys_send_open_menu ) ;
2014-09-11 21:18:19 +02:00
bool enable_commands = ! is_stopped ;
2014-11-24 19:12:04 +01:00
send_open_menu . SetItemLabel ( wxString : : Format ( " Send &%s system menu cmd " , ( m_sys_menu_opened ? " close " : " open " ) ) ) ;
2013-12-08 14:47:54 +01:00
send_open_menu . Enable ( enable_commands ) ;
send_exit . Enable ( enable_commands ) ;
2014-07-06 01:30:28 +02:00
// Tools
2014-07-26 07:51:45 +02:00
wxMenuItem & kernel_explorer = * menubar . FindItem ( id_tools_kernel_explorer ) ;
wxMenuItem & memory_viewer = * menubar . FindItem ( id_tools_memory_viewer ) ;
wxMenuItem & rsx_debugger = * menubar . FindItem ( id_tools_rsx_debugger ) ;
2014-12-25 05:39:57 +01:00
wxMenuItem & string_search = * menubar . FindItem ( id_tools_string_search ) ;
2014-07-26 07:51:45 +02:00
kernel_explorer . Enable ( ! is_stopped ) ;
2014-07-06 01:30:28 +02:00
memory_viewer . Enable ( ! is_stopped ) ;
rsx_debugger . Enable ( ! is_stopped ) ;
2014-12-25 05:39:57 +01:00
string_search . Enable ( ! is_stopped ) ;
2013-12-08 14:47:54 +01:00
2017-02-09 23:51:29 +01:00
// Debugger
m_debugger_frame - > UpdateUI ( ) ;
// Logs
m_log_frame - > UpdateUI ( ) ;
2013-12-08 14:47:54 +01:00
}
void MainFrame : : OnKeyDown ( wxKeyEvent & event )
{
if ( wxGetActiveWindow ( ) /*== this*/ & & event . ControlDown ( ) )
{
switch ( event . GetKeyCode ( ) )
{
2014-02-19 01:41:57 +01:00
case ' E ' : case ' e ' : if ( Emu . IsPaused ( ) ) Emu . Resume ( ) ; else if ( Emu . IsReady ( ) ) Emu . Run ( ) ; return ;
2013-12-08 14:47:54 +01:00
case ' P ' : case ' p ' : if ( Emu . IsRunning ( ) ) Emu . Pause ( ) ; return ;
case ' S ' : case ' s ' : if ( ! Emu . IsStopped ( ) ) Emu . Stop ( ) ; return ;
2015-09-18 00:41:14 +02:00
case ' R ' : case ' r ' : if ( ! Emu . GetPath ( ) . empty ( ) ) { Emu . Stop ( ) ; Emu . Run ( ) ; } return ;
2013-12-08 14:47:54 +01:00
}
}
event . Skip ( ) ;
}