2011-02-20 08:40:22 +00:00
using System ;
2011-07-24 06:45:05 +00:00
using System.Text ;
2011-02-20 08:40:22 +00:00
using System.Threading ;
2011-01-11 02:55:51 +00:00
using System.Drawing ;
using System.Drawing.Imaging ;
using System.IO ;
using System.Windows.Forms ;
2012-12-25 20:36:04 +00:00
using System.Diagnostics ;
2011-01-11 02:55:51 +00:00
using BizHawk.Core ;
2011-08-03 00:57:01 +00:00
using BizHawk.DiscSystem ;
2011-01-11 02:55:51 +00:00
using BizHawk.Emulation.Consoles.Sega ;
using BizHawk.Emulation.Consoles.TurboGrafx ;
2011-01-18 10:28:10 +00:00
using BizHawk.Emulation.Consoles.Calculator ;
2011-02-20 02:17:09 +00:00
using BizHawk.Emulation.Consoles.Nintendo ;
2012-09-04 00:20:36 +00:00
using BizHawk.Emulation.Consoles.Nintendo.SNES ;
2012-05-06 00:54:13 +00:00
using BizHawk.Emulation.Consoles.Coleco ;
2011-08-03 03:00:19 +00:00
using BizHawk.MultiClient.tools ;
2012-03-04 19:02:28 +00:00
using System.Collections.Generic ;
2012-07-09 05:29:45 +00:00
using BizHawk.Emulation.Consoles.Intellivision ;
2012-09-09 02:06:07 +00:00
using BizHawk.Emulation.Consoles.GB ;
2012-11-19 22:43:34 +00:00
using BizHawk.Emulation.Consoles.Nintendo.GBA ;
2012-11-01 16:48:32 +00:00
using BizHawk.Emulation.Computers.Commodore64 ;
2012-12-14 02:17:47 +00:00
using BizHawk.Emulation ;
2011-01-11 02:55:51 +00:00
namespace BizHawk.MultiClient
{
2011-07-11 07:35:14 +00:00
2011-02-20 08:40:22 +00:00
public partial class MainForm : Form
{
2012-12-25 20:36:04 +00:00
public static bool INTERIM = true ;
2012-10-21 05:21:59 +00:00
public const string EMUVERSION = "Version " + VersionInfo . MAINVERSION ;
2012-12-23 18:40:16 +00:00
public const string RELEASEDATE = "December 23, 2012" ;
2011-02-20 08:40:22 +00:00
private Control renderTarget ;
2011-01-11 02:55:51 +00:00
private RetainedViewportPanel retainedPanel ;
2011-05-11 01:47:28 +00:00
public string CurrentlyOpenRom ;
2011-07-01 01:28:25 +00:00
SavestateManager StateSlots = new SavestateManager ( ) ;
2011-08-06 19:30:21 +00:00
2013-02-26 00:36:13 +00:00
public bool PauseAVI = false ;
2011-06-11 19:39:34 +00:00
public bool PressFrameAdvance = false ;
public bool PressRewind = false ;
2012-05-28 01:29:43 +00:00
public bool FastForward = false ;
public bool TurboFastForward = false ;
2012-06-18 01:36:38 +00:00
public bool RestoreReadWriteOnStop = false ;
2012-06-01 05:49:26 +00:00
public bool UpdateFrame = false ;
2012-09-29 23:03:51 +00:00
public bool NeedsReboot = false ;
2011-07-11 07:35:14 +00:00
//avi/wav state
2012-05-06 22:18:16 +00:00
IVideoWriter CurrAviWriter = null ;
sound api changes. added a new ISyncSoundProvider, which works similarly to ISoundProvider except the source (not the sink) determines the number of samples to process. Added facilities to metaspu, dcfilter, speexresampler to work with ISyncSoundProvider. Add ISyncSoundProvider to IEmulator. All IEmulators must provide sync sound, but they need not provide async sound. When async is needed and an IEmulator doesn't provide it, the frontend will wrap it in a vecna metaspu. SNES, GB changed to provide sync sound only. All other emulator cores mostly unchanged; they just provide stub fakesync alongside async, for now. For the moment, the only use of the sync sound is for realtime audio throttling, where it works and sounds quite nice. In the future, sync sound will be supported for AV dumping as well.
2012-10-11 00:44:59 +00:00
ISoundProvider AviSoundInput = null ;
2012-05-28 01:29:43 +00:00
/// <summary>
/// an audio proxy used for dumping
/// </summary>
2012-09-05 00:36:38 +00:00
Emulation . Sound . MetaspuSoundProvider DumpProxy = null ;
2012-07-11 21:37:35 +00:00
/// <summary>audio timekeeping for video dumping</summary>
long SoundRemainder = 0 ;
2012-11-26 02:25:23 +00:00
int avwriter_resizew ;
int avwriter_resizeh ;
2011-07-11 07:35:14 +00:00
2011-02-20 08:40:22 +00:00
//runloop control
2011-02-21 09:48:53 +00:00
bool exit ;
bool runloop_frameProgress ;
DateTime FrameAdvanceTimestamp = DateTime . MinValue ;
2012-09-29 22:37:34 +00:00
public bool EmulatorPaused { get ; private set ; }
2012-01-28 21:43:55 +00:00
public EventWaitHandle MainWait ;
2011-03-16 06:30:25 +00:00
int runloop_fps ;
2011-06-10 07:12:57 +00:00
int runloop_last_fps ;
2011-02-21 09:48:53 +00:00
bool runloop_frameadvance ;
2011-03-16 06:30:25 +00:00
DateTime runloop_second ;
2011-06-11 12:54:26 +00:00
bool runloop_last_ff ;
2011-08-27 18:09:54 +00:00
Throttle throttle ;
2011-06-11 12:54:26 +00:00
bool unthrottled = false ;
2011-02-20 08:40:22 +00:00
//For handling automatic pausing when entering the menu
private bool wasPaused = false ;
private bool didMenuPause = false ;
//tool dialogs
public RamWatch RamWatch1 = new RamWatch ( ) ;
public RamSearch RamSearch1 = new RamSearch ( ) ;
2011-06-11 12:54:26 +00:00
public HexEditor HexEditor1 = new HexEditor ( ) ;
2012-09-30 00:53:08 +00:00
public TraceLogger TraceLogger1 = new TraceLogger ( ) ;
2012-09-06 08:32:25 +00:00
public SNESGraphicsDebugger SNESGraphicsDebugger1 = new SNESGraphicsDebugger ( ) ;
2011-06-11 12:54:26 +00:00
public NESNameTableViewer NESNameTableViewer1 = new NESNameTableViewer ( ) ;
public NESPPU NESPPU1 = new NESPPU ( ) ;
public NESDebugger NESDebug1 = new NESDebugger ( ) ;
2012-11-05 01:34:11 +00:00
public GBtools . GBGPUView GBGPUView1 = new GBtools . GBGPUView ( ) ;
2012-11-26 23:16:31 +00:00
public GBAtools . GBAGPUView GBAGPUView1 = new GBAtools . GBAGPUView ( ) ;
2012-03-12 05:19:59 +00:00
public PCEBGViewer PCEBGViewer1 = new PCEBGViewer ( ) ;
2011-06-11 12:54:26 +00:00
public Cheats Cheats1 = new Cheats ( ) ;
public ToolBox ToolBox1 = new ToolBox ( ) ;
public TI83KeyPad TI83KeyPad1 = new TI83KeyPad ( ) ;
public TAStudio TAStudio1 = new TAStudio ( ) ;
2012-10-29 22:57:15 +00:00
public VirtualPadForm VirtualPadForm1 = new VirtualPadForm ( ) ;
2012-03-12 04:44:34 +00:00
#if WINDOWS
2012-01-21 20:05:53 +00:00
public LuaConsole LuaConsole1 = new LuaConsole ( ) ;
2012-03-12 04:44:34 +00:00
#endif
2011-02-20 08:40:22 +00:00
2012-07-23 00:33:30 +00:00
/// <summary>
/// number of frames to autodump
/// </summary>
int autoDumpLength = 0 ;
2013-01-02 18:52:11 +00:00
static MainForm ( )
{
//if this isnt here, then our assemblyresolving hacks wont work due to the check for MainForm.INTERIM
//its.. weird. dont ask.
}
2012-07-23 00:33:30 +00:00
2011-02-20 08:40:22 +00:00
public MainForm ( string [ ] args )
{
2011-09-03 18:07:30 +00:00
Global . MovieSession = new MovieSession ( ) ;
Global . MovieSession . Movie = new Movie ( ) ;
2012-01-28 21:43:55 +00:00
MainWait = new AutoResetEvent ( false ) ;
2011-08-21 06:07:38 +00:00
Icon = BizHawk . MultiClient . Properties . Resources . logo ;
2011-03-21 00:54:30 +00:00
InitializeComponent ( ) ;
2011-09-11 00:11:46 +00:00
Global . Game = GameInfo . GetNullGame ( ) ;
2011-07-10 20:01:27 +00:00
if ( Global . Config . ShowLogWindow )
{
2012-03-09 21:36:55 +00:00
ShowConsole ( ) ;
2012-02-24 20:45:27 +00:00
//PsxApi.StdioFixes();
2011-07-10 20:01:27 +00:00
displayLogWindowToolStripMenuItem . Checked = true ;
}
2011-09-24 16:19:38 +00:00
2011-08-27 18:09:54 +00:00
throttle = new Throttle ( ) ;
2011-08-08 01:48:31 +00:00
DiscSystem . FFMpeg . FFMpegPath = PathManager . MakeProgramRelativePath ( Global . Config . FFMpegPath ) ;
2011-07-09 19:54:24 +00:00
2011-08-06 19:30:21 +00:00
Global . CheatList = new CheatList ( ) ;
2011-07-22 01:14:13 +00:00
UpdateStatusSlots ( ) ;
2012-12-02 16:17:42 +00:00
UpdateKeyPriorityIcon ( ) ;
2011-08-09 00:51:46 +00:00
2011-03-07 10:41:46 +00:00
//in order to allow late construction of this database, we hook up a delegate here to dearchive the data and provide it on demand
//we could background thread this later instead if we wanted to be real clever
2011-06-11 12:54:26 +00:00
NES . BootGodDB . GetDatabaseBytes = ( ) = >
{
2012-10-09 20:33:14 +00:00
using ( HawkFile NesCartFile = new HawkFile ( Path . Combine ( PathManager . GetExeDirectoryAbsolute ( ) , "gamedb" , "NesCarts.7z" ) ) . BindFirst ( ) )
2011-06-11 12:54:26 +00:00
return Util . ReadAllBytes ( NesCartFile . GetStream ( ) ) ;
2011-03-07 10:41:46 +00:00
} ;
2011-02-20 08:40:22 +00:00
Global . MainForm = this ;
2012-12-10 00:43:43 +00:00
//Global.CoreComm = new CoreComm();
//SyncCoreCommInputSignals();
2011-02-20 08:40:22 +00:00
2012-10-09 01:54:15 +00:00
Database . LoadDatabase ( Path . Combine ( PathManager . GetExeDirectoryAbsolute ( ) , "gamedb" , "gamedb.txt" ) ) ;
2011-01-11 02:55:51 +00:00
2011-03-21 00:54:30 +00:00
SyncPresentationMode ( ) ;
2011-01-11 02:55:51 +00:00
2011-02-20 08:40:22 +00:00
Load + = ( o , e ) = >
2011-02-21 16:35:42 +00:00
{
AllowDrop = true ;
DragEnter + = FormDragEnter ;
DragDrop + = FormDragDrop ;
} ;
2011-02-20 08:40:22 +00:00
2011-06-11 12:54:26 +00:00
Closing + = ( o , e ) = >
{
2011-08-06 22:03:10 +00:00
Global . CheatList . SaveSettings ( ) ;
2011-06-11 12:54:26 +00:00
CloseGame ( ) ;
2012-09-03 19:42:53 +00:00
Global . MovieSession . Movie . Stop ( ) ;
2012-04-21 22:46:48 +00:00
CloseTools ( ) ;
2012-02-03 12:18:27 +00:00
SaveConfig ( ) ;
2011-06-11 12:54:26 +00:00
} ;
2011-02-20 08:40:22 +00:00
ResizeBegin + = ( o , e ) = >
{
if ( Global . Sound ! = null ) Global . Sound . StopSound ( ) ;
} ;
ResizeEnd + = ( o , e ) = >
{
if ( Global . RenderPanel ! = null ) Global . RenderPanel . Resized = true ;
if ( Global . Sound ! = null ) Global . Sound . StartSound ( ) ;
} ;
2011-07-13 01:29:13 +00:00
Input . Initialize ( ) ;
InitControls ( ) ;
2012-12-10 00:43:43 +00:00
Global . CoreComm = new CoreComm ( ) ;
SyncCoreCommInputSignals ( ) ;
Global . Emulator = new NullEmulator ( Global . CoreComm ) ;
2011-06-11 12:54:26 +00:00
Global . ActiveController = Global . NullControls ;
2011-08-09 22:13:57 +00:00
Global . AutoFireController = Global . AutofireNullControls ;
2012-09-15 13:33:04 +00:00
Global . AutofireStickyXORAdapter . SetOnOffPatternFromConfig ( ) ;
2012-03-12 04:44:34 +00:00
#if WINDOWS
2011-02-20 08:40:22 +00:00
Global . Sound = new Sound ( Handle , Global . DSound ) ;
2012-03-12 04:44:34 +00:00
#else
Global . Sound = new Sound ( ) ;
#endif
2011-02-20 08:40:22 +00:00
Global . Sound . StartSound ( ) ;
2011-06-28 23:43:13 +00:00
RewireInputChain ( ) ;
2011-02-05 21:00:59 +00:00
//TODO - replace this with some kind of standard dictionary-yielding parser in a separate component
string cmdRom = null ;
string cmdLoadState = null ;
2011-06-11 12:54:26 +00:00
string cmdMovie = null ;
2012-07-23 00:33:30 +00:00
string cmdDumpType = null ;
string cmdDumpName = null ;
2011-02-05 21:00:59 +00:00
for ( int i = 0 ; i < args . Length ; i + + )
2011-06-11 12:54:26 +00:00
{
2011-06-06 21:08:38 +00:00
//for some reason sometimes visual studio will pass this to us on the commandline. it makes no sense.
if ( args [ i ] = = ">" )
{
i + + ;
string stdout = args [ i ] ;
Console . SetOut ( new StreamWriter ( stdout ) ) ;
continue ;
}
2011-02-05 21:00:59 +00:00
string arg = args [ i ] . ToLower ( ) ;
2011-06-06 21:08:38 +00:00
if ( arg . StartsWith ( "--load-slot=" ) )
cmdLoadState = arg . Substring ( arg . IndexOf ( '=' ) + 1 ) ;
else if ( arg . StartsWith ( "--movie=" ) )
cmdMovie = arg . Substring ( arg . IndexOf ( '=' ) + 1 ) ;
2012-07-23 00:33:30 +00:00
else if ( arg . StartsWith ( "--dump-type=" ) )
cmdDumpType = arg . Substring ( arg . IndexOf ( '=' ) + 1 ) ;
else if ( arg . StartsWith ( "--dump-name=" ) )
cmdDumpName = arg . Substring ( arg . IndexOf ( '=' ) + 1 ) ;
else if ( arg . StartsWith ( "--dump-length=" ) )
int . TryParse ( arg . Substring ( arg . IndexOf ( '=' ) + 1 ) , out autoDumpLength ) ;
2011-06-06 21:08:38 +00:00
else
cmdRom = arg ;
2011-02-05 21:00:59 +00:00
}
2011-03-19 09:12:56 +00:00
if ( cmdRom ! = null )
{
//Commandline should always override auto-load
2011-02-05 21:00:59 +00:00
LoadRom ( cmdRom ) ;
2011-03-19 09:12:56 +00:00
if ( Global . Game = = null )
{
2011-05-22 00:13:12 +00:00
MessageBox . Show ( "Failed to load " + cmdRom + " specified on commandline" ) ;
2011-03-19 09:12:56 +00:00
}
}
2013-03-10 22:42:54 +00:00
else if ( Global . Config . AutoLoadMostRecentRom & & ! Global . Config . RecentRoms . IsEmpty )
2011-02-20 08:40:22 +00:00
LoadRomFromRecent ( Global . Config . RecentRoms . GetRecentFileByPosition ( 0 ) ) ;
2011-01-19 04:18:33 +00:00
2011-06-11 12:54:26 +00:00
if ( cmdMovie ! = null )
{
2011-06-30 02:30:06 +00:00
if ( Global . Game = = null )
2012-09-03 19:42:53 +00:00
{
2011-06-30 02:30:06 +00:00
OpenROM ( ) ;
2012-09-03 19:42:53 +00:00
}
else
2011-06-30 02:30:06 +00:00
{
2012-09-03 19:42:53 +00:00
Movie m = new Movie ( cmdMovie ) ;
2011-06-30 02:30:06 +00:00
ReadOnly = true ;
2012-07-23 00:33:30 +00:00
// if user is dumping and didnt supply dump length, make it as long as the loaded movie
if ( autoDumpLength = = 0 )
2012-09-03 19:42:53 +00:00
{
autoDumpLength = m . Frames ;
}
2011-06-30 02:30:06 +00:00
StartNewMovie ( m , false ) ;
Global . Config . RecentMovies . Add ( cmdMovie ) ;
}
2011-06-11 12:54:26 +00:00
}
2013-03-10 22:42:54 +00:00
else if ( Global . Config . AutoLoadMostRecentMovie & & ! Global . Config . RecentMovies . IsEmpty )
2011-06-11 12:54:26 +00:00
{
2011-06-30 02:30:06 +00:00
if ( Global . Game = = null )
2012-09-03 19:42:53 +00:00
{
2011-06-30 02:30:06 +00:00
OpenROM ( ) ;
2012-09-03 19:42:53 +00:00
}
else
2011-06-30 02:30:06 +00:00
{
2012-09-03 19:42:53 +00:00
Movie m = new Movie ( Global . Config . RecentMovies . GetRecentFileByPosition ( 0 ) ) ;
2011-06-30 02:30:06 +00:00
StartNewMovie ( m , false ) ;
}
2011-06-11 12:54:26 +00:00
}
2011-05-21 22:37:15 +00:00
2011-03-19 09:12:56 +00:00
if ( cmdLoadState ! = null & & Global . Game ! = null )
2012-09-03 19:42:53 +00:00
{
2011-02-05 21:00:59 +00:00
LoadState ( "QuickSave" + cmdLoadState ) ;
2012-09-03 19:42:53 +00:00
}
2011-09-17 00:25:34 +00:00
else if ( Global . Config . AutoLoadLastSaveSlot & & Global . Game ! = null )
2012-09-03 19:42:53 +00:00
{
2011-09-17 00:25:34 +00:00
LoadState ( "QuickSave" + Global . Config . SaveSlot . ToString ( ) ) ;
2012-09-03 19:42:53 +00:00
}
2011-02-05 21:00:59 +00:00
2011-02-20 08:40:22 +00:00
if ( Global . Config . AutoLoadRamWatch )
2012-08-15 01:03:27 +00:00
{
2012-08-15 01:14:25 +00:00
if ( Global . Config . DisplayRamWatch )
{
LoadRamWatch ( false ) ;
}
else
{
LoadRamWatch ( true ) ;
}
2012-08-15 01:03:27 +00:00
}
2011-02-20 08:40:22 +00:00
if ( Global . Config . AutoLoadRamSearch )
LoadRamSearch ( ) ;
2011-06-11 12:54:26 +00:00
if ( Global . Config . AutoLoadHexEditor )
LoadHexEditor ( ) ;
if ( Global . Config . AutoLoadCheats )
LoadCheatsWindow ( ) ;
2011-03-16 14:37:01 +00:00
if ( Global . Config . AutoLoadNESPPU & & Global . Emulator is NES )
2011-06-11 12:54:26 +00:00
LoadNESPPU ( ) ;
if ( Global . Config . AutoLoadNESNameTable & & Global . Emulator is NES )
LoadNESNameTable ( ) ;
if ( Global . Config . AutoLoadNESDebugger & & Global . Emulator is NES )
LoadNESDebugger ( ) ;
if ( Global . Config . NESGGAutoload & & Global . Emulator is NES )
LoadGameGenieEC ( ) ;
2012-11-09 18:55:59 +00:00
if ( Global . Config . AutoLoadGBGPUView & & Global . Emulator is Gameboy )
LoadGBGPUView ( ) ;
2012-10-29 22:57:15 +00:00
2011-06-11 22:32:12 +00:00
if ( Global . Config . AutoloadTAStudio )
2012-10-29 22:57:15 +00:00
{
2011-06-11 22:32:12 +00:00
LoadTAStudio ( ) ;
2012-10-29 22:57:15 +00:00
}
if ( Global . Config . AutoloadVirtualPad )
{
LoadVirtualPads ( ) ;
}
2012-01-10 01:30:17 +00:00
if ( Global . Config . AutoLoadLuaConsole )
OpenLuaConsole ( ) ;
2012-03-13 02:41:10 +00:00
if ( Global . Config . PCEBGViewerAutoload & & Global . Emulator is PCEngine )
LoadPCEBGViewer ( ) ;
2012-09-10 19:44:44 +00:00
if ( Global . Config . AutoLoadSNESGraphicsDebugger & & Global . Emulator is LibsnesCore )
LoadSNESGraphicsDebugger ( ) ;
2012-09-30 03:09:41 +00:00
if ( Global . Config . TraceLoggerAutoLoad )
2012-09-30 13:38:37 +00:00
{
2012-12-10 00:43:43 +00:00
if ( Global . CoreComm . CpuTraceAvailable )
2012-09-30 13:38:37 +00:00
{
LoadTraceLogger ( ) ;
}
}
2011-02-20 08:40:22 +00:00
if ( Global . Config . MainWndx > = 0 & & Global . Config . MainWndy > = 0 & & Global . Config . SaveWindowPosition )
this . Location = new Point ( Global . Config . MainWndx , Global . Config . MainWndy ) ;
2011-06-11 12:54:26 +00:00
if ( Global . Config . DisplayStatusBar = = false )
2011-07-01 01:28:25 +00:00
StatusSlot0 . Visible = false ;
2011-06-11 12:54:26 +00:00
else
displayStatusBarToolStripMenuItem . Checked = true ;
2011-06-10 04:41:33 +00:00
2011-02-20 08:40:22 +00:00
if ( Global . Config . StartPaused )
PauseEmulator ( ) ;
2011-09-11 00:11:46 +00:00
if ( ! INTERIM )
{
debuggerToolStripMenuItem . Enabled = false ;
2012-03-03 20:49:44 +00:00
//luaConsoleToolStripMenuItem.Enabled = false;
2011-09-11 00:11:46 +00:00
}
2012-07-23 00:33:30 +00:00
// start dumping, if appropriate
if ( cmdDumpType ! = null & & cmdDumpName ! = null )
{
RecordAVI ( cmdDumpType , cmdDumpName ) ;
}
2012-10-10 22:52:11 +00:00
UpdateStatusSlots ( ) ;
2011-02-21 09:48:53 +00:00
}
2011-02-20 08:40:22 +00:00
2012-04-16 08:18:41 +00:00
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose ( bool disposing )
{
2012-05-28 01:29:43 +00:00
if ( Global . DisplayManager ! = null ) Global . DisplayManager . Dispose ( ) ;
2012-04-16 08:18:41 +00:00
Global . DisplayManager = null ;
if ( disposing & & ( components ! = null ) )
{
components . Dispose ( ) ;
}
base . Dispose ( disposing ) ;
}
2012-12-25 20:36:04 +00:00
//contains a mapping: profilename->exepath ; or null if the exe wasnt available
Dictionary < string , string > SNES_prepared = new Dictionary < string , string > ( ) ;
string SNES_Prepare ( string profile )
{
SNES_Check ( profile ) ;
if ( SNES_prepared [ profile ] = = null )
{
throw new InvalidOperationException ( "Couldn't locate the executable for SNES emulation for profile: " + profile + ". Please make sure you're using a fresh dearchive of a BizHawk distribution." ) ;
}
return SNES_prepared [ profile ] ;
}
void SNES_Check ( string profile )
{
if ( SNES_prepared . ContainsKey ( profile ) ) return ;
2012-12-26 20:25:06 +00:00
string bits = "32" ;
2012-12-26 21:30:29 +00:00
//disabled til it works
//if (Win32.Is64BitOperatingSystem)
// bits = "64";
2012-12-26 20:25:06 +00:00
string exename = "libsneshawk-" + bits + "-" + profile . ToLower ( ) + ".exe" ;
2012-12-25 20:36:04 +00:00
string thisDir = PathManager . GetExeDirectoryAbsolute ( ) ;
string exePath = Path . Combine ( thisDir , exename ) ;
if ( ! File . Exists ( exePath ) )
exePath = Path . Combine ( Path . Combine ( thisDir , "dll" ) , exename ) ;
if ( ! File . Exists ( exePath ) )
exePath = null ;
SNES_prepared [ profile ] = exePath ;
}
2012-12-10 00:43:43 +00:00
public void SyncCoreCommInputSignals ( CoreComm target )
{
target . NES_BackdropColor = Global . Config . NESBackgroundColor ;
target . NES_UnlimitedSprites = Global . Config . NESAllowMoreThanEightSprites ;
target . NES_ShowBG = Global . Config . NESDispBackground ;
target . NES_ShowOBJ = Global . Config . NESDispSprites ;
target . PCE_ShowBG1 = Global . Config . PCEDispBG1 ;
target . PCE_ShowOBJ1 = Global . Config . PCEDispOBJ1 ;
target . PCE_ShowBG2 = Global . Config . PCEDispBG2 ;
target . PCE_ShowOBJ2 = Global . Config . PCEDispOBJ2 ;
target . SMS_ShowBG = Global . Config . SMSDispBG ;
target . SMS_ShowOBJ = Global . Config . SMSDispOBJ ;
2012-12-30 17:52:40 +00:00
target . PSX_FirmwaresPath = PathManager . MakeAbsolutePath ( Global . Config . FirmwaresPath ) ; // PathManager.MakeAbsolutePath(Global.Config.PathPSXFirmwares, "PSX");
2012-12-10 00:43:43 +00:00
2012-12-30 17:52:40 +00:00
target . C64_FirmwaresPath = PathManager . MakeAbsolutePath ( Global . Config . FirmwaresPath ) ; // PathManager.MakeAbsolutePath(Global.Config.PathC64Firmwares, "C64");
2012-12-10 00:43:43 +00:00
2012-12-30 17:52:40 +00:00
target . SNES_FirmwaresPath = PathManager . MakeAbsolutePath ( Global . Config . FirmwaresPath ) ; // PathManager.MakeAbsolutePath(Global.Config.PathSNESFirmwares, "SNES");
2012-12-10 00:43:43 +00:00
target . SNES_ShowBG1_0 = Global . Config . SNES_ShowBG1_0 ;
target . SNES_ShowBG1_1 = Global . Config . SNES_ShowBG1_1 ;
target . SNES_ShowBG2_0 = Global . Config . SNES_ShowBG2_0 ;
target . SNES_ShowBG2_1 = Global . Config . SNES_ShowBG2_1 ;
target . SNES_ShowBG3_0 = Global . Config . SNES_ShowBG3_0 ;
target . SNES_ShowBG3_1 = Global . Config . SNES_ShowBG3_1 ;
target . SNES_ShowBG4_0 = Global . Config . SNES_ShowBG4_0 ;
target . SNES_ShowBG4_1 = Global . Config . SNES_ShowBG4_1 ;
target . SNES_ShowOBJ_0 = Global . Config . SNES_ShowOBJ1 ;
target . SNES_ShowOBJ_1 = Global . Config . SNES_ShowOBJ2 ;
target . SNES_ShowOBJ_2 = Global . Config . SNES_ShowOBJ3 ;
target . SNES_ShowOBJ_3 = Global . Config . SNES_ShowOBJ4 ;
2012-12-25 20:36:04 +00:00
target . SNES_Profile = Global . Config . SNESProfile ;
2013-01-18 05:06:26 +00:00
target . SNES_UseRingBuffer = Global . Config . SNESUseRingBuffer ;
2012-12-25 20:36:04 +00:00
2012-12-10 00:43:43 +00:00
target . GG_HighlightActiveDisplayRegion = Global . Config . GGHighlightActiveDisplayRegion ;
target . GG_ShowClippedRegions = Global . Config . GGShowClippedRegions ;
target . Atari2600_ShowBG = Global . Config . Atari2600_ShowBG ;
target . Atari2600_ShowPlayer1 = Global . Config . Atari2600_ShowPlayer1 ;
target . Atari2600_ShowPlayer2 = Global . Config . Atari2600_ShowPlayer2 ;
target . Atari2600_ShowMissle1 = Global . Config . Atari2600_ShowMissle1 ;
target . Atari2600_ShowMissle2 = Global . Config . Atari2600_ShowMissle2 ;
target . Atari2600_ShowBall = Global . Config . Atari2600_ShowBall ;
target . Atari2600_ShowPF = Global . Config . Atari2600_ShowPlayfield ;
}
public void SyncCoreCommInputSignals ( )
{
SyncCoreCommInputSignals ( Global . CoreComm ) ;
2011-06-11 22:15:08 +00:00
}
2011-03-21 00:54:30 +00:00
void SyncPresentationMode ( )
{
2012-04-16 08:18:41 +00:00
Global . DisplayManager . Suspend ( ) ;
2012-03-12 04:44:34 +00:00
#if WINDOWS
2011-08-21 01:07:58 +00:00
bool gdi = Global . Config . DisplayGDI ;
2011-09-24 16:19:38 +00:00
if ( Global . Direct3D = = null )
2011-08-21 01:07:58 +00:00
gdi = true ;
2012-03-12 04:44:34 +00:00
#endif
2011-03-21 00:54:30 +00:00
if ( renderTarget ! = null )
{
renderTarget . Dispose ( ) ;
Controls . Remove ( renderTarget ) ;
}
if ( retainedPanel ! = null ) retainedPanel . Dispose ( ) ;
if ( Global . RenderPanel ! = null ) Global . RenderPanel . Dispose ( ) ;
2012-03-12 04:44:34 +00:00
#if WINDOWS
2011-03-21 00:54:30 +00:00
if ( gdi )
2012-03-12 04:44:34 +00:00
#endif
2011-03-21 00:54:30 +00:00
renderTarget = retainedPanel = new RetainedViewportPanel ( ) ;
2012-03-12 04:44:34 +00:00
#if WINDOWS
2011-03-21 00:54:30 +00:00
else renderTarget = new ViewportPanel ( ) ;
2012-03-12 04:44:34 +00:00
#endif
2011-03-21 00:54:30 +00:00
Controls . Add ( renderTarget ) ;
Controls . SetChildIndex ( renderTarget , 0 ) ;
renderTarget . Dock = DockStyle . Fill ;
renderTarget . BackColor = Color . Black ;
2012-03-12 04:44:34 +00:00
#if WINDOWS
2011-03-21 00:54:30 +00:00
if ( gdi )
{
2012-03-12 04:44:34 +00:00
#endif
2011-03-21 00:54:30 +00:00
Global . RenderPanel = new SysdrawingRenderPanel ( retainedPanel ) ;
retainedPanel . ActivateThreaded ( ) ;
2012-03-12 04:44:34 +00:00
#if WINDOWS
2011-03-21 00:54:30 +00:00
}
else
{
2011-08-21 01:07:58 +00:00
try
{
var d3dPanel = new Direct3DRenderPanel ( Global . Direct3D , renderTarget ) ;
d3dPanel . CreateDevice ( ) ;
Global . RenderPanel = d3dPanel ;
}
catch
{
Program . DisplayDirect3DError ( ) ;
Global . Direct3D . Dispose ( ) ;
Global . Direct3D = null ;
SyncPresentationMode ( ) ;
}
2011-03-21 00:54:30 +00:00
}
2012-03-12 04:44:34 +00:00
#endif
2012-04-16 08:18:41 +00:00
Global . DisplayManager . Resume ( ) ;
2011-03-21 00:54:30 +00:00
}
2011-06-11 12:54:26 +00:00
void SyncThrottle ( )
{
2012-08-28 01:29:07 +00:00
bool fastforward = Global . ClientControls [ "Fast Forward" ] | | FastForward | | Global . ClientControls [ "MaxTurbo" ] ;
2012-10-10 17:19:51 +00:00
Global . ForceNoThrottle = unthrottled | | fastforward ;
2011-09-04 05:18:38 +00:00
2012-07-11 21:37:35 +00:00
// realtime throttle is never going to be so exact that using a double here is wrong
2012-12-10 00:43:43 +00:00
throttle . SetCoreFps ( Global . Emulator . CoreComm . VsyncRate ) ;
2011-09-16 00:40:33 +00:00
2012-03-18 17:11:59 +00:00
throttle . signal_paused = EmulatorPaused | | Global . Emulator is NullEmulator ;
2011-06-11 12:54:26 +00:00
throttle . signal_unthrottle = unthrottled ;
2011-09-04 05:18:38 +00:00
if ( fastforward )
2011-06-11 12:54:26 +00:00
throttle . SetSpeedPercent ( Global . Config . SpeedPercentAlternate ) ;
else
throttle . SetSpeedPercent ( Global . Config . SpeedPercent ) ;
}
2011-06-10 07:12:57 +00:00
2011-06-11 12:54:26 +00:00
void SetSpeedPercentAlternate ( int value )
{
Global . Config . SpeedPercentAlternate = value ;
SyncThrottle ( ) ;
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "Alternate Speed: " + value + "%" ) ;
2011-06-11 12:54:26 +00:00
}
2011-03-21 00:54:30 +00:00
2011-02-21 09:48:53 +00:00
void SetSpeedPercent ( int value )
{
Global . Config . SpeedPercent = value ;
2011-06-11 12:54:26 +00:00
SyncThrottle ( ) ;
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "Speed: " + value + "%" ) ;
2011-02-20 08:40:22 +00:00
}
public void ProgramRunLoop ( )
{
2012-02-24 20:38:35 +00:00
CheckMessages ( ) ;
LogConsole . PositionConsole ( ) ;
2011-02-20 08:40:22 +00:00
for ( ; ; )
{
2011-07-09 22:09:39 +00:00
Input . Instance . Update ( ) ;
2011-07-10 07:39:40 +00:00
//handle events and dispatch as a hotkey action, or a hotkey button, or an input button
ProcessInput ( ) ;
Global . ClientControls . LatchFromPhysical ( Global . HotkeyCoalescer ) ;
Global . ActiveController . LatchFromPhysical ( Global . ControllerInputCoalescer ) ;
2012-09-15 13:11:29 +00:00
2011-07-24 20:23:27 +00:00
Global . ActiveController . OR_FromLogical ( Global . ClickyVirtualPadController ) ;
2011-08-09 00:51:46 +00:00
Global . AutoFireController . LatchFromPhysical ( Global . ControllerInputCoalescer ) ;
2012-09-15 13:11:29 +00:00
if ( Global . ClientControls [ "Autohold" ] )
{
Global . StickyXORAdapter . MassToggleStickyState ( Global . ActiveController . PressedButtons ) ;
Global . AutofireStickyXORAdapter . MassToggleStickyState ( Global . AutoFireController . PressedButtons ) ;
}
2013-03-09 20:10:04 +00:00
else if ( Global . ClientControls [ "AutoholdAutofire" ] )
{
Global . AutofireStickyXORAdapter . MassToggleStickyState ( Global . ActiveController . PressedButtons ) ;
}
2012-09-15 13:11:29 +00:00
2012-11-18 15:25:55 +00:00
//if (!EmulatorPaused)
//Global.ClickyVirtualPadController.FrameTick();
2012-01-28 21:43:55 +00:00
2012-03-23 23:03:39 +00:00
#if WINDOWS
2012-03-30 12:26:36 +00:00
LuaConsole1 . ResumeScripts ( false ) ;
2012-03-23 23:03:39 +00:00
#endif
2011-02-21 09:48:53 +00:00
StepRunLoop_Core ( ) ;
2011-09-16 00:40:33 +00:00
//if(!IsNullEmulator())
2011-09-24 16:19:38 +00:00
StepRunLoop_Throttle ( ) ;
2011-06-11 12:54:26 +00:00
2011-02-20 08:40:22 +00:00
Render ( ) ;
2012-01-28 21:43:55 +00:00
2011-02-20 08:40:22 +00:00
CheckMessages ( ) ;
2011-02-21 09:48:53 +00:00
if ( exit )
2011-02-20 18:28:01 +00:00
break ;
2011-02-20 08:40:22 +00:00
Thread . Sleep ( 0 ) ;
}
2011-07-11 07:35:14 +00:00
Shutdown ( ) ;
}
void Shutdown ( )
{
if ( CurrAviWriter ! = null )
{
CurrAviWriter . CloseFile ( ) ;
CurrAviWriter = null ;
2012-02-24 07:48:06 +00:00
}
2011-02-20 08:40:22 +00:00
}
void CheckMessages ( )
{
Application . DoEvents ( ) ;
if ( ActiveForm ! = null )
ScreenSaver . ResetTimerPeriodically ( ) ;
}
2012-01-21 20:20:06 +00:00
public void PauseEmulator ( )
2011-02-20 08:40:22 +00:00
{
EmulatorPaused = true ;
2012-11-06 00:04:50 +00:00
SetPauseStatusbarIcon ( ) ;
2011-02-20 08:40:22 +00:00
}
2012-01-21 20:20:06 +00:00
public void UnpauseEmulator ( )
2011-02-20 08:40:22 +00:00
{
EmulatorPaused = false ;
2012-11-06 00:04:50 +00:00
SetPauseStatusbarIcon ( ) ;
2011-02-20 08:40:22 +00:00
}
2012-09-29 22:37:34 +00:00
private void SetPauseStatusbarIcon ( )
2011-06-11 12:54:26 +00:00
{
2011-06-19 20:50:46 +00:00
if ( EmulatorPaused )
2012-09-03 20:17:57 +00:00
{
2011-07-09 18:39:48 +00:00
PauseStrip . Image = BizHawk . MultiClient . Properties . Resources . Pause ;
2012-09-29 22:37:34 +00:00
PauseStrip . Visible = true ;
PauseStrip . ToolTipText = "Emulator Paused" ;
2012-09-03 20:17:57 +00:00
}
2011-06-19 20:50:46 +00:00
else
2012-09-03 20:17:57 +00:00
{
2011-07-09 18:39:48 +00:00
PauseStrip . Image = BizHawk . MultiClient . Properties . Resources . Blank ;
2012-09-29 22:37:34 +00:00
PauseStrip . Visible = false ;
PauseStrip . ToolTipText = "" ;
2012-09-03 20:17:57 +00:00
}
2012-09-29 22:37:34 +00:00
}
2011-06-19 20:50:46 +00:00
2012-09-29 22:37:34 +00:00
public void TogglePause ( )
{
EmulatorPaused ^ = true ;
SetPauseStatusbarIcon ( ) ;
2011-06-11 12:54:26 +00:00
}
2011-05-22 18:38:44 +00:00
2011-02-20 08:40:22 +00:00
private void LoadRomFromRecent ( string rom )
{
2011-06-11 12:54:26 +00:00
bool r = LoadRom ( rom ) ;
2011-02-20 08:40:22 +00:00
if ( ! r )
{
Global . Sound . StopSound ( ) ;
DialogResult result = MessageBox . Show ( "Could not open " + rom + "\nRemove from list?" , "File not found" , MessageBoxButtons . YesNo , MessageBoxIcon . Error ) ;
if ( result = = DialogResult . Yes )
2012-09-03 20:17:57 +00:00
{
2011-02-20 08:40:22 +00:00
Global . Config . RecentRoms . Remove ( rom ) ;
2012-09-03 20:17:57 +00:00
}
2011-02-20 08:40:22 +00:00
Global . Sound . StartSound ( ) ;
}
}
2011-06-11 12:54:26 +00:00
private void LoadMoviesFromRecent ( string movie )
{
2012-09-03 19:42:53 +00:00
Movie m = new Movie ( movie ) ;
2011-07-13 01:29:13 +00:00
2011-07-30 23:59:31 +00:00
if ( ! m . Loaded )
2011-06-11 12:54:26 +00:00
{
Global . Sound . StopSound ( ) ;
DialogResult result = MessageBox . Show ( "Could not open " + movie + "\nRemove from list?" , "File not found" , MessageBoxButtons . YesNo , MessageBoxIcon . Error ) ;
if ( result = = DialogResult . Yes )
2012-09-03 20:17:57 +00:00
{
2011-06-11 12:54:26 +00:00
Global . Config . RecentMovies . Remove ( movie ) ;
2012-09-03 20:17:57 +00:00
}
2011-06-11 12:54:26 +00:00
Global . Sound . StartSound ( ) ;
}
2011-07-13 01:29:13 +00:00
else
{
ReadOnly = true ;
StartNewMovie ( m , false ) ;
}
2011-06-11 12:54:26 +00:00
}
2011-05-19 18:50:09 +00:00
2011-02-20 08:40:22 +00:00
public static ControllerDefinition ClientControlsDef = new ControllerDefinition
{
Name = "Emulator Frontend Controls" ,
2012-02-24 07:48:06 +00:00
BoolButtons = { "Fast Forward" , "Rewind" , "Hard Reset" , "Mode Flip" , "Quick Save State" , "Quick Load State" , "Save Named State" , "Load Named State" ,
2012-08-28 01:29:07 +00:00
"Emulator Pause" , "Frame Advance" , "Unthrottle" , "MaxTurbo" , "Screenshot" , "Toggle Fullscreen" , "SelectSlot0" , "SelectSlot1" , "SelectSlot2" , "SelectSlot3" , "SelectSlot4" ,
2011-06-30 02:22:12 +00:00
"SelectSlot5" , "SelectSlot6" , "SelectSlot7" , "SelectSlot8" , "SelectSlot9" , "SaveSlot0" , "SaveSlot1" , "SaveSlot2" , "SaveSlot3" , "SaveSlot4" ,
"SaveSlot5" , "SaveSlot6" , "SaveSlot7" , "SaveSlot8" , "SaveSlot9" , "LoadSlot0" , "LoadSlot1" , "LoadSlot2" , "LoadSlot3" , "LoadSlot4" , "LoadSlot5" , "LoadSlot6" ,
2012-02-24 07:48:06 +00:00
"LoadSlot7" , "LoadSlot8" , "LoadSlot9" , "ToolBox" , "Previous Slot" , "Next Slot" , "Ram Watch" , "Ram Search" , "Ram Poke" , "Hex Editor" ,
2011-06-30 02:22:12 +00:00
"Lua Console" , "Cheats" , "Open ROM" , "Close ROM" , "Display FPS" , "Display FrameCounter" , "Display LagCounter" , "Display Input" , "Toggle Read Only" ,
"Play Movie" , "Record Movie" , "Stop Movie" , "Play Beginning" , "Volume Up" , "Volume Down" , "Toggle MultiTrack" , "Record All" , "Record None" , "Increment Player" ,
2012-09-15 13:11:29 +00:00
"Soft Reset" , "Decrement Player" , "Record AVI/WAV" , "Stop AVI/WAV" , "Toggle Menu" , "Increase Speed" , "Decrease Speed" , "Toggle Background Input" ,
2012-09-15 16:43:16 +00:00
"Autohold" , "Clear Autohold" , "SNES Toggle BG 1" , "SNES Toggle BG 2" , "SNES Toggle BG 3" , "SNES Toggle BG 4" , "SNES Toggle OBJ 1" , "SNES Toggle OBJ 2" , "SNES Toggle OBJ 3" ,
2013-03-09 23:37:37 +00:00
"SNES Toggle OBJ 4" , "Reboot Core" , "Save Movie" , "Virtual Pad" , "AutoholdAutofire" , "MoviePokeToggle" , "ClearFrame" }
2011-02-20 08:40:22 +00:00
} ;
private void InitControls ( )
{
var controls = new Controller ( ClientControlsDef ) ;
2012-09-15 16:43:16 +00:00
controls . BindMulti ( "SNES Toggle BG 1" , Global . Config . ToggleSNESBG1Binding ) ;
controls . BindMulti ( "SNES Toggle BG 2" , Global . Config . ToggleSNESBG2Binding ) ;
controls . BindMulti ( "SNES Toggle BG 3" , Global . Config . ToggleSNESBG3Binding ) ;
controls . BindMulti ( "SNES Toggle BG 4" , Global . Config . ToggleSNESBG4Binding ) ;
controls . BindMulti ( "SNES Toggle OBJ 1" , Global . Config . ToggleSNESOBJ1Binding ) ;
controls . BindMulti ( "SNES Toggle OBJ 2" , Global . Config . ToggleSNESOBJ2Binding ) ;
controls . BindMulti ( "SNES Toggle OBJ 3" , Global . Config . ToggleSNESOBJ3Binding ) ;
controls . BindMulti ( "SNES Toggle OBJ 4" , Global . Config . ToggleSNESOBJ4Binding ) ;
2012-10-28 23:38:41 +00:00
controls . BindMulti ( "Save Movie" , Global . Config . SaveMovieBinding ) ;
2012-03-28 02:32:05 +00:00
controls . BindMulti ( "IncreaseWindowSize" , Global . Config . IncreaseWindowSize ) ;
controls . BindMulti ( "DecreaseWindowSize" , Global . Config . DecreaseWindowSize ) ;
2011-02-20 08:40:22 +00:00
controls . BindMulti ( "Fast Forward" , Global . Config . FastForwardBinding ) ;
controls . BindMulti ( "Rewind" , Global . Config . RewindBinding ) ;
2012-09-16 17:10:33 +00:00
controls . BindMulti ( "Hard Reset" , Global . Config . HardResetBinding ) ;
controls . BindMulti ( "Reboot Core" , Global . Config . RebootCoreResetBinding ) ;
2011-02-20 08:40:22 +00:00
controls . BindMulti ( "Emulator Pause" , Global . Config . EmulatorPauseBinding ) ;
controls . BindMulti ( "Frame Advance" , Global . Config . FrameAdvanceBinding ) ;
2012-07-12 21:39:11 +00:00
controls . BindMulti ( "Increase Speed" , Global . Config . IncreaseSpeedBinding ) ;
controls . BindMulti ( "Decrease Speed" , Global . Config . DecreaseSpeedBinding ) ;
2012-07-12 21:56:59 +00:00
controls . BindMulti ( "Toggle Background Input" , Global . Config . ToggleBackgroundInput ) ;
2011-07-05 02:36:46 +00:00
controls . BindMulti ( "Unthrottle" , Global . Config . TurboBinding ) ;
2012-08-28 01:29:07 +00:00
controls . BindMulti ( "MaxTurbo" , Global . Config . MaxTurboBinding ) ;
2011-02-20 08:40:22 +00:00
controls . BindMulti ( "Screenshot" , Global . Config . ScreenshotBinding ) ;
controls . BindMulti ( "Toggle Fullscreen" , Global . Config . ToggleFullscreenBinding ) ;
controls . BindMulti ( "Quick Save State" , Global . Config . QuickSave ) ;
controls . BindMulti ( "Quick Load State" , Global . Config . QuickLoad ) ;
controls . BindMulti ( "SelectSlot0" , Global . Config . SelectSlot0 ) ;
controls . BindMulti ( "SelectSlot1" , Global . Config . SelectSlot1 ) ;
controls . BindMulti ( "SelectSlot2" , Global . Config . SelectSlot2 ) ;
controls . BindMulti ( "SelectSlot3" , Global . Config . SelectSlot3 ) ;
controls . BindMulti ( "SelectSlot4" , Global . Config . SelectSlot4 ) ;
controls . BindMulti ( "SelectSlot5" , Global . Config . SelectSlot5 ) ;
controls . BindMulti ( "SelectSlot6" , Global . Config . SelectSlot6 ) ;
controls . BindMulti ( "SelectSlot7" , Global . Config . SelectSlot7 ) ;
controls . BindMulti ( "SelectSlot8" , Global . Config . SelectSlot8 ) ;
controls . BindMulti ( "SelectSlot9" , Global . Config . SelectSlot9 ) ;
controls . BindMulti ( "SaveSlot0" , Global . Config . SaveSlot0 ) ;
controls . BindMulti ( "SaveSlot1" , Global . Config . SaveSlot1 ) ;
controls . BindMulti ( "SaveSlot2" , Global . Config . SaveSlot2 ) ;
controls . BindMulti ( "SaveSlot3" , Global . Config . SaveSlot3 ) ;
controls . BindMulti ( "SaveSlot4" , Global . Config . SaveSlot4 ) ;
controls . BindMulti ( "SaveSlot5" , Global . Config . SaveSlot5 ) ;
controls . BindMulti ( "SaveSlot6" , Global . Config . SaveSlot6 ) ;
controls . BindMulti ( "SaveSlot7" , Global . Config . SaveSlot7 ) ;
controls . BindMulti ( "SaveSlot8" , Global . Config . SaveSlot8 ) ;
controls . BindMulti ( "SaveSlot9" , Global . Config . SaveSlot9 ) ;
controls . BindMulti ( "LoadSlot0" , Global . Config . LoadSlot0 ) ;
controls . BindMulti ( "LoadSlot1" , Global . Config . LoadSlot1 ) ;
controls . BindMulti ( "LoadSlot2" , Global . Config . LoadSlot2 ) ;
controls . BindMulti ( "LoadSlot3" , Global . Config . LoadSlot3 ) ;
controls . BindMulti ( "LoadSlot4" , Global . Config . LoadSlot4 ) ;
controls . BindMulti ( "LoadSlot5" , Global . Config . LoadSlot5 ) ;
controls . BindMulti ( "LoadSlot6" , Global . Config . LoadSlot6 ) ;
controls . BindMulti ( "LoadSlot7" , Global . Config . LoadSlot7 ) ;
controls . BindMulti ( "LoadSlot8" , Global . Config . LoadSlot8 ) ;
controls . BindMulti ( "LoadSlot9" , Global . Config . LoadSlot9 ) ;
2011-06-11 12:54:26 +00:00
controls . BindMulti ( "ToolBox" , Global . Config . ToolBox ) ;
controls . BindMulti ( "Save Named State" , Global . Config . SaveNamedState ) ;
controls . BindMulti ( "Load Named State" , Global . Config . LoadNamedState ) ;
controls . BindMulti ( "Previous Slot" , Global . Config . PreviousSlot ) ;
controls . BindMulti ( "Next Slot" , Global . Config . NextSlot ) ;
controls . BindMulti ( "Ram Watch" , Global . Config . RamWatch ) ;
2012-04-24 00:11:58 +00:00
controls . BindMulti ( "TASTudio" , Global . Config . TASTudio ) ;
2012-11-23 17:03:10 +00:00
controls . BindMulti ( "Virtual Pad" , Global . Config . OpenVirtualPadBinding ) ;
2011-06-11 12:54:26 +00:00
controls . BindMulti ( "Ram Search" , Global . Config . RamSearch ) ;
controls . BindMulti ( "Ram Poke" , Global . Config . RamPoke ) ;
controls . BindMulti ( "Hex Editor" , Global . Config . HexEditor ) ;
controls . BindMulti ( "Lua Console" , Global . Config . LuaConsole ) ;
controls . BindMulti ( "Cheats" , Global . Config . Cheats ) ;
controls . BindMulti ( "Open ROM" , Global . Config . OpenROM ) ;
controls . BindMulti ( "Close ROM" , Global . Config . CloseROM ) ;
controls . BindMulti ( "Display FPS" , Global . Config . FPSBinding ) ;
controls . BindMulti ( "Display FrameCounter" , Global . Config . FrameCounterBinding ) ;
controls . BindMulti ( "Display LagCounter" , Global . Config . LagCounterBinding ) ;
controls . BindMulti ( "Display Input" , Global . Config . InputDisplayBinding ) ;
controls . BindMulti ( "Toggle Read Only" , Global . Config . ReadOnlyToggleBinding ) ;
controls . BindMulti ( "Play Movie" , Global . Config . PlayMovieBinding ) ;
controls . BindMulti ( "Record Movie" , Global . Config . RecordMovieBinding ) ;
controls . BindMulti ( "Stop Movie" , Global . Config . StopMovieBinding ) ;
controls . BindMulti ( "Play Beginning" , Global . Config . PlayBeginningBinding ) ;
controls . BindMulti ( "Volume Up" , Global . Config . VolUpBinding ) ;
controls . BindMulti ( "Volume Down" , Global . Config . VolDownBinding ) ;
2011-06-30 02:22:12 +00:00
controls . BindMulti ( "Toggle MultiTrack" , Global . Config . ToggleMultiTrack ) ;
controls . BindMulti ( "Record All" , Global . Config . MTRecordAll ) ;
controls . BindMulti ( "Record None" , Global . Config . MTRecordNone ) ;
controls . BindMulti ( "Increment Player" , Global . Config . MTIncrementPlayer ) ;
controls . BindMulti ( "Decrement Player" , Global . Config . MTDecrementPlayer ) ;
controls . BindMulti ( "Soft Reset" , Global . Config . SoftResetBinding ) ;
2012-09-09 19:52:08 +00:00
controls . BindMulti ( "Record AVI/WAV" , Global . Config . AVIRecordBinding ) ;
controls . BindMulti ( "Stop AVI/WAV" , Global . Config . AVIStopBinding ) ;
2011-10-01 03:43:37 +00:00
controls . BindMulti ( "Toggle Menu" , Global . Config . ToggleMenuBinding ) ;
2012-09-15 13:11:29 +00:00
controls . BindMulti ( "Autohold" , Global . Config . AutoholdBinding ) ;
2013-03-09 20:10:04 +00:00
controls . BindMulti ( "AutoholdAutofire" , Global . Config . AutoholdAutofireBinding ) ;
2012-09-15 13:11:29 +00:00
controls . BindMulti ( "Clear Autohold" , Global . Config . AutoholdClear ) ;
2013-03-09 23:11:00 +00:00
controls . BindMulti ( "MoviePokeToggle" , Global . Config . MoviePlaybackPokeModeBinding ) ;
2013-03-09 23:37:37 +00:00
controls . BindMulti ( "ClearFrame" , Global . Config . ClearFrameBinding ) ;
2011-04-11 01:30:11 +00:00
2011-02-20 08:40:22 +00:00
Global . ClientControls = controls ;
2011-06-11 12:54:26 +00:00
Global . NullControls = new Controller ( NullEmulator . NullController ) ;
2011-08-10 04:31:07 +00:00
Global . AutofireNullControls = new AutofireController ( NullEmulator . NullController ) ;
2011-05-08 13:43:53 +00:00
2011-02-20 08:40:22 +00:00
var smsControls = new Controller ( SMS . SmsController ) ;
2012-11-08 03:16:41 +00:00
smsControls . BindMulti ( "Reset" , Global . Config . SMSConsoleButtons . Reset ) ;
smsControls . BindMulti ( "Pause" , Global . Config . SMSConsoleButtons . Pause ) ;
2011-02-20 08:40:22 +00:00
for ( int i = 0 ; i < 2 ; i + + )
{
smsControls . BindMulti ( string . Format ( "P{0} Up" , i + 1 ) , Global . Config . SMSController [ i ] . Up ) ;
smsControls . BindMulti ( string . Format ( "P{0} Left" , i + 1 ) , Global . Config . SMSController [ i ] . Left ) ;
smsControls . BindMulti ( string . Format ( "P{0} Right" , i + 1 ) , Global . Config . SMSController [ i ] . Right ) ;
smsControls . BindMulti ( string . Format ( "P{0} Down" , i + 1 ) , Global . Config . SMSController [ i ] . Down ) ;
smsControls . BindMulti ( string . Format ( "P{0} B1" , i + 1 ) , Global . Config . SMSController [ i ] . B1 ) ;
smsControls . BindMulti ( string . Format ( "P{0} B2" , i + 1 ) , Global . Config . SMSController [ i ] . B2 ) ;
}
Global . SMSControls = smsControls ;
2011-08-09 22:13:57 +00:00
var asmsControls = new AutofireController ( SMS . SmsController ) ;
2011-08-09 02:16:46 +00:00
asmsControls . Autofire = true ;
2012-11-08 03:16:41 +00:00
asmsControls . BindMulti ( "Reset" , Global . Config . SMSConsoleButtons . Reset ) ;
asmsControls . BindMulti ( "Pause" , Global . Config . SMSConsoleButtons . Pause ) ;
2011-08-09 02:16:46 +00:00
for ( int i = 0 ; i < 2 ; i + + )
{
asmsControls . BindMulti ( string . Format ( "P{0} Up" , i + 1 ) , Global . Config . SMSAutoController [ i ] . Up ) ;
asmsControls . BindMulti ( string . Format ( "P{0} Left" , i + 1 ) , Global . Config . SMSAutoController [ i ] . Left ) ;
asmsControls . BindMulti ( string . Format ( "P{0} Right" , i + 1 ) , Global . Config . SMSAutoController [ i ] . Right ) ;
asmsControls . BindMulti ( string . Format ( "P{0} Down" , i + 1 ) , Global . Config . SMSAutoController [ i ] . Down ) ;
asmsControls . BindMulti ( string . Format ( "P{0} B1" , i + 1 ) , Global . Config . SMSAutoController [ i ] . B1 ) ;
asmsControls . BindMulti ( string . Format ( "P{0} B2" , i + 1 ) , Global . Config . SMSAutoController [ i ] . B2 ) ;
}
Global . AutofireSMSControls = asmsControls ;
2011-02-20 08:40:22 +00:00
var pceControls = new Controller ( PCEngine . PCEngineController ) ;
2011-03-14 06:12:40 +00:00
for ( int i = 0 ; i < 5 ; i + + )
2011-02-20 08:40:22 +00:00
{
2011-06-11 12:54:26 +00:00
pceControls . BindMulti ( "P" + ( i + 1 ) + " Up" , Global . Config . PCEController [ i ] . Up ) ;
pceControls . BindMulti ( "P" + ( i + 1 ) + " Down" , Global . Config . PCEController [ i ] . Down ) ;
pceControls . BindMulti ( "P" + ( i + 1 ) + " Left" , Global . Config . PCEController [ i ] . Left ) ;
pceControls . BindMulti ( "P" + ( i + 1 ) + " Right" , Global . Config . PCEController [ i ] . Right ) ;
pceControls . BindMulti ( "P" + ( i + 1 ) + " B2" , Global . Config . PCEController [ i ] . II ) ;
pceControls . BindMulti ( "P" + ( i + 1 ) + " B1" , Global . Config . PCEController [ i ] . I ) ;
pceControls . BindMulti ( "P" + ( i + 1 ) + " Select" , Global . Config . PCEController [ i ] . Select ) ;
pceControls . BindMulti ( "P" + ( i + 1 ) + " Run" , Global . Config . PCEController [ i ] . Run ) ;
2011-02-20 08:40:22 +00:00
}
Global . PCEControls = pceControls ;
2011-08-09 22:13:57 +00:00
var apceControls = new AutofireController ( PCEngine . PCEngineController ) ;
2011-08-09 02:40:22 +00:00
apceControls . Autofire = true ;
for ( int i = 0 ; i < 5 ; i + + )
{
apceControls . BindMulti ( "P" + ( i + 1 ) + " Up" , Global . Config . PCEAutoController [ i ] . Up ) ;
apceControls . BindMulti ( "P" + ( i + 1 ) + " Down" , Global . Config . PCEAutoController [ i ] . Down ) ;
apceControls . BindMulti ( "P" + ( i + 1 ) + " Left" , Global . Config . PCEAutoController [ i ] . Left ) ;
apceControls . BindMulti ( "P" + ( i + 1 ) + " Right" , Global . Config . PCEAutoController [ i ] . Right ) ;
apceControls . BindMulti ( "P" + ( i + 1 ) + " B2" , Global . Config . PCEAutoController [ i ] . II ) ;
apceControls . BindMulti ( "P" + ( i + 1 ) + " B1" , Global . Config . PCEAutoController [ i ] . I ) ;
apceControls . BindMulti ( "P" + ( i + 1 ) + " Select" , Global . Config . PCEAutoController [ i ] . Select ) ;
apceControls . BindMulti ( "P" + ( i + 1 ) + " Run" , Global . Config . PCEAutoController [ i ] . Run ) ;
}
Global . AutofirePCEControls = apceControls ;
2012-09-04 00:20:36 +00:00
var snesControls = new Controller ( LibsnesCore . SNESController ) ;
2012-09-26 01:20:11 +00:00
for ( int i = 0 ; i < 4 ; i + + )
2012-09-04 00:20:36 +00:00
{
snesControls . BindMulti ( "P" + ( i + 1 ) + " Up" , Global . Config . SNESController [ i ] . Up ) ;
snesControls . BindMulti ( "P" + ( i + 1 ) + " Down" , Global . Config . SNESController [ i ] . Down ) ;
snesControls . BindMulti ( "P" + ( i + 1 ) + " Left" , Global . Config . SNESController [ i ] . Left ) ;
snesControls . BindMulti ( "P" + ( i + 1 ) + " Right" , Global . Config . SNESController [ i ] . Right ) ;
snesControls . BindMulti ( "P" + ( i + 1 ) + " A" , Global . Config . SNESController [ i ] . A ) ;
snesControls . BindMulti ( "P" + ( i + 1 ) + " B" , Global . Config . SNESController [ i ] . B ) ;
snesControls . BindMulti ( "P" + ( i + 1 ) + " X" , Global . Config . SNESController [ i ] . X ) ;
snesControls . BindMulti ( "P" + ( i + 1 ) + " Y" , Global . Config . SNESController [ i ] . Y ) ;
snesControls . BindMulti ( "P" + ( i + 1 ) + " L" , Global . Config . SNESController [ i ] . L ) ;
snesControls . BindMulti ( "P" + ( i + 1 ) + " R" , Global . Config . SNESController [ i ] . R ) ;
2012-09-16 16:23:10 +00:00
snesControls . BindMulti ( "P" + ( i + 1 ) + " Select" , Global . Config . SNESController [ i ] . Select ) ;
snesControls . BindMulti ( "P" + ( i + 1 ) + " Start" , Global . Config . SNESController [ i ] . Start ) ;
2012-09-04 00:20:36 +00:00
}
2012-11-08 04:13:55 +00:00
snesControls . BindMulti ( "Reset" , Global . Config . SNESConsoleButtons . Reset ) ;
snesControls . BindMulti ( "Power" , Global . Config . SNESConsoleButtons . Power ) ;
2012-09-04 00:20:36 +00:00
Global . SNESControls = snesControls ;
2011-07-13 02:11:20 +00:00
2012-09-26 01:20:11 +00:00
var asnesControls = new AutofireController ( LibsnesCore . SNESController ) ;
asnesControls . Autofire = true ;
for ( int i = 0 ; i < 4 ; i + + )
{
asnesControls . BindMulti ( "P" + ( i + 1 ) + " Up" , Global . Config . SNESAutoController [ i ] . Up ) ;
asnesControls . BindMulti ( "P" + ( i + 1 ) + " Down" , Global . Config . SNESAutoController [ i ] . Down ) ;
asnesControls . BindMulti ( "P" + ( i + 1 ) + " Left" , Global . Config . SNESAutoController [ i ] . Left ) ;
asnesControls . BindMulti ( "P" + ( i + 1 ) + " Right" , Global . Config . SNESAutoController [ i ] . Right ) ;
asnesControls . BindMulti ( "P" + ( i + 1 ) + " A" , Global . Config . SNESAutoController [ i ] . A ) ;
asnesControls . BindMulti ( "P" + ( i + 1 ) + " B" , Global . Config . SNESAutoController [ i ] . B ) ;
asnesControls . BindMulti ( "P" + ( i + 1 ) + " X" , Global . Config . SNESAutoController [ i ] . X ) ;
asnesControls . BindMulti ( "P" + ( i + 1 ) + " Y" , Global . Config . SNESAutoController [ i ] . Y ) ;
asnesControls . BindMulti ( "P" + ( i + 1 ) + " L" , Global . Config . SNESAutoController [ i ] . L ) ;
asnesControls . BindMulti ( "P" + ( i + 1 ) + " R" , Global . Config . SNESAutoController [ i ] . R ) ;
asnesControls . BindMulti ( "P" + ( i + 1 ) + " Select" , Global . Config . SNESAutoController [ i ] . Select ) ;
asnesControls . BindMulti ( "P" + ( i + 1 ) + " Start" , Global . Config . SNESAutoController [ i ] . Start ) ;
}
Global . AutofireSNESControls = asnesControls ;
var nesControls = new Controller ( NES . NESController ) ;
2011-06-19 00:18:02 +00:00
for ( int i = 0 ; i < 2 /*TODO*/ ; i + + )
2011-06-11 12:54:26 +00:00
{
2011-06-19 00:18:02 +00:00
nesControls . BindMulti ( "P" + ( i + 1 ) + " Up" , Global . Config . NESController [ i ] . Up ) ;
nesControls . BindMulti ( "P" + ( i + 1 ) + " Down" , Global . Config . NESController [ i ] . Down ) ;
nesControls . BindMulti ( "P" + ( i + 1 ) + " Left" , Global . Config . NESController [ i ] . Left ) ;
nesControls . BindMulti ( "P" + ( i + 1 ) + " Right" , Global . Config . NESController [ i ] . Right ) ;
nesControls . BindMulti ( "P" + ( i + 1 ) + " A" , Global . Config . NESController [ i ] . A ) ;
nesControls . BindMulti ( "P" + ( i + 1 ) + " B" , Global . Config . NESController [ i ] . B ) ;
nesControls . BindMulti ( "P" + ( i + 1 ) + " Select" , Global . Config . NESController [ i ] . Select ) ;
nesControls . BindMulti ( "P" + ( i + 1 ) + " Start" , Global . Config . NESController [ i ] . Start ) ;
2011-06-11 12:54:26 +00:00
}
2012-11-06 03:27:24 +00:00
2012-11-08 03:16:41 +00:00
nesControls . BindMulti ( "Reset" , Global . Config . NESConsoleButtons . Reset ) ;
nesControls . BindMulti ( "Power" , Global . Config . NESConsoleButtons . Power ) ;
2012-11-09 02:47:50 +00:00
//nesControls.BindMulti("FDS Eject", Global.Config.NESConsoleButtons.FDS_Eject);
//nesControls.BindMulti("VS Coin 1", Global.Config.NESConsoleButtons.VS_Coin_1);
//nesControls.BindMulti("VS Coin 2", Global.Config.NESConsoleButtons.VS_Coin_2);
2012-11-06 03:27:24 +00:00
2011-06-11 12:54:26 +00:00
Global . NESControls = nesControls ;
2011-03-01 13:25:23 +00:00
2011-08-09 22:13:57 +00:00
var anesControls = new AutofireController ( NES . NESController ) ;
2011-08-09 00:51:46 +00:00
anesControls . Autofire = true ;
2011-08-09 01:38:51 +00:00
for ( int i = 0 ; i < 2 /*TODO*/ ; i + + )
2011-08-09 00:51:46 +00:00
{
2011-08-09 01:38:51 +00:00
anesControls . BindMulti ( "P" + ( i + 1 ) + " Up" , Global . Config . NESAutoController [ i ] . Up ) ;
anesControls . BindMulti ( "P" + ( i + 1 ) + " Down" , Global . Config . NESAutoController [ i ] . Down ) ;
anesControls . BindMulti ( "P" + ( i + 1 ) + " Left" , Global . Config . NESAutoController [ i ] . Left ) ;
anesControls . BindMulti ( "P" + ( i + 1 ) + " Right" , Global . Config . NESAutoController [ i ] . Right ) ;
anesControls . BindMulti ( "P" + ( i + 1 ) + " A" , Global . Config . NESAutoController [ i ] . A ) ;
anesControls . BindMulti ( "P" + ( i + 1 ) + " B" , Global . Config . NESAutoController [ i ] . B ) ;
anesControls . BindMulti ( "P" + ( i + 1 ) + " Select" , Global . Config . NESAutoController [ i ] . Select ) ;
anesControls . BindMulti ( "P" + ( i + 1 ) + " Start" , Global . Config . NESAutoController [ i ] . Start ) ;
2011-08-09 00:51:46 +00:00
}
2011-08-09 02:16:46 +00:00
Global . AutofireNESControls = anesControls ;
2011-08-09 00:51:46 +00:00
2012-10-13 21:10:20 +00:00
var gbControls = new Controller ( Gameboy . GbController ) ;
gbControls . BindMulti ( "Up" , Global . Config . GBController [ 0 ] . Up ) ;
gbControls . BindMulti ( "Down" , Global . Config . GBController [ 0 ] . Down ) ;
gbControls . BindMulti ( "Left" , Global . Config . GBController [ 0 ] . Left ) ;
gbControls . BindMulti ( "Right" , Global . Config . GBController [ 0 ] . Right ) ;
gbControls . BindMulti ( "A" , Global . Config . GBController [ 0 ] . A ) ;
gbControls . BindMulti ( "B" , Global . Config . GBController [ 0 ] . B ) ;
gbControls . BindMulti ( "Select" , Global . Config . GBController [ 0 ] . Select ) ;
gbControls . BindMulti ( "Start" , Global . Config . GBController [ 0 ] . Start ) ;
2012-11-08 04:43:07 +00:00
gbControls . BindMulti ( "Power" , Global . Config . GBController [ 0 ] . Power ) ;
2012-10-13 21:10:20 +00:00
Global . GBControls = gbControls ;
var agbControls = new AutofireController ( Gameboy . GbController ) ;
agbControls . Autofire = true ;
agbControls . BindMulti ( "Up" , Global . Config . GBAutoController [ 0 ] . Up ) ;
agbControls . BindMulti ( "Down" , Global . Config . GBAutoController [ 0 ] . Down ) ;
agbControls . BindMulti ( "Left" , Global . Config . GBAutoController [ 0 ] . Left ) ;
agbControls . BindMulti ( "Right" , Global . Config . GBAutoController [ 0 ] . Right ) ;
agbControls . BindMulti ( "A" , Global . Config . GBAutoController [ 0 ] . A ) ;
agbControls . BindMulti ( "B" , Global . Config . GBAutoController [ 0 ] . B ) ;
agbControls . BindMulti ( "Select" , Global . Config . GBAutoController [ 0 ] . Select ) ;
agbControls . BindMulti ( "Start" , Global . Config . GBAutoController [ 0 ] . Start ) ;
Global . AutofireGBControls = agbControls ;
2011-08-09 02:40:22 +00:00
2012-12-29 02:30:31 +00:00
var dualgbControls = new Controller ( Gameboy . GbController ) ;
dualgbControls . BindMulti ( "P1 Up" , Global . Config . DualGBController [ 0 ] . P1_Up ) ;
dualgbControls . BindMulti ( "P1 Down" , Global . Config . DualGBController [ 0 ] . P1_Down ) ;
dualgbControls . BindMulti ( "P1 Left" , Global . Config . DualGBController [ 0 ] . P1_Left ) ;
dualgbControls . BindMulti ( "P1 Right" , Global . Config . DualGBController [ 0 ] . P1_Right ) ;
dualgbControls . BindMulti ( "P1 A" , Global . Config . DualGBController [ 0 ] . P1_A ) ;
dualgbControls . BindMulti ( "P1 B" , Global . Config . DualGBController [ 0 ] . P1_B ) ;
dualgbControls . BindMulti ( "P1 Select" , Global . Config . DualGBController [ 0 ] . P1_Select ) ;
dualgbControls . BindMulti ( "P1 Start" , Global . Config . DualGBController [ 0 ] . P1_Start ) ;
dualgbControls . BindMulti ( "P1 Power" , Global . Config . DualGBController [ 0 ] . P1_Power ) ;
dualgbControls . BindMulti ( "P2 Up" , Global . Config . DualGBController [ 0 ] . P2_Up ) ;
dualgbControls . BindMulti ( "P2 Down" , Global . Config . DualGBController [ 0 ] . P2_Down ) ;
dualgbControls . BindMulti ( "P2 Left" , Global . Config . DualGBController [ 0 ] . P2_Left ) ;
dualgbControls . BindMulti ( "P2 Right" , Global . Config . DualGBController [ 0 ] . P2_Right ) ;
dualgbControls . BindMulti ( "P2 A" , Global . Config . DualGBController [ 0 ] . P2_A ) ;
dualgbControls . BindMulti ( "P2 B" , Global . Config . DualGBController [ 0 ] . P2_B ) ;
dualgbControls . BindMulti ( "P2 Select" , Global . Config . DualGBController [ 0 ] . P2_Select ) ;
dualgbControls . BindMulti ( "P2 Start" , Global . Config . DualGBController [ 0 ] . P2_Start ) ;
dualgbControls . BindMulti ( "P2 Power" , Global . Config . DualGBController [ 0 ] . P2_Power ) ;
Global . DualGBControls = dualgbControls ;
var adualgbControls = new AutofireController ( Gameboy . GbController ) ;
adualgbControls . Autofire = true ;
adualgbControls . BindMulti ( "P1 Up" , Global . Config . AutoDualGBController [ 0 ] . P1_Up ) ;
adualgbControls . BindMulti ( "P1 Down" , Global . Config . AutoDualGBController [ 0 ] . P1_Down ) ;
adualgbControls . BindMulti ( "P1 Left" , Global . Config . AutoDualGBController [ 0 ] . P1_Left ) ;
adualgbControls . BindMulti ( "P1 Right" , Global . Config . AutoDualGBController [ 0 ] . P1_Right ) ;
adualgbControls . BindMulti ( "P1 A" , Global . Config . AutoDualGBController [ 0 ] . P1_A ) ;
adualgbControls . BindMulti ( "P1 B" , Global . Config . AutoDualGBController [ 0 ] . P1_B ) ;
adualgbControls . BindMulti ( "P1 Select" , Global . Config . AutoDualGBController [ 0 ] . P1_Select ) ;
adualgbControls . BindMulti ( "P1 Start" , Global . Config . AutoDualGBController [ 0 ] . P1_Start ) ;
adualgbControls . BindMulti ( "P2 Up" , Global . Config . AutoDualGBController [ 0 ] . P2_Up ) ;
adualgbControls . BindMulti ( "P2 Down" , Global . Config . AutoDualGBController [ 0 ] . P2_Down ) ;
adualgbControls . BindMulti ( "P2 Left" , Global . Config . AutoDualGBController [ 0 ] . P2_Left ) ;
adualgbControls . BindMulti ( "P2 Right" , Global . Config . AutoDualGBController [ 0 ] . P2_Right ) ;
adualgbControls . BindMulti ( "P2 A" , Global . Config . AutoDualGBController [ 0 ] . P2_A ) ;
adualgbControls . BindMulti ( "P2 B" , Global . Config . AutoDualGBController [ 0 ] . P2_B ) ;
adualgbControls . BindMulti ( "P2 Select" , Global . Config . AutoDualGBController [ 0 ] . P2_Select ) ;
adualgbControls . BindMulti ( "P2 Start" , Global . Config . AutoDualGBController [ 0 ] . P2_Start ) ;
Global . DualAutofireGBControls = adualgbControls ;
2012-11-24 16:14:30 +00:00
var gbaControls = new Controller ( GBA . GBAController ) ;
gbaControls . BindMulti ( "Up" , Global . Config . GBAController [ 0 ] . Up ) ;
gbaControls . BindMulti ( "Down" , Global . Config . GBAController [ 0 ] . Down ) ;
gbaControls . BindMulti ( "Left" , Global . Config . GBAController [ 0 ] . Left ) ;
gbaControls . BindMulti ( "Right" , Global . Config . GBAController [ 0 ] . Right ) ;
gbaControls . BindMulti ( "A" , Global . Config . GBAController [ 0 ] . A ) ;
gbaControls . BindMulti ( "B" , Global . Config . GBAController [ 0 ] . B ) ;
gbaControls . BindMulti ( "Select" , Global . Config . GBAController [ 0 ] . Select ) ;
gbaControls . BindMulti ( "Start" , Global . Config . GBAController [ 0 ] . Start ) ;
gbaControls . BindMulti ( "L" , Global . Config . GBAController [ 0 ] . L ) ;
gbaControls . BindMulti ( "R" , Global . Config . GBAController [ 0 ] . R ) ;
gbaControls . BindMulti ( "Power" , Global . Config . GBAController [ 0 ] . Power ) ;
Global . GBAControls = gbaControls ;
var agbaControls = new AutofireController ( GBA . GBAController ) ;
agbaControls . BindMulti ( "Up" , Global . Config . GBAAutoController [ 0 ] . Up ) ;
agbaControls . BindMulti ( "Down" , Global . Config . GBAAutoController [ 0 ] . Down ) ;
agbaControls . BindMulti ( "Left" , Global . Config . GBAAutoController [ 0 ] . Left ) ;
agbaControls . BindMulti ( "Right" , Global . Config . GBAAutoController [ 0 ] . Right ) ;
agbaControls . BindMulti ( "A" , Global . Config . GBAAutoController [ 0 ] . A ) ;
agbaControls . BindMulti ( "B" , Global . Config . GBAAutoController [ 0 ] . B ) ;
agbaControls . BindMulti ( "Select" , Global . Config . GBAAutoController [ 0 ] . Select ) ;
agbaControls . BindMulti ( "Start" , Global . Config . GBAAutoController [ 0 ] . Start ) ;
agbaControls . BindMulti ( "L" , Global . Config . GBAAutoController [ 0 ] . L ) ;
agbaControls . BindMulti ( "R" , Global . Config . GBAAutoController [ 0 ] . R ) ;
agbaControls . BindMulti ( "Power" , Global . Config . GBAAutoController [ 0 ] . Power ) ;
Global . AutofireGBAControls = agbaControls ;
2011-02-20 08:40:22 +00:00
var genControls = new Controller ( Genesis . GenesisController ) ;
2011-12-24 01:59:51 +00:00
genControls . BindMulti ( "P1 Up" , Global . Config . GenesisController [ 0 ] . Up ) ;
genControls . BindMulti ( "P1 Left" , Global . Config . GenesisController [ 0 ] . Left ) ;
genControls . BindMulti ( "P1 Right" , Global . Config . GenesisController [ 0 ] . Right ) ;
genControls . BindMulti ( "P1 Down" , Global . Config . GenesisController [ 0 ] . Down ) ;
genControls . BindMulti ( "P1 A" , Global . Config . GenesisController [ 0 ] . A ) ;
genControls . BindMulti ( "P1 B" , Global . Config . GenesisController [ 0 ] . B ) ;
genControls . BindMulti ( "P1 C" , Global . Config . GenesisController [ 0 ] . C ) ;
genControls . BindMulti ( "P1 Start" , Global . Config . GenesisController [ 0 ] . Start ) ;
2012-11-08 04:33:18 +00:00
genControls . BindMulti ( "Reset" , Global . Config . GenesisConsoleButtons . Reset ) ;
2011-02-20 08:40:22 +00:00
Global . GenControls = genControls ;
2011-01-18 10:28:10 +00:00
2012-05-28 01:29:43 +00:00
var agenControls = new AutofireController ( Genesis . GenesisController ) ;
agenControls . BindMulti ( "P1 Up" , Global . Config . GenesisAutoController [ 0 ] . Up ) ;
agenControls . BindMulti ( "P1 Left" , Global . Config . GenesisAutoController [ 0 ] . Left ) ;
agenControls . BindMulti ( "P1 Right" , Global . Config . GenesisAutoController [ 0 ] . Right ) ;
agenControls . BindMulti ( "P1 Down" , Global . Config . GenesisAutoController [ 0 ] . Down ) ;
agenControls . BindMulti ( "P1 A" , Global . Config . GenesisAutoController [ 0 ] . A ) ;
agenControls . BindMulti ( "P1 B" , Global . Config . GenesisAutoController [ 0 ] . B ) ;
agenControls . BindMulti ( "P1 C" , Global . Config . GenesisAutoController [ 0 ] . C ) ;
agenControls . BindMulti ( "P1 Start" , Global . Config . GenesisAutoController [ 0 ] . Start ) ;
Global . AutofireGenControls = agenControls ;
2012-04-14 16:02:45 +00:00
2012-03-07 00:40:20 +00:00
var a2600Controls = new Controller ( Atari2600 . Atari2600ControllerDefinition ) ;
a2600Controls . BindMulti ( "P1 Up" , Global . Config . Atari2600Controller [ 0 ] . Up ) ;
a2600Controls . BindMulti ( "P1 Left" , Global . Config . Atari2600Controller [ 0 ] . Left ) ;
a2600Controls . BindMulti ( "P1 Right" , Global . Config . Atari2600Controller [ 0 ] . Right ) ;
a2600Controls . BindMulti ( "P1 Down" , Global . Config . Atari2600Controller [ 0 ] . Down ) ;
a2600Controls . BindMulti ( "P1 Button" , Global . Config . Atari2600Controller [ 0 ] . Button ) ;
2012-10-15 15:15:44 +00:00
2012-03-22 06:33:28 +00:00
a2600Controls . BindMulti ( "P2 Up" , Global . Config . Atari2600Controller [ 1 ] . Up ) ;
a2600Controls . BindMulti ( "P2 Left" , Global . Config . Atari2600Controller [ 1 ] . Left ) ;
a2600Controls . BindMulti ( "P2 Right" , Global . Config . Atari2600Controller [ 1 ] . Right ) ;
a2600Controls . BindMulti ( "P2 Down" , Global . Config . Atari2600Controller [ 1 ] . Down ) ;
a2600Controls . BindMulti ( "P2 Button" , Global . Config . Atari2600Controller [ 1 ] . Button ) ;
2012-10-15 15:15:44 +00:00
2012-03-30 16:40:52 +00:00
a2600Controls . BindMulti ( "Reset" , Global . Config . Atari2600ConsoleButtons [ 0 ] . Reset ) ;
a2600Controls . BindMulti ( "Select" , Global . Config . Atari2600ConsoleButtons [ 0 ] . Select ) ;
2012-10-15 15:15:44 +00:00
2012-03-07 00:40:20 +00:00
Global . Atari2600Controls = a2600Controls ;
var autofireA2600Controls = new AutofireController ( Atari2600 . Atari2600ControllerDefinition ) ;
2012-03-23 02:15:58 +00:00
autofireA2600Controls . BindMulti ( "P1 Up" , Global . Config . Atari2600AutoController [ 0 ] . Up ) ;
autofireA2600Controls . BindMulti ( "P1 Left" , Global . Config . Atari2600AutoController [ 0 ] . Left ) ;
autofireA2600Controls . BindMulti ( "P1 Right" , Global . Config . Atari2600AutoController [ 0 ] . Right ) ;
autofireA2600Controls . BindMulti ( "P1 Down" , Global . Config . Atari2600AutoController [ 0 ] . Down ) ;
autofireA2600Controls . BindMulti ( "P1 Button" , Global . Config . Atari2600AutoController [ 0 ] . Button ) ;
2012-10-15 15:15:44 +00:00
2012-03-23 02:15:58 +00:00
autofireA2600Controls . BindMulti ( "P2 Up" , Global . Config . Atari2600AutoController [ 1 ] . Up ) ;
autofireA2600Controls . BindMulti ( "P2 Left" , Global . Config . Atari2600AutoController [ 1 ] . Left ) ;
autofireA2600Controls . BindMulti ( "P2 Right" , Global . Config . Atari2600AutoController [ 1 ] . Right ) ;
autofireA2600Controls . BindMulti ( "P2 Down" , Global . Config . Atari2600AutoController [ 1 ] . Down ) ;
2012-10-15 15:15:44 +00:00
autofireA2600Controls . BindMulti ( "P2 Button" , Global . Config . Atari2600AutoController [ 1 ] . Button ) ;
2012-03-07 00:40:20 +00:00
Global . AutofireAtari2600Controls = autofireA2600Controls ;
2012-01-28 21:43:55 +00:00
2012-12-15 02:36:38 +00:00
var a7800Controls = new Controller ( Atari7800Control . ProLineJoystick ) ;
2012-12-16 20:04:39 +00:00
a7800Controls . BindMulti ( "Power" , Global . Config . Atari7800ConsoleButtons [ 0 ] . Power ) ;
a7800Controls . BindMulti ( "Reset" , Global . Config . Atari7800ConsoleButtons [ 0 ] . Reset ) ;
a7800Controls . BindMulti ( "Select" , Global . Config . Atari7800ConsoleButtons [ 0 ] . Select ) ;
a7800Controls . BindMulti ( "Pause" , Global . Config . Atari7800ConsoleButtons [ 0 ] . Pause ) ;
2012-12-14 02:17:47 +00:00
a7800Controls . BindMulti ( "P1 Up" , Global . Config . Atari7800Controller [ 0 ] . Up ) ;
a7800Controls . BindMulti ( "P1 Left" , Global . Config . Atari7800Controller [ 0 ] . Left ) ;
a7800Controls . BindMulti ( "P1 Right" , Global . Config . Atari7800Controller [ 0 ] . Right ) ;
a7800Controls . BindMulti ( "P1 Down" , Global . Config . Atari7800Controller [ 0 ] . Down ) ;
2012-12-15 02:36:38 +00:00
a7800Controls . BindMulti ( "P1 Trigger" , Global . Config . Atari7800Controller [ 0 ] . Button1 ) ;
a7800Controls . BindMulti ( "P1 Trigger 2" , Global . Config . Atari7800Controller [ 0 ] . Button2 ) ;
2012-12-14 02:17:47 +00:00
a7800Controls . BindMulti ( "P2 Up" , Global . Config . Atari7800Controller [ 1 ] . Up ) ;
a7800Controls . BindMulti ( "P2 Left" , Global . Config . Atari7800Controller [ 1 ] . Left ) ;
a7800Controls . BindMulti ( "P2 Right" , Global . Config . Atari7800Controller [ 1 ] . Right ) ;
a7800Controls . BindMulti ( "P2 Down" , Global . Config . Atari7800Controller [ 1 ] . Down ) ;
2012-12-15 02:36:38 +00:00
a7800Controls . BindMulti ( "P2 Trigger" , Global . Config . Atari7800Controller [ 1 ] . Button1 ) ;
a7800Controls . BindMulti ( "P2 Trigger 2" , Global . Config . Atari7800Controller [ 1 ] . Button2 ) ;
2012-12-14 02:17:47 +00:00
Global . Atari7800Controls = a7800Controls ;
2012-12-15 02:36:38 +00:00
var autofireA7800Controls = new AutofireController ( Atari7800Control . ProLineJoystick ) ;
2012-12-14 02:17:47 +00:00
autofireA7800Controls . BindMulti ( "P1 Up" , Global . Config . Atari7800AutoController [ 0 ] . Up ) ;
autofireA7800Controls . BindMulti ( "P1 Left" , Global . Config . Atari7800AutoController [ 0 ] . Left ) ;
autofireA7800Controls . BindMulti ( "P1 Right" , Global . Config . Atari7800AutoController [ 0 ] . Right ) ;
autofireA7800Controls . BindMulti ( "P1 Down" , Global . Config . Atari7800AutoController [ 0 ] . Down ) ;
2012-12-15 02:36:38 +00:00
autofireA7800Controls . BindMulti ( "P1 Trigger" , Global . Config . Atari7800Controller [ 0 ] . Button1 ) ;
autofireA7800Controls . BindMulti ( "P1 Trigger 2" , Global . Config . Atari7800Controller [ 0 ] . Button2 ) ;
2012-12-14 02:17:47 +00:00
autofireA7800Controls . BindMulti ( "P2 Up" , Global . Config . Atari7800AutoController [ 1 ] . Up ) ;
autofireA7800Controls . BindMulti ( "P2 Left" , Global . Config . Atari7800AutoController [ 1 ] . Left ) ;
autofireA7800Controls . BindMulti ( "P2 Right" , Global . Config . Atari7800AutoController [ 1 ] . Right ) ;
autofireA7800Controls . BindMulti ( "P2 Down" , Global . Config . Atari7800AutoController [ 1 ] . Down ) ;
2012-12-15 02:36:38 +00:00
autofireA7800Controls . BindMulti ( "P2 Trigger" , Global . Config . Atari7800Controller [ 1 ] . Button1 ) ;
autofireA7800Controls . BindMulti ( "P2 Trigger 2" , Global . Config . Atari7800Controller [ 1 ] . Button2 ) ;
2012-12-14 02:17:47 +00:00
Global . AutofireAtari7800Controls = autofireA2600Controls ;
2012-05-06 00:54:13 +00:00
var colecoControls = new Controller ( ColecoVision . ColecoVisionControllerDefinition ) ;
2012-11-17 22:38:32 +00:00
colecoControls . BindMulti ( "P1 Up" , Global . Config . ColecoController [ 0 ] . Up ) ;
colecoControls . BindMulti ( "P1 Left" , Global . Config . ColecoController [ 0 ] . Left ) ;
colecoControls . BindMulti ( "P1 Right" , Global . Config . ColecoController [ 0 ] . Right ) ;
colecoControls . BindMulti ( "P1 Down" , Global . Config . ColecoController [ 0 ] . Down ) ;
2012-11-18 02:36:30 +00:00
colecoControls . BindMulti ( "P1 L" , Global . Config . ColecoController [ 0 ] . L ) ;
colecoControls . BindMulti ( "P1 R" , Global . Config . ColecoController [ 0 ] . R ) ;
2012-11-17 22:38:32 +00:00
colecoControls . BindMulti ( "P1 Key0" , Global . Config . ColecoController [ 0 ] . _0 ) ;
colecoControls . BindMulti ( "P1 Key1" , Global . Config . ColecoController [ 0 ] . _1 ) ;
colecoControls . BindMulti ( "P1 Key2" , Global . Config . ColecoController [ 0 ] . _2 ) ;
colecoControls . BindMulti ( "P1 Key3" , Global . Config . ColecoController [ 0 ] . _3 ) ;
colecoControls . BindMulti ( "P1 Key4" , Global . Config . ColecoController [ 0 ] . _4 ) ;
colecoControls . BindMulti ( "P1 Key5" , Global . Config . ColecoController [ 0 ] . _5 ) ;
colecoControls . BindMulti ( "P1 Key6" , Global . Config . ColecoController [ 0 ] . _6 ) ;
colecoControls . BindMulti ( "P1 Key7" , Global . Config . ColecoController [ 0 ] . _7 ) ;
colecoControls . BindMulti ( "P1 Key8" , Global . Config . ColecoController [ 0 ] . _8 ) ;
colecoControls . BindMulti ( "P1 Key9" , Global . Config . ColecoController [ 0 ] . _9 ) ;
colecoControls . BindMulti ( "P1 Star" , Global . Config . ColecoController [ 0 ] . Star ) ;
colecoControls . BindMulti ( "P1 Pound" , Global . Config . ColecoController [ 0 ] . Pound ) ;
colecoControls . BindMulti ( "P2 Up" , Global . Config . ColecoController [ 1 ] . Up ) ;
colecoControls . BindMulti ( "P2 Left" , Global . Config . ColecoController [ 1 ] . Left ) ;
colecoControls . BindMulti ( "P2 Right" , Global . Config . ColecoController [ 1 ] . Right ) ;
colecoControls . BindMulti ( "P2 Down" , Global . Config . ColecoController [ 1 ] . Down ) ;
2012-11-18 02:36:30 +00:00
colecoControls . BindMulti ( "P2 L" , Global . Config . ColecoController [ 1 ] . L ) ;
colecoControls . BindMulti ( "P2 R" , Global . Config . ColecoController [ 1 ] . R ) ;
2012-11-17 22:38:32 +00:00
colecoControls . BindMulti ( "P2 Key0" , Global . Config . ColecoController [ 1 ] . _0 ) ;
colecoControls . BindMulti ( "P2 Key1" , Global . Config . ColecoController [ 1 ] . _1 ) ;
colecoControls . BindMulti ( "P2 Key2" , Global . Config . ColecoController [ 1 ] . _2 ) ;
colecoControls . BindMulti ( "P2 Key3" , Global . Config . ColecoController [ 1 ] . _3 ) ;
colecoControls . BindMulti ( "P2 Key4" , Global . Config . ColecoController [ 1 ] . _4 ) ;
colecoControls . BindMulti ( "P2 Key5" , Global . Config . ColecoController [ 1 ] . _5 ) ;
colecoControls . BindMulti ( "P2 Key6" , Global . Config . ColecoController [ 1 ] . _6 ) ;
colecoControls . BindMulti ( "P2 Key7" , Global . Config . ColecoController [ 1 ] . _7 ) ;
colecoControls . BindMulti ( "P2 Key8" , Global . Config . ColecoController [ 1 ] . _8 ) ;
colecoControls . BindMulti ( "P2 Key9" , Global . Config . ColecoController [ 1 ] . _9 ) ;
colecoControls . BindMulti ( "P2 Star" , Global . Config . ColecoController [ 1 ] . Star ) ;
colecoControls . BindMulti ( "P2 Pound" , Global . Config . ColecoController [ 1 ] . Pound ) ;
2012-05-06 00:54:13 +00:00
Global . ColecoControls = colecoControls ;
2012-11-17 21:57:39 +00:00
var acolecoControls = new AutofireController ( ColecoVision . ColecoVisionControllerDefinition ) ;
2012-11-17 22:38:32 +00:00
acolecoControls . BindMulti ( "P1 Up" , Global . Config . ColecoAutoController [ 0 ] . Up ) ;
acolecoControls . BindMulti ( "P1 Left" , Global . Config . ColecoAutoController [ 0 ] . Left ) ;
acolecoControls . BindMulti ( "P1 Right" , Global . Config . ColecoAutoController [ 0 ] . Right ) ;
acolecoControls . BindMulti ( "P1 Down" , Global . Config . ColecoAutoController [ 0 ] . Down ) ;
2012-11-18 02:36:30 +00:00
acolecoControls . BindMulti ( "P1 L" , Global . Config . ColecoAutoController [ 0 ] . L ) ;
acolecoControls . BindMulti ( "P1 R" , Global . Config . ColecoAutoController [ 0 ] . R ) ;
2012-11-17 22:38:32 +00:00
acolecoControls . BindMulti ( "P1 Key0" , Global . Config . ColecoAutoController [ 0 ] . _0 ) ;
acolecoControls . BindMulti ( "P1 Key1" , Global . Config . ColecoAutoController [ 0 ] . _1 ) ;
acolecoControls . BindMulti ( "P1 Key2" , Global . Config . ColecoAutoController [ 0 ] . _2 ) ;
acolecoControls . BindMulti ( "P1 Key3" , Global . Config . ColecoAutoController [ 0 ] . _3 ) ;
acolecoControls . BindMulti ( "P1 Key4" , Global . Config . ColecoAutoController [ 0 ] . _4 ) ;
acolecoControls . BindMulti ( "P1 Key5" , Global . Config . ColecoAutoController [ 0 ] . _5 ) ;
acolecoControls . BindMulti ( "P1 Key6" , Global . Config . ColecoAutoController [ 0 ] . _6 ) ;
acolecoControls . BindMulti ( "P1 Key7" , Global . Config . ColecoAutoController [ 0 ] . _7 ) ;
acolecoControls . BindMulti ( "P1 Key8" , Global . Config . ColecoAutoController [ 0 ] . _8 ) ;
acolecoControls . BindMulti ( "P1 Key9" , Global . Config . ColecoAutoController [ 0 ] . _9 ) ;
acolecoControls . BindMulti ( "P1 Star" , Global . Config . ColecoAutoController [ 0 ] . Star ) ;
acolecoControls . BindMulti ( "P1 Pound" , Global . Config . ColecoController [ 0 ] . Pound ) ;
acolecoControls . BindMulti ( "P2 Up" , Global . Config . ColecoAutoController [ 1 ] . Up ) ;
acolecoControls . BindMulti ( "P2 Left" , Global . Config . ColecoAutoController [ 1 ] . Left ) ;
acolecoControls . BindMulti ( "P2 Right" , Global . Config . ColecoAutoController [ 1 ] . Right ) ;
acolecoControls . BindMulti ( "P2 Down" , Global . Config . ColecoAutoController [ 1 ] . Down ) ;
2012-11-18 02:36:30 +00:00
acolecoControls . BindMulti ( "P2 L" , Global . Config . ColecoAutoController [ 1 ] . L ) ;
acolecoControls . BindMulti ( "P2 R" , Global . Config . ColecoAutoController [ 1 ] . R ) ;
2012-11-17 22:38:32 +00:00
acolecoControls . BindMulti ( "P2 Key0" , Global . Config . ColecoAutoController [ 1 ] . _0 ) ;
acolecoControls . BindMulti ( "P2 Key1" , Global . Config . ColecoAutoController [ 1 ] . _1 ) ;
acolecoControls . BindMulti ( "P2 Key2" , Global . Config . ColecoAutoController [ 1 ] . _2 ) ;
acolecoControls . BindMulti ( "P2 Key3" , Global . Config . ColecoAutoController [ 1 ] . _3 ) ;
acolecoControls . BindMulti ( "P2 Key4" , Global . Config . ColecoAutoController [ 1 ] . _4 ) ;
acolecoControls . BindMulti ( "P2 Key5" , Global . Config . ColecoAutoController [ 1 ] . _5 ) ;
acolecoControls . BindMulti ( "P2 Key6" , Global . Config . ColecoAutoController [ 1 ] . _6 ) ;
acolecoControls . BindMulti ( "P2 Key7" , Global . Config . ColecoAutoController [ 1 ] . _7 ) ;
acolecoControls . BindMulti ( "P2 Key8" , Global . Config . ColecoAutoController [ 1 ] . _8 ) ;
acolecoControls . BindMulti ( "P2 Key9" , Global . Config . ColecoAutoController [ 1 ] . _9 ) ;
acolecoControls . BindMulti ( "P2 Star" , Global . Config . ColecoAutoController [ 1 ] . Star ) ;
acolecoControls . BindMulti ( "P2 Pound" , Global . Config . ColecoController [ 1 ] . Pound ) ;
2012-11-17 21:57:39 +00:00
Global . AutofireColecoControls = acolecoControls ;
2012-12-22 01:56:14 +00:00
var intelliControls = new Controller ( Intellivision . IntellivisionController ) ;
intelliControls . BindMulti ( "P1 Up" , Global . Config . IntellivisionController [ 0 ] . Up ) ;
intelliControls . BindMulti ( "P1 Left" , Global . Config . IntellivisionController [ 0 ] . Left ) ;
intelliControls . BindMulti ( "P1 Right" , Global . Config . IntellivisionController [ 0 ] . Right ) ;
intelliControls . BindMulti ( "P1 Down" , Global . Config . IntellivisionController [ 0 ] . Down ) ;
intelliControls . BindMulti ( "P1 L" , Global . Config . IntellivisionController [ 0 ] . L ) ;
intelliControls . BindMulti ( "P1 R" , Global . Config . IntellivisionController [ 0 ] . R ) ;
intelliControls . BindMulti ( "P1 Key0" , Global . Config . IntellivisionController [ 0 ] . _0 ) ;
intelliControls . BindMulti ( "P1 Key1" , Global . Config . IntellivisionController [ 0 ] . _1 ) ;
intelliControls . BindMulti ( "P1 Key2" , Global . Config . IntellivisionController [ 0 ] . _2 ) ;
intelliControls . BindMulti ( "P1 Key3" , Global . Config . IntellivisionController [ 0 ] . _3 ) ;
intelliControls . BindMulti ( "P1 Key4" , Global . Config . IntellivisionController [ 0 ] . _4 ) ;
intelliControls . BindMulti ( "P1 Key5" , Global . Config . IntellivisionController [ 0 ] . _5 ) ;
intelliControls . BindMulti ( "P1 Key6" , Global . Config . IntellivisionController [ 0 ] . _6 ) ;
intelliControls . BindMulti ( "P1 Key7" , Global . Config . IntellivisionController [ 0 ] . _7 ) ;
intelliControls . BindMulti ( "P1 Key8" , Global . Config . IntellivisionController [ 0 ] . _8 ) ;
intelliControls . BindMulti ( "P1 Key9" , Global . Config . IntellivisionController [ 0 ] . _9 ) ;
intelliControls . BindMulti ( "P1 Clear" , Global . Config . IntellivisionController [ 0 ] . Clear ) ;
intelliControls . BindMulti ( "P1 Enter" , Global . Config . IntellivisionController [ 0 ] . Enter ) ;
intelliControls . BindMulti ( "P2 Up" , Global . Config . IntellivisionController [ 1 ] . Up ) ;
intelliControls . BindMulti ( "P2 Left" , Global . Config . IntellivisionController [ 1 ] . Left ) ;
intelliControls . BindMulti ( "P2 Right" , Global . Config . IntellivisionController [ 1 ] . Right ) ;
intelliControls . BindMulti ( "P2 Down" , Global . Config . IntellivisionController [ 1 ] . Down ) ;
intelliControls . BindMulti ( "P2 L" , Global . Config . IntellivisionController [ 1 ] . L ) ;
intelliControls . BindMulti ( "P2 R" , Global . Config . IntellivisionController [ 1 ] . R ) ;
intelliControls . BindMulti ( "P2 Key0" , Global . Config . IntellivisionController [ 1 ] . _0 ) ;
intelliControls . BindMulti ( "P2 Key1" , Global . Config . IntellivisionController [ 1 ] . _1 ) ;
intelliControls . BindMulti ( "P2 Key2" , Global . Config . IntellivisionController [ 1 ] . _2 ) ;
intelliControls . BindMulti ( "P2 Key3" , Global . Config . IntellivisionController [ 1 ] . _3 ) ;
intelliControls . BindMulti ( "P2 Key4" , Global . Config . IntellivisionController [ 1 ] . _4 ) ;
intelliControls . BindMulti ( "P2 Key5" , Global . Config . IntellivisionController [ 1 ] . _5 ) ;
intelliControls . BindMulti ( "P2 Key6" , Global . Config . IntellivisionController [ 1 ] . _6 ) ;
intelliControls . BindMulti ( "P2 Key7" , Global . Config . IntellivisionController [ 1 ] . _7 ) ;
intelliControls . BindMulti ( "P2 Key8" , Global . Config . IntellivisionController [ 1 ] . _8 ) ;
intelliControls . BindMulti ( "P2 Key9" , Global . Config . IntellivisionController [ 1 ] . _9 ) ;
intelliControls . BindMulti ( "P2 Clear" , Global . Config . IntellivisionController [ 1 ] . Clear ) ;
intelliControls . BindMulti ( "P2 Enter" , Global . Config . IntellivisionController [ 1 ] . Enter ) ;
Global . IntellivisionControls = intelliControls ;
var aintelliControls = new AutofireController ( Intellivision . IntellivisionController ) ;
aintelliControls . BindMulti ( "P1 Up" , Global . Config . IntellivisionAutoController [ 0 ] . Up ) ;
aintelliControls . BindMulti ( "P1 Left" , Global . Config . IntellivisionAutoController [ 0 ] . Left ) ;
aintelliControls . BindMulti ( "P1 Right" , Global . Config . IntellivisionAutoController [ 0 ] . Right ) ;
aintelliControls . BindMulti ( "P1 Down" , Global . Config . IntellivisionAutoController [ 0 ] . Down ) ;
aintelliControls . BindMulti ( "P1 L" , Global . Config . IntellivisionAutoController [ 0 ] . L ) ;
aintelliControls . BindMulti ( "P1 R" , Global . Config . IntellivisionAutoController [ 0 ] . R ) ;
aintelliControls . BindMulti ( "P1 Key0" , Global . Config . IntellivisionAutoController [ 0 ] . _0 ) ;
aintelliControls . BindMulti ( "P1 Key1" , Global . Config . IntellivisionAutoController [ 0 ] . _1 ) ;
aintelliControls . BindMulti ( "P1 Key2" , Global . Config . IntellivisionAutoController [ 0 ] . _2 ) ;
aintelliControls . BindMulti ( "P1 Key3" , Global . Config . IntellivisionAutoController [ 0 ] . _3 ) ;
aintelliControls . BindMulti ( "P1 Key4" , Global . Config . IntellivisionAutoController [ 0 ] . _4 ) ;
aintelliControls . BindMulti ( "P1 Key5" , Global . Config . IntellivisionAutoController [ 0 ] . _5 ) ;
aintelliControls . BindMulti ( "P1 Key6" , Global . Config . IntellivisionAutoController [ 0 ] . _6 ) ;
aintelliControls . BindMulti ( "P1 Key7" , Global . Config . IntellivisionAutoController [ 0 ] . _7 ) ;
aintelliControls . BindMulti ( "P1 Key8" , Global . Config . IntellivisionAutoController [ 0 ] . _8 ) ;
aintelliControls . BindMulti ( "P1 Key9" , Global . Config . IntellivisionAutoController [ 0 ] . _9 ) ;
aintelliControls . BindMulti ( "P1 Clear" , Global . Config . IntellivisionAutoController [ 0 ] . Clear ) ;
aintelliControls . BindMulti ( "P1 Enter" , Global . Config . IntellivisionAutoController [ 0 ] . Enter ) ;
aintelliControls . BindMulti ( "P2 Up" , Global . Config . IntellivisionAutoController [ 1 ] . Up ) ;
aintelliControls . BindMulti ( "P2 Left" , Global . Config . IntellivisionAutoController [ 1 ] . Left ) ;
aintelliControls . BindMulti ( "P2 Right" , Global . Config . IntellivisionAutoController [ 1 ] . Right ) ;
aintelliControls . BindMulti ( "P2 Down" , Global . Config . IntellivisionAutoController [ 1 ] . Down ) ;
aintelliControls . BindMulti ( "P2 L" , Global . Config . IntellivisionAutoController [ 1 ] . L ) ;
aintelliControls . BindMulti ( "P2 R" , Global . Config . IntellivisionAutoController [ 1 ] . R ) ;
aintelliControls . BindMulti ( "P2 Key0" , Global . Config . IntellivisionAutoController [ 1 ] . _0 ) ;
aintelliControls . BindMulti ( "P2 Key1" , Global . Config . IntellivisionAutoController [ 1 ] . _1 ) ;
aintelliControls . BindMulti ( "P2 Key2" , Global . Config . IntellivisionAutoController [ 1 ] . _2 ) ;
aintelliControls . BindMulti ( "P2 Key3" , Global . Config . IntellivisionAutoController [ 1 ] . _3 ) ;
aintelliControls . BindMulti ( "P2 Key4" , Global . Config . IntellivisionAutoController [ 1 ] . _4 ) ;
aintelliControls . BindMulti ( "P2 Key5" , Global . Config . IntellivisionAutoController [ 1 ] . _5 ) ;
aintelliControls . BindMulti ( "P2 Key6" , Global . Config . IntellivisionAutoController [ 1 ] . _6 ) ;
aintelliControls . BindMulti ( "P2 Key7" , Global . Config . IntellivisionAutoController [ 1 ] . _7 ) ;
aintelliControls . BindMulti ( "P2 Key8" , Global . Config . IntellivisionAutoController [ 1 ] . _8 ) ;
aintelliControls . BindMulti ( "P2 Key9" , Global . Config . IntellivisionAutoController [ 1 ] . _9 ) ;
aintelliControls . BindMulti ( "P2 Clear" , Global . Config . IntellivisionAutoController [ 1 ] . Clear ) ;
aintelliControls . BindMulti ( "P2 Enter" , Global . Config . IntellivisionAutoController [ 1 ] . Enter ) ;
Global . AutofireIntellivisionControls = aintelliControls ;
2011-01-18 10:28:10 +00:00
var TI83Controls = new Controller ( TI83 . TI83Controller ) ;
2011-07-13 02:11:20 +00:00
TI83Controls . BindMulti ( "0" , Global . Config . TI83Controller [ 0 ] . _0 ) ;
2011-04-24 02:01:36 +00:00
TI83Controls . BindMulti ( "1" , Global . Config . TI83Controller [ 0 ] . _1 ) ;
TI83Controls . BindMulti ( "2" , Global . Config . TI83Controller [ 0 ] . _2 ) ;
2011-06-11 12:54:26 +00:00
TI83Controls . BindMulti ( "3" , Global . Config . TI83Controller [ 0 ] . _3 ) ;
TI83Controls . BindMulti ( "4" , Global . Config . TI83Controller [ 0 ] . _4 ) ;
TI83Controls . BindMulti ( "5" , Global . Config . TI83Controller [ 0 ] . _5 ) ;
TI83Controls . BindMulti ( "6" , Global . Config . TI83Controller [ 0 ] . _6 ) ;
TI83Controls . BindMulti ( "7" , Global . Config . TI83Controller [ 0 ] . _7 ) ;
TI83Controls . BindMulti ( "8" , Global . Config . TI83Controller [ 0 ] . _8 ) ;
TI83Controls . BindMulti ( "9" , Global . Config . TI83Controller [ 0 ] . _9 ) ;
2011-04-24 02:01:36 +00:00
TI83Controls . BindMulti ( "ON" , Global . Config . TI83Controller [ 0 ] . ON ) ;
TI83Controls . BindMulti ( "ENTER" , Global . Config . TI83Controller [ 0 ] . ENTER ) ;
TI83Controls . BindMulti ( "DOWN" , Global . Config . TI83Controller [ 0 ] . DOWN ) ;
TI83Controls . BindMulti ( "LEFT" , Global . Config . TI83Controller [ 0 ] . LEFT ) ;
TI83Controls . BindMulti ( "RIGHT" , Global . Config . TI83Controller [ 0 ] . RIGHT ) ;
TI83Controls . BindMulti ( "UP" , Global . Config . TI83Controller [ 0 ] . UP ) ;
TI83Controls . BindMulti ( "PLUS" , Global . Config . TI83Controller [ 0 ] . PLUS ) ;
TI83Controls . BindMulti ( "MINUS" , Global . Config . TI83Controller [ 0 ] . MINUS ) ;
TI83Controls . BindMulti ( "MULTIPLY" , Global . Config . TI83Controller [ 0 ] . MULTIPLY ) ;
TI83Controls . BindMulti ( "DIVIDE" , Global . Config . TI83Controller [ 0 ] . DIVIDE ) ;
TI83Controls . BindMulti ( "CLEAR" , Global . Config . TI83Controller [ 0 ] . CLEAR ) ;
TI83Controls . BindMulti ( "DOT" , Global . Config . TI83Controller [ 0 ] . DOT ) ;
2011-06-11 12:54:26 +00:00
TI83Controls . BindMulti ( "EXP" , Global . Config . TI83Controller [ 0 ] . EXP ) ;
TI83Controls . BindMulti ( "DASH" , Global . Config . TI83Controller [ 0 ] . DASH ) ;
TI83Controls . BindMulti ( "PARACLOSE" , Global . Config . TI83Controller [ 0 ] . DASH ) ;
TI83Controls . BindMulti ( "TAN" , Global . Config . TI83Controller [ 0 ] . TAN ) ;
TI83Controls . BindMulti ( "VARS" , Global . Config . TI83Controller [ 0 ] . VARS ) ;
TI83Controls . BindMulti ( "PARAOPEN" , Global . Config . TI83Controller [ 0 ] . PARAOPEN ) ;
TI83Controls . BindMulti ( "COS" , Global . Config . TI83Controller [ 0 ] . COS ) ;
TI83Controls . BindMulti ( "PRGM" , Global . Config . TI83Controller [ 0 ] . PRGM ) ;
TI83Controls . BindMulti ( "STAT" , Global . Config . TI83Controller [ 0 ] . STAT ) ;
TI83Controls . BindMulti ( "COMMA" , Global . Config . TI83Controller [ 0 ] . COMMA ) ;
TI83Controls . BindMulti ( "SIN" , Global . Config . TI83Controller [ 0 ] . SIN ) ;
TI83Controls . BindMulti ( "MATRIX" , Global . Config . TI83Controller [ 0 ] . MATRIX ) ;
TI83Controls . BindMulti ( "X" , Global . Config . TI83Controller [ 0 ] . X ) ;
TI83Controls . BindMulti ( "STO" , Global . Config . TI83Controller [ 0 ] . STO ) ;
TI83Controls . BindMulti ( "LN" , Global . Config . TI83Controller [ 0 ] . LN ) ;
TI83Controls . BindMulti ( "LOG" , Global . Config . TI83Controller [ 0 ] . LOG ) ;
TI83Controls . BindMulti ( "SQUARED" , Global . Config . TI83Controller [ 0 ] . SQUARED ) ;
TI83Controls . BindMulti ( "NEG1" , Global . Config . TI83Controller [ 0 ] . NEG1 ) ;
TI83Controls . BindMulti ( "MATH" , Global . Config . TI83Controller [ 0 ] . MATH ) ;
TI83Controls . BindMulti ( "ALPHA" , Global . Config . TI83Controller [ 0 ] . ALPHA ) ;
TI83Controls . BindMulti ( "GRAPH" , Global . Config . TI83Controller [ 0 ] . GRAPH ) ;
TI83Controls . BindMulti ( "TRACE" , Global . Config . TI83Controller [ 0 ] . TRACE ) ;
TI83Controls . BindMulti ( "ZOOM" , Global . Config . TI83Controller [ 0 ] . ZOOM ) ;
TI83Controls . BindMulti ( "WINDOW" , Global . Config . TI83Controller [ 0 ] . WINDOW ) ;
TI83Controls . BindMulti ( "Y" , Global . Config . TI83Controller [ 0 ] . Y ) ;
TI83Controls . BindMulti ( "2ND" , Global . Config . TI83Controller [ 0 ] . SECOND ) ;
TI83Controls . BindMulti ( "MODE" , Global . Config . TI83Controller [ 0 ] . MODE ) ;
TI83Controls . BindMulti ( "DEL" , Global . Config . TI83Controller [ 0 ] . DEL ) ;
2011-01-18 10:28:10 +00:00
Global . TI83Controls = TI83Controls ;
2012-11-08 13:33:30 +00:00
var CommodoreControls = new Controller ( C64 . C64ControllerDefinition ) ;
CommodoreControls . BindMulti ( "P1 Up" , Global . Config . C64Joysticks [ 0 ] . Up ) ;
CommodoreControls . BindMulti ( "P1 Left" , Global . Config . C64Joysticks [ 0 ] . Left ) ;
CommodoreControls . BindMulti ( "P1 Right" , Global . Config . C64Joysticks [ 0 ] . Right ) ;
CommodoreControls . BindMulti ( "P1 Down" , Global . Config . C64Joysticks [ 0 ] . Down ) ;
CommodoreControls . BindMulti ( "P1 Button" , Global . Config . C64Joysticks [ 0 ] . Button ) ;
CommodoreControls . BindMulti ( "P2 Up" , Global . Config . C64Joysticks [ 1 ] . Up ) ;
CommodoreControls . BindMulti ( "P2 Left" , Global . Config . C64Joysticks [ 1 ] . Left ) ;
CommodoreControls . BindMulti ( "P2 Right" , Global . Config . C64Joysticks [ 1 ] . Right ) ;
CommodoreControls . BindMulti ( "P2 Down" , Global . Config . C64Joysticks [ 1 ] . Down ) ;
CommodoreControls . BindMulti ( "P2 Button" , Global . Config . C64Joysticks [ 1 ] . Button ) ;
2012-11-10 03:19:42 +00:00
CommodoreControls . BindMulti ( "Key F1" , Global . Config . C64Keyboard . F1 ) ;
CommodoreControls . BindMulti ( "Key F3" , Global . Config . C64Keyboard . F3 ) ;
CommodoreControls . BindMulti ( "Key F5" , Global . Config . C64Keyboard . F5 ) ;
CommodoreControls . BindMulti ( "Key F7" , Global . Config . C64Keyboard . F7 ) ;
CommodoreControls . BindMulti ( "Key Left Arrow" , Global . Config . C64Keyboard . Left_Arrow ) ;
CommodoreControls . BindMulti ( "Key 1" , Global . Config . C64Keyboard . _1 ) ;
CommodoreControls . BindMulti ( "Key 2" , Global . Config . C64Keyboard . _2 ) ;
CommodoreControls . BindMulti ( "Key 3" , Global . Config . C64Keyboard . _3 ) ;
CommodoreControls . BindMulti ( "Key 4" , Global . Config . C64Keyboard . _4 ) ;
CommodoreControls . BindMulti ( "Key 5" , Global . Config . C64Keyboard . _5 ) ;
CommodoreControls . BindMulti ( "Key 6" , Global . Config . C64Keyboard . _6 ) ;
CommodoreControls . BindMulti ( "Key 7" , Global . Config . C64Keyboard . _7 ) ;
CommodoreControls . BindMulti ( "Key 8" , Global . Config . C64Keyboard . _8 ) ;
CommodoreControls . BindMulti ( "Key 9" , Global . Config . C64Keyboard . _9 ) ;
CommodoreControls . BindMulti ( "Key 0" , Global . Config . C64Keyboard . _0 ) ;
CommodoreControls . BindMulti ( "Key Plus" , Global . Config . C64Keyboard . Plus ) ;
2012-11-11 02:36:29 +00:00
CommodoreControls . BindMulti ( "Key Minus" , Global . Config . C64Keyboard . Minus ) ;
CommodoreControls . BindMulti ( "Key Pound" , Global . Config . C64Keyboard . Pound ) ;
CommodoreControls . BindMulti ( "Key Clear/Home" , Global . Config . C64Keyboard . Clear_Home ) ;
CommodoreControls . BindMulti ( "Key Insert/Delete" , Global . Config . C64Keyboard . Insert_Delete ) ;
CommodoreControls . BindMulti ( "Key Control" , Global . Config . C64Keyboard . Control ) ;
CommodoreControls . BindMulti ( "Key Q" , Global . Config . C64Keyboard . Q ) ;
CommodoreControls . BindMulti ( "Key W" , Global . Config . C64Keyboard . W ) ;
CommodoreControls . BindMulti ( "Key E" , Global . Config . C64Keyboard . E ) ;
CommodoreControls . BindMulti ( "Key R" , Global . Config . C64Keyboard . R ) ;
CommodoreControls . BindMulti ( "Key T" , Global . Config . C64Keyboard . T ) ;
CommodoreControls . BindMulti ( "Key Y" , Global . Config . C64Keyboard . Y ) ;
CommodoreControls . BindMulti ( "Key U" , Global . Config . C64Keyboard . U ) ;
CommodoreControls . BindMulti ( "Key I" , Global . Config . C64Keyboard . I ) ;
CommodoreControls . BindMulti ( "Key O" , Global . Config . C64Keyboard . O ) ;
CommodoreControls . BindMulti ( "Key P" , Global . Config . C64Keyboard . P ) ;
CommodoreControls . BindMulti ( "Key At" , Global . Config . C64Keyboard . At ) ;
CommodoreControls . BindMulti ( "Key Asterisk" , Global . Config . C64Keyboard . Asterisk ) ;
CommodoreControls . BindMulti ( "Key Up Arrow" , Global . Config . C64Keyboard . Up_Arrow ) ;
2012-11-25 21:49:07 +00:00
CommodoreControls . BindMulti ( "Key Restore" , Global . Config . C64Keyboard . Restore ) ;
2012-11-11 02:36:29 +00:00
CommodoreControls . BindMulti ( "Key Run/Stop" , Global . Config . C64Keyboard . Run_Stop ) ;
2012-11-19 00:56:26 +00:00
CommodoreControls . BindMulti ( "Key Lck" , Global . Config . C64Keyboard . Lck ) ;
2012-11-11 02:36:29 +00:00
CommodoreControls . BindMulti ( "Key A" , Global . Config . C64Keyboard . A ) ;
CommodoreControls . BindMulti ( "Key S" , Global . Config . C64Keyboard . S ) ;
CommodoreControls . BindMulti ( "Key D" , Global . Config . C64Keyboard . D ) ;
CommodoreControls . BindMulti ( "Key F" , Global . Config . C64Keyboard . F ) ;
CommodoreControls . BindMulti ( "Key G" , Global . Config . C64Keyboard . G ) ;
CommodoreControls . BindMulti ( "Key H" , Global . Config . C64Keyboard . H ) ;
CommodoreControls . BindMulti ( "Key J" , Global . Config . C64Keyboard . J ) ;
CommodoreControls . BindMulti ( "Key K" , Global . Config . C64Keyboard . K ) ;
CommodoreControls . BindMulti ( "Key L" , Global . Config . C64Keyboard . L ) ;
CommodoreControls . BindMulti ( "Key Colon" , Global . Config . C64Keyboard . Colon ) ;
CommodoreControls . BindMulti ( "Key Semicolon" , Global . Config . C64Keyboard . Semicolon ) ;
CommodoreControls . BindMulti ( "Key Equal" , Global . Config . C64Keyboard . Equal ) ;
CommodoreControls . BindMulti ( "Key Return" , Global . Config . C64Keyboard . Return ) ;
CommodoreControls . BindMulti ( "Key Commodore" , Global . Config . C64Keyboard . Commodore ) ;
CommodoreControls . BindMulti ( "Key Left Shift" , Global . Config . C64Keyboard . Left_Shift ) ;
CommodoreControls . BindMulti ( "Key Z" , Global . Config . C64Keyboard . Z ) ;
CommodoreControls . BindMulti ( "Key X" , Global . Config . C64Keyboard . X ) ;
CommodoreControls . BindMulti ( "Key C" , Global . Config . C64Keyboard . C ) ;
CommodoreControls . BindMulti ( "Key V" , Global . Config . C64Keyboard . V ) ;
CommodoreControls . BindMulti ( "Key B" , Global . Config . C64Keyboard . B ) ;
CommodoreControls . BindMulti ( "Key N" , Global . Config . C64Keyboard . N ) ;
CommodoreControls . BindMulti ( "Key M" , Global . Config . C64Keyboard . M ) ;
CommodoreControls . BindMulti ( "Key Comma" , Global . Config . C64Keyboard . Comma ) ;
CommodoreControls . BindMulti ( "Key Period" , Global . Config . C64Keyboard . Period ) ;
CommodoreControls . BindMulti ( "Key Period" , Global . Config . C64Keyboard . Period ) ;
CommodoreControls . BindMulti ( "Key Slash" , Global . Config . C64Keyboard . Slash ) ;
CommodoreControls . BindMulti ( "Key Right Shift" , Global . Config . C64Keyboard . Right_Shift ) ;
CommodoreControls . BindMulti ( "Key Cursor Up/Down" , Global . Config . C64Keyboard . Cursor_Up_Down ) ;
CommodoreControls . BindMulti ( "Key Cursor Left/Right" , Global . Config . C64Keyboard . Cursor_Left_Right ) ;
CommodoreControls . BindMulti ( "Key Space" , Global . Config . C64Keyboard . Space ) ;
2012-11-10 03:19:42 +00:00
2012-11-08 13:33:30 +00:00
Global . Commodore64Controls = CommodoreControls ;
var autofireC64Controls = new AutofireController ( C64 . C64ControllerDefinition ) ;
autofireC64Controls . BindMulti ( "P1 Up" , Global . Config . C64AutoJoysticks [ 0 ] . Up ) ;
autofireC64Controls . BindMulti ( "P1 Left" , Global . Config . C64AutoJoysticks [ 0 ] . Left ) ;
autofireC64Controls . BindMulti ( "P1 Right" , Global . Config . C64AutoJoysticks [ 0 ] . Right ) ;
autofireC64Controls . BindMulti ( "P1 Down" , Global . Config . C64AutoJoysticks [ 0 ] . Down ) ;
autofireC64Controls . BindMulti ( "P1 Button" , Global . Config . C64AutoJoysticks [ 0 ] . Button ) ;
autofireC64Controls . BindMulti ( "P2 Up" , Global . Config . C64AutoJoysticks [ 1 ] . Up ) ;
autofireC64Controls . BindMulti ( "P2 Left" , Global . Config . C64AutoJoysticks [ 1 ] . Left ) ;
autofireC64Controls . BindMulti ( "P2 Right" , Global . Config . C64AutoJoysticks [ 1 ] . Right ) ;
autofireC64Controls . BindMulti ( "P2 Down" , Global . Config . C64AutoJoysticks [ 1 ] . Down ) ;
autofireC64Controls . BindMulti ( "P2 Button" , Global . Config . C64AutoJoysticks [ 1 ] . Button ) ;
2012-11-08 19:39:00 +00:00
Global . AutofireCommodore64Controls = autofireC64Controls ;
2011-02-20 08:40:22 +00:00
}
2011-06-11 12:54:26 +00:00
private static void FormDragEnter ( object sender , DragEventArgs e )
2011-02-20 08:40:22 +00:00
{
e . Effect = e . Data . GetDataPresent ( DataFormats . FileDrop ) ? DragDropEffects . Copy : DragDropEffects . None ;
}
2011-06-11 12:54:26 +00:00
private bool IsValidMovieExtension ( string ext )
{
2012-04-02 00:47:52 +00:00
if ( ext . ToUpper ( ) = = "." + Global . Config . MovieExtension )
return true ;
else if ( ext . ToUpper ( ) = = ".TAS" )
return true ;
else if ( ext . ToUpper ( ) = = ".BKM" )
return true ;
return false ;
2011-06-11 12:54:26 +00:00
}
2011-05-13 17:03:05 +00:00
2011-02-20 08:40:22 +00:00
private void FormDragDrop ( object sender , DragEventArgs e )
{
string [ ] filePaths = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
2012-06-07 03:41:45 +00:00
bool isLua = false ;
foreach ( string path in filePaths )
{
if ( Path . GetExtension ( path ) . ToUpper ( ) = = ".LUA" )
{
OpenLuaConsole ( ) ;
LuaConsole1 . LoadLuaFile ( path ) ;
isLua = true ;
}
}
if ( isLua )
return ;
if ( Path . GetExtension ( filePaths [ 0 ] ) . ToUpper ( ) = = ".LUASES" )
{
OpenLuaConsole ( ) ;
LuaConsole1 . LoadLuaSession ( filePaths [ 0 ] ) ;
}
else if ( IsValidMovieExtension ( Path . GetExtension ( filePaths [ 0 ] ) ) )
2011-06-11 12:54:26 +00:00
{
2012-09-03 19:42:53 +00:00
Movie m = new Movie ( filePaths [ 0 ] ) ;
2011-06-11 12:54:26 +00:00
StartNewMovie ( m , false ) ;
}
else if ( Path . GetExtension ( filePaths [ 0 ] ) . ToUpper ( ) = = ".STATE" )
LoadStateFile ( filePaths [ 0 ] , Path . GetFileName ( filePaths [ 0 ] ) ) ;
else if ( Path . GetExtension ( filePaths [ 0 ] ) . ToUpper ( ) = = ".CHT" )
{
LoadCheatsWindow ( ) ;
Cheats1 . LoadCheatFile ( filePaths [ 0 ] , false ) ;
Cheats1 . DisplayCheatsList ( ) ;
}
else if ( Path . GetExtension ( filePaths [ 0 ] ) . ToUpper ( ) = = ".WCH" )
{
2012-08-15 01:14:25 +00:00
LoadRamWatch ( true ) ;
2011-06-11 12:54:26 +00:00
RamWatch1 . LoadWatchFile ( filePaths [ 0 ] , false ) ;
RamWatch1 . DisplayWatchList ( ) ;
}
2012-02-15 00:43:21 +00:00
else if ( MovieImport . IsValidMovieExtension ( Path . GetExtension ( filePaths [ 0 ] ) ) )
2011-06-11 12:54:26 +00:00
{
2012-12-02 20:35:51 +00:00
//tries to open a legacy movie format as if it were a BKM, by importing it
2012-03-03 18:11:07 +00:00
if ( CurrentlyOpenRom = = null )
OpenROM ( ) ;
else
LoadRom ( CurrentlyOpenRom ) ;
2012-03-03 18:24:34 +00:00
2012-02-24 07:48:06 +00:00
string errorMsg = "" ;
string warningMsg = "" ;
Movie m = MovieImport . ImportFile ( filePaths [ 0 ] , out errorMsg , out warningMsg ) ;
if ( errorMsg . Length > 0 )
2012-09-03 20:17:57 +00:00
{
2012-02-24 07:48:06 +00:00
MessageBox . Show ( errorMsg , "Conversion error" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
2012-09-03 20:17:57 +00:00
}
2011-07-14 01:12:18 +00:00
else
2012-09-03 20:17:57 +00:00
{
2012-12-02 20:35:51 +00:00
//fix movie extension to something palatable for these purposes.
//for instance, something which doesnt clobber movies you already may have had.
//i'm evenly torn between this, and a file in %TEMP%, but since we dont really have a way to clean up this tempfile, i choose this:
m . Filename + = ".autoimported." + Global . Config . MovieExtension ;
m . WriteMovie ( ) ;
2011-07-14 01:12:18 +00:00
StartNewMovie ( m , false ) ;
2012-09-03 20:17:57 +00:00
}
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( warningMsg ) ;
2012-03-30 12:26:36 +00:00
}
else
2011-06-11 12:54:26 +00:00
LoadRom ( filePaths [ 0 ] ) ;
2011-02-20 08:40:22 +00:00
}
2011-02-23 16:22:41 +00:00
public bool IsNullEmulator ( )
2011-02-20 08:40:22 +00:00
{
if ( Global . Emulator is NullEmulator )
return true ;
else
return false ;
}
private string DisplayNameForSystem ( string system )
{
2011-09-11 00:11:46 +00:00
string str = "" ;
2011-02-20 08:40:22 +00:00
switch ( system )
{
2012-09-08 21:09:10 +00:00
case "INTV" : str + = "Intellivision" ; break ;
2011-09-11 00:11:46 +00:00
case "SG" : str + = "SG-1000" ; break ;
case "SMS" : str + = "Sega Master System" ; break ;
case "GG" : str + = "Game Gear" ; break ;
2011-09-24 17:05:34 +00:00
case "PCECD" : str + = "TurboGrafx-16 (CD)" ; break ;
2011-09-11 00:11:46 +00:00
case "PCE" : str + = "TurboGrafx-16" ; break ;
case "SGX" : str + = "SuperGrafx" ; break ;
case "GEN" : str + = "Genesis" ; break ;
case "TI83" : str + = "TI-83" ; break ;
case "NES" : str + = "NES" ; break ;
2012-09-08 21:09:10 +00:00
case "SNES" : str + = "SNES" ; break ;
2011-09-11 00:11:46 +00:00
case "GB" : str + = "Game Boy" ; break ;
2012-10-07 14:52:03 +00:00
case "GBC" : str + = "Game Boy Color" ; break ;
2012-03-30 12:26:36 +00:00
case "A26" : str + = "Atari 2600" ; break ;
2012-10-23 19:13:57 +00:00
case "A78" : str + = "Atari 7800" ; break ;
2012-11-01 16:48:32 +00:00
case "C64" : str + = "Commodore 64" ; break ;
2012-11-17 22:16:23 +00:00
case "Coleco" : str + = "ColecoVision" ; break ;
2012-11-19 22:43:34 +00:00
case "GBA" : str + = "Game Boy Advance" ; break ;
2011-02-20 08:40:22 +00:00
}
2012-03-30 12:26:36 +00:00
2011-09-24 17:05:34 +00:00
if ( INTERIM ) str + = " (interim)" ;
2011-09-11 00:11:46 +00:00
return str ;
2011-02-20 08:40:22 +00:00
}
2011-06-11 12:54:26 +00:00
private void HandlePlatformMenus ( )
{
2011-03-13 00:44:45 +00:00
string system = "" ;
2012-10-06 12:27:56 +00:00
2011-03-13 00:44:45 +00:00
if ( Global . Game ! = null )
2012-10-06 12:27:56 +00:00
{
2011-03-13 00:44:45 +00:00
system = Global . Game . System ;
2012-10-06 12:27:56 +00:00
}
2012-04-29 02:48:33 +00:00
tI83ToolStripMenuItem . Visible = false ;
NESToolStripMenuItem . Visible = false ;
pCEToolStripMenuItem . Visible = false ;
sMSToolStripMenuItem . Visible = false ;
gBToolStripMenuItem . Visible = false ;
2012-11-26 23:16:31 +00:00
gBAToolStripMenuItem . Visible = false ;
2012-04-29 02:48:33 +00:00
atariToolStripMenuItem . Visible = false ;
2012-09-10 18:32:36 +00:00
sNESToolStripMenuItem . Visible = false ;
2012-11-22 02:01:15 +00:00
colecoToolStripMenuItem . Visible = false ;
2011-06-11 12:54:26 +00:00
switch ( system )
{
case "TI83" :
2012-03-11 17:08:25 +00:00
tI83ToolStripMenuItem . Visible = true ;
2011-06-11 12:54:26 +00:00
break ;
case "NES" :
NESToolStripMenuItem . Visible = true ;
2012-10-31 21:15:44 +00:00
NESSpeicalMenuControls ( ) ;
2012-03-11 15:12:48 +00:00
break ;
case "PCE" :
case "PCECD" :
case "SGX" :
pCEToolStripMenuItem . Visible = true ;
2012-03-11 17:08:25 +00:00
break ;
case "SMS" :
2012-10-06 12:27:56 +00:00
sMSToolStripMenuItem . Text = "SMS" ;
sMSToolStripMenuItem . Visible = true ;
break ;
2012-03-11 17:08:25 +00:00
case "SG" :
2012-10-06 12:27:56 +00:00
sMSToolStripMenuItem . Text = "SG" ;
sMSToolStripMenuItem . Visible = true ;
break ;
case "GG" :
sMSToolStripMenuItem . Text = "GG" ;
2012-03-11 17:08:25 +00:00
sMSToolStripMenuItem . Visible = true ;
2011-06-27 00:15:47 +00:00
break ;
2011-07-15 03:25:32 +00:00
case "GB" :
2012-10-06 23:53:05 +00:00
case "GBC" :
2011-06-27 00:15:47 +00:00
gBToolStripMenuItem . Visible = true ;
2011-06-11 12:54:26 +00:00
break ;
2012-11-26 23:16:31 +00:00
case "GBA" :
gBAToolStripMenuItem . Visible = true ;
break ;
2012-04-29 02:48:33 +00:00
case "A26" :
atariToolStripMenuItem . Visible = true ;
break ;
2012-09-10 18:32:36 +00:00
case "SNES" :
2012-09-26 15:59:14 +00:00
case "SGB" :
2012-10-07 00:00:23 +00:00
if ( ( Global . Emulator as LibsnesCore ) . IsSGB )
2012-10-05 04:47:45 +00:00
sNESToolStripMenuItem . Text = "&SGB" ;
2012-10-07 00:00:23 +00:00
else
sNESToolStripMenuItem . Text = "&SNES" ;
2012-09-10 18:32:36 +00:00
sNESToolStripMenuItem . Visible = true ;
break ;
2012-11-22 02:01:15 +00:00
case "Coleco" :
colecoToolStripMenuItem . Visible = true ;
break ;
2011-06-11 12:54:26 +00:00
default :
break ;
}
}
2011-03-02 17:12:48 +00:00
2012-10-31 21:15:44 +00:00
void NESSpeicalMenuAdd ( string name , string button , string msg )
2012-10-28 15:22:15 +00:00
{
2012-10-31 21:15:44 +00:00
nESSpeicalToolStripMenuItem . Visible = true ;
nESSpeicalToolStripMenuItem . DropDownItems . Add ( name , null , delegate ( object sender , EventArgs e )
2012-10-28 15:22:15 +00:00
{
if ( Global . Emulator . ControllerDefinition . BoolButtons . Contains ( button ) )
{
if ( ! Global . MovieSession . Movie . IsPlaying | | Global . MovieSession . Movie . IsFinished )
{
Global . ClickyVirtualPadController . Click ( button ) ;
Global . OSD . AddMessage ( msg ) ;
}
}
}
) ;
}
2012-10-31 21:15:44 +00:00
void NESSpeicalMenuControls ( )
2012-10-28 15:22:15 +00:00
{
// ugly and hacky
2012-10-31 21:15:44 +00:00
nESSpeicalToolStripMenuItem . Visible = false ;
nESSpeicalToolStripMenuItem . DropDownItems . Clear ( ) ;
2012-10-28 15:22:15 +00:00
var ss = Global . Emulator . ControllerDefinition . BoolButtons ;
if ( ss . Contains ( "FDS Eject" ) )
2012-10-31 21:15:44 +00:00
NESSpeicalMenuAdd ( "Eject Disk" , "FDS Eject" , "FDS Disk Ejected." ) ;
2012-10-28 15:22:15 +00:00
for ( int i = 0 ; i < 16 ; i + + )
{
string s = "FDS Insert " + i ;
if ( ss . Contains ( s ) )
2012-10-31 21:15:44 +00:00
NESSpeicalMenuAdd ( "Insert Disk " + i , s , "FDS Disk " + i + " inserted." ) ;
2012-10-28 15:22:15 +00:00
}
2012-10-31 21:15:44 +00:00
if ( ss . Contains ( "VS Coin 1" ) )
NESSpeicalMenuAdd ( "Insert Coin 1" , "VS Coin 1" , "Coin 1 inserted." ) ;
if ( ss . Contains ( "VS Coin 2" ) )
NESSpeicalMenuAdd ( "Insert Coin 2" , "VS Coin 2" , "Coin 2 inserted." ) ;
2012-10-28 15:22:15 +00:00
}
2011-04-06 05:43:59 +00:00
void SyncControls ( )
{
2011-06-11 12:54:26 +00:00
if ( Global . Game = = null ) return ;
switch ( Global . Game . System )
2011-04-06 05:43:59 +00:00
{
2011-06-11 12:54:26 +00:00
case "SG" :
2011-04-06 05:43:59 +00:00
case "SMS" :
2011-06-11 12:54:26 +00:00
Global . ActiveController = Global . SMSControls ;
2011-08-09 02:16:46 +00:00
Global . AutoFireController = Global . AutofireSMSControls ;
2011-04-06 05:43:59 +00:00
break ;
case "GG" :
2011-06-11 12:54:26 +00:00
Global . ActiveController = Global . SMSControls ;
2011-08-09 02:40:22 +00:00
Global . AutoFireController = Global . AutofireSMSControls ;
2011-04-06 05:43:59 +00:00
break ;
2012-03-07 00:40:20 +00:00
case "A26" :
Global . ActiveController = Global . Atari2600Controls ;
Global . AutoFireController = Global . AutofireAtari2600Controls ;
break ;
2012-12-14 02:17:47 +00:00
case "A78" :
Global . ActiveController = Global . Atari7800Controls ;
Global . AutoFireController = Global . AutofireAtari7800Controls ;
break ;
2011-04-06 05:43:59 +00:00
case "PCE" :
2011-09-24 17:05:34 +00:00
case "PCECD" :
2011-06-11 12:54:26 +00:00
Global . ActiveController = Global . PCEControls ;
2011-08-09 02:40:22 +00:00
Global . AutoFireController = Global . AutofirePCEControls ;
2011-04-06 05:43:59 +00:00
break ;
case "SGX" :
2011-06-11 12:54:26 +00:00
Global . ActiveController = Global . PCEControls ;
2011-08-09 02:40:22 +00:00
Global . AutoFireController = Global . AutofirePCEControls ;
2011-04-06 05:43:59 +00:00
break ;
case "GEN" :
2011-06-11 12:54:26 +00:00
Global . ActiveController = Global . GenControls ;
2011-08-09 02:40:22 +00:00
Global . AutoFireController = Global . AutofireGenControls ;
2011-04-06 05:43:59 +00:00
break ;
case "TI83" :
2011-06-11 12:54:26 +00:00
Global . ActiveController = Global . TI83Controls ;
2011-04-06 05:43:59 +00:00
break ;
case "NES" :
2011-06-11 12:54:26 +00:00
Global . ActiveController = Global . NESControls ;
2011-08-09 02:16:46 +00:00
Global . AutoFireController = Global . AutofireNESControls ;
2011-04-06 05:43:59 +00:00
break ;
2012-09-04 00:20:36 +00:00
case "SNES" :
Global . ActiveController = Global . SNESControls ;
2012-09-26 01:20:11 +00:00
Global . AutoFireController = Global . AutofireSNESControls ;
2012-09-04 00:20:36 +00:00
break ;
2011-04-06 05:43:59 +00:00
case "GB" :
2012-10-06 23:53:05 +00:00
case "GBC" :
2012-05-16 03:14:50 +00:00
Global . ActiveController = Global . GBControls ;
Global . AutoFireController = Global . AutofireGBControls ;
2011-04-06 05:43:59 +00:00
break ;
2012-11-24 16:14:30 +00:00
case "GBA" :
Global . ActiveController = Global . GBAControls ;
Global . AutoFireController = Global . AutofireGBAControls ;
break ;
2012-11-17 21:12:51 +00:00
case "Coleco" :
2012-05-06 00:54:13 +00:00
Global . ActiveController = Global . ColecoControls ;
2012-11-17 21:57:39 +00:00
Global . AutoFireController = Global . AutofireColecoControls ;
2012-05-06 00:54:13 +00:00
break ;
2012-11-08 13:33:30 +00:00
case "C64" :
Global . ActiveController = Global . Commodore64Controls ;
Global . AutoFireController = Global . AutofireCommodore64Controls ;
break ;
2012-12-22 01:56:14 +00:00
case "INTV" :
Global . ActiveController = Global . IntellivisionControls ;
Global . AutoFireController = Global . AutofireIntellivisionControls ;
break ;
2012-12-29 02:30:31 +00:00
case "DGB" :
Global . ActiveController = Global . DualGBControls ;
Global . AutoFireController = Global . DualAutofireGBControls ;
break ;
2011-06-11 12:54:26 +00:00
default :
Global . ActiveController = Global . NullControls ;
break ;
2011-04-06 05:43:59 +00:00
}
2012-10-28 15:22:15 +00:00
// allow propogating controls that are in the current controller definition but not in the prebaked one
Global . ActiveController . ForceType ( new ControllerDefinition ( Global . Emulator . ControllerDefinition ) ) ;
Global . ClickyVirtualPadController . Type = new ControllerDefinition ( Global . Emulator . ControllerDefinition ) ;
2011-06-27 05:31:46 +00:00
RewireInputChain ( ) ;
}
void RewireInputChain ( )
{
2012-12-09 01:42:47 +00:00
Global . ControllerInputCoalescer = new ControllerInputCoalescer ( ) ;
2011-09-24 16:19:38 +00:00
2011-07-10 07:39:40 +00:00
Global . ControllerInputCoalescer . Type = Global . ActiveController . Type ;
2011-08-09 00:51:46 +00:00
Global . OrControllerAdapter . Source = Global . ActiveController ;
Global . OrControllerAdapter . SourceOr = Global . AutoFireController ;
Global . UD_LR_ControllerAdapter . Source = Global . OrControllerAdapter ;
2011-08-08 23:35:13 +00:00
2011-08-09 00:51:46 +00:00
Global . StickyXORAdapter . Source = Global . UD_LR_ControllerAdapter ;
2012-09-15 13:11:29 +00:00
Global . AutofireStickyXORAdapter . Source = Global . StickyXORAdapter ;
2011-09-24 16:19:38 +00:00
2012-09-15 13:11:29 +00:00
Global . MultitrackRewiringControllerAdapter . Source = Global . AutofireStickyXORAdapter ;
2011-06-27 05:31:46 +00:00
Global . MovieInputSourceAdapter . Source = Global . MultitrackRewiringControllerAdapter ;
2011-08-21 04:44:40 +00:00
Global . ControllerOutput . Source = Global . MovieOutputHardpoint ;
2011-08-09 00:51:46 +00:00
2011-06-27 05:31:46 +00:00
Global . Emulator . Controller = Global . ControllerOutput ;
2011-07-24 23:14:16 +00:00
Global . MovieSession . MovieControllerAdapter . Type = Global . MovieInputSourceAdapter . Type ;
2011-08-21 04:44:40 +00:00
//connect the movie session before MovieOutputHardpoint if it is doing anything
//otherwise connect the MovieInputSourceAdapter to it, effectively bypassing the movie session
2011-07-24 23:14:16 +00:00
if ( Global . MovieSession . Movie ! = null )
2011-08-21 04:44:40 +00:00
Global . MovieOutputHardpoint . Source = Global . MovieSession . MovieControllerAdapter ;
2011-07-24 23:14:16 +00:00
else
2011-08-21 04:44:40 +00:00
Global . MovieOutputHardpoint . Source = Global . MovieInputSourceAdapter ;
2011-04-06 05:43:59 +00:00
}
2012-10-01 14:39:52 +00:00
public bool LoadRom ( string path , bool deterministicemulation = false )
2011-02-20 08:40:22 +00:00
{
2011-07-30 23:20:49 +00:00
if ( path = = null ) return false ;
2011-06-27 05:31:46 +00:00
using ( var file = new HawkFile ( ) )
2011-01-20 06:24:31 +00:00
{
2012-11-17 17:39:33 +00:00
string [ ] romExtensions = new string [ ] { "SMS" , "SMC" , "SFC" , "PCE" , "SGX" , "GG" , "SG" , "BIN" , "GEN" , "MD" , "SMD" , "GB" , "NES" , "FDS" , "ROM" , "INT" , "GBC" , "UNF" , "A78" , "CRT" , "COL" } ;
2011-06-27 05:31:46 +00:00
//lets not use this unless we need to
//file.NonArchiveExtensions = romExtensions;
file . Open ( path ) ;
2011-03-07 02:04:42 +00:00
//if the provided file doesnt even exist, give up!
2011-03-07 02:44:30 +00:00
if ( ! file . Exists ) return false ;
2011-03-07 01:07:49 +00:00
2011-03-07 02:04:42 +00:00
//try binding normal rom extensions first
if ( ! file . IsBound )
2011-06-27 05:31:46 +00:00
file . BindSoleItemOf ( romExtensions ) ;
2011-03-07 02:04:42 +00:00
//if we have an archive and need to bind something, then pop the dialog
if ( file . IsArchive & & ! file . IsBound )
{
var ac = new ArchiveChooser ( file ) ;
if ( ac . ShowDialog ( this ) = = DialogResult . OK )
{
file . BindArchiveMember ( ac . SelectedMemberIndex ) ;
}
else return false ;
}
2011-03-07 10:41:46 +00:00
IEmulator nextEmulator = null ;
2011-08-04 03:20:54 +00:00
RomGame rom = null ;
2011-08-09 00:51:46 +00:00
GameInfo game = null ;
2012-12-10 00:43:43 +00:00
CoreComm nextComm = new CoreComm ( ) ;
SyncCoreCommInputSignals ( nextComm ) ;
2011-03-07 01:07:49 +00:00
2011-08-04 03:20:54 +00:00
try
2011-03-07 01:07:49 +00:00
{
2012-02-24 20:45:27 +00:00
//if (file.Extension.ToLower() == ".exe")
//{
// PSX psx = new PSX();
// nextEmulator = psx;
// psx.LoadFile(file.CanonicalFullPath);
// game = new GameInfo();
// game.System = "PSX";
// game.Name = "xx";
// game.Hash = "xx";
//}
//else
if ( file . Extension . ToLower ( ) = = ".iso" )
2012-02-24 20:38:35 +00:00
{
//if (Global.PsxCoreLibrary.IsOpen)
//{
// // sorry zero ;'( I leave de-RomGameifying this to you
// //PsxCore psx = new PsxCore(Global.PsxCoreLibrary);
// //nextEmulator = psx;
// //game = new RomGame();
// //var disc = Disc.FromIsoPath(path);
// //Global.DiscHopper.Clear();
// //Global.DiscHopper.Enqueue(disc);
// //Global.DiscHopper.Insert();
// //psx.SetDiscHopper(Global.DiscHopper);
//}
2011-08-09 00:51:46 +00:00
}
else if ( file . Extension . ToLower ( ) = = ".cue" )
{
2012-01-23 00:38:28 +00:00
Disc disc = Disc . FromCuePath ( path , new CueBinPrefs ( ) ) ;
2011-08-09 00:51:46 +00:00
var hash = disc . GetHash ( ) ;
game = Database . CheckDatabase ( hash ) ;
if ( game = = null )
{
2012-02-24 07:48:06 +00:00
// Game was not found in DB. For now we're going to send it to the PCE-CD core.
2011-08-09 00:51:46 +00:00
// In the future we need to do something smarter, possibly including simply asking the user
// what system the game is for.
2012-11-05 00:11:41 +00:00
if ( BizHawk . Emulation . Consoles . PSX . Octoshock . CheckIsPSX ( disc ) )
2012-11-04 23:29:06 +00:00
{
game = new GameInfo ( ) ;
game . System = "PSX" ;
game . Name = Path . GetFileNameWithoutExtension ( file . Name ) ;
game . Hash = hash ;
2012-11-05 00:11:41 +00:00
disc . Dispose ( ) ;
2012-11-04 23:29:06 +00:00
}
else
{
game = new GameInfo ( ) ;
game . System = "PCECD" ;
game . Name = Path . GetFileNameWithoutExtension ( file . Name ) ;
game . Hash = hash ;
}
2011-08-09 00:51:46 +00:00
}
switch ( game . System )
{
2012-11-04 23:29:06 +00:00
case "PSX" :
{
2012-12-10 00:43:43 +00:00
var psx = new BizHawk . Emulation . Consoles . PSX . Octoshock ( nextComm ) ;
2012-11-04 23:29:06 +00:00
nextEmulator = psx ;
psx . LoadCuePath ( file . CanonicalFullPath ) ;
2012-12-10 00:43:43 +00:00
nextEmulator . CoreComm . RomStatusDetails = "PSX etc." ;
2012-11-04 23:29:06 +00:00
}
break ;
2011-08-09 00:51:46 +00:00
case "PCE" :
2011-09-24 17:05:34 +00:00
case "PCECD" :
2011-08-09 00:51:46 +00:00
{
2012-12-30 17:33:33 +00:00
string biosPath = PathManager . StandardFirmwareName ( Global . Config . FilenamePCEBios ) ; //PathManager.MakeAbsolutePath(Global.Config.PathPCEBios, "PCE");
2012-03-03 21:51:20 +00:00
if ( File . Exists ( biosPath ) = = false )
{
MessageBox . Show ( "PCE-CD System Card not found. Please check the BIOS path in Config->Paths->PC Engine." ) ;
return false ;
}
rom = new RomGame ( new HawkFile ( biosPath ) ) ;
2011-08-30 04:02:52 +00:00
2012-03-03 21:51:20 +00:00
if ( rom . GameInfo . Status = = RomStatus . BadDump )
MessageBox . Show ( "The PCE-CD System Card you have selected is known to be a bad dump. This may cause problems playing PCE-CD games.\n\n" +
"It is recommended that you find a good dump of the system card. Sorry to be the bearer of bad news!" ) ;
2011-08-30 04:02:52 +00:00
2012-03-03 21:51:20 +00:00
else if ( rom . GameInfo . NotInDatabase )
MessageBox . Show ( "The PCE-CD System Card you have selected is not recognized in our database. That might mean it's a bad dump, or isn't the correct rom." ) ;
2011-08-30 04:02:52 +00:00
2012-03-03 21:51:20 +00:00
else if ( rom . GameInfo [ "BIOS" ] = = false )
MessageBox . Show ( "The PCE-CD System Card you have selected is not a BIOS image. You may have selected the wrong rom." ) ;
2011-08-30 04:02:52 +00:00
2012-03-03 21:51:20 +00:00
if ( rom . GameInfo [ "SuperSysCard" ] )
game . AddOption ( "SuperSysCard" ) ;
if ( ( game [ "NeedSuperSysCard" ] ) & & game [ "SuperSysCard" ] = = false )
MessageBox . Show ( "This game requires a version 3.0 System card and won't run with the system card you've selected. Try selecting a 3.0 System Card in Config->Paths->PC Engine." ) ;
2011-09-24 16:09:40 +00:00
2012-03-03 21:51:20 +00:00
if ( Global . Config . PceSpriteLimit ) game . AddOption ( "ForceSpriteLimit" ) ;
if ( Global . Config . PceEqualizeVolume ) game . AddOption ( "EqualizeVolumes" ) ;
if ( Global . Config . PceArcadeCardRewindHack ) game . AddOption ( "ArcadeRewindHack" ) ;
2011-09-19 00:39:28 +00:00
2012-10-05 21:04:46 +00:00
game . FirmwareHash = Util . BytesToHexString ( System . Security . Cryptography . SHA1 . Create ( ) . ComputeHash ( rom . RomData ) ) ;
2012-12-10 00:43:43 +00:00
nextEmulator = new PCEngine ( nextComm , game , disc , rom . RomData ) ;
2012-03-03 21:51:20 +00:00
break ;
}
2011-08-09 00:51:46 +00:00
}
}
else
{
rom = new RomGame ( file ) ;
game = rom . GameInfo ;
2012-10-05 04:47:45 +00:00
RETRY :
2011-08-09 00:51:46 +00:00
switch ( game . System )
{
2012-09-04 06:08:46 +00:00
case "SNES" :
2012-09-27 07:22:31 +00:00
{
game . System = "SNES" ;
2012-12-25 20:36:04 +00:00
nextComm . SNES_ExePath = SNES_Prepare ( Global . Config . SNESProfile ) ;
2012-12-10 00:43:43 +00:00
var snes = new LibsnesCore ( nextComm ) ;
2012-09-27 07:22:31 +00:00
nextEmulator = snes ;
2012-10-03 15:31:04 +00:00
snes . Load ( game , rom . FileData , null , deterministicemulation ) ;
2012-09-27 07:22:31 +00:00
}
2012-09-04 06:08:46 +00:00
break ;
2011-08-09 00:51:46 +00:00
case "SMS" :
case "SG" :
if ( Global . Config . SmsEnableFM ) game . AddOption ( "UseFM" ) ;
if ( Global . Config . SmsAllowOverlock ) game . AddOption ( "AllowOverclock" ) ;
if ( Global . Config . SmsForceStereoSeparation ) game . AddOption ( "ForceStereo" ) ;
2011-09-24 16:09:40 +00:00
if ( Global . Config . SmsSpriteLimit ) game . AddOption ( "SpriteLimit" ) ;
2012-12-10 00:43:43 +00:00
nextEmulator = new SMS ( nextComm , game , rom . RomData ) ;
2011-08-09 00:51:46 +00:00
break ;
case "GG" :
if ( Global . Config . SmsAllowOverlock ) game . AddOption ( "AllowOverclock" ) ;
2011-09-24 16:09:40 +00:00
if ( Global . Config . SmsSpriteLimit ) game . AddOption ( "SpriteLimit" ) ;
2012-12-10 00:43:43 +00:00
nextEmulator = new SMS ( nextComm , game , rom . RomData ) ;
2011-08-09 00:51:46 +00:00
break ;
2012-03-07 00:40:20 +00:00
case "A26" :
2012-12-10 00:43:43 +00:00
nextEmulator = new Atari2600 ( nextComm , game , rom . FileData ) ;
2012-04-29 02:48:33 +00:00
( ( Atari2600 ) nextEmulator ) . SetBw ( Global . Config . Atari2600_BW ) ;
( ( Atari2600 ) nextEmulator ) . SetP0Diff ( Global . Config . Atari2600_LeftDifficulty ) ;
( ( Atari2600 ) nextEmulator ) . SetP1Diff ( Global . Config . Atari2600_RightDifficulty ) ;
2012-03-07 00:40:20 +00:00
break ;
2011-08-09 00:51:46 +00:00
case "PCE" :
2011-09-24 17:05:34 +00:00
case "PCECD" :
2011-08-09 00:51:46 +00:00
case "SGX" :
2011-09-24 16:09:40 +00:00
if ( Global . Config . PceSpriteLimit ) game . AddOption ( "ForceSpriteLimit" ) ;
2012-12-10 00:43:43 +00:00
nextEmulator = new PCEngine ( nextComm , game , rom . RomData ) ;
2011-08-09 00:51:46 +00:00
break ;
case "GEN" :
2012-12-10 00:43:43 +00:00
nextEmulator = new Genesis ( nextComm , game , rom . RomData ) ;
2011-08-09 00:51:46 +00:00
break ;
case "TI83" :
2012-12-10 00:43:43 +00:00
nextEmulator = new TI83 ( nextComm , game , rom . RomData ) ;
2011-08-09 00:51:46 +00:00
if ( Global . Config . TI83autoloadKeyPad )
LoadTI83KeyPad ( ) ;
break ;
case "NES" :
{
2012-12-30 17:33:33 +00:00
string biosPath = PathManager . StandardFirmwareName ( Global . Config . FilenameFDSBios ) ;
2012-10-21 15:58:24 +00:00
byte [ ] bios = null ;
if ( File . Exists ( biosPath ) )
2012-10-22 18:33:34 +00:00
{
2012-10-21 15:58:24 +00:00
bios = File . ReadAllBytes ( biosPath ) ;
2012-10-22 18:33:34 +00:00
// ines header + 24KB of garbage + actual bios + 8KB of garbage
if ( bios . Length = = 40976 )
{
MessageBox . Show ( this , "Your FDS BIOS is a bad dump. BizHawk will attempt to use it, but no guarantees! You should find a new one." ) ;
byte [ ] tmp = new byte [ 8192 ] ;
Buffer . BlockCopy ( bios , 16 + 8192 * 3 , tmp , 0 , 8192 ) ;
bios = tmp ;
}
}
2012-10-21 15:58:24 +00:00
2012-12-10 00:43:43 +00:00
NES nes = new NES ( nextComm , game , rom . FileData , bios ) ;
2012-03-15 19:16:43 +00:00
nes . SoundOn = Global . Config . SoundEnabled ;
2011-09-04 01:12:12 +00:00
nes . FirstDrawLine = Global . Config . NESTopLine ;
nes . LastDrawLine = Global . Config . NESBottomLine ;
2011-09-04 01:58:16 +00:00
nes . SetClipLeftAndRight ( Global . Config . NESClipLeftAndRight ) ;
2011-08-09 00:51:46 +00:00
nextEmulator = nes ;
if ( Global . Config . NESAutoLoadPalette & & Global . Config . NESPaletteFile . Length > 0 & &
HawkFile . ExistsAt ( Global . Config . NESPaletteFile ) )
{
nes . SetPalette (
NES . Palettes . Load_FCEUX_Palette ( HawkFile . ReadAllBytes ( Global . Config . NESPaletteFile ) ) ) ;
}
}
break ;
case "GB" :
2012-10-06 22:02:24 +00:00
case "GBC" :
2013-02-24 20:17:12 +00:00
//if (false) // this code will load up a dual game boy
//{
// // this is horrible. we MUST decide when we should be using Game.System and when we should be using Emulator.SystemID
// game.System = "DGB"; // HACK
// if (Global.Config.GB_ForceDMG) game.AddOption("ForceDMG");
// if (Global.Config.GB_GBACGB) game.AddOption("GBACGB");
// if (Global.Config.GB_MulticartCompat) game.AddOption("MulitcartCompat");
// GambatteLink gbl = new GambatteLink(nextComm, game, rom.FileData, game, rom.FileData);
// nextEmulator = gbl;
// // other stuff todo
//}
//else
//{
2012-12-29 01:25:06 +00:00
if ( ! Global . Config . GB_AsSGB )
2012-11-18 18:46:57 +00:00
{
2012-12-29 01:25:06 +00:00
if ( Global . Config . GB_ForceDMG ) game . AddOption ( "ForceDMG" ) ;
if ( Global . Config . GB_GBACGB ) game . AddOption ( "GBACGB" ) ;
if ( Global . Config . GB_MulticartCompat ) game . AddOption ( "MulitcartCompat" ) ;
Emulation . Consoles . GB . Gameboy gb = new Emulation . Consoles . GB . Gameboy ( nextComm , game , rom . FileData ) ;
nextEmulator = gb ;
if ( gb . IsCGBMode ( ) )
{
gb . SetCGBColors ( Global . Config . CGBColors ) ;
}
else
{
try
{
using ( StreamReader f = new StreamReader ( Global . Config . GB_PaletteFile ) )
{
int [ ] colors = GBtools . ColorChooserForm . LoadPalFile ( f ) ;
if ( colors ! = null )
gb . ChangeDMGColors ( colors ) ;
}
}
catch { }
}
2012-11-18 18:46:57 +00:00
}
else
2012-09-15 23:50:18 +00:00
{
2012-12-29 01:25:06 +00:00
// todo: get these bioses into a gamedb?? then we could demand different filenames for different regions?
2012-12-30 17:33:33 +00:00
string sgbromPath = PathManager . StandardFirmwareName ( "sgb.sfc" ) ; //Path.Combine(PathManager.MakeAbsolutePath(Global.Config.PathSNESFirmwares, "SNES"), "sgb.sfc");
2012-12-29 01:25:06 +00:00
byte [ ] sgbrom = null ;
2012-11-18 18:46:57 +00:00
try
2012-09-26 15:59:14 +00:00
{
2012-12-29 01:25:06 +00:00
if ( File . Exists ( sgbromPath ) )
{
sgbrom = File . ReadAllBytes ( sgbromPath ) ;
}
else
2012-11-18 18:46:57 +00:00
{
2012-12-29 01:25:06 +00:00
MessageBox . Show ( "Couldn't open sgb.sfc from the configured SNES firmwares path, which is:\n\n" + sgbromPath + "\n\nPlease make sure it is available and try again.\n\nWe're going to disable SGB for now; please re-enable it when you've set up the file." ) ;
Global . Config . GB_AsSGB = false ;
game . System = "GB" ;
goto RETRY ;
2012-11-18 18:46:57 +00:00
}
2012-09-26 15:59:14 +00:00
}
2012-12-29 01:25:06 +00:00
catch ( Exception )
2012-10-05 04:47:45 +00:00
{
2012-12-29 01:25:06 +00:00
// failed to load SGB bios. to avoid catch-22, disable SGB mode
Global . Config . GB_AsSGB = false ;
throw ;
2012-10-05 04:47:45 +00:00
}
2012-12-29 01:25:06 +00:00
if ( sgbrom ! = null )
2012-10-05 04:47:45 +00:00
{
2012-12-29 01:25:06 +00:00
game . System = "SNES" ;
game . AddOption ( "SGB" ) ;
nextComm . SNES_ExePath = SNES_Prepare ( Global . Config . SNESProfile ) ;
var snes = new LibsnesCore ( nextComm ) ;
nextEmulator = snes ;
game . FirmwareHash = Util . BytesToHexString ( System . Security . Cryptography . SHA1 . Create ( ) . ComputeHash ( sgbrom ) ) ;
snes . Load ( game , rom . FileData , sgbrom , deterministicemulation ) ;
2012-10-05 04:47:45 +00:00
}
2012-09-29 23:21:55 +00:00
}
2013-02-24 20:17:12 +00:00
//}
2011-08-09 00:51:46 +00:00
break ;
2012-11-17 21:12:51 +00:00
case "Coleco" :
2012-12-30 17:33:33 +00:00
string colbiosPath = PathManager . StandardFirmwareName ( Global . Config . FilenameCOLBios ) ;
2012-11-25 01:32:17 +00:00
FileInfo colfile = new FileInfo ( colbiosPath ) ;
if ( ! colfile . Exists )
{
MessageBox . Show ( "Unable to find the required ColecoVision BIOS file - \n" + colbiosPath , "Unable to load BIOS" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
2012-11-25 03:47:58 +00:00
throw new Exception ( ) ;
2012-11-25 01:32:17 +00:00
}
else
{
2012-12-10 00:43:43 +00:00
ColecoVision c = new ColecoVision ( nextComm , game , rom . RomData , colbiosPath , Global . Config . ColecoSkipBiosIntro ) ;
2012-11-25 01:32:17 +00:00
nextEmulator = c ;
}
2012-05-06 00:54:13 +00:00
break ;
2012-09-04 06:08:46 +00:00
case "INTV" :
2012-09-07 06:18:58 +00:00
{
2012-12-10 00:43:43 +00:00
Intellivision intv = new Intellivision ( nextComm , game , rom . RomData ) ;
2012-12-30 17:33:33 +00:00
string eromPath = PathManager . StandardFirmwareName ( Global . Config . FilenameINTVEROM ) ;
2012-09-07 06:18:58 +00:00
if ( ! File . Exists ( eromPath ) )
throw new InvalidOperationException ( "Specified EROM path does not exist:\n\n" + eromPath ) ;
intv . LoadExecutiveRom ( eromPath ) ;
2012-12-30 17:33:33 +00:00
string gromPath = PathManager . StandardFirmwareName ( Global . Config . FilenameINTVGROM ) ;
2012-09-07 06:18:58 +00:00
if ( ! File . Exists ( gromPath ) )
throw new InvalidOperationException ( "Specified GROM path does not exist:\n\n" + gromPath ) ;
intv . LoadGraphicsRom ( gromPath ) ;
nextEmulator = intv ;
}
2012-09-04 06:08:46 +00:00
break ;
2012-10-23 03:33:57 +00:00
case "A78" :
2012-12-30 17:33:33 +00:00
string ntsc_biospath = PathManager . StandardFirmwareName ( Global . Config . FilenameA78NTSCBios ) ;
string pal_biospath = PathManager . StandardFirmwareName ( Global . Config . FilenameA78PALBios ) ;
string hsbiospath = PathManager . StandardFirmwareName ( Global . Config . FilenameA78HSCBios ) ;
2012-11-27 02:24:15 +00:00
FileInfo ntscfile = new FileInfo ( ntsc_biospath ) ;
FileInfo palfile = new FileInfo ( pal_biospath ) ;
FileInfo hsfile = new FileInfo ( hsbiospath ) ;
2012-12-27 22:24:42 +00:00
byte [ ] NTSC_BIOS7800 = null ;
byte [ ] PAL_BIOS7800 = null ;
byte [ ] HighScoreBIOS = null ;
2012-11-27 02:24:15 +00:00
if ( ! ntscfile . Exists )
{
2012-12-27 22:24:42 +00:00
MessageBox . Show ( "Unable to find the required Atari 7800 BIOS file - \n" + ntsc_biospath + "\nIf the selected game requires it, it may crash" , "Unable to load BIOS" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
//throw new Exception();
}
else
{
NTSC_BIOS7800 = File . ReadAllBytes ( ntsc_biospath ) ;
2012-11-27 02:24:15 +00:00
}
if ( ! palfile . Exists )
{
2012-12-27 22:24:42 +00:00
MessageBox . Show ( "Unable to find the required Atari 7800 BIOS file - \n" + pal_biospath + "\nIf the selected game requires it, it may crash" , "Unable to load BIOS" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
//throw new Exception();
}
else
{
PAL_BIOS7800 = File . ReadAllBytes ( pal_biospath ) ;
2012-11-27 02:24:15 +00:00
}
if ( ! hsfile . Exists )
{
2012-12-27 22:24:42 +00:00
MessageBox . Show ( "Unable to find the required Atari 7800 BIOS file - \n" + hsbiospath + "\nIf the selected game requires it, it may crash" , "Unable to load BIOS" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
//throw new Exception();
}
else
{
HighScoreBIOS = File . ReadAllBytes ( hsbiospath ) ;
2012-11-27 02:24:15 +00:00
}
2012-11-20 03:17:53 +00:00
2012-12-12 03:40:18 +00:00
string gamedbpath = Path . Combine ( PathManager . GetExeDirectoryAbsolute ( ) , "gamedb" , "EMU7800.csv" ) ;
2012-12-12 18:17:30 +00:00
var a78 = new BizHawk . Emulation . Atari7800 ( nextComm , game , rom . RomData , NTSC_BIOS7800 , PAL_BIOS7800 , HighScoreBIOS , gamedbpath ) ;
2012-10-23 03:33:57 +00:00
nextEmulator = a78 ;
break ;
2012-11-01 16:48:32 +00:00
case "C64" :
2012-12-10 00:43:43 +00:00
C64 c64 = new C64 ( nextComm , game , rom . RomData , rom . Extension ) ;
2012-11-06 06:19:27 +00:00
c64 . HardReset ( ) ;
2012-11-01 17:06:14 +00:00
nextEmulator = c64 ;
2012-11-01 16:48:32 +00:00
break ;
2012-11-19 22:43:34 +00:00
case "GBA" :
2012-12-01 18:53:13 +00:00
if ( INTERIM )
2012-11-24 22:23:31 +00:00
{
2012-12-30 17:33:33 +00:00
string gbabiospath = PathManager . StandardFirmwareName ( Global . Config . FilenameGBABIOS ) ;
2012-12-01 18:53:13 +00:00
byte [ ] gbabios = null ;
if ( File . Exists ( gbabiospath ) )
{
gbabios = File . ReadAllBytes ( gbabiospath ) ;
}
else
{
MessageBox . Show ( "Unable to find the required GBA BIOS file - \n" + gbabios , "Unable to load BIOS" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
throw new Exception ( ) ;
}
2012-12-10 20:24:21 +00:00
GBA gba = new GBA ( nextComm ) ;
//var gba = new GarboDev.GbaManager(nextComm);
2012-12-01 18:53:13 +00:00
gba . Load ( rom . RomData , gbabios ) ;
nextEmulator = gba ;
2012-11-20 03:17:53 +00:00
}
2012-11-19 22:43:34 +00:00
break ;
2011-08-09 00:51:46 +00:00
}
}
if ( nextEmulator = = null )
2012-10-06 20:59:44 +00:00
throw new Exception ( "No core could load the rom." ) ;
2011-07-24 06:45:05 +00:00
}
2011-08-04 03:20:54 +00:00
catch ( Exception ex )
2011-07-24 06:45:05 +00:00
{
2011-08-04 03:20:54 +00:00
MessageBox . Show ( "Exception during loadgame:\n\n" + ex . ToString ( ) ) ;
return false ;
2011-03-07 10:41:46 +00:00
}
2011-08-09 00:51:46 +00:00
2012-10-06 20:59:44 +00:00
if ( nextEmulator = = null ) throw new Exception ( "No core could load the rom." ) ;
2011-07-24 06:45:05 +00:00
2011-03-07 10:41:46 +00:00
CloseGame ( ) ;
2011-06-11 12:54:26 +00:00
Global . Emulator . Dispose ( ) ;
2011-03-07 10:41:46 +00:00
Global . Emulator = nextEmulator ;
2012-12-10 00:43:43 +00:00
Global . CoreComm = nextComm ;
2011-03-07 10:41:46 +00:00
Global . Game = game ;
2012-12-10 00:43:43 +00:00
SyncCoreCommInputSignals ( ) ;
2011-04-06 05:43:59 +00:00
SyncControls ( ) ;
2011-03-07 10:41:46 +00:00
2012-11-25 20:06:31 +00:00
if ( nextEmulator is LibsnesCore )
{
var snes = nextEmulator as LibsnesCore ;
snes . SetPalette ( ( SnesColors . ColorType ) Enum . Parse ( typeof ( SnesColors . ColorType ) , Global . Config . SNESPalette , false ) ) ;
}
2011-06-18 21:39:53 +00:00
if ( game . System = = "NES" )
{
2011-09-24 20:38:48 +00:00
NES nes = Global . Emulator as NES ;
2012-10-21 15:58:24 +00:00
if ( nes . GameName ! = null )
Global . Game . Name = nes . GameName ;
2011-09-24 20:38:48 +00:00
Global . Game . Status = nes . RomStatus ;
2012-07-12 23:13:22 +00:00
SetNESSoundChannels ( ) ;
2011-06-18 21:39:53 +00:00
}
2011-03-07 10:41:46 +00:00
2011-04-21 23:22:33 +00:00
Text = DisplayNameForSystem ( game . System ) + " - " + game . Name ;
2011-03-07 01:07:49 +00:00
ResetRewindBuffer ( ) ;
2012-04-16 08:18:41 +00:00
2012-12-10 00:43:43 +00:00
if ( Global . Emulator . CoreComm . RomStatusDetails = = null )
2012-10-08 20:37:41 +00:00
{
2012-12-10 00:43:43 +00:00
Global . Emulator . CoreComm . RomStatusDetails =
2012-10-08 20:37:41 +00:00
string . Format ( "{0}\r\nSHA1:{1}\r\nMD5:{2}\r\n" ,
game . Name ,
Util . BytesToHexString ( System . Security . Cryptography . SHA1 . Create ( ) . ComputeHash ( rom . RomData ) ) ,
Util . BytesToHexString ( System . Security . Cryptography . MD5 . Create ( ) . ComputeHash ( rom . RomData ) ) ) ;
}
2012-04-16 08:18:41 +00:00
//restarts the lua console if a different rom is loaded.
//im not really a fan of how this is done..
2013-03-10 22:42:54 +00:00
if ( Global . Config . RecentRoms . IsEmpty | | Global . Config . RecentRoms . GetRecentFileByPosition ( 0 ) ! = file . CanonicalFullPath )
2012-04-16 08:18:41 +00:00
{
2012-04-02 19:50:26 +00:00
#if WINDOWS
2012-04-16 08:18:41 +00:00
LuaConsole1 . Restart ( ) ;
2012-04-02 19:50:26 +00:00
#endif
2012-04-16 08:18:41 +00:00
}
2011-05-21 19:31:00 +00:00
Global . Config . RecentRoms . Add ( file . CanonicalFullPath ) ;
2011-08-04 03:20:54 +00:00
if ( File . Exists ( PathManager . SaveRamPath ( game ) ) )
2011-03-07 01:07:49 +00:00
LoadSaveRam ( ) ;
2012-01-10 02:11:17 +00:00
if ( Global . Config . AutoSavestates )
LoadState ( "Auto" ) ;
2011-03-07 01:07:49 +00:00
2011-09-16 00:40:33 +00:00
////setup the throttle based on platform's specifications
////(one day later for some systems we will need to modify it at runtime as the display mode changes)
//{
2012-12-10 00:43:43 +00:00
// throttle.SetCoreFps(Global.Emulator.CoreComm.VsyncRate);
2011-09-16 00:40:33 +00:00
// SyncThrottle();
//}
2011-03-07 01:07:49 +00:00
RamSearch1 . Restart ( ) ;
2011-06-11 12:54:26 +00:00
RamWatch1 . Restart ( ) ;
2011-03-07 01:07:49 +00:00
HexEditor1 . Restart ( ) ;
2011-06-11 12:54:26 +00:00
NESPPU1 . Restart ( ) ;
NESNameTableViewer1 . Restart ( ) ;
NESDebug1 . Restart ( ) ;
2012-11-05 04:09:04 +00:00
GBGPUView1 . Restart ( ) ;
2012-11-26 23:16:31 +00:00
GBAGPUView1 . Restart ( ) ;
2012-03-12 05:19:59 +00:00
PCEBGViewer1 . Restart ( ) ;
2011-06-11 12:54:26 +00:00
TI83KeyPad1 . Restart ( ) ;
2011-07-30 17:59:18 +00:00
TAStudio1 . Restart ( ) ;
2012-10-29 22:57:15 +00:00
VirtualPadForm1 . Restart ( ) ;
2011-08-07 01:16:55 +00:00
Cheats1 . Restart ( ) ;
2012-01-10 02:11:17 +00:00
ToolBox1 . Restart ( ) ;
2012-09-30 13:38:37 +00:00
TraceLogger1 . Restart ( ) ;
2012-01-10 02:11:17 +00:00
2011-06-11 12:54:26 +00:00
if ( Global . Config . LoadCheatFileByGame )
{
2011-08-06 22:03:10 +00:00
if ( Global . CheatList . AttemptLoadCheatFile ( ) )
2012-09-01 17:44:55 +00:00
{
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "Cheats file loaded" ) ;
2012-09-01 17:44:55 +00:00
}
2011-06-11 12:54:26 +00:00
}
2012-09-01 19:29:41 +00:00
Cheats1 . UpdateValues ( ) ;
2011-08-07 01:16:55 +00:00
2011-06-12 22:55:34 +00:00
CurrentlyOpenRom = file . CanonicalFullPath ;
2011-06-11 12:54:26 +00:00
HandlePlatformMenus ( ) ;
2011-07-31 23:25:00 +00:00
StateSlots . Clear ( ) ;
2011-08-26 23:54:15 +00:00
UpdateStatusSlots ( ) ;
2011-07-10 15:36:41 +00:00
UpdateDumpIcon ( ) ;
2012-05-28 04:59:22 +00:00
2012-08-19 04:41:34 +00:00
CaptureRewindState ( ) ;
2012-05-28 04:59:22 +00:00
2012-09-15 13:11:29 +00:00
Global . StickyXORAdapter . ClearStickies ( ) ;
Global . AutofireStickyXORAdapter . ClearStickies ( ) ;
sound api changes. added a new ISyncSoundProvider, which works similarly to ISoundProvider except the source (not the sink) determines the number of samples to process. Added facilities to metaspu, dcfilter, speexresampler to work with ISyncSoundProvider. Add ISyncSoundProvider to IEmulator. All IEmulators must provide sync sound, but they need not provide async sound. When async is needed and an IEmulator doesn't provide it, the frontend will wrap it in a vecna metaspu. SNES, GB changed to provide sync sound only. All other emulator cores mostly unchanged; they just provide stub fakesync alongside async, for now. For the moment, the only use of the sync sound is for realtime audio throttling, where it works and sounds quite nice. In the future, sync sound will be supported for AV dumping as well.
2012-10-11 00:44:59 +00:00
RewireSound ( ) ;
2011-03-07 01:07:49 +00:00
return true ;
2011-02-21 09:48:53 +00:00
}
2011-02-20 08:40:22 +00:00
}
sound api changes. added a new ISyncSoundProvider, which works similarly to ISoundProvider except the source (not the sink) determines the number of samples to process. Added facilities to metaspu, dcfilter, speexresampler to work with ISyncSoundProvider. Add ISyncSoundProvider to IEmulator. All IEmulators must provide sync sound, but they need not provide async sound. When async is needed and an IEmulator doesn't provide it, the frontend will wrap it in a vecna metaspu. SNES, GB changed to provide sync sound only. All other emulator cores mostly unchanged; they just provide stub fakesync alongside async, for now. For the moment, the only use of the sync sound is for realtime audio throttling, where it works and sounds quite nice. In the future, sync sound will be supported for AV dumping as well.
2012-10-11 00:44:59 +00:00
void RewireSound ( )
{
if ( DumpProxy ! = null )
{
// we're video dumping, so async mode only and use the DumpProxy.
// note that the avi dumper has already rewired the emulator itself in this case.
Global . Sound . SetAsyncInputPin ( DumpProxy ) ;
}
else if ( Global . Config . SoundThrottle )
{
// for sound throttle, use sync mode
Global . Emulator . EndAsyncSound ( ) ;
Global . Sound . SetSyncInputPin ( Global . Emulator . SyncSoundProvider ) ;
}
else
{
// for vsync\clock throttle modes, use async
if ( ! Global . Emulator . StartAsyncSound ( ) )
{
// if the core doesn't support async mode, use a standard vecna wrapper
Global . Sound . SetAsyncInputPin ( new Emulation . Sound . MetaspuAsync ( Global . Emulator . SyncSoundProvider , Emulation . Sound . ESynchMethod . ESynchMethod_V ) ) ;
}
else
{
Global . Sound . SetAsyncInputPin ( Global . Emulator . SoundProvider ) ;
}
}
}
2011-07-10 15:36:41 +00:00
private void UpdateDumpIcon ( )
{
2011-07-10 21:00:28 +00:00
DumpStatus . Image = BizHawk . MultiClient . Properties . Resources . Blank ;
DumpStatus . ToolTipText = "" ;
if ( Global . Emulator = = null ) return ;
2011-07-22 01:34:21 +00:00
if ( Global . Game = = null ) return ;
2011-07-10 21:00:28 +00:00
2011-08-04 03:20:54 +00:00
var status = Global . Game . Status ;
2011-07-10 21:00:28 +00:00
string annotation = "" ;
if ( status = = RomStatus . BadDump )
2011-07-10 15:36:41 +00:00
{
2011-07-10 21:00:28 +00:00
DumpStatus . Image = BizHawk . MultiClient . Properties . Resources . ExclamationRed ;
annotation = "Warning: Bad ROM Dump" ;
}
else if ( status = = RomStatus . Overdump )
{
DumpStatus . Image = BizHawk . MultiClient . Properties . Resources . ExclamationRed ;
annotation = "Warning: Overdump" ;
}
else if ( status = = RomStatus . NotInDatabase )
{
DumpStatus . Image = BizHawk . MultiClient . Properties . Resources . RetroQuestion ;
annotation = "Warning: Unknown ROM" ;
}
else if ( status = = RomStatus . TranslatedRom )
{
DumpStatus . Image = BizHawk . MultiClient . Properties . Resources . Translation ;
annotation = "Translated ROM" ;
}
else if ( status = = RomStatus . Homebrew )
{
DumpStatus . Image = BizHawk . MultiClient . Properties . Resources . HomeBrew ;
annotation = "Homebrew ROM" ;
}
else if ( Global . Game . Status = = RomStatus . Hack )
{
DumpStatus . Image = BizHawk . MultiClient . Properties . Resources . Hack ;
annotation = "Hacked ROM" ;
2011-07-10 15:36:41 +00:00
}
2012-04-16 08:18:41 +00:00
else if ( Global . Game . Status = = RomStatus . Unknown )
{
DumpStatus . Image = BizHawk . MultiClient . Properties . Resources . Hack ;
annotation = "Warning: ROM of Unknown Character" ;
}
2011-07-10 15:36:41 +00:00
else
{
2011-07-10 21:00:28 +00:00
DumpStatus . Image = BizHawk . MultiClient . Properties . Resources . GreenCheck ;
annotation = "Verified good dump" ;
2011-07-10 15:36:41 +00:00
}
2012-12-10 00:43:43 +00:00
if ( ! string . IsNullOrEmpty ( Global . Emulator . CoreComm . RomStatusAnnotation ) )
annotation = Global . Emulator . CoreComm . RomStatusAnnotation ;
2011-07-10 21:00:28 +00:00
DumpStatus . ToolTipText = annotation ;
2011-07-10 15:36:41 +00:00
}
2012-09-04 07:09:00 +00:00
2011-02-20 08:40:22 +00:00
private void LoadSaveRam ( )
{
2012-09-04 07:09:00 +00:00
//zero says: this is sort of sketchy... but this is no time for rearchitecting
2011-08-09 00:51:46 +00:00
try
{
2012-11-24 02:25:47 +00:00
byte [ ] sram ;
// GBA core might not know how big the saveram ought to be, so just send it the whole file
if ( Global . Emulator is GBA )
{
sram = File . ReadAllBytes ( PathManager . SaveRamPath ( Global . Game ) ) ;
}
2012-09-10 23:40:53 +00:00
else
2012-11-24 02:25:47 +00:00
{
sram = new byte [ Global . Emulator . ReadSaveRam ( ) . Length ] ;
using ( var reader = new BinaryReader ( new FileStream ( PathManager . SaveRamPath ( Global . Game ) , FileMode . Open , FileAccess . Read ) ) )
2012-09-14 22:28:38 +00:00
reader . Read ( sram , 0 , sram . Length ) ;
2012-11-24 02:25:47 +00:00
}
2012-09-14 22:28:38 +00:00
Global . Emulator . StoreSaveRam ( sram ) ;
2011-08-09 00:51:46 +00:00
}
2012-10-27 13:57:26 +00:00
catch ( IOException ) { }
2011-02-20 08:40:22 +00:00
}
2011-08-09 00:51:46 +00:00
private static void SaveRam ( )
{
string path = PathManager . SaveRamPath ( Global . Game ) ;
2011-08-04 03:20:54 +00:00
2011-08-09 00:51:46 +00:00
var f = new FileInfo ( path ) ;
if ( f . Directory . Exists = = false )
f . Directory . Create ( ) ;
2011-08-04 03:20:54 +00:00
2012-09-29 15:32:44 +00:00
//Make backup first
if ( Global . Config . BackupSaveram & & f . Exists = = true )
{
string backup = path + ".bak" ;
var backupFile = new FileInfo ( backup ) ;
if ( backupFile . Exists = = true )
backupFile . Delete ( ) ;
f . CopyTo ( backup ) ;
}
2011-08-09 00:51:46 +00:00
var writer = new BinaryWriter ( new FileStream ( path , FileMode . Create , FileAccess . Write ) ) ;
2012-09-14 22:28:38 +00:00
var saveram = Global . Emulator . ReadSaveRam ( ) ;
// this assumes that the default state of the core's sram is 0-filled, so don't do
// int len = Util.SaveRamBytesUsed(saveram);
int len = saveram . Length ;
writer . Write ( saveram , 0 , len ) ;
2011-08-09 00:51:46 +00:00
writer . Close ( ) ;
}
2011-08-04 03:20:54 +00:00
2011-07-09 22:09:39 +00:00
void OnSelectSlot ( int num )
{
2011-09-17 00:04:50 +00:00
Global . Config . SaveSlot = num ;
2011-07-09 22:09:39 +00:00
SaveSlotSelectedMessage ( ) ;
2011-08-09 00:51:46 +00:00
UpdateStatusSlots ( ) ;
2011-07-09 22:09:39 +00:00
}
2011-07-24 23:14:16 +00:00
/// <summary>
/// Controls whether the app generates input events. should be turned off for most modal dialogs
/// </summary>
public bool AllowInput
{
get
{
//the main form gets input
2011-08-27 02:45:02 +00:00
if ( Form . ActiveForm = = this ) return true ;
2011-08-09 00:51:46 +00:00
2011-07-24 23:14:16 +00:00
//modals that need to capture input for binding purposes get input, of course
2012-10-02 00:23:37 +00:00
if ( Form . ActiveForm is HotkeyWindow ) return true ;
if ( Form . ActiveForm is ControllerConfig ) return true ;
2012-12-02 01:56:30 +00:00
if ( Form . ActiveForm is TAStudio ) return true ;
2011-07-24 23:14:16 +00:00
//if no form is active on this process, then the background input setting applies
if ( Form . ActiveForm = = null & & Global . Config . AcceptBackgroundInput ) return true ;
return false ;
}
}
2011-07-10 07:39:40 +00:00
public void ProcessInput ( )
2011-06-11 12:54:26 +00:00
{
2011-08-09 00:51:46 +00:00
for ( ; ; )
2011-06-11 12:54:26 +00:00
{
2011-07-10 07:39:40 +00:00
//loop through all available events
2011-07-09 22:09:39 +00:00
var ie = Input . Instance . DequeueEvent ( ) ;
2012-03-24 15:55:22 +00:00
if ( ie = = null ) { break ; }
2011-06-11 12:54:26 +00:00
2011-07-10 19:50:59 +00:00
//useful debugging:
//Console.WriteLine(ie);
2011-07-09 22:09:39 +00:00
//TODO - wonder what happens if we pop up something interactive as a response to one of these hotkeys? may need to purge further processing
2011-06-11 12:54:26 +00:00
2012-09-10 04:13:02 +00:00
//look for hotkey bindings for this key
2011-07-09 22:09:39 +00:00
var triggers = Global . ClientControls . SearchBindings ( ie . LogicalButton . ToString ( ) ) ;
2011-07-10 02:14:58 +00:00
if ( triggers . Count = = 0 )
{
2012-09-10 04:13:02 +00:00
//bool sys_hotkey = false;
2011-07-10 19:50:59 +00:00
//maybe it is a system alt-key which hasnt been overridden
if ( ie . EventType = = Input . InputEventType . Press )
{
if ( ie . LogicalButton . Alt & & ie . LogicalButton . Button . Length = = 1 )
{
char c = ie . LogicalButton . Button . ToLower ( ) [ 0 ] ;
2011-08-09 00:51:46 +00:00
if ( c > = 'a' & & c < = 'z' | | c = = ' ' )
2011-07-10 19:50:59 +00:00
{
SendAltKeyChar ( c ) ;
2012-09-10 04:16:30 +00:00
//sys_hotkey = true;
2011-07-10 19:50:59 +00:00
}
}
if ( ie . LogicalButton . Alt & & ie . LogicalButton . Button = = "Space" )
{
SendPlainAltKey ( 32 ) ;
2012-09-10 04:16:30 +00:00
//sys_hotkey = true;
2011-07-10 19:50:59 +00:00
}
}
//ordinarily, an alt release with nothing else would move focus to the menubar. but that is sort of useless, and hard to implement exactly right.
2011-08-09 00:51:46 +00:00
2012-09-10 04:13:02 +00:00
//????????????
2011-07-10 19:50:59 +00:00
//no hotkeys or system keys bound this, so mutate it to an unmodified key and assign it for use as a game controller input
2011-07-10 07:39:40 +00:00
//(we have a rule that says: modified events may be used for game controller inputs but not hotkeys)
2012-09-10 04:13:02 +00:00
//if (!sys_hotkey)
//{
// var mutated_ie = new Input.InputEvent();
// mutated_ie.EventType = ie.EventType;
// mutated_ie.LogicalButton = ie.LogicalButton;
// mutated_ie.LogicalButton.Modifiers = Input.ModifierKey.None;
// Global.ControllerInputCoalescer.Receive(ie);
//}
2011-07-10 02:14:58 +00:00
}
2011-07-10 07:39:40 +00:00
2012-09-10 04:13:02 +00:00
//zero 09-sep-2012 - all input is eligible for controller input. not sure why the above was done.
//maybe because it doesnt make sense to me to bind hotkeys and controller inputs to the same keystrokes
2012-12-02 15:18:28 +00:00
//adelikat 02-dec-2012 - implemented options for how to handle controller vs hotkey conflicts. This is primarily motivated by computer emulation and thus controller being nearly the entire keyboard
bool handled ;
switch ( Global . Config . Input_Hotkey_OverrideOptions )
2011-07-09 22:09:39 +00:00
{
2012-12-02 15:18:28 +00:00
default :
case 0 : //Both allowed
Global . ControllerInputCoalescer . Receive ( ie ) ;
2011-07-10 02:14:58 +00:00
2012-12-02 15:18:28 +00:00
handled = false ;
if ( ie . EventType = = Input . InputEventType . Press )
{
foreach ( var trigger in triggers )
{
handled | = CheckHotkey ( trigger ) ;
}
}
//hotkeys which arent handled as actions get coalesced as pollable virtual client buttons
if ( ! handled )
{
Global . HotkeyCoalescer . Receive ( ie ) ;
}
break ;
case 1 : //Input overrides Hokeys
Global . ControllerInputCoalescer . Receive ( ie ) ;
bool inputisbound = Global . ActiveController . HasBinding ( ie . LogicalButton . ToString ( ) ) ;
if ( ! inputisbound )
{
handled = false ;
if ( ie . EventType = = Input . InputEventType . Press )
{
foreach ( var trigger in triggers )
{
handled | = CheckHotkey ( trigger ) ;
}
}
//hotkeys which arent handled as actions get coalesced as pollable virtual client buttons
if ( ! handled )
{
Global . HotkeyCoalescer . Receive ( ie ) ;
}
}
break ;
case 2 : //Hotkeys override Input
handled = false ;
if ( ie . EventType = = Input . InputEventType . Press )
{
foreach ( var trigger in triggers )
{
handled | = CheckHotkey ( trigger ) ;
}
}
//hotkeys which arent handled as actions get coalesced as pollable virtual client buttons
if ( ! handled )
{
Global . HotkeyCoalescer . Receive ( ie ) ;
Global . ControllerInputCoalescer . Receive ( ie ) ;
}
break ;
2011-07-10 07:39:40 +00:00
}
2011-08-09 00:51:46 +00:00
2011-07-10 07:39:40 +00:00
} //foreach event
2011-07-10 02:14:58 +00:00
2011-07-10 07:39:40 +00:00
}
2012-09-15 13:11:29 +00:00
private void ClearAutohold ( )
{
Global . StickyXORAdapter . ClearStickies ( ) ;
Global . AutofireStickyXORAdapter . ClearStickies ( ) ;
2012-10-29 22:57:15 +00:00
VirtualPadForm1 . ClearVirtualPadHolds ( ) ;
2012-09-15 13:11:29 +00:00
Global . OSD . AddMessage ( "Autohold keys cleared" ) ;
}
2011-07-10 07:39:40 +00:00
bool CheckHotkey ( string trigger )
{
//todo - could have these in a table somehow ?
switch ( trigger )
{
default :
return false ;
2012-09-15 16:43:16 +00:00
case "SNES Toggle BG 1" :
SNES_ToggleBG1 ( ) ;
break ;
case "SNES Toggle BG 2" :
SNES_ToggleBG2 ( ) ;
break ;
case "SNES Toggle BG 3" :
SNES_ToggleBG3 ( ) ;
break ;
case "SNES Toggle BG 4" :
SNES_ToggleBG4 ( ) ;
break ;
case "SNES Toggle OBJ 1" :
SNES_ToggleOBJ1 ( ) ;
break ;
case "SNES Toggle OBJ 2" :
SNES_ToggleOBJ2 ( ) ;
break ;
case "SNES Toggle OBJ 3" :
SNES_ToggleOBJ3 ( ) ;
break ;
case "SNES Toggle OBJ 4" :
SNES_ToggleOBJ4 ( ) ;
break ;
2012-10-28 23:38:41 +00:00
case "Save Movie" :
SaveMovie ( ) ;
break ;
2012-09-15 13:11:29 +00:00
case "Clear Autohold" :
ClearAutohold ( ) ;
break ;
2012-03-28 02:32:05 +00:00
case "IncreaseWindowSize" :
IncreaseWindowSize ( ) ;
break ;
case "DecreaseWindowSize" :
DecreaseWIndowSize ( ) ;
break ;
2012-09-09 19:52:08 +00:00
case "Record AVI/WAV" :
2011-07-12 00:05:14 +00:00
RecordAVI ( ) ;
break ;
2012-09-09 19:52:08 +00:00
case "Stop AVI/WAV" :
2011-07-12 00:05:14 +00:00
StopAVI ( ) ;
break ;
2011-07-10 07:39:40 +00:00
case "ToolBox" :
LoadToolBox ( ) ;
break ;
2012-07-12 21:39:11 +00:00
case "Increase Speed" :
IncreaseSpeed ( ) ;
break ;
case "Decrease Speed" :
DecreaseSpeed ( ) ;
break ;
2012-07-12 21:56:59 +00:00
case "Toggle Background Input" :
ToggleBackgroundInput ( ) ;
break ;
2011-07-10 07:39:40 +00:00
case "Quick Save State" :
if ( ! IsNullEmulator ( ) )
2012-03-30 12:26:36 +00:00
SaveState ( "QuickSave" + Global . Config . SaveSlot . ToString ( ) ) ;
2011-07-10 07:39:40 +00:00
break ;
2011-07-09 22:09:39 +00:00
2011-07-10 07:39:40 +00:00
case "Quick Load State" :
if ( ! IsNullEmulator ( ) )
2011-09-17 00:04:50 +00:00
LoadState ( "QuickSave" + Global . Config . SaveSlot . ToString ( ) ) ;
2011-07-10 07:39:40 +00:00
break ;
2011-07-09 22:09:39 +00:00
2011-07-10 07:39:40 +00:00
case "Unthrottle" :
unthrottled ^ = true ;
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "Unthrottled: " + unthrottled ) ;
2011-07-10 07:39:40 +00:00
break ;
2011-07-09 22:09:39 +00:00
2012-09-16 17:10:33 +00:00
case "Reboot Core" :
2012-01-28 21:43:55 +00:00
{
bool autoSaveState = Global . Config . AutoSavestates ;
Global . Config . AutoSavestates = false ;
LoadRom ( CurrentlyOpenRom ) ;
Global . Config . AutoSavestates = autoSaveState ;
break ;
}
2011-07-09 22:09:39 +00:00
2012-09-16 17:10:33 +00:00
case "Hard Reset" :
HardReset ( ) ;
break ;
2011-07-10 07:39:40 +00:00
case "Screenshot" :
TakeScreenshot ( ) ;
break ;
2011-07-09 22:09:39 +00:00
2011-07-10 07:39:40 +00:00
case "SaveSlot0" : if ( ! IsNullEmulator ( ) ) SaveState ( "QuickSave0" ) ; break ;
case "SaveSlot1" : if ( ! IsNullEmulator ( ) ) SaveState ( "QuickSave1" ) ; break ;
case "SaveSlot2" : if ( ! IsNullEmulator ( ) ) SaveState ( "QuickSave2" ) ; break ;
case "SaveSlot3" : if ( ! IsNullEmulator ( ) ) SaveState ( "QuickSave3" ) ; break ;
case "SaveSlot4" : if ( ! IsNullEmulator ( ) ) SaveState ( "QuickSave4" ) ; break ;
case "SaveSlot5" : if ( ! IsNullEmulator ( ) ) SaveState ( "QuickSave5" ) ; break ;
case "SaveSlot6" : if ( ! IsNullEmulator ( ) ) SaveState ( "QuickSave6" ) ; break ;
case "SaveSlot7" : if ( ! IsNullEmulator ( ) ) SaveState ( "QuickSave7" ) ; break ;
case "SaveSlot8" : if ( ! IsNullEmulator ( ) ) SaveState ( "QuickSave8" ) ; break ;
case "SaveSlot9" : if ( ! IsNullEmulator ( ) ) SaveState ( "QuickSave9" ) ; break ;
case "LoadSlot0" : if ( ! IsNullEmulator ( ) ) LoadState ( "QuickSave0" ) ; break ;
case "LoadSlot1" : if ( ! IsNullEmulator ( ) ) LoadState ( "QuickSave1" ) ; break ;
case "LoadSlot2" : if ( ! IsNullEmulator ( ) ) LoadState ( "QuickSave2" ) ; break ;
case "LoadSlot3" : if ( ! IsNullEmulator ( ) ) LoadState ( "QuickSave3" ) ; break ;
case "LoadSlot4" : if ( ! IsNullEmulator ( ) ) LoadState ( "QuickSave4" ) ; break ;
case "LoadSlot5" : if ( ! IsNullEmulator ( ) ) LoadState ( "QuickSave5" ) ; break ;
case "LoadSlot6" : if ( ! IsNullEmulator ( ) ) LoadState ( "QuickSave6" ) ; break ;
case "LoadSlot7" : if ( ! IsNullEmulator ( ) ) LoadState ( "QuickSave7" ) ; break ;
case "LoadSlot8" : if ( ! IsNullEmulator ( ) ) LoadState ( "QuickSave8" ) ; break ;
case "LoadSlot9" : if ( ! IsNullEmulator ( ) ) LoadState ( "QuickSave9" ) ; break ;
2012-03-24 15:55:22 +00:00
case "SelectSlot0" : OnSelectSlot ( 0 ) ; break ;
case "SelectSlot1" : OnSelectSlot ( 1 ) ; break ;
case "SelectSlot2" : OnSelectSlot ( 2 ) ; break ;
case "SelectSlot3" : OnSelectSlot ( 3 ) ; break ;
case "SelectSlot4" : OnSelectSlot ( 4 ) ; break ;
2011-07-10 07:39:40 +00:00
case "SelectSlot5" : OnSelectSlot ( 5 ) ; break ;
case "SelectSlot6" : OnSelectSlot ( 6 ) ; break ;
case "SelectSlot7" : OnSelectSlot ( 7 ) ; break ;
case "SelectSlot8" : OnSelectSlot ( 8 ) ; break ;
case "SelectSlot9" : OnSelectSlot ( 9 ) ; break ;
case "Toggle Fullscreen" : ToggleFullscreen ( ) ; break ;
case "Save Named State" : SaveStateAs ( ) ; break ;
case "Load Named State" : LoadStateAs ( ) ; break ;
case "Previous Slot" : PreviousSlot ( ) ; break ;
case "Next Slot" : NextSlot ( ) ; break ;
2012-08-15 01:14:25 +00:00
case "Ram Watch" : LoadRamWatch ( true ) ; break ;
2011-07-10 07:39:40 +00:00
case "Ram Search" : LoadRamSearch ( ) ; break ;
case "Ram Poke" :
{
RamPoke r = new RamPoke ( ) ;
r . Show ( ) ;
break ;
}
case "Hex Editor" : LoadHexEditor ( ) ; break ;
2012-04-24 00:11:58 +00:00
case "Lua Console" : OpenLuaConsole ( ) ; break ;
2011-07-10 07:39:40 +00:00
case "Cheats" : LoadCheatsWindow ( ) ; break ;
2012-04-24 00:11:58 +00:00
case "TASTudio" : LoadTAStudio ( ) ; break ;
2012-11-23 17:03:10 +00:00
case "Virtual Pad" : LoadVirtualPads ( ) ; break ;
2012-04-24 00:11:58 +00:00
case "Open ROM" : OpenROM ( ) ; break ;
2011-07-10 07:39:40 +00:00
case "Close ROM" : CloseROM ( ) ; break ;
case "Display FPS" : ToggleFPS ( ) ; break ;
case "Display FrameCounter" : ToggleFrameCounter ( ) ; break ;
case "Display LagCounter" : ToggleLagCounter ( ) ; break ;
case "Display Input" : ToggleInputDisplay ( ) ; break ;
case "Toggle Read Only" : ToggleReadOnly ( ) ; break ;
2012-04-24 00:11:58 +00:00
case "Play Movie" : PlayMovie ( ) ; break ;
case "Record Movie" : RecordMovie ( ) ; break ;
2011-07-22 01:34:21 +00:00
case "Stop Movie" : StopMovie ( ) ; break ;
2011-07-10 07:39:40 +00:00
case "Play Beginning" : PlayMovieFromBeginning ( ) ; break ;
case "Volume Up" : VolumeUp ( ) ; break ;
case "Volume Down" : VolumeDown ( ) ; break ;
case "Soft Reset" : SoftReset ( ) ; break ;
case "Toggle MultiTrack" :
{
2012-09-03 19:42:53 +00:00
if ( Global . MovieSession . Movie . IsActive )
2011-07-10 07:39:40 +00:00
{
2013-03-09 19:54:50 +00:00
if ( Global . Config . VBAStyleMovieLoadState )
2011-08-17 02:06:50 +00:00
{
2013-03-09 19:54:50 +00:00
Global . OSD . AddMessage ( "Multi-track can not be used in Full Movie Loadstates mode" ) ;
2011-08-17 02:06:50 +00:00
}
else
2013-03-09 19:54:50 +00:00
{
Global . MovieSession . MultiTrack . IsActive = ! Global . MovieSession . MultiTrack . IsActive ;
if ( Global . MovieSession . MultiTrack . IsActive )
{
Global . OSD . AddMessage ( "MultiTrack Enabled" ) ;
Global . OSD . MT = "Recording None" ;
}
else
{
Global . OSD . AddMessage ( "MultiTrack Disabled" ) ;
}
Global . MovieSession . MultiTrack . RecordAll = false ;
Global . MovieSession . MultiTrack . CurrentPlayer = 0 ;
}
2011-07-10 07:39:40 +00:00
}
else
2011-08-17 02:06:50 +00:00
{
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "MultiTrack cannot be enabled while not recording." ) ;
2011-08-17 02:06:50 +00:00
}
2011-07-10 07:39:40 +00:00
break ;
}
case "Increment Player" :
{
2011-07-24 23:14:16 +00:00
Global . MovieSession . MultiTrack . CurrentPlayer + + ;
Global . MovieSession . MultiTrack . RecordAll = false ;
if ( Global . MovieSession . MultiTrack . CurrentPlayer > 5 ) //TODO: Replace with console's maximum or current maximum players??!
2011-07-10 07:39:40 +00:00
{
2011-07-24 23:14:16 +00:00
Global . MovieSession . MultiTrack . CurrentPlayer = 1 ;
2011-07-10 07:39:40 +00:00
}
2012-04-16 08:18:41 +00:00
Global . OSD . MT = "Recording Player " + Global . MovieSession . MultiTrack . CurrentPlayer . ToString ( ) ;
2011-07-10 07:39:40 +00:00
break ;
}
case "Decrement Player" :
{
2011-07-24 23:14:16 +00:00
Global . MovieSession . MultiTrack . CurrentPlayer - - ;
Global . MovieSession . MultiTrack . RecordAll = false ;
2011-08-09 00:51:46 +00:00
if ( Global . MovieSession . MultiTrack . CurrentPlayer < 1 )
2011-07-10 07:39:40 +00:00
{
2012-02-24 07:48:06 +00:00
Global . MovieSession . MultiTrack . CurrentPlayer = 5 ; //TODO: Replace with console's maximum or current maximum players??!
2011-07-10 07:39:40 +00:00
}
2012-04-16 08:18:41 +00:00
Global . OSD . MT = "Recording Player " + Global . MovieSession . MultiTrack . CurrentPlayer . ToString ( ) ;
2011-07-10 07:39:40 +00:00
break ;
}
case "Record All" :
{
2011-07-24 23:14:16 +00:00
Global . MovieSession . MultiTrack . CurrentPlayer = 0 ;
Global . MovieSession . MultiTrack . RecordAll = true ;
2012-04-16 08:18:41 +00:00
Global . OSD . MT = "Recording All" ;
2011-07-10 07:39:40 +00:00
break ;
}
case "Record None" :
{
2011-07-24 23:14:16 +00:00
Global . MovieSession . MultiTrack . CurrentPlayer = 0 ;
Global . MovieSession . MultiTrack . RecordAll = false ;
2012-04-16 08:18:41 +00:00
Global . OSD . MT = "Recording None" ;
2011-07-10 07:39:40 +00:00
break ;
}
case "Emulator Pause" :
//used to be here: (the pause hotkey is ignored when we are frame advancing)
TogglePause ( ) ;
break ;
2011-10-01 03:43:37 +00:00
case "Toggle Menu" :
ShowHideMenu ( ) ;
break ;
2013-03-09 23:11:00 +00:00
case "MoviePokeToggle" :
ToggleModePokeMode ( ) ;
break ;
2011-07-10 07:39:40 +00:00
} //switch(trigger)
return true ;
2011-06-11 12:54:26 +00:00
}
2011-02-21 09:48:53 +00:00
void StepRunLoop_Throttle ( )
{
2011-06-11 12:54:26 +00:00
SyncThrottle ( ) ;
2011-02-21 09:48:53 +00:00
throttle . signal_frameAdvance = runloop_frameadvance ;
throttle . signal_continuousframeAdvancing = runloop_frameProgress ;
throttle . Step ( true , - 1 ) ;
}
2011-02-20 08:40:22 +00:00
void StepRunLoop_Core ( )
{
2011-06-11 12:54:26 +00:00
bool runFrame = false ;
2011-02-21 09:48:53 +00:00
runloop_frameadvance = false ;
DateTime now = DateTime . Now ;
2011-02-23 06:40:04 +00:00
bool suppressCaptureRewind = false ;
2011-02-20 08:40:22 +00:00
2011-02-21 09:48:53 +00:00
double frameAdvanceTimestampDelta = ( now - FrameAdvanceTimestamp ) . TotalMilliseconds ;
bool frameProgressTimeElapsed = Global . Config . FrameProgressDelayMs < frameAdvanceTimestampDelta ;
2011-02-20 08:40:22 +00:00
2012-08-02 21:30:30 +00:00
if ( Global . Config . SkipLagFrame & & Global . Emulator . IsLagFrame & & frameProgressTimeElapsed )
2012-03-16 15:27:45 +00:00
{
2012-09-20 20:00:14 +00:00
Global . Emulator . FrameAdvance ( true ) ;
2012-03-16 15:27:45 +00:00
}
2012-03-07 03:58:54 +00:00
2011-07-24 17:35:53 +00:00
if ( Global . ClientControls [ "Frame Advance" ] | | PressFrameAdvance )
2011-02-20 08:40:22 +00:00
{
2011-02-21 09:48:53 +00:00
//handle the initial trigger of a frame advance
if ( FrameAdvanceTimestamp = = DateTime . MinValue )
2011-02-20 08:40:22 +00:00
{
2011-08-19 01:36:41 +00:00
PauseEmulator ( ) ;
2011-02-20 08:40:22 +00:00
runFrame = true ;
2011-02-21 09:48:53 +00:00
runloop_frameadvance = true ;
FrameAdvanceTimestamp = now ;
2011-02-20 08:40:22 +00:00
}
else
{
2011-02-21 09:48:53 +00:00
//handle the timed transition from countdown to FrameProgress
if ( frameProgressTimeElapsed )
{
runFrame = true ;
runloop_frameProgress = true ;
UnpauseEmulator ( ) ;
}
2011-02-20 08:40:22 +00:00
}
}
2011-02-21 09:48:53 +00:00
else
2011-02-20 08:40:22 +00:00
{
2011-02-21 09:48:53 +00:00
//handle release of frame advance: do we need to deactivate FrameProgress?
if ( runloop_frameProgress )
{
runloop_frameProgress = false ;
PauseEmulator ( ) ;
}
FrameAdvanceTimestamp = DateTime . MinValue ;
2011-02-20 08:40:22 +00:00
}
2012-03-16 15:27:45 +00:00
if ( ! EmulatorPaused )
{
runFrame = true ;
}
2011-02-20 08:40:22 +00:00
2012-09-03 19:42:53 +00:00
bool ReturnToRecording = Global . MovieSession . Movie . IsRecording ;
2012-05-28 00:44:27 +00:00
if ( Global . Config . RewindEnabled & & ( Global . ClientControls [ "Rewind" ] | | PressRewind ) )
2011-02-20 08:40:22 +00:00
{
2011-07-26 01:08:38 +00:00
Rewind ( 1 ) ;
suppressCaptureRewind = true ;
2012-05-28 01:29:43 +00:00
if ( 0 = = RewindBuf . Count )
{
runFrame = false ;
}
else
{
runFrame = true ;
}
2012-05-30 00:52:08 +00:00
//we don't want to capture input when rewinding, even in record mode
2012-09-03 19:42:53 +00:00
if ( Global . MovieSession . Movie . IsRecording )
{
2012-09-03 20:17:57 +00:00
Global . MovieSession . Movie . SwitchToPlay ( ) ;
2012-09-03 19:42:53 +00:00
}
2011-07-26 01:08:38 +00:00
}
2012-09-03 19:42:53 +00:00
if ( UpdateFrame = = true )
2012-06-01 05:49:26 +00:00
{
runFrame = true ;
2012-09-03 19:42:53 +00:00
if ( Global . MovieSession . Movie . IsRecording )
{
2012-09-03 20:17:57 +00:00
Global . MovieSession . Movie . SwitchToPlay ( ) ;
2012-09-03 19:42:53 +00:00
}
2012-06-01 05:49:26 +00:00
}
2011-02-20 08:40:22 +00:00
2011-02-21 19:06:54 +00:00
bool genSound = false ;
2012-10-11 01:00:36 +00:00
bool coreskipaudio = false ;
2011-02-20 08:40:22 +00:00
if ( runFrame )
{
2012-10-11 22:37:44 +00:00
bool ff = Global . ClientControls [ "Fast Forward" ] | | Global . ClientControls [ "MaxTurbo" ] ;
bool fff = Global . ClientControls [ "MaxTurbo" ] ;
bool updateFpsString = ( runloop_last_ff ! = ff ) ;
runloop_last_ff = ff ;
if ( ! fff )
{
UpdateToolsBefore ( ) ;
}
2012-11-18 15:25:55 +00:00
Global . ClickyVirtualPadController . FrameTick ( ) ;
2012-08-28 01:29:07 +00:00
runloop_fps + + ;
2012-01-28 21:43:55 +00:00
//client input-related duties
2012-04-16 08:18:41 +00:00
Global . OSD . ClearGUIText ( ) ;
2011-06-11 12:54:26 +00:00
2011-03-16 06:30:25 +00:00
if ( ( DateTime . Now - runloop_second ) . TotalSeconds > 1 )
{
2011-06-10 07:12:57 +00:00
runloop_last_fps = runloop_fps ;
2011-03-16 06:30:25 +00:00
runloop_second = DateTime . Now ;
runloop_fps = 0 ;
2011-06-10 07:12:57 +00:00
updateFpsString = true ;
}
if ( updateFpsString )
{
string fps_string = runloop_last_fps + " fps" ;
2012-08-28 01:29:07 +00:00
if ( fff )
{
fps_string + = " >>>>" ;
}
else if ( ff )
{
fps_string + = " >>" ;
}
2012-04-16 08:18:41 +00:00
Global . OSD . FPS = fps_string ;
2011-03-16 06:30:25 +00:00
}
2011-06-11 12:54:26 +00:00
if ( ! suppressCaptureRewind & & Global . Config . RewindEnabled ) CaptureRewindState ( ) ;
2012-06-03 01:18:13 +00:00
2011-02-21 19:06:54 +00:00
if ( ! runloop_frameadvance ) genSound = true ;
else if ( ! Global . Config . MuteFrameAdvance )
genSound = true ;
2011-06-11 12:54:26 +00:00
2012-08-25 23:31:54 +00:00
HandleMovieOnFrameLoop ( ) ;
2011-06-27 05:31:46 +00:00
2012-10-11 01:00:36 +00:00
coreskipaudio = Global . ClientControls [ "MaxTurbo" ] & & CurrAviWriter = = null ;
2011-06-27 05:31:46 +00:00
//=======================================
2011-08-09 00:51:46 +00:00
MemoryPulse . Pulse ( ) ;
2012-10-19 14:51:10 +00:00
Global . Emulator . FrameAdvance ( ! throttle . skipnextframe | | CurrAviWriter ! = null , ! coreskipaudio ) ;
2011-08-09 00:51:46 +00:00
MemoryPulse . Pulse ( ) ;
2011-06-27 05:31:46 +00:00
//=======================================
2011-07-11 07:35:14 +00:00
2013-02-26 00:36:13 +00:00
if ( ! PauseAVI )
{
AVIFrameAdvance ( ) ;
}
2012-11-26 21:08:08 +00:00
2011-08-29 22:25:40 +00:00
if ( Global . Emulator . IsLagFrame & & Global . Config . AutofireLagFrames )
2011-08-29 03:28:34 +00:00
{
Global . AutoFireController . IncrementStarts ( ) ;
}
2012-03-16 15:27:45 +00:00
PressFrameAdvance = false ;
2012-08-28 01:29:07 +00:00
if ( ! fff )
{
UpdateToolsAfter ( ) ;
}
2012-05-28 01:29:43 +00:00
}
if ( Global . ClientControls [ "Rewind" ] | | PressRewind )
{
UpdateToolsAfter ( ) ;
2012-05-30 00:52:08 +00:00
if ( ReturnToRecording )
2012-08-02 21:30:30 +00:00
{
2012-09-03 20:17:57 +00:00
Global . MovieSession . Movie . SwitchToRecord ( ) ;
2012-08-02 21:30:30 +00:00
}
2012-05-28 01:29:43 +00:00
PressRewind = false ;
}
2013-02-26 00:36:13 +00:00
if ( UpdateFrame )
2012-06-01 05:49:26 +00:00
{
if ( ReturnToRecording )
2012-08-02 21:30:30 +00:00
{
2012-09-03 20:17:57 +00:00
Global . MovieSession . Movie . SwitchToRecord ( ) ;
2012-08-02 21:30:30 +00:00
}
2012-06-01 05:49:26 +00:00
UpdateFrame = false ;
}
2012-05-28 01:29:43 +00:00
2012-10-11 01:00:36 +00:00
if ( genSound & & ! coreskipaudio )
2012-05-28 01:29:43 +00:00
{
sound api changes. added a new ISyncSoundProvider, which works similarly to ISoundProvider except the source (not the sink) determines the number of samples to process. Added facilities to metaspu, dcfilter, speexresampler to work with ISyncSoundProvider. Add ISyncSoundProvider to IEmulator. All IEmulators must provide sync sound, but they need not provide async sound. When async is needed and an IEmulator doesn't provide it, the frontend will wrap it in a vecna metaspu. SNES, GB changed to provide sync sound only. All other emulator cores mostly unchanged; they just provide stub fakesync alongside async, for now. For the moment, the only use of the sync sound is for realtime audio throttling, where it works and sounds quite nice. In the future, sync sound will be supported for AV dumping as well.
2012-10-11 00:44:59 +00:00
Global . Sound . UpdateSound ( ) ;
2012-05-28 01:29:43 +00:00
}
else
sound api changes. added a new ISyncSoundProvider, which works similarly to ISoundProvider except the source (not the sink) determines the number of samples to process. Added facilities to metaspu, dcfilter, speexresampler to work with ISyncSoundProvider. Add ISyncSoundProvider to IEmulator. All IEmulators must provide sync sound, but they need not provide async sound. When async is needed and an IEmulator doesn't provide it, the frontend will wrap it in a vecna metaspu. SNES, GB changed to provide sync sound only. All other emulator cores mostly unchanged; they just provide stub fakesync alongside async, for now. For the moment, the only use of the sync sound is for realtime audio throttling, where it works and sounds quite nice. In the future, sync sound will be supported for AV dumping as well.
2012-10-11 00:44:59 +00:00
Global . Sound . UpdateSilence ( ) ;
2011-02-20 08:40:22 +00:00
}
2012-10-13 21:10:20 +00:00
2012-08-25 23:31:54 +00:00
2011-07-09 00:26:23 +00:00
/// <summary>
2012-05-28 00:44:27 +00:00
/// Update all tools that are frame dependent like Ram Search before processing
2011-07-09 00:26:23 +00:00
/// </summary>
2012-10-13 12:44:52 +00:00
public void UpdateToolsBefore ( bool fromLua = false )
2011-07-09 00:26:23 +00:00
{
2012-10-06 16:13:45 +00:00
#if WINDOWS
2012-10-13 12:44:52 +00:00
if ( ! fromLua )
LuaConsole1 . StartLuaDrawing ( ) ;
2012-09-02 16:23:42 +00:00
LuaConsole1 . LuaImp . FrameRegisterBefore ( ) ;
2012-10-13 12:44:52 +00:00
2012-10-06 16:13:45 +00:00
#endif
2011-07-09 00:26:23 +00:00
NESNameTableViewer1 . UpdateValues ( ) ;
NESPPU1 . UpdateValues ( ) ;
2012-03-12 05:19:59 +00:00
PCEBGViewer1 . UpdateValues ( ) ;
2012-11-05 01:34:11 +00:00
GBGPUView1 . UpdateValues ( ) ;
2012-11-26 23:16:31 +00:00
GBAGPUView1 . UpdateValues ( ) ;
2012-09-22 05:03:52 +00:00
}
public void UpdateToolsLoadstate ( )
{
SNESGraphicsDebugger1 . UpdateToolsLoadstate ( ) ;
2011-07-09 00:26:23 +00:00
}
2012-05-28 00:44:27 +00:00
/// <summary>
/// Update all tools that are frame dependent like Ram Search after processing
/// </summary>
2012-10-13 12:44:52 +00:00
public void UpdateToolsAfter ( bool fromLua = false )
2012-05-28 01:29:43 +00:00
{
2012-10-06 14:24:12 +00:00
#if WINDOWS
2012-10-13 12:44:52 +00:00
if ( ! fromLua )
LuaConsole1 . ResumeScripts ( true ) ;
2012-10-06 14:24:12 +00:00
#endif
2012-10-04 21:56:40 +00:00
RamWatch1 . UpdateValues ( ) ;
RamSearch1 . UpdateValues ( ) ;
HexEditor1 . UpdateValues ( ) ;
2012-05-28 01:29:43 +00:00
//The other tool updates are earlier, TAStudio needs to be later so it can display the latest
//frame of execution in its list view.
2012-10-13 12:44:52 +00:00
2012-06-07 04:47:54 +00:00
TAStudio1 . UpdateValues ( ) ;
2012-10-29 22:57:15 +00:00
VirtualPadForm1 . UpdateValues ( ) ;
2012-09-22 05:03:52 +00:00
SNESGraphicsDebugger1 . UpdateToolsAfter ( ) ;
2012-09-30 00:53:08 +00:00
TraceLogger1 . UpdateValues ( ) ;
2012-12-08 18:00:55 +00:00
HandleToggleLight ( ) ;
2012-10-06 16:13:45 +00:00
#if WINDOWS
LuaConsole1 . LuaImp . FrameRegisterAfter ( ) ;
2012-10-13 12:44:52 +00:00
if ( ! fromLua )
{
Global . DisplayManager . PreFrameUpdateLuaSource ( ) ;
LuaConsole1 . EndLuaDrawing ( ) ;
}
2012-10-06 16:13:45 +00:00
#endif
2012-05-28 01:29:43 +00:00
}
2012-05-28 00:44:27 +00:00
2012-03-04 01:30:30 +00:00
private unsafe Image MakeScreenshotImage ( )
2011-06-11 12:54:26 +00:00
{
var video = Global . Emulator . VideoProvider ;
var image = new Bitmap ( video . BufferWidth , video . BufferHeight , PixelFormat . Format32bppArgb ) ;
2011-02-20 08:40:22 +00:00
2012-03-04 01:30:30 +00:00
//TODO - replace with BitmapBuffer
2011-06-11 12:54:26 +00:00
var framebuf = video . GetVideoBuffer ( ) ;
2012-03-30 12:26:36 +00:00
var bmpdata = image . LockBits ( new Rectangle ( 0 , 0 , image . Width , image . Height ) , ImageLockMode . WriteOnly , PixelFormat . Format32bppArgb ) ;
2012-03-04 01:30:30 +00:00
int * ptr = ( int * ) bmpdata . Scan0 . ToPointer ( ) ;
2012-03-30 12:26:36 +00:00
int stride = bmpdata . Stride / 4 ;
2011-06-11 12:54:26 +00:00
for ( int y = 0 ; y < video . BufferHeight ; y + + )
for ( int x = 0 ; x < video . BufferWidth ; x + + )
2011-07-10 01:55:37 +00:00
{
int col = framebuf [ ( y * video . BufferWidth ) + x ] ;
if ( Global . Emulator is TI83 )
{
if ( col = = 0 )
col = Color . Black . ToArgb ( ) ;
else
col = Color . White . ToArgb ( ) ;
}
2012-03-04 01:30:30 +00:00
ptr [ y * stride + x ] = col ;
2011-07-10 01:55:37 +00:00
}
2012-03-04 01:30:30 +00:00
image . UnlockBits ( bmpdata ) ;
return image ;
2011-06-11 12:54:26 +00:00
}
2011-05-21 02:51:47 +00:00
2012-10-27 00:19:43 +00:00
public void TakeScreenshotToClipboard ( )
2012-03-18 04:08:05 +00:00
{
2012-09-22 04:04:35 +00:00
using ( var img = Global . Config . Screenshot_CaptureOSD ? CaptureOSD ( ) : MakeScreenshotImage ( ) )
2012-03-18 04:08:05 +00:00
{
System . Windows . Forms . Clipboard . SetImage ( img ) ;
}
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "Screenshot saved to clipboard." ) ;
2012-03-18 04:08:05 +00:00
}
2012-10-26 23:48:28 +00:00
public void TakeScreenshot ( )
2011-05-21 02:51:47 +00:00
{
2012-03-04 01:30:30 +00:00
string path = String . Format ( PathManager . ScreenshotPrefix ( Global . Game ) + ".{0:yyyy-MM-dd HH.mm.ss}.png" , DateTime . Now ) ;
TakeScreenshot ( path ) ;
2012-03-04 19:02:28 +00:00
/ * int frames = 120 ;
int skip = 1 ;
int speed = 1 ;
bool reversable = true ;
string path = String . Format ( PathManager . ScreenshotPrefix ( Global . Game ) + frames + "Frames-Skip=" + skip + "-Speed=" + speed + "-reversable=" + reversable + ".gif" ) ;
makeAnimatedGif ( frames , skip , speed , reversable , path ) ; * /
//Was using this code to test the animated gif functions
2012-03-04 01:30:30 +00:00
}
2012-10-26 23:48:28 +00:00
public void TakeScreenshot ( string path )
2012-03-04 01:30:30 +00:00
{
var fi = new FileInfo ( path ) ;
if ( fi . Directory . Exists = = false )
fi . Directory . Create ( ) ;
2012-09-22 04:04:35 +00:00
using ( var img = Global . Config . Screenshot_CaptureOSD ? CaptureOSD ( ) : MakeScreenshotImage ( ) )
2012-03-04 01:30:30 +00:00
{
img . Save ( fi . FullName , ImageFormat . Png ) ;
}
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( fi . Name + " saved." ) ;
2011-02-20 08:40:22 +00:00
}
2012-02-03 12:18:27 +00:00
public void SaveState ( string name )
2011-02-20 08:40:22 +00:00
{
2011-08-04 03:20:54 +00:00
string path = PathManager . SaveStatePrefix ( Global . Game ) + "." + name + ".State" ;
2011-02-20 08:40:22 +00:00
var file = new FileInfo ( path ) ;
if ( file . Directory . Exists = = false )
file . Directory . Create ( ) ;
2011-07-31 21:39:54 +00:00
//Make backup first
if ( Global . Config . BackupSavestates & & file . Exists = = true )
{
string backup = path + ".bak" ;
var backupFile = new FileInfo ( backup ) ;
if ( backupFile . Exists = = true )
backupFile . Delete ( ) ;
file . CopyTo ( backup ) ;
}
2011-02-20 08:40:22 +00:00
var writer = new StreamWriter ( path ) ;
2012-03-18 18:24:24 +00:00
SaveStateFile ( writer , name , false ) ;
2012-03-28 01:03:50 +00:00
LuaConsole1 . LuaImp . SavestateRegisterSave ( name ) ;
2011-07-31 20:57:14 +00:00
}
2012-03-18 18:24:24 +00:00
public void SaveStateFile ( StreamWriter writer , string name , bool fromLua )
2011-07-31 20:57:14 +00:00
{
2011-02-20 08:40:22 +00:00
Global . Emulator . SaveStateText ( writer ) ;
2011-06-11 12:54:26 +00:00
HandleMovieSaveState ( writer ) ;
2011-09-24 16:19:38 +00:00
if ( Global . Config . SaveScreenshotWithStates )
{
2012-08-25 18:18:05 +00:00
writer . Write ( "Framebuffer " ) ;
Global . Emulator . VideoProvider . GetVideoBuffer ( ) . SaveAsHex ( writer ) ;
2011-09-24 16:19:38 +00:00
}
2011-09-11 21:08:41 +00:00
2011-02-20 08:40:22 +00:00
writer . Close ( ) ;
2012-03-18 18:24:24 +00:00
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "Saved state: " + name ) ;
2012-03-18 18:24:24 +00:00
if ( ! fromLua )
{
2012-03-30 12:26:36 +00:00
2012-03-18 18:24:24 +00:00
UpdateStatusSlots ( ) ;
}
2011-02-20 08:40:22 +00:00
}
2011-06-11 12:54:26 +00:00
private void SaveStateAs ( )
{
2012-04-22 13:56:34 +00:00
if ( IsNullEmulator ( ) ) return ;
2011-06-11 12:54:26 +00:00
var sfd = new SaveFileDialog ( ) ;
2012-04-22 13:56:34 +00:00
string path = PathManager . GetSaveStatePath ( Global . Game ) ;
2011-06-11 12:54:26 +00:00
sfd . InitialDirectory = path ;
2011-09-24 16:25:16 +00:00
sfd . FileName = PathManager . SaveStatePrefix ( Global . Game ) + "." + "QuickSave0.State" ;
2011-06-11 12:54:26 +00:00
var file = new FileInfo ( path ) ;
if ( file . Directory . Exists = = false )
file . Directory . Create ( ) ;
2012-03-08 12:37:40 +00:00
Global . Sound . StopSound ( ) ;
2011-06-11 12:54:26 +00:00
var result = sfd . ShowDialog ( ) ;
2012-03-08 12:37:40 +00:00
Global . Sound . StartSound ( ) ;
2011-06-11 12:54:26 +00:00
if ( result ! = DialogResult . OK )
return ;
var writer = new StreamWriter ( sfd . FileName ) ;
2012-03-18 18:24:24 +00:00
SaveStateFile ( writer , sfd . FileName , false ) ;
2011-06-11 12:54:26 +00:00
}
2012-10-13 12:44:52 +00:00
public void LoadStateFile ( string path , string name , bool fromLua = false )
2011-06-11 12:54:26 +00:00
{
2011-08-20 19:27:00 +00:00
if ( HandleMovieLoadState ( path ) )
2011-07-31 16:41:27 +00:00
{
2011-08-20 19:27:00 +00:00
var reader = new StreamReader ( path ) ;
2011-07-31 16:41:27 +00:00
Global . Emulator . LoadStateText ( reader ) ;
2011-09-11 21:08:41 +00:00
while ( true )
{
2011-09-24 16:19:38 +00:00
string str = reader . ReadLine ( ) ;
if ( str = = null ) break ;
if ( str . Trim ( ) = = "" ) continue ;
string [ ] args = str . Split ( ' ' ) ;
2011-09-15 23:32:21 +00:00
if ( args [ 0 ] = = "Framebuffer" )
2012-08-25 18:18:05 +00:00
{
2011-09-24 16:19:38 +00:00
Global . Emulator . VideoProvider . GetVideoBuffer ( ) . ReadFromHex ( args [ 1 ] ) ;
2012-08-25 18:18:05 +00:00
}
2011-09-11 21:08:41 +00:00
}
2011-09-24 16:19:38 +00:00
reader . Close ( ) ;
2012-08-19 23:22:10 +00:00
Global . OSD . ClearGUIText ( ) ;
2012-10-13 12:44:52 +00:00
UpdateToolsBefore ( fromLua ) ;
UpdateToolsAfter ( fromLua ) ;
2012-09-22 05:03:52 +00:00
UpdateToolsLoadstate ( ) ;
2012-05-28 01:29:43 +00:00
Global . OSD . AddMessage ( "Loaded state: " + name ) ;
2012-10-13 12:44:52 +00:00
LuaConsole1 . LuaImp . SavestateRegisterLoad ( name ) ;
2011-07-31 16:41:27 +00:00
}
2011-07-31 17:35:02 +00:00
else
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "Loadstate error!" ) ;
2011-06-11 12:54:26 +00:00
}
2011-05-22 19:52:49 +00:00
2012-10-13 12:44:52 +00:00
public void LoadState ( string name , bool fromLua = false )
2011-05-16 15:38:48 +00:00
{
2011-08-04 03:20:54 +00:00
string path = PathManager . SaveStatePrefix ( Global . Game ) + "." + name + ".State" ;
2011-05-16 15:38:48 +00:00
if ( File . Exists ( path ) = = false )
2012-09-17 01:52:17 +00:00
{
Global . OSD . AddMessage ( "Unable to load " + name + ".State" ) ;
2011-05-16 15:38:48 +00:00
return ;
2012-09-17 01:52:17 +00:00
}
2011-05-16 15:38:48 +00:00
2012-10-13 12:44:52 +00:00
LoadStateFile ( path , name , fromLua ) ;
2011-02-20 08:40:22 +00:00
}
2011-06-11 12:54:26 +00:00
private void LoadStateAs ( )
{
2012-04-22 13:56:34 +00:00
if ( IsNullEmulator ( ) ) return ;
2011-06-11 12:54:26 +00:00
var ofd = new OpenFileDialog ( ) ;
2012-04-22 13:56:34 +00:00
ofd . InitialDirectory = PathManager . GetSaveStatePath ( Global . Game ) ;
2011-07-25 01:30:18 +00:00
ofd . Filter = "Save States (*.State)|*.State|All Files|*.*" ;
2011-06-11 12:54:26 +00:00
ofd . RestoreDirectory = true ;
2011-04-11 00:22:17 +00:00
2011-06-11 12:54:26 +00:00
Global . Sound . StopSound ( ) ;
var result = ofd . ShowDialog ( ) ;
Global . Sound . StartSound ( ) ;
2011-04-11 00:22:17 +00:00
2011-06-11 12:54:26 +00:00
if ( result ! = DialogResult . OK )
return ;
2011-04-11 00:22:17 +00:00
2011-06-11 12:54:26 +00:00
if ( File . Exists ( ofd . FileName ) = = false )
return ;
LoadStateFile ( ofd . FileName , Path . GetFileName ( ofd . FileName ) ) ;
}
2011-04-11 00:22:17 +00:00
2011-02-20 08:40:22 +00:00
private void SaveSlotSelectedMessage ( )
{
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "Slot " + Global . Config . SaveSlot + " selected." ) ;
2011-02-20 08:40:22 +00:00
}
private void UpdateAutoLoadRecentRom ( )
{
if ( Global . Config . AutoLoadMostRecentRom = = true )
{
autoloadMostRecentToolStripMenuItem . Checked = false ;
Global . Config . AutoLoadMostRecentRom = false ;
}
else
{
autoloadMostRecentToolStripMenuItem . Checked = true ;
Global . Config . AutoLoadMostRecentRom = true ;
}
}
2011-06-11 12:54:26 +00:00
private void UpdateAutoLoadRecentMovie ( )
{
if ( Global . Config . AutoLoadMostRecentMovie = = true )
{
autoloadMostRecentToolStripMenuItem1 . Checked = false ;
Global . Config . AutoLoadMostRecentMovie = false ;
}
else
{
autoloadMostRecentToolStripMenuItem1 . Checked = true ;
Global . Config . AutoLoadMostRecentMovie = true ;
}
}
2011-05-19 18:50:09 +00:00
2011-08-09 00:51:46 +00:00
public void LoadRamSearch ( )
2011-02-20 08:40:22 +00:00
{
if ( ! RamSearch1 . IsHandleCreated | | RamSearch1 . IsDisposed )
{
RamSearch1 = new RamSearch ( ) ;
RamSearch1 . Show ( ) ;
}
else
RamSearch1 . Focus ( ) ;
}
2011-06-11 12:54:26 +00:00
public void LoadGameGenieEC ( )
{
NESGameGenie gg = new NESGameGenie ( ) ;
gg . Show ( ) ;
}
2012-09-06 08:32:25 +00:00
public void LoadSNESGraphicsDebugger ( )
{
if ( ! SNESGraphicsDebugger1 . IsHandleCreated | | SNESGraphicsDebugger1 . IsDisposed )
{
SNESGraphicsDebugger1 = new SNESGraphicsDebugger ( ) ;
2012-10-06 20:00:59 +00:00
SNESGraphicsDebugger1 . UpdateToolsLoadstate ( ) ;
2012-09-06 08:32:25 +00:00
SNESGraphicsDebugger1 . Show ( ) ;
}
else
SNESGraphicsDebugger1 . Focus ( ) ;
}
2011-06-11 12:54:26 +00:00
public void LoadHexEditor ( )
{
if ( ! HexEditor1 . IsHandleCreated | | HexEditor1 . IsDisposed )
{
HexEditor1 = new HexEditor ( ) ;
HexEditor1 . Show ( ) ;
}
else
HexEditor1 . Focus ( ) ;
}
2012-09-30 00:53:08 +00:00
public void LoadTraceLogger ( )
{
if ( ! TraceLogger1 . IsHandleCreated | | TraceLogger1 . IsDisposed )
{
TraceLogger1 = new TraceLogger ( ) ;
TraceLogger1 . Show ( ) ;
}
else
TraceLogger1 . Focus ( ) ;
}
2011-06-11 12:54:26 +00:00
public void LoadToolBox ( )
{
if ( ! ToolBox1 . IsHandleCreated | | ToolBox1 . IsDisposed )
{
ToolBox1 = new ToolBox ( ) ;
ToolBox1 . Show ( ) ;
}
else
ToolBox1 . Close ( ) ;
}
public void LoadNESPPU ( )
{
if ( ! NESPPU1 . IsHandleCreated | | NESPPU1 . IsDisposed )
{
NESPPU1 = new NESPPU ( ) ;
NESPPU1 . Show ( ) ;
}
else
NESPPU1 . Focus ( ) ;
}
public void LoadNESNameTable ( )
{
if ( ! NESNameTableViewer1 . IsHandleCreated | | NESNameTableViewer1 . IsDisposed )
{
NESNameTableViewer1 = new NESNameTableViewer ( ) ;
NESNameTableViewer1 . Show ( ) ;
}
else
NESNameTableViewer1 . Focus ( ) ;
}
public void LoadNESDebugger ( )
{
if ( ! NESDebug1 . IsHandleCreated | | NESDebug1 . IsDisposed )
{
NESDebug1 = new NESDebugger ( ) ;
NESDebug1 . Show ( ) ;
}
else
NESDebug1 . Focus ( ) ;
}
2012-03-12 05:19:59 +00:00
public void LoadPCEBGViewer ( )
{
if ( ! PCEBGViewer1 . IsHandleCreated | | PCEBGViewer1 . IsDisposed )
{
PCEBGViewer1 = new PCEBGViewer ( ) ;
PCEBGViewer1 . Show ( ) ;
}
else
PCEBGViewer1 . Focus ( ) ;
}
2012-11-05 01:34:11 +00:00
public void LoadGBGPUView ( )
{
if ( ! GBGPUView1 . IsHandleCreated | | GBGPUView1 . IsDisposed )
{
GBGPUView1 = new GBtools . GBGPUView ( ) ;
GBGPUView1 . Show ( ) ;
}
else
GBGPUView1 . Focus ( ) ;
}
2012-11-26 23:16:31 +00:00
public void LoadGBAGPUView ( )
{
if ( ! GBAGPUView1 . IsHandleCreated | | GBAGPUView1 . IsDisposed )
{
GBAGPUView1 = new GBAtools . GBAGPUView ( ) ;
GBAGPUView1 . Show ( ) ;
}
else
GBAGPUView1 . Focus ( ) ;
}
2011-06-11 12:54:26 +00:00
public void LoadTI83KeyPad ( )
{
if ( ! TI83KeyPad1 . IsHandleCreated | | TI83KeyPad1 . IsDisposed )
{
TI83KeyPad1 = new TI83KeyPad ( ) ;
TI83KeyPad1 . Show ( ) ;
}
else
TI83KeyPad1 . Focus ( ) ;
}
public void LoadCheatsWindow ( )
{
if ( ! Cheats1 . IsHandleCreated | | Cheats1 . IsDisposed )
{
2011-08-06 02:34:24 +00:00
Cheats1 = new Cheats ( ) ;
2011-06-11 12:54:26 +00:00
Cheats1 . Show ( ) ;
}
else
Cheats1 . Focus ( ) ;
}
2011-03-16 03:56:22 +00:00
2011-02-20 08:40:22 +00:00
private int lastWidth = - 1 ;
private int lastHeight = - 1 ;
private void Render ( )
{
var video = Global . Emulator . VideoProvider ;
2012-08-19 19:16:08 +00:00
if ( video . BufferHeight ! = lastHeight | | video . BufferWidth ! = lastWidth )
2011-02-20 08:40:22 +00:00
{
2012-08-19 19:16:08 +00:00
lastWidth = video . BufferWidth ;
2011-02-20 08:40:22 +00:00
lastHeight = video . BufferHeight ;
FrameBufferResized ( ) ;
}
2012-04-16 08:18:41 +00:00
Global . DisplayManager . UpdateSource ( Global . Emulator . VideoProvider ) ;
2011-02-20 08:40:22 +00:00
}
2012-07-12 22:20:48 +00:00
public void FrameBufferResized ( )
2011-02-20 08:40:22 +00:00
{
2012-09-30 14:18:21 +00:00
// run this entire thing exactly twice, since the first resize may adjust the menu stacking
for ( int i = 0 ; i < 2 ; i + + )
{
var video = Global . Emulator . VideoProvider ;
int zoom = Global . Config . TargetZoomFactor ;
var area = Screen . FromControl ( this ) . WorkingArea ;
2011-02-20 08:40:22 +00:00
2012-09-30 14:18:21 +00:00
int borderWidth = Size . Width - renderTarget . Size . Width ;
int borderHeight = Size . Height - renderTarget . Size . Height ;
2011-02-20 08:40:22 +00:00
2012-09-30 14:18:21 +00:00
// start at target zoom and work way down until we find acceptable zoom
for ( ; zoom > = 1 ; zoom - - )
{
if ( ( ( ( video . BufferWidth * zoom ) + borderWidth ) < area . Width ) & & ( ( ( video . BufferHeight * zoom ) + borderHeight ) < area . Height ) )
break ;
}
2011-02-20 08:40:22 +00:00
2012-09-30 14:18:21 +00:00
// Change size
Size = new Size ( ( video . BufferWidth * zoom ) + borderWidth , ( video . BufferHeight * zoom + borderHeight ) ) ;
PerformLayout ( ) ;
Global . RenderPanel . Resized = true ;
2011-02-20 08:40:22 +00:00
2012-09-30 14:18:21 +00:00
// Is window off the screen at this size?
if ( area . Contains ( Bounds ) = = false )
{
if ( Bounds . Right > area . Right ) // Window is off the right edge
Location = new Point ( area . Right - Size . Width , Location . Y ) ;
2011-02-20 08:40:22 +00:00
2012-09-30 14:18:21 +00:00
if ( Bounds . Bottom > area . Bottom ) // Window is off the bottom edge
Location = new Point ( Location . X , area . Bottom - Size . Height ) ;
}
2011-02-20 08:40:22 +00:00
}
}
private bool InFullscreen = false ;
private Point WindowedLocation ;
public void ToggleFullscreen ( )
{
if ( InFullscreen = = false )
{
WindowedLocation = Location ;
FormBorderStyle = FormBorderStyle . None ;
WindowState = FormWindowState . Maximized ;
2011-09-24 23:00:59 +00:00
if ( Global . Config . ShowMenuInFullscreen )
MainMenuStrip . Visible = true ;
else
MainMenuStrip . Visible = false ;
2011-07-01 01:28:25 +00:00
StatusSlot0 . Visible = false ;
2011-02-20 08:40:22 +00:00
PerformLayout ( ) ;
Global . RenderPanel . Resized = true ;
InFullscreen = true ;
}
else
{
FormBorderStyle = FormBorderStyle . FixedSingle ;
WindowState = FormWindowState . Normal ;
MainMenuStrip . Visible = true ;
2011-07-01 01:28:25 +00:00
StatusSlot0 . Visible = Global . Config . DisplayStatusBar ;
2011-02-20 08:40:22 +00:00
Location = WindowedLocation ;
PerformLayout ( ) ;
FrameBufferResized ( ) ;
InFullscreen = false ;
}
}
2011-07-10 19:50:59 +00:00
//--alt key hacks
protected override void WndProc ( ref Message m )
{
//this is necessary to trap plain alt keypresses so that only our hotkey system gets them
if ( m . Msg = = 0x0112 ) //WM_SYSCOMMAND
if ( m . WParam . ToInt32 ( ) = = 0xF100 ) //SC_KEYMENU
return ;
base . WndProc ( ref m ) ;
}
protected override bool ProcessDialogChar ( char charCode )
{
//this is necessary to trap alt+char combinations so that only our hotkey system gets them
if ( ( Control . ModifierKeys & Keys . Alt ) ! = 0 )
return true ;
else return base . ProcessDialogChar ( charCode ) ;
}
//sends a simulation of a plain alt key keystroke
void SendPlainAltKey ( int lparam )
{
Message m = new Message ( ) ;
m . WParam = new IntPtr ( 0xF100 ) ; //SC_KEYMENU
m . LParam = new IntPtr ( lparam ) ;
m . Msg = 0x0112 ; //WM_SYSCOMMAND
m . HWnd = Handle ;
base . WndProc ( ref m ) ;
}
//sends an alt+mnemonic combination
void SendAltKeyChar ( char c )
{
typeof ( ToolStrip ) . InvokeMember ( "ProcessMnemonicInternal" , System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . InvokeMethod | System . Reflection . BindingFlags . Instance , null , menuStrip1 , new object [ ] { c } ) ;
}
2011-07-24 06:45:05 +00:00
string FormatFilter ( params string [ ] args )
{
var sb = new StringBuilder ( ) ;
if ( args . Length % 2 ! = 0 ) throw new ArgumentException ( ) ;
int num = args . Length / 2 ;
for ( int i = 0 ; i < num ; i + + )
{
sb . AppendFormat ( "{0} ({1})|{1}" , args [ i * 2 ] , args [ i * 2 + 1 ] ) ;
if ( i ! = num - 1 ) sb . Append ( '|' ) ;
}
string str = sb . ToString ( ) . Replace ( "%ARCH%" , "*.zip;*.rar;*.7z" ) ;
str = str . Replace ( ";" , "; " ) ;
return str ;
}
2012-10-20 22:58:01 +00:00
int LastOpenRomFilter = 0 ;
2011-06-11 12:54:26 +00:00
private void OpenROM ( )
{
var ofd = new OpenFileDialog ( ) ;
ofd . InitialDirectory = PathManager . GetRomsPath ( Global . Emulator . SystemId ) ;
2011-07-24 06:45:05 +00:00
//"Rom Files|*.NES;*.SMS;*.GG;*.SG;*.PCE;*.SGX;*.GB;*.BIN;*.SMD;*.ROM;*.ZIP;*.7z|NES (*.NES)|*.NES|Master System|*.SMS;*.GG;*.SG;*.ZIP;*.7z|PC Engine|*.PCE;*.SGX;*.ZIP;*.7z|Gameboy|*.GB;*.ZIP;*.7z|TI-83|*.rom|Archive Files|*.zip;*.7z|Savestate|*.state|All Files|*.*";
2012-03-18 00:00:47 +00:00
//adelikat: ugly design for this, I know
if ( INTERIM )
{
ofd . Filter = FormatFilter (
2013-03-09 18:41:23 +00:00
"Rom Files" , "*.nes;*.fds;*.sms;*.gg;*.sg;*.pce;*.sgx;*.bin;*.smd;*.rom;*.a26;*.a78;*.cue;*.exe;*.gb;*.gbc;*.gen;*.md;*.col;.int;*.smc;*.sfc;*.prg;*.d64;*.g64;*.crt;*.sgb;%ARCH%" ,
2012-11-13 20:10:06 +00:00
"Music Files" , "*.psf;*.sid" ,
2012-03-18 00:00:47 +00:00
"Disc Images" , "*.cue" ,
2012-11-18 02:51:39 +00:00
"NES" , "*.nes;*.fds;%ARCH%" ,
2012-09-04 18:07:40 +00:00
"Super NES" , "*.smc;*.sfc;%ARCH%" ,
2012-03-18 00:00:47 +00:00
"Master System" , "*.sms;*.gg;*.sg;%ARCH%" ,
"PC Engine" , "*.pce;*.sgx;*.cue;%ARCH%" ,
"TI-83" , "*.rom;%ARCH%" ,
"Archive Files" , "%ARCH%" ,
"Savestate" , "*.state" ,
2012-10-20 13:40:58 +00:00
"Atari 2600" , "*.a26;*.bin;%ARCH%" ,
2012-10-23 19:13:57 +00:00
"Atari 7800" , "*.a78;*.bin;%ARCH%" ,
2012-09-23 02:44:04 +00:00
"Genesis (experimental)" , "*.gen;*.smd;*.bin;*.md;*.cue;%ARCH%" ,
2013-03-09 18:41:23 +00:00
"Gameboy" , "*.gb;*.gbc;*.sgb;%ARCH%" ,
2012-11-18 02:51:39 +00:00
"Colecovision" , "*.col;%ARCH%" ,
2012-09-26 01:20:11 +00:00
"Intellivision (very experimental)" , "*.int;*.bin;*.rom;%ARCH%" ,
2012-09-10 21:26:22 +00:00
"PSX Executables (very experimental)" , "*.exe" ,
2012-11-13 20:10:06 +00:00
"PSF Playstation Sound File (very experimental)" , "*.psf" ,
2012-11-18 02:51:39 +00:00
"Commodore 64 (experimental)" , "*.prg; *.d64, *.g64; *.crt;%ARCH%" ,
2012-11-13 20:10:06 +00:00
"SID Commodore 64 Music File" , "*.sid;%ARCH%" ,
2012-03-18 00:00:47 +00:00
"All Files" , "*.*" ) ;
}
else
{
ofd . Filter = FormatFilter (
2013-03-09 18:41:23 +00:00
"Rom Files" , "*.nes;*.fds;*.sms;*.gg;*.sg;*.gb;*.gbc;*.pce;*.sgx;*.bin;*.smd;*.gen;*.md;*.smc;*.sfc;*.a26;*.a78;*.col;*.rom;*.cue;*.sgb;%ARCH%" ,
2012-03-18 00:00:47 +00:00
"Disc Images" , "*.cue" ,
2012-11-18 02:51:39 +00:00
"NES" , "*.nes;*.fds;%ARCH%" ,
2012-09-04 18:07:40 +00:00
"Super NES" , "*.smc;*.sfc;%ARCH%" ,
2013-03-09 18:41:23 +00:00
"Gameboy" , "*.gb;*.gbc;*.sgb;%ARCH%" ,
2012-03-18 00:00:47 +00:00
"Master System" , "*.sms;*.gg;*.sg;%ARCH%" ,
"PC Engine" , "*.pce;*.sgx;*.cue;%ARCH%" ,
2012-10-20 13:40:58 +00:00
"Atari 2600" , "*.a26;%ARCH%" ,
2012-12-23 18:55:05 +00:00
"Atari 7800" , "*.a78;%ARCH%" ,
2012-11-18 02:51:39 +00:00
"Colecovision" , "*.col;%ARCH%" ,
2012-03-18 00:00:47 +00:00
"TI-83" , "*.rom;%ARCH%" ,
"Archive Files" , "%ARCH%" ,
"Savestate" , "*.state" ,
2012-09-23 02:44:04 +00:00
"Genesis (experimental)" , "*.gen;*.md;*.smd;*.bin;*.cue;%ARCH%" ,
2012-11-18 02:51:39 +00:00
2012-03-18 00:00:47 +00:00
"All Files" , "*.*" ) ;
}
2012-10-20 22:58:01 +00:00
2011-06-11 12:54:26 +00:00
ofd . RestoreDirectory = false ;
2012-10-20 22:58:01 +00:00
ofd . FilterIndex = LastOpenRomFilter ;
2011-06-11 12:54:26 +00:00
Global . Sound . StopSound ( ) ;
var result = ofd . ShowDialog ( ) ;
Global . Sound . StartSound ( ) ;
if ( result ! = DialogResult . OK )
return ;
var file = new FileInfo ( ofd . FileName ) ;
Global . Config . LastRomPath = file . DirectoryName ;
2012-10-20 22:58:01 +00:00
LastOpenRomFilter = ofd . FilterIndex ;
2011-06-11 12:54:26 +00:00
LoadRom ( file . FullName ) ;
}
2012-12-10 00:43:43 +00:00
//-------------------------------------------------------
//whats the difference between these two methods??
//its very tricky. rename to be more clear or combine them.
private void CloseGame ( )
{
if ( Global . Config . AutoSavestates & & Global . Emulator is NullEmulator = = false )
SaveState ( "Auto" ) ;
if ( Global . Emulator . SaveRamModified )
SaveRam ( ) ;
StopAVI ( ) ;
Global . Emulator . Dispose ( ) ;
Global . CoreComm = new CoreComm ( ) ;
SyncCoreCommInputSignals ( ) ;
Global . Emulator = new NullEmulator ( Global . CoreComm ) ;
Global . ActiveController = Global . NullControls ;
Global . AutoFireController = Global . AutofireNullControls ;
Global . MovieSession . Movie . Stop ( ) ;
NeedsReboot = false ;
SetRebootIconStatus ( ) ;
}
2012-01-22 22:42:40 +00:00
public void CloseROM ( )
2011-06-11 12:54:26 +00:00
{
2011-08-09 00:51:46 +00:00
CloseGame ( ) ;
2012-12-10 00:43:43 +00:00
Global . CoreComm = new CoreComm ( ) ;
SyncCoreCommInputSignals ( ) ;
Global . Emulator = new NullEmulator ( Global . CoreComm ) ;
2011-09-24 16:19:38 +00:00
Global . Game = GameInfo . GetNullGame ( ) ;
2011-08-09 00:51:46 +00:00
MemoryPulse . Clear ( ) ;
2012-10-12 01:13:55 +00:00
RewireSound ( ) ;
2012-10-12 01:19:49 +00:00
ResetRewindBuffer ( ) ;
2011-06-11 12:54:26 +00:00
RamSearch1 . Restart ( ) ;
RamWatch1 . Restart ( ) ;
HexEditor1 . Restart ( ) ;
NESPPU1 . Restart ( ) ;
NESNameTableViewer1 . Restart ( ) ;
NESDebug1 . Restart ( ) ;
2012-11-05 01:34:11 +00:00
GBGPUView1 . Restart ( ) ;
2012-11-26 23:16:31 +00:00
GBAGPUView1 . Restart ( ) ;
2012-03-12 05:19:59 +00:00
PCEBGViewer1 . Restart ( ) ;
2011-06-11 12:54:26 +00:00
TI83KeyPad1 . Restart ( ) ;
Cheats1 . Restart ( ) ;
2012-01-10 02:11:17 +00:00
ToolBox1 . Restart ( ) ;
2012-03-12 04:44:34 +00:00
#if WINDOWS
2012-01-21 20:05:53 +00:00
LuaConsole1 . Restart ( ) ;
2012-03-12 04:44:34 +00:00
#endif
2011-09-11 00:11:46 +00:00
Text = "BizHawk" + ( INTERIM ? " (interim) " : "" ) ;
2011-06-11 12:54:26 +00:00
HandlePlatformMenus ( ) ;
2011-07-31 23:25:00 +00:00
StateSlots . Clear ( ) ;
2011-07-10 15:36:41 +00:00
UpdateDumpIcon ( ) ;
2011-06-11 12:54:26 +00:00
}
2011-04-16 19:35:37 +00:00
2012-12-10 00:43:43 +00:00
//-------------------------------------------------------
2011-06-11 12:54:26 +00:00
private void SaveConfig ( )
{
if ( Global . Config . SaveWindowPosition )
{
Global . Config . MainWndx = this . Location . X ;
Global . Config . MainWndy = this . Location . Y ;
}
else
{
Global . Config . MainWndx = - 1 ;
Global . Config . MainWndy = - 1 ;
}
2012-05-28 01:29:43 +00:00
2012-04-21 22:46:48 +00:00
if ( Global . Config . ShowLogWindow ) LogConsole . SaveConfigSettings ( ) ;
ConfigService . Save ( PathManager . DefaultIniPath , Global . Config ) ;
}
public void CloseTools ( )
{
2012-03-09 20:10:01 +00:00
CloseForm ( RamWatch1 ) ;
CloseForm ( RamSearch1 ) ;
CloseForm ( HexEditor1 ) ;
CloseForm ( NESNameTableViewer1 ) ;
CloseForm ( NESPPU1 ) ;
CloseForm ( NESDebug1 ) ;
2012-11-05 01:34:11 +00:00
CloseForm ( GBGPUView1 ) ;
2012-11-26 23:16:31 +00:00
CloseForm ( GBAGPUView1 ) ;
2012-03-12 05:19:59 +00:00
CloseForm ( PCEBGViewer1 ) ;
2012-03-09 20:10:01 +00:00
CloseForm ( Cheats1 ) ;
CloseForm ( TI83KeyPad1 ) ;
CloseForm ( TAStudio1 ) ;
2012-09-30 00:53:08 +00:00
CloseForm ( TraceLogger1 ) ;
2012-10-29 22:57:15 +00:00
CloseForm ( VirtualPadForm1 ) ;
2012-03-12 04:44:34 +00:00
#if WINDOWS
2012-03-09 20:12:57 +00:00
CloseForm ( LuaConsole1 ) ;
2012-03-12 04:44:34 +00:00
#endif
2011-06-11 12:54:26 +00:00
}
2012-03-09 20:10:01 +00:00
private void CloseForm ( Form form )
{
if ( form . IsHandleCreated ) form . Close ( ) ;
}
2011-06-11 12:54:26 +00:00
private void PreviousSlot ( )
{
2011-09-24 16:19:38 +00:00
if ( Global . Config . SaveSlot = = 0 )
2011-09-17 00:04:50 +00:00
Global . Config . SaveSlot = 9 ; //Wrap to end of slot list
else if ( Global . Config . SaveSlot > 9 )
Global . Config . SaveSlot = 9 ; //Meh, just in case
else Global . Config . SaveSlot - - ;
2011-06-11 12:54:26 +00:00
SaveSlotSelectedMessage ( ) ;
2011-07-17 13:33:09 +00:00
UpdateStatusSlots ( ) ;
2011-06-11 12:54:26 +00:00
}
private void NextSlot ( )
{
2011-09-17 00:04:50 +00:00
if ( Global . Config . SaveSlot > = 9 )
Global . Config . SaveSlot = 0 ; //Wrap to beginning of slot list
else if ( Global . Config . SaveSlot < 0 )
Global . Config . SaveSlot = 0 ; //Meh, just in case
else Global . Config . SaveSlot + + ;
2011-06-11 12:54:26 +00:00
SaveSlotSelectedMessage ( ) ;
2011-07-17 13:33:09 +00:00
UpdateStatusSlots ( ) ;
2011-06-11 12:54:26 +00:00
}
private void ToggleFPS ( )
{
Global . Config . DisplayFPS ^ = true ;
}
private void ToggleFrameCounter ( )
{
Global . Config . DisplayFrameCounter ^ = true ;
}
private void ToggleLagCounter ( )
{
Global . Config . DisplayLagCounter ^ = true ;
}
private void ToggleInputDisplay ( )
{
Global . Config . DisplayInput ^ = true ;
}
public void ToggleReadOnly ( )
{
2012-09-03 19:42:53 +00:00
if ( Global . MovieSession . Movie . IsActive )
2011-08-17 02:06:50 +00:00
{
ReadOnly ^ = true ;
if ( ReadOnly )
2012-09-03 19:42:53 +00:00
{
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "Movie read-only mode" ) ;
2012-09-03 19:42:53 +00:00
}
2011-08-17 02:06:50 +00:00
else
2012-09-03 19:42:53 +00:00
{
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "Movie read+write mode" ) ;
2012-09-03 19:42:53 +00:00
}
2011-08-17 02:06:50 +00:00
}
2011-06-11 12:54:26 +00:00
else
2011-08-17 02:06:50 +00:00
{
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "No movie active" ) ;
2011-08-17 02:06:50 +00:00
}
2011-06-11 23:54:35 +00:00
}
public void SetReadOnly ( bool read_only )
{
ReadOnly = read_only ;
2012-05-28 01:29:43 +00:00
if ( ReadOnly )
Global . OSD . AddMessage ( "Movie read-only mode" ) ;
else
Global . OSD . AddMessage ( "Movie read+write mode" ) ;
2011-06-11 12:54:26 +00:00
}
2012-08-15 01:14:25 +00:00
public void LoadRamWatch ( bool load_dialog )
2011-06-11 12:54:26 +00:00
{
if ( ! RamWatch1 . IsHandleCreated | | RamWatch1 . IsDisposed )
{
RamWatch1 = new RamWatch ( ) ;
2013-03-10 22:42:54 +00:00
if ( Global . Config . AutoLoadRamWatch & & Global . Config . RecentWatches . Count > 0 )
2012-08-15 01:03:27 +00:00
{
2011-06-11 12:54:26 +00:00
RamWatch1 . LoadWatchFromRecent ( Global . Config . RecentWatches . GetRecentFileByPosition ( 0 ) ) ;
2012-08-15 01:03:27 +00:00
}
2012-08-15 01:14:25 +00:00
if ( load_dialog )
2012-08-15 01:03:27 +00:00
{
RamWatch1 . Show ( ) ;
}
2011-06-11 12:54:26 +00:00
}
else
RamWatch1 . Focus ( ) ;
}
public void LoadTAStudio ( )
{
if ( ! TAStudio1 . IsHandleCreated | | TAStudio1 . IsDisposed )
{
TAStudio1 = new TAStudio ( ) ;
TAStudio1 . Show ( ) ;
}
else
TAStudio1 . Focus ( ) ;
}
2012-10-29 22:57:15 +00:00
public void LoadVirtualPads ( )
{
if ( ! VirtualPadForm1 . IsHandleCreated | | VirtualPadForm1 . IsDisposed )
{
VirtualPadForm1 = new VirtualPadForm ( ) ;
VirtualPadForm1 . Show ( ) ;
}
else
VirtualPadForm1 . Focus ( ) ;
}
2011-06-11 12:54:26 +00:00
private void VolumeUp ( )
{
Global . Config . SoundVolume + = 10 ;
if ( Global . Config . SoundVolume > 100 )
Global . Config . SoundVolume = 100 ;
Global . Sound . ChangeVolume ( Global . Config . SoundVolume ) ;
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "Volume " + Global . Config . SoundVolume . ToString ( ) ) ;
2011-06-11 12:54:26 +00:00
}
private void VolumeDown ( )
{
Global . Config . SoundVolume - = 10 ;
if ( Global . Config . SoundVolume < 0 )
Global . Config . SoundVolume = 0 ;
Global . Sound . ChangeVolume ( Global . Config . SoundVolume ) ;
2012-04-16 08:18:41 +00:00
Global . OSD . AddMessage ( "Volume " + Global . Config . SoundVolume . ToString ( ) ) ;
2011-06-18 18:27:51 +00:00
}
2011-06-26 21:11:12 +00:00
2011-06-30 02:22:12 +00:00
private void SoftReset ( )
{
2011-07-24 20:37:10 +00:00
//is it enough to run this for one frame? maybe..
2011-06-30 02:22:12 +00:00
if ( Global . Emulator . ControllerDefinition . BoolButtons . Contains ( "Reset" ) )
2011-08-19 01:05:30 +00:00
{
2012-09-17 23:03:38 +00:00
if ( ! Global . MovieSession . Movie . IsPlaying | | Global . MovieSession . Movie . IsFinished )
{
Global . ClickyVirtualPadController . Click ( "Reset" ) ;
Global . OSD . AddMessage ( "Reset button pressed." ) ;
}
2011-08-19 01:05:30 +00:00
}
2011-06-30 02:22:12 +00:00
}
2011-07-01 01:28:25 +00:00
2012-09-16 16:52:30 +00:00
private void HardReset ( )
{
//is it enough to run this for one frame? maybe..
if ( Global . Emulator . ControllerDefinition . BoolButtons . Contains ( "Power" ) )
{
2012-09-17 23:03:38 +00:00
if ( ! Global . MovieSession . Movie . IsPlaying | | Global . MovieSession . Movie . IsFinished )
{
Global . ClickyVirtualPadController . Click ( "Power" ) ;
Global . OSD . AddMessage ( "Power button pressed." ) ;
}
2012-09-16 16:52:30 +00:00
}
}
2011-07-01 01:28:25 +00:00
public void UpdateStatusSlots ( )
{
StateSlots . Update ( ) ;
2012-10-07 19:52:09 +00:00
if ( StateSlots . HasSlot ( 1 ) )
{
StatusSlot1 . ForeColor = Color . Black ;
}
else
{
StatusSlot1 . ForeColor = Color . Gray ;
}
if ( StateSlots . HasSlot ( 2 ) )
{
StatusSlot2 . ForeColor = Color . Black ;
}
else
{
StatusSlot2 . ForeColor = Color . Gray ;
}
if ( StateSlots . HasSlot ( 3 ) )
{
StatusSlot3 . ForeColor = Color . Black ;
}
else
{
StatusSlot3 . ForeColor = Color . Gray ;
}
if ( StateSlots . HasSlot ( 3 ) )
{
StatusSlot3 . ForeColor = Color . Black ;
}
else
{
StatusSlot3 . ForeColor = Color . Gray ;
}
if ( StateSlots . HasSlot ( 4 ) )
{
StatusSlot4 . ForeColor = Color . Black ;
}
else
{
StatusSlot4 . ForeColor = Color . Gray ;
}
if ( StateSlots . HasSlot ( 5 ) )
{
StatusSlot5 . ForeColor = Color . Black ;
}
else
{
StatusSlot5 . ForeColor = Color . Gray ;
}
if ( StateSlots . HasSlot ( 6 ) )
{
StatusSlot6 . ForeColor = Color . Black ;
}
else
{
StatusSlot6 . ForeColor = Color . Gray ;
}
if ( StateSlots . HasSlot ( 7 ) )
{
StatusSlot7 . ForeColor = Color . Black ;
}
else
{
StatusSlot7 . ForeColor = Color . Gray ;
}
if ( StateSlots . HasSlot ( 8 ) )
{
StatusSlot8 . ForeColor = Color . Black ;
}
else
{
StatusSlot8 . ForeColor = Color . Gray ;
}
if ( StateSlots . HasSlot ( 9 ) )
{
StatusSlot9 . ForeColor = Color . Black ;
}
else
{
StatusSlot9 . ForeColor = Color . Gray ;
}
if ( StateSlots . HasSlot ( 0 ) )
{
StatusSlot0 . ForeColor = Color . Black ;
}
else
{
StatusSlot0 . ForeColor = Color . Gray ;
}
2012-10-13 21:10:20 +00:00
2011-07-01 01:28:25 +00:00
StatusSlot1 . BackColor = SystemColors . Control ;
StatusSlot2 . BackColor = SystemColors . Control ;
StatusSlot3 . BackColor = SystemColors . Control ;
StatusSlot4 . BackColor = SystemColors . Control ;
StatusSlot5 . BackColor = SystemColors . Control ;
StatusSlot6 . BackColor = SystemColors . Control ;
StatusSlot7 . BackColor = SystemColors . Control ;
StatusSlot8 . BackColor = SystemColors . Control ;
StatusSlot9 . BackColor = SystemColors . Control ;
StatusSlot10 . BackColor = SystemColors . Control ;
2012-10-07 18:42:42 +00:00
if ( Global . Config . SaveSlot = = 0 ) StatusSlot10 . BackColor = SystemColors . ControlDark ;
if ( Global . Config . SaveSlot = = 1 ) StatusSlot1 . BackColor = SystemColors . ControlDark ;
if ( Global . Config . SaveSlot = = 2 ) StatusSlot2 . BackColor = SystemColors . ControlDark ;
if ( Global . Config . SaveSlot = = 3 ) StatusSlot3 . BackColor = SystemColors . ControlDark ;
if ( Global . Config . SaveSlot = = 4 ) StatusSlot4 . BackColor = SystemColors . ControlDark ;
if ( Global . Config . SaveSlot = = 5 ) StatusSlot5 . BackColor = SystemColors . ControlDark ;
if ( Global . Config . SaveSlot = = 6 ) StatusSlot6 . BackColor = SystemColors . ControlDark ;
if ( Global . Config . SaveSlot = = 7 ) StatusSlot7 . BackColor = SystemColors . ControlDark ;
if ( Global . Config . SaveSlot = = 8 ) StatusSlot8 . BackColor = SystemColors . ControlDark ;
if ( Global . Config . SaveSlot = = 9 ) StatusSlot9 . BackColor = SystemColors . ControlDark ;
2011-07-01 01:28:25 +00:00
}
2012-11-26 21:08:08 +00:00
#region AVI Stuff
2012-07-23 00:33:30 +00:00
/// <summary>
/// start avi recording, unattended
/// </summary>
/// <param name="videowritername">match the short name of an ivideowriter</param>
/// <param name="filename">filename to save to</param>
public void RecordAVI ( string videowritername , string filename )
{
_RecordAVI ( videowritername , filename , true ) ;
}
/// <summary>
/// start avi recording, asking user for filename and options
/// </summary>
2011-07-11 23:26:20 +00:00
public void RecordAVI ( )
2012-07-23 00:33:30 +00:00
{
_RecordAVI ( null , null , false ) ;
}
/// <summary>
/// start avi recording
/// </summary>
/// <param name="videowritername"></param>
/// <param name="filename"></param>
/// <param name="unattended"></param>
private void _RecordAVI ( string videowritername , string filename , bool unattended )
2011-07-09 21:13:18 +00:00
{
2011-07-12 00:05:14 +00:00
if ( CurrAviWriter ! = null ) return ;
2012-06-13 19:50:50 +00:00
// select IVideoWriter to use
2012-07-23 00:33:30 +00:00
IVideoWriter aw = null ;
var writers = VideoWriterInventory . GetAllVideoWriters ( ) ;
if ( unattended )
{
foreach ( var w in writers )
{
if ( w . ShortName ( ) = = videowritername )
{
aw = w ;
break ;
}
}
}
else
{
2012-11-26 02:25:23 +00:00
aw = VideoWriterChooserForm . DoVideoWriterChoserDlg ( writers , Global . MainForm , out avwriter_resizew , out avwriter_resizeh ) ;
2012-07-23 00:33:30 +00:00
}
2012-06-13 19:50:50 +00:00
foreach ( var w in writers )
2011-07-11 23:26:20 +00:00
{
2012-06-13 19:50:50 +00:00
if ( w ! = aw )
w . Dispose ( ) ;
2011-07-11 23:26:20 +00:00
}
2012-07-23 00:33:30 +00:00
2012-06-13 19:50:50 +00:00
if ( aw = = null )
2011-07-11 23:26:20 +00:00
{
2012-07-23 00:33:30 +00:00
if ( unattended )
Global . OSD . AddMessage ( string . Format ( "Couldn't start video writer \"{0}\"" , videowritername ) ) ;
else
Global . OSD . AddMessage ( "A/V capture canceled." ) ;
2011-07-11 23:26:20 +00:00
return ;
2012-06-13 19:50:50 +00:00
}
2011-08-09 00:51:46 +00:00
2011-07-11 23:26:20 +00:00
try
{
2012-12-10 00:43:43 +00:00
aw . SetMovieParameters ( Global . Emulator . CoreComm . VsyncNum , Global . Emulator . CoreComm . VsyncDen ) ;
2012-11-26 02:25:23 +00:00
if ( avwriter_resizew > 0 & & avwriter_resizeh > 0 )
aw . SetVideoParameters ( avwriter_resizew , avwriter_resizeh ) ;
else
aw . SetVideoParameters ( Global . Emulator . VideoProvider . BufferWidth , Global . Emulator . VideoProvider . BufferHeight ) ;
2011-07-11 23:26:20 +00:00
aw . SetAudioParameters ( 44100 , 2 , 16 ) ;
2012-06-13 19:50:50 +00:00
// select codec token
// do this before save dialog because ffmpeg won't know what extension it wants until it's been configured
2012-07-23 00:33:30 +00:00
if ( unattended )
2012-05-28 01:29:43 +00:00
{
2012-07-23 00:33:30 +00:00
aw . SetDefaultVideoCodecToken ( ) ;
}
else
{
var token = aw . AcquireVideoCodecToken ( Global . MainForm ) ;
if ( token = = null )
{
Global . OSD . AddMessage ( "A/V capture canceled." ) ;
aw . Dispose ( ) ;
return ;
}
aw . SetVideoCodecToken ( token ) ;
2012-05-28 01:29:43 +00:00
}
2012-06-13 19:50:50 +00:00
// select file to save to
2012-07-23 00:33:30 +00:00
if ( unattended )
2012-06-13 19:50:50 +00:00
{
2012-07-23 00:33:30 +00:00
aw . OpenFile ( filename ) ;
2012-06-13 19:50:50 +00:00
}
else
{
2012-07-23 00:33:30 +00:00
var sfd = new SaveFileDialog ( ) ;
if ( ! ( Global . Emulator is NullEmulator ) )
{
sfd . FileName = PathManager . FilesystemSafeName ( Global . Game ) ;
2012-12-30 17:52:40 +00:00
sfd . InitialDirectory = PathManager . MakeAbsolutePath ( Global . Config . AVIPath ) ;
2012-07-23 00:33:30 +00:00
}
else
{
sfd . FileName = "NULL" ;
2012-12-30 17:52:40 +00:00
sfd . InitialDirectory = PathManager . MakeAbsolutePath ( Global . Config . AVIPath ) ;
2012-07-23 00:33:30 +00:00
}
sfd . Filter = String . Format ( "{0} (*.{0})|*.{0}|All Files|*.*" , aw . DesiredExtension ( ) ) ;
2012-06-13 19:50:50 +00:00
2012-07-23 00:33:30 +00:00
Global . Sound . StopSound ( ) ;
var result = sfd . ShowDialog ( ) ;
Global . Sound . StartSound ( ) ;
2012-06-13 19:50:50 +00:00
2012-07-23 00:33:30 +00:00
if ( result = = DialogResult . Cancel )
{
aw . Dispose ( ) ;
return ;
}
aw . OpenFile ( sfd . FileName ) ;
2012-06-13 19:50:50 +00:00
}
2011-07-11 23:26:20 +00:00
//commit the avi writing last, in case there were any errors earlier
CurrAviWriter = aw ;
2012-06-13 19:50:50 +00:00
Global . OSD . AddMessage ( "A/V capture started" ) ;
2011-07-12 00:37:24 +00:00
AVIStatusLabel . Image = BizHawk . MultiClient . Properties . Resources . AVI ;
2012-06-13 19:50:50 +00:00
AVIStatusLabel . ToolTipText = "A/V capture in progress" ;
2012-09-29 22:37:34 +00:00
AVIStatusLabel . Visible = true ;
2012-10-13 21:10:20 +00:00
2011-07-11 23:26:20 +00:00
}
catch
{
2012-06-13 19:50:50 +00:00
Global . OSD . AddMessage ( "A/V capture failed!" ) ;
2011-07-11 23:26:20 +00:00
aw . Dispose ( ) ;
throw ;
}
2012-06-13 19:50:50 +00:00
sound api changes. added a new ISyncSoundProvider, which works similarly to ISoundProvider except the source (not the sink) determines the number of samples to process. Added facilities to metaspu, dcfilter, speexresampler to work with ISyncSoundProvider. Add ISyncSoundProvider to IEmulator. All IEmulators must provide sync sound, but they need not provide async sound. When async is needed and an IEmulator doesn't provide it, the frontend will wrap it in a vecna metaspu. SNES, GB changed to provide sync sound only. All other emulator cores mostly unchanged; they just provide stub fakesync alongside async, for now. For the moment, the only use of the sync sound is for realtime audio throttling, where it works and sounds quite nice. In the future, sync sound will be supported for AV dumping as well.
2012-10-11 00:44:59 +00:00
// do sound rewire. the plan is to eventually have AVI writing support syncsound input, but it doesn't for the moment
if ( ! Global . Emulator . StartAsyncSound ( ) )
AviSoundInput = new Emulation . Sound . MetaspuAsync ( Global . Emulator . SyncSoundProvider , Emulation . Sound . ESynchMethod . ESynchMethod_V ) ;
else
AviSoundInput = Global . Emulator . SoundProvider ;
2012-09-06 00:07:37 +00:00
DumpProxy = new Emulation . Sound . MetaspuSoundProvider ( Emulation . Sound . ESynchMethod . ESynchMethod_V ) ;
2012-07-11 21:37:35 +00:00
SoundRemainder = 0 ;
sound api changes. added a new ISyncSoundProvider, which works similarly to ISoundProvider except the source (not the sink) determines the number of samples to process. Added facilities to metaspu, dcfilter, speexresampler to work with ISyncSoundProvider. Add ISyncSoundProvider to IEmulator. All IEmulators must provide sync sound, but they need not provide async sound. When async is needed and an IEmulator doesn't provide it, the frontend will wrap it in a vecna metaspu. SNES, GB changed to provide sync sound only. All other emulator cores mostly unchanged; they just provide stub fakesync alongside async, for now. For the moment, the only use of the sync sound is for realtime audio throttling, where it works and sounds quite nice. In the future, sync sound will be supported for AV dumping as well.
2012-10-11 00:44:59 +00:00
RewireSound ( ) ;
2011-07-09 21:13:18 +00:00
}
2011-07-10 00:04:33 +00:00
2012-10-18 20:57:53 +00:00
void AbortAVI ( )
{
if ( CurrAviWriter = = null )
{
DumpProxy = null ;
RewireSound ( ) ;
return ;
}
CurrAviWriter . Dispose ( ) ;
CurrAviWriter = null ;
2012-11-25 15:51:18 +00:00
Global . OSD . AddMessage ( "A/V capture aborted" ) ;
2012-10-18 20:57:53 +00:00
AVIStatusLabel . Image = BizHawk . MultiClient . Properties . Resources . Blank ;
AVIStatusLabel . ToolTipText = "" ;
AVIStatusLabel . Visible = false ;
AviSoundInput = null ;
DumpProxy = null ; // return to normal sound output
SoundRemainder = 0 ;
RewireSound ( ) ;
}
2011-07-11 23:26:20 +00:00
public void StopAVI ( )
2011-07-10 00:04:33 +00:00
{
2012-05-28 01:29:43 +00:00
if ( CurrAviWriter = = null )
{
DumpProxy = null ;
sound api changes. added a new ISyncSoundProvider, which works similarly to ISoundProvider except the source (not the sink) determines the number of samples to process. Added facilities to metaspu, dcfilter, speexresampler to work with ISyncSoundProvider. Add ISyncSoundProvider to IEmulator. All IEmulators must provide sync sound, but they need not provide async sound. When async is needed and an IEmulator doesn't provide it, the frontend will wrap it in a vecna metaspu. SNES, GB changed to provide sync sound only. All other emulator cores mostly unchanged; they just provide stub fakesync alongside async, for now. For the moment, the only use of the sync sound is for realtime audio throttling, where it works and sounds quite nice. In the future, sync sound will be supported for AV dumping as well.
2012-10-11 00:44:59 +00:00
RewireSound ( ) ;
2012-05-28 01:29:43 +00:00
return ;
}
2011-07-11 23:26:20 +00:00
CurrAviWriter . CloseFile ( ) ;
2012-07-23 00:33:30 +00:00
CurrAviWriter . Dispose ( ) ;
2011-07-11 23:26:20 +00:00
CurrAviWriter = null ;
2012-11-25 15:51:18 +00:00
Global . OSD . AddMessage ( "A/V capture stopped" ) ;
2011-07-12 00:37:24 +00:00
AVIStatusLabel . Image = BizHawk . MultiClient . Properties . Resources . Blank ;
AVIStatusLabel . ToolTipText = "" ;
2012-09-29 22:37:34 +00:00
AVIStatusLabel . Visible = false ;
sound api changes. added a new ISyncSoundProvider, which works similarly to ISoundProvider except the source (not the sink) determines the number of samples to process. Added facilities to metaspu, dcfilter, speexresampler to work with ISyncSoundProvider. Add ISyncSoundProvider to IEmulator. All IEmulators must provide sync sound, but they need not provide async sound. When async is needed and an IEmulator doesn't provide it, the frontend will wrap it in a vecna metaspu. SNES, GB changed to provide sync sound only. All other emulator cores mostly unchanged; they just provide stub fakesync alongside async, for now. For the moment, the only use of the sync sound is for realtime audio throttling, where it works and sounds quite nice. In the future, sync sound will be supported for AV dumping as well.
2012-10-11 00:44:59 +00:00
AviSoundInput = null ;
2012-05-28 01:29:43 +00:00
DumpProxy = null ; // return to normal sound output
2012-07-11 21:37:35 +00:00
SoundRemainder = 0 ;
sound api changes. added a new ISyncSoundProvider, which works similarly to ISoundProvider except the source (not the sink) determines the number of samples to process. Added facilities to metaspu, dcfilter, speexresampler to work with ISyncSoundProvider. Add ISyncSoundProvider to IEmulator. All IEmulators must provide sync sound, but they need not provide async sound. When async is needed and an IEmulator doesn't provide it, the frontend will wrap it in a vecna metaspu. SNES, GB changed to provide sync sound only. All other emulator cores mostly unchanged; they just provide stub fakesync alongside async, for now. For the moment, the only use of the sync sound is for realtime audio throttling, where it works and sounds quite nice. In the future, sync sound will be supported for AV dumping as well.
2012-10-11 00:44:59 +00:00
RewireSound ( ) ;
2011-07-10 00:04:33 +00:00
}
2011-07-31 22:29:56 +00:00
2012-11-26 21:08:08 +00:00
void AVIFrameAdvance ( )
{
if ( CurrAviWriter ! = null )
{
2012-12-10 00:43:43 +00:00
long nsampnum = 44100 * ( long ) Global . Emulator . CoreComm . VsyncDen + SoundRemainder ;
long nsamp = nsampnum / Global . Emulator . CoreComm . VsyncNum ;
2012-11-26 21:08:08 +00:00
// exactly remember fractional parts of an audio sample
2012-12-10 00:43:43 +00:00
SoundRemainder = nsampnum % Global . Emulator . CoreComm . VsyncNum ;
2012-11-26 21:08:08 +00:00
short [ ] temp = new short [ nsamp * 2 ] ;
AviSoundInput . GetSamples ( temp ) ;
DumpProxy . buffer . enqueue_samples ( temp , ( int ) nsamp ) ;
try
{
IVideoProvider output ;
if ( avwriter_resizew > 0 & & avwriter_resizeh > 0 )
{
Bitmap bmpin ;
if ( Global . Config . AVI_CaptureOSD )
bmpin = CaptureOSD ( ) ;
else
{
bmpin = new Bitmap ( Global . Emulator . VideoProvider . BufferWidth , Global . Emulator . VideoProvider . BufferHeight , PixelFormat . Format32bppArgb ) ;
var lockdata = bmpin . LockBits ( new Rectangle ( 0 , 0 , bmpin . Width , bmpin . Height ) , ImageLockMode . WriteOnly , PixelFormat . Format32bppArgb ) ;
System . Runtime . InteropServices . Marshal . Copy ( Global . Emulator . VideoProvider . GetVideoBuffer ( ) , 0 , lockdata . Scan0 , bmpin . Width * bmpin . Height ) ;
bmpin . UnlockBits ( lockdata ) ;
}
Bitmap bmpout = new Bitmap ( avwriter_resizew , avwriter_resizeh , PixelFormat . Format32bppArgb ) ;
using ( Graphics g = Graphics . FromImage ( bmpout ) )
g . DrawImage ( bmpin , new Rectangle ( 0 , 0 , bmpout . Width , bmpout . Height ) ) ;
bmpin . Dispose ( ) ;
output = new AVOut . BmpVideoProvder ( bmpout ) ;
}
else
{
if ( Global . Config . AVI_CaptureOSD )
output = new AVOut . BmpVideoProvder ( CaptureOSD ( ) ) ;
else
output = Global . Emulator . VideoProvider ;
}
CurrAviWriter . AddFrame ( output ) ;
if ( output is AVOut . BmpVideoProvder )
( output as AVOut . BmpVideoProvder ) . Dispose ( ) ;
CurrAviWriter . AddSamples ( temp ) ;
}
catch ( Exception e )
{
MessageBox . Show ( "Video dumping died:\n\n" + e . ToString ( ) ) ;
AbortAVI ( ) ;
}
if ( autoDumpLength > 0 )
{
autoDumpLength - - ;
if ( autoDumpLength = = 0 ) // finish
StopAVI ( ) ;
}
}
}
#endregion
2011-07-31 22:29:56 +00:00
private void SwapBackupSavestate ( string path )
{
//Takes the .state and .bak files and swaps them
var state = new FileInfo ( path ) ;
var backup = new FileInfo ( path + ".bak" ) ;
var temp = new FileInfo ( path + ".bak.tmp" ) ;
if ( state . Exists = = false ) return ;
if ( backup . Exists = = false ) return ;
if ( temp . Exists = = true ) temp . Delete ( ) ;
backup . CopyTo ( path + ".bak.tmp" ) ;
backup . Delete ( ) ;
state . CopyTo ( path + ".bak" ) ;
state . Delete ( ) ;
temp . CopyTo ( path ) ;
temp . Delete ( ) ;
2011-07-31 23:25:00 +00:00
2011-09-17 00:04:50 +00:00
StateSlots . ToggleRedo ( Global . Config . SaveSlot ) ;
2011-07-31 22:29:56 +00:00
}
2011-09-24 23:12:43 +00:00
private void ShowHideMenu ( )
{
MainMenuStrip . Visible ^ = true ;
}
2012-01-10 01:30:17 +00:00
public void OpenLuaConsole ( )
{
2012-03-12 04:44:34 +00:00
#if WINDOWS
2012-01-21 20:05:53 +00:00
if ( ! LuaConsole1 . IsHandleCreated | | LuaConsole1 . IsDisposed )
{
LuaConsole1 = new LuaConsole ( ) ;
LuaConsole1 . Show ( ) ;
}
else
LuaConsole1 . Focus ( ) ;
2012-03-12 04:44:34 +00:00
#else
MessageBox . Show ( "Sorry, Lua is not supported on this platform." , "Lua not supported" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
#endif
2012-01-10 01:30:17 +00:00
}
2012-01-22 22:42:40 +00:00
public void LoadRamPoke ( )
{
RamPoke r = new RamPoke ( ) ;
r . Show ( ) ;
}
2012-03-03 20:14:20 +00:00
private void importMovieToolStripMenuItem_Click ( object sender , EventArgs e )
{
var ofd = new OpenFileDialog ( ) ;
ofd . InitialDirectory = PathManager . GetRomsPath ( Global . Emulator . SystemId ) ;
ofd . Multiselect = true ;
ofd . Filter = FormatFilter (
2012-09-12 04:11:35 +00:00
"Movie Files" , "*.fm2;*.mc2;*.mcm;*.mmv;*.gmv;*.vbm;*.lsmv;*.fcm;*.fmv;*.vmv;*.nmv;*.smv;*.zmv;" ,
2012-03-03 20:14:20 +00:00
"FCEUX" , "*.fm2" ,
2012-03-09 16:31:14 +00:00
"PCEjin/Mednafen" , "*.mc2;*.mcm" ,
2012-03-09 12:10:41 +00:00
"Dega" , "*.mmv" ,
2012-09-12 04:11:35 +00:00
"Gens" , "*.gmv" ,
"Visual Boy Advance" , "*.vbm" ,
"LSNES" , "*.lsmv" ,
2012-03-09 12:10:41 +00:00
"FCEU" , "*.fcm" ,
"Famtasia" , "*.fmv" ,
2012-03-14 20:46:59 +00:00
"VirtuaNES" , "*.vmv" ,
"Nintendulator" , "*.nmv" ,
2012-09-12 04:11:35 +00:00
"Snes9x" , "*.smv" ,
"ZSNES" , "*.zmv" ,
2012-03-03 20:14:20 +00:00
"All Files" , "*.*" ) ;
ofd . RestoreDirectory = false ;
Global . Sound . StopSound ( ) ;
var result = ofd . ShowDialog ( ) ;
Global . Sound . StartSound ( ) ;
if ( result ! = DialogResult . OK )
return ;
2012-03-30 12:26:36 +00:00
2012-03-03 20:14:20 +00:00
foreach ( string fn in ofd . FileNames )
{
2012-12-02 20:35:51 +00:00
ProcessMovieImport ( fn ) ;
2012-03-03 20:14:20 +00:00
}
}
2012-03-03 20:49:44 +00:00
2012-12-02 20:35:51 +00:00
void ProcessMovieImport ( string fn )
{
var file = new FileInfo ( fn ) ;
2012-12-30 17:52:40 +00:00
string d = PathManager . MakeAbsolutePath ( Global . Config . MoviesPath ) ;
2012-12-02 20:35:51 +00:00
string errorMsg = "" ;
string warningMsg = "" ;
Movie m = MovieImport . ImportFile ( fn , out errorMsg , out warningMsg ) ;
if ( errorMsg . Length > 0 )
MessageBox . Show ( errorMsg , "Conversion error" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
if ( warningMsg . Length > 0 )
Global . OSD . AddMessage ( warningMsg ) ;
else
Global . OSD . AddMessage ( Path . GetFileName ( fn ) + " imported as " + "Movies\\" +
Path . GetFileName ( fn ) + "." + Global . Config . MovieExtension ) ;
if ( ! Directory . Exists ( d ) )
Directory . CreateDirectory ( d ) ;
2012-10-02 21:28:14 +00:00
2012-12-02 20:35:51 +00:00
string outPath = d + "\\" + Path . GetFileName ( fn ) + "." + Global . Config . MovieExtension ;
m . WriteMovie ( outPath ) ;
}
2012-10-02 21:28:14 +00:00
// workaround for possible memory leak in SysdrawingRenderPanel
RetainedViewportPanel captureosd_rvp ;
SysdrawingRenderPanel captureosd_srp ;
2012-09-22 01:06:18 +00:00
/// <summary>
/// sort of like MakeScreenShot(), but with OSD and LUA captured as well. slow and bad.
/// </summary>
Bitmap CaptureOSD ( )
{
// this code captures the emu display with OSD and lua composited onto it.
// it's slow and a bit hackish; a better solution is to create a new
// "dummy render" class that implements IRenderer, IBlitter, and possibly
// IVideoProvider, and pass that to DisplayManager.UpdateSourceEx()
2012-10-02 21:28:14 +00:00
if ( captureosd_rvp = = null )
{
captureosd_rvp = new RetainedViewportPanel ( ) ;
captureosd_srp = new SysdrawingRenderPanel ( captureosd_rvp ) ;
}
2012-09-22 01:06:18 +00:00
// this size can be different for showing off stretching or filters
2012-10-02 21:28:14 +00:00
captureosd_rvp . Width = Global . Emulator . VideoProvider . BufferWidth ;
captureosd_rvp . Height = Global . Emulator . VideoProvider . BufferHeight ;
2012-09-22 01:06:18 +00:00
2012-10-02 21:28:14 +00:00
Global . DisplayManager . UpdateSourceEx ( Global . Emulator . VideoProvider , captureosd_srp ) ;
2012-09-22 01:06:18 +00:00
2012-10-02 21:28:14 +00:00
Bitmap ret = ( Bitmap ) captureosd_rvp . GetBitmap ( ) . Clone ( ) ;
2012-09-27 17:53:00 +00:00
2012-09-22 01:06:18 +00:00
return ret ;
}
2012-03-04 19:02:28 +00:00
#region Animaged Gifs
/// <summary>
/// Creates Animated Gifs
/// </summary>
/// <param name="num_images">Total number of frames in the gif</param>
/// <param name="frameskip">How many frames to skip per screenshot in the image.
/// A value of 5 means that frame 1002 will be an image and 1007 will be an image in the gif
/// A value of 1 means that frame 1001 will be an image and 1002 will be an image in the gif</param>
/// <param name="gifSpeed">How quickly the animated gif will run. A value of 1 or -1 = normal emulator speed.
/// A value of 2 will double the speed of the gif.
/// Input a negative value to slow down the speed of the gif.
/// A value of -2 will be half speed</param>
/// <param name="reversable">Flag for making the gif loop back and forth</param>
/// <param name="filename">location to save the file</param>
/// <returns>false if the parameters are incorrect, true if it completes</returns>
2012-03-04 20:37:49 +00:00
public bool AnimatedGif ( int num_images , int frameskip , int gifSpeed , bool reversable , String filename )
2012-03-04 19:02:28 +00:00
{
if ( num_images < 1 | | frameskip < 1 | | gifSpeed = = 0 ) return false ; //Exits if settings are bad
#region declare / insantiate variables
List < Image > images = new List < Image > ( ) ; //Variable for holding all images for the gif animation
Image tempImage ; //Holding the image in case it doesn't end up being added to the animation
// Such a scenario could be a frameskip setting of 2 and a gifSpeed setting of 3
// This would result in 1 of every 3 images being requested getting skipped.
// My math might be wrong at this hour, but you get the point!
int speedTracker = 0 ; // To keep track of when to add another image to the list
bool status = PressFrameAdvance ;
PressFrameAdvance = true ;
#endregion
#region Get the Images for the File
int totalFrames = ( gifSpeed > 0 ? num_images : ( num_images * ( gifSpeed * - 1 ) ) ) ;
2012-09-22 04:04:35 +00:00
images . Add ( Global . Config . Screenshot_CaptureOSD ? CaptureOSD ( ) : MakeScreenshotImage ( ) ) ;
2012-03-30 12:26:36 +00:00
while ( images . Count < totalFrames )
2012-03-04 19:02:28 +00:00
{
2012-09-22 04:04:35 +00:00
tempImage = Global . Config . Screenshot_CaptureOSD ? CaptureOSD ( ) : MakeScreenshotImage ( ) ;
2012-03-30 12:26:36 +00:00
if ( gifSpeed < 0 )
2012-03-04 19:02:28 +00:00
for ( speedTracker = 0 ; speedTracker > gifSpeed ; speedTracker - - )
images . Add ( tempImage ) ; //If the speed of the animation is to be slowed down, then add that many copies
2012-03-30 12:26:36 +00:00
//of the image to the list
2012-03-04 19:02:28 +00:00
for ( int j = 0 ; j < frameskip ; j + + )
{
StepRunLoop_Core ( ) ;
2012-09-20 20:00:14 +00:00
Global . Emulator . FrameAdvance ( true ) ; //Frame advance
2012-04-16 08:18:41 +00:00
//Global.RenderPanel.Render(Global.Emulator.VideoProvider);
2012-03-04 19:02:28 +00:00
if ( gifSpeed > 0 )
{
speedTracker + + ; //Advance the frame counter for adding to the List of Images
2012-03-30 12:26:36 +00:00
if ( speedTracker = = Math . Max ( gifSpeed , frameskip ) )
2012-03-04 19:02:28 +00:00
{
images . Add ( tempImage ) ;
speedTracker = 0 ;
}
}
}
}
#endregion
PressFrameAdvance = status ;
/ *
* The following code was obtained from here :
* http : //social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/0c4252c8-8274-449c-ad9b-e4f07a8f8cdd/
* Modified to work with the BizHawk Project
* /
#region make gif file
2012-03-30 12:26:36 +00:00
byte [ ] GifAnimation = { 33 , 255 , 11 , 78 , 69 , 84 , 83 , 67 , 65 , 80 , 69 , 50 , 46 , 48 , 3 , 1 , 0 , 0 , 0 } ;
2012-03-04 19:02:28 +00:00
MemoryStream MS = new MemoryStream ( ) ;
BinaryReader BR = new BinaryReader ( MS ) ;
2012-03-04 19:07:52 +00:00
var fi = new FileInfo ( filename ) ;
if ( fi . Directory . Exists = = false )
fi . Directory . Create ( ) ;
2012-03-04 19:02:28 +00:00
BinaryWriter BW = new BinaryWriter ( new FileStream ( filename , FileMode . Create ) ) ;
2012-03-30 12:26:36 +00:00
images [ 0 ] . Save ( MS , ImageFormat . Gif ) ;
2012-03-04 19:02:28 +00:00
byte [ ] B = MS . ToArray ( ) ;
B [ 10 ] = ( byte ) ( B [ 10 ] & 0X78 ) ; //No global color table.
BW . Write ( B , 0 , 13 ) ;
BW . Write ( GifAnimation ) ;
WriteGifImg ( B , BW ) ;
for ( int I = 1 ; I < images . Count ; I + + )
{
MS . SetLength ( 0 ) ;
images [ I ] . Save ( MS , ImageFormat . Gif ) ;
B = MS . ToArray ( ) ;
WriteGifImg ( B , BW ) ;
}
if ( reversable )
{
for ( int I = images . Count - 2 ; I > = 0 ; I - - ) //Start at (count - 2) because last image is already in place
{
MS . SetLength ( 0 ) ;
images [ I ] . Save ( MS , ImageFormat . Gif ) ;
B = MS . ToArray ( ) ;
WriteGifImg ( B , BW ) ;
}
}
BW . Write ( B [ B . Length - 1 ] ) ;
BW . Close ( ) ;
MS . Dispose ( ) ;
#endregion
return true ;
}
public void WriteGifImg ( byte [ ] B , BinaryWriter BW )
{
2012-03-30 12:26:36 +00:00
byte [ ] Delay = { 0 , 0 } ;
2012-03-04 19:02:28 +00:00
B [ 785 ] = Delay [ 0 ] ;
B [ 786 ] = Delay [ 1 ] ;
B [ 798 ] = ( byte ) ( B [ 798 ] | 0X87 ) ;
BW . Write ( B , 781 , 18 ) ;
BW . Write ( B , 13 , 768 ) ;
BW . Write ( B , 799 , B . Length - 800 ) ;
}
#endregion
2012-03-04 19:24:10 +00:00
private void animatedGIFConfigToolStripMenuItem_Click ( object sender , EventArgs e )
{
GifAnimator g = new GifAnimator ( ) ;
g . Show ( ) ;
}
2012-03-04 20:37:49 +00:00
private void makeAnimatedGIFToolStripMenuItem_Click ( object sender , EventArgs e )
{
makeAnimatedGif ( ) ;
}
private void makeAnimatedGif ( )
{
string path = String . Format ( PathManager . ScreenshotPrefix ( Global . Game ) + "AGIF.{0:yyyy-MM-dd HH.mm.ss}.gif" , DateTime . Now ) ;
AnimatedGif ( Global . Config . GifAnimatorNumFrames , Global . Config . GifAnimatorFrameSkip , Global . Config . GifAnimatorSpeed , Global . Config . GifAnimatorReversable , path ) ;
}
private void makeAnimatedGif ( string path )
{
AnimatedGif ( Global . Config . GifAnimatorNumFrames , Global . Config . GifAnimatorFrameSkip , Global . Config . GifAnimatorSpeed , Global . Config . GifAnimatorReversable , path ) ;
}
private void makeAnimatedGifAsToolStripMenuItem_Click ( object sender , EventArgs e )
{
string path = String . Format ( PathManager . ScreenshotPrefix ( Global . Game ) + "AGIF.{0:yyyy-MM-dd HH.mm.ss}.gif" , DateTime . Now ) ;
SaveFileDialog sfd = new SaveFileDialog ( ) ;
sfd . InitialDirectory = Path . GetDirectoryName ( path ) ;
sfd . FileName = Path . GetFileName ( path ) ;
sfd . Filter = "GIF File (*.gif)|*.gif" ;
Global . Sound . StopSound ( ) ;
var result = sfd . ShowDialog ( ) ;
Global . Sound . StartSound ( ) ;
if ( result ! = DialogResult . OK )
return ;
makeAnimatedGif ( sfd . FileName ) ;
}
2012-03-07 03:58:54 +00:00
2012-03-09 21:36:55 +00:00
private void ShowConsole ( )
{
LogConsole . ShowConsole ( ) ;
logWindowAsConsoleToolStripMenuItem . Enabled = false ;
}
private void HideConsole ( )
{
LogConsole . HideConsole ( ) ;
logWindowAsConsoleToolStripMenuItem . Enabled = true ;
}
2012-03-09 21:20:02 +00:00
public void notifyLogWindowClosing ( )
{
displayLogWindowToolStripMenuItem . Checked = false ;
2012-03-09 21:36:55 +00:00
logWindowAsConsoleToolStripMenuItem . Enabled = true ;
2012-03-09 21:20:02 +00:00
}
2012-03-18 04:08:05 +00:00
2012-03-24 12:20:21 +00:00
private void MainForm_Load ( object sender , EventArgs e )
{
Text = "BizHawk" + ( INTERIM ? " (interim) " : "" ) ;
2012-09-29 22:37:34 +00:00
//Hide Status bar icons
PlayRecordStatus . Visible = false ;
AVIStatusLabel . Visible = false ;
SetPauseStatusbarIcon ( ) ;
UpdateCheatStatus ( ) ;
2012-09-29 23:03:51 +00:00
SetRebootIconStatus ( ) ;
2012-03-24 12:20:21 +00:00
}
2012-03-28 02:32:05 +00:00
private void IncreaseWindowSize ( )
{
switch ( Global . Config . TargetZoomFactor )
{
case 1 :
Global . Config . TargetZoomFactor = 2 ;
break ;
case 2 :
Global . Config . TargetZoomFactor = 3 ;
break ;
case 3 :
Global . Config . TargetZoomFactor = 4 ;
break ;
case 4 :
Global . Config . TargetZoomFactor = 5 ;
break ;
case 5 :
Global . Config . TargetZoomFactor = 10 ;
break ;
case 10 :
return ;
}
FrameBufferResized ( ) ;
}
private void DecreaseWIndowSize ( )
{
switch ( Global . Config . TargetZoomFactor )
{
case 1 :
return ;
case 2 :
Global . Config . TargetZoomFactor = 1 ;
break ;
case 3 :
Global . Config . TargetZoomFactor = 2 ;
break ;
case 4 :
Global . Config . TargetZoomFactor = 3 ;
break ;
case 5 :
Global . Config . TargetZoomFactor = 4 ;
break ;
case 10 :
Global . Config . TargetZoomFactor = 5 ;
return ;
}
FrameBufferResized ( ) ;
}
2012-06-10 02:19:36 +00:00
2012-07-10 17:22:23 +00:00
private void neverBeAskedToSaveChangesToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . SupressAskSave ^ = true ;
}
2012-07-12 21:39:11 +00:00
private void IncreaseSpeed ( )
{
int oldp = Global . Config . SpeedPercent ;
int newp = 0 ;
if ( oldp < 3 ) newp = 3 ;
else if ( oldp < 6 ) newp = 6 ;
else if ( oldp < 12 ) newp = 12 ;
else if ( oldp < 25 ) newp = 25 ;
else if ( oldp < 50 ) newp = 50 ;
else if ( oldp < 75 ) newp = 75 ;
else if ( oldp < 100 ) newp = 100 ;
else if ( oldp < 150 ) newp = 150 ;
else if ( oldp < 200 ) newp = 200 ;
else if ( oldp < 400 ) newp = 400 ;
else if ( oldp < 800 ) newp = 800 ;
else newp = 1000 ;
SetSpeedPercent ( newp ) ;
}
private void DecreaseSpeed ( )
{
int oldp = Global . Config . SpeedPercent ;
int newp = 0 ;
if ( oldp > 800 ) newp = 800 ;
else if ( oldp > 400 ) newp = 400 ;
else if ( oldp > 200 ) newp = 200 ;
2012-07-13 16:54:33 +00:00
else if ( oldp > 150 ) newp = 150 ;
2012-07-12 21:39:11 +00:00
else if ( oldp > 100 ) newp = 100 ;
2012-07-13 16:54:33 +00:00
else if ( oldp > 75 ) newp = 75 ;
2012-07-12 21:39:11 +00:00
else if ( oldp > 50 ) newp = 50 ;
else if ( oldp > 25 ) newp = 25 ;
else if ( oldp > 12 ) newp = 12 ;
else if ( oldp > 6 ) newp = 6 ;
else if ( oldp > 3 ) newp = 3 ;
else newp = 1 ;
SetSpeedPercent ( newp ) ;
}
2012-07-12 23:13:22 +00:00
public void SetNESSoundChannels ( )
{
NES nes = Global . Emulator as NES ;
nes . SetSquare1 ( Global . Config . NESEnableSquare1 ) ;
nes . SetSquare2 ( Global . Config . NESEnableSquare2 ) ;
nes . SetTriangle ( Global . Config . NESEnableTriangle ) ;
nes . SetNoise ( Global . Config . NESEnableNoise ) ;
nes . SetDMC ( Global . Config . NESEnableDMC ) ;
}
private void soundChannelsToolStripMenuItem_Click ( object sender , EventArgs e )
{
if ( Global . Emulator is NES )
{
Global . Sound . StopSound ( ) ;
NESSoundConfig config = new NESSoundConfig ( ) ;
config . ShowDialog ( ) ;
Global . Sound . StartSound ( ) ;
}
}
2012-07-15 08:50:24 +00:00
2012-09-03 19:42:53 +00:00
public void ClearSaveRAM ( )
{
2012-09-08 19:02:28 +00:00
//zero says: this is sort of sketchy... but this is no time for rearchitecting
2012-09-29 14:55:11 +00:00
/ *
2012-09-08 19:02:28 +00:00
string saveRamPath = PathManager . SaveRamPath ( Global . Game ) ;
var file = new FileInfo ( saveRamPath ) ;
2012-09-03 19:42:53 +00:00
if ( file . Exists ) file . Delete ( ) ;
2012-09-29 14:55:11 +00:00
* /
2012-09-08 19:02:28 +00:00
try
{
2012-09-14 22:28:38 +00:00
/ *
2012-09-08 19:02:28 +00:00
var sram = new byte [ Global . Emulator . ReadSaveRam . Length ] ;
if ( Global . Emulator is LibsnesCore )
( ( LibsnesCore ) Global . Emulator ) . StoreSaveRam ( sram ) ;
2012-09-12 22:18:51 +00:00
else if ( Global . Emulator is Gameboy )
2012-09-14 21:29:35 +00:00
( ( Gameboy ) Global . Emulator ) . ClearSaveRam ( ) ;
2012-09-12 22:18:51 +00:00
else
Array . Copy ( sram , Global . Emulator . ReadSaveRam , Global . Emulator . ReadSaveRam . Length ) ;
2012-09-14 22:28:38 +00:00
* /
Global . Emulator . ClearSaveRam ( ) ;
2012-09-08 19:02:28 +00:00
}
catch { }
2012-09-03 19:42:53 +00:00
}
2012-09-12 22:18:51 +00:00
private void changeDMGPalettesToolStripMenuItem_Click ( object sender , EventArgs e )
{
if ( Global . Emulator is Gameboy )
{
2012-11-18 18:46:57 +00:00
var g = Global . Emulator as Gameboy ;
if ( g . IsCGBMode ( ) )
{
if ( GBtools . CGBColorChooserForm . DoCGBColorChooserFormDialog ( this ) )
{
g . SetCGBColors ( Global . Config . CGBColors ) ;
}
}
else
{
GBtools . ColorChooserForm . DoColorChooserFormDialog ( g . ChangeDMGColors , this ) ;
}
2012-09-12 22:18:51 +00:00
}
}
2012-09-22 04:04:35 +00:00
private void captureOSDToolStripMenuItem1_Click ( object sender , EventArgs e )
{
Global . Config . Screenshot_CaptureOSD ^ = true ;
}
private void screenshotToolStripMenuItem_DropDownOpening ( object sender , EventArgs e )
{
captureOSDToolStripMenuItem1 . Checked = Global . Config . Screenshot_CaptureOSD ;
}
2012-09-26 15:59:14 +00:00
private void sNESToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
2012-10-05 04:47:45 +00:00
if ( ( Global . Emulator as LibsnesCore ) . IsSGB )
2012-09-26 15:59:14 +00:00
{
loadGBInSGBToolStripMenuItem . Visible = true ;
loadGBInSGBToolStripMenuItem . Checked = Global . Config . GB_AsSGB ;
}
else
loadGBInSGBToolStripMenuItem . Visible = false ;
}
private void loadGBInSGBToolStripMenuItem1_Click ( object sender , EventArgs e )
{
loadGBInSGBToolStripMenuItem_Click ( sender , e ) ;
}
private void loadGBInSGBToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . GB_AsSGB ^ = true ;
2012-09-29 23:03:51 +00:00
FlagNeedsReboot ( ) ;
2012-09-26 15:59:14 +00:00
}
2012-09-29 14:43:35 +00:00
private void MainForm_Resize ( object sender , EventArgs e )
{
Global . RenderPanel . Resized = true ;
}
2012-09-29 15:32:44 +00:00
private void backupSaveramToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . BackupSaveram ^ = true ;
if ( Global . Config . BackupSaveram )
{
Global . OSD . AddMessage ( "Backup saveram enabled" ) ;
}
else
{
Global . OSD . AddMessage ( "Backup saveram disabled" ) ;
}
}
2012-09-29 23:03:51 +00:00
private void toolStripStatusLabel2_Click ( object sender , EventArgs e )
{
RebootCore ( ) ;
}
private void SetRebootIconStatus ( )
{
if ( NeedsReboot )
{
RebootStatusBarIcon . Visible = true ;
}
else
{
RebootStatusBarIcon . Visible = false ;
}
}
private void FlagNeedsReboot ( )
{
NeedsReboot = true ;
SetRebootIconStatus ( ) ;
Global . OSD . AddMessage ( "Core reboot needed for this setting" ) ;
}
2012-09-30 00:53:08 +00:00
private void traceLoggerToolStripMenuItem_Click ( object sender , EventArgs e )
{
LoadTraceLogger ( ) ;
}
2012-10-01 02:30:25 +00:00
private void blurryToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . DispBlurry ^ = true ;
}
2012-10-06 12:27:56 +00:00
private void showClippedRegionsToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . GGShowClippedRegions ^ = true ;
2012-12-10 00:43:43 +00:00
Global . CoreComm . GG_ShowClippedRegions = Global . Config . GGShowClippedRegions ;
2012-10-06 12:27:56 +00:00
}
2012-10-06 12:37:38 +00:00
private void highlightActiveDisplayRegionToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . GGHighlightActiveDisplayRegion ^ = true ;
2012-12-10 00:43:43 +00:00
Global . CoreComm . GG_HighlightActiveDisplayRegion = Global . Config . GGHighlightActiveDisplayRegion ;
2012-10-06 12:37:38 +00:00
}
2012-10-08 00:27:21 +00:00
private void loadConfigToolStripMenuItem_Click_1 ( object sender , EventArgs e )
{
}
2012-10-28 22:50:19 +00:00
private void saveMovieToolStripMenuItem_Click ( object sender , EventArgs e )
2012-10-28 23:38:41 +00:00
{
SaveMovie ( ) ;
}
private void SaveMovie ( )
2012-10-28 22:50:19 +00:00
{
if ( Global . MovieSession . Movie . IsActive )
{
Global . MovieSession . Movie . WriteMovie ( ) ;
Global . OSD . AddMessage ( Global . MovieSession . Movie . Filename + " saved." ) ;
}
}
2012-10-28 23:38:41 +00:00
private void saveMovieToolStripMenuItem1_Click ( object sender , EventArgs e )
{
SaveMovie ( ) ;
}
2012-10-29 22:57:15 +00:00
private void virtualPadToolStripMenuItem_Click ( object sender , EventArgs e )
{
LoadVirtualPads ( ) ;
}
2012-10-30 00:18:56 +00:00
private void showBGToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . Atari2600_ShowBG ^ = true ;
2012-12-10 00:43:43 +00:00
SyncCoreCommInputSignals ( ) ;
2012-10-30 00:18:56 +00:00
}
private void showPlayer1ToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . Atari2600_ShowPlayer1 ^ = true ;
2012-12-10 00:43:43 +00:00
SyncCoreCommInputSignals ( ) ;
2012-10-30 00:18:56 +00:00
}
private void showPlayer2ToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . Atari2600_ShowPlayer2 ^ = true ;
2012-12-10 00:43:43 +00:00
SyncCoreCommInputSignals ( ) ;
2012-10-30 00:18:56 +00:00
}
private void showMissle1ToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . Atari2600_ShowMissle1 ^ = true ;
2012-12-10 00:43:43 +00:00
SyncCoreCommInputSignals ( ) ;
2012-10-30 00:18:56 +00:00
}
private void showMissle2ToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . Atari2600_ShowMissle2 ^ = true ;
2012-12-10 00:43:43 +00:00
SyncCoreCommInputSignals ( ) ;
2012-10-30 00:18:56 +00:00
}
private void showBallToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . Atari2600_ShowBall ^ = true ;
2012-12-10 00:43:43 +00:00
SyncCoreCommInputSignals ( ) ;
2012-10-30 00:18:56 +00:00
}
2012-10-30 23:38:53 +00:00
private void showPlayfieldToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . Atari2600_ShowPlayfield ^ = true ;
2012-12-10 00:43:43 +00:00
SyncCoreCommInputSignals ( ) ;
2012-10-30 23:38:53 +00:00
}
2012-11-05 01:34:11 +00:00
private void gPUViewerToolStripMenuItem_Click ( object sender , EventArgs e )
{
LoadGBGPUView ( ) ;
}
2012-11-12 17:57:11 +00:00
private void miLimitFramerate_DropDownOpened ( object sender , EventArgs e )
{
}
2012-11-22 02:01:15 +00:00
private void skipBIOIntroToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . ColecoSkipBiosIntro ^ = true ;
FlagNeedsReboot ( ) ;
}
private void colecoToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
2012-11-23 03:10:01 +00:00
skipBIOSIntroToolStripMenuItem . Checked = Global . Config . ColecoSkipBiosIntro ;
2012-11-22 02:01:15 +00:00
}
2012-11-26 01:28:14 +00:00
private void HandleToggleLight ( )
{
if ( StatusSlot0 . Visible )
{
2012-12-10 00:43:43 +00:00
if ( Global . Emulator . CoreComm . UsesDriveLed )
2012-11-26 01:28:14 +00:00
{
if ( ! StatusBarLedLight . Visible )
{
StatusBarLedLight . Visible = true ;
}
2012-12-10 00:43:43 +00:00
if ( Global . Emulator . CoreComm . DriveLED )
2012-11-26 01:28:14 +00:00
{
StatusBarLedLight . Image = BizHawk . MultiClient . Properties . Resources . LightOn ;
}
else
{
StatusBarLedLight . Image = BizHawk . MultiClient . Properties . Resources . LightOff ;
}
}
else
{
if ( StatusBarLedLight . Visible )
{
StatusBarLedLight . Visible = false ;
}
}
}
}
2012-11-26 23:16:31 +00:00
private void gPUViewToolStripMenuItem_Click ( object sender , EventArgs e )
{
LoadGBAGPUView ( ) ;
}
2012-12-02 15:18:28 +00:00
private void bothHotkeysAndControllersToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . Input_Hotkey_OverrideOptions = 0 ;
2012-12-02 16:17:42 +00:00
UpdateKeyPriorityIcon ( ) ;
2012-12-02 15:18:28 +00:00
}
private void inputOverridesHotkeysToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . Input_Hotkey_OverrideOptions = 1 ;
2012-12-02 16:17:42 +00:00
UpdateKeyPriorityIcon ( ) ;
2012-12-02 15:18:28 +00:00
}
private void hotkeysOverrideInputToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . Input_Hotkey_OverrideOptions = 2 ;
2012-12-02 16:17:42 +00:00
UpdateKeyPriorityIcon ( ) ;
2012-12-02 15:18:28 +00:00
}
private void keyPriorityToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
switch ( Global . Config . Input_Hotkey_OverrideOptions )
{
default :
case 0 :
bothHotkeysAndControllersToolStripMenuItem . Checked = true ;
inputOverridesHotkeysToolStripMenuItem . Checked = false ;
hotkeysOverrideInputToolStripMenuItem . Checked = false ;
break ;
case 1 :
bothHotkeysAndControllersToolStripMenuItem . Checked = false ;
inputOverridesHotkeysToolStripMenuItem . Checked = true ;
hotkeysOverrideInputToolStripMenuItem . Checked = false ;
break ;
case 2 :
bothHotkeysAndControllersToolStripMenuItem . Checked = false ;
inputOverridesHotkeysToolStripMenuItem . Checked = false ;
hotkeysOverrideInputToolStripMenuItem . Checked = true ;
break ;
}
}
2012-12-02 16:17:42 +00:00
private void KeyPriorityStatusBarLabel_Click ( object sender , EventArgs e )
{
switch ( Global . Config . Input_Hotkey_OverrideOptions )
{
default :
case 0 :
Global . Config . Input_Hotkey_OverrideOptions = 1 ;
break ;
case 1 :
Global . Config . Input_Hotkey_OverrideOptions = 2 ;
break ;
case 2 :
Global . Config . Input_Hotkey_OverrideOptions = 0 ;
break ;
}
UpdateKeyPriorityIcon ( ) ;
}
private void UpdateKeyPriorityIcon ( )
{
switch ( Global . Config . Input_Hotkey_OverrideOptions )
{
default :
case 0 :
KeyPriorityStatusBarLabel . Image = BizHawk . MultiClient . Properties . Resources . Both ;
KeyPriorityStatusBarLabel . ToolTipText = "Key priority: Allow both hotkeys and controller buttons" ;
break ;
case 1 :
KeyPriorityStatusBarLabel . Image = BizHawk . MultiClient . Properties . Resources . GameController ;
KeyPriorityStatusBarLabel . ToolTipText = "Key priority: Controller buttons will override hotkeys" ;
break ;
case 2 :
KeyPriorityStatusBarLabel . Image = BizHawk . MultiClient . Properties . Resources . HotKeys ;
KeyPriorityStatusBarLabel . ToolTipText = "Key priority: Hotkeys will override controller buttons" ;
break ;
}
}
2012-12-25 20:36:04 +00:00
2013-03-09 19:54:50 +00:00
private void fullMovieLoadstatesToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . VBAStyleMovieLoadState ^ = true ;
}
2013-03-09 23:11:00 +00:00
private void ToggleModePokeMode ( )
{
Global . Config . MoviePlaybackPokeMode ^ = true ;
if ( Global . Config . MoviePlaybackPokeMode )
{
Global . OSD . AddMessage ( "Movie Poke mode enabled" ) ;
}
else
{
Global . OSD . AddMessage ( "Movie Poke mode disabled" ) ;
}
}
2011-02-20 08:40:22 +00:00
}
2012-03-09 12:10:41 +00:00
}