add support for snes pad to windows port

This commit is contained in:
zeromus 2016-03-30 21:40:59 +00:00
parent 90621da6d4
commit 094d1bb827
5 changed files with 253 additions and 105 deletions

View File

@ -104,6 +104,7 @@ static void UpdateMahjong(void);
static void UpdateFTrainer(void);
static void UpdateTopRider(void);
static uint32 snespad_return[4];
static uint32 JSreturn=0;
int NoWaiting=0;
bool turbo = false;
@ -126,7 +127,7 @@ int allowUDLR=0;
#define GPZ() {MKZ(), MKZ(), MKZ(), MKZ()}
ButtConfig GamePadConfig[4][10]={
ButtConfig GamePadConfig[4][12]={
//Gamepad 1
{
MK(F), MK(D), MK(S), MK(ENTER), MK(BL_CURSORUP),
@ -241,27 +242,37 @@ int DTestButton(ButtConfig *bc)
return(0);
}
void UpdateGamepad()
void UpdateGamepad(bool snes)
{
if(FCEUMOV_Mode(MOVIEMODE_PLAY))
return;
uint32 JS=0;
int x;
int wg;
int JS=0;
if(FCEUMOV_Mode(MOVIEMODE_RECORD))
AutoFire();
for(wg=0;wg<4;wg++)
for(int wg=0;wg<4;wg++)
{
for(x=0;x<8;x++)
if(DTestButton(&GamePadConfig[wg][x]))
JS|=(1<<x)<<(wg<<3);
int wgs = wg;
if(snes)
{
wgs = 0;
for(int x=0;x<16;x++)
if(DTestButton(&GamePadConfig[wg][x]))
JS|=(1<<x)<<(wgs<<3);
}
else
{
for(int x=0;x<8;x++)
if(DTestButton(&GamePadConfig[wg][x]))
JS|=(1<<x)<<(wgs<<3);
}
// Check if U+D/L+R is disabled
//TODO: how does this affect snes pads?
if(!allowUDLR)
{
for(x=0;x<32;x+=8)
for(int x=0;x<32;x+=8)
{
if((JS & (0xC0<<x) ) == (0xC0<<x) ) JS&=~(0xC0<<x);
if((JS & (0x30<<x) ) == (0x30<<x) ) JS&=~(0x30<<x);
@ -269,9 +280,18 @@ void UpdateGamepad()
}
// if(rapidAlternator)
for(x=0;x<2;x++)
if(DTestButton(&GamePadConfig[wg][8+x]))
JS|=((1<<x)<<(wg<<3))*(rapidAlternator^(x*DesynchAutoFire));
if(!snes)
{
for(int x=0;x<2;x++)
if(DTestButton(&GamePadConfig[wg][8+x]))
JS|=((1<<x)<<(wgs<<3))*(rapidAlternator^(x*DesynchAutoFire));
}
if(snes)
{
snespad_return[wg] = JS;
//printf("%d %d\n",wg,JS);
}
}
if(autoHoldOn)
@ -283,8 +303,8 @@ void UpdateGamepad()
JSAutoHeldAffected = 0;
}
for(wg=0;wg<4;wg++)
for(x=0;x<8;x++)
for(int wg=0;wg<4;wg++)
for(int x=0;x<8;x++)
if(DTestButton(&GamePadConfig[wg][x]))
{
if(!autoHoldRefire || !(JSAutoHeldAffected&(1<<x)<<(wg<<3)))
@ -340,7 +360,8 @@ void UpdateGamepad()
if(JSAutoHeld)
JS ^= JSAutoHeld;
JSreturn=JS;
if(!snes)
JSreturn=JS;
}
ButtConfig powerpadsc[2][12]={
@ -405,6 +426,9 @@ void FCEUD_UpdateInput()
switch(InputType[x])
{
case SI_GAMEPAD: joy=true; break;
case SI_SNES:
UpdateGamepad(true);
break;
case SI_ARKANOID: mouse=true; break;
case SI_ZAPPER: mouse=true; break;
case SI_POWERPADA:
@ -436,7 +460,7 @@ void FCEUD_UpdateInput()
}
if(joy)
UpdateGamepad();
UpdateGamepad(false);
if(mouse)
if(FCEUMOVState != MOVIEMODE_PLAY) //FatRatKnight: Moved this if out of the function
@ -489,6 +513,9 @@ void InitInputPorts(bool fourscore)
case SI_ZAPPER:
InputDPtr=MouseData;
break;
case SI_SNES:
InputDPtr=snespad_return;
break;
}
FCEUI_SetInput(i,(ESI)InputType[i],InputDPtr,attrib);
}
@ -603,6 +630,18 @@ static ButtConfig HyperShotButtons[4]=
MK(Q),MK(W),MK(E),MK(R)
};
static void UpdateSNES()
{
int x;
HyperShotData=0;
for(x=0;x<0x4;x++)
{
if(DTestButton(&HyperShotButtons[x]))
HyperShotData|=1<<x;
}
}
static void UpdateHyperShot(void)
{
int x;
@ -1022,6 +1061,15 @@ static BOOL CALLBACK DoTBCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
sprintf(buf,"Virtual Gamepad %d",DoTBPort+3);
SetDlgItemText(hwndDlg, GRP_GAMEPAD2, buf);
}
if(DoTBType == SI_SNES)
{
char buf[32];
sprintf(buf,"Virtual SNES Pad %d",DoTBPort+1);
SetDlgItemText(hwndDlg, GRP_GAMEPAD1,buf);
sprintf(buf,"Virtual SNES Pad %d",DoTBPort+3);
SetDlgItemText(hwndDlg, GRP_GAMEPAD2, buf);
}
SetWindowText(hwndDlg, DoTBTitle);
break;
case WM_CLOSE:
@ -1064,7 +1112,7 @@ const unsigned int NUMBER_OF_PORTS = 2;
const unsigned int NUMBER_OF_NES_DEVICES = SI_COUNT + 1;
const static unsigned int NUMBER_OF_FAMICOM_DEVICES = SIFC_COUNT + 1;
//these are unfortunate lists. they match the ESI and ESIFC enums
static const int configurable_nes[NUMBER_OF_NES_DEVICES]= { 0, 1, 0, 1, 1, 0 };
static const int configurable_nes[NUMBER_OF_NES_DEVICES]= { 0, 1, 0, 1, 1, 0, 0, 1 };
static const int configurable_fam[NUMBER_OF_FAMICOM_DEVICES]= { 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0 };
const unsigned int FAMICOM_POSITION = 2;
@ -1367,18 +1415,22 @@ BOOL CALLBACK InputConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
switch(InputType[which])
{
case SI_GAMEPAD:
case SI_SNES:
{
ButtConfig tmp[10 + 10];
ButtConfig tmp[12 + 12];
memcpy(tmp, GamePadConfig[which], 10 * sizeof(ButtConfig));
memcpy(&tmp[10], GamePadConfig[which + 2], 10 * sizeof(ButtConfig));
memcpy(tmp, GamePadConfig[which], 12 * sizeof(ButtConfig));
memcpy(&tmp[12], GamePadConfig[which + 2], 12 * sizeof(ButtConfig));
DoTBType = SI_GAMEPAD;
DoTBType = InputType[which];
DoTBPort = which;
DoTBConfig(hwndDlg, text, "GAMEPADDIALOG", tmp, 10 + 10);
if(DoTBType == SI_GAMEPAD)
DoTBConfig(hwndDlg, text, "GAMEPADDIALOG", tmp, 12 + 12);
else
DoTBConfig(hwndDlg, text, MAKEINTRESOURCE(DLG_SNESPAD), tmp, 12); //no 2nd controller since no four score
memcpy(GamePadConfig[which], tmp, 10 * sizeof(ButtConfig));
memcpy(GamePadConfig[which + 2], &tmp[10], 10 * sizeof(ButtConfig));
memcpy(GamePadConfig[which], tmp, 12 * sizeof(ButtConfig));
memcpy(GamePadConfig[which + 2], &tmp[12], 12 * sizeof(ButtConfig));
}
break;

View File

@ -11,12 +11,88 @@
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Russian (Russia) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
#pragma code_page(1251)
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_TASEDITOR_SAVINGOPTIONS DIALOGEX 0, 0, 223, 208
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Project file saving options"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,109,187,50,14
PUSHBUTTON "Cancel",IDCANCEL,165,187,50,14
CONTROL " Binary format of Input",IDC_CHECK_BINARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,17,89,10
CONTROL " Markers",IDC_CHECK_MARKERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,32,67,10
CONTROL " Bookmarks",IDC_CHECK_BOOKMARKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,47,67,10
CONTROL " History",IDC_CHECK_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,62,67,10
CONTROL " Piano Roll",IDC_CHECK_PIANO_ROLL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,77,67,10
CONTROL " Selection",IDC_CHECK_SELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,92,67,10
GROUPBOX "File contents",IDC_STATIC,105,4,111,177
GROUPBOX "Greenzone saving options",IDC_STATIC,112,106,97,69
CONTROL " all frames",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,122,117,77,10
CONTROL " every 16th frame",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,122,131,77,10
CONTROL " marked frames",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,122,145,77,10
CONTROL " don't save",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON,122,159,77,10
CONTROL " Autosave project",IDC_AUTOSAVE_PROJECT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,17,81,10
CONTROL " silently",IDC_SILENT_AUTOSAVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,47,42,10
LTEXT "every",IDC_STATIC,14,32,21,8
EDITTEXT IDC_AUTOSAVE_PERIOD,36,30,24,14,ES_AUTOHSCROLL | ES_NUMBER
LTEXT "minutes",IDC_STATIC,64,32,28,8
GROUPBOX "Settings",IDC_STATIC,6,4,91,177
END
IDD_SYMBOLIC_DEBUG_NAMING DIALOGEX 0, 0, 245, 83
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Symbolic Debug Naming"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,132,62,50,14
PUSHBUTTON "Cancel",IDCANCEL,189,62,50,14
LTEXT "File",IDC_STATIC,7,7,15,9
EDITTEXT IDC_SYMBOLIC_ADDRESS,38,24,33,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP
LTEXT "Address",IDC_STATIC,6,26,30,10
EDITTEXT IDC_SYMBOLIC_NAME,107,24,132,13,ES_AUTOHSCROLL
LTEXT "Name",IDC_STATIC,83,26,22,10
LTEXT "Comment",IDC_STATIC,6,45,37,10
EDITTEXT IDC_SYMBOLIC_COMMENT,45,43,194,13,ES_AUTOHSCROLL
EDITTEXT IDC_SYMBOLIC_FILENAME,24,6,215,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_SYMBOLIC_DEBUG_NAMING, DIALOG
BEGIN
BOTTOMMARGIN, 82
END
END
#endif // APSTUDIO_INVOKED
#endif // Russian (Russia) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Neutral resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#pragma code_page(1251)
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
@ -1535,6 +1611,28 @@ BEGIN
EDITTEXT IDC_PROMPT_EDIT,10,15,167,14,ES_AUTOHSCROLL
END
DLG_SNESPAD DIALOGEX 4, 109, 243, 220
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Gamepad Configuration"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "Close",BTN_CLOSE,173,196,56,14
GROUPBOX "",GRP_GAMEPAD1,4,8,232,82,WS_GROUP
PUSHBUTTON "Up",304,35,36,24,12
PUSHBUTTON "Left",306,9,54,25,12
PUSHBUTTON "Right",307,60,54,24,12
PUSHBUTTON "Down",305,35,73,24,12
PUSHBUTTON "Select",302,91,54,26,12
PUSHBUTTON "Start",303,126,54,26,12
PUSHBUTTON "Y",301,164,53,16,12
PUSHBUTTON "B",300,181,66,16,12
PUSHBUTTON "A",308,199,53,16,12
PUSHBUTTON "X",309,181,40,16,12
PUSHBUTTON "L",310,10,19,32,12
PUSHBUTTON "R",311,198,19,32,12
GROUPBOX "",GRP_GAMEPAD2,4,101,232,82,WS_GROUP
END
/////////////////////////////////////////////////////////////////////////////
//
@ -1551,6 +1649,14 @@ BEGIN
TOPMARGIN, 8
END
"GAMEPADDIALOG", DIALOG
BEGIN
END
"GUICONFIG", DIALOG
BEGIN
END
"INPUTCONFIG", DIALOG
BEGIN
LEFTMARGIN, 10
@ -1694,6 +1800,10 @@ BEGIN
"VIDEOCONFIG", DIALOG
BEGIN
END
DLG_SNESPAD, DIALOG
BEGIN
END
END
#endif // APSTUDIO_INVOKED
@ -2217,82 +2327,6 @@ END
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Russian (Russia) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
#pragma code_page(1251)
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_TASEDITOR_SAVINGOPTIONS DIALOGEX 0, 0, 223, 208
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Project file saving options"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,109,187,50,14
PUSHBUTTON "Cancel",IDCANCEL,165,187,50,14
CONTROL " Binary format of Input",IDC_CHECK_BINARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,17,89,10
CONTROL " Markers",IDC_CHECK_MARKERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,32,67,10
CONTROL " Bookmarks",IDC_CHECK_BOOKMARKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,47,67,10
CONTROL " History",IDC_CHECK_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,62,67,10
CONTROL " Piano Roll",IDC_CHECK_PIANO_ROLL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,77,67,10
CONTROL " Selection",IDC_CHECK_SELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,92,67,10
GROUPBOX "File contents",IDC_STATIC,105,4,111,177
GROUPBOX "Greenzone saving options",IDC_STATIC,112,106,97,69
CONTROL " all frames",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,122,117,77,10
CONTROL " every 16th frame",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,122,131,77,10
CONTROL " marked frames",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,122,145,77,10
CONTROL " don't save",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON,122,159,77,10
CONTROL " Autosave project",IDC_AUTOSAVE_PROJECT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,17,81,10
CONTROL " silently",IDC_SILENT_AUTOSAVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,47,42,10
LTEXT "every",IDC_STATIC,14,32,21,8
EDITTEXT IDC_AUTOSAVE_PERIOD,36,30,24,14,ES_AUTOHSCROLL | ES_NUMBER
LTEXT "minutes",IDC_STATIC,64,32,28,8
GROUPBOX "Settings",IDC_STATIC,6,4,91,177
END
IDD_SYMBOLIC_DEBUG_NAMING DIALOGEX 0, 0, 245, 83
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Symbolic Debug Naming"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,132,62,50,14
PUSHBUTTON "Cancel",IDCANCEL,189,62,50,14
LTEXT "File",IDC_STATIC,7,7,15,9
EDITTEXT IDC_SYMBOLIC_ADDRESS,38,24,33,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP
LTEXT "Address",IDC_STATIC,6,26,30,10
EDITTEXT IDC_SYMBOLIC_NAME,107,24,132,13,ES_AUTOHSCROLL
LTEXT "Name",IDC_STATIC,83,26,22,10
LTEXT "Comment",IDC_STATIC,6,45,37,10
EDITTEXT IDC_SYMBOLIC_COMMENT,45,43,194,13,ES_AUTOHSCROLL
EDITTEXT IDC_SYMBOLIC_FILENAME,24,6,215,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_SYMBOLIC_DEBUG_NAMING, DIALOG
BEGIN
BOTTOMMARGIN, 82
END
END
#endif // APSTUDIO_INVOKED
#endif // Russian (Russia) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources

View File

@ -365,6 +365,7 @@
#define IDB_BITMAP_SELECTED19 288
#define IDD_TASEDITOR_SAVINGOPTIONS 289
#define IDD_SYMBOLIC_DEBUG_NAMING 290
#define DLG_SNESPAD 291
#define MENU_HIDE_MENU 300
#define COMBO_FILTER 300
#define IDC_EDIT_AUTHORINFO 300
@ -1235,7 +1236,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 291
#define _APS_NEXT_RESOURCE_VALUE 292
#define _APS_NEXT_COMMAND_VALUE 40596
#define _APS_NEXT_CONTROL_VALUE 1303
#define _APS_NEXT_SYMED_VALUE 101

View File

@ -36,8 +36,9 @@ enum ESI
SI_POWERPADB = 4,
SI_ARKANOID = 5,
SI_MOUSE = 6,
SI_SNES = 7,
SI_COUNT = SI_MOUSE
SI_COUNT = SI_SNES
};
inline const char* ESI_Name(ESI esi)
@ -50,7 +51,8 @@ inline const char* ESI_Name(ESI esi)
"Power Pad A",
"Power Pad B",
"Arkanoid Paddle",
"Mouse"
"Mouse",
"SNES Pad"
};
if(esi >= SI_NONE && esi <= SI_COUNT)

View File

@ -88,6 +88,7 @@ extern bool movieSubtitles;
static uint8 joy_readbit[2];
uint8 joy[4]={0,0,0,0}; //HACK - should be static but movie needs it
uint16 snesjoy[4]={0,0,0,0}; //HACK - should be static but movie needs it
static uint8 LastStrobe;
uint8 RawReg4016 = 0; // Joystick strobe (W)
@ -314,9 +315,64 @@ static void StrobeGP(int w)
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//SNES pad
static void UpdateSNES(int w, void *data, int arg)
{
//LUA NOT SUPPORTED YET
if(w==0)
{
snesjoy[0]= ((uint32 *)joyports[0].ptr)[0];
snesjoy[2]= ((uint32 *)joyports[0].ptr)[2];
}
else
{
snesjoy[1] = ((uint32 *)joyports[0].ptr)[1];
snesjoy[3] = ((uint32 *)joyports[0].ptr)[3];
}
}
static void LogSNES(int w, MovieRecord* mr)
{
//not supported for SNES pad right noe
}
static void LoadSNES(int w, MovieRecord* mr)
{
//not supported for SNES pad right now
}
static uint8 ReadSNES(int w)
{
//no fourscore support on snes (not clear how it would work)
uint8 ret;
if(joy_readbit[w]>=16)
ret = 1;
else
{
ret = ((snesjoy[w]>>(joy_readbit[w]))&1);
}
if(!fceuindbg)
joy_readbit[w]++;
return ret;
}
static void StrobeSNES(int w)
{
joy_readbit[w]=0;
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
static INPUTC GPC={ReadGP,0,StrobeGP,UpdateGP,0,0,LogGP,LoadGP};
static INPUTC GPCVS={ReadGPVS,0,StrobeGP,UpdateGP,0,0,LogGP,LoadGP};
static INPUTC GPSNES={ReadSNES,0,StrobeSNES,UpdateSNES,0,0,LogSNES,LoadSNES};
void FCEU_DrawInput(uint8 *buf)
{
@ -399,6 +455,9 @@ static void SetInputStuff(int port)
joyports[port].driver= &GPC;
}
break;
case SI_SNES:
joyports[port].driver= &GPSNES;
break;
case SI_ARKANOID:
joyports[port].driver=FCEU_InitArkanoid(port);
break;