@@ -10,6 +10,8 @@ public final class PatchFactory {
1010
1111 private static final Pattern GAME_GENIE_CODE = Pattern .compile ("^([0-9A-Fa-f]{3})[+-]([0-9A-Fa-f]{3})[+-]([0-9A-Fa-f]{3})$" );
1212
13+ private static final Pattern GAME_GENIE_SHORT_CODE = Pattern .compile ("^([0-9A-Fa-f]{3})[+-]([0-9A-Fa-f]{3})$" );
14+
1315 private static final Pattern GAME_SHARK_CODE = Pattern .compile ("^([0-9A-Fa-f]{8})$" );
1416
1517 private PatchFactory () {
@@ -26,6 +28,8 @@ public static List<Patch> createPatches(String code) {
2628 static Patch createPatch (String code ) {
2729 if (GAME_GENIE_CODE .matcher (code ).matches ()) {
2830 return parseGameGenieCode (code );
31+ } else if (GAME_GENIE_SHORT_CODE .matcher (code ).matches ()) {
32+ return parseGameGenieShortCode (code );
2933 } else if (GAME_SHARK_CODE .matcher (code ).matches ()) {
3034 return parseGameSharkCode (code );
3135 } else {
@@ -41,6 +45,13 @@ private static GameGeniePatch parseGameGenieCode(String code) {
4145 return new GameGeniePatch (newData , address , oldData );
4246 }
4347
48+ private static GameGeniePatch parseGameGenieShortCode (String code ) {
49+ var c = code .toLowerCase ().replace ("-" , "" ).toCharArray ();
50+ var newData = parse (c , 0 , 1 );
51+ var address = parse (c , 5 , 2 , 3 , 4 ) ^ 0xf000 ;
52+ return new GameGeniePatch (newData , address , -1 );
53+ }
54+
4455 private static GameSharkPatch parseGameSharkCode (String code ) {
4556 var c = code .toLowerCase ().toCharArray ();
4657 var bank = parse (c , 0 , 1 );
0 commit comments