Skip to content

Commit

Permalink
pfbn: fix default dip switch values (fix red hearth, some megadrive g…
Browse files Browse the repository at this point in the history
…ames, ...)
  • Loading branch information
Cpasjuste committed Jun 9, 2022
1 parent 1bba5e0 commit 9522b70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions pfbneo/sources/fbneo/drv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ int DrvInit(int nDrvNum, bool bRestore) {
return 0;
}

// for uiStateMenu.cpp (BurnStateLoad)
int DrvInitCallback() {
return DrvInit((int) nBurnDrvSelect[0], false);
}
Expand Down
19 changes: 12 additions & 7 deletions pfbneo/sources/fbneo/retro_input_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ int16_t input_cb(unsigned port, unsigned device, unsigned index, unsigned id) {

void poll_cb() {}

static void InpDIPSWGetOffset(void) {
BurnDIPInfo bdi;
static void InpDIPSWGetOffset() {
BurnDIPInfo bdi{};
nDIPOffset = 0;

for (int i = 0; BurnDrvGetDIPInfo(&bdi, i) == 0; i++) {
Expand All @@ -45,18 +45,23 @@ static void InpDIPSWGetOffset(void) {
}
}

void InpDIPSWResetDIPs(void) {
void InpDIPSWResetDIPs() {
int i = 0;
BurnDIPInfo bdi;
struct GameInp *pgi = NULL;
BurnDIPInfo bdi{};
struct GameInp *pgi;

InpDIPSWGetOffset();

while (BurnDrvGetDIPInfo(&bdi, i) == 0) {
if (bdi.nFlags == 0xFF) {
pgi = GameInp + bdi.nInput + nDIPOffset;
if (pgi)
pgi->Input.Constant.nConst = (pgi->Input.Constant.nConst & ~bdi.nMask) | (bdi.nSetting & bdi.nMask);
if (pgi) {
pgi->Input.Constant.nConst = pgi->Input.nVal =
(pgi->Input.Constant.nConst & ~bdi.nMask) | (bdi.nSetting & bdi.nMask);
if (pgi->Input.pVal) {
*(pgi->Input.pVal) = pgi->Input.nVal;
}
}
}
i++;
}
Expand Down

0 comments on commit 9522b70

Please sign in to comment.