snes: add a toggle multitap button

This commit is contained in:
nattthebear 2017-04-22 17:07:33 -04:00
parent ba3000db89
commit 5bebd0685a
6 changed files with 23 additions and 4 deletions

View File

@ -219,6 +219,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
.SelectMany(i => Buttons
.OrderBy(ButtonOrder)
.Select(b => i + b))
.Concat(new[] { "0Toggle Multitap" })
.ToList()
};
@ -226,6 +227,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public short GetState(IController controller, int index, int id)
{
if (id == 16)
{
return (short)(controller.IsPressed("0Toggle Multitap") ? 1 : 0);
}
if (id >= 12)
{
return 0;

View File

@ -177,8 +177,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
var bw = new BinaryWriter(ms);
bw.Write(CoreSaveState());
bw.Write(true); // framezero, so no controller follows and don't frameadvance on load
// hack: write fake dummy controller info
bw.Write(new byte[536]);
bw.Close();
_savestatebuff = ms.ToArray();
}

View File

@ -1,8 +1,10 @@
#ifdef CONTROLLER_CPP
uint2 Multitap::data() {
if(latched) return 2; //multitap detection
unsigned index, port1, port2;
if (latched)
return connected ? 2 : 0;
unsigned index, port1, port2;
if(iobit()) {
index = counter1;
@ -25,6 +27,12 @@ uint2 Multitap::data() {
void Multitap::latch(bool data) {
if(latched == data) return;
bool newtoggleConnectedInput = interface()->inputPoll(port, Input::Device::Multitap, 0, 16);
if (newtoggleConnectedInput > toggleConnectedInput)
connected ^= true;
toggleConnectedInput = newtoggleConnectedInput;
latched = data;
counter1 = 0;
counter2 = 0;
@ -37,11 +45,15 @@ void Multitap::serialize(serializer& s) {
block[0] = latched ? 1 : 0;
block[1] = counter1;
block[2] = counter2;
block[3] = connected;
block[4] = toggleConnectedInput;
s.array(block, Controller::SaveSize);
if(s.mode() == nall::serializer::Load) {
latched = (block[0] != 0);
counter1 = block[1];
counter2 = block[2];
connected = block[3];
toggleConnectedInput = block[4];
}
}
@ -50,6 +62,8 @@ Multitap::Multitap(bool port) : Controller(port) {
latched = 0;
counter1 = 0;
counter2 = 0;
connected = true;
toggleConnectedInput = false;
}
#endif

View File

@ -4,6 +4,8 @@ struct Multitap : Controller {
Multitap(bool port);
void serialize(serializer& s);
private:
bool connected;
bool toggleConnectedInput;
bool latched;
unsigned counter1;
unsigned counter2;