public static float[] reg_to_float(SPU spu, int r) { float[] d = new float[4]; for (int i = 0; i < 4; i++) { d[i] = BitConverter.ToSingle(ConversionUtil.uintToByte(spu.Register[r, i]), 0); } return(d); }
public static void reg2ls(SPU spu, int r, uint addr) { addr &= SPUCommandHelper.LSLR & 0xfffffff0; byte[] r0 = ConversionUtil.uintToByte(spu.Register[r, 0]); byte[] r1 = ConversionUtil.uintToByte(spu.Register[r, 1]); byte[] r2 = ConversionUtil.uintToByte(spu.Register[r, 2]); byte[] r3 = ConversionUtil.uintToByte(spu.Register[r, 3]); for (int i = 0; i < 4; i++) { spu.LocalStorage[addr + i] = r0[i]; spu.LocalStorage[addr + 4 + i] = r1[i]; spu.LocalStorage[addr + 8 + i] = r2[i]; spu.LocalStorage[addr + 12 + i] = r3[i]; } for (uint i = 0; i < 16; i += 4) { uint cmdI = (addr + i) >> 2; spu.LocalStorageCommands[cmdI] = new SPUCommand(spu.LocalStorage, (int)(cmdI << 2)); } }
public static double[] reg_to_double(SPU spu, int r) { byte[] b = new byte[4]; byte[] b2 = new byte[4]; double[] d = new double[2]; byte[] db = new byte[8]; b = ConversionUtil.uintToByte(spu.Register[r, 1]); b2 = ConversionUtil.uintToByte(spu.Register[r, 0]); for (int i = 0; i < 4; i++) { db[i] = b[i]; db[i + 4] = b2[i]; } d[0] = BitConverter.ToDouble(db, 0); b = ConversionUtil.uintToByte(spu.Register[r, 3]); b2 = ConversionUtil.uintToByte(spu.Register[r, 2]); for (int i = 0; i < 4; i++) { db[i] = b[i]; db[i + 4] = b2[i]; } d[1] = BitConverter.ToDouble(db, 0); return(d); }
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(); }