2006-07-29 05:46:15 +00:00
/* FCE Ultra - NES/Famicom Emulator
2008-06-07 08:18:04 +00:00
*
* Copyright notice for this file :
* Copyright ( C ) 1998 BERO
* Copyright ( C ) 2002 Xodnizel
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
2012-08-04 22:33:16 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA
2008-06-07 08:18:04 +00:00
*/
2008-05-23 09:58:38 +00:00
2006-07-29 05:46:15 +00:00
# include "types.h"
# include "x6502.h"
# include "fceu.h"
# include "sound.h"
# include "netplay.h"
# include "movie.h"
# include "state.h"
2008-06-06 08:23:12 +00:00
# include "input/zapper.h"
2008-09-24 06:06:31 +00:00
# ifdef _S9XLUA_H
2008-07-23 06:54:14 +00:00
# include "fceulua.h"
2008-09-24 06:06:31 +00:00
# endif
2006-07-29 05:46:15 +00:00
# include "input.h"
# include "vsuni.h"
# include "fds.h"
2008-06-17 06:55:07 +00:00
# include "driver.h"
2006-07-29 05:46:15 +00:00
2006-08-21 14:19:02 +00:00
# ifdef WIN32
2008-07-07 15:54:38 +00:00
# include "drivers/win/main.h"
# include "drivers/win/memwatch.h"
# include "drivers/win/cheat.h"
# include "drivers/win/debugger.h"
# include "drivers/win/ppuview.h"
# include "drivers/win/cdlogger.h"
# include "drivers/win/tracer.h"
# include "drivers/win/memview.h"
2011-01-11 03:30:15 +00:00
# include "drivers/win/window.h"
2011-05-09 05:57:35 +00:00
# include "drivers/win/ntview.h"
2012-06-12 17:29:18 +00:00
# include "drivers/win/taseditor.h"
2013-04-13 02:52:13 +00:00
# include <string>
# include <ostream>
# include <cstring>
2013-03-04 16:58:54 +00:00
extern bool mustRewindNow ;
2006-08-21 14:19:02 +00:00
# endif // WIN32
2006-08-21 13:40:13 +00:00
2008-06-07 08:18:04 +00:00
//it is easier to declare these input drivers extern here than include a bunch of files
//-------------
2006-07-29 05:46:15 +00:00
extern INPUTC * FCEU_InitZapper ( int w ) ;
extern INPUTC * FCEU_InitPowerpadA ( int w ) ;
extern INPUTC * FCEU_InitPowerpadB ( int w ) ;
extern INPUTC * FCEU_InitArkanoid ( int w ) ;
2016-04-23 03:01:32 +00:00
extern INPUTC * FCEU_InitMouse ( int w ) ;
2016-04-23 04:58:30 +00:00
extern INPUTC * FCEU_InitSNESMouse ( int w ) ;
2020-02-07 11:50:10 +00:00
extern INPUTC * FCEU_InitVirtualBoy ( int w ) ;
2020-07-21 03:28:29 +00:00
extern INPUTC * FCEU_InitLCDCompZapper ( int w ) ;
2006-07-29 05:46:15 +00:00
extern INPUTCFC * FCEU_InitArkanoidFC ( void ) ;
extern INPUTCFC * FCEU_InitSpaceShadow ( void ) ;
extern INPUTCFC * FCEU_InitFKB ( void ) ;
extern INPUTCFC * FCEU_InitSuborKB ( void ) ;
2014-01-12 14:53:50 +00:00
extern INPUTCFC * FCEU_InitPEC586KB ( void ) ;
2006-07-29 05:46:15 +00:00
extern INPUTCFC * FCEU_InitHS ( void ) ;
extern INPUTCFC * FCEU_InitMahjong ( void ) ;
2014-11-22 01:23:19 +00:00
extern INPUTCFC * FCEU_InitQuizKing ( void ) ;
2006-07-29 05:46:15 +00:00
extern INPUTCFC * FCEU_InitFamilyTrainerA ( void ) ;
extern INPUTCFC * FCEU_InitFamilyTrainerB ( void ) ;
extern INPUTCFC * FCEU_InitOekaKids ( void ) ;
extern INPUTCFC * FCEU_InitTopRider ( void ) ;
2020-01-04 10:16:54 +00:00
extern INPUTCFC * FCEU_InitFamiNetSys ( void ) ;
2014-11-22 01:23:19 +00:00
extern INPUTCFC * FCEU_InitBarcodeWorld ( void ) ;
2008-06-07 08:18:04 +00:00
//---------------
2006-07-29 05:46:15 +00:00
2008-07-10 04:55:52 +00:00
//global lag variables
unsigned int lagCounter ;
2008-07-09 05:47:13 +00:00
bool lagCounterDisplay ;
2008-08-07 04:56:40 +00:00
char lagFlag ;
2008-08-07 15:56:39 +00:00
extern bool frameAdvanceLagSkip ;
2008-11-23 22:20:00 +00:00
extern bool movieSubtitles ;
2008-07-10 04:55:52 +00:00
//-------------
2006-07-29 05:46:15 +00:00
static uint8 joy_readbit [ 2 ] ;
2008-06-08 10:22:33 +00:00
uint8 joy [ 4 ] = { 0 , 0 , 0 , 0 } ; //HACK - should be static but movie needs it
2016-03-30 21:40:59 +00:00
uint16 snesjoy [ 4 ] = { 0 , 0 , 0 , 0 } ; //HACK - should be static but movie needs it
2006-07-29 05:46:15 +00:00
static uint8 LastStrobe ;
2014-07-13 12:22:22 +00:00
uint8 RawReg4016 = 0 ; // Joystick strobe (W)
2006-07-29 05:46:15 +00:00
2014-11-22 01:23:19 +00:00
bool replaceP2StartWithMicrophone = false ;
2010-04-28 08:06:56 +00:00
2008-06-07 08:18:04 +00:00
//This function is a quick hack to get the NSF player to use emulated gamepad input.
2006-07-29 05:46:15 +00:00
uint8 FCEU_GetJoyJoy ( void )
{
2008-06-07 08:18:04 +00:00
return ( joy [ 0 ] | joy [ 1 ] | joy [ 2 ] | joy [ 3 ] ) ;
2006-07-29 05:46:15 +00:00
}
2008-06-07 08:18:04 +00:00
2006-07-29 05:46:15 +00:00
extern uint8 coinon ;
2023-01-06 13:58:02 +00:00
extern uint8 coinon2 ;
extern uint8 service ;
2006-07-29 05:46:15 +00:00
2008-06-09 08:15:20 +00:00
//set to true if the fourscore is attached
static bool FSAttached = false ;
2006-07-29 05:46:15 +00:00
2008-06-08 10:22:33 +00:00
JOYPORT joyports [ 2 ] = { JOYPORT ( 0 ) , JOYPORT ( 1 ) } ;
FCPORT portFC ;
2006-07-29 05:46:15 +00:00
2015-11-15 21:26:52 +00:00
FILE * DumpInputFile ;
FILE * PlayInputFile ;
2008-06-07 08:18:04 +00:00
static DECLFR ( JPRead )
2006-07-29 05:46:15 +00:00
{
2008-08-07 04:56:40 +00:00
lagFlag = 0 ;
2008-06-07 08:18:04 +00:00
uint8 ret = 0 ;
2010-04-28 08:06:56 +00:00
static bool microphone = false ;
2008-06-07 08:18:04 +00:00
ret | = joyports [ A & 1 ] . driver - > Read ( A & 1 ) ;
2008-06-07 01:21:38 +00:00
2010-04-28 19:25:52 +00:00
// Test if the port 2 start button is being pressed.
// On a famicom, port 2 start shouldn't exist, so this removes it.
// Games can't automatically be checked for NES/Famicom status,
// so it's an all-encompassing change in the input config menu.
if ( ( replaceP2StartWithMicrophone ) & & ( A & 1 ) & & ( joy_readbit [ 1 ] = = 4 ) ) {
// Nullify Port 2 Start Button
ret & = 0xFE ;
}
2008-06-07 08:18:04 +00:00
if ( portFC . driver )
ret = portFC . driver - > Read ( A & 1 , ret ) ;
2010-04-28 08:06:56 +00:00
// Not verified against hardware.
2010-04-28 19:25:52 +00:00
if ( replaceP2StartWithMicrophone ) {
2010-04-28 21:51:08 +00:00
if ( joy [ 1 ] & 8 ) {
microphone = ! microphone ;
if ( microphone ) {
ret | = 4 ;
2010-04-28 08:06:56 +00:00
}
2010-04-28 21:51:08 +00:00
} else {
microphone = false ;
2010-04-28 08:06:56 +00:00
}
}
2015-11-15 21:26:52 +00:00
if ( PlayInputFile )
ret = fgetc ( PlayInputFile ) ;
if ( DumpInputFile )
fputc ( ret , DumpInputFile ) ;
2008-06-07 08:18:04 +00:00
ret | = X . DB & 0xC0 ;
2010-04-28 19:25:52 +00:00
2008-06-07 08:18:04 +00:00
return ( ret ) ;
2006-07-29 05:46:15 +00:00
}
2008-06-07 08:18:04 +00:00
static DECLFW ( B4016 )
2006-07-29 05:46:15 +00:00
{
2008-06-07 08:18:04 +00:00
if ( portFC . driver )
portFC . driver - > Write ( V & 7 ) ;
2006-07-29 05:46:15 +00:00
2008-06-07 08:18:04 +00:00
for ( int i = 0 ; i < 2 ; i + + )
joyports [ i ] . driver - > Write ( V & 1 ) ;
if ( ( LastStrobe & 1 ) & & ( ! ( V & 1 ) ) )
{
//old comment:
//This strobe code is just for convenience. If it were
//with the code in input / *.c, it would more accurately represent
//what's really going on. But who wants accuracy? ;)
//Seriously, though, this shouldn't be a problem.
//new comment:
2012-10-21 16:40:04 +00:00
2008-06-07 08:18:04 +00:00
//mbg 6/7/08 - I guess he means that the input drivers could track the strobing themselves
//I dont see why it is unreasonable here.
for ( int i = 0 ; i < 2 ; i + + )
2008-06-09 08:15:20 +00:00
joyports [ i ] . driver - > Strobe ( i ) ;
2008-06-07 08:18:04 +00:00
if ( portFC . driver )
portFC . driver - > Strobe ( ) ;
}
LastStrobe = V & 0x1 ;
2014-07-13 12:22:22 +00:00
RawReg4016 = V ;
2006-07-29 05:46:15 +00:00
}
2008-06-07 08:18:04 +00:00
//a main joystick port driver representing the case where nothing is plugged in
2013-04-16 19:53:01 +00:00
static INPUTC DummyJPort = { 0 } ;
2008-06-07 08:18:04 +00:00
//and an expansion port driver for the same ting
2013-04-16 19:53:01 +00:00
static INPUTCFC DummyPortFC = { 0 } ;
2008-06-07 01:21:38 +00:00
2006-07-29 05:46:15 +00:00
2008-06-07 08:18:04 +00:00
//--------4 player driver for expansion port--------
static uint8 F4ReadBit [ 2 ] ;
static void StrobeFami4 ( void )
{
F4ReadBit [ 0 ] = F4ReadBit [ 1 ] = 0 ;
}
static uint8 ReadFami4 ( int w , uint8 ret )
{
ret & = 1 ;
ret | = ( ( joy [ 2 + w ] > > ( F4ReadBit [ w ] ) ) & 1 ) < < 1 ;
if ( F4ReadBit [ w ] > = 8 ) ret | = 2 ;
else F4ReadBit [ w ] + + ;
2006-07-29 05:46:15 +00:00
return ( ret ) ;
}
2008-06-07 08:18:04 +00:00
static INPUTCFC FAMI4C = { ReadFami4 , 0 , StrobeFami4 , 0 , 0 , 0 } ;
//------------------
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
static uint8 ReadGPVS ( int w )
2006-07-29 05:46:15 +00:00
{
2008-06-07 08:18:04 +00:00
uint8 ret = 0 ;
if ( joy_readbit [ w ] > = 8 )
ret = 1 ;
else
{
ret = ( ( joy [ w ] > > ( joy_readbit [ w ] ) ) & 1 ) ;
if ( ! fceuindbg )
joy_readbit [ w ] + + ;
}
return ret ;
2006-07-29 05:46:15 +00:00
}
2008-06-08 06:23:43 +00:00
static void UpdateGP ( int w , void * data , int arg )
{
2009-03-14 21:00:28 +00:00
if ( w = = 0 ) //adelikat, 3/14/09: Changing the joypads to inclusive OR the user's joypad + the Lua joypad, this way lua only takes over the buttons it explicity says to
2009-09-15 16:39:49 +00:00
{ //FatRatKnight: Assume lua is always good. If it's doing nothing in particular using my logic, it'll pass-through the values anyway.
2008-09-24 06:06:31 +00:00
# ifdef _S9XLUA_H
2009-09-15 16:39:49 +00:00
joy [ 0 ] = * ( uint32 * ) joyports [ 0 ] . ptr ;
joy [ 0 ] = FCEU_LuaReadJoypad ( 0 , joy [ 0 ] ) ;
joy [ 2 ] = * ( uint32 * ) joyports [ 0 ] . ptr > > 16 ;
joy [ 2 ] = FCEU_LuaReadJoypad ( 2 , joy [ 2 ] ) ;
2009-04-15 03:40:08 +00:00
# else // without this, there seems to be no input at all without Lua
joy [ 0 ] = * ( uint32 * ) joyports [ 0 ] . ptr ; ;
joy [ 2 ] = * ( uint32 * ) joyports [ 0 ] . ptr > > 16 ;
2008-09-24 06:06:31 +00:00
# endif
2008-06-08 06:23:43 +00:00
}
else
{
2008-09-24 06:06:31 +00:00
# ifdef _S9XLUA_H
2009-09-15 16:39:49 +00:00
joy [ 1 ] = * ( uint32 * ) joyports [ 1 ] . ptr > > 8 ;
joy [ 1 ] = FCEU_LuaReadJoypad ( 1 , joy [ 1 ] ) ;
joy [ 3 ] = * ( uint32 * ) joyports [ 1 ] . ptr > > 24 ;
joy [ 3 ] = FCEU_LuaReadJoypad ( 3 , joy [ 3 ] ) ;
2009-04-15 03:40:08 +00:00
# else // same goes for the other two pads
joy [ 1 ] = * ( uint32 * ) joyports [ 1 ] . ptr > > 8 ;
joy [ 3 ] = * ( uint32 * ) joyports [ 1 ] . ptr > > 24 ;
2008-09-24 06:06:31 +00:00
# endif
2008-06-08 06:23:43 +00:00
}
2008-08-04 16:02:46 +00:00
2008-06-08 06:23:43 +00:00
}
2008-06-08 10:22:33 +00:00
static void LogGP ( int w , MovieRecord * mr )
{
if ( w = = 0 )
{
mr - > joysticks [ 0 ] = joy [ 0 ] ;
mr - > joysticks [ 2 ] = joy [ 2 ] ;
}
else
{
mr - > joysticks [ 1 ] = joy [ 1 ] ;
mr - > joysticks [ 3 ] = joy [ 3 ] ;
}
}
static void LoadGP ( int w , MovieRecord * mr )
{
if ( w = = 0 )
{
joy [ 0 ] = mr - > joysticks [ 0 ] ;
2008-08-12 07:32:44 +00:00
if ( FSAttached ) joy [ 2 ] = mr - > joysticks [ 2 ] ;
2008-06-08 10:22:33 +00:00
}
else
{
joy [ 1 ] = mr - > joysticks [ 1 ] ;
2008-08-12 07:32:44 +00:00
if ( FSAttached ) joy [ 3 ] = mr - > joysticks [ 3 ] ;
2008-06-08 10:22:33 +00:00
}
}
2008-06-07 08:18:04 +00:00
//basic joystick port driver
static uint8 ReadGP ( int w )
2006-07-29 05:46:15 +00:00
{
2008-06-07 08:18:04 +00:00
uint8 ret ;
if ( joy_readbit [ w ] > = 8 )
ret = ( ( joy [ 2 + w ] > > ( joy_readbit [ w ] & 7 ) ) & 1 ) ;
else
ret = ( ( joy [ w ] > > ( joy_readbit [ w ] ) ) & 1 ) ;
if ( joy_readbit [ w ] > = 16 ) ret = 0 ;
2008-06-09 08:15:20 +00:00
if ( ! FSAttached )
2008-06-07 08:18:04 +00:00
{
if ( joy_readbit [ w ] > = 8 ) ret | = 1 ;
}
else
{
if ( joy_readbit [ w ] = = 19 - w ) ret | = 1 ;
}
if ( ! fceuindbg )
joy_readbit [ w ] + + ;
return ret ;
2006-07-29 05:46:15 +00:00
}
2008-06-08 06:23:43 +00:00
static void StrobeGP ( int w )
{
joy_readbit [ w ] = 0 ;
}
2013-04-10 20:58:01 +00:00
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2008-06-07 08:18:04 +00:00
2016-03-30 21:40:59 +00:00
//SNES pad
static void UpdateSNES ( int w , void * data , int arg )
{
//LUA NOT SUPPORTED YET
if ( w = = 0 )
{
snesjoy [ 0 ] = ( ( uint32 * ) joyports [ 0 ] . ptr ) [ 0 ] ;
snesjoy [ 2 ] = ( ( uint32 * ) joyports [ 0 ] . ptr ) [ 2 ] ;
}
else
{
snesjoy [ 1 ] = ( ( uint32 * ) joyports [ 0 ] . ptr ) [ 1 ] ;
snesjoy [ 3 ] = ( ( uint32 * ) joyports [ 0 ] . ptr ) [ 3 ] ;
}
}
static void LogSNES ( int w , MovieRecord * mr )
{
//not supported for SNES pad right noe
}
static void LoadSNES ( int w , MovieRecord * mr )
{
//not supported for SNES pad right now
}
static uint8 ReadSNES ( int w )
{
//no fourscore support on snes (not clear how it would work)
uint8 ret ;
if ( joy_readbit [ w ] > = 16 )
ret = 1 ;
else
{
ret = ( ( snesjoy [ w ] > > ( joy_readbit [ w ] ) ) & 1 ) ;
}
if ( ! fceuindbg )
joy_readbit [ w ] + + ;
return ret ;
}
static void StrobeSNES ( int w )
{
joy_readbit [ w ] = 0 ;
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020-10-06 06:37:31 +00:00
//--------Hori 4 player driver for expansion port--------
static uint8 Hori4ReadBit [ 2 ] ;
static void StrobeHori4 ( void )
{
Hori4ReadBit [ 0 ] = Hori4ReadBit [ 1 ] = 0 ;
}
static uint8 ReadHori4 ( int w , uint8 ret )
{
ret & = 1 ;
if ( Hori4ReadBit [ w ] < 8 )
{
ret | = ( ( joy [ w ] > > ( Hori4ReadBit [ w ] ) ) & 1 ) < < 1 ;
}
else if ( Hori4ReadBit [ w ] < 16 )
{
ret | = ( ( joy [ 2 + w ] > > ( Hori4ReadBit [ w ] - 8 ) ) & 1 ) < < 1 ;
}
else if ( Hori4ReadBit [ w ] < 24 )
{
ret | = ( ( ( w ? 0x10 : 0x20 ) > > ( 7 - ( Hori4ReadBit [ w ] - 16 ) ) ) & 1 ) < < 1 ;
}
if ( Hori4ReadBit [ w ] > = 24 ) ret | = 2 ;
else Hori4ReadBit [ w ] + + ;
2016-03-30 21:40:59 +00:00
2020-10-06 06:37:31 +00:00
return ( ret ) ;
}
static INPUTCFC HORI4C = { ReadHori4 , 0 , StrobeHori4 , 0 , 0 , 0 } ;
//------------------
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2008-06-07 08:18:04 +00:00
2008-06-08 10:22:33 +00:00
static INPUTC GPC = { ReadGP , 0 , StrobeGP , UpdateGP , 0 , 0 , LogGP , LoadGP } ;
static INPUTC GPCVS = { ReadGPVS , 0 , StrobeGP , UpdateGP , 0 , 0 , LogGP , LoadGP } ;
2016-03-30 21:40:59 +00:00
static INPUTC GPSNES = { ReadSNES , 0 , StrobeSNES , UpdateSNES , 0 , 0 , LogSNES , LoadSNES } ;
2006-07-29 05:46:15 +00:00
void FCEU_DrawInput ( uint8 * buf )
{
2008-06-07 08:18:04 +00:00
for ( int pad = 0 ; pad < 2 ; pad + + )
joyports [ pad ] . driver - > Draw ( pad , buf , joyports [ pad ] . attrib ) ;
if ( portFC . driver )
portFC . driver - > Draw ( buf , portFC . attrib ) ;
2006-07-29 05:46:15 +00:00
}
2008-06-08 10:22:33 +00:00
2006-07-29 05:46:15 +00:00
void FCEU_UpdateInput ( void )
{
2008-06-08 10:22:33 +00:00
//tell all drivers to poll input and set up their logical states
2008-07-31 16:21:42 +00:00
if ( ! FCEUMOV_Mode ( MOVIEMODE_PLAY ) )
2006-07-29 05:46:15 +00:00
{
2013-04-10 20:58:01 +00:00
for ( int port = 0 ; port < 2 ; port + + ) {
2008-06-08 06:23:43 +00:00
joyports [ port ] . driver - > Update ( port , joyports [ port ] . ptr , joyports [ port ] . attrib ) ;
2016-04-23 03:01:32 +00:00
}
2008-06-07 08:18:04 +00:00
portFC . driver - > Update ( portFC . ptr , portFC . attrib ) ;
2012-10-21 16:40:04 +00:00
}
2006-07-29 05:46:15 +00:00
2023-01-06 13:58:02 +00:00
if ( GameInfo - > type = = GIT_VSUNI ) {
if ( coinon ) coinon - - ;
if ( coinon2 ) coinon2 - - ;
if ( service ) service - - ;
}
2006-07-29 05:46:15 +00:00
if ( FCEUnetplay )
NetplayUpdate ( joy ) ;
2008-06-08 10:22:33 +00:00
FCEUMOV_AddInputState ( ) ;
2012-10-21 16:40:04 +00:00
2008-06-08 10:22:33 +00:00
//TODO - should this apply to the movie data? should this be displayed in the input hud?
2013-04-10 20:58:01 +00:00
if ( GameInfo - > type = = GIT_VSUNI ) {
2006-07-29 05:46:15 +00:00
FCEU_VSUniSwap ( & joy [ 0 ] , & joy [ 1 ] ) ;
2016-04-23 03:01:32 +00:00
}
2006-07-29 05:46:15 +00:00
}
static DECLFR ( VSUNIRead0 )
2008-06-07 01:21:38 +00:00
{
2008-08-07 04:56:40 +00:00
lagFlag = 0 ;
2008-06-07 08:18:04 +00:00
uint8 ret = 0 ;
2008-06-07 01:21:38 +00:00
2008-06-07 08:18:04 +00:00
ret | = ( joyports [ 0 ] . driver - > Read ( 0 ) ) & 1 ;
2008-06-07 01:21:38 +00:00
2008-06-07 08:18:04 +00:00
ret | = ( vsdip & 3 ) < < 3 ;
if ( coinon )
2023-01-06 13:58:02 +00:00
ret | = 0x20 ;
if ( coinon2 )
ret | = 0x40 ;
if ( service )
ret | = 0x04 ;
2008-06-07 08:18:04 +00:00
return ret ;
2006-07-29 05:46:15 +00:00
}
2008-06-07 01:21:38 +00:00
2006-07-29 05:46:15 +00:00
static DECLFR ( VSUNIRead1 )
{
2008-08-07 04:56:40 +00:00
lagFlag = 0 ;
2008-06-07 08:18:04 +00:00
uint8 ret = 0 ;
2008-06-07 01:21:38 +00:00
2008-06-07 08:18:04 +00:00
ret | = ( joyports [ 1 ] . driver - > Read ( 1 ) ) & 1 ;
ret | = vsdip & 0xFC ;
return ret ;
2008-06-07 01:21:38 +00:00
}
2006-07-29 05:46:15 +00:00
2008-06-07 08:18:04 +00:00
//calls from the ppu;
//calls the SLHook for any driver that needs it
void InputScanlineHook ( uint8 * bg , uint8 * spr , uint32 linets , int final )
2006-07-29 05:46:15 +00:00
{
2008-06-07 08:18:04 +00:00
for ( int port = 0 ; port < 2 ; port + + )
joyports [ port ] . driver - > SLHook ( port , bg , spr , linets , final ) ;
portFC . driver - > SLHook ( bg , spr , linets , final ) ;
2006-07-29 05:46:15 +00:00
}
2013-04-10 20:58:01 +00:00
# include <iostream>
2008-06-07 08:18:04 +00:00
//binds JPorts[pad] to the driver specified in JPType[pad]
static void SetInputStuff ( int port )
2006-07-29 05:46:15 +00:00
{
2008-06-07 08:18:04 +00:00
switch ( joyports [ port ] . type )
{
case SI_GAMEPAD :
2021-03-20 01:37:27 +00:00
if ( GameInfo )
{
if ( GameInfo - > type = = GIT_VSUNI ) {
joyports [ port ] . driver = & GPCVS ;
} else {
joyports [ port ] . driver = & GPC ;
}
}
else
{
2008-06-07 08:18:04 +00:00
joyports [ port ] . driver = & GPC ;
2016-04-23 03:01:32 +00:00
}
2008-06-07 08:18:04 +00:00
break ;
2016-03-30 21:40:59 +00:00
case SI_SNES :
joyports [ port ] . driver = & GPSNES ;
break ;
2008-06-07 08:18:04 +00:00
case SI_ARKANOID :
joyports [ port ] . driver = FCEU_InitArkanoid ( port ) ;
break ;
case SI_ZAPPER :
joyports [ port ] . driver = FCEU_InitZapper ( port ) ;
break ;
case SI_POWERPADA :
joyports [ port ] . driver = FCEU_InitPowerpadA ( port ) ;
break ;
case SI_POWERPADB :
joyports [ port ] . driver = FCEU_InitPowerpadB ( port ) ;
break ;
2016-04-23 03:01:32 +00:00
case SI_MOUSE :
joyports [ port ] . driver = FCEU_InitMouse ( port ) ;
break ;
2016-04-23 04:58:30 +00:00
case SI_SNES_MOUSE :
joyports [ port ] . driver = FCEU_InitSNESMouse ( port ) ;
break ;
2020-02-07 11:50:10 +00:00
case SI_VIRTUALBOY :
joyports [ port ] . driver = FCEU_InitVirtualBoy ( port ) ;
break ;
2020-07-21 03:28:29 +00:00
case SI_LCDCOMP_ZAPPER :
joyports [ port ] . driver = FCEU_InitLCDCompZapper ( port ) ;
2020-07-19 04:32:29 +00:00
break ;
2008-06-07 08:18:04 +00:00
case SI_NONE :
2020-06-16 02:53:45 +00:00
case SI_UNSET :
2008-06-07 08:18:04 +00:00
joyports [ port ] . driver = & DummyJPort ;
break ;
}
2006-07-29 05:46:15 +00:00
}
2008-06-07 08:18:04 +00:00
static void SetInputStuffFC ( )
2006-07-29 05:46:15 +00:00
{
2008-06-07 08:18:04 +00:00
switch ( portFC . type )
{
2012-10-21 16:40:04 +00:00
case SIFC_NONE :
2020-06-16 02:53:45 +00:00
case SIFC_UNSET :
2008-06-07 08:18:04 +00:00
portFC . driver = & DummyPortFC ;
break ;
case SIFC_ARKANOID :
portFC . driver = FCEU_InitArkanoidFC ( ) ;
break ;
case SIFC_SHADOW :
portFC . driver = FCEU_InitSpaceShadow ( ) ;
break ;
case SIFC_OEKAKIDS :
portFC . driver = FCEU_InitOekaKids ( ) ;
break ;
case SIFC_4PLAYER :
portFC . driver = & FAMI4C ;
memset ( & F4ReadBit , 0 , sizeof ( F4ReadBit ) ) ;
break ;
case SIFC_FKB :
portFC . driver = FCEU_InitFKB ( ) ;
break ;
case SIFC_SUBORKB :
portFC . driver = FCEU_InitSuborKB ( ) ;
break ;
2014-01-12 14:53:50 +00:00
case SIFC_PEC586KB :
portFC . driver = FCEU_InitPEC586KB ( ) ;
break ;
2008-06-07 08:18:04 +00:00
case SIFC_HYPERSHOT :
portFC . driver = FCEU_InitHS ( ) ;
break ;
case SIFC_MAHJONG :
portFC . driver = FCEU_InitMahjong ( ) ;
break ;
2014-11-22 01:23:19 +00:00
case SIFC_QUIZKING :
portFC . driver = FCEU_InitQuizKing ( ) ;
2008-06-07 08:18:04 +00:00
break ;
case SIFC_FTRAINERA :
portFC . driver = FCEU_InitFamilyTrainerA ( ) ;
break ;
case SIFC_FTRAINERB :
portFC . driver = FCEU_InitFamilyTrainerB ( ) ;
break ;
2014-11-22 01:23:19 +00:00
case SIFC_BWORLD :
portFC . driver = FCEU_InitBarcodeWorld ( ) ;
2008-06-07 08:18:04 +00:00
break ;
case SIFC_TOPRIDER :
portFC . driver = FCEU_InitTopRider ( ) ;
break ;
2020-01-04 10:16:54 +00:00
case SIFC_FAMINETSYS :
portFC . driver = FCEU_InitFamiNetSys ( ) ;
break ;
2020-10-06 06:37:31 +00:00
case SIFC_HORI4PLAYER :
portFC . driver = & HORI4C ;
memset ( & Hori4ReadBit , 0 , sizeof ( Hori4ReadBit ) ) ;
break ;
2008-06-07 08:18:04 +00:00
}
2006-07-29 05:46:15 +00:00
}
2008-06-07 08:18:04 +00:00
void FCEUI_SetInput ( int port , ESI type , void * ptr , int attrib )
2006-07-29 05:46:15 +00:00
{
2008-06-07 08:18:04 +00:00
joyports [ port ] . attrib = attrib ;
joyports [ port ] . type = type ;
joyports [ port ] . ptr = ptr ;
SetInputStuff ( port ) ;
2006-07-29 05:46:15 +00:00
}
2008-06-07 08:18:04 +00:00
void FCEUI_SetInputFC ( ESIFC type , void * ptr , int attrib )
{
portFC . attrib = attrib ;
portFC . type = type ;
portFC . ptr = ptr ;
SetInputStuffFC ( ) ;
2006-07-29 05:46:15 +00:00
}
2008-06-07 08:18:04 +00:00
//initializes the input system to power-on state
2006-07-29 05:46:15 +00:00
void InitializeInput ( void )
2008-06-07 01:21:38 +00:00
{
2006-07-29 05:46:15 +00:00
memset ( joy_readbit , 0 , sizeof ( joy_readbit ) ) ;
2008-06-07 08:18:04 +00:00
memset ( joy , 0 , sizeof ( joy ) ) ;
2006-07-29 05:46:15 +00:00
LastStrobe = 0 ;
2008-06-07 08:18:04 +00:00
if ( GameInfo - > type = = GIT_VSUNI )
{
SetReadHandler ( 0x4016 , 0x4016 , VSUNIRead0 ) ;
SetReadHandler ( 0x4017 , 0x4017 , VSUNIRead1 ) ;
}
else
SetReadHandler ( 0x4016 , 0x4017 , JPRead ) ;
2006-07-29 05:46:15 +00:00
2008-06-07 08:18:04 +00:00
SetWriteHandler ( 0x4016 , 0x4016 , B4016 ) ;
2006-07-29 05:46:15 +00:00
2008-06-07 08:18:04 +00:00
//force the port drivers to be setup
SetInputStuff ( 0 ) ;
SetInputStuff ( 1 ) ;
2006-07-29 05:46:15 +00:00
SetInputStuffFC ( ) ;
}
2008-06-09 08:15:20 +00:00
bool FCEUI_GetInputFourscore ( )
{
return FSAttached ;
}
2010-04-28 19:25:52 +00:00
bool FCEUI_GetInputMicrophone ( )
{
return replaceP2StartWithMicrophone ;
}
2014-11-22 01:23:19 +00:00
void FCEUI_SetInputFourscore ( bool attachFourscore )
2006-07-29 05:46:15 +00:00
{
2014-11-22 01:23:19 +00:00
FSAttached = attachFourscore ;
2006-07-29 05:46:15 +00:00
}
2008-06-19 03:26:37 +00:00
//mbg 6/18/08 HACK
extern ZAPPER ZD [ 2 ] ;
2006-07-29 05:46:15 +00:00
SFORMAT FCEUCTRL_STATEINFO [ ] = {
2008-11-17 14:50:42 +00:00
{ joy_readbit , 2 , " JYRB " } ,
{ joy , 4 , " JOYS " } ,
{ & LastStrobe , 1 , " LSTS " } ,
{ & ZD [ 0 ] . bogo , 1 , " ZBG0 " } ,
{ & ZD [ 1 ] . bogo , 1 , " ZBG1 " } ,
{ & lagFlag , 1 , " LAGF " } ,
{ & lagCounter , 4 , " LAGC " } ,
2009-03-11 22:29:09 +00:00
{ & currFrameCounter , 4 , " FRAM " } ,
2008-06-07 08:18:04 +00:00
{ 0 }
} ;
2006-07-29 05:46:15 +00:00
void FCEU_DoSimpleCommand ( int cmd )
{
switch ( cmd )
{
case FCEUNPCMD_FDSINSERT : FCEU_FDSInsert ( ) ; break ;
case FCEUNPCMD_FDSSELECT : FCEU_FDSSelect ( ) ; break ;
2023-01-06 13:58:02 +00:00
case FCEUNPCMD_VSUNICOIN : FCEU_VSUniCoin ( 0 ) ; break ;
case FCEUNPCMD_VSUNICOIN2 : FCEU_VSUniCoin ( 1 ) ; break ;
case FCEUNPCMD_VSUNISERVICE : FCEU_VSUniService ( ) ; break ;
2012-10-21 16:40:04 +00:00
case FCEUNPCMD_VSUNIDIP0 :
2006-07-29 05:46:15 +00:00
case FCEUNPCMD_VSUNIDIP0 + 1 :
case FCEUNPCMD_VSUNIDIP0 + 2 :
case FCEUNPCMD_VSUNIDIP0 + 3 :
case FCEUNPCMD_VSUNIDIP0 + 4 :
case FCEUNPCMD_VSUNIDIP0 + 5 :
case FCEUNPCMD_VSUNIDIP0 + 6 :
2008-11-17 14:50:42 +00:00
case FCEUNPCMD_VSUNIDIP0 + 7 : FCEU_VSUniToggleDIP ( cmd - FCEUNPCMD_VSUNIDIP0 ) ; break ;
2006-07-29 05:46:15 +00:00
case FCEUNPCMD_POWER : PowerNES ( ) ; break ;
case FCEUNPCMD_RESET : ResetNES ( ) ; break ;
}
}
void FCEU_QSimpleCommand ( int cmd )
{
2008-06-07 08:18:04 +00:00
if ( FCEUnetplay )
FCEUNET_SendCommand ( cmd , 0 ) ;
else
{
2012-02-06 16:57:46 +00:00
if ( ! FCEUMOV_Mode ( MOVIEMODE_TASEDITOR ) ) // TAS Editor will do the command himself
FCEU_DoSimpleCommand ( cmd ) ;
if ( FCEUMOV_Mode ( MOVIEMODE_RECORD | MOVIEMODE_TASEDITOR ) )
2008-06-07 08:18:04 +00:00
FCEUMOV_AddCommand ( cmd ) ;
}
2006-07-29 05:46:15 +00:00
}
void FCEUI_FDSSelect ( void )
2008-06-07 01:21:38 +00:00
{
2012-02-06 16:57:46 +00:00
if ( ! FCEU_IsValidUI ( FCEUI_SWITCH_DISK ) )
return ;
FCEU_DispMessage ( " Command: Switch disk side " , 0 ) ;
2008-06-07 08:18:04 +00:00
FCEU_QSimpleCommand ( FCEUNPCMD_FDSSELECT ) ;
2008-06-07 01:21:38 +00:00
}
2006-07-29 05:46:15 +00:00
void FCEUI_FDSInsert ( void )
2008-06-07 01:21:38 +00:00
{
2012-02-06 16:57:46 +00:00
if ( ! FCEU_IsValidUI ( FCEUI_EJECT_DISK ) )
return ;
FCEU_DispMessage ( " Command: Insert/Eject disk " , 0 ) ;
2008-06-07 08:18:04 +00:00
FCEU_QSimpleCommand ( FCEUNPCMD_FDSINSERT ) ;
2006-07-29 05:46:15 +00:00
}
void FCEUI_VSUniToggleDIP ( int w )
{
2008-06-07 08:18:04 +00:00
FCEU_QSimpleCommand ( FCEUNPCMD_VSUNIDIP0 + w ) ;
2006-07-29 05:46:15 +00:00
}
void FCEUI_VSUniCoin ( void )
{
2013-06-15 19:44:11 +00:00
if ( ! FCEU_IsValidUI ( FCEUI_INSERT_COIN ) )
return ;
2008-06-07 08:18:04 +00:00
FCEU_QSimpleCommand ( FCEUNPCMD_VSUNICOIN ) ;
2006-07-29 05:46:15 +00:00
}
2023-01-06 13:58:02 +00:00
void FCEUI_VSUniCoin2 ( void )
{
if ( ! FCEU_IsValidUI ( FCEUI_INSERT_COIN ) )
return ;
FCEU_QSimpleCommand ( FCEUNPCMD_VSUNICOIN2 ) ;
}
void FCEUI_VSUniService ( void )
{
if ( ! FCEU_IsValidUI ( FCEUI_INSERT_COIN ) )
return ;
FCEU_QSimpleCommand ( FCEUNPCMD_VSUNISERVICE ) ;
}
2008-11-11 22:58:29 +00:00
//Resets the frame counter if movie inactive and rom is reset or power-cycle
void ResetFrameCounter ( )
{
extern EMOVIEMODE movieMode ;
if ( movieMode = = MOVIEMODE_INACTIVE )
currFrameCounter = 0 ;
}
2008-06-07 08:18:04 +00:00
//Resets the NES
2006-07-29 05:46:15 +00:00
void FCEUI_ResetNES ( void )
{
2008-06-21 07:24:01 +00:00
if ( ! FCEU_IsValidUI ( FCEUI_RESET ) )
return ;
2012-02-06 16:57:46 +00:00
FCEU_DispMessage ( " Command: Soft reset " , 0 ) ;
2006-07-29 05:46:15 +00:00
FCEU_QSimpleCommand ( FCEUNPCMD_RESET ) ;
2008-11-11 22:58:29 +00:00
ResetFrameCounter ( ) ;
2006-07-29 05:46:15 +00:00
}
2007-02-07 18:28:50 +00:00
2008-06-07 08:18:04 +00:00
//Powers off the NES
2006-07-29 05:46:15 +00:00
void FCEUI_PowerNES ( void )
{
2008-06-21 07:24:01 +00:00
if ( ! FCEU_IsValidUI ( FCEUI_POWER ) )
return ;
2012-02-06 16:57:46 +00:00
FCEU_DispMessage ( " Command: Power switch " , 0 ) ;
2008-06-07 08:18:04 +00:00
FCEU_QSimpleCommand ( FCEUNPCMD_POWER ) ;
2008-11-11 22:58:29 +00:00
ResetFrameCounter ( ) ;
2006-07-29 05:46:15 +00:00
}
const char * FCEUI_CommandTypeNames [ ] =
{
" Misc. " ,
" Speed " ,
" State " ,
" Movie " ,
" Sound " ,
" AVI " ,
" FDS " ,
" VS Sys " ,
2008-07-07 15:54:38 +00:00
" Tools " ,
2012-06-19 13:56:11 +00:00
" TAS Editor " ,
2006-07-29 05:46:15 +00:00
} ;
2020-06-16 02:53:45 +00:00
//static void CommandUnImpl(void);
2006-07-29 05:46:15 +00:00
static void CommandToggleDip ( void ) ;
static void CommandStateLoad ( void ) ;
static void CommandStateSave ( void ) ;
static void CommandSelectSaveSlot ( void ) ;
static void CommandEmulationSpeed ( void ) ;
static void CommandSoundAdjust ( void ) ;
2008-05-21 15:35:37 +00:00
static void CommandUsePreset ( void ) ;
2008-07-03 14:01:41 +00:00
static void BackgroundDisplayToggle ( void ) ;
static void ObjectDisplayToggle ( void ) ;
2006-07-29 05:46:15 +00:00
static void ViewSlots ( void ) ;
2012-01-12 19:56:17 +00:00
static void LaunchTasEditor ( void ) ;
2008-07-07 15:54:38 +00:00
static void LaunchMemoryWatch ( void ) ;
2008-11-17 15:12:04 +00:00
static void LaunchCheats ( void ) ;
2008-07-07 15:54:38 +00:00
static void LaunchDebugger ( void ) ;
static void LaunchPPU ( void ) ;
2011-05-09 05:57:35 +00:00
static void LaunchNTView ( void ) ;
2008-07-07 15:54:38 +00:00
static void LaunchHex ( void ) ;
static void LaunchTraceLogger ( void ) ;
static void LaunchCodeDataLogger ( void ) ;
2009-11-01 02:20:31 +00:00
static void LaunchRamWatch ( void ) ;
static void LaunchRamSearch ( void ) ;
2010-05-12 03:09:56 +00:00
static void RamSearchOpLT ( void ) ;
static void RamSearchOpGT ( void ) ;
static void RamSearchOpLTE ( void ) ;
static void RamSearchOpGTE ( void ) ;
static void RamSearchOpEQ ( void ) ;
static void RamSearchOpNE ( void ) ;
2022-08-21 00:18:45 +00:00
static void ToggleCheats ( void ) ;
2015-11-05 18:33:40 +00:00
static void DebuggerStepInto ( void ) ;
2008-08-07 15:56:39 +00:00
static void FA_SkipLag ( void ) ;
2008-11-11 04:09:08 +00:00
static void OpenRom ( void ) ;
static void CloseRom ( void ) ;
2017-04-19 05:37:19 +00:00
void ReloadRom ( void ) ;
2008-11-23 22:20:00 +00:00
static void MovieSubtitleToggle ( void ) ;
2008-12-24 04:46:56 +00:00
static void UndoRedoSavestate ( void ) ;
2009-03-22 21:24:23 +00:00
static void FCEUI_DoExit ( void ) ;
2012-08-20 20:41:45 +00:00
void ToggleFullscreen ( ) ;
2012-01-12 19:56:17 +00:00
static void TaseditorRewindOn ( void ) ;
static void TaseditorRewindOff ( void ) ;
2012-07-01 14:11:24 +00:00
static void TaseditorCommand ( void ) ;
2012-09-26 20:19:01 +00:00
extern void FCEUI_ToggleShowFPS ( ) ;
2006-07-29 05:46:15 +00:00
struct EMUCMDTABLE FCEUI_CommandTable [ ] =
{
2015-11-05 18:33:40 +00:00
{ EMUCMD_POWER , EMUCMDTYPE_MISC , FCEUI_PowerNES , 0 , 0 , " Power " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_RESET , EMUCMDTYPE_MISC , FCEUI_ResetNES , 0 , 0 , " Reset " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_PAUSE , EMUCMDTYPE_MISC , FCEUI_ToggleEmulationPause , 0 , 0 , " Pause " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_FRAME_ADVANCE , EMUCMDTYPE_MISC , FCEUI_FrameAdvance , FCEUI_FrameAdvanceEnd , 0 , " Frame Advance " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SCREENSHOT , EMUCMDTYPE_MISC , FCEUI_SaveSnapshot , 0 , 0 , " Screenshot " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_HIDE_MENU_TOGGLE , EMUCMDTYPE_MISC , FCEUD_HideMenuToggle , 0 , 0 , " Hide Menu Toggle " , 0 } ,
{ EMUCMD_EXIT , EMUCMDTYPE_MISC , FCEUI_DoExit , 0 , 0 , " Exit " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SPEED_SLOWEST , EMUCMDTYPE_SPEED , CommandEmulationSpeed , 0 , 0 , " Slowest Speed " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SPEED_SLOWER , EMUCMDTYPE_SPEED , CommandEmulationSpeed , 0 , 0 , " Speed Down " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SPEED_NORMAL , EMUCMDTYPE_SPEED , CommandEmulationSpeed , 0 , 0 , " Normal Speed " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SPEED_FASTER , EMUCMDTYPE_SPEED , CommandEmulationSpeed , 0 , 0 , " Speed Up " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SPEED_FASTEST , EMUCMDTYPE_SPEED , CommandEmulationSpeed , 0 , 0 , " Fastest Speed " , 0 } ,
{ EMUCMD_SPEED_TURBO , EMUCMDTYPE_SPEED , FCEUD_TurboOn , FCEUD_TurboOff , 0 , " Turbo " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SPEED_TURBO_TOGGLE , EMUCMDTYPE_SPEED , FCEUD_TurboToggle , 0 , 0 , " Turbo Toggle " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_SLOT_0 , EMUCMDTYPE_STATE , CommandSelectSaveSlot , 0 , 0 , " Savestate Slot 0 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_SLOT_1 , EMUCMDTYPE_STATE , CommandSelectSaveSlot , 0 , 0 , " Savestate Slot 1 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_SLOT_2 , EMUCMDTYPE_STATE , CommandSelectSaveSlot , 0 , 0 , " Savestate Slot 2 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_SLOT_3 , EMUCMDTYPE_STATE , CommandSelectSaveSlot , 0 , 0 , " Savestate Slot 3 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_SLOT_4 , EMUCMDTYPE_STATE , CommandSelectSaveSlot , 0 , 0 , " Savestate Slot 4 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_SLOT_5 , EMUCMDTYPE_STATE , CommandSelectSaveSlot , 0 , 0 , " Savestate Slot 5 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_SLOT_6 , EMUCMDTYPE_STATE , CommandSelectSaveSlot , 0 , 0 , " Savestate Slot 6 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_SLOT_7 , EMUCMDTYPE_STATE , CommandSelectSaveSlot , 0 , 0 , " Savestate Slot 7 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_SLOT_8 , EMUCMDTYPE_STATE , CommandSelectSaveSlot , 0 , 0 , " Savestate Slot 8 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_SLOT_9 , EMUCMDTYPE_STATE , CommandSelectSaveSlot , 0 , 0 , " Savestate Slot 9 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_SLOT_NEXT , EMUCMDTYPE_STATE , CommandSelectSaveSlot , 0 , 0 , " Next Savestate Slot " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_SLOT_PREV , EMUCMDTYPE_STATE , CommandSelectSaveSlot , 0 , 0 , " Previous Savestate Slot " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_STATE , EMUCMDTYPE_STATE , CommandStateSave , 0 , 0 , " Save State " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_STATE_AS , EMUCMDTYPE_STATE , FCEUD_SaveStateAs , 0 , 0 , " Save State As... " , 0 } ,
{ EMUCMD_SAVE_STATE_SLOT_0 , EMUCMDTYPE_STATE , CommandStateSave , 0 , 0 , " Save State to Slot 0 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_STATE_SLOT_1 , EMUCMDTYPE_STATE , CommandStateSave , 0 , 0 , " Save State to Slot 1 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_STATE_SLOT_2 , EMUCMDTYPE_STATE , CommandStateSave , 0 , 0 , " Save State to Slot 2 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_STATE_SLOT_3 , EMUCMDTYPE_STATE , CommandStateSave , 0 , 0 , " Save State to Slot 3 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_STATE_SLOT_4 , EMUCMDTYPE_STATE , CommandStateSave , 0 , 0 , " Save State to Slot 4 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_STATE_SLOT_5 , EMUCMDTYPE_STATE , CommandStateSave , 0 , 0 , " Save State to Slot 5 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_STATE_SLOT_6 , EMUCMDTYPE_STATE , CommandStateSave , 0 , 0 , " Save State to Slot 6 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_STATE_SLOT_7 , EMUCMDTYPE_STATE , CommandStateSave , 0 , 0 , " Save State to Slot 7 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_STATE_SLOT_8 , EMUCMDTYPE_STATE , CommandStateSave , 0 , 0 , " Save State to Slot 8 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SAVE_STATE_SLOT_9 , EMUCMDTYPE_STATE , CommandStateSave , 0 , 0 , " Save State to Slot 9 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_LOAD_STATE , EMUCMDTYPE_STATE , CommandStateLoad , 0 , 0 , " Load State " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_LOAD_STATE_FROM , EMUCMDTYPE_STATE , FCEUD_LoadStateFrom , 0 , 0 , " Load State From... " , 0 } ,
{ EMUCMD_LOAD_STATE_SLOT_0 , EMUCMDTYPE_STATE , CommandStateLoad , 0 , 0 , " Load State from Slot 0 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_LOAD_STATE_SLOT_1 , EMUCMDTYPE_STATE , CommandStateLoad , 0 , 0 , " Load State from Slot 1 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_LOAD_STATE_SLOT_2 , EMUCMDTYPE_STATE , CommandStateLoad , 0 , 0 , " Load State from Slot 2 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_LOAD_STATE_SLOT_3 , EMUCMDTYPE_STATE , CommandStateLoad , 0 , 0 , " Load State from Slot 3 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_LOAD_STATE_SLOT_4 , EMUCMDTYPE_STATE , CommandStateLoad , 0 , 0 , " Load State from Slot 4 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_LOAD_STATE_SLOT_5 , EMUCMDTYPE_STATE , CommandStateLoad , 0 , 0 , " Load State from Slot 5 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_LOAD_STATE_SLOT_6 , EMUCMDTYPE_STATE , CommandStateLoad , 0 , 0 , " Load State from Slot 6 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_LOAD_STATE_SLOT_7 , EMUCMDTYPE_STATE , CommandStateLoad , 0 , 0 , " Load State from Slot 7 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_LOAD_STATE_SLOT_8 , EMUCMDTYPE_STATE , CommandStateLoad , 0 , 0 , " Load State from Slot 8 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_LOAD_STATE_SLOT_9 , EMUCMDTYPE_STATE , CommandStateLoad , 0 , 0 , " Load State from Slot 9 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_MOVIE_RECORD_TO , EMUCMDTYPE_MOVIE , FCEUD_MovieRecordTo , 0 , 0 , " Record Movie To... " , 0 } ,
{ EMUCMD_MOVIE_REPLAY_FROM , EMUCMDTYPE_MOVIE , FCEUD_MovieReplayFrom , 0 , 0 , " Play Movie From... " , 0 } ,
{ EMUCMD_MOVIE_PLAY_FROM_BEGINNING , EMUCMDTYPE_MOVIE , FCEUI_MoviePlayFromBeginning , 0 , 0 , " Play Movie From Beginning " , EMUCMDFLAG_TASEDITOR } ,
2018-04-04 13:13:42 +00:00
{ EMUCMD_MOVIE_TOGGLE_RECORDING , EMUCMDTYPE_MOVIE , FCEUI_MovieToggleRecording , 0 , 0 , " Toggle Movie Recording/Playing " , 0 } ,
{ EMUCMD_MOVIE_INSERT_1_FRAME , EMUCMDTYPE_MOVIE , FCEUI_MovieInsertFrame , 0 , 0 , " Insert 1 Frame To Movie " , 0 } ,
{ EMUCMD_MOVIE_DELETE_1_FRAME , EMUCMDTYPE_MOVIE , FCEUI_MovieDeleteFrame , 0 , 0 , " Delete 1 Frame From Movie " , 0 } ,
{ EMUCMD_MOVIE_TRUNCATE , EMUCMDTYPE_MOVIE , FCEUI_MovieTruncate , 0 , 0 , " Truncate Movie At Current Frame " , 0 } ,
2015-11-05 18:33:40 +00:00
{ EMUCMD_MOVIE_STOP , EMUCMDTYPE_MOVIE , FCEUI_StopMovie , 0 , 0 , " Stop Movie " , 0 } ,
{ EMUCMD_MOVIE_READONLY_TOGGLE , EMUCMDTYPE_MOVIE , FCEUI_MovieToggleReadOnly , 0 , 0 , " Toggle Read-Only " , EMUCMDFLAG_TASEDITOR } ,
2018-04-05 00:18:53 +00:00
{ EMUCMD_MOVIE_NEXT_RECORD_MODE , EMUCMDTYPE_MOVIE , FCEUI_MovieNextRecordMode , 0 , 0 , " Next Record Mode " , 0 } ,
{ EMUCMD_MOVIE_PREV_RECORD_MODE , EMUCMDTYPE_MOVIE , FCEUI_MoviePrevRecordMode , 0 , 0 , " Prev Record Mode " , 0 } ,
{ EMUCMD_MOVIE_RECORD_MODE_TRUNCATE , EMUCMDTYPE_MOVIE , FCEUI_MovieRecordModeTruncate , 0 , 0 , " Record Mode Truncate " , 0 } ,
{ EMUCMD_MOVIE_RECORD_MODE_OVERWRITE , EMUCMDTYPE_MOVIE , FCEUI_MovieRecordModeOverwrite , 0 , 0 , " Record Mode Overwrite " , 0 } ,
{ EMUCMD_MOVIE_RECORD_MODE_INSERT , EMUCMDTYPE_MOVIE , FCEUI_MovieRecordModeInsert , 0 , 0 , " Record Mode Insert " , 0 } ,
{ EMUCMD_MOVIE_FRAME_DISPLAY_TOGGLE , EMUCMDTYPE_MOVIE , FCEUI_MovieToggleFrameDisplay , 0 , 0 , " Toggle Frame Display " , EMUCMDFLAG_TASEDITOR } ,
2015-11-05 18:33:40 +00:00
{ EMUCMD_MOVIE_INPUT_DISPLAY_TOGGLE , EMUCMDTYPE_MISC , FCEUI_ToggleInputDisplay , 0 , 0 , " Toggle Input Display " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_MOVIE_ICON_DISPLAY_TOGGLE , EMUCMDTYPE_MISC , FCEUD_ToggleStatusIcon , 0 , 0 , " Toggle Status Icon " , EMUCMDFLAG_TASEDITOR } ,
2008-06-28 22:03:59 +00:00
2008-09-24 06:06:31 +00:00
# ifdef _S9XLUA_H
2015-11-05 18:33:40 +00:00
{ EMUCMD_SCRIPT_RELOAD , EMUCMDTYPE_MISC , FCEU_ReloadLuaCode , 0 , 0 , " Reload current Lua script " , EMUCMDFLAG_TASEDITOR } ,
2008-09-24 06:06:31 +00:00
# endif
2008-07-23 06:54:14 +00:00
2015-11-05 18:33:40 +00:00
{ EMUCMD_SOUND_TOGGLE , EMUCMDTYPE_SOUND , FCEUD_SoundToggle , 0 , 0 , " Sound Mute Toggle " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SOUND_VOLUME_UP , EMUCMDTYPE_SOUND , CommandSoundAdjust , 0 , 0 , " Sound Volume Up " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SOUND_VOLUME_DOWN , EMUCMDTYPE_SOUND , CommandSoundAdjust , 0 , 0 , " Sound Volume Down " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_SOUND_VOLUME_NORMAL , EMUCMDTYPE_SOUND , CommandSoundAdjust , 0 , 0 , " Sound Volume Normal " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_AVI_RECORD_AS , EMUCMDTYPE_AVI , FCEUD_AviRecordTo , 0 , 0 , " Record AVI As... " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_AVI_STOP , EMUCMDTYPE_AVI , FCEUD_AviStop , 0 , 0 , " Stop AVI " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_FDS_EJECT_INSERT , EMUCMDTYPE_FDS , FCEUI_FDSInsert , 0 , 0 , " Eject or Insert FDS Disk " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_FDS_SIDE_SELECT , EMUCMDTYPE_FDS , FCEUI_FDSSelect , 0 , 0 , " Switch FDS Disk Side " , EMUCMDFLAG_TASEDITOR } ,
2023-01-06 13:58:02 +00:00
{ EMUCMD_VSUNI_COIN , EMUCMDTYPE_VSUNI , FCEUI_VSUniCoin , 0 , 0 , " Insert Coin #1 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_VSUNI_COIN_2 , EMUCMDTYPE_VSUNI , FCEUI_VSUniCoin2 , 0 , 0 , " Insert Coin #2 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_VSUNI_SERVICE_BUTTON , EMUCMDTYPE_VSUNI , FCEUI_VSUniService , 0 , 0 , " Service Button " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_VSUNI_TOGGLE_DIP_0 , EMUCMDTYPE_VSUNI , CommandToggleDip , 0 , 0 , " Toggle Dip Switch 0 " , 0 } ,
{ EMUCMD_VSUNI_TOGGLE_DIP_1 , EMUCMDTYPE_VSUNI , CommandToggleDip , 0 , 0 , " Toggle Dip Switch 1 " , 0 } ,
{ EMUCMD_VSUNI_TOGGLE_DIP_2 , EMUCMDTYPE_VSUNI , CommandToggleDip , 0 , 0 , " Toggle Dip Switch 2 " , 0 } ,
{ EMUCMD_VSUNI_TOGGLE_DIP_3 , EMUCMDTYPE_VSUNI , CommandToggleDip , 0 , 0 , " Toggle Dip Switch 3 " , 0 } ,
{ EMUCMD_VSUNI_TOGGLE_DIP_4 , EMUCMDTYPE_VSUNI , CommandToggleDip , 0 , 0 , " Toggle Dip Switch 4 " , 0 } ,
{ EMUCMD_VSUNI_TOGGLE_DIP_5 , EMUCMDTYPE_VSUNI , CommandToggleDip , 0 , 0 , " Toggle Dip Switch 5 " , 0 } ,
{ EMUCMD_VSUNI_TOGGLE_DIP_6 , EMUCMDTYPE_VSUNI , CommandToggleDip , 0 , 0 , " Toggle Dip Switch 6 " , 0 } ,
{ EMUCMD_VSUNI_TOGGLE_DIP_7 , EMUCMDTYPE_VSUNI , CommandToggleDip , 0 , 0 , " Toggle Dip Switch 7 " , 0 } ,
2015-11-05 18:33:40 +00:00
{ EMUCMD_MISC_AUTOSAVE , EMUCMDTYPE_MISC , FCEUI_RewindToLastAutosave , 0 , 0 , " Load Last Auto-save " , 0 } ,
2016-04-23 03:01:32 +00:00
{ EMUCMD_MISC_SHOWSTATES , EMUCMDTYPE_MISC , ViewSlots , 0 , 0 , " View save slots " , 0 } ,
2015-11-05 18:33:40 +00:00
{ EMUCMD_MISC_USE_INPUT_PRESET_1 , EMUCMDTYPE_MISC , CommandUsePreset , 0 , 0 , " Use Input Preset 1 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_MISC_USE_INPUT_PRESET_2 , EMUCMDTYPE_MISC , CommandUsePreset , 0 , 0 , " Use Input Preset 2 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_MISC_USE_INPUT_PRESET_3 , EMUCMDTYPE_MISC , CommandUsePreset , 0 , 0 , " Use Input Preset 3 " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_MISC_DISPLAY_BG_TOGGLE , EMUCMDTYPE_MISC , BackgroundDisplayToggle , 0 , 0 , " Toggle Background Display " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_MISC_DISPLAY_OBJ_TOGGLE , EMUCMDTYPE_MISC , ObjectDisplayToggle , 0 , 0 , " Toggle Object Display " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_MISC_DISPLAY_LAGCOUNTER_TOGGLE , EMUCMDTYPE_MISC , LagCounterToggle , 0 , 0 , " Lag Counter Toggle " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_MISC_OPENTASEDITOR , EMUCMDTYPE_TOOL , LaunchTasEditor , 0 , 0 , " Open TAS Editor " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TOOL_OPENMEMORYWATCH , EMUCMDTYPE_TOOL , LaunchMemoryWatch , 0 , 0 , " Open Memory Watch " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TOOL_OPENCHEATS , EMUCMDTYPE_TOOL , LaunchCheats , 0 , 0 , " Open Cheats " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TOOL_OPENDEBUGGER , EMUCMDTYPE_TOOL , LaunchDebugger , 0 , 0 , " Open Debugger " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TOOL_OPENHEX , EMUCMDTYPE_TOOL , LaunchHex , 0 , 0 , " Open Hex Editor " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TOOL_OPENPPU , EMUCMDTYPE_TOOL , LaunchPPU , 0 , 0 , " Open PPU Viewer " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TOOL_OPENNTVIEW , EMUCMDTYPE_TOOL , LaunchNTView , 0 , 0 , " Open Name Table Viewer " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TOOL_OPENTRACELOGGER , EMUCMDTYPE_TOOL , LaunchTraceLogger , 0 , 0 , " Open Trace Logger " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TOOL_OPENCDLOGGER , EMUCMDTYPE_TOOL , LaunchCodeDataLogger , 0 , 0 , " Open Code/Data Logger " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_FRAMEADV_SKIPLAG , EMUCMDTYPE_MISC , FA_SkipLag , 0 , 0 , " Frame Adv.-Skip Lag " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_OPENROM , EMUCMDTYPE_TOOL , OpenRom , 0 , 0 , " Open ROM " , 0 } ,
{ EMUCMD_CLOSEROM , EMUCMDTYPE_TOOL , CloseRom , 0 , 0 , " Close ROM " , 0 } ,
{ EMUCMD_RELOAD , EMUCMDTYPE_TOOL , ReloadRom , 0 , 0 , " Reload ROM or TAS Editor Project " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_MISC_DISPLAY_MOVIESUBTITLES , EMUCMDTYPE_MISC , MovieSubtitleToggle , 0 , 0 , " Toggle Movie Subtitles " , EMUCMDFLAG_TASEDITOR } ,
2016-04-23 03:01:32 +00:00
{ EMUCMD_MISC_UNDOREDOSAVESTATE , EMUCMDTYPE_MISC , UndoRedoSavestate , 0 , 0 , " Undo/Redo Savestate " , 0 } ,
{ EMUCMD_MISC_TOGGLEFULLSCREEN , EMUCMDTYPE_MISC , ToggleFullscreen , 0 , 0 , " Toggle Fullscreen " , 0 } ,
2015-11-05 18:33:40 +00:00
{ EMUCMD_TOOL_OPENRAMWATCH , EMUCMDTYPE_TOOL , LaunchRamWatch , 0 , 0 , " Open Ram Watch " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TOOL_OPENRAMSEARCH , EMUCMDTYPE_TOOL , LaunchRamSearch , 0 , 0 , " Open Ram Search " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TOOL_RAMSEARCHLT , EMUCMDTYPE_TOOL , RamSearchOpLT , 0 , 0 , " Ram Search - Less Than " , 0 } ,
{ EMUCMD_TOOL_RAMSEARCHGT , EMUCMDTYPE_TOOL , RamSearchOpGT , 0 , 0 , " Ram Search - Greater Than " , 0 } ,
{ EMUCMD_TOOL_RAMSEARCHLTE , EMUCMDTYPE_TOOL , RamSearchOpLTE , 0 , 0 , " Ram Search - Less Than or Equal " , 0 } ,
{ EMUCMD_TOOL_RAMSEARCHGTE , EMUCMDTYPE_TOOL , RamSearchOpGTE , 0 , 0 , " Ram Search - Greater Than or Equal " , 0 } ,
{ EMUCMD_TOOL_RAMSEARCHEQ , EMUCMDTYPE_TOOL , RamSearchOpEQ , 0 , 0 , " Ram Search - Equal " , 0 } ,
{ EMUCMD_TOOL_RAMSEARCHNE , EMUCMDTYPE_TOOL , RamSearchOpNE , 0 , 0 , " Ram Search - Not Equal " , 0 } ,
2022-08-21 00:18:45 +00:00
{ EMUCMD_TOOL_TOGGLECHEATS , EMUCMDTYPE_TOOL , ToggleCheats , 0 , 0 , " Toggle Cheats " , 0 } ,
2015-11-05 18:33:40 +00:00
{ EMUCMD_RERECORD_DISPLAY_TOGGLE , EMUCMDTYPE_MISC , FCEUI_MovieToggleRerecordDisplay , 0 , 0 , " Toggle Rerecord Display " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TASEDITOR_REWIND , EMUCMDTYPE_TASEDITOR , TaseditorRewindOn , TaseditorRewindOff , 0 , " Frame Rewind " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TASEDITOR_RESTORE_PLAYBACK , EMUCMDTYPE_TASEDITOR , TaseditorCommand , 0 , 0 , " Restore Playback " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TASEDITOR_CANCEL_SEEKING , EMUCMDTYPE_TASEDITOR , TaseditorCommand , 0 , 0 , " Cancel Seeking " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TASEDITOR_SWITCH_AUTORESTORING , EMUCMDTYPE_TASEDITOR , TaseditorCommand , 0 , 0 , " Switch Auto-restore last position " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TASEDITOR_SWITCH_MULTITRACKING , EMUCMDTYPE_TASEDITOR , TaseditorCommand , 0 , 0 , " Switch current Multitracking mode " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TASEDITOR_RUN_MANUAL_LUA , EMUCMDTYPE_TASEDITOR , TaseditorCommand , 0 , 0 , " Run Manual Lua function " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_FPS_DISPLAY_TOGGLE , EMUCMDTYPE_MISC , FCEUI_ToggleShowFPS , 0 , 0 , " Toggle FPS Display " , EMUCMDFLAG_TASEDITOR } ,
{ EMUCMD_TOOL_DEBUGSTEPINTO , EMUCMDTYPE_TOOL , DebuggerStepInto , 0 , 0 , " Debugger - Step Into " , EMUCMDFLAG_TASEDITOR } ,
2006-07-29 05:46:15 +00:00
} ;
# define NUM_EMU_CMDS (sizeof(FCEUI_CommandTable) / sizeof(FCEUI_CommandTable[0]))
2023-01-29 01:24:17 +00:00
static int execcmd ;
2006-07-29 05:46:15 +00:00
2014-11-22 01:23:19 +00:00
void FCEUI_HandleEmuCommands ( TestCommandState * testfn )
2006-07-29 05:46:15 +00:00
{
2012-01-12 19:56:17 +00:00
bool taseditor = FCEUMOV_Mode ( MOVIEMODE_TASEDITOR ) ;
2023-01-29 01:24:17 +00:00
for ( size_t i = 0 ; i < NUM_EMU_CMDS ; + + i )
2006-07-29 05:46:15 +00:00
{
2009-03-22 17:36:35 +00:00
int new_state ;
int old_state = FCEUI_CommandTable [ i ] . state ;
execcmd = FCEUI_CommandTable [ i ] . cmd ;
2014-11-22 01:23:19 +00:00
new_state = ( * testfn ) ( execcmd ) ;
2012-02-25 17:27:51 +00:00
// in TAS Editor mode forbid commands without EMUCMDFLAG_TASEDITOR flag
2008-06-28 22:03:59 +00:00
bool allow = true ;
2012-01-12 19:56:17 +00:00
if ( taseditor & & ! ( FCEUI_CommandTable [ i ] . flags & EMUCMDFLAG_TASEDITOR ) )
2008-06-28 22:03:59 +00:00
allow = false ;
2012-10-21 16:40:04 +00:00
2008-06-28 22:03:59 +00:00
if ( allow )
{
2009-03-22 17:36:35 +00:00
if ( new_state = = 1 & & old_state = = 0 & & FCEUI_CommandTable [ i ] . fn_on )
( * ( FCEUI_CommandTable [ i ] . fn_on ) ) ( ) ;
else if ( new_state = = 0 & & old_state = = 1 & & FCEUI_CommandTable [ i ] . fn_off )
( * ( FCEUI_CommandTable [ i ] . fn_off ) ) ( ) ;
2008-06-28 22:03:59 +00:00
}
2009-03-22 17:36:35 +00:00
FCEUI_CommandTable [ i ] . state = new_state ;
2006-07-29 05:46:15 +00:00
}
}
2020-06-16 02:53:45 +00:00
// Function not currently used
//static void CommandUnImpl(void)
//{
// FCEU_DispMessage("command '%s' unimplemented.",0, FCEUI_CommandTable[i].name);
//}
2006-07-29 05:46:15 +00:00
static void CommandToggleDip ( void )
{
2006-08-20 19:40:15 +00:00
if ( GameInfo - > type = = GIT_VSUNI )
2006-07-29 05:46:15 +00:00
FCEUI_VSUniToggleDIP ( execcmd - EMUCMD_VSUNI_TOGGLE_DIP_0 ) ;
}
static void CommandEmulationSpeed ( void )
{
FCEUD_SetEmulationSpeed ( EMUSPEED_SLOWEST + ( execcmd - EMUCMD_SPEED_SLOWEST ) ) ;
}
void FCEUI_SelectStateNext ( int ) ;
static void ViewSlots ( void )
{
FCEUI_SelectState ( CurrentState , 1 ) ;
}
static void CommandSelectSaveSlot ( void )
{
2012-01-12 19:56:17 +00:00
if ( FCEUMOV_Mode ( MOVIEMODE_TASEDITOR ) )
2011-10-26 23:10:53 +00:00
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2013-03-04 16:58:54 +00:00
handleEmuCmdByTaseditor ( execcmd ) ;
2011-10-26 23:10:53 +00:00
# endif
} else
{
if ( execcmd < = EMUCMD_SAVE_SLOT_9 )
FCEUI_SelectState ( execcmd - EMUCMD_SAVE_SLOT_0 , 1 ) ;
else if ( execcmd = = EMUCMD_SAVE_SLOT_NEXT )
FCEUI_SelectStateNext ( 1 ) ;
else if ( execcmd = = EMUCMD_SAVE_SLOT_PREV )
FCEUI_SelectStateNext ( - 1 ) ;
}
2006-07-29 05:46:15 +00:00
}
static void CommandStateSave ( void )
{
2012-01-12 19:56:17 +00:00
if ( FCEUMOV_Mode ( MOVIEMODE_TASEDITOR ) )
2006-07-29 05:46:15 +00:00
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2013-03-04 16:58:54 +00:00
handleEmuCmdByTaseditor ( execcmd ) ;
2011-10-26 23:10:53 +00:00
# endif
} else
{
// FCEU_PrintError("execcmd=%d, EMUCMD_SAVE_STATE_SLOT_0=%d, EMUCMD_SAVE_STATE_SLOT_9=%d", execcmd,EMUCMD_SAVE_STATE_SLOT_0,EMUCMD_SAVE_STATE_SLOT_9);
if ( execcmd > = EMUCMD_SAVE_STATE_SLOT_0 & & execcmd < = EMUCMD_SAVE_STATE_SLOT_9 )
{
int oldslot = FCEUI_SelectState ( execcmd - EMUCMD_SAVE_STATE_SLOT_0 , 0 ) ;
FCEUI_SaveState ( 0 ) ;
FCEUI_SelectState ( oldslot , 0 ) ;
}
else
FCEUI_SaveState ( 0 ) ;
2006-07-29 05:46:15 +00:00
}
}
static void CommandStateLoad ( void )
{
2012-01-12 19:56:17 +00:00
if ( FCEUMOV_Mode ( MOVIEMODE_TASEDITOR ) )
2011-10-26 23:10:53 +00:00
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2013-03-04 16:58:54 +00:00
handleEmuCmdByTaseditor ( execcmd ) ;
2011-10-26 23:10:53 +00:00
# endif
} else
2006-07-29 05:46:15 +00:00
{
2011-10-26 23:10:53 +00:00
if ( execcmd > = EMUCMD_LOAD_STATE_SLOT_0 & & execcmd < = EMUCMD_LOAD_STATE_SLOT_9 )
{
int oldslot = FCEUI_SelectState ( execcmd - EMUCMD_LOAD_STATE_SLOT_0 , 0 ) ;
FCEUI_LoadState ( 0 ) ;
FCEUI_SelectState ( oldslot , 0 ) ;
}
else
FCEUI_LoadState ( 0 ) ;
2006-07-29 05:46:15 +00:00
}
}
static void CommandSoundAdjust ( void )
{
2008-06-10 18:09:46 +00:00
int n = 0 ;
2006-07-29 05:46:15 +00:00
switch ( execcmd )
{
case EMUCMD_SOUND_VOLUME_UP : n = 1 ; break ;
case EMUCMD_SOUND_VOLUME_DOWN : n = - 1 ; break ;
case EMUCMD_SOUND_VOLUME_NORMAL : n = 0 ; break ;
}
FCEUD_SoundVolumeAdjust ( n ) ;
}
2008-05-21 15:35:37 +00:00
static void CommandUsePreset ( void )
{
FCEUI_UseInputPreset ( execcmd - EMUCMD_MISC_USE_INPUT_PRESET_1 ) ;
}
2008-07-03 14:01:41 +00:00
static void BackgroundDisplayToggle ( void )
{
bool spr , bg ;
FCEUI_GetRenderPlanes ( spr , bg ) ;
bg = ! bg ;
FCEUI_SetRenderPlanes ( spr , bg ) ;
}
static void ObjectDisplayToggle ( void )
{
bool spr , bg ;
FCEUI_GetRenderPlanes ( spr , bg ) ;
spr = ! spr ;
FCEUI_SetRenderPlanes ( spr , bg ) ;
2008-07-07 00:18:55 +00:00
}
2008-08-07 04:56:40 +00:00
void LagCounterReset ( )
2008-07-07 00:18:55 +00:00
{
2008-07-10 04:55:52 +00:00
lagCounter = 0 ;
2008-07-07 00:18:55 +00:00
}
2011-10-26 23:10:53 +00:00
void LagCounterToggle ( void )
2008-07-07 00:18:55 +00:00
{
2008-07-10 04:55:52 +00:00
lagCounterDisplay ^ = 1 ;
2008-07-07 00:18:55 +00:00
}
2008-07-07 15:54:38 +00:00
2012-01-12 19:56:17 +00:00
static void LaunchTasEditor ( void )
2011-09-22 16:02:09 +00:00
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2013-03-04 16:58:54 +00:00
extern bool enterTASEditor ( ) ;
enterTASEditor ( ) ;
2011-09-22 16:02:09 +00:00
# endif
}
2008-07-07 15:54:38 +00:00
static void LaunchMemoryWatch ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2008-07-07 15:54:38 +00:00
CreateMemWatch ( ) ;
# endif
}
static void LaunchDebugger ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2008-07-07 15:54:38 +00:00
DoDebug ( 0 ) ;
# endif
}
2011-05-09 05:57:35 +00:00
static void LaunchNTView ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2011-05-09 05:57:35 +00:00
DoNTView ( ) ;
# endif
}
2008-07-07 15:54:38 +00:00
static void LaunchPPU ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2008-07-07 15:54:38 +00:00
DoPPUView ( ) ;
# endif
}
static void LaunchHex ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2008-07-07 15:54:38 +00:00
DoMemView ( ) ;
# endif
}
static void LaunchTraceLogger ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2008-07-07 15:54:38 +00:00
DoTracer ( ) ;
# endif
}
static void LaunchCodeDataLogger ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2008-07-07 15:54:38 +00:00
DoCDLogger ( ) ;
# endif
2008-08-02 04:37:16 +00:00
}
2008-11-17 15:12:04 +00:00
static void LaunchCheats ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2019-06-18 08:56:10 +00:00
extern HWND hCheat ;
ConfigCheats ( hCheat ) ;
2008-11-17 15:12:04 +00:00
# endif
}
2009-11-01 02:20:31 +00:00
static void LaunchRamWatch ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2009-11-01 02:20:31 +00:00
extern void OpenRamWatch ( ) ; //adelikat: Blah blah hacky, I know
OpenRamWatch ( ) ;
# endif
}
static void LaunchRamSearch ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2009-11-01 02:20:31 +00:00
extern void OpenRamSearch ( ) ;
OpenRamSearch ( ) ;
# endif
}
2010-05-12 03:09:56 +00:00
static void RamSearchOpLT ( void ) {
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2011-11-28 17:06:38 +00:00
if ( GameInfo )
{
extern void SetSearchType ( int SearchType ) ;
extern void DoRamSearchOperation ( ) ;
SetSearchType ( 0 ) ;
DoRamSearchOperation ( ) ;
}
2010-05-12 03:09:56 +00:00
# endif
}
2010-05-11 22:12:49 +00:00
2010-05-12 03:09:56 +00:00
static void RamSearchOpGT ( void ) {
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2011-11-28 17:06:38 +00:00
if ( GameInfo )
{
extern void SetSearchType ( int SearchType ) ;
extern void DoRamSearchOperation ( ) ;
SetSearchType ( 1 ) ;
DoRamSearchOperation ( ) ;
}
2010-05-12 03:09:56 +00:00
# endif
}
static void RamSearchOpLTE ( void ) {
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2011-11-28 17:06:38 +00:00
if ( GameInfo )
{
extern void SetSearchType ( int SearchType ) ;
extern void DoRamSearchOperation ( ) ;
SetSearchType ( 2 ) ;
DoRamSearchOperation ( ) ;
}
2010-05-12 03:09:56 +00:00
# endif
}
static void RamSearchOpGTE ( void ) {
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2011-11-28 17:06:38 +00:00
if ( GameInfo )
{
extern void SetSearchType ( int SearchType ) ;
extern void DoRamSearchOperation ( ) ;
SetSearchType ( 3 ) ;
DoRamSearchOperation ( ) ;
}
2010-05-12 03:09:56 +00:00
# endif
}
static void RamSearchOpEQ ( void ) {
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2011-11-28 17:06:38 +00:00
if ( GameInfo )
{
extern void SetSearchType ( int SearchType ) ;
extern void DoRamSearchOperation ( ) ;
SetSearchType ( 4 ) ;
DoRamSearchOperation ( ) ;
}
2010-05-12 03:09:56 +00:00
# endif
}
static void RamSearchOpNE ( void ) {
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2011-11-28 17:06:38 +00:00
if ( GameInfo )
{
extern void SetSearchType ( int SearchType ) ;
extern void DoRamSearchOperation ( ) ;
SetSearchType ( 5 ) ;
DoRamSearchOperation ( ) ;
}
2010-05-12 03:09:56 +00:00
# endif
}
2010-05-11 22:12:49 +00:00
2022-08-21 00:18:45 +00:00
extern int globalCheatDisabled ;
2022-08-21 01:49:30 +00:00
extern unsigned int FrozenAddressCount ;
2022-08-21 00:18:45 +00:00
static void ToggleCheats ( )
{
FCEUI_GlobalToggleCheat ( globalCheatDisabled ) ;
FCEU_DispMessage ( " %d cheats active " , 0 , FrozenAddressCount ) ;
# ifdef __WIN_DRIVER__
UpdateCheatRelatedWindow ( ) ;
UpdateCheatListGroupBoxUI ( ) ;
# endif
}
2015-11-05 18:33:40 +00:00
static void DebuggerStepInto ( )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2015-11-05 18:33:40 +00:00
if ( GameInfo )
{
extern void DoDebuggerStepInto ( ) ;
DoDebuggerStepInto ( ) ;
}
# endif
}
2008-08-07 15:56:39 +00:00
static void FA_SkipLag ( void )
{
frameAdvanceLagSkip ^ = 1 ;
2008-11-11 04:09:08 +00:00
}
static void OpenRom ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2008-11-11 04:09:08 +00:00
extern HWND hAppWnd ;
LoadNewGamey ( hAppWnd , 0 ) ;
# endif
}
static void CloseRom ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2008-11-11 04:09:08 +00:00
CloseGame ( ) ;
# endif
2008-11-23 22:20:00 +00:00
}
2017-04-19 05:37:19 +00:00
void ReloadRom ( void )
2011-01-11 03:30:15 +00:00
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2012-01-12 19:56:17 +00:00
if ( FCEUMOV_Mode ( MOVIEMODE_TASEDITOR ) )
2011-12-07 19:07:09 +00:00
{
// load most recent project
2013-03-04 16:58:54 +00:00
handleEmuCmdByTaseditor ( execcmd ) ;
2011-12-07 19:07:09 +00:00
} else
2011-01-11 03:30:15 +00:00
{
2011-12-07 19:07:09 +00:00
// load most recent ROM
extern void LoadRecentRom ( int slot ) ;
LoadRecentRom ( 0 ) ;
}
2011-01-11 03:30:15 +00:00
# endif
}
2008-11-23 22:20:00 +00:00
static void MovieSubtitleToggle ( void )
{
movieSubtitles ^ = 1 ;
2010-05-16 04:18:49 +00:00
if ( movieSubtitles ) FCEU_DispMessage ( " Movie subtitles on " , 0 ) ;
else FCEU_DispMessage ( " Movie subtitles off " , 0 ) ;
2008-12-24 04:46:56 +00:00
}
static void UndoRedoSavestate ( void )
{
2023-01-21 03:37:17 +00:00
if ( ! lastSavestateMade . empty ( ) & & ( undoSS | | redoSS ) )
2008-12-24 04:46:56 +00:00
SwapSaveState ( ) ;
2009-03-22 21:24:23 +00:00
}
static void FCEUI_DoExit ( void )
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2009-03-22 21:24:23 +00:00
DoFCEUExit ( ) ;
# endif
2009-05-21 17:13:08 +00:00
}
2012-08-20 20:41:45 +00:00
void ToggleFullscreen ( )
2009-05-21 17:13:08 +00:00
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2014-11-22 01:29:32 +00:00
extern int SetVideoMode ( int fs ) ; //adelikat: Yeah, I know, hacky
2009-05-21 17:13:08 +00:00
extern void UpdateCheckedMenuItems ( ) ;
2012-10-21 16:40:04 +00:00
2009-05-21 17:13:08 +00:00
UpdateCheckedMenuItems ( ) ;
2014-01-03 05:33:39 +00:00
changerecursive = 1 ;
2014-11-22 01:29:32 +00:00
int oldmode = fullscreen ;
if ( ! SetVideoMode ( oldmode ^ 1 ) )
SetVideoMode ( oldmode ) ;
2009-05-21 17:13:08 +00:00
changerecursive = 0 ;
# endif
2011-10-14 17:33:58 +00:00
}
2012-01-12 19:56:17 +00:00
static void TaseditorRewindOn ( void )
2011-10-14 17:33:58 +00:00
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2013-03-04 16:58:54 +00:00
mustRewindNow = true ;
2011-10-14 17:33:58 +00:00
# endif
}
2012-01-12 19:56:17 +00:00
static void TaseditorRewindOff ( void )
2011-10-14 17:33:58 +00:00
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2013-03-04 16:58:54 +00:00
mustRewindNow = false ;
2011-10-14 17:33:58 +00:00
# endif
}
2012-07-01 14:11:24 +00:00
static void TaseditorCommand ( void )
2012-01-29 22:33:23 +00:00
{
2021-02-06 17:15:28 +00:00
# ifdef __WIN_DRIVER__
2012-06-06 18:59:21 +00:00
if ( FCEUMOV_Mode ( MOVIEMODE_TASEDITOR ) )
2013-03-04 16:58:54 +00:00
handleEmuCmdByTaseditor ( execcmd ) ;
2012-01-29 22:33:23 +00:00
# endif
}
2021-06-20 12:02:32 +00:00
/**
* Function to get command info entry by command number
* */
EMUCMDTABLE * GetEmuCommandById ( int cmd )
{
2023-01-29 01:24:17 +00:00
for ( size_t i = 0 ; i < NUM_EMU_CMDS ; + + i )
2021-06-20 12:02:32 +00:00
{
if ( FCEUI_CommandTable [ i ] . cmd = = cmd )
return & FCEUI_CommandTable [ i ] ;
}
return NULL ;
}