From b22753762fbbbbb93559e83b2692a31082519d06 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 7 Feb 2020 06:50:10 -0500 Subject: [PATCH] Virtual Boy controller support --- src/drivers/win/input.cpp | 47 ++++++++++++++++++++++++++++- src/drivers/win/res.rc | 27 +++++++++++++++++ src/git.h | 6 ++-- src/input.cpp | 4 +++ src/input/virtualboy.cpp | 57 +++++++++++++++++++++++++++++++++++ vc/vc14_fceux.vcxproj | 1 + vc/vc14_fceux.vcxproj.filters | 3 ++ 7 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 src/input/virtualboy.cpp diff --git a/src/drivers/win/input.cpp b/src/drivers/win/input.cpp index 0eb9e32f..edded8ea 100644 --- a/src/drivers/win/input.cpp +++ b/src/drivers/win/input.cpp @@ -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<= SI_NONE && esi <= SI_COUNT) diff --git a/src/input.cpp b/src/input.cpp index ff2f6d76..f44c7ef6 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -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; diff --git a/src/input/virtualboy.cpp b/src/input/virtualboy.cpp new file mode 100644 index 00000000..a689309d --- /dev/null +++ b/src/input/virtualboy.cpp @@ -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)< + diff --git a/vc/vc14_fceux.vcxproj.filters b/vc/vc14_fceux.vcxproj.filters index 44320047..e8870620 100644 --- a/vc/vc14_fceux.vcxproj.filters +++ b/vc/vc14_fceux.vcxproj.filters @@ -1102,6 +1102,9 @@ boards + + input +