Merge pull request #180 from ClusterM/hori

Hori 4-Player Adapter support
This commit is contained in:
CaH4e3 2020-10-06 14:29:29 +03:00 committed by GitHub
commit 0120f63ed0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 2 deletions

View File

@ -85,8 +85,9 @@ enum ESIFC
SIFC_BWORLD = 13,
SIFC_TOPRIDER = 14,
SIFC_FAMINETSYS = 15,
SIFC_HORI4PLAYER = 16,
SIFC_COUNT = SIFC_FAMINETSYS
SIFC_COUNT = SIFC_HORI4PLAYER
};
@ -109,7 +110,8 @@ inline const char* ESIFC_Name(ESIFC esifc)
"Oeka Kids Tablet",
"Barcode World",
"Top Rider",
"Famicom Network Controller"
"Famicom Network Controller",
"Hori 4-Player Adapter"
};
if(esifc >= SIFC_NONE && esifc <= SIFC_COUNT)

View File

@ -372,7 +372,39 @@ static void StrobeSNES(int w)
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//--------Hori 4 player driver for expansion port--------
static uint8 Hori4ReadBit[2];
static void StrobeHori4(void)
{
Hori4ReadBit[0] = Hori4ReadBit[1] = 0;
}
static uint8 ReadHori4(int w, uint8 ret)
{
ret &= 1;
if (Hori4ReadBit[w] < 8)
{
ret |= ((joy[w] >> (Hori4ReadBit[w])) & 1) << 1;
}
else if (Hori4ReadBit[w] < 16)
{
ret |= ((joy[2 + w] >> (Hori4ReadBit[w] - 8)) & 1) << 1;
}
else if (Hori4ReadBit[w] < 24)
{
ret |= (((w ? 0x10 : 0x20) >> (7 - (Hori4ReadBit[w] - 16))) & 1) << 1;
}
if (Hori4ReadBit[w] >= 24) ret |= 2;
else Hori4ReadBit[w]++;
return(ret);
}
static INPUTCFC HORI4C = { ReadHori4,0,StrobeHori4,0,0,0 };
//------------------
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
static INPUTC GPC={ReadGP,0,StrobeGP,UpdateGP,0,0,LogGP,LoadGP};
static INPUTC GPCVS={ReadGPVS,0,StrobeGP,UpdateGP,0,0,LogGP,LoadGP};
@ -544,6 +576,10 @@ static void SetInputStuffFC()
case SIFC_FAMINETSYS:
portFC.driver = FCEU_InitFamiNetSys();
break;
case SIFC_HORI4PLAYER:
portFC.driver = &HORI4C;
memset(&Hori4ReadBit, 0, sizeof(Hori4ReadBit));
break;
}
}