示例#1
0
文件: Usbio.cs 项目: srdqty/EDN8-PRO
        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);
            }
        }