From f90336a6a5265a4e0afcdf064988a013ddff4020 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 8 Jun 2008 10:22:33 +0000 Subject: [PATCH] some work on infrastructure for recording any kind of input. but now movies are broken. once i teach the movies how to only output the three columns that are currently defined, zappers will work. --- src/driver.h | 123 +-- src/drivers/win/config.cpp | 2 +- src/drivers/win/config.h | 2 +- src/drivers/win/input.cpp | 1927 ++++++++++++++++++------------------ src/drivers/win/input.h | 4 +- src/drivers/win/main.cpp | 5 +- src/drivers/win/main.h | 1 + src/drivers/win/video.cpp | 24 +- src/drivers/win/window.cpp | 2 +- src/fceu.cpp | 24 +- src/fceu.h | 2 +- src/git.h | 87 +- src/ines.cpp | 157 ++- src/input.cpp | 68 +- src/input.h | 58 +- src/input/oekakids.cpp | 2 +- src/input/shadow.cpp | 1 - src/input/zapper.cpp | 30 +- src/movie.cpp | 33 +- src/movie.h | 2 +- src/video.cpp | 4 +- src/vsuni.cpp | 1 - 22 files changed, 1298 insertions(+), 1261 deletions(-) diff --git a/src/driver.h b/src/driver.h index 3aeab612..415029ba 100644 --- a/src/driver.h +++ b/src/driver.h @@ -15,44 +15,41 @@ std::fstream* FCEUD_UTF8_fstream(const char *n, const char *m); //mbg 7/23/06 const char *FCEUD_GetCompilerString(); -/* This makes me feel dirty for some reason. */ +//This makes me feel dirty for some reason. void FCEU_printf(char *format, ...); #define FCEUI_printf FCEU_printf -/* Video interface */ +//Video interface void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b); void FCEUD_GetPalette(uint8 i,uint8 *r, uint8 *g, uint8 *b); -/* Displays an error. Can block or not. */ +//Displays an error. Can block or not. void FCEUD_PrintError(const char *s); void FCEUD_Message(const char *s); -/* Network interface */ +//Network interface -/* Call only when a game is loaded. */ +//Call only when a game is loaded. int FCEUI_NetplayStart(int nlocal, int divisor); -/* Call when network play needs to stop. */ +// Call when network play needs to stop. void FCEUI_NetplayStop(void); -/* Note: YOU MUST NOT CALL ANY FCEUI_* FUNCTIONS WHILE IN FCEUD_SendData() or - FCEUD_RecvData(). -*/ +//Note: YOU MUST NOT CALL ANY FCEUI_* FUNCTIONS WHILE IN FCEUD_SendData() or FCEUD_RecvData(). -/* Return 0 on failure, 1 on success. */ +//Return 0 on failure, 1 on success. int FCEUD_SendData(void *data, uint32 len); int FCEUD_RecvData(void *data, uint32 len); -/* Display text received over the network. */ +//Display text received over the network. void FCEUD_NetplayText(uint8 *text); -/* Encode and send text over the network. */ +//Encode and send text over the network. void FCEUI_NetplayText(uint8 *text); -/* Called when a fatal error occurred and network play can't continue. This function - should call FCEUI_NetplayStop() after it has deinitialized the network on the driver - side. -*/ +//Called when a fatal error occurred and network play can't continue. This function +//should call FCEUI_NetplayStop() after it has deinitialized the network on the driver +//side. void FCEUD_NetworkClose(void); bool FCEUI_BeginWaveRecord(const char *fn); @@ -68,82 +65,45 @@ void FCEUI_NTSCINC(void); void FCEUI_GetNTSCTH(int *tint, int *hue); void FCEUI_SetNTSCTH(int n, int tint, int hue); -//input device types for the standard joystick port -enum ESI -{ - SI_NONE = 0, - SI_GAMEPAD = 1, - SI_ZAPPER = 2, - SI_POWERPADA = 3, - SI_POWERPADB = 4, - SI_ARKANOID = 5, - SI_MOUSE = 6 //mbg merge 7/17/06 added -}; - -//input device types for the expansion port -enum ESIFC -{ - SIFC_NONE = 0, - SIFC_ARKANOID = 1, - SIFC_SHADOW = 2, - SIFC_4PLAYER = 3, - SIFC_FKB = 4, - SIFC_SUBORKB = 5, - SIFC_HYPERSHOT = 6, - SIFC_MAHJONG = 7, - SIFC_QUIZKING = 8, - SIFC_FTRAINERA = 9, - SIFC_FTRAINERB = 10, - SIFC_OEKAKIDS = 11, - SIFC_BWORLD = 12, - SIFC_TOPRIDER = 13, -}; - void FCEUI_SetInput(int port, ESI type, void *ptr, int attrib); void FCEUI_SetInputFC(ESIFC type, void *ptr, int attrib); void FCEUI_DisableFourScore(bool disabled); void FCEUI_UseInputPreset(int preset); -#define SIS_NONE 0 -#define SIS_DATACH 1 -#define SIS_NWC 2 -#define SIS_VSUNISYSTEM 3 -#define SIS_NSF 4 +//New interface functions -/* New interface functions */ - -/* 0 to order screen snapshots numerically(0.png), 1 to order them file base-numerically(smb3-0.png). */ +//0 to order screen snapshots numerically(0.png), 1 to order them file base-numerically(smb3-0.png). void FCEUI_SetSnapName(int a); -/* 0 to keep 8-sprites limitation, 1 to remove it */ +//0 to keep 8-sprites limitation, 1 to remove it void FCEUI_DisableSpriteLimitation(int a); -/* -1 = no change, 0 = show, 1 = hide, 2 = internal toggle */ +//-1 = no change, 0 = show, 1 = hide, 2 = internal toggle void FCEUI_SetRenderDisable(int sprites, int bg); -/* name=path and file to load. returns 0 on failure, 1 on success */ +//name=path and file to load. returns 0 on failure, 1 on success FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode); -/* allocates memory. 0 on failure, 1 on success. */ -int FCEUI_Initialize(void); +//general purpose emulator initialization. returns true if successful +bool FCEUI_Initialize(); -/* Emulates a frame. */ +//Emulates a frame. void FCEUI_Emulate(uint8 **, int32 **, int32 *, int); -/* Closes currently loaded game */ +//Closes currently loaded game void FCEUI_CloseGame(void); -/* Deallocates all allocated memory. Call after FCEUI_Emulate() returns. */ +//Deallocates all allocated memory. Call after FCEUI_Emulate() returns. void FCEUI_Kill(void); -/* Enable/Disable game genie. a=0 disable, a=1 enable */ -void FCEUI_SetGameGenie(int a); +//Enable/Disable game genie. a=true->enabled +void FCEUI_SetGameGenie(bool a); -/* Set video system a=0 NTSC, a=1 PAL */ +//Set video system a=0 NTSC, a=1 PAL void FCEUI_SetVidSystem(int a); -/* Convenience function; returns currently emulated video system(0=NTSC, 1=PAL). */ +//Convenience function; returns currently emulated video system(0=NTSC, 1=PAL). int FCEUI_GetCurrentVidSystem(int *slstart, int *slend); #ifdef FRAMESKIP @@ -154,23 +114,19 @@ int FCEUI_GetCurrentVidSystem(int *slstart, int *slend); void FCEUI_FrameSkip(int x); #endif -/* First and last scanlines to render, for ntsc and pal emulation. */ +//First and last scanlines to render, for ntsc and pal emulation. void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall); -/* Sets the base directory(save states, snapshots, etc. are saved in directories - below this directory. */ +//Sets the base directory(save states, snapshots, etc. are saved in directories below this directory. void FCEUI_SetBaseDirectory(const char *dir); -/* Tells FCE Ultra to copy the palette data pointed to by pal and use it. - Data pointed to by pal needs to be 64*3 bytes in length. -*/ +//Tells FCE Ultra to copy the palette data pointed to by pal and use it. +//Data pointed to by pal needs to be 64*3 bytes in length. void FCEUI_SetPaletteArray(uint8 *pal); -/* Sets up sound code to render sound at the specified rate, in samples - per second. Only sample rates of 44100, 48000, and 96000 are currently - supported. - If "Rate" equals 0, sound is disabled. -*/ +//Sets up sound code to render sound at the specified rate, in samples +//per second. Only sample rates of 44100, 48000, and 96000 are currently supported. +//If "Rate" equals 0, sound is disabled. void FCEUI_Sound(int Rate); void FCEUI_SetSoundVolume(uint32 volume); void FCEUI_SetSoundQuality(int quality); @@ -180,7 +136,7 @@ void FCEUD_SoundVolumeAdjust(int); int FCEUI_SelectState(int, int); -/* "fname" overrides the default save state filename code if non-NULL. */ +//"fname" overrides the default save state filename code if non-NULL. void FCEUI_SaveState(char *fname); void FCEUI_LoadState(char *fname); @@ -305,7 +261,7 @@ void FCEUI_FDSSelect(void); int FCEUI_DatachSet(const uint8 *rcode); ///returns a flag indicating whether emulation is paused -int FCEUI_EmulationPaused(void); +int FCEUI_EmulationPaused(); ///returns a flag indicating whether a one frame step has been requested int FCEUI_EmulationFrameStepped(); ///clears the framestepped flag. use it after youve stepped your one frame @@ -313,7 +269,10 @@ void FCEUI_ClearEmulationFrameStepped(); ///sets the EmulationPaused flags void FCEUI_SetEmulationPaused(int val); ///toggles the paused bit (bit0) for EmulationPaused. caused FCEUD_DebugUpdate() to fire if the emulation pauses -void FCEUI_ToggleEmulationPause(void); +void FCEUI_ToggleEmulationPause(); + +//indicates whether input aids should be drawn (such as crosshairs, etc; usually in fullscreen mode) +bool FCEUD_ShouldDrawInputAids(); ///called when the emulator closes a game void FCEUD_OnCloseGame(void); @@ -389,4 +348,4 @@ extern "C" #endif FILE *FCEUI_UTF8fopen_C(const char *n, const char *m); -#endif /* __DRIVER_H_ */ +#endif //__DRIVER_H_ diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index 7f6fba7d..7f057ee0 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -118,7 +118,7 @@ static CFGSTRUCT fceuconfig[] = { NAC("eoptions",eoptions), NACA("cpalette",cpalette), - NACA("InputType",UsrInputType), + NACA("InputType",InputType), NAC("vmcx",vmodes[0].x), NAC("vmcy",vmodes[0].y), diff --git a/src/drivers/win/config.h b/src/drivers/win/config.h index bbbcca92..1b163101 100644 --- a/src/drivers/win/config.h +++ b/src/drivers/win/config.h @@ -1,4 +1,4 @@ void SaveConfig(const char *filename); void LoadConfig(const char *filename); -extern int UsrInputType[3]; +extern int InputType[3]; diff --git a/src/drivers/win/input.cpp b/src/drivers/win/input.cpp index 9a725998..91099a05 100644 --- a/src/drivers/win/input.cpp +++ b/src/drivers/win/input.cpp @@ -1,22 +1,22 @@ /* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * 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 - */ +* +* Copyright notice for this file: +* 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 +*/ // For commctrl.h below #define _WIN32_IE 0x0300 @@ -41,11 +41,8 @@ LPDIRECTINPUT7 lpDI=0; //UsrInputType[] is user-specified. InputType[] is current // (game/savestate/movie loading can override user settings) -int UsrInputType[3]={SI_GAMEPAD,SI_GAMEPAD,SIFC_NONE}; -int InputType[3]={0,0,0}; -int cspec=0; - -int gametype=0; +//int UsrInputType[3]={SI_GAMEPAD,SI_GAMEPAD,SIFC_NONE}; +int InputType[3]={SI_GAMEPAD,SI_GAMEPAD,SIFC_NONE}; int InitDInput(void) { @@ -63,48 +60,21 @@ static void PresetExport(int preset); static void PresetImport(int preset); static uint32 MouseData[3]; -static int screenmode=0; -void InputScreenChanged(int fs) -{ - int x; - if(GameInfo) - { - for(x=0;x<2;x++) - if(InputType[x]==SI_ZAPPER) - FCEUI_SetInput(x,SI_ZAPPER,MouseData,fs); - if(InputType[2]==SIFC_SHADOW) - FCEUI_SetInputFC(SIFC_SHADOW,MouseData,fs); - } - screenmode=fs; -} - -//Necessary for proper GUI functioning(configuring when a game isn't loaded). -void InputUserActiveFix(void) -{ - int x; - for(x=0;x<3;x++) InputType[x]=UsrInputType[x]; -} +//force the input types suggested by the game void ParseGIInput(FCEUGI *gi) { - InputType[0]=UsrInputType[0]; - InputType[1]=UsrInputType[1]; - InputType[2]=UsrInputType[2]; - if(gi) { - if(gi->input[0]>=0) + if(gi->input[0]!=SI_UNSET) InputType[0]=gi->input[0]; - if(gi->input[1]>=0) + if(gi->input[1]!=SI_UNSET) InputType[1]=gi->input[1]; - if(gi->inputfc>=0) + if(gi->inputfc!=SIFC_UNSET) InputType[2]=gi->inputfc; - cspec = gi->cspecial; - gametype=gi->type; - InitOtherInput(); + InitInputPorts(); } - else cspec=gametype=0; } @@ -118,7 +88,7 @@ static uint8 BWorldData[1+13+1]; static void UpdateFKB(void); static void UpdateSuborKB(void); - void UpdateGamepad(void); +void UpdateGamepad(void); static void UpdateQuizKing(void); static void UpdateHyperShot(void); static void UpdateMahjong(void); @@ -148,20 +118,20 @@ int allowUDLR=1; #define GPZ() {MKZ(), MKZ(), MKZ(), MKZ()} ButtConfig GamePadConfig[4][10]={ - /* Gamepad 1 */ - { - MK(LEFTALT), MK(LEFTCONTROL), MK(TAB), MK(ENTER), MK(BL_CURSORUP), - MK(BL_CURSORDOWN),MK(BL_CURSORLEFT),MK(BL_CURSORRIGHT) + //Gamepad 1 + { + MK(LEFTALT), MK(LEFTCONTROL), MK(TAB), MK(ENTER), MK(BL_CURSORUP), + MK(BL_CURSORDOWN),MK(BL_CURSORLEFT),MK(BL_CURSORRIGHT) }, - /* Gamepad 2 */ - GPZ(), + //Gamepad 2 + GPZ(), - /* Gamepad 3 */ - GPZ(), - - /* Gamepad 4 */ - GPZ() + //Gamepad 3 + GPZ(), + + //Gamepad 4 + GPZ() }; ButtConfig GamePadPreset1[4][10]={GPZ(),GPZ(),GPZ(),GPZ()}; @@ -193,140 +163,140 @@ int GetAutoFireDesynch() int DTestButton(ButtConfig *bc) { - uint32 x;//mbg merge 7/17/06 changed to uint + uint32 x;//mbg merge 7/17/06 changed to uint - for(x=0;xNumC;x++) - { - if(bc->ButtType[x]==BUTTC_KEYBOARD) - { - if(keys_nr[bc->ButtonNum[x]]) - { - return(1); - } - } - } - if(DTestButtonJoy(bc)) return(1); - return(0); + for(x=0;xNumC;x++) + { + if(bc->ButtType[x]==BUTTC_KEYBOARD) + { + if(keys_nr[bc->ButtonNum[x]]) + { + return(1); + } + } + } + if(DTestButtonJoy(bc)) return(1); + return(0); } void UpdateGamepad() { - if(FCEUMOV_Mode(MOVIEMODE_PLAY)) - return; + if(FCEUMOV_Mode(MOVIEMODE_PLAY)) + return; - uint32 JS=0; - int x; - int wg; - if(FCEUMOV_Mode(MOVIEMODE_RECORD)) - AutoFire(); + uint32 JS=0; + int x; + int wg; + if(FCEUMOV_Mode(MOVIEMODE_RECORD)) + AutoFire(); - for(wg=0;wg<4;wg++) - { - for(x=0;x<8;x++) - if(DTestButton(&GamePadConfig[wg][x])) - JS|=(1<':' ', (c&0x20)?'v':' ', - (c&0x01)?'A':' ', (c&0x02)?'B':' ', (c&0x08)?'S':' ', (c&0x04)?'s':' ', - (c&0x4000)?'<':' ', (c&0x1000)?'^':' ', (c&0x8000)?'>':' ', (c&0x2000)?'v':' ', - (c&0x0100)?'A':' ', (c&0x0200)?'B':' ', (c&0x0800)?'S':' ', (c&0x0400)?'s':' '); - if(!(c&0xff00)) - inputstr[8] = '\0'; + // if(rapidAlternator) + for(x=0;x<2;x++) + if(DTestButton(&GamePadConfig[wg][8+x])) + JS|=((1<':' ', (c&0x20)?'v':' ', + (c&0x01)?'A':' ', (c&0x02)?'B':' ', (c&0x08)?'S':' ', (c&0x04)?'s':' ', + (c&0x4000)?'<':' ', (c&0x1000)?'^':' ', (c&0x8000)?'>':' ', (c&0x2000)?'v':' ', + (c&0x0100)?'A':' ', (c&0x0200)?'B':' ', (c&0x0800)?'S':' ', (c&0x0400)?'s':' '); + if(!(c&0xff00)) + inputstr[8] = '\0'; + } + FCEU_DispMessage("Held: %s", inputstr); + } + else + { + JSAutoHeldAffected = 0; + autoHoldRefire = 0; + } + + if(autoHoldReset) + { + FCEU_DispMessage("Held: "); + JSAutoHeld = 0; + JSAutoHeldAffected = 0; + autoHoldRefire = 0; + } + + // apply auto-hold + if(JSAutoHeld) + JS ^= JSAutoHeld; + + JSreturn=JS; } ButtConfig powerpadsc[2][12]={ - { - MK(O),MK(P),MK(BRACKET_LEFT), - MK(BRACKET_RIGHT), + { + MK(O),MK(P),MK(BRACKET_LEFT), + MK(BRACKET_RIGHT), - MK(K),MK(L),MK(SEMICOLON), - MK(APOSTROPHE), - MK(M),MK(COMMA),MK(PERIOD),MK(SLASH) - }, - { - MK(O),MK(P),MK(BRACKET_LEFT), - MK(BRACKET_RIGHT),MK(K),MK(L),MK(SEMICOLON), - MK(APOSTROPHE), - MK(M),MK(COMMA),MK(PERIOD),MK(SLASH) - } - }; + MK(K),MK(L),MK(SEMICOLON), + MK(APOSTROPHE), + MK(M),MK(COMMA),MK(PERIOD),MK(SLASH) + }, + { + MK(O),MK(P),MK(BRACKET_LEFT), + MK(BRACKET_RIGHT),MK(K),MK(L),MK(SEMICOLON), + MK(APOSTROPHE), + MK(M),MK(COMMA),MK(PERIOD),MK(SLASH) + } +}; static uint32 powerpadbuf[2]; static uint32 UpdatePPadData(int w) { - uint32 r=0; - ButtConfig *ppadtsc=powerpadsc[w]; - int x; + uint32 r=0; + ButtConfig *ppadtsc=powerpadsc[w]; + int x; - for(x=0;x<12;x++) - if(DTestButton(&ppadtsc[x])) r|=1<NumC;x++) - { - if(x) strcat(tmpstr, ", "); + for(x=0;xNumC;x++) + { + if(x) strcat(tmpstr, ", "); - if(bc->ButtType[x] == BUTTC_KEYBOARD) - { - strcat(tmpstr,"KB: "); - if(!GetKeyNameText(bc->ButtonNum[x]<<16,tmpstr+strlen(tmpstr),16)) - { - switch(bc->ButtonNum[x]) - { - case 200: strcpy(tmpstr+strlen(tmpstr),"Up Arrow"); break; - case 203: strcpy(tmpstr+strlen(tmpstr),"Left Arrow"); break; - case 205: strcpy(tmpstr+strlen(tmpstr),"Right Arrow"); break; - case 208: strcpy(tmpstr+strlen(tmpstr),"Down Arrow"); break; - default: sprintf(tmpstr+strlen(tmpstr),"%03d",bc->ButtonNum[x]); break; - } - } - } - else if(bc->ButtType[x] == BUTTC_JOYSTICK) - { - strcat(tmpstr,"JS "); - sprintf(tmpstr+strlen(tmpstr), "%d ", bc->DeviceNum[x]); - if(bc->ButtonNum[x] & 0x8000) - { - char *asel[3]={"x","y","z"}; - sprintf(tmpstr+strlen(tmpstr), "axis %s%s", asel[bc->ButtonNum[x] & 3],(bc->ButtonNum[x]&0x4000)?"-":"+"); - } - else if(bc->ButtonNum[x] & 0x2000) - { - sprintf(tmpstr+strlen(tmpstr), "hat %d:%d", (bc->ButtonNum[x] >> 4)&3, - bc->ButtonNum[x]&3); - } - else - { - sprintf(tmpstr+strlen(tmpstr), "button %d", bc->ButtonNum[x] & 127); - } + if(bc->ButtType[x] == BUTTC_KEYBOARD) + { + strcat(tmpstr,"KB: "); + if(!GetKeyNameText(bc->ButtonNum[x]<<16,tmpstr+strlen(tmpstr),16)) + { + switch(bc->ButtonNum[x]) + { + case 200: strcpy(tmpstr+strlen(tmpstr),"Up Arrow"); break; + case 203: strcpy(tmpstr+strlen(tmpstr),"Left Arrow"); break; + case 205: strcpy(tmpstr+strlen(tmpstr),"Right Arrow"); break; + case 208: strcpy(tmpstr+strlen(tmpstr),"Down Arrow"); break; + default: sprintf(tmpstr+strlen(tmpstr),"%03d",bc->ButtonNum[x]); break; + } + } + } + else if(bc->ButtType[x] == BUTTC_JOYSTICK) + { + strcat(tmpstr,"JS "); + sprintf(tmpstr+strlen(tmpstr), "%d ", bc->DeviceNum[x]); + if(bc->ButtonNum[x] & 0x8000) + { + char *asel[3]={"x","y","z"}; + sprintf(tmpstr+strlen(tmpstr), "axis %s%s", asel[bc->ButtonNum[x] & 3],(bc->ButtonNum[x]&0x4000)?"-":"+"); + } + else if(bc->ButtonNum[x] & 0x2000) + { + sprintf(tmpstr+strlen(tmpstr), "hat %d:%d", (bc->ButtonNum[x] >> 4)&3, + bc->ButtonNum[x]&3); + } + else + { + sprintf(tmpstr+strlen(tmpstr), "button %d", bc->ButtonNum[x] & 127); + } - } - } + } + } - astr=(char*)malloc(strlen(tmpstr) + 1); //mbg merge 7/17/06 added cast - strcpy(astr,tmpstr); - return(astr); + astr=(char*)malloc(strlen(tmpstr) + 1); //mbg merge 7/17/06 added cast + strcpy(astr,tmpstr); + return(astr); } @@ -736,210 +659,210 @@ static HWND die; static BOOL CALLBACK DWBCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch(uMsg) { + switch(uMsg) { case WM_DESTROY: - die = NULL; - return(0); + die = NULL; + return(0); case WM_TIMER: - { - uint8 devicenum; - uint16 buttonnum; - GUID guid; + { + uint8 devicenum; + uint16 buttonnum; + GUID guid; - if(DoJoyWaitTest(&guid, &devicenum, &buttonnum)) - { - ButtConfig *bc = DWBButtons; - char *nstr; - int wc; - if(DWBStarted) - { - ButtConfig *bc = DWBButtons; - bc->NumC = 0; - DWBStarted = 0; - } - wc = bc->NumC; - //FCEU_printf("%d: %d\n",devicenum,buttonnum); - bc->ButtType[wc]=BUTTC_JOYSTICK; - bc->DeviceNum[wc]=devicenum; - bc->ButtonNum[wc]=buttonnum; - bc->DeviceInstance[wc] = guid; + if(DoJoyWaitTest(&guid, &devicenum, &buttonnum)) + { + ButtConfig *bc = DWBButtons; + char *nstr; + int wc; + if(DWBStarted) + { + ButtConfig *bc = DWBButtons; + bc->NumC = 0; + DWBStarted = 0; + } + wc = bc->NumC; + //FCEU_printf("%d: %d\n",devicenum,buttonnum); + bc->ButtType[wc]=BUTTC_JOYSTICK; + bc->DeviceNum[wc]=devicenum; + bc->ButtonNum[wc]=buttonnum; + bc->DeviceInstance[wc] = guid; - /* Stop config if the user pushes the same button twice in a row. */ - if(wc && bc->ButtType[wc]==bc->ButtType[wc-1] && bc->DeviceNum[wc]==bc->DeviceNum[wc-1] && - bc->ButtonNum[wc]==bc->ButtonNum[wc-1]) - goto gornk; + /* Stop config if the user pushes the same button twice in a row. */ + if(wc && bc->ButtType[wc]==bc->ButtType[wc-1] && bc->DeviceNum[wc]==bc->DeviceNum[wc-1] && + bc->ButtonNum[wc]==bc->ButtonNum[wc-1]) + goto gornk; - bc->NumC++; + bc->NumC++; - /* Stop config if we reached our maximum button limit. */ - if(bc->NumC >= MAXBUTTCONFIG) - goto gornk; - nstr = MakeButtString(bc); - SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); - free(nstr); - } - } - break; + /* Stop config if we reached our maximum button limit. */ + if(bc->NumC >= MAXBUTTCONFIG) + goto gornk; + nstr = MakeButtString(bc); + SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); + free(nstr); + } + } + break; case WM_USER + 666: - //SetFocus(GetDlgItem(hwndDlg,LBL_DWBDIALOG_TEXT)); - if(DWBStarted) - { - char *nstr; - ButtConfig *bc = DWBButtons; - bc->NumC = 0; - DWBStarted = 0; - nstr = MakeButtString(bc); - SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); - free(nstr); - } + //SetFocus(GetDlgItem(hwndDlg,LBL_DWBDIALOG_TEXT)); + if(DWBStarted) + { + char *nstr; + ButtConfig *bc = DWBButtons; + bc->NumC = 0; + DWBStarted = 0; + nstr = MakeButtString(bc); + SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); + free(nstr); + } - { - ButtConfig *bc = DWBButtons; - int wc = bc->NumC; - char *nstr; + { + ButtConfig *bc = DWBButtons; + int wc = bc->NumC; + char *nstr; - bc->ButtType[wc]=BUTTC_KEYBOARD; - bc->DeviceNum[wc]=0; - bc->ButtonNum[wc]=lParam&255; + bc->ButtType[wc]=BUTTC_KEYBOARD; + bc->DeviceNum[wc]=0; + bc->ButtonNum[wc]=lParam&255; - /* Stop config if the user pushes the same button twice in a row. */ - if(wc && bc->ButtType[wc]==bc->ButtType[wc-1] && bc->DeviceNum[wc]==bc->DeviceNum[wc-1] && - bc->ButtonNum[wc]==bc->ButtonNum[wc-1]) - goto gornk; + /* Stop config if the user pushes the same button twice in a row. */ + if(wc && bc->ButtType[wc]==bc->ButtType[wc-1] && bc->DeviceNum[wc]==bc->DeviceNum[wc-1] && + bc->ButtonNum[wc]==bc->ButtonNum[wc-1]) + goto gornk; - bc->NumC++; - /* Stop config if we reached our maximum button limit. */ - if(bc->NumC >= MAXBUTTCONFIG) - goto gornk; + bc->NumC++; + /* Stop config if we reached our maximum button limit. */ + if(bc->NumC >= MAXBUTTCONFIG) + goto gornk; - nstr = MakeButtString(bc); - SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); - free(nstr); - } - break; + nstr = MakeButtString(bc); + SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); + free(nstr); + } + break; case WM_INITDIALOG: - SetWindowText(hwndDlg, (char*)DWBText); //mbg merge 7/17/06 added cast - BeginJoyWait(hwndDlg); - SetTimer(hwndDlg,666,25,0); /* Every 25ms.*/ - { - char *nstr = MakeButtString(DWBButtons); - SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); - free(nstr); - } - break; + SetWindowText(hwndDlg, (char*)DWBText); //mbg merge 7/17/06 added cast + BeginJoyWait(hwndDlg); + SetTimer(hwndDlg,666,25,0); /* Every 25ms.*/ + { + char *nstr = MakeButtString(DWBButtons); + SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); + free(nstr); + } + break; case WM_CLOSE: case WM_QUIT: goto gornk; case WM_COMMAND: - switch(wParam&0xFFFF) - { - case BTN_CLEAR: - { - ButtConfig *bc = DWBButtons; - char *nstr; - bc->NumC = 0; - nstr = MakeButtString(bc); - SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); - free(nstr); - } - break; - case BTN_CLOSE: - gornk: - KillTimer(hwndDlg,666); - EndJoyWait(hAppWnd); - SetForegroundWindow(GetParent(hwndDlg)); - DestroyWindow(hwndDlg); - break; - } - } - return 0; + switch(wParam&0xFFFF) + { + case BTN_CLEAR: + { + ButtConfig *bc = DWBButtons; + char *nstr; + bc->NumC = 0; + nstr = MakeButtString(bc); + SetDlgItemText(hwndDlg, LBL_DWBDIALOG_TEXT, nstr); + free(nstr); + } + break; + case BTN_CLOSE: +gornk: + KillTimer(hwndDlg,666); + EndJoyWait(hAppWnd); + SetForegroundWindow(GetParent(hwndDlg)); + DestroyWindow(hwndDlg); + break; + } + } + return 0; } int DWaitButton(HWND hParent, const uint8 *text, ButtConfig *bc) { - DWBText=text; - DWBButtons = bc; - DWBStarted = 1; + DWBText=text; + DWBButtons = bc; + DWBStarted = 1; - die = CreateDialog(fceu_hInstance, "DWBDIALOG", hParent, DWBCallB); + die = CreateDialog(fceu_hInstance, "DWBDIALOG", hParent, DWBCallB); - EnableWindow(hParent, 0); - - ShowWindow(die, 1); + EnableWindow(hParent, 0); - while(die) - { - MSG msg; - while(PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) - { - if(GetMessage(&msg, 0, 0, 0) > 0) - { - if(msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) - { - LPARAM tmpo; + ShowWindow(die, 1); - tmpo=((msg.lParam>>16)&0x7F)|((msg.lParam>>17)&0x80); - PostMessage(die,WM_USER+666,0,tmpo); - continue; - } - if(msg.message == WM_SYSCOMMAND) continue; - if(!IsDialogMessage(die, &msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - } - Sleep(10); - } - - EnableWindow(hParent, 1); - return 0; //mbg merge TODO 7/17/06 - had to add this return value--is it right? + while(die) + { + MSG msg; + while(PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) + { + if(GetMessage(&msg, 0, 0, 0) > 0) + { + if(msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) + { + LPARAM tmpo; + + tmpo=((msg.lParam>>16)&0x7F)|((msg.lParam>>17)&0x80); + PostMessage(die,WM_USER+666,0,tmpo); + continue; + } + if(msg.message == WM_SYSCOMMAND) continue; + if(!IsDialogMessage(die, &msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + } + Sleep(10); + } + + EnableWindow(hParent, 1); + return 0; //mbg merge TODO 7/17/06 - had to add this return value--is it right? } int DWaitSimpleButton(HWND hParent, const uint8 *text) { - DWBStarted = 1; - int ret = 0; + DWBStarted = 1; + int ret = 0; - die = CreateDialog(fceu_hInstance, "DWBDIALOGSIMPLE", hParent, NULL); - SetWindowText(die, (char*)text); //mbg merge 7/17/06 added cast - EnableWindow(hParent, 0); - - ShowWindow(die, 1); + die = CreateDialog(fceu_hInstance, "DWBDIALOGSIMPLE", hParent, NULL); + SetWindowText(die, (char*)text); //mbg merge 7/17/06 added cast + EnableWindow(hParent, 0); - while(die) - { - MSG msg; - while(PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) - { - if(GetMessage(&msg, 0, 0, 0) > 0) - { - if(msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) - { - LPARAM tmpo; + ShowWindow(die, 1); - tmpo=((msg.lParam>>16)&0x7F)|((msg.lParam>>17)&0x80); - ret = tmpo; - goto done; - } - if(msg.message == WM_SYSCOMMAND) continue; - if(!IsDialogMessage(die, &msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - } - Sleep(10); - } + while(die) + { + MSG msg; + while(PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) + { + if(GetMessage(&msg, 0, 0, 0) > 0) + { + if(msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) + { + LPARAM tmpo; + + tmpo=((msg.lParam>>16)&0x7F)|((msg.lParam>>17)&0x80); + ret = tmpo; + goto done; + } + if(msg.message == WM_SYSCOMMAND) continue; + if(!IsDialogMessage(die, &msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + } + Sleep(10); + } done: - EndDialog(die,0); - EnableWindow(hParent, 1); + EndDialog(die,0); + EnableWindow(hParent, 1); - if(ret == 1) // convert Esc to nothing (why is it 1 and not VK_ESCAPE?) - ret = 0; - return ret; + if(ret == 1) // convert Esc to nothing (why is it 1 and not VK_ESCAPE?) + ret = 0; + return ret; } @@ -950,61 +873,61 @@ static int DoTBType=0,DoTBPort=0; static BOOL CALLBACK DoTBCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch(uMsg) { + switch(uMsg) { case WM_INITDIALOG: - if(DoTBType == SI_GAMEPAD) - { - char buf[32]; - sprintf(buf,"Virtual Gamepad %d",DoTBPort+1); - SetDlgItemText(hwndDlg, GRP_GAMEPAD1,buf); + if(DoTBType == SI_GAMEPAD) + { + char buf[32]; + sprintf(buf,"Virtual Gamepad %d",DoTBPort+1); + SetDlgItemText(hwndDlg, GRP_GAMEPAD1,buf); - sprintf(buf,"Virtual Gamepad %d",DoTBPort+3); - SetDlgItemText(hwndDlg, GRP_GAMEPAD2, buf); + sprintf(buf,"Virtual Gamepad %d",DoTBPort+3); + SetDlgItemText(hwndDlg, GRP_GAMEPAD2, buf); - CheckDlgButton(hwndDlg,CHECK_DISABLE_FOURSCORE,(eoptions & EO_NOFOURSCORE)?BST_CHECKED:BST_UNCHECKED); - } - SetWindowText(hwndDlg, DoTBTitle); - break; + CheckDlgButton(hwndDlg,CHECK_DISABLE_FOURSCORE,(eoptions & EO_NOFOURSCORE)?BST_CHECKED:BST_UNCHECKED); + } + SetWindowText(hwndDlg, DoTBTitle); + break; case WM_CLOSE: case WM_QUIT: goto gornk; case WM_COMMAND: - { - int b; - b=wParam&0xFFFF; - if(b>= 300 && b < (300 + DoTBMax)) - { - char btext[128]; - btext[0]=0; - GetDlgItemText(hwndDlg, b, btext, 128); - DWaitButton(hwndDlg, (uint8*)btext,&DoTBButtons[b - 300]); //mbg merge 7/17/06 added cast - } - else switch(wParam&0xFFFF) - { - case BTN_CLOSE: - gornk: + { + int b; + b=wParam&0xFFFF; + if(b>= 300 && b < (300 + DoTBMax)) + { + char btext[128]; + btext[0]=0; + GetDlgItemText(hwndDlg, b, btext, 128); + DWaitButton(hwndDlg, (uint8*)btext,&DoTBButtons[b - 300]); //mbg merge 7/17/06 added cast + } + else switch(wParam&0xFFFF) + { + case BTN_CLOSE: +gornk: - if(DoTBType == SI_GAMEPAD) - { - eoptions &= ~EO_NOFOURSCORE; - if(IsDlgButtonChecked(hwndDlg,CHECK_DISABLE_FOURSCORE)==BST_CHECKED) - eoptions|=EO_NOFOURSCORE; - } - EndDialog(hwndDlg,0); - break; - } - } - } - return 0; + if(DoTBType == SI_GAMEPAD) + { + eoptions &= ~EO_NOFOURSCORE; + if(IsDlgButtonChecked(hwndDlg,CHECK_DISABLE_FOURSCORE)==BST_CHECKED) + eoptions|=EO_NOFOURSCORE; + } + EndDialog(hwndDlg,0); + break; + } + } + } + return 0; } static void DoTBConfig(HWND hParent, const char *text, char *_template, ButtConfig *buttons, int max) { - DoTBTitle=text; - DoTBButtons = buttons; - DoTBMax = max; - DialogBox(fceu_hInstance,_template,hParent,DoTBCallB); + DoTBTitle=text; + DoTBButtons = buttons; + DoTBMax = max; + DialogBox(fceu_hInstance,_template,hParent,DoTBCallB); } /** @@ -1052,373 +975,368 @@ BOOL CALLBACK InputConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara switch(uMsg) { - case WM_INITDIALOG: - // Update the disable UDLR checkbox based on the current value - CheckDlgButton(hwndDlg,BTN_ALLOW_LRUD,allowUDLR?BST_CHECKED:BST_UNCHECKED); + case WM_INITDIALOG: + // Update the disable UDLR checkbox based on the current value + CheckDlgButton(hwndDlg,BTN_ALLOW_LRUD,allowUDLR?BST_CHECKED:BST_UNCHECKED); - // Initialize the controls for the input ports - for(unsigned int port = 0; port < NUMBER_OF_PORTS; port++) + // Initialize the controls for the input ports + for(unsigned int port = 0; port < NUMBER_OF_PORTS; port++) + { + // Initialize the combobox + for(unsigned int current_device = 0; current_device < NUMBER_OF_NES_DEVICES; current_device++) { - // Initialize the combobox - for(unsigned int current_device = 0; current_device < NUMBER_OF_NES_DEVICES; current_device++) - { - SendDlgItemMessage(hwndDlg, - COMBO_PAD1 + port, - CB_ADDSTRING, 0, - (LPARAM)(LPSTR)nes_description[current_device] - ); - } - - // Update the combobox selection according to the - // currently selected input mode. SendDlgItemMessage(hwndDlg, COMBO_PAD1 + port, - CB_SETCURSEL, - UsrInputType[port], - (LPARAM)(LPSTR)0 - ); - - // Enable the configuration button if necessary. - EnableWindow( - GetDlgItem(hwndDlg, BTN_PORT1 + port), - configurable_nes[InputType[port]] - ); - - // Update the label that displays the input device. - SetDlgItemText( - hwndDlg, - TXT_PAD1 + port, - (LPTSTR)nes_description[InputType[port]] - ); - } - - // Initialize the Famicom combobox - for(unsigned current_device = 0; current_device < NUMBER_OF_FAMICOM_DEVICES; current_device++) - { - SendDlgItemMessage( - hwndDlg, - COMBO_FAM, - CB_ADDSTRING, - 0, - (LPARAM)(LPSTR)famicom_description[current_device] + CB_ADDSTRING, 0, + (LPARAM)(LPSTR)nes_description[current_device] ); } // Update the combobox selection according to the // currently selected input mode. - SendDlgItemMessage( - hwndDlg, - COMBO_FAM, + SendDlgItemMessage(hwndDlg, + COMBO_PAD1 + port, CB_SETCURSEL, - UsrInputType[FAMICOM_POSITION], + InputType[port], (LPARAM)(LPSTR)0 - ); + ); // Enable the configuration button if necessary. EnableWindow( - GetDlgItem(hwndDlg, BTN_FAM), - configurable_fam[InputType[FAMICOM_POSITION]] + GetDlgItem(hwndDlg, BTN_PORT1 + port), + configurable_nes[InputType[port]] ); // Update the label that displays the input device. SetDlgItemText( hwndDlg, - TXT_FAM, - (LPTSTR)famicom_description[InputType[FAMICOM_POSITION]] + TXT_PAD1 + port, + (LPTSTR)nes_description[InputType[port]] + ); + } + + // Initialize the Famicom combobox + for(unsigned current_device = 0; current_device < NUMBER_OF_FAMICOM_DEVICES; current_device++) + { + SendDlgItemMessage( + hwndDlg, + COMBO_FAM, + CB_ADDSTRING, + 0, + (LPARAM)(LPSTR)famicom_description[current_device] + ); + } + + // Update the combobox selection according to the + // currently selected input mode. + SendDlgItemMessage( + hwndDlg, + COMBO_FAM, + CB_SETCURSEL, + InputType[FAMICOM_POSITION], + (LPARAM)(LPSTR)0 ); - // Initialize the auto key controls + // Enable the configuration button if necessary. + EnableWindow( + GetDlgItem(hwndDlg, BTN_FAM), + configurable_fam[InputType[FAMICOM_POSITION]] + ); - extern int autoHoldKey, autoHoldClearKey; - char btext[128]; + // Update the label that displays the input device. + SetDlgItemText( + hwndDlg, + TXT_FAM, + (LPTSTR)famicom_description[InputType[FAMICOM_POSITION]] + ); - if(autoHoldKey) + // Initialize the auto key controls + + extern int autoHoldKey, autoHoldClearKey; + char btext[128]; + + if(autoHoldKey) + { + if(!GetKeyNameText(autoHoldKey << 16, btext, 128)) { - if(!GetKeyNameText(autoHoldKey << 16, btext, 128)) + sprintf(btext, "KB: %d", autoHoldKey); + } + } + else + { + sprintf(btext, "not assigned"); + } + + SetDlgItemText(hwndDlg, LBL_AUTO_HOLD, btext); + + if(autoHoldClearKey) + { + if(!GetKeyNameText(autoHoldClearKey << 16, btext, 128)) + { + sprintf(btext, "KB: %d", autoHoldClearKey); + } + } + else + { + sprintf(btext, "not assigned"); + } + + SetDlgItemText(hwndDlg, LBL_CLEAR_AH, btext); + + CenterWindowOnScreen(hwndDlg); + + break; + + case WM_CLOSE: + case WM_QUIT: + EndDialog(hwndDlg, 0); + + case WM_COMMAND: + // Handle disable UD/LR option + if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == BTN_ALLOW_LRUD) + { + FCEU_printf("Allow UDLR toggled.\n"); + allowUDLR = !allowUDLR; + } + + if(HIWORD(wParam) == CBN_SELENDOK) + { + switch(LOWORD(wParam)) + { + case COMBO_PAD1: + case COMBO_PAD2: { - sprintf(btext, "KB: %d", autoHoldKey); - } - } - else - { - sprintf(btext, "not assigned"); - } + unsigned int sel_input = LOWORD(wParam) - COMBO_PAD1; - SetDlgItemText(hwndDlg, LBL_AUTO_HOLD, btext); - - if(autoHoldClearKey) - { - if(!GetKeyNameText(autoHoldClearKey << 16, btext, 128)) - { - sprintf(btext, "KB: %d", autoHoldClearKey); - } - } - else - { - sprintf(btext, "not assigned"); - } - - SetDlgItemText(hwndDlg, LBL_CLEAR_AH, btext); - - CenterWindowOnScreen(hwndDlg); - - break; - - case WM_CLOSE: - case WM_QUIT: - EndDialog(hwndDlg, 0); - - case WM_COMMAND: - // Handle disable UD/LR option - if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == BTN_ALLOW_LRUD) - { - FCEU_printf("Allow UDLR toggled.\n"); - allowUDLR = !allowUDLR; - } - - if(HIWORD(wParam) == CBN_SELENDOK) - { - switch(LOWORD(wParam)) - { - case COMBO_PAD1: - case COMBO_PAD2: - { - unsigned int sel_input = LOWORD(wParam) - COMBO_PAD1; - - // Update the user input type - UsrInputType[sel_input] = - InputType[sel_input] = - SendDlgItemMessage( - hwndDlg, - LOWORD(wParam), - CB_GETCURSEL, - 0, - (LPARAM)(LPSTR)0 - ); - - // Enable or disable the configuration button - EnableWindow( - GetDlgItem(hwndDlg, LOWORD(wParam) + 2), - configurable_nes[InputType[sel_input]] - ); - - // Update the text field - SetDlgItemText( - hwndDlg, - TXT_PAD1 + sel_input, - (LPTSTR)nes_description[InputType[sel_input]] - ); - } - - break; - - case COMBO_FAM: - - // Update the user input type of the famicom - UsrInputType[FAMICOM_POSITION] = - InputType[FAMICOM_POSITION] = - SendDlgItemMessage( - hwndDlg, - COMBO_FAM, - CB_GETCURSEL, - 0, - (LPARAM)(LPSTR)0 - ); - - // Enable or disable the configuration button - EnableWindow( - GetDlgItem(hwndDlg, BTN_FAM), - configurable_fam[InputType[FAMICOM_POSITION]] + // Update the user input type + InputType[sel_input] = + SendDlgItemMessage( + hwndDlg, + LOWORD(wParam), + CB_GETCURSEL, + 0, + (LPARAM)(LPSTR)0 ); - // Update the text field - SetDlgItemText( - hwndDlg, - TXT_FAM, - (LPTSTR)famicom_description[InputType[FAMICOM_POSITION]] - ); - - break; + // Enable or disable the configuration button + EnableWindow( + GetDlgItem(hwndDlg, LOWORD(wParam) + 2), + configurable_nes[InputType[sel_input]] + ); + // Update the text field + SetDlgItemText( + hwndDlg, + TXT_PAD1 + sel_input, + (LPTSTR)nes_description[InputType[sel_input]] + ); } + break; + + case COMBO_FAM: + + // Update the user input type of the famicom + InputType[FAMICOM_POSITION] = + SendDlgItemMessage( + hwndDlg, + COMBO_FAM, + CB_GETCURSEL, + 0, + (LPARAM)(LPSTR)0 + ); + + // Enable or disable the configuration button + EnableWindow( + GetDlgItem(hwndDlg, BTN_FAM), + configurable_fam[InputType[FAMICOM_POSITION]] + ); + + // Update the text field + SetDlgItemText( + hwndDlg, + TXT_FAM, + (LPTSTR)famicom_description[InputType[FAMICOM_POSITION]] + ); + + break; + } - if( !(wParam >> 16) ) + } + + if( !(wParam >> 16) ) + { + switch(wParam & 0xFFFF) { - switch(wParam & 0xFFFF) + case BTN_FAM: { - case BTN_FAM: - { - const char *text = famicom_description[InputType[FAMICOM_POSITION]]; + const char *text = famicom_description[InputType[FAMICOM_POSITION]]; - DoTBType = DoTBPort = 0; - - switch(InputType[FAMICOM_POSITION]) - { - case SIFC_FTRAINERA: - case SIFC_FTRAINERB: - DoTBConfig(hwndDlg, text, "POWERPADDIALOG", FTrainerButtons, 12); - break; - case SIFC_FKB: - DoTBConfig(hwndDlg, text, "FKBDIALOG", fkbmap, 0x48); - break; - case SIFC_SUBORKB: - DoTBConfig(hwndDlg, text, "SUBORKBDIALOG", suborkbmap, 0x60); - break; - case SIFC_MAHJONG: - DoTBConfig(hwndDlg, text, "MAHJONGDIALOG", MahjongButtons, 21); - break; - case SIFC_QUIZKING: - DoTBConfig(hwndDlg, text, "QUIZKINGDIALOG", QuizKingButtons, 6); - break; - } - } + DoTBType = DoTBPort = 0; + switch(InputType[FAMICOM_POSITION]) + { + case SIFC_FTRAINERA: + case SIFC_FTRAINERB: + DoTBConfig(hwndDlg, text, "POWERPADDIALOG", FTrainerButtons, 12); break; - - case BTN_PORT2: - case BTN_PORT1: - { - int which = (wParam & 0xFFFF) - BTN_PORT1; - const char *text = nes_description[InputType[which]]; - - DoTBType = DoTBPort = 0; - - switch(InputType[which]) - { - case SI_GAMEPAD: - { - ButtConfig tmp[10 + 10]; - - memcpy(tmp, GamePadConfig[which], 10 * sizeof(ButtConfig)); - memcpy(&tmp[10], GamePadConfig[which + 2], 10 * sizeof(ButtConfig)); - - DoTBType = SI_GAMEPAD; - DoTBPort = which; - DoTBConfig(hwndDlg, text, "GAMEPADDIALOG", tmp, 10 + 10); - - memcpy(GamePadConfig[which], tmp, 10 * sizeof(ButtConfig)); - memcpy(GamePadConfig[which + 2], &tmp[10], 10 * sizeof(ButtConfig)); - } - break; - - case SI_POWERPADA: - case SI_POWERPADB: - DoTBConfig(hwndDlg, text, "POWERPADDIALOG", powerpadsc[which], 12); - break; - } - } - + case SIFC_FKB: + DoTBConfig(hwndDlg, text, "FKBDIALOG", fkbmap, 0x48); break; - - case BTN_PRESET_SET1: - MessageBox(0, "Current input configuration has been set as Preset 1.", "FCE Ultra Message", MB_ICONINFORMATION | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); - memcpy(GamePadPreset1, GamePadConfig, sizeof(GamePadConfig)); + case SIFC_SUBORKB: + DoTBConfig(hwndDlg, text, "SUBORKBDIALOG", suborkbmap, 0x60); break; - case BTN_PRESET_SET2: - MessageBox(0, "Current input configuration has been set as Preset 2.", "FCE Ultra Message", MB_ICONINFORMATION | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); - memcpy(GamePadPreset2, GamePadConfig, sizeof(GamePadConfig)); + case SIFC_MAHJONG: + DoTBConfig(hwndDlg, text, "MAHJONGDIALOG", MahjongButtons, 21); break; - case BTN_PRESET_SET3: - MessageBox(0, "Current input configuration has been set as Preset 3.", "FCE Ultra Message", MB_ICONINFORMATION | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); - memcpy(GamePadPreset3, GamePadConfig, sizeof(GamePadConfig)); - break; - - case BTN_PRESET_EXPORT1: PresetExport(1); break; - case BTN_PRESET_EXPORT2: PresetExport(2); break; - case BTN_PRESET_EXPORT3: PresetExport(3); break; - - case BTN_PRESET_IMPORT1: PresetImport(1); break; - case BTN_PRESET_IMPORT2: PresetImport(2); break; - case BTN_PRESET_IMPORT3: PresetImport(3); break; - - case BTN_AUTO_HOLD: // auto-hold button - { - char btext[128] = { 0 }; - - GetDlgItemText(hwndDlg, BTN_AUTO_HOLD, btext, sizeof(btext) ); - - int button = DWaitSimpleButton(hwndDlg, (uint8*)btext); //mbg merge 7/17/06 - - if(button) - { - if(!GetKeyNameText(button << 16, btext, 128)) - { - sprintf(btext, "KB: %d", button); - } - } - else - { - sprintf(btext, "not assigned"); - } - - extern int autoHoldKey; - autoHoldKey = button; - SetDlgItemText(hwndDlg, LBL_AUTO_HOLD, btext); - } - break; - - case BTN_CLEAR_AH: // auto-hold clear button - { - char btext[128] = { 0 }; - - GetDlgItemText(hwndDlg, BTN_CLEAR_AH, btext, 128); - - int button = DWaitSimpleButton(hwndDlg, (uint8*)btext); //mbg merge 7/17/06 added cast - - if(button) - { - if( !GetKeyNameText(button << 16, btext, sizeof(btext))) - { - sprintf(btext, "KB: %d", button); - } - } - else - { - sprintf(btext, "not assigned"); - } - - extern int autoHoldClearKey; - autoHoldClearKey = button; - - SetDlgItemText(hwndDlg, LBL_CLEAR_AH, btext); - } - break; - - case BTN_CLOSE: - EndDialog(hwndDlg, 0); + case SIFC_QUIZKING: + DoTBConfig(hwndDlg, text, "QUIZKINGDIALOG", QuizKingButtons, 6); break; + } } + + break; + + case BTN_PORT2: + case BTN_PORT1: + { + int which = (wParam & 0xFFFF) - BTN_PORT1; + const char *text = nes_description[InputType[which]]; + + DoTBType = DoTBPort = 0; + + switch(InputType[which]) + { + case SI_GAMEPAD: + { + ButtConfig tmp[10 + 10]; + + memcpy(tmp, GamePadConfig[which], 10 * sizeof(ButtConfig)); + memcpy(&tmp[10], GamePadConfig[which + 2], 10 * sizeof(ButtConfig)); + + DoTBType = SI_GAMEPAD; + DoTBPort = which; + DoTBConfig(hwndDlg, text, "GAMEPADDIALOG", tmp, 10 + 10); + + memcpy(GamePadConfig[which], tmp, 10 * sizeof(ButtConfig)); + memcpy(GamePadConfig[which + 2], &tmp[10], 10 * sizeof(ButtConfig)); + } + break; + + case SI_POWERPADA: + case SI_POWERPADB: + DoTBConfig(hwndDlg, text, "POWERPADDIALOG", powerpadsc[which], 12); + break; + } + } + + break; + + case BTN_PRESET_SET1: + MessageBox(0, "Current input configuration has been set as Preset 1.", "FCE Ultra Message", MB_ICONINFORMATION | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); + memcpy(GamePadPreset1, GamePadConfig, sizeof(GamePadConfig)); + break; + case BTN_PRESET_SET2: + MessageBox(0, "Current input configuration has been set as Preset 2.", "FCE Ultra Message", MB_ICONINFORMATION | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); + memcpy(GamePadPreset2, GamePadConfig, sizeof(GamePadConfig)); + break; + case BTN_PRESET_SET3: + MessageBox(0, "Current input configuration has been set as Preset 3.", "FCE Ultra Message", MB_ICONINFORMATION | MB_OK | MB_SETFOREGROUND | MB_TOPMOST); + memcpy(GamePadPreset3, GamePadConfig, sizeof(GamePadConfig)); + break; + + case BTN_PRESET_EXPORT1: PresetExport(1); break; + case BTN_PRESET_EXPORT2: PresetExport(2); break; + case BTN_PRESET_EXPORT3: PresetExport(3); break; + + case BTN_PRESET_IMPORT1: PresetImport(1); break; + case BTN_PRESET_IMPORT2: PresetImport(2); break; + case BTN_PRESET_IMPORT3: PresetImport(3); break; + + case BTN_AUTO_HOLD: // auto-hold button + { + char btext[128] = { 0 }; + + GetDlgItemText(hwndDlg, BTN_AUTO_HOLD, btext, sizeof(btext) ); + + int button = DWaitSimpleButton(hwndDlg, (uint8*)btext); //mbg merge 7/17/06 + + if(button) + { + if(!GetKeyNameText(button << 16, btext, 128)) + { + sprintf(btext, "KB: %d", button); + } + } + else + { + sprintf(btext, "not assigned"); + } + + extern int autoHoldKey; + autoHoldKey = button; + SetDlgItemText(hwndDlg, LBL_AUTO_HOLD, btext); + } + break; + + case BTN_CLEAR_AH: // auto-hold clear button + { + char btext[128] = { 0 }; + + GetDlgItemText(hwndDlg, BTN_CLEAR_AH, btext, 128); + + int button = DWaitSimpleButton(hwndDlg, (uint8*)btext); //mbg merge 7/17/06 added cast + + if(button) + { + if( !GetKeyNameText(button << 16, btext, sizeof(btext))) + { + sprintf(btext, "KB: %d", button); + } + } + else + { + sprintf(btext, "not assigned"); + } + + extern int autoHoldClearKey; + autoHoldClearKey = button; + + SetDlgItemText(hwndDlg, LBL_CLEAR_AH, btext); + } + break; + + case BTN_CLOSE: + EndDialog(hwndDlg, 0); + break; } + } } return 0; } -/** -* Shows the input configuration dialog. -* -* @param hParent Handle of the parent window. -**/ +//Shows the input configuration dialog. void ConfigInput(HWND hParent) { DialogBox(fceu_hInstance, "INPUTCONFIG", hParent, InputConCallB); + //in case the input config changes while a game is running, reconfigure the input ports if(GameInfo) { - InitOtherInput(); + InitInputPorts(); } } void DestroyInput(void) { - if(lpDI) - { - KillJoysticks(); - KeyboardClose(); - IDirectInput7_Release(lpDI); - } + if(lpDI) + { + KillJoysticks(); + KeyboardClose(); + IDirectInput7_Release(lpDI); + } } int FCEUD_CommandMapping[EMUCMD_MAX]; @@ -1435,22 +1353,22 @@ int FCEUD_TestCommandState(int c) // allow certain commands be affected by key repeat if(c == EMUCMD_FRAME_ADVANCE/* - || c == EMUCMD_SOUND_VOLUME_UP - || c == EMUCMD_SOUND_VOLUME_DOWN - || c == EMUCMD_SPEED_SLOWER - || c == EMUCMD_SPEED_FASTER*/) + || c == EMUCMD_SOUND_VOLUME_UP + || c == EMUCMD_SOUND_VOLUME_DOWN + || c == EMUCMD_SPEED_SLOWER + || c == EMUCMD_SPEED_FASTER*/) { keys=GetKeyboard_nr(); -/* if((cmdmask & CMD_KEY_LALT) == CMD_KEY_LALT + /* if((cmdmask & CMD_KEY_LALT) == CMD_KEY_LALT || (cmdmask & CMD_KEY_RALT) == CMD_KEY_RALT || (cmdmask & CMD_KEY_LALT) == CMD_KEY_LALT || (cmdmask & CMD_KEY_LCTRL) == CMD_KEY_LCTRL || (cmdmask & CMD_KEY_RCTRL) == CMD_KEY_RCTRL || (cmdmask & CMD_KEY_LSHIFT) == CMD_KEY_LSHIFT || (cmdmask & CMD_KEY_RSHIFT) == CMD_KEY_RSHIFT)*/ - keys_nr=GetKeyboard_nr(); -// else -// keys_nr=GetKeyboard_nr(); + keys_nr=GetKeyboard_nr(); + // else + // keys_nr=GetKeyboard_nr(); } else if(c != EMUCMD_SPEED_TURBO) // TODO: this should be made more general by detecting if the command has an "off" function, but right now Turbo is the only command that has it { @@ -1513,9 +1431,9 @@ void FCEUI_UseInputPreset(int preset) { switch(preset) { - case 0: memcpy(GamePadConfig, GamePadPreset1, sizeof(GamePadPreset1)); break; - case 1: memcpy(GamePadConfig, GamePadPreset2, sizeof(GamePadPreset2)); break; - case 2: memcpy(GamePadConfig, GamePadPreset3, sizeof(GamePadPreset3)); break; + case 0: memcpy(GamePadConfig, GamePadPreset1, sizeof(GamePadPreset1)); break; + case 1: memcpy(GamePadConfig, GamePadPreset2, sizeof(GamePadPreset2)); break; + case 2: memcpy(GamePadConfig, GamePadPreset3, sizeof(GamePadPreset3)); break; } FCEU_DispMessage("Using input preset %d.",preset+1); } @@ -1569,9 +1487,9 @@ static void PresetExport(int preset) FILE *fp=FCEUD_UTF8fopen(nameo,"w"); switch(preset) { - case 1: fwrite(GamePadPreset1,1,sizeof(GamePadPreset1),fp); break; - case 2: fwrite(GamePadPreset2,1,sizeof(GamePadPreset2),fp); break; - case 3: fwrite(GamePadPreset3,1,sizeof(GamePadPreset3),fp); break; + case 1: fwrite(GamePadPreset1,1,sizeof(GamePadPreset1),fp); break; + case 2: fwrite(GamePadPreset2,1,sizeof(GamePadPreset2),fp); break; + case 3: fwrite(GamePadPreset3,1,sizeof(GamePadPreset3),fp); break; } fclose(fp); } @@ -1597,21 +1515,64 @@ static void PresetImport(int preset) { //Save the directory if(ofn.nFileOffset < 1024) - if(ofn.nFileOffset < 1024) - { - free(InputPresetDir); - InputPresetDir=(char*)malloc(strlen(ofn.lpstrFile)+1); - strcpy(InputPresetDir,ofn.lpstrFile); - InputPresetDir[ofn.nFileOffset]=0; - } + if(ofn.nFileOffset < 1024) + { + free(InputPresetDir); + InputPresetDir=(char*)malloc(strlen(ofn.lpstrFile)+1); + strcpy(InputPresetDir,ofn.lpstrFile); + InputPresetDir[ofn.nFileOffset]=0; + } - FILE *fp=FCEUD_UTF8fopen(nameo,"r"); - switch(preset) - { + FILE *fp=FCEUD_UTF8fopen(nameo,"r"); + switch(preset) + { case 1: fread(GamePadPreset1,1,sizeof(GamePadPreset1),fp); break; case 2: fread(GamePadPreset2,1,sizeof(GamePadPreset2),fp); break; case 3: fread(GamePadPreset3,1,sizeof(GamePadPreset3),fp); break; - } - fclose(fp); + } + fclose(fp); } } + + +//commandline input config. not being used right now +//--------------------------- +//static void FCExp(char *text) +//{ +// static char *fccortab[12]={"none","arkanoid","shadow","4player","fkb","suborkb", +// "hypershot","mahjong","quizking","ftrainera","ftrainerb","oekakids"}; +// +// static int fccortabi[12]={SIFC_NONE,SIFC_ARKANOID,SIFC_SHADOW, +// SIFC_4PLAYER,SIFC_FKB,SIFC_SUBORKB,SIFC_HYPERSHOT,SIFC_MAHJONG,SIFC_QUIZKING, +// SIFC_FTRAINERA,SIFC_FTRAINERB,SIFC_OEKAKIDS}; +// int y; +// for(y=0;y<12;y++) +// if(!strcmp(fccortab[y],text)) +// UsrInputType[2]=fccortabi[y]; +//} +//static char *cortab[6]={"none","gamepad","zapper","powerpada","powerpadb","arkanoid"}; +//static int cortabi[6]={SI_NONE,SI_GAMEPAD, +// SI_ZAPPER,SI_POWERPADA,SI_POWERPADB,SI_ARKANOID}; +//static void Input1(char *text) +//{ +// int y; +// +// for(y=0;y<6;y++) +// if(!strcmp(cortab[y],text)) +// UsrInputType[0]=cortabi[y]; +//} +// +//static void Input2(char *text) +//{ +// int y; +// +// for(y=0;y<6;y++) +// if(!strcmp(cortab[y],text)) +// UsrInputType[1]=cortabi[y]; +//} +//ARGPSTRUCT InputArgs[]={ +// {"-fcexp",0,(void *)FCExp,0x2000}, +// {"-input1",0,(void *)Input1,0x2000}, +// {"-input2",0,(void *)Input2,0x2000}, +// {0,0,0,0} +//}; diff --git a/src/drivers/win/input.h b/src/drivers/win/input.h index 159ec5bf..14e7d28c 100644 --- a/src/drivers/win/input.h +++ b/src/drivers/win/input.h @@ -26,7 +26,7 @@ int GetAutoFireDesynch(); extern LPDIRECTINPUT7 lpDI; extern int InputType[3]; -extern int UsrInputType[3]; +//extern int UsrInputType[3]; extern int cidisabled; #ifndef _aosdfjk02fmasf #define _aosdfjk02fmasf @@ -58,7 +58,7 @@ void ParseGIInput(FCEUGI *GameInfo); #define FCFGD_HYPERSHOT 3 #define FCFGD_QUIZKING 4 -void InitOtherInput(void); +void InitInputPorts(void); void SetEmulationSpeed(int type); int FCEUD_TestCommandState(int c); void FCEUD_UpdateInput(); diff --git a/src/drivers/win/main.cpp b/src/drivers/win/main.cpp index 9c1ff9c5..57360539 100644 --- a/src/drivers/win/main.cpp +++ b/src/drivers/win/main.cpp @@ -613,13 +613,12 @@ int main(int argc,char *argv[]) // Parse the commandline arguments t = ParseArgies(argc, argv); - /* Bleh, need to find a better place for this. */ + //Bleh, need to find a better place for this. { pal_emulation = !!pal_emulation; FCEUI_SetVidSystem(pal_emulation); - genie = !!genie; - FCEUI_SetGameGenie(genie); + FCEUI_SetGameGenie(genie!=0); fullscreen = !!fullscreen; soundo = !!soundo; diff --git a/src/drivers/win/main.h b/src/drivers/win/main.h index 97db7e7d..a71730e7 100644 --- a/src/drivers/win/main.h +++ b/src/drivers/win/main.h @@ -26,6 +26,7 @@ extern int maxconbskip; extern int ffbskip; static int fullscreen = 0; + // Flag that indicates whether Game Genie is enabled or not. extern int genie; diff --git a/src/drivers/win/video.cpp b/src/drivers/win/video.cpp index a8e4d0b0..829192a3 100644 --- a/src/drivers/win/video.cpp +++ b/src/drivers/win/video.cpp @@ -35,7 +35,7 @@ static int bpp; static int vflags; static int veflags; -int disvaccel = 0; /* Disable video hardware acceleration. */ +int disvaccel = 0; //Disable video hardware acceleration. int fssync=0; int winsync=0; @@ -257,7 +257,7 @@ int SetVideoMode(int fs) return 1; } - /* Beginning */ + //Beginning memset(&ddsd,0,sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; @@ -280,10 +280,9 @@ int SetVideoMode(int fs) ddsdback.dwWidth=256 * specmul; ddsdback.dwHeight=FSettings.TotalScanlines() * specmul; - /* - If the blit hardware can't stretch, assume it's cheap(and slow) - and create the buffer in system memory. - */ + //If the blit hardware can't stretch, assume it's cheap(and slow) + //and create the buffer in system memory. + if(!(caps.dwCaps&DDCAPS_BLTSTRETCH)) ddsdback.ddsCaps.dwCaps|=DDSCAPS_SYSTEMMEMORY; @@ -329,7 +328,7 @@ int SetVideoMode(int fs) windowedfailed=0; SetMainWindowStuff(); } - else /* Following is full-screen */ + else //Following is full-screen { if(vmod == 0) { @@ -421,11 +420,16 @@ int SetVideoMode(int fs) ShowCursorAbs(0); } - InputScreenChanged(fs); fullscreen=fs; return 1; } +//draw input aids if we are fullscreen +bool FCEUD_ShouldDrawInputAids() +{ + return fullscreen!=0; +} + static void BlitScreenWindow(uint8 *XBuf); static void BlitScreenFull(uint8 *XBuf); //static uint8 *XBSave; @@ -1105,9 +1109,7 @@ void DoVideoConfigFix(void) UpdateRendBounds(); } -/** -* Shows the Video configuration dialog. -**/ +//Shows the Video configuration dialog. void ConfigVideo(void) { DialogBox(fceu_hInstance, "VIDEOCONFIG", hAppWnd, VideoConCallB); diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index cef55a00..d269c8e0 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -889,7 +889,7 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) // Game Genie menu was selected genie ^= 1; - FCEUI_SetGameGenie(genie); + FCEUI_SetGameGenie(genie!=0); UpdateCheckedMenuItems(); break; diff --git a/src/fceu.cpp b/src/fceu.cpp index bb78ed57..c99d1ba3 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -342,9 +342,9 @@ FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode) GameInfo->name=0; GameInfo->type=GIT_CART; GameInfo->vidsys=GIV_USER; - GameInfo->input[0]=GameInfo->input[1]=-1; - GameInfo->inputfc=-1; - GameInfo->cspecial=0; + GameInfo->input[0]=GameInfo->input[1]=SI_UNSET; + GameInfo->inputfc=SIFC_UNSET; + GameInfo->cspecial=SIS_NONE; //try to load each different format if(iNESLoad(name,fp,OverwriteVidMode)) @@ -392,16 +392,14 @@ FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode) } -/** -* Return: Flag that indicates whether the function was succesful or not. -**/ -int FCEUI_Initialize(void) +//Return: Flag that indicates whether the function was succesful or not. +bool FCEUI_Initialize() { srand(time(0)); if(!FCEU_InitVirtualVideo()) { - return 0; + return false; } AllocBuffers(); @@ -422,7 +420,7 @@ int FCEUI_Initialize(void) X6502_Init(); - return 1; + return true; } void FCEUI_Kill(void) @@ -750,12 +748,10 @@ int FCEUI_GetCurrentVidSystem(int *slstart, int *slend) return(PAL); } -/** -* Enable or disable Game Genie option. -**/ -void FCEUI_SetGameGenie(int a) +//Enable or disable Game Genie option. +void FCEUI_SetGameGenie(bool a) { - FSettings.GameGenie = a ? 1 : 0; + FSettings.GameGenie = a; } void FCEUI_SetSnapName(int a) diff --git a/src/fceu.h b/src/fceu.h index 85ba3a0b..5bb18294 100644 --- a/src/fceu.h +++ b/src/fceu.h @@ -71,7 +71,7 @@ typedef struct { int PAL; int NetworkPlay; int SoundVolume; - int GameGenie; + bool GameGenie; //the currently selected first and last rendered scanlines. int FirstSLine; diff --git a/src/git.h b/src/git.h index c1946ea4..0e46fadc 100644 --- a/src/git.h +++ b/src/git.h @@ -1,31 +1,78 @@ #ifndef __FCEU_GIT #define __FCEU_GIT -/* Mmm...git. Almost as funny as "gimp". */ -#define GIT_CART 0 /* Cart. */ -#define GIT_VSUNI 1 /* VS Unisystem. */ -#define GIT_FDS 2 /* Famicom Disk System. */ -#define GIT_NSF 3 /* NES Sound Format. */ -#define GIV_NTSC 0 /* NTSC emulation. */ -#define GIV_PAL 1 /* PAL emulation. */ -#define GIV_USER 2 /* What was set by FCEUI_SetVidSys(). */ +enum EGIT +{ + GIT_CART = 0, //Cart + GIT_VSUNI = 1, //VS Unisystem + GIT_FDS = 2, // Famicom Disk System + GIT_NSF = 3, //NES Sound Format +}; + +enum EGIV +{ + GIV_NTSC = 0, //NTSC emulation. + GIV_PAL = 1, //PAL emulation. + GIV_USER = 2, //What was set by FCEUI_SetVidSys(). +}; + +enum ESIS +{ + SIS_NONE = 0, + SIS_DATACH = 1, + SIS_NWC = 2, + SIS_VSUNISYSTEM = 3, + SIS_NSF = 4, +}; + +//input device types for the standard joystick port +enum ESI +{ + SI_UNSET = -1, + SI_NONE = 0, + SI_GAMEPAD = 1, + SI_ZAPPER = 2, + SI_POWERPADA = 3, + SI_POWERPADB = 4, + SI_ARKANOID = 5, + SI_MOUSE = 6 //mbg merge 7/17/06 added +}; + +//input device types for the expansion port +enum ESIFC +{ + SIFC_UNSET = -1, + SIFC_NONE = 0, + SIFC_ARKANOID = 1, + SIFC_SHADOW = 2, + SIFC_4PLAYER = 3, + SIFC_FKB = 4, + SIFC_SUBORKB = 5, + SIFC_HYPERSHOT = 6, + SIFC_MAHJONG = 7, + SIFC_QUIZKING = 8, + SIFC_FTRAINERA = 9, + SIFC_FTRAINERB = 10, + SIFC_OEKAKIDS = 11, + SIFC_BWORLD = 12, + SIFC_TOPRIDER = 13, +}; #include "utils/md5.h" typedef struct { - uint8 *name; /* Game name, UTF8 encoding */ + uint8 *name; //Game name, UTF8 encoding - int type; /* GIT_* */ - int vidsys; /* Current emulated video system; GIV_* */ - int input[2]; /* Desired input for emulated input ports 1 and 2; -1 - for unknown desired input. */ - int inputfc; /* Desired Famicom expansion port device. -1 for unknown - desired input. */ - int cspecial; /* Special cart expansion: DIP switches, barcode - reader, etc. - */ + EGIT type; + EGIV vidsys; //Current emulated video system; + ESI input[2]; //Desired input for emulated input ports 1 and 2; -1 for unknown desired input. + ESIFC inputfc; //Desired Famicom expansion port device. -1 for unknown desired input. + ESIS cspecial; //Special cart expansion: DIP switches, barcode reader, etc. + MD5DATA MD5; - int soundrate; /* For Ogg Vorbis expansion sound wacky support. 0 for default. */ - int soundchan; /* Number of sound channels. */ + + //mbg 6/8/08 - ??? + int soundrate; //For Ogg Vorbis expansion sound wacky support. 0 for default. + int soundchan; //Number of sound channels. } FCEUGI; #endif diff --git a/src/ines.cpp b/src/ines.cpp index 8b3e9fcd..a51682cf 100644 --- a/src/ines.cpp +++ b/src/ines.cpp @@ -169,104 +169,103 @@ struct CRCMATCH { struct INPSEL { uint32 crc32; - int input1; - int input2; - int inputfc; + ESI input1; + ESI input2; + ESIFC inputfc; }; -/* This is mostly for my personal use. So HA. */ static void SetInput(void) { - static struct INPSEL moo[]= + static struct INPSEL moo[]= { - {0x3a1694f9,SI_GAMEPAD,SI_GAMEPAD,SIFC_4PLAYER}, /* Nekketsu Kakutou Densetsu */ + {0x3a1694f9,SI_GAMEPAD,SI_GAMEPAD,SIFC_4PLAYER}, // Nekketsu Kakutou Densetsu - {0xc3c0811d,SI_GAMEPAD,SI_GAMEPAD,SIFC_OEKAKIDS}, /* The two "Oeka Kids" games */ - {0x9d048ea4,SI_GAMEPAD,SI_GAMEPAD,SIFC_OEKAKIDS}, /* */ + {0xc3c0811d,SI_GAMEPAD,SI_GAMEPAD,SIFC_OEKAKIDS}, // The two "Oeka Kids" games + {0x9d048ea4,SI_GAMEPAD,SI_GAMEPAD,SIFC_OEKAKIDS}, // - {0xaf4010ea,SI_GAMEPAD,SI_POWERPADB,-1}, /* World Class Track Meet */ - {0xd74b2719,SI_GAMEPAD,SI_POWERPADB,-1}, /* Super Team Games */ - {0x61d86167,SI_GAMEPAD,SI_POWERPADB,-1}, /* Street Cop */ - {0x6435c095,SI_GAMEPAD,SI_POWERPADB,-1}, /* Short Order/Eggsplode */ + {0xaf4010ea,SI_GAMEPAD,SI_POWERPADB,SIFC_UNSET}, // World Class Track Meet + {0xd74b2719,SI_GAMEPAD,SI_POWERPADB,SIFC_UNSET}, // Super Team Games + {0x61d86167,SI_GAMEPAD,SI_POWERPADB,SIFC_UNSET}, // Street Cop + {0x6435c095,SI_GAMEPAD,SI_POWERPADB,SIFC_UNSET}, // Short Order/Eggsplode - {0x47232739,SI_GAMEPAD,SI_GAMEPAD,SIFC_TOPRIDER}, /* Top Rider */ + {0x47232739,SI_GAMEPAD,SI_GAMEPAD,SIFC_TOPRIDER}, // Top Rider - {0x48ca0ee1,SI_GAMEPAD,SI_GAMEPAD,SIFC_BWORLD}, /* Barcode World */ - {0x9f8f200a,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERA}, /* Super Mogura Tataki!! - Pokkun Moguraa */ - {0x9044550e,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERA}, /* Rairai Kyonshizu */ - {0x2f128512,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERA}, /* Jogging Race */ - {0x60ad090a,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERA}, /* Athletic World */ + {0x48ca0ee1,SI_GAMEPAD,SI_GAMEPAD,SIFC_BWORLD}, // Barcode World + {0x9f8f200a,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERA}, // Super Mogura Tataki!! - Pokkun Moguraa + {0x9044550e,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERA}, // Rairai Kyonshizu + {0x2f128512,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERA}, // Jogging Race + {0x60ad090a,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERA}, // Athletic World - {0x8a12a7d9,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, /* Totsugeki Fuuun Takeshi Jou */ - {0xea90f3e2,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, /* Running Stadium */ - {0x370ceb65,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, /* Meiro Dai Sakusen */ - // Bad dump? {0x69ffb014,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, /* Fuun Takeshi Jou 2 */ - {0x6cca1c1f,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, /* Dai Undoukai */ - {0x29de87af,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, /* Aerobics Studio */ - {0xbba58be5,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, /* Family Trainer: Manhattan Police */ - {0xea90f3e2,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, /* Family Trainer: Running Stadium */ + {0x8a12a7d9,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, // Totsugeki Fuuun Takeshi Jou + {0xea90f3e2,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, // Running Stadium + {0x370ceb65,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, // Meiro Dai Sakusen + // Bad dump? {0x69ffb014,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, // Fuun Takeshi Jou 2 + {0x6cca1c1f,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, // Dai Undoukai + {0x29de87af,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, // Aerobics Studio + {0xbba58be5,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, // Family Trainer: Manhattan Police + {0xea90f3e2,SI_GAMEPAD,SI_GAMEPAD,SIFC_FTRAINERB}, // Family Trainer: Running Stadium - {0xd9f45be9,SI_GAMEPAD,SI_GAMEPAD,SIFC_QUIZKING}, /* Gimme a Break ... */ - {0x1545bd13,SI_GAMEPAD,SI_GAMEPAD,SIFC_QUIZKING}, /* Gimme a Break ... 2 */ + {0xd9f45be9,SI_GAMEPAD,SI_GAMEPAD,SIFC_QUIZKING}, // Gimme a Break ... + {0x1545bd13,SI_GAMEPAD,SI_GAMEPAD,SIFC_QUIZKING}, // Gimme a Break ... 2 - {0x7b44fb2a,SI_GAMEPAD,SI_GAMEPAD,SIFC_MAHJONG}, /* Ide Yousuke Meijin no Jissen Mahjong 2 */ - {0x9fae4d46,SI_GAMEPAD,SI_GAMEPAD,SIFC_MAHJONG}, /* Ide Yousuke Meijin no Jissen Mahjong */ + {0x7b44fb2a,SI_GAMEPAD,SI_GAMEPAD,SIFC_MAHJONG}, // Ide Yousuke Meijin no Jissen Mahjong 2 + {0x9fae4d46,SI_GAMEPAD,SI_GAMEPAD,SIFC_MAHJONG}, // Ide Yousuke Meijin no Jissen Mahjong - {0x980be936,SI_GAMEPAD,SI_GAMEPAD,SIFC_HYPERSHOT}, /* Hyper Olympic */ - {0x21f85681,SI_GAMEPAD,SI_GAMEPAD,SIFC_HYPERSHOT}, /* Hyper Olympic (Gentei Ban) */ - {0x915a53a7,SI_GAMEPAD,SI_GAMEPAD,SIFC_HYPERSHOT}, /* Hyper Sports */ - {0xad9c63e2,SI_GAMEPAD,-1,SIFC_SHADOW}, /* Space Shadow */ + {0x980be936,SI_GAMEPAD,SI_GAMEPAD,SIFC_HYPERSHOT}, // Hyper Olympic + {0x21f85681,SI_GAMEPAD,SI_GAMEPAD,SIFC_HYPERSHOT}, // Hyper Olympic (Gentei Ban) + {0x915a53a7,SI_GAMEPAD,SI_GAMEPAD,SIFC_HYPERSHOT}, // Hyper Sports + {0xad9c63e2,SI_GAMEPAD,SI_UNSET,SIFC_SHADOW}, // Space Shadow - {0x24598791,-1,SI_ZAPPER,0}, /* Duck Hunt */ - {0xff24d794,-1,SI_ZAPPER,0}, /* Hogan's Alley */ - {0xbeb8ab01,-1,SI_ZAPPER,0}, /* Gumshoe */ - {0xde8fd935,-1,SI_ZAPPER,0}, /* To the Earth */ - {0xedc3662b,-1,SI_ZAPPER,0}, /* Operation Wolf */ - {0x2a6559a1,-1,SI_ZAPPER,0}, /* Operation Wolf (J) */ + {0x24598791,SI_UNSET,SI_ZAPPER,SIFC_NONE}, // Duck Hunt + {0xff24d794,SI_UNSET,SI_ZAPPER,SIFC_NONE}, // Hogan's Alley + {0xbeb8ab01,SI_UNSET,SI_ZAPPER,SIFC_NONE}, // Gumshoe + {0xde8fd935,SI_UNSET,SI_ZAPPER,SIFC_NONE}, // To the Earth + {0xedc3662b,SI_UNSET,SI_ZAPPER,SIFC_NONE}, // Operation Wolf + {0x2a6559a1,SI_UNSET,SI_ZAPPER,SIFC_NONE}, // Operation Wolf (J) - {0x23d17f5e,SI_GAMEPAD,SI_ZAPPER,0}, /* The Lone Ranger */ - {0xb8b9aca3,-1,SI_ZAPPER,0}, /* Wild Gunman */ - {0x5112dc21,-1,SI_ZAPPER,0}, /* Wild Gunman */ - {0x4318a2f8,-1,SI_ZAPPER,0}, /* Barker Bill's Trick Shooting */ - {0x5ee6008e,-1,SI_ZAPPER,0}, /* Mechanized Attack */ - {0x3e58a87e,-1,SI_ZAPPER,0}, /* Freedom Force */ - {0xe9a7fe9e,-1,SI_MOUSE,0}, /* Educational Computer 2000 */ //mbg merge 7/17/06 added -- appears to be from newer MM build - {0x851eb9be,SI_GAMEPAD,SI_ZAPPER,0}, /* Shooting Range */ - {0x74bea652,SI_GAMEPAD,SI_ZAPPER,0}, /* Supergun 3-in-1 */ - {0x32fb0583,-1,SI_ARKANOID,0}, /* Arkanoid(NES) */ - {0xd89e5a67,-1,-1,SIFC_ARKANOID}, /* Arkanoid (J) */ - {0x0f141525,-1,-1,SIFC_ARKANOID}, /* Arkanoid 2(J) */ + {0x23d17f5e,SI_GAMEPAD,SI_ZAPPER,SIFC_NONE}, // The Lone Ranger + {0xb8b9aca3,SI_UNSET,SI_ZAPPER,SIFC_NONE}, // Wild Gunman + {0x5112dc21,SI_UNSET,SI_ZAPPER,SIFC_NONE}, // Wild Gunman + {0x4318a2f8,SI_UNSET,SI_ZAPPER,SIFC_NONE}, // Barker Bill's Trick Shooting + {0x5ee6008e,SI_UNSET,SI_ZAPPER,SIFC_NONE}, // Mechanized Attack + {0x3e58a87e,SI_UNSET,SI_ZAPPER,SIFC_NONE}, // Freedom Force + {0xe9a7fe9e,SI_UNSET,SI_MOUSE,SIFC_NONE}, // Educational Computer 2000 //mbg merge 7/17/06 added -- appears to be from newer MM build + {0x851eb9be,SI_GAMEPAD,SI_ZAPPER,SIFC_NONE}, // Shooting Range + {0x74bea652,SI_GAMEPAD,SI_ZAPPER,SIFC_NONE}, // Supergun 3-in-1 + {0x32fb0583,SI_UNSET,SI_ARKANOID,SIFC_NONE}, // Arkanoid(NES) + {0xd89e5a67,SI_UNSET,SI_UNSET,SIFC_ARKANOID}, // Arkanoid (J) + {0x0f141525,SI_UNSET,SI_UNSET,SIFC_ARKANOID}, // Arkanoid 2(J) - {0x912989dc,-1,-1,SIFC_FKB}, /* Playbox BASIC */ - {0xf7606810,-1,-1,SIFC_FKB}, /* Family BASIC 2.0A */ - {0x895037bc,-1,-1,SIFC_FKB}, /* Family BASIC 2.1a */ - {0xb2530afc,-1,-1,SIFC_FKB}, /* Family BASIC 3.0 */ - {0x82f1fb96,-1,-1,SIFC_SUBORKB}, /* Subor 1.0 Russian */ - {0xabb2f974,-1,-1,SIFC_SUBORKB}, /* Study and Game 32-in-1 */ - {0xd5d6eac4,-1,-1,SIFC_SUBORKB}, /* Edu (As) */ - {0x589b6b0d,-1,-1,SIFC_SUBORKB}, /* SuporV20 */ - {0x5e073a1b,-1,-1,SIFC_SUBORKB}, /* Supor English (Chinese) */ - {0x8b265862,-1,-1,SIFC_SUBORKB}, - {0x41401c6d,-1,-1,SIFC_SUBORKB}, /* SuporV40 */ - {0x41ef9ac4,-1,-1,SIFC_SUBORKB}, - {0x368c19a8,-1,-1,SIFC_SUBORKB}, /* LIKO Study Cartridge */ - {0x543ab532,-1,-1,SIFC_SUBORKB}, /* LIKO Color Lines */ - {0,-1,-1,-1} + {0x912989dc,SI_UNSET,SI_UNSET,SIFC_FKB}, // Playbox BASIC + {0xf7606810,SI_UNSET,SI_UNSET,SIFC_FKB}, // Family BASIC 2.0A + {0x895037bc,SI_UNSET,SI_UNSET,SIFC_FKB}, // Family BASIC 2.1a + {0xb2530afc,SI_UNSET,SI_UNSET,SIFC_FKB}, // Family BASIC 3.0 + {0x82f1fb96,SI_UNSET,SI_UNSET,SIFC_SUBORKB}, // Subor 1.0 Russian + {0xabb2f974,SI_UNSET,SI_UNSET,SIFC_SUBORKB}, // Study and Game 32-in-1 + {0xd5d6eac4,SI_UNSET,SI_UNSET,SIFC_SUBORKB}, // Edu (As) + {0x589b6b0d,SI_UNSET,SI_UNSET,SIFC_SUBORKB}, // SuporV20 + {0x5e073a1b,SI_UNSET,SI_UNSET,SIFC_SUBORKB}, // Supor English (Chinese) + {0x8b265862,SI_UNSET,SI_UNSET,SIFC_SUBORKB}, + {0x41401c6d,SI_UNSET,SI_UNSET,SIFC_SUBORKB}, // SuporV40 + {0x41ef9ac4,SI_UNSET,SI_UNSET,SIFC_SUBORKB}, + {0x368c19a8,SI_UNSET,SI_UNSET,SIFC_SUBORKB}, // LIKO Study Cartridge + {0x543ab532,SI_UNSET,SI_UNSET,SIFC_SUBORKB}, // LIKO Color Lines + {0,SI_UNSET,SI_UNSET,SIFC_UNSET} }; - int x=0; + int x=0; - while(moo[x].input1>=0 || moo[x].input2>=0 || moo[x].inputfc>=0) - { - if(moo[x].crc32==iNESGameCRC32) - { - GameInfo->input[0]=moo[x].input1; - GameInfo->input[1]=moo[x].input2; - GameInfo->inputfc=moo[x].inputfc; - break; - } - x++; - } + while(moo[x].input1>=0 || moo[x].input2>=0 || moo[x].inputfc>=0) + { + if(moo[x].crc32==iNESGameCRC32) + { + GameInfo->input[0]=moo[x].input1; + GameInfo->input[1]=moo[x].input2; + GameInfo->inputfc=moo[x].inputfc; + break; + } + x++; + } } #define INESB_INCOMPLETE 1 diff --git a/src/input.cpp b/src/input.cpp index 188fe76d..6532303e 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -20,6 +20,7 @@ */ #include +#include #include #include "types.h" @@ -65,7 +66,7 @@ extern INPUTCFC *FCEU_InitBarcodeWorld(void); //--------------- static uint8 joy_readbit[2]; -static uint8 joy[4]={0,0,0,0}; +uint8 joy[4]={0,0,0,0}; //HACK - should be static but movie needs it static uint8 LastStrobe; static int BotMode = 0; @@ -83,23 +84,8 @@ extern uint8 coinon; static bool FSDisable=false; // Set to true if NES-style four-player adapter is disabled. -static struct JOYPORT -{ - int attrib; - ESI type; - void* ptr; - INPUTC* driver; -} joyports[2]; - -static struct FCPORT -{ - int attrib; - ESIFC type; - void* ptr; - INPUTCFC* driver; -} portFC; - - +JOYPORT joyports[2] = { JOYPORT(0), JOYPORT(1) }; +FCPORT portFC; static DECLFR(JPRead) { @@ -142,9 +128,9 @@ static DECLFW(B4016) } //a main joystick port driver representing the case where nothing is plugged in -static INPUTC DummyJPort={0,0,0,0,0}; +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}; +static INPUTCFC DummyPortFC={0,0,0,0,0,0}; //--------4 player driver for expansion port-------- @@ -200,6 +186,35 @@ static void UpdateGP(int w, void *data, int arg) } } +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) { @@ -231,8 +246,8 @@ static void StrobeGP(int w) //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^6 -static INPUTC GPC={ReadGP,0,StrobeGP,UpdateGP,0,0}; -static INPUTC GPCVS={ReadGPVS,0,StrobeGP,UpdateGP,0,0}; +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() { @@ -295,14 +310,16 @@ void FCEU_UpdateBot() #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--; @@ -310,8 +327,9 @@ void FCEU_UpdateInput(void) if(FCEUnetplay) NetplayUpdate(joy); - FCEUMOV_AddInputState(ZD, joy, BotMode); - + 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]); } diff --git a/src/input.h b/src/input.h index 5c2a6df8..ed758c24 100644 --- a/src/input.h +++ b/src/input.h @@ -1,8 +1,16 @@ #ifndef _INPUT_H_ #define _INPUT_H_ +#include + +#include "git.h" + +class MovieRecord; + +//MBG TODO - COMBINE THESE INPUTC AND INPUTCFC + //The interface for standard joystick port device drivers -typedef struct +struct INPUTC { //these methods call the function pointers (or not, if they are null) uint8 Read(int w) { if(_Read) return _Read(w); else return 0; } @@ -11,17 +19,25 @@ typedef struct void Update(int w, void *data, int arg) { if(_Update) _Update(w,data,arg); } void SLHook(int w, uint8 *bg, uint8 *spr, uint32 linets, int final) { if(_SLHook) _SLHook(w,bg,spr,linets,final); } void Draw(int w, uint8 *buf, int arg) { if(_Draw) _Draw(w,buf,arg); } + void Log(int w, MovieRecord* mr) { if(_Log) _Log(w,mr); } + void Load(int w, MovieRecord* mr) { if(_Load) _Load(w,mr); } uint8 (*_Read)(int w); void (*_Write)(uint8 v); void (*_Strobe)(int w); + //update will be called if input is coming from the user. refresh your logical state from user input devices void (*_Update)(int w, void *data, int arg); void (*_SLHook)(int w, uint8 *bg, uint8 *spr, uint32 linets, int final); void (*_Draw)(int w, uint8 *buf, int arg); -} INPUTC; + + //log is called when you need to put your logical state into a movie record for recording + void (*_Log)(int w, MovieRecord* mr); + //load will be called if input is coming from a movie. refresh your logical state from a movie record + void (*_Load)(int w, MovieRecord* mr); +}; //The interface for the expansion port device drivers -typedef struct +struct INPUTCFC { //these methods call the function pointers (or not, if they are null) uint8 Read(int w, uint8 ret) { if(_Read) return _Read(w,ret); else return ret; } @@ -30,14 +46,48 @@ typedef struct void Update(void *data, int arg) { if(_Update) _Update(data,arg); } void SLHook(uint8 *bg, uint8 *spr, uint32 linets, int final) { if(_SLHook) _SLHook(bg,spr,linets,final); } void Draw(uint8 *buf, int arg) { if(_Draw) _Draw(buf,arg); } + void Log(MovieRecord* mr) { if(_Log) _Log(mr); } + void Load(MovieRecord* mr) { if(_Load) _Load(mr); } uint8 (*_Read)(int w, uint8 ret); void (*_Write)(uint8 v); void (*_Strobe)(); + //update will be called if input is coming from the user. refresh your logical state from user input devices void (*_Update)(void *data, int arg); void (*_SLHook)(uint8 *bg, uint8 *spr, uint32 linets, int final); void (*_Draw)(uint8 *buf, int arg); -} INPUTCFC; + + //log is called when you need to put your logical state into a movie record for recording + void (*_Log)(MovieRecord* mr); + + //load will be called if input is coming from a movie. refresh your logical state from a movie record + void (*_Load)(MovieRecord* mr); +}; + +extern struct JOYPORT +{ + JOYPORT(int _w) + : w(_w) + {} + + int w; + int attrib; + ESI type; + void* ptr; + INPUTC* driver; + + void log(MovieRecord* mr) { driver->Log(w,mr); } + void load(MovieRecord* mr) { driver->Load(w,mr); } +} joyports[2]; + +extern struct FCPORT +{ + int attrib; + ESIFC type; + void* ptr; + INPUTCFC* driver; +} portFC; + void FCEU_DrawInput(uint8 *buf); void FCEU_UpdateInput(void); diff --git a/src/input/oekakids.cpp b/src/input/oekakids.cpp index f94bd8dc..f4b65649 100644 --- a/src/input/oekakids.cpp +++ b/src/input/oekakids.cpp @@ -82,7 +82,7 @@ static void OK_Update(void *data, int arg) static void DrawOeka(uint8 *buf, int arg) { - if(arg && OKY<44) + if(OKY<44) FCEU_DrawCursor(buf, OKX, OKY); } diff --git a/src/input/shadow.cpp b/src/input/shadow.cpp index 55a6ed43..fab5d8b6 100644 --- a/src/input/shadow.cpp +++ b/src/input/shadow.cpp @@ -117,7 +117,6 @@ static uint8 ReadZapper(int w, uint8 ret) static void DrawZapper(uint8 *buf, int arg) { - if(arg) FCEU_DrawCursor(buf, ZD.mzx, ZD.mzy); } diff --git a/src/input/zapper.cpp b/src/input/zapper.cpp index b3928183..d8d101a4 100644 --- a/src/input/zapper.cpp +++ b/src/input/zapper.cpp @@ -23,8 +23,9 @@ #include "share.h" #include "zapper.h" +#include "movie.h" -ZAPPER ZD[2]; +static ZAPPER ZD[2]; static void ZapperFrapper(int w, uint8 *bg, uint8 *spr, uint32 linets, int final) { @@ -125,8 +126,7 @@ static uint8 ReadZapper(int w) static void DrawZapper(int w, uint8 *buf, int arg) { - if(arg) - FCEU_DrawGunSight(buf, ZD[w].mzx,ZD[w].mzy); + FCEU_DrawGunSight(buf, ZD[w].mzx,ZD[w].mzy); } static void UpdateZapper(int w, void *data, int arg) @@ -144,8 +144,28 @@ static void UpdateZapper(int w, void *data, int arg) ZD[w].mzb=ptr[2]; } -static INPUTC ZAPC={ReadZapper,0,0,UpdateZapper,ZapperFrapper,DrawZapper}; -static INPUTC ZAPVSC={ReadZapperVS,0,StrobeZapperVS,UpdateZapper,ZapperFrapper,DrawZapper}; +static void LogZapper(int w, MovieRecord* mr) +{ + mr->zappers[w].x = ZD[w].mzx; + mr->zappers[w].y = ZD[w].mzy; + mr->zappers[w].b = ZD[w].mzb; +} + +static void LoadZapper(int w, MovieRecord* mr) +{ + if(ZD[w].bogo) + ZD[w].bogo--; + if(mr->zappers[w].b&3 && (!(ZD[w].mzb&3))) + ZD[w].bogo=5; + + ZD[w].mzx = mr->zappers[w].x; + ZD[w].mzy = mr->zappers[w].y; + ZD[w].mzb = mr->zappers[w].b; +} + + +static INPUTC ZAPC={ReadZapper,0,0,UpdateZapper,ZapperFrapper,DrawZapper,LogZapper,LoadZapper}; +static INPUTC ZAPVSC={ReadZapperVS,0,StrobeZapperVS,UpdateZapper,ZapperFrapper,DrawZapper,LogZapper,LoadZapper}; INPUTC *FCEU_InitZapper(int w) { diff --git a/src/movie.cpp b/src/movie.cpp index 907c3ddf..0289a2bf 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -608,7 +608,7 @@ void FCEUI_SaveMovie(char *fname, uint8 flags) //the main interaction point between the emulator and the movie system. //either dumps the current joystick state or loads one state from the movie -void FCEUMOV_AddInputState(ZAPPER (&zappers)[2], uint8 (&js)[4], int SkipFlush) +void FCEUMOV_AddInputState() { //todo - for tasedit, either dump or load depending on whether input recording is enabled //or something like that @@ -624,16 +624,9 @@ void FCEUMOV_AddInputState(ZAPPER (&zappers)[2], uint8 (&js)[4], int SkipFlush) } else { - MovieRecord& mr = currMovieData.records[currFrameCounter]; - for(int i=0;i<4;i++) - js[i] = mr.joysticks[i]; - - for(int i=0;i<2;i++) - { - zappers[i].mzx = mr.zappers[i].x; - zappers[i].mzy = mr.zappers[i].y; - zappers[i].mzb = mr.zappers[i].b; - } + MovieRecord* mr = &currMovieData.records[currFrameCounter]; + joyports[0].load(mr); + joyports[1].load(mr); } //if we are on the last frame, then pause the emulator if the player requested it @@ -657,28 +650,20 @@ void FCEUMOV_AddInputState(ZAPPER (&zappers)[2], uint8 (&js)[4], int SkipFlush) { MovieRecord mr; - //for each joystick - for(int i=0;i<4;i++) - mr.joysticks[i] = js[i]; + joyports[0].log(&mr); + joyports[1].log(&mr); - //printf("%d %d %d\n",zappers[1].mzx,zappers[1].mzy,zappers[1].mzb); - - for(int i=0;i<2;i++) - { - mr.zappers[i].x = zappers[i].mzx; - mr.zappers[i].y = zappers[i].mzy; - mr.zappers[i].b = zappers[i].mzb; - } - mr.dump(osRecordingMovie,currMovieData.records.size()); currMovieData.records.push_back(mr); } currFrameCounter++; - memcpy(&cur_input_display,js,4); + extern uint8 joy[4]; + memcpy(&cur_input_display,joy,4); } + //TODO void FCEUMOV_AddCommand(int cmd) { diff --git a/src/movie.h b/src/movie.h index e6f69319..14b0b1c9 100644 --- a/src/movie.h +++ b/src/movie.h @@ -8,7 +8,7 @@ #include "input/zapper.h" -void FCEUMOV_AddInputState(ZAPPER (&zappers)[2], uint8 (&js)[4], int SkipFlush); +void FCEUMOV_AddInputState(); void FCEUMOV_AddCommand(int cmd); void FCEU_DrawMovies(uint8 *); diff --git a/src/video.cpp b/src/video.cpp index 9d08955e..f490dde9 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -223,7 +223,9 @@ void FCEU_PutImage(void) } DrawMessage(false); - FCEU_DrawInput(XBuf); + + if(FCEUD_ShouldDrawInputAids()) + FCEU_DrawInput(XBuf); //Fancy input display code if(input_display) diff --git a/src/vsuni.cpp b/src/vsuni.cpp index 79ffd400..f5a1669b 100644 --- a/src/vsuni.cpp +++ b/src/vsuni.cpp @@ -334,7 +334,6 @@ void FCEU_VSUniCheck(uint64 md5partial, int *MapperNo, uint8 *Mirroring) { if(vs->ppu < RCP2C03B) pale = vs->ppu; - //puts(vs->name); *MapperNo = vs->mapper; *Mirroring = vs->mirroring; GameInfo->type = GIT_VSUNI;