public void loadGame(NesRom rom, string map_path) { int resp; byte[] id_bin = rom.getRomID(); byte[] prg = rom.PrgData; byte[] chr = rom.ChrData; cmd(cmd_sel_game); txString("USB:" + Path.GetFileName(rom.Name)); resp = edio.rx8();//system ready to receive id edio.fifoWR(id_bin, 0, id_bin.Length); resp = edio.rx8(); if (resp != 0) { throw new Exception("Game select error 0x: " + resp.ToString("X2")); } int map_idx = edio.rx16(); if (map_idx != rom.Mapper) { Console.WriteLine("map reloc: " + map_idx); } if (map_path == null) { map_path = getTestMapper(map_idx); } cmd(cmd_run_game); edio.rx8();//exec edio.memWR(rom.PrgAddr, prg, 0, prg.Length); edio.memWR(rom.ChrAddr, chr, 0, chr.Length); if (map_path == null) { mapLoadSDC(map_idx, null); } else { Console.WriteLine("ext mapper: " + map_path); edio.fpgInit(File.ReadAllBytes(map_path), null); } }
static void cmdProcessor(string [] args) { string rom_path = null; string map_path = null; for (int i = 0; i < args.Length; i++) { string s = args[i].ToLower().Trim(); if (s.Equals("-recovery")) { cmd_recovery(); } if (s.Equals("-appmode")) { cmd_exitServiceMode(); } if (s.Equals("-sermode")) { cmd_enterServiceMode(); } if (s.Equals("-diag")) { cmd_diagnosics(); } if (s.Equals("-mkdir")) { usb.makeDir(args[i + 1]); i += 1; continue; } if (s.Equals("-rtcset")) { edio.rtcSet(DateTime.Now); continue; } if (s.Equals("-cp")) { usb.copyFile(args[i + 1], args[i + 2]); i += 2; continue; } if (s.Equals("-flawr")) { cmd_flashWrite(args[i + 1], args[i + 2]); i += 2; continue; } if (s.EndsWith(".nes") || s.EndsWith(".fds")) { rom_path = args[i]; continue; } if (s.EndsWith(".rbf")) { map_path = args[i]; continue; } if (s.StartsWith("-memwr")) { cmd_memWrite(args[i + 1], args[i + 2]); i += 2; } if (s.StartsWith("-memrd")) { cmd_memRead(args[i + 1], args[i + 2], args[i + 3]); i += 3; } if (s.StartsWith("-fpginit")) { edio.fpgInit(File.ReadAllBytes(args[i + 1]), null); i += 1; } } if (rom_path != null) { //edio.getConfig().print(); loadROM(rom_path, map_path); } Console.WriteLine(""); }