public byte[] CreateRwStore(uint aSectorBytes) { List <byte[]> sectors = new List <byte[]>(); byte[] sector = CreateSector(aSectorBytes); int offset = 4; foreach (StoreEntry e in iStoreEntryList.Values) { if (offset + e.Data.Length + 8 > aSectorBytes) { sectors.Add(sector); sector = CreateSector(aSectorBytes); offset = 4; } byte[] length = BigEndian.Bytes(e.Data.Length + 8); byte[] key = BigEndian.Bytes(e.Key); Array.Copy(length, 0, sector, offset, 4); Array.Copy(key, 0, sector, offset + 4, 4); Array.Copy(e.Data, 0, sector, offset + 8, e.Data.Length); int skip = (e.Data.Length + 8 + 3) & ~3; offset += skip; } if (offset > 4) { byte[] last = new byte[offset]; Array.Copy(sector, 0, last, 0, offset); sectors.Add(last); // add last sector } int bytes = 0; foreach (byte[] s in sectors) { bytes += s.Length; } byte[] result = new byte[bytes]; offset = 0; foreach (byte[] s in sectors) { Array.Copy(s, 0, result, offset, s.Length); offset += s.Length; } return(result); }
public byte[] Create() { byte[] data = new byte[(iEntryList.Count * RomDirEntry.kRomDirEntryBytes) + 4]; byte[] count = BigEndian.Bytes(iEntryList.Count); Array.Copy(count, 0, data, 0, 4); int offset = 4; foreach (RomDirEntry e in iEntryList) { byte[] entry = e.Create(); Array.Copy(entry, 0, data, offset, entry.Length); offset += entry.Length; } return(data); }
public byte[] CreateRoStore() { int bytes = 0; foreach (StoreEntry e in iStoreEntryList.Values) { bytes += (e.Data.Length + 8 + 3) & ~3; } bytes += 4; byte[] data = new byte[bytes]; for (uint i = 0; i < bytes; i++) { data[i] = 0xff; } int offset = 0; foreach (StoreEntry e in iStoreEntryList.Values) { byte[] length = BigEndian.Bytes(e.Data.Length + 8); byte[] key = BigEndian.Bytes(e.Key); Array.Copy(length, 0, data, offset, 4); Array.Copy(key, 0, data, offset + 4, 4); Array.Copy(e.Data, 0, data, offset + 8, e.Data.Length); int skip = (e.Data.Length + 8 + 3) & ~3; offset += skip; } return(data); }
public byte[] Create() { byte[] key = BigEndian.Bytes(iKey); byte[] flashId = BigEndian.Bytes(iFlashId); byte[] offset = BigEndian.Bytes(iOffset); byte[] bytes = BigEndian.Bytes(iBytes); byte[] type = BigEndian.Bytes(iType); byte[] crc = BigEndian.Bytes(iCrc); byte[] originalFlashId = BigEndian.Bytes(iOriginalFlashId); byte[] originalOffset = BigEndian.Bytes(iOriginalOffset); byte[] data = new byte[kRomDirEntryBytes]; Array.Copy(key, 0, data, 0, 4); Array.Copy(flashId, 0, data, 4, 4); Array.Copy(offset, 0, data, 8, 4); Array.Copy(bytes, 0, data, 12, 4); Array.Copy(type, 0, data, 16, 4); Array.Copy(crc, 0, data, 20, 4); Array.Copy(originalFlashId, 0, data, 24, 4); Array.Copy(originalOffset, 0, data, 28, 4); return(data); }
public static StoreEntry Create(uint aKey, int aValue) { byte[] bytes = BigEndian.Bytes(aValue); return(new StoreEntry(aKey, bytes)); }