public void loadOS(NesRom rom, string map_path) { if (map_path == null) { map_path = getTestMapper(255); } byte[] prg = rom.PrgData; byte[] chr = rom.ChrData; MapConfig cfg = new MapConfig(); cfg.map_idx = 0xff; cfg.Ctrl = MapConfig.ctrl_unlock; cmd(cmd_reboot); edio.rx8();//exec edio.memWR(rom.PrgAddr, prg, 0, prg.Length); edio.memWR(rom.ChrAddr, chr, 0, chr.Length); edio.getStatus(); if (map_path == null) { mapLoadSDC(255, cfg); } else { byte[] map = File.ReadAllBytes(map_path); edio.fpgInit(map, cfg); } }
public MapConfig(NesRom rom) { map_idx = rom.Mapper; if (rom.Mirroring == 'H') { MapCfg |= cfg_mir_h; } if (rom.Mirroring == 'V') { MapCfg |= cfg_mir_v; } if (rom.Mirroring == '4') { MapCfg |= cfg_mir_4; } if (rom.ChrSize == 0) { MapCfg |= cfg_chr_ram; } PrgSize = rom.PrgSize; ChrSize = rom.ChrSize; SrmSize = rom.SrmSize; MasterVol = 8; SSKey_save = 0x14; //start + down SSKey_load = 0x18; //start + up }
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 loadROM(string rom_path, string map_path) { Console.WriteLine("ROM loading..."); NesRom rom = new NesRom(rom_path); rom.print(); if (rom.Type == NesRom.ROM_TYPE_OS) { usb.loadOS(rom, map_path); } else { usb.loadGame(rom, map_path); } Console.WriteLine(); edio.getConfig().print(); }