示例#1
0
 public void Add(uint addr, SPUDumperCmd cmd)
 {
     if (!commands.ContainsKey(addr))
     {
         commands.Add(addr, new List <SPUDumperCmd>());
     }
     commands[addr].Add(cmd);
 }
示例#2
0
        public static void LoadScriptFile(string FileName, SPU spu)
        {
            StreamReader fs = new StreamReader(File.OpenRead(FileName));
            string       input;

            char[] tokens = { ',' };
            while ((input = fs.ReadLine()) != null)
            {
                string unModdedInput = input;
                input = input.Trim();
                input = input.Replace("\t", " ");
                input = input.Replace(" ", "");
                string inputLower = input.ToLower();
                if (input != "")
                {
                    SPUDumperCmd dcmd;
                    string[]     token = input.Split(tokens);
                    switch (token[0])
                    {
                    case "r":     // r,0,1,0xAFCE
                        int  registerSelect     = int.Parse(token[1]);
                        int  registerByteSelect = int.Parse(token[2]);
                        uint valueSelect        = ParseUInt(token[3]);
                        spu.Register[registerSelect, registerByteSelect] = valueSelect;
                        break;

                    case "elf":     // elf,blub.elf,true
                        FileLoader.LoadElf(token[1], spu, (token.Length > 2 && token[2] == "true"));
                        break;

                    case "bin":
                        int lsStart = (int)ParseUInt(token[1]);
                        FileLoader.LoadBin(lsStart, token[2], spu);
                        break;

                    case "mfc":
                        byte[] data = FileLoader.LoadBin(token[3]);
                        uint   EAH  = ParseUInt(token[1]);
                        uint   EAL  = ParseUInt(token[2]);
                        spu.MFC.WriteMemory(EAH, EAL, data);
                        break;

                    case "ip":     // ip,0x400
                        spu.IP = ParseUInt(token[1]);
                        break;

                    case "mBox":     // mBox, 0x0000
                        spu.mBox.Push(ParseUInt(token[1]));
                        break;

                    case "print":     // print, 0x12345678, [string]
                        string[] printToken = unModdedInput.Split(tokens, 3);
                        dcmd = new SPUDumperCmd(token[0], new string[] { printToken[2] });
                        SPUDumper.Instance.Add(ParseUInt(token[1]), dcmd);
                        break;

                    case "print_r":     // print_r, 0x12345678, [register], [register_part]
                    case "print_ls":    // print_ls, 0x12345678, [spezial_addr], [spezial_size]
                        dcmd = new SPUDumperCmd(token[0], new string[] { token[2], token[3] });
                        SPUDumper.Instance.Add(ParseUInt(token[1]), dcmd);
                        break;

                    case "print_dma":     // print_ls, 0x12345678, [spezial_eah], [spezial_eal], [spezial_size]
                        dcmd = new SPUDumperCmd(token[0], new string[] { token[2], token[3], token[4] });
                        SPUDumper.Instance.Add(ParseUInt(token[1]), dcmd);
                        break;

                    case "setls":
                        byte b = (byte)ParseUInt(token[2]);
                        spu.LocalStorage[ParseUInt(token[1])] = b;
                        break;

                    case "setls32":
                        uint   val  = ParseUInt(token[2]);
                        uint   addr = ParseUInt(token[1]);
                        byte[] bb   = ConversionUtil.uintToByte(val);
                        for (int i = 0; i < 4; i++)
                        {
                            spu.LocalStorage[addr + i] = bb[i];
                        }
                        break;
                    }
                }
            }
            fs.Close();
        }
示例#3
0
 public void Add(uint addr, SPUDumperCmd cmd)
 {
     if (!commands.ContainsKey(addr))
         commands.Add(addr, new List<SPUDumperCmd>());
     commands[addr].Add(cmd);
 }
示例#4
0
 public static void LoadScriptFile(string FileName, SPU spu)
 {
     StreamReader fs = new StreamReader(File.OpenRead(FileName));
     string input;
     char[] tokens = { ',' };
     while((input = fs.ReadLine()) != null)
     {
         string unModdedInput = input;
         input = input.Trim();
         input = input.Replace("\t", " ");
         input = input.Replace(" ", "");
         string inputLower = input.ToLower();
         if(input != "")
         {
             SPUDumperCmd dcmd;
             string[] token = input.Split(tokens);
             switch (token[0])
             {
                 case "r": // r,0,1,0xAFCE
                     int registerSelect = int.Parse(token[1]);
                     int registerByteSelect = int.Parse(token[2]);
                     uint valueSelect = ParseUInt(token[3]);
                     spu.Register[registerSelect, registerByteSelect] = valueSelect;
                     break;
                 case "elf": // elf,blub.elf,true
                     FileLoader.LoadElf(token[1], spu, (token.Length > 2 && token[2] == "true"));
                     break;
                 case "bin":
                     int lsStart = (int) ParseUInt(token[1]);
                     FileLoader.LoadBin(lsStart, token[2], spu);
                     break;
                 case "mfc":
                     byte[] data = FileLoader.LoadBin(token[3]);
                     uint EAH = ParseUInt(token[1]);
                     uint EAL = ParseUInt(token[2]);
                     spu.MFC.WriteMemory(EAH, EAL, data);
                     break;
                 case "ip": // ip,0x400
                     spu.IP = ParseUInt(token[1]);
                     break;
                 case "mBox": // mBox, 0x0000
                     spu.mBox.Push(ParseUInt(token[1]));
                     break;
                 case "print": // print, 0x12345678, [string]
                     string[] printToken = unModdedInput.Split(tokens, 3);
                     dcmd = new SPUDumperCmd(token[0], new string[] { printToken[2] });
                     SPUDumper.Instance.Add(ParseUInt(token[1]), dcmd);
                     break;
                 case "print_r": // print_r, 0x12345678, [register], [register_part]
                 case "print_ls": // print_ls, 0x12345678, [spezial_addr], [spezial_size]
                     dcmd = new SPUDumperCmd(token[0], new string[] { token[2], token[3] });
                     SPUDumper.Instance.Add(ParseUInt(token[1]), dcmd);
                     break;
                 case "print_dma": // print_ls, 0x12345678, [spezial_eah], [spezial_eal], [spezial_size]
                     dcmd = new SPUDumperCmd(token[0], new string[] { token[2], token[3], token[4] });
                     SPUDumper.Instance.Add(ParseUInt(token[1]), dcmd);
                     break;
                 case "setls":
                     byte b = (byte)ParseUInt(token[2]);
                     spu.LocalStorage[ParseUInt(token[1])] = b;
                     break;
                 case "setls32":
                     uint val = ParseUInt(token[2]);
                     uint addr = ParseUInt(token[1]);
                     byte[] bb = ConversionUtil.uintToByte(val);
                     for(int i = 0; i < 4; i++)
                         spu.LocalStorage[addr+i] = bb[i];
                     break;
             }
         }
     }
     fs.Close();
 }