Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        static void cmd_memWrite(string path, string addr_str)
        {
            int addr = 0;

            Console.Write("Memory write...");

            addr = getNum(addr_str);

            byte[] data = File.ReadAllBytes(path);
            edio.memWR(addr, data, 0, data.Length);

            Console.WriteLine("ok");
        }
Esempio n. 3
0
        int testMEM(string name, int addr, int size)
        {
            byte[] buff;
            Console.Write("Testing " + name + "...");

            //simple data bus test
            buff = new byte[] { 0xAA };
            edio.memWR(addr, buff, 0, buff.Length);
            edio.memRD(addr, buff, 0, buff.Length);
            if (buff[0] != 0xAA)
            {
                return(0x01);
            }
            buff = new byte[] { 0x55 };
            edio.memWR(addr, buff, 0, buff.Length);
            edio.memRD(addr, buff, 0, buff.Length);
            if (buff[0] != 0x55)
            {
                return(0x01);
            }


            //full data bus + partial address bus test
            buff = new byte[256];
            for (int i = 0; i < buff.Length; i++)
            {
                buff[i] = (byte)i;
            }
            edio.memWR(addr, buff, 0, buff.Length);
            edio.memRD(addr, buff, 0, buff.Length);
            for (int i = 0; i < buff.Length; i++)
            {
                if (buff[i] != i)
                {
                    return(0x02);
                }
            }

            //full address bus test
            for (int i = 0; i < size; i *= 2)
            {
                buff = BitConverter.GetBytes(i);
                edio.memWR(addr + i, buff, 0, buff.Length);
                if (i == 0)
                {
                    i = 2;
                }
            }
            for (int i = 0; i < size; i *= 2)
            {
                edio.memRD(addr + i, buff, 0, buff.Length);
                int val = BitConverter.ToInt32(buff, 0);
                if (val != i)
                {
                    return(0x03);
                }
                if (i == 0)
                {
                    i = 2;
                }
            }

            //random data test
            Random rnd = new Random((int)DateTime.Now.Ticks);

            byte[] rnd_dat = new byte[0x10000];
            buff = new byte[rnd_dat.Length];
            rnd.NextBytes(rnd_dat);
            edio.memWR(addr, rnd_dat, 0, rnd_dat.Length);
            edio.memRD(addr, buff, 0, buff.Length);
            for (int i = 0; i < buff.Length; i++)
            {
                if (buff[i] != rnd_dat[i])
                {
                    return(0x04);
                }
            }

            return(0);
        }