static void Main() { ntrClient = new NtrClient(); loadConfig(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); gCmdWindow = new CmdWindow(); Application.Run(gCmdWindow); }
private static void Main() { pyEngine = Python.CreateEngine(); ntrClient = new NtrClient(); scriptHelper = new ScriptHelper(); globalScope = pyEngine.CreateScope(); globalScope.SetVariable("nc", scriptHelper); loadConfig(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); gCmdWindow = new CmdWindow(); Application.Run(gCmdWindow); }
/* * * [TEST] * D3000000 10000000 * C0000000 00000003 * DF000000 00000000 * D1000000 00000001 * D3000000 00000000 * * */ public void execute() { int index = 0; int dummy_count = 0; Boolean gs_if = false; Boolean valid = true; Int32 gs_if_layer = 0; Int32 gs_if_sLayer = 0; do { gateshark_ar gs_ar = lines[index]; int cmd = gs_ar.getCMD(); if (gs_if_layer == 0 && valid) { if ((cmd == 0) || (cmd == 1) || (cmd == 2)) { valid = gs_ar.execute(offset); } // Conditional codes else if (cmd == 0x3) { UInt32 read = Convert.ToUInt32(CmdWindow.fromLE(Program.gCmdWindow.readValue(gs_ar.getBlock_A() + offset, 4), 0)); gs_if = !(read < gs_ar.getBlock_B()); } else if (cmd == 0x4) { UInt32 read = Convert.ToUInt32(CmdWindow.fromLE(Program.gCmdWindow.readValue(gs_ar.getBlock_A() + offset, 4), 0)); gs_if = !(read > gs_ar.getBlock_B()); } else if (cmd == 0x5) { UInt32 read = Convert.ToUInt32(CmdWindow.fromLE(Program.gCmdWindow.readValue(gs_ar.getBlock_A() + offset, 4), 0)); gs_if = !(read == gs_ar.getBlock_B()); } else if (cmd == 0x6) { UInt32 read = Convert.ToUInt32(CmdWindow.fromLE(Program.gCmdWindow.readValue(gs_ar.getBlock_A() + offset, 4), 0)); gs_if = !(read != gs_ar.getBlock_B()); } else if (cmd == 0x7) { UInt32 read = Convert.ToUInt32(CmdWindow.fromLE(Program.gCmdWindow.readValue(gs_ar.getBlock_A() + offset, 2), 2)); gs_if = !(read < gs_ar.getBlock_B()); } else if (cmd == 0x8) { UInt32 read = Convert.ToUInt32(CmdWindow.fromLE(Program.gCmdWindow.readValue(gs_ar.getBlock_A() + offset, 2), 2)); gs_if = !(read > gs_ar.getBlock_B()); } else if (cmd == 0x9) { UInt32 read = Convert.ToUInt32(CmdWindow.fromLE(Program.gCmdWindow.readValue(gs_ar.getBlock_A() + offset, 2), 2)); gs_if = !(read == gs_ar.getBlock_B()); } else if (cmd == 0xA) { UInt32 read = Convert.ToUInt32(CmdWindow.fromLE(Program.gCmdWindow.readValue(gs_ar.getBlock_A() + offset, 2), 2)); gs_if = !(read != gs_ar.getBlock_B()); } else if (cmd == 0xB) { offset = CmdWindow.fromLE(Program.gCmdWindow.readValue(gs_ar.getBlock_A() + offset, 4), 4); //MessageBox.Show(String.Format("SET > O: {0:X}", offset)); } else if (cmd == 0xC) { loop = true; loop_index = index; loop_count = gs_ar.getBlock_B() + 1; } else if (cmd == 0xD1) { //Task.Delay(100); if (loop) { loop_count--; if (loop_count == 0) { loop = false; //MessageBox.Show("Stopped the loop"); } else { index = loop_index; offset += Convert.ToInt32(gs_ar.getBlock_B()); //MessageBox.Show("Continuing loop"); } } } else if (cmd == 0xD2) // RESET { loop = false; loop_count = 0; loop_index = 0; offset = 0; gs_if_layer = 0; gs_if_sLayer = 0; } else if (cmd == 0xD3) // Read offset { // Fix for Issue #8 UInt32 b = gs_ar.getBlock_B(); Int32 b_ = 0; if (b > Int32.MaxValue) { // Offset in negative. Int32 r = Convert.ToInt32(b % 0x80000000); b_ = Convert.ToInt32(Int32.MinValue + r); } else { b_ = Convert.ToInt32(b); } offset = b_; } else if (cmd == 0xD4) { // Fix for Issue #8 UInt32 b = gs_ar.getBlock_B(); Int32 b_ = 0; if (b > Int32.MaxValue) { // Offset in negative. Int32 r = Convert.ToInt32(b % 0x80000000); b_ = Convert.ToInt32(Int32.MinValue + r); } else { b_ = Convert.ToInt32(b); } dxData += b_; } else if (cmd == 0xD5) // DxData WRITE { dxData = Convert.ToInt32(gs_ar.getBlock_B()); } else if (cmd == 0xD6) // DxData WORD { int addr = Convert.ToInt32(gs_ar.getBlock_B()) + offset; dxData = CmdWindow.fromLE(Program.gCmdWindow.readValue(addr, 4), 4); } else if (cmd == 0xD7) // DxData SHORT { int addr = Convert.ToInt32(gs_ar.getBlock_B()) + offset; dxData = CmdWindow.fromLE(Program.gCmdWindow.readValue(addr, 2), 2); } else if (cmd == 0xD8) // DxData Byte { int addr = Convert.ToInt32(gs_ar.getBlock_B()) + offset; dxData = Program.gCmdWindow.readValue(addr, 1); } else if (cmd == 0xD9) // DxData READ WORD { int len = 4; String cmd_string = Program.gCmdWindow.generateWriteString(Convert.ToInt32(gs_ar.getBlock_B()) + offset, dxData, len); Program.gCmdWindow.runCmd(cmd_string); offset += len; } else if (cmd == 0xDA) // DxData READ SHORT { int len = 2; String cmd_string = Program.gCmdWindow.generateWriteString(Convert.ToInt32(gs_ar.getBlock_B()) + offset, dxData, len); Program.gCmdWindow.runCmd(cmd_string); offset += len; } else if (cmd == 0xDB) // DxData READ BYTE { int len = 1; String cmd_string = Program.gCmdWindow.generateWriteString(Convert.ToInt32(gs_ar.getBlock_B()) + offset, dxData, len); Program.gCmdWindow.runCmd(cmd_string); offset += len; } else if (cmd == 0xDC) { // Fix for Issue #8 UInt32 b = gs_ar.getBlock_B(); Int32 b_ = 0; if (b > Int32.MaxValue) { // Offset in negative. Int32 r = Convert.ToInt32(b % 0x80000000); b_ = Convert.ToInt32(Int32.MinValue + r); } else { b_ = Convert.ToInt32(b); } offset += b_; } else if (cmd == 0xDF) { // This doesn't actually exist! It's for testing only! dummy_count++; MessageBox.Show(String.Format( "I: {0} \r\n" + "O: {1:X} \r\n" + "LOOP: {2} {3} {4} \r\n" + "DX: {5:X} \r\n" + "DUMMY: {6}\r\n" + "LAYERS: {7} {8}" , index, offset, loop, loop_index, loop_count, dxData, dummy_count, gs_if_sLayer, gs_if_layer)); } if (gs_if) { gs_if = false; gs_if_layer += 1; } } else if (cmd >= 0x3 && cmd <= 0xA) { gs_if_sLayer += 1; } else if (cmd == 0xD0) { if (gs_if_sLayer > 0) { gs_if_sLayer -= 1; } else if (gs_if_layer > 0) { gs_if_layer -= 1; } } index++; } while (index < lines.Count); }