addded -instantcc and -nocc options

This commit is contained in:
FIX94 2017-10-03 09:09:23 +02:00
parent 2b837e92a1
commit 5c5724abb6
No known key found for this signature in database
GPG Key ID: CE39016A19D8EADA

View File

@ -23,6 +23,8 @@ namespace nfs2iso2nfs
public static bool map_shoulder_to_trigger = false; public static bool map_shoulder_to_trigger = false;
public static bool homebrew = false; public static bool homebrew = false;
public static bool passthrough = false; public static bool passthrough = false;
public static bool instantcc = false;
public static bool nocc = false;
public static string keyFile = "..\\code\\htk.bin"; public static string keyFile = "..\\code\\htk.bin";
public static string isoFile = "game.iso"; public static string isoFile = "game.iso";
public static string wiiKeyFile = "wii_common_key.bin"; public static string wiiKeyFile = "wii_common_key.bin";
@ -132,9 +134,15 @@ namespace nfs2iso2nfs
case "-passthrough": case "-passthrough":
passthrough = true; passthrough = true;
break; break;
case "-instantcc":
instantcc = true;
break;
case "-nocc":
nocc = true;
break;
case "-help": case "-help":
Console.WriteLine("+++++ NFS2ISO2NFS v0.5.4 +++++"); Console.WriteLine("+++++ NFS2ISO2NFS v0.5.5 +++++");
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("-dec Decrypt .nfs files to an .iso file."); Console.WriteLine("-dec Decrypt .nfs files to an .iso file.");
Console.WriteLine("-enc Encrypt an .iso file to .nfs file(s)"); Console.WriteLine("-enc Encrypt an .iso file to .nfs file(s)");
@ -150,6 +158,8 @@ namespace nfs2iso2nfs
Console.WriteLine("-vertical Remap Wii Remote d-pad for vertical usage (implies -wiimote)"); Console.WriteLine("-vertical Remap Wii Remote d-pad for vertical usage (implies -wiimote)");
Console.WriteLine("-homebrew Various patches to enable proper homebrew functionality"); Console.WriteLine("-homebrew Various patches to enable proper homebrew functionality");
Console.WriteLine("-passthrough Allow homebrew to keep using normal wiimotes with gamepad enabled"); Console.WriteLine("-passthrough Allow homebrew to keep using normal wiimotes with gamepad enabled");
Console.WriteLine("-instantcc Report emulated Classic Controller at the very first check");
Console.WriteLine("-nocc Report that no Classic Controller is connected");
Console.WriteLine("-help Print this text."); Console.WriteLine("-help Print this text.");
return -1; return -1;
default: default:
@ -1251,6 +1261,66 @@ namespace nfs2iso2nfs
Console.WriteLine(); Console.WriteLine();
} }
//for titles that dont immediately detect CC
if (instantcc)
{
Array.Clear(buffer_8, 0, 8);
int patchCount = 0;
byte[] pattern = { 0x78, 0x93, 0x21, 0x10, 0x2B, 0x02, 0xD1, 0xB7 };
byte[] patch = { 0x78, 0x93, 0x21, 0x10, 0x2B, 0x02, 0x46, 0xC0 };
for (int offset = 0; offset < input_ios.Length - 8; offset++)
{
input_ios.Position = offset; // set position to advance byte by byte
input_ios.Read(buffer_8, 0, 8); // because we read 8 bytes at once
if (ByteArrayCompare(buffer_8, pattern)) // see if it matches
{
input_ios.Seek(offset, SeekOrigin.Begin); // seek
input_ios.Write(patch, 0, 8);
patchCount++;
}
}
if (patchCount == 0)
Console.WriteLine("Instant Classic Controller report patching: Nothing to patch.");
else
Console.WriteLine("Instant Classic Controller report patched... (Patches applied: {0})", patchCount);
Console.WriteLine();
}
//for titles that dont want CC connected
if (nocc)
{
Array.Clear(buffer_8, 0, 8);
int patchCount = 0;
byte[] pattern = { 0x78, 0x93, 0x21, 0x10, 0x2B, 0x02, 0xD1, 0xB7 };
byte[] patch = { 0x78, 0x93, 0x21, 0x10, 0x2B, 0x02, 0xE0, 0xB7 };
for (int offset = 0; offset < input_ios.Length - 8; offset++)
{
input_ios.Position = offset; // set position to advance byte by byte
input_ios.Read(buffer_8, 0, 8); // because we read 8 bytes at once
if (ByteArrayCompare(buffer_8, pattern)) // see if it matches
{
input_ios.Seek(offset, SeekOrigin.Begin); // seek
input_ios.Write(patch, 0, 8);
patchCount++;
}
}
if (patchCount == 0)
Console.WriteLine("No Classic Controller report patching: Nothing to patch.");
else
Console.WriteLine("No Classic Controller report patched... (Patches applied: {0})", patchCount);
Console.WriteLine();
}
// write to disk // write to disk
//FileStream patched_file = File.OpenWrite("newfw.img"); // for testing //FileStream patched_file = File.OpenWrite("newfw.img"); // for testing
FileStream patched_file = File.OpenWrite(fw_file); // open file FileStream patched_file = File.OpenWrite(fw_file); // open file