Merge pull request #133 from JasonWThompson/Issue130

Add LCD Mod Compatible Zapper support
This commit is contained in:
CaH4e3 2020-10-08 21:52:55 +03:00 committed by GitHub
commit 679e59ab45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 3191 additions and 3071 deletions

View File

@ -371,6 +371,7 @@ set(SRC_CORE
${CMAKE_CURRENT_SOURCE_DIR}/input/suborkb.cpp
${CMAKE_CURRENT_SOURCE_DIR}/input/toprider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/input/virtualboy.cpp
${CMAKE_CURRENT_SOURCE_DIR}/input/lcdcompzapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/input/zapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils/backward.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils/ConvertUTF.c

View File

@ -436,6 +436,35 @@ static uint32 UpdateVirtualBoyData(int w)
return r;
}
// Holds the button configurations for the LCD Compatible Zapper.
// Two collections of two buttons.
// One for each controller port.
// The defaults shouldn't matter since this is intended to be configured by the user to match their custom hardware.
ButtConfig lcdcompzappersc[2][2] = {
{
MK(A), MK(B)
},
{
MK(A), MK(B)
}
};
// buffer to hold the state of the zapper.
static uint32 lcdcompzapperbuf[2];
// Determines if the zapper trigger is pressed and/or if it's sensing light based on the button config and return
// the result as a two bit value.
static uint32 UpdateLCDCompatibleZapperData(int w)
{
uint32 r = 0;
ButtConfig* lcdcompzappertsc = lcdcompzappersc[w];
int x;
for (x = 0; x < 2; x++)
if (DTestButton(&lcdcompzappertsc[x])) r |= 1 << x;
return r;
}
static uint8 fkbkeys[0x48];
static uint8 suborkbkeys[0x65];
@ -486,7 +515,10 @@ void FCEUD_UpdateInput()
case SI_VIRTUALBOY:
virtualboybuf[x]=UpdateVirtualBoyData(x);
break;
}
case SI_LCDCOMP_ZAPPER:
lcdcompzapperbuf[x] = UpdateLCDCompatibleZapperData(x);
break;
}
switch(InputType[2])
{
@ -582,6 +614,9 @@ void InitInputPorts(bool fourscore)
case SI_VIRTUALBOY:
InputDPtr=&virtualboybuf[i];
break;
case SI_LCDCOMP_ZAPPER:
InputDPtr = &lcdcompzapperbuf[i];
break;
}
FCEUI_SetInput(i,(ESI)InputType[i],InputDPtr,attrib);
}
@ -833,6 +868,7 @@ CFGSTRUCT InputConfig[]={
AC(fkbmap),
AC(suborkbmap),
AC(virtualboysc),
AC(lcdcompzappersc),
ENDCFGSTRUCT
};
@ -868,6 +904,10 @@ void InitInputStuff(void)
for(x=0; x<2; x++)
for(y=0; y<14; y++)
JoyClearBC(&virtualboysc[x][y]);
for (x = 0; x < 2; x++)
for (y = 0; y < 2; y++)
JoyClearBC(&lcdcompzappersc[x][y]);
}
static char *MakeButtString(ButtConfig *bc)
@ -1204,7 +1244,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, 0, 1 };
static const int configurable_nes[NUMBER_OF_NES_DEVICES]= { 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 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;
@ -1537,6 +1577,9 @@ INT_PTR CALLBACK InputConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
case SI_VIRTUALBOY:
DoTBConfig(hwndDlg, text, "VIRTUALBOYDIALOG", virtualboysc[which], 14);
break;
case SI_LCDCOMP_ZAPPER:
DoTBConfig(hwndDlg, text, "LCDCOMPZAPPERDIALOG", lcdcompzappersc[which], 2);
break;
}
}

BIN
src/drivers/win/res.aps Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,9 @@ enum ESI
SI_SNES = 7,
SI_SNES_MOUSE = 8,
SI_VIRTUALBOY = 9,
SI_LCDCOMP_ZAPPER = 10,
SI_COUNT = SI_VIRTUALBOY
SI_COUNT = SI_LCDCOMP_ZAPPER
};
inline const char* ESI_Name(ESI esi)
@ -56,7 +57,8 @@ inline const char* ESI_Name(ESI esi)
"Subor Mouse",
"SNES Pad",
"SNES Mouse",
"Virtual Boy"
"Virtual Boy",
"LCD Zapper (Advance)"
};
if(esi >= SI_NONE && esi <= SI_COUNT)

View File

@ -65,6 +65,7 @@ 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 INPUTC *FCEU_InitLCDCompZapper(int w);
extern INPUTCFC *FCEU_InitArkanoidFC(void);
extern INPUTCFC *FCEU_InitSpaceShadow(void);
@ -515,6 +516,9 @@ static void SetInputStuff(int port)
case SI_VIRTUALBOY:
joyports[port].driver=FCEU_InitVirtualBoy(port);
break;
case SI_LCDCOMP_ZAPPER:
joyports[port].driver = FCEU_InitLCDCompZapper(port);
break;
case SI_NONE:
case SI_UNSET:
joyports[port].driver=&DummyJPort;

View File

@ -0,0 +1,48 @@
/* 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 lcdCompZapperStrobe[2];
static uint32 lcdCompZapperData[2];
static uint8 ReadLCDCompZapper(int w)
{
return lcdCompZapperData[w];
}
static void StrobeLCDCompZapper(int w)
{
lcdCompZapperStrobe[w] = 0;
}
void UpdateLCDCompZapper(int w, void* data, int arg)
{
// In the '(*(uint32*)data)' variable, bit 0 holds the trigger value and bit 1 holds the light sense value.
// Ultimately this needs to be converted from 0000 00lt to 000t l000 where l is the light bit and t
// is the trigger bit.
lcdCompZapperData[w] = ((((*(uint32*)data) & 1) << 4) |
(((*(uint32*)data) & 2) << 2));
}
static INPUTC LCDCompZapperCtrl = { ReadLCDCompZapper,0,StrobeLCDCompZapper,UpdateLCDCompZapper,0,0 };
INPUTC* FCEU_InitLCDCompZapper(int w)
{
lcdCompZapperStrobe[w] = lcdCompZapperData[w] = 0;
return(&LCDCompZapperCtrl);
}

View File

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

View File

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