Virtual Boy controller support

This commit is contained in:
bbbradsmith 2020-02-07 06:50:10 -05:00 committed by Brad Smith
parent e48b208918
commit b22753762f
7 changed files with 142 additions and 3 deletions

View File

@ -398,6 +398,36 @@ static uint32 UpdatePPadData(int w)
}
ButtConfig virtualboysc[2][14]={
{
MK(K),MK(J),MK(E),MK(R),
MK(W),MK(S),MK(A),MK(D),
MK(L),MK(I),MK(Q),MK(O),
MK(Y),MK(U)
},
{
MK(K),MK(J),MK(E),MK(R),
MK(W),MK(S),MK(A),MK(D),
MK(L),MK(I),MK(Q),MK(O),
MK(Y),MK(U)
}
};
static uint32 virtualboybuf[2];
static uint32 UpdateVirtualBoyData(int w)
{
uint32 r=0;
ButtConfig *virtualboytsc=virtualboysc[w];
int x;
for(x=0;x<14;x++)
if(DTestButton(&virtualboytsc[x])) r|=1<<x;
return r;
}
static uint8 fkbkeys[0x48];
static uint8 suborkbkeys[0x65];
@ -444,6 +474,9 @@ void FCEUD_UpdateInput()
case SI_POWERPADB:
powerpadbuf[x]=UpdatePPadData(x);
break;
case SI_VIRTUALBOY:
virtualboybuf[x]=UpdateVirtualBoyData(x);
break;
}
switch(InputType[2])
@ -531,6 +564,9 @@ void InitInputPorts(bool fourscore)
case SI_SNES:
InputDPtr=snespad_return;
break;
case SI_VIRTUALBOY:
InputDPtr=&virtualboybuf[i];
break;
}
FCEUI_SetInput(i,(ESI)InputType[i],InputDPtr,attrib);
}
@ -781,6 +817,7 @@ CFGSTRUCT InputConfig[]={
AC(GamePadPreset3),
AC(fkbmap),
AC(suborkbmap),
AC(virtualboysc),
ENDCFGSTRUCT
};
@ -812,6 +849,10 @@ void InitInputStuff(void)
JoyClearBC(&MahjongButtons[x]);
for(x=0; x<4; x++)
JoyClearBC(&HyperShotButtons[x]);
for(x=0; x<2; x++)
for(y=0; y<14; y++)
JoyClearBC(&virtualboysc[x][y]);
}
static char *MakeButtString(ButtConfig *bc)
@ -1148,7 +1189,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, 0, 1 };
static const int configurable_nes[NUMBER_OF_NES_DEVICES]= { 0, 1, 0, 1, 1, 0, 0, 1, 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;
@ -1477,6 +1518,10 @@ INT_PTR CALLBACK InputConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
case SI_POWERPADB:
DoTBConfig(hwndDlg, text, "POWERPADDIALOG", powerpadsc[which], 12);
break;
case SI_VIRTUALBOY:
DoTBConfig(hwndDlg, text, "VIRTUALBOYDIALOG", virtualboysc[which], 14);
break;
}
}

View File

@ -1083,6 +1083,29 @@ BEGIN
PUSHBUTTON "12",311,91,59,16,12
END
VIRTUALBOYDIALOG DIALOGEX 4, 109, 243, 121
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Virtual Boy Configuration"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "Close",BTN_CLOSE,177,97,56,14
GROUPBOX "",GRP_GAMEPAD1,4,8,232,82,WS_GROUP
PUSHBUTTON "Up", 304, 40,36,30,12
PUSHBUTTON "Left", 306, 10,50,30,12
PUSHBUTTON "Right", 307, 70,50,30,12
PUSHBUTTON "Down", 305, 40,64,30,12
PUSHBUTTON "Select",302, 46,19,32,12
PUSHBUTTON "Start", 303, 82,19,32,12
PUSHBUTTON "Left", 301,140,50,30,12
PUSHBUTTON "Down", 300,170,64,30,12
PUSHBUTTON "Right", 308,200,50,30,12
PUSHBUTTON "Up", 309,170,36,30,12
PUSHBUTTON "L", 310, 10,19,32,12
PUSHBUTTON "R", 311,198,19,32,12
PUSHBUTTON "B", 312,126,19,32,12
PUSHBUTTON "A", 313,162,19,32,12
END
QUIZKINGDIALOG DIALOG 30, 123, 160, 74
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "quiz king"
@ -2435,6 +2458,10 @@ BEGIN
BEGIN
END
"VIRTUALBOYDIALOG", DIALOG
BEGIN
END
"QUIZKINGDIALOG", DIALOG
BEGIN
END

View File

@ -38,8 +38,9 @@ enum ESI
SI_MOUSE = 6,
SI_SNES = 7,
SI_SNES_MOUSE = 8,
SI_VIRTUALBOY = 9,
SI_COUNT = SI_SNES_MOUSE
SI_COUNT = SI_VIRTUALBOY
};
inline const char* ESI_Name(ESI esi)
@ -54,7 +55,8 @@ inline const char* ESI_Name(ESI esi)
"Arkanoid Paddle",
"Subor Mouse",
"SNES Pad",
"SNES Mouse"
"SNES Mouse",
"Virtual Boy"
};
if(esi >= SI_NONE && esi <= SI_COUNT)

View File

@ -64,6 +64,7 @@ extern INPUTC *FCEU_InitPowerpadB(int w);
extern INPUTC *FCEU_InitArkanoid(int w);
extern INPUTC *FCEU_InitMouse(int w);
extern INPUTC *FCEU_InitSNESMouse(int w);
extern INPUTC *FCEU_InitVirtualBoy(int w);
extern INPUTCFC *FCEU_InitArkanoidFC(void);
extern INPUTCFC *FCEU_InitSpaceShadow(void);
@ -479,6 +480,9 @@ static void SetInputStuff(int port)
case SI_SNES_MOUSE:
joyports[port].driver=FCEU_InitSNESMouse(port);
break;
case SI_VIRTUALBOY:
joyports[port].driver=FCEU_InitVirtualBoy(port);
break;
case SI_NONE:
joyports[port].driver=&DummyJPort;
break;

57
src/input/virtualboy.cpp Normal file
View File

@ -0,0 +1,57 @@
/* FCE Ultra - NES/Famicom Emulator
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "share.h"
static uint32 vbrsb[2];
static uint32 vbrdata[2];
static uint8 ReadVB(int w)
{
uint8 ret=0;
ret |= (vbrdata[w]>>vbrsb[w])&1;
if(vbrsb[w] >= 16)
{
ret|=0x1;
vbrsb[w] = 16;
}
if(!fceuindbg)
vbrsb[w]++;
return ret;
}
static void StrobeVB(int w)
{
vbrsb[w]=0;
}
void UpdateVB(int w, void *data, int arg)
{
vbrdata[w]=0;
for (int x=0;x<14;x++)
{
vbrdata[w]|=(((*(uint32 *)data)>>x)&1)<<x;
}
}
static INPUTC VirtualBoyCtrl={ReadVB,0,StrobeVB,UpdateVB,0,0};
INPUTC *FCEU_InitVirtualBoy(int w)
{
vbrsb[w]=vbrdata[w]=0;
return(&VirtualBoyCtrl);
}

View File

@ -702,6 +702,7 @@
<ClCompile Include="..\src\input\shadow.cpp" />
<ClCompile Include="..\src\input\suborkb.cpp" />
<ClCompile Include="..\src\input\toprider.cpp" />
<ClCompile Include="..\src\input\virtualboy.cpp" />
<ClCompile Include="..\src\input\zapper.cpp" />
<ClCompile Include="..\src\boards\emu2413.c" />
<ClCompile Include="..\src\utils\ConvertUTF.c" />

View File

@ -1102,6 +1102,9 @@
<ClCompile Include="..\src\boards\fns.cpp">
<Filter>boards</Filter>
</ClCompile>
<ClCompile Include="..\src\input\virtualboy.cpp">
<Filter>input</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\drivers\common\args.h">