/* FCE Ultra - NES/Famicom Emulator * * 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 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "types.h" #include "x6502.h" #include "fceu.h" #include "sound.h" #include "netplay.h" #include "movie.h" #include "state.h" #include "input/zapper.h" //#include "input/basic.h" #include "input.h" #include "vsuni.h" #include "fds.h" // qfox: For UpdateExternalButton(), called when the // botmode state changes, to update a label in gui. #ifdef WIN32 #include "drivers/win/basicbot.h" #endif // WIN32 //it is easier to declare these input drivers extern here than include a bunch of files //------------- extern INPUTC *FCEU_InitZapper(int w); extern INPUTC *FCEU_InitPowerpadA(int w); extern INPUTC *FCEU_InitPowerpadB(int w); extern INPUTC *FCEU_InitArkanoid(int w); extern INPUTCFC *FCEU_InitArkanoidFC(void); extern INPUTCFC *FCEU_InitSpaceShadow(void); extern INPUTCFC *FCEU_InitFKB(void); extern INPUTCFC *FCEU_InitSuborKB(void); extern INPUTCFC *FCEU_InitHS(void); extern INPUTCFC *FCEU_InitMahjong(void); extern INPUTCFC *FCEU_InitQuizKing(void); extern INPUTCFC *FCEU_InitFamilyTrainerA(void); extern INPUTCFC *FCEU_InitFamilyTrainerB(void); extern INPUTCFC *FCEU_InitOekaKids(void); extern INPUTCFC *FCEU_InitTopRider(void); extern INPUTCFC *FCEU_InitBarcodeWorld(void); //--------------- static uint8 joy_readbit[2]; uint8 joy[4]={0,0,0,0}; //HACK - should be static but movie needs it static uint8 LastStrobe; static int BotMode = 0; #ifdef _USE_SHARED_MEMORY_ static uint32 BotPointer = 0; //mbg merge 7/18/06 changed to uint32 #endif //This function is a quick hack to get the NSF player to use emulated gamepad input. uint8 FCEU_GetJoyJoy(void) { return(joy[0]|joy[1]|joy[2]|joy[3]); } extern uint8 coinon; static bool FSDisable=false; // Set to true if NES-style four-player adapter is disabled. JOYPORT joyports[2] = { JOYPORT(0), JOYPORT(1) }; FCPORT portFC; static DECLFR(JPRead) { uint8 ret=0; ret|=joyports[A&1].driver->Read(A&1); if(portFC.driver) ret = portFC.driver->Read(A&1,ret); ret|=X.DB&0xC0; return(ret); } static DECLFW(B4016) { if(portFC.driver) portFC.driver->Write(V&7); 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: //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++) joyports[i].driver->Strobe(0); if(portFC.driver) portFC.driver->Strobe(); } LastStrobe=V&0x1; } //a main joystick port driver representing the case where nothing is plugged in static INPUTC DummyJPort={0,0,0,0,0,0}; //and an expansion port driver for the same ting static INPUTCFC DummyPortFC={0,0,0,0,0,0}; //--------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]++; return(ret); } static INPUTCFC FAMI4C={ReadFami4,0,StrobeFami4,0,0,0}; //------------------ //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ static uint8 ReadGPVS(int w) { 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; } static void UpdateGP(int w, void *data, int arg) { if(w==0) { joy[0]=*(uint32 *)joyports[0].ptr; joy[2]=*(uint32 *)joyports[0].ptr >> 16; } else { joy[1]=*(uint32 *)joyports[1].ptr >> 8; joy[3]=*(uint32 *)joyports[1].ptr >> 24; } } 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]; joy[2] = mr->joysticks[2]; } else { joy[1] = mr->joysticks[1]; joy[3] = mr->joysticks[3]; } } //basic joystick port driver static uint8 ReadGP(int w) { 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; if(FSDisable) { if(joy_readbit[w]>=8) ret|=1; } else { if(joy_readbit[w]==19-w) ret|=1; } if(!fceuindbg) joy_readbit[w]++; return ret; } static void StrobeGP(int w) { joy_readbit[w]=0; } //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^6 static INPUTC GPC={ReadGP,0,StrobeGP,UpdateGP,0,0,LogGP,LoadGP}; static INPUTC GPCVS={ReadGPVS,0,StrobeGP,UpdateGP,0,0,LogGP,LoadGP}; int FCEU_BotMode() { return BotMode; } void FCEU_SetBotMode(int x) { BotMode = x; #ifdef WIN32 // qfox: update gui in basicbot UpdateExternalButton(); #endif // WIN32 } void FCEU_DrawInput(uint8 *buf) { 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); } void FCEU_UpdateBot() { #ifdef _USE_SHARED_MEMORY_ //This is the external input (aka bot) code if(!BotMode) return; if(BotInput[0]) { BotPointer++; switch(BotInput[BotPointer] >> 16) { case 0: joy[0] = BotInput[BotPointer] & 255; joy[1] = BotInput[BotPointer] >> 8; joy[2] = joy[3] = 0; FCEUI_FrameAdvance(); break; case 1: FCEUI_LoadState(BOT_STATEFILE); break; default: break; } //Bot input ends; let the world know we're done if(BotPointer >= BotInput[0] || BotPointer >= BOT_MAXFRAMES-1) { BotInput[0] = 0; BotPointer = 0; } } else { BotPointer = 0; joy[0] = joy[1] = joy[2] = joy[3] = 0; } #endif //_USE_SHARED_MEMORY_ } void FCEU_UpdateInput(void) { //tell all drivers to poll input and set up their logical states if(!FCEUMOV_Mode(MOVIEMODE_PLAY) && !BotMode) { for(int port=0;port<2;port++) joyports[port].driver->Update(port,joyports[port].ptr,joyports[port].attrib); portFC.driver->Update(portFC.ptr,portFC.attrib); } if(GameInfo->type==GIT_VSUNI) if(coinon) coinon--; if(FCEUnetplay) NetplayUpdate(joy); FCEUMOV_AddInputState(); //TODO - should this apply to the movie data? should this be displayed in the input hud? if(GameInfo->type==GIT_VSUNI) FCEU_VSUniSwap(&joy[0],&joy[1]); } static DECLFR(VSUNIRead0) { uint8 ret=0; ret|=(joyports[0].driver->Read(0))&1; ret|=(vsdip&3)<<3; if(coinon) ret|=0x4; return ret; } static DECLFR(VSUNIRead1) { uint8 ret=0; ret|=(joyports[1].driver->Read(1))&1; ret|=vsdip&0xFC; return ret; } //calls from the ppu; //calls the SLHook for any driver that needs it void InputScanlineHook(uint8 *bg, uint8 *spr, uint32 linets, int final) { for(int port=0;port<2;port++) joyports[port].driver->SLHook(port,bg,spr,linets,final); portFC.driver->SLHook(bg,spr,linets,final); } //binds JPorts[pad] to the driver specified in JPType[pad] static void SetInputStuff(int port) { switch(joyports[port].type) { case SI_GAMEPAD: if(GameInfo->type==GIT_VSUNI) joyports[port].driver = &GPCVS; else joyports[port].driver= &GPC; break; 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; case SI_NONE: joyports[port].driver=&DummyJPort; break; } } static void SetInputStuffFC() { switch(portFC.type) { case SIFC_NONE: 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; case SIFC_HYPERSHOT: portFC.driver=FCEU_InitHS(); break; case SIFC_MAHJONG: portFC.driver=FCEU_InitMahjong(); break; case SIFC_QUIZKING: portFC.driver=FCEU_InitQuizKing(); break; case SIFC_FTRAINERA: portFC.driver=FCEU_InitFamilyTrainerA(); break; case SIFC_FTRAINERB: portFC.driver=FCEU_InitFamilyTrainerB(); break; case SIFC_BWORLD: portFC.driver=FCEU_InitBarcodeWorld(); break; case SIFC_TOPRIDER: portFC.driver=FCEU_InitTopRider(); break; } } void FCEUI_SetInput(int port, ESI type, void *ptr, int attrib) { joyports[port].attrib = attrib; joyports[port].type = type; joyports[port].ptr = ptr; SetInputStuff(port); } void FCEUI_SetInputFC(ESIFC type, void *ptr, int attrib) { portFC.attrib = attrib; portFC.type = type; portFC.ptr = ptr; SetInputStuffFC(); } //initializes the input system to power-on state void InitializeInput(void) { memset(joy_readbit,0,sizeof(joy_readbit)); memset(joy,0,sizeof(joy)); LastStrobe = 0; if(GameInfo->type==GIT_VSUNI) { SetReadHandler(0x4016,0x4016,VSUNIRead0); SetReadHandler(0x4017,0x4017,VSUNIRead1); } else SetReadHandler(0x4016,0x4017,JPRead); SetWriteHandler(0x4016,0x4016,B4016); //force the port drivers to be setup SetInputStuff(0); SetInputStuff(1); SetInputStuffFC(); } void FCEUI_DisableFourScore(bool disabled) { FSDisable = disabled; } SFORMAT FCEUCTRL_STATEINFO[]={ { joy_readbit, 2, "JYRB"}, { joy, 4, "JOYS"}, { &LastStrobe, 1, "LSTS"}, { 0 } }; void FCEU_DoSimpleCommand(int cmd) { switch(cmd) { case FCEUNPCMD_FDSINSERT: FCEU_FDSInsert();break; case FCEUNPCMD_FDSSELECT: FCEU_FDSSelect();break; // case FCEUNPCMD_FDSEJECT: FCEU_FDSEject();break; case FCEUNPCMD_VSUNICOIN: FCEU_VSUniCoin(); break; case FCEUNPCMD_VSUNIDIP0: //mbg merge 7/17/06 removed case range syntax case FCEUNPCMD_VSUNIDIP0+1: case FCEUNPCMD_VSUNIDIP0+2: case FCEUNPCMD_VSUNIDIP0+3: case FCEUNPCMD_VSUNIDIP0+4: case FCEUNPCMD_VSUNIDIP0+5: case FCEUNPCMD_VSUNIDIP0+6: case FCEUNPCMD_VSUNIDIP0+7: FCEU_VSUniToggleDIP(cmd - FCEUNPCMD_VSUNIDIP0);break; case FCEUNPCMD_POWER: PowerNES();break; case FCEUNPCMD_RESET: ResetNES();break; } } void FCEU_QSimpleCommand(int cmd) { if(FCEUnetplay) FCEUNET_SendCommand(cmd, 0); else { FCEU_DoSimpleCommand(cmd); if(FCEUMOV_Mode(MOVIEMODE_RECORD)) FCEUMOV_AddCommand(cmd); } } void FCEUI_FDSSelect(void) { FCEU_QSimpleCommand(FCEUNPCMD_FDSSELECT); } //mbg merge 7/17/06 changed to void fn(void) to make it an EMUCMDFN void FCEUI_FDSInsert(void) { FCEU_QSimpleCommand(FCEUNPCMD_FDSINSERT); //return(1); } /* int FCEUI_FDSEject(void) { FCEU_QSimpleCommand(FCEUNPCMD_FDSEJECT); return(1); } */ void FCEUI_VSUniToggleDIP(int w) { FCEU_QSimpleCommand(FCEUNPCMD_VSUNIDIP0 + w); } void FCEUI_VSUniCoin(void) { FCEU_QSimpleCommand(FCEUNPCMD_VSUNICOIN); } //Resets the NES void FCEUI_ResetNES(void) { FCEU_QSimpleCommand(FCEUNPCMD_RESET); } //Powers off the NES void FCEUI_PowerNES(void) { FCEU_QSimpleCommand(FCEUNPCMD_POWER); } const char* FCEUI_CommandTypeNames[]= { "Misc.", "Speed", "State", "Movie", "Sound", "AVI", "FDS", "VS Sys", }; static void CommandUnImpl(void); static void CommandToggleDip(void); static void CommandStateLoad(void); static void CommandStateSave(void); static void CommandSelectSaveSlot(void); static void CommandEmulationSpeed(void); // static void CommandMovieSelectSlot(void); //static void CommandMovieRecord(void); //static void CommandMovieReplay(void); static void CommandSoundAdjust(void); static void CommandUsePreset(void); static void ViewSlots(void); struct EMUCMDTABLE FCEUI_CommandTable[]= { { EMUCMD_POWER, EMUCMDTYPE_MISC, FCEUI_PowerNES, 0, 0, "Power", }, { EMUCMD_RESET, EMUCMDTYPE_MISC, FCEUI_ResetNES, 0, 0, "Reset", }, { EMUCMD_PAUSE, EMUCMDTYPE_MISC, FCEUI_ToggleEmulationPause, 0, 0, "Pause", }, { EMUCMD_FRAME_ADVANCE, EMUCMDTYPE_MISC, FCEUI_FrameAdvance, FCEUI_FrameAdvanceEnd, 0, "Frame Advance", }, { EMUCMD_SCREENSHOT, EMUCMDTYPE_MISC, FCEUI_SaveSnapshot, 0, 0, "Screenshot", }, { EMUCMD_HIDE_MENU_TOGGLE, EMUCMDTYPE_MISC, FCEUD_HideMenuToggle, 0, 0, "Hide Menu Toggle", }, { EMUCMD_SPEED_SLOWEST, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Slowest Speed", }, { EMUCMD_SPEED_SLOWER, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Speed Down", }, { EMUCMD_SPEED_NORMAL, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Normal Speed", }, { EMUCMD_SPEED_FASTER, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Speed Up", }, { EMUCMD_SPEED_FASTEST, EMUCMDTYPE_SPEED, CommandEmulationSpeed, 0, 0, "Fastest Speed", }, { EMUCMD_SPEED_TURBO, EMUCMDTYPE_SPEED, FCEUD_TurboOn, FCEUD_TurboOff, 0, "Turbo", }, { EMUCMD_SAVE_SLOT_0, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 0", }, { EMUCMD_SAVE_SLOT_1, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 1", }, { EMUCMD_SAVE_SLOT_2, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 2", }, { EMUCMD_SAVE_SLOT_3, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 3", }, { EMUCMD_SAVE_SLOT_4, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 4", }, { EMUCMD_SAVE_SLOT_5, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 5", }, { EMUCMD_SAVE_SLOT_6, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 6", }, { EMUCMD_SAVE_SLOT_7, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 7", }, { EMUCMD_SAVE_SLOT_8, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 8", }, { EMUCMD_SAVE_SLOT_9, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Savestate Slot 9", }, { EMUCMD_SAVE_SLOT_NEXT, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Next Savestate Slot", }, { EMUCMD_SAVE_SLOT_PREV, EMUCMDTYPE_STATE, CommandSelectSaveSlot, 0, 0, "Previous Savestate Slot", }, { EMUCMD_SAVE_STATE, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State", }, { EMUCMD_SAVE_STATE_AS, EMUCMDTYPE_STATE, FCEUD_SaveStateAs, 0, 0, "Save State As...", }, { EMUCMD_SAVE_STATE_SLOT_0, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 0", }, { EMUCMD_SAVE_STATE_SLOT_1, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 1", }, { EMUCMD_SAVE_STATE_SLOT_2, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 2", }, { EMUCMD_SAVE_STATE_SLOT_3, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 3", }, { EMUCMD_SAVE_STATE_SLOT_4, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 4", }, { EMUCMD_SAVE_STATE_SLOT_5, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 5", }, { EMUCMD_SAVE_STATE_SLOT_6, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 6", }, { EMUCMD_SAVE_STATE_SLOT_7, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 7", }, { EMUCMD_SAVE_STATE_SLOT_8, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 8", }, { EMUCMD_SAVE_STATE_SLOT_9, EMUCMDTYPE_STATE, CommandStateSave, 0, 0, "Save State to Slot 9", }, { EMUCMD_LOAD_STATE, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State", }, { EMUCMD_LOAD_STATE_FROM, EMUCMDTYPE_STATE, FCEUD_LoadStateFrom, 0, 0, "Load State From...", }, { EMUCMD_LOAD_STATE_SLOT_0, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 0", }, { EMUCMD_LOAD_STATE_SLOT_1, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 1", }, { EMUCMD_LOAD_STATE_SLOT_2, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 2", }, { EMUCMD_LOAD_STATE_SLOT_3, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 3", }, { EMUCMD_LOAD_STATE_SLOT_4, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 4", }, { EMUCMD_LOAD_STATE_SLOT_5, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 5", }, { EMUCMD_LOAD_STATE_SLOT_6, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 6", }, { EMUCMD_LOAD_STATE_SLOT_7, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 7", }, { EMUCMD_LOAD_STATE_SLOT_8, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 8", }, { EMUCMD_LOAD_STATE_SLOT_9, EMUCMDTYPE_STATE, CommandStateLoad, 0, 0, "Load State from Slot 9", }, /* { EMUCMD_MOVIE_SLOT_0, EMUCMDTYPE_MOVIE, CommandMovieSelectSlot, 0, 0, "Movie Slot 0", }, { EMUCMD_MOVIE_SLOT_1, EMUCMDTYPE_MOVIE, CommandMovieSelectSlot, 0, 0, "Movie Slot 1", }, { EMUCMD_MOVIE_SLOT_2, EMUCMDTYPE_MOVIE, CommandMovieSelectSlot, 0, 0, "Movie Slot 2", }, { EMUCMD_MOVIE_SLOT_3, EMUCMDTYPE_MOVIE, CommandMovieSelectSlot, 0, 0, "Movie Slot 3", }, { EMUCMD_MOVIE_SLOT_4, EMUCMDTYPE_MOVIE, CommandMovieSelectSlot, 0, 0, "Movie Slot 4", }, { EMUCMD_MOVIE_SLOT_5, EMUCMDTYPE_MOVIE, CommandMovieSelectSlot, 0, 0, "Movie Slot 5", }, { EMUCMD_MOVIE_SLOT_6, EMUCMDTYPE_MOVIE, CommandMovieSelectSlot, 0, 0, "Movie Slot 6", }, { EMUCMD_MOVIE_SLOT_7, EMUCMDTYPE_MOVIE, CommandMovieSelectSlot, 0, 0, "Movie Slot 7", }, { EMUCMD_MOVIE_SLOT_8, EMUCMDTYPE_MOVIE, CommandMovieSelectSlot, 0, 0, "Movie Slot 8", }, { EMUCMD_MOVIE_SLOT_9, EMUCMDTYPE_MOVIE, CommandMovieSelectSlot, 0, 0, "Movie Slot 9", }, { EMUCMD_MOVIE_SLOT_NEXT, EMUCMDTYPE_MOVIE, CommandMovieSelectSlot, 0, 0, "Next Movie Slot", }, { EMUCMD_MOVIE_SLOT_PREV, EMUCMDTYPE_MOVIE, CommandMovieSelectSlot, 0, 0, "Previous Movie Slot", }, { EMUCMD_MOVIE_RECORD, EMUCMDTYPE_MOVIE, CommandMovieRecord, 0, 0, "Record Movie", },*/ { EMUCMD_MOVIE_RECORD_TO, EMUCMDTYPE_MOVIE, FCEUD_MovieRecordTo, 0, 0, "Record Movie To...", }, /* { EMUCMD_MOVIE_RECORD_SLOT_0, EMUCMDTYPE_MOVIE, CommandMovieRecord, 0, 0, "Record Movie to Slot 0", }, { EMUCMD_MOVIE_RECORD_SLOT_1, EMUCMDTYPE_MOVIE, CommandMovieRecord, 0, 0, "Record Movie to Slot 1", }, { EMUCMD_MOVIE_RECORD_SLOT_2, EMUCMDTYPE_MOVIE, CommandMovieRecord, 0, 0, "Record Movie to Slot 2", }, { EMUCMD_MOVIE_RECORD_SLOT_3, EMUCMDTYPE_MOVIE, CommandMovieRecord, 0, 0, "Record Movie to Slot 3", }, { EMUCMD_MOVIE_RECORD_SLOT_4, EMUCMDTYPE_MOVIE, CommandMovieRecord, 0, 0, "Record Movie to Slot 4", }, { EMUCMD_MOVIE_RECORD_SLOT_5, EMUCMDTYPE_MOVIE, CommandMovieRecord, 0, 0, "Record Movie to Slot 5", }, { EMUCMD_MOVIE_RECORD_SLOT_6, EMUCMDTYPE_MOVIE, CommandMovieRecord, 0, 0, "Record Movie to Slot 6", }, { EMUCMD_MOVIE_RECORD_SLOT_7, EMUCMDTYPE_MOVIE, CommandMovieRecord, 0, 0, "Record Movie to Slot 7", }, { EMUCMD_MOVIE_RECORD_SLOT_8, EMUCMDTYPE_MOVIE, CommandMovieRecord, 0, 0, "Record Movie to Slot 8", }, { EMUCMD_MOVIE_RECORD_SLOT_9, EMUCMDTYPE_MOVIE, CommandMovieRecord, 0, 0, "Record Movie to Slot 9", }, { EMUCMD_MOVIE_REPLAY, EMUCMDTYPE_MOVIE, CommandMovieReplay, 0, 0, "Replay Movie", },*/ { EMUCMD_MOVIE_REPLAY_FROM, EMUCMDTYPE_MOVIE, FCEUD_MovieReplayFrom, 0, 0, "Replay Movie From...", }, /* { EMUCMD_MOVIE_REPLAY_SLOT_0, EMUCMDTYPE_MOVIE, CommandMovieReplay, 0, 0, "Replay Movie from Slot 0", }, { EMUCMD_MOVIE_REPLAY_SLOT_1, EMUCMDTYPE_MOVIE, CommandMovieReplay, 0, 0, "Replay Movie from Slot 1", }, { EMUCMD_MOVIE_REPLAY_SLOT_2, EMUCMDTYPE_MOVIE, CommandMovieReplay, 0, 0, "Replay Movie from Slot 2", }, { EMUCMD_MOVIE_REPLAY_SLOT_3, EMUCMDTYPE_MOVIE, CommandMovieReplay, 0, 0, "Replay Movie from Slot 3", }, { EMUCMD_MOVIE_REPLAY_SLOT_4, EMUCMDTYPE_MOVIE, CommandMovieReplay, 0, 0, "Replay Movie from Slot 4", }, { EMUCMD_MOVIE_REPLAY_SLOT_5, EMUCMDTYPE_MOVIE, CommandMovieReplay, 0, 0, "Replay Movie from Slot 5", }, { EMUCMD_MOVIE_REPLAY_SLOT_6, EMUCMDTYPE_MOVIE, CommandMovieReplay, 0, 0, "Replay Movie from Slot 6", }, { EMUCMD_MOVIE_REPLAY_SLOT_7, EMUCMDTYPE_MOVIE, CommandMovieReplay, 0, 0, "Replay Movie from Slot 7", }, { EMUCMD_MOVIE_REPLAY_SLOT_8, EMUCMDTYPE_MOVIE, CommandMovieReplay, 0, 0, "Replay Movie from Slot 8", }, { EMUCMD_MOVIE_REPLAY_SLOT_9, EMUCMDTYPE_MOVIE, CommandMovieReplay, 0, 0, "Replay Movie from Slot 9", }, */ { EMUCMD_MOVIE_PLAY_FROM_BEGINNING, EMUCMDTYPE_MOVIE, FCEUI_MoviePlayFromBeginning, 0, 0, "Play Movie From Beginning", }, { EMUCMD_MOVIE_STOP, EMUCMDTYPE_MOVIE, FCEUI_StopMovie, 0, 0, "Stop Movie", }, { EMUCMD_MOVIE_READONLY_TOGGLE, EMUCMDTYPE_MOVIE, FCEUI_MovieToggleReadOnly, 0, 0, "Toggle Read-Only", }, { EMUCMD_MOVIE_FRAME_DISPLAY_TOGGLE, EMUCMDTYPE_MOVIE, FCEUI_MovieToggleFrameDisplay, 0, 0, "Movie Frame Display Toggle", }, { EMUCMD_MOVIE_INPUT_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUI_ToggleInputDisplay, 0, 0, "Toggle Input Display", }, { EMUCMD_MOVIE_ICON_DISPLAY_TOGGLE, EMUCMDTYPE_MISC, FCEUD_ToggleStatusIcon, 0, 0, "Toggle Status Icon", }, { EMUCMD_SOUND_TOGGLE, EMUCMDTYPE_SOUND, FCEUD_SoundToggle, 0, 0, "Sound Mute Toggle", }, { EMUCMD_SOUND_VOLUME_UP, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Up", }, { EMUCMD_SOUND_VOLUME_DOWN, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Down", }, { EMUCMD_SOUND_VOLUME_NORMAL, EMUCMDTYPE_SOUND, CommandSoundAdjust, 0, 0, "Sound Volume Normal", }, { EMUCMD_AVI_RECORD_AS, EMUCMDTYPE_AVI, FCEUD_AviRecordTo, 0, 0, "Record AVI As...", }, { EMUCMD_AVI_STOP, EMUCMDTYPE_AVI, FCEUD_AviStop, 0, 0, "Stop AVI", }, { EMUCMD_FDS_EJECT_INSERT, EMUCMDTYPE_FDS, FCEUI_FDSInsert, 0, 0, "Eject or Insert FDS Disk", }, { EMUCMD_FDS_SIDE_SELECT, EMUCMDTYPE_FDS, FCEUI_FDSSelect, 0, 0, "Switch FDS Disk Side", }, { EMUCMD_VSUNI_COIN, EMUCMDTYPE_VSUNI, FCEUI_VSUniCoin, 0, 0, "Insert Coin", }, { EMUCMD_VSUNI_TOGGLE_DIP_0, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 0", }, { EMUCMD_VSUNI_TOGGLE_DIP_1, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 1", }, { EMUCMD_VSUNI_TOGGLE_DIP_2, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 2", }, { EMUCMD_VSUNI_TOGGLE_DIP_3, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 3", }, { EMUCMD_VSUNI_TOGGLE_DIP_4, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 4", }, { EMUCMD_VSUNI_TOGGLE_DIP_5, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 5", }, { EMUCMD_VSUNI_TOGGLE_DIP_6, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 6", }, { EMUCMD_VSUNI_TOGGLE_DIP_7, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 7", }, { EMUCMD_VSUNI_TOGGLE_DIP_8, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 8", }, { EMUCMD_VSUNI_TOGGLE_DIP_9, EMUCMDTYPE_VSUNI, CommandToggleDip, 0, 0, "Toggle Dipswitch 9", }, { EMUCMD_MISC_REWIND, EMUCMDTYPE_MISC, FCEUI_Rewind, 0, 0, "Rewind", }, { EMUCMD_MISC_SHOWSTATES, EMUCMDTYPE_MISC, ViewSlots, 0,0, "View save slots", }, { EMUCMD_MISC_USE_INPUT_PRESET_1, EMUCMDTYPE_MISC, CommandUsePreset, 0,0, "Use Input Preset 1", }, { EMUCMD_MISC_USE_INPUT_PRESET_2, EMUCMDTYPE_MISC, CommandUsePreset, 0,0, "Use Input Preset 2", }, { EMUCMD_MISC_USE_INPUT_PRESET_3, EMUCMDTYPE_MISC, CommandUsePreset, 0,0, "Use Input Preset 3", }, }; #define NUM_EMU_CMDS (sizeof(FCEUI_CommandTable)/sizeof(FCEUI_CommandTable[0])) static int execcmd; void FCEUI_HandleEmuCommands(TestCommandState* testfn) { for(execcmd=0; execcmdtype==GIT_VSUNI) 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) { 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); } static void CommandStateSave(void) { // 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); } static void CommandStateLoad(void) { 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); } /*static void CommandMovieRecord(void) { FCEUI_SaveMovie(0, 0); } static void CommandMovieReplay(void) { FCEUI_LoadMovie(0, 0, 0); }*/ static void CommandSoundAdjust(void) { int n; 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); } static void CommandUsePreset(void) { FCEUI_UseInputPreset(execcmd-EMUCMD_MISC_USE_INPUT_PRESET_1); }