Skip to content

Commit

Permalink
Added Sonic Mania support
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtleMan64 authored Jul 22, 2018
1 parent b9650d4 commit adab694
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion SonicInputDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public static void Main()
case 1: setValuesFromSADX(); break;

case 2: setValuesFromHeroes(); break;

case 3: setValuesFromMania(); break;

default: attatchToGame(); break;
}
Expand Down Expand Up @@ -159,6 +161,26 @@ private static void setValuesFromHeroes()
theDisplay.setControllerDataHeroes(buttons, joyX, joyY, cameraPan);
}

private static void setValuesFromMania()
{
int bytesRead = 0;
byte[] buffer = new byte[2];
if (ReadProcessMemory((int)processHandle, 0x0083251D, buffer, 2, ref bytesRead) == false || bytesRead != 2)
{
theDisplay.setControllerDataMania(0, 0);
gameID = -1;
return;
}

int buttons = 0;
buttons+=buffer[0];

int stick = 0;
stick+=buffer[1];

theDisplay.setControllerDataMania(buttons, stick);
}

private static void attatchToGame()
{
theDisplay.Text = "Searching for game...";
Expand Down Expand Up @@ -194,7 +216,15 @@ private static void attatchToGame()
}
catch
{
gameID = -1;
try
{
process = Process.GetProcessesByName("SonicMania")[0];
gameID = 3;
}
catch
{
gameID = -1;
}
}
}
}
Expand All @@ -221,6 +251,8 @@ private static void attatchToGame()
case 1: theDisplay.Text = "SADX Input"; break;

case 2: theDisplay.Text = "Heroes Input"; break;

case 3: theDisplay.Text = "Mania Input"; break;

default: break;
}
Expand Down

0 comments on commit adab694

Please sign in to comment.