public DownloadHandler(BinaryReader stream, BackgroundWorkerEx worker) { worker?.ReportProgress(0, "Loading \"download\"..."); stream.Skip(2); // DL byte b1 = stream.ReadByte(); byte b2 = stream.ReadByte(); byte b3 = stream.ReadByte(); int numFiles = stream.ReadInt32BE(); short numTags = stream.ReadInt16BE(); int numMaskBytes = (numFiles + 7) / 8; for (int i = 0; i < numFiles; i++) { MD5Hash key = stream.Read<MD5Hash>(); //byte[] unk = stream.ReadBytes(0xA); stream.Skip(0xA); //var entry = new DownloadEntry() { Index = i, Unk = unk }; var entry = new DownloadEntry() { Index = i }; DownloadData.Add(key, entry); worker?.ReportProgress((int)((i + 1) / (float)numFiles * 100)); } for (int i = 0; i < numTags; i++) { DownloadTag tag = new DownloadTag(); string name = stream.ReadCString(); tag.Type = stream.ReadInt16BE(); byte[] bits = stream.ReadBytes(numMaskBytes); for (int j = 0; j < numMaskBytes; j++) bits[j] = (byte)((bits[j] * 0x0202020202 & 0x010884422010) % 1023); tag.Bits = new BitArray(bits); Tags.Add(name, tag); } }
public InstallHandler(BinaryReader stream, BackgroundWorkerEx worker) { worker?.ReportProgress(0, "Loading \"install\"..."); stream.ReadBytes(2); // IN byte b1 = stream.ReadByte(); byte b2 = stream.ReadByte(); short numTags = stream.ReadInt16BE(); int numFiles = stream.ReadInt32BE(); int numMaskBytes = (numFiles + 7) / 8; List<InstallTag> Tags = new List<InstallTag>(); for (int i = 0; i < numTags; i++) { InstallTag tag = new InstallTag(); tag.Name = stream.ReadCString(); tag.Type = stream.ReadInt16BE(); byte[] bits = stream.ReadBytes(numMaskBytes); for (int j = 0; j < numMaskBytes; j++) bits[j] = (byte)((bits[j] * 0x0202020202 & 0x010884422010) % 1023); tag.Bits = new BitArray(bits); Tags.Add(tag); } for (int i = 0; i < numFiles; i++) { InstallEntry entry = new InstallEntry(); entry.Name = stream.ReadCString(); entry.MD5 = stream.ReadBytes(16); entry.Size = stream.ReadInt32BE(); InstallData.Add(entry); entry.Tags = Tags.FindAll(tag => tag.Bits[i]); worker?.ReportProgress((int)((i + 1) / (float)numFiles * 100)); } }
public DownloadHandler(BinaryReader stream) { stream.Skip(2); // DL byte b1 = stream.ReadByte(); byte b2 = stream.ReadByte(); byte b3 = stream.ReadByte(); int numFiles = stream.ReadInt32BE(); short numTags = stream.ReadInt16BE(); int numMaskBytes = numFiles / 8 + (numFiles % 8 > 0 ? 1 : 0); for (int i = 0; i < numFiles; i++) { byte[] key = stream.ReadBytes(0x10); byte[] unk = stream.ReadBytes(0xA); DownloadEntry entry = new DownloadEntry() { Index = i, Unk = unk }; DownloadData.Add(key, entry); } for (int i = 0; i < numTags; i++) { DownloadTag tag = new DownloadTag(); string name = stream.ReadCString(); tag.Type = stream.ReadInt16BE(); byte[] bits = stream.ReadBytes(numMaskBytes); for (int j = 0; j < numMaskBytes; j++) bits[j] = (byte)((bits[j] * 0x0202020202 & 0x010884422010) % 1023); tag.Bits = new BitArray(bits); Tags.Add(name, tag); } }
public InstallHandler(BinaryReader stream) { stream.ReadBytes(2); // IN byte b1 = stream.ReadByte(); byte b2 = stream.ReadByte(); short numTags = stream.ReadInt16BE(); int numFiles = stream.ReadInt32BE(); int numMaskBytes = (numFiles + 7) / 8; List<InstallTag> Tags = new List<InstallTag>(); for (int i = 0; i < numTags; i++) { InstallTag tag = new InstallTag(); tag.Name = stream.ReadCString(); tag.Type = stream.ReadInt16BE(); byte[] bits = stream.ReadBytes(numMaskBytes); for (int j = 0; j < numMaskBytes; j++) bits[j] = (byte)((bits[j] * 0x0202020202 & 0x010884422010) % 1023); tag.Bits = new BitArray(bits); Tags.Add(tag); } for (int i = 0; i < numFiles; i++) { InstallEntry entry = new InstallEntry(); entry.Name = stream.ReadCString(); entry.MD5 = stream.Read<MD5Hash>(); entry.Size = stream.ReadInt32BE(); InstallData.Add(entry); entry.Tags = Tags.FindAll(tag => tag.Bits[i]); } }
public Instrument(BinaryReader reader) : this() { SynthMode = reader.ReadInt16BE(); SampleWaveNo = reader.ReadInt16BE(); Length = reader.ReadInt16BE(); Repeat = reader.ReadInt16BE(); reader.ReadBytes(8); Volume = reader.ReadInt16BE(); FineTuning = reader.ReadInt16BE(); Portamento = reader.ReadInt16BE(); VibDelay = reader.ReadInt16BE(); VibSpeed = reader.ReadInt16BE(); VibLevel = reader.ReadInt16BE(); AmfWave = reader.ReadInt16BE(); AmfDelay = reader.ReadInt16BE(); AmfLength = reader.ReadInt16BE(); AmfRepeat = reader.ReadInt16BE(); AdsrWave = reader.ReadInt16BE(); AdsrDelay = reader.ReadInt16BE(); AdsrLength = reader.ReadInt16BE(); AdsrRepeat = reader.ReadInt16BE(); SustainPt = reader.ReadInt16BE(); SustainVal = reader.ReadInt16BE(); reader.ReadBytes(16); EffectNumber = reader.ReadInt16BE(); Effect1 = reader.ReadInt16BE(); Effect2 = reader.ReadInt16BE(); Effect3 = reader.ReadInt16BE(); EffectDelay = reader.ReadInt16BE(); ArpegData = new Arpeggiato[3]; for(int i = 0; i < ArpegData.Length; i++) { ArpegData[i] = new Arpeggiato(reader); } Name = new string(reader.ReadChars(30)).Split(new[]{'\0'}, 2)[0]; }
public Voice(BinaryReader reader) : this() { NoteAddress = reader.ReadInt16BE(); SoundTranspose = reader.ReadByte(); NoteTranspose = reader.ReadByte(); }
public Song(BinaryReader reader) : this() { SongSpeed = reader.ReadInt16BE(); PatternLength = reader.ReadInt16BE(); StartPos = reader.ReadInt16BE(); StopPos = reader.ReadInt16BE(); RepeatPos = reader.ReadInt16BE(); NBIrqps = reader.ReadInt16BE(); }
public Song(BinaryReader reader) : this() { Start = reader.ReadInt16BE(); End = reader.ReadInt16BE(); Speed = reader.ReadInt16BE(); }
private void LoadBannerImage() { int tileMaxW = 4; int tileMaxH = 4; int tileMaxS = tileMaxW * tileMaxH; int tileW = 0; int tileH = -1; int imgMaxTileW = 24; int imgMaxTileH = 8; int imgMaxTileS = imgMaxTileW * imgMaxTileH; int imgTileW = 0; int imgTileH = -1; int bmpShift = 0x36; int bmpH = imgMaxTileH * tileMaxW; byte[] bmp = new byte[bmpShift + 0x1800]; int bmpLineLen = imgMaxTileW * tileMaxW * 2; byte[] bmpLine = new byte[bmpLineLen]; int bmpSize = bmpLineLen * imgMaxTileH * tileMaxH + bmpShift; int bmpPos = 0; int pix; byte b1, b2, b3, b4; int i, j; Array.Copy(GCRebuilder.Properties.Resources.bmp15, bmp, GCRebuilder.Properties.Resources.bmp15.Length); bnr.Position = 0x20; for (i = 0; i < imgMaxTileS; i++) { if (i % imgMaxTileW == 0) { imgTileW = 0; imgTileH += 1; } bmpPos = ((imgTileW * tileMaxW) * 2 + (imgTileH * tileMaxH * bmpLineLen)) + bmpShift; //bmpPos = bmpSize - (bmpLineLen * tileMaxH) - (((imgTileW * tileMaxW) * 2 + (imgTileH * tileMaxH * bmpLineLen)) + bmpShift); for (j = 0; j < tileMaxS; j++) { if (j % tileMaxW == 0) { tileW = 0; tileH += 1; if (tileH > 0) { bmpPos += bmpLineLen; } } pix = bnrr.ReadInt16BE(); if ((pix & 0x8000) != 0x8000) { b1 = (byte)((pix >> 0x0c) & 0x0f); b2 = (byte)((pix >> 0x08) & 0x0f); b3 = (byte)((pix >> 0x04) & 0x0f); b4 = (byte)(pix & 0x0f); pix = (b2 << 0x0b) | (b3 << 0x06) | (b4 << 0x01); } else { pix &= 0x7fff; } bmp[bmpPos + (tileW * 2)] = (byte)(pix & 0xff); bmp[bmpPos + (tileW * 2) + 1] = (byte)(pix >> 0x8); tileW += 1; } tileH = -1; imgTileW += 1; } for (i = bmpH / 2; i < bmpH; i++) { Array.Copy(bmp, (i * bmpLineLen) + bmpShift, bmpLine, 0, bmpLineLen); Array.Copy(bmp, ((bmpH - i - 1) * bmpLineLen) + bmpShift, bmp, (i * bmpLineLen) + bmpShift, bmpLineLen); Array.Copy(bmpLine, 0, bmp, ((bmpH - i - 1) * bmpLineLen) + bmpShift, bmpLineLen); } img = System.Drawing.Image.FromStream(new sio.MemoryStream(bmp)); btnBDImport.Enabled = true; btnBDExport.Enabled = true; btnBDSave.Enabled = true; pbBDBanner.Invalidate(); }