public void loadGame(string path, bool usr_fpga) { int resp; int offset = 0; bool sms = path.ToLower().EndsWith(".sms") || path.ToLower().EndsWith(".gg"); byte[] data = File.ReadAllBytes(path); if (data.Length > Edio.MAX_ROM_SIZE) { throw new Exception("ROM is too big"); } if (data.Length % 1024 == 512 && sms) { offset = 512; //skip sms header } int dst_addr = Edio.ADDR_ROM; if (path.ToLower().EndsWith(".nes")) { dst_addr += 0x10000; } edio.hostReset(Edio.HOST_RST_SOFT); edio.memWR(dst_addr, data, offset, data.Length - offset); edio.hostReset(Edio.HOST_RST_OFF); resp = edio.rx8(); if (resp != 'r') { throw new Exception("unexpected response: " + resp); } hostTest(); if (usr_fpga) { edio.fifoWR("*u"); //skip fpga reloading from sd } edio.fifoWR("*g"); edio.fifoTX32(data.Length - offset); edio.fifoTxString("USB:" + Path.GetFileName(path)); }