Skip to content

Commit

Permalink
Better Patch Hook
Browse files Browse the repository at this point in the history
Patches now run guaranteed on NES emulation exit
  • Loading branch information
Cuyler36 committed Jul 8, 2018
1 parent df1a0d9 commit 8efd1c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ACNESCreator.Core/NES.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ internal void GenerateDefaultTagData(string GameName, bool NESImage)
if (GameName.Length > 1)
{
GameName = GameName.Trim().ToUpper();
List<KeyValuePair<string, byte[]>> Tags = new List <KeyValuePair<string, byte[]>>
List<KeyValuePair<string, byte[]>> Tags = new List<KeyValuePair<string, byte[]>>
{
new KeyValuePair<string, byte[]>("GID", Encoding.ASCII.GetBytes(GameName.Substring(0, 1) + GameName.Substring(GameName.Length - 1, 1))),
new KeyValuePair<string, byte[]>("GNM", Encoding.ASCII.GetBytes(GameName)),
Expand All @@ -209,7 +209,7 @@ internal void GenerateDefaultTagData(string GameName, bool NESImage)
if (!NESImage)
{
AddPatchData(ref Tags, 0x80003970, Patch.PatcherData);
AddPatchData(ref Tags, 0x800451C8, Patch.PatcherEntryPointData);
AddPatchData(ref Tags, 0x806D4B9C, Patch.PatcherEntryPointData);
}

Tags.Add(new KeyValuePair<string, byte[]>("END", new byte[0]));
Expand Down
22 changes: 13 additions & 9 deletions ACNESCreator.Core/Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ public static class Patch
{
public static readonly byte[] PatcherData = new byte[]
{
0x94, 0x21, 0xFF, 0xE0, 0x90, 0x61, 0x00, 0x1C, 0x90, 0x81, 0x00, 0x18, 0x90, 0xA1, 0x00, 0x14,
0x90, 0xC1, 0x00, 0x10, 0x90, 0xE1, 0x00, 0x0C, 0x91, 0x01, 0x00, 0x08, 0x3C, 0x60, 0x80, 0x1F,
0x38, 0x63, 0x6C, 0x64, 0x80, 0x63, 0x00, 0x00, 0x28, 0x03, 0x00, 0x00, 0x41, 0x82, 0x00, 0x40,
0x80, 0x83, 0x00, 0x00, 0x28, 0x04, 0x00, 0x00, 0x41, 0x82, 0x00, 0x34, 0x7C, 0x88, 0x23, 0x78,
0x80, 0xC3, 0x00, 0x04, 0x80, 0xE3, 0x00, 0x08, 0x38, 0xA3, 0x00, 0x0C, 0x2C, 0x06, 0x00, 0x00,
0x94, 0x21, 0xFF, 0xD4, 0x7C, 0x08, 0x02, 0xA6, 0x90, 0x01, 0x00, 0x20, 0x90, 0x61, 0x00, 0x1C,
0x90, 0x81, 0x00, 0x18, 0x90, 0xA1, 0x00, 0x14, 0x90, 0xC1, 0x00, 0x10, 0x90, 0xE1, 0x00, 0x0C,
0x91, 0x01, 0x00, 0x08, 0x3C, 0x60, 0x80, 0x1F, 0x38, 0x63, 0x6C, 0x64, 0x80, 0x63, 0x00, 0x00,
0x28, 0x03, 0x00, 0x00, 0x41, 0x82, 0x00, 0x48, 0x80, 0x83, 0x00, 0x00, 0x28, 0x04, 0x00, 0x00,
0x41, 0x82, 0x00, 0x3C, 0x7C, 0x88, 0x23, 0x78, 0x80, 0xC3, 0x00, 0x04, 0x80, 0xE3, 0x00, 0x08,
0x90, 0xE1, 0x00, 0x24, 0x91, 0x01, 0x00, 0x28, 0x38, 0xA3, 0x00, 0x0C, 0x2C, 0x06, 0x00, 0x00,
0x40, 0x81, 0x00, 0x1C, 0x88, 0x65, 0x00, 0x00, 0x98, 0x64, 0x00, 0x00, 0x38, 0x84, 0x00, 0x01,
0x38, 0xA5, 0x00, 0x01, 0x38, 0xC6, 0xFF, 0xFF, 0x4B, 0xFF, 0xFF, 0xE4, 0x28, 0x07, 0x00, 0x00,
0x41, 0x82, 0x00, 0x0C, 0x7C, 0x08, 0x02, 0xA6, 0x7D, 0x08, 0x03, 0xA6, 0x80, 0x61, 0x00, 0x1C,
0x38, 0xA5, 0x00, 0x01, 0x38, 0xC6, 0xFF, 0xFF, 0x4B, 0xFF, 0xFF, 0xE4, 0x80, 0x61, 0x00, 0x1C,
0x3C, 0xA0, 0x80, 0x62, 0x60, 0xA5, 0xD4, 0xCC, 0x3C, 0xC0, 0x80, 0x6D, 0x60, 0xC6, 0x4B, 0x9C,
0x90, 0xA6, 0x00, 0x00, 0x7C, 0xA9, 0x03, 0xA6, 0x4E, 0x80, 0x04, 0x21, 0x80, 0xE1, 0x00, 0x24,
0x28, 0x07, 0x00, 0x00, 0x41, 0x82, 0x00, 0x14, 0x81, 0x01, 0x00, 0x28, 0x80, 0x01, 0x00, 0x20,
0x7D, 0x08, 0x03, 0xA6, 0x48, 0x00, 0x00, 0x0C, 0x80, 0x01, 0x00, 0x20, 0x7C, 0x08, 0x03, 0xA6,
0x80, 0x81, 0x00, 0x18, 0x80, 0xA1, 0x00, 0x14, 0x80, 0xC1, 0x00, 0x10, 0x80, 0xE1, 0x00, 0x0C,
0x81, 0x01, 0x00, 0x08, 0x38, 0x21, 0x00, 0x20, 0x3C, 0xC0, 0x00, 0x08, 0x4E, 0x80, 0x00, 0x20
0x81, 0x01, 0x00, 0x08, 0x38, 0x21, 0x00, 0x2C, 0x4E, 0x80, 0x00, 0x20
};

public static readonly byte[] PatcherEntryPointData = new byte[]
{
0x4B, 0xFB, 0xE7, 0xA9
0x80, 0x00, 0x39, 0x70
};

public static readonly byte[] MemcardLoadSizePatchData = new byte[]
Expand Down

0 comments on commit 8efd1c2

Please sign in to comment.