static void DoMove(UInt32 player, UInt32 move, ref UInt32 input) { UInt32 Offset = 0x00; if (player == 1) { Offset = 0x1DD265; } else if (player == 2) { Offset = 0x1DD27D; } switch (Project64Watch.Read16(Offset)) { case 0x0101: //Attack / Switch / Run { switch (move) { case 1: case 2: case 3: case 4: { Project64Watch.SetInput(ref input, "A"); } break; case 5: case 6: case 7: { Project64Watch.SetInput(ref input, "B"); } break; } } break; case 0x0505: //Pick Pokemon Forced case 0x0501: //Pick Pokemon { switch (move) { case 5: { Project64Watch.SetInput(ref input, "C Left"); } break; case 6: { Project64Watch.SetInput(ref input, "C Up"); } break; case 7: { Project64Watch.SetInput(ref input, "C Right"); } break; } } break; case 0x0201: //Pick Move { switch (move) { case 1: { Project64Watch.SetInput(ref input, "C Up"); } break; case 2: { Project64Watch.SetInput(ref input, "C Right"); } break; case 3: { Project64Watch.SetInput(ref input, "C Down"); } break; case 4: { Project64Watch.SetInput(ref input, "C Left"); } break; } } break; } }
static void Main(string[] args) { UInt32 input1; UInt32 input2; UInt32 cycle = 0; UInt32 player = 1; UInt32 move1 = 0; //0 undecided; 1-4 moves1-4; 5-7 pokemon1-3 UInt32 move2 = 0; for (int i = 0; i < args.Length; i += 2) { if (args[i] == "-ip") { Project64Watch.host = args[i + 1]; } if (args[i] == "-p") { Project64Watch.port = Convert.ToInt32(args[i + 1]); } } Project64Watch.Connect(); while (true) { input1 = 0; input2 = 0; switch (Project64Watch.Read8(0x90CC3)) { case 0x00: //Intro case 0x01: //Title { player = 1; move1 = 0; move2 = 0; Project64Watch.SetInput(ref input1, "A"); } break; case 0x02: //Menus { switch (Project64Watch.Read8(0x9031B)) { case 0x00: //Game Pak Check case 0x33: //Please Select { Project64Watch.SetInput(ref input1, "A"); } break; case 0x37: //Hub World { switch (Project64Watch.Read8(0xA9EF7)) { case 0xA7: //Stadium { Project64Watch.SetInput(ref input1, "DPad R"); } break; case 0xEE: //Pokémon Academy { Project64Watch.SetInput(ref input1, "DPad U"); } break; case 0xC5: //Free Battle { Project64Watch.SetInput(ref input1, "A"); } break; } } break; } } break; case 0x07: //Free Battle Setup { switch (Project64Watch.Read8(0xAA6F3)) { case 0x0C: //1P { Project64Watch.SetInput(ref input1, "A"); } break; case 0x7C: { switch (Project64Watch.Read8(0xAA6A7)) { case 0x76: //COM { Project64Watch.SetInput(ref input1, "DPad D"); } break; case 0x94: //2P { Project64Watch.SetInput(ref input1, "A"); } break; } } break; case 0xC5: //Free Battle { Project64Watch.SetInput(ref input1, "DPad U"); } break; case 0xAB: //Random { Project64Watch.SetInput(ref input1, "A"); } break; default: { switch (Project64Watch.Read8(0xAA8DB)) { case 0x00: //Choose Entry case 0x10: //Anything Goes { if (player == 1) { if (Project64Watch.Read8(0x146240) == 0x00) //No 1P Team { Project64Watch.SetInput(ref input1, "A"); } else { player = 2; } } else if (Project64Watch.Read8(0x146480) == 0x00) //No 2P Team { Project64Watch.SetInput(ref input2, "A"); } else { InjectTeams(); } } break; case 0x02: //OK { Project64Watch.SetInput(ref input1, "A"); Project64Watch.SetInput(ref input2, "A"); } break; case 0x26: //Team 2 { Project64Watch.SetInput(ref input2, "A"); } break; case 0x80: //Team 1 { if (player == 1) { Project64Watch.SetInput(ref input1, "A"); } else { Project64Watch.SetInput(ref input2, "DPad D"); } } break; } } break; } } break; case 0x08: //In Battle { ReadString(); if (Project64Watch.Read8(0x91B7C) == 0x01) //Waiting { if (move1 == 0x00) { PickMove(1, ref move1); } else { DoMove(1, move1, ref input1); } if (move2 == 0x00) { PickMove(2, ref move2); } else { DoMove(2, move2, ref input2); } } else { move1 = 0; move2 = 0; } } break; case 0x09: //Battle Setup { if (Project64Watch.Read8(0x147D30) == 0x31) //Names { EditNames(); } if (Project64Watch.Read8(0xAA8DB) == 0xE9) //Choose Pokemon { switch (Project64Watch.Read8(0xAA407)) { case 0x03: //Pick Pokemon case 0xD1: //Pick Pokemon { switch (cycle) { case 0x00: { Project64Watch.SetInput(ref input1, "B"); Project64Watch.SetInput(ref input2, "B"); cycle++; } break; case 0x01: { Project64Watch.SetInput(ref input1, "C Left"); Project64Watch.SetInput(ref input2, "C Left"); cycle++; } break; case 0x02: { Project64Watch.SetInput(ref input1, "C Up"); Project64Watch.SetInput(ref input2, "C Up"); cycle = 0; } break; } } break; case 0xB0: //Yes { Project64Watch.SetInput(ref input1, "A"); Project64Watch.SetInput(ref input2, "A"); } break; } } } break; case 0x0A: //Battle Result { Project64Watch.SetInput(ref input1, "A"); cycle = (uint)rand.Next(0, 2); if (Project64Watch.Read8(0x147D61) != 0x00) //1P Wins! { Console.WriteLine("\n1P Wins!\n"); Project64Watch.Write8(0x147D61, 0x00); InjectTeams(); } else if (Project64Watch.Read8(0x147D63) != 0x00) //2P Wins! { Console.WriteLine("\n2P Wins!\n"); Project64Watch.Write8(0x147D63, 0x00); InjectTeams(); } } break; } Project64Watch.SendInput(1, input1); Project64Watch.SendInput(2, input2); Thread.Sleep(250); } }