public VCNES GetBase(string path) { try { ValidateBase(path, false); RPXNES vc = ValidateRPX(path); return(VCNES.GetVC(vc.CRCsSum)); } catch { return(null); } }
protected override byte[] GetNewRodata(uint crcsSum, byte[] rodata, string rom, byte speed, byte players, byte soundVolume, byte romType) { //int romOffset = ReadInt32(rodata, 0x28); //ROM offset (Always 0x00000030) int footerOffset = ReadInt32(rodata, 0x2C); //Footer offset /*int romSize = * (rodata[0x20 + romOffset] == 'N' && * rodata[0x21 + romOffset] == 'E' && * rodata[0x22 + romOffset] == 'S') ? * rodata[0x24 + romOffset] * 16384 + rodata[0x25 + romOffset] * 8192 + 16 : * footerOffset - romOffset;*/ VCNES vc = VCNES.GetVC(crcsSum); if (vc.ROMSize == -1) { throw new FormatException("The source RPXNES is unknown."); } int romSize = vc.ROMSize + (vc.FDSROM ? 0 : 16); FileStream fs = File.Open(rom, FileMode.Open); byte[] romBytes = new byte[fs.Length]; fs.Read(romBytes, 0, romBytes.Length); fs.Close(); if (romBytes.Length > romSize) { throw new FormatException("The source ROM is too large for this base."); } int paddingLength = romSize - romBytes.Length; byte[] padding = new byte[paddingLength]; MemoryStream ms = new MemoryStream(rodata); ms.Position = 0x50;//romOffset + 0x20; ms.Write(romBytes, 0, romBytes.Length); ms.Write(padding, 0, padding.Length); ms.Position = footerOffset + 0x20; ms.WriteByte(speed); ms.Position = footerOffset + 0x2A; ms.WriteByte(players); rodata = ms.ToArray(); ms.Close(); return(rodata); }