public static bloScreen loadBlo1(Stream stream) { aBinaryReader reader = new aBinaryReader(stream, Endianness.Big, Encoding.GetEncoding(1252)); bloScreen scrn = new bloScreen(); if (reader.Read32() != cSCRN) { return(null); } if (reader.Read32() != cBLO1) { return(null); } reader.Step(24); if (reader.Read32() != cINF1) { return(null); } long inf1size = reader.Read32(); int width = reader.ReadS16(); int height = reader.ReadS16(); scrn.mRect.set(0, 0, width, height); scrn.mTintColor = new bloColor(reader.Read32()); if (!loadBlo1(scrn, reader)) { return(null); } return(scrn); }
public override void load(Stream stream) { aBinaryReader reader = new aBinaryReader(stream, Endianness.Big); mFormat = (gxTextureFormat)reader.Read8(); // 0000 mTransparency = reader.Read8(); // 0001 mWidth = reader.Read16(); // 0002 mHeight = reader.Read16(); // 0004 mWrapS = (gxWrapMode)reader.Read8(); // 0006 mWrapT = (gxWrapMode)reader.Read8(); // 0007 reader.Step(1); // 0008 (0001) mTlutFormat = (gxTlutFormat)reader.Read8(); // 0009 int tlutentrycount = reader.Read16(); // 000A long tlutoffset = reader.Read32(); // 000C mMipMap = (reader.Read8() != 0); // 0010 mEdgeLOD = (reader.Read8() != 0); // 0011 mBiasClamp = (reader.Read8() != 0); // 0012 mMaxAniso = (gxAnisotropy)reader.Read8(); // 0013 mMinFilter = (gxTextureFilter)reader.Read8(); // 0014 mMagFilter = (gxTextureFilter)reader.Read8(); // 0015 mMinLod = reader.ReadS8(); // 0016 mMaxLod = reader.ReadS8(); // 0017 mImageCount = reader.Read8(); // 0018 (0001) mLodBias = reader.ReadS16(); // 001A long texoffset = reader.Read32(); // 001C loadImageData(reader, texoffset); if (tlutentrycount > 0) { loadPaletteData(reader, tlutentrycount, tlutoffset); } }
public override string Read(aBinaryReader reader) { var value = base.Read(reader); #if DEBUG aError.Check<Exception>(reader.ReadChar() == '\0', "BZSTR is not null-terminated."); #else reader.Step(1); #endif return value; }
static bool ReadAafHeader(aBinaryReader reader, int id, int index, out int offset, out int size) { int section; offset = 0; size = 0; while ((section = reader.ReadS32()) != 0) { if (section == 2 || section == 3) { for (int i = 0; (offset = reader.ReadS32()) != 0; ++i) { size = reader.ReadS32(); reader.Step(4); if (section == id && i == index) { return(true); } } } else { offset = reader.ReadS32(); size = reader.ReadS32(); reader.Step(4); if (section == id && index == 0) { return(true); } } if (section == id) { break; } } return(false); }
public GlyphBlock(aBinaryReader reader) { firstCode = reader.Read16(); // 0008 lastCode = reader.Read16(); // 000A cellWidth = reader.Read16(); // 000C cellHeight = reader.Read16(); // 000E sheetSize = reader.ReadS32(); // 0010 sheetFormat = (gxTextureFormat)reader.Read16(); // 0014 sheetRow = reader.Read16(); // 0016 sheetColumn = reader.Read16(); // 0018 sheetWidth = reader.Read16(); // 001A sheetHeight = reader.Read16(); // 001C reader.Step(2); // 001E // we have to manually calculate how many sheets there are int sheetCount = (((lastCode - firstCode) / (sheetRow * sheetColumn)) + 1); sheets = aCollection.Initialize(sheetCount, () => reader.Read8s(sheetSize)); }
protected virtual void loadCompact(aBinaryReader reader) { if (reader == null) { throw new ArgumentNullException("reader"); } mVisible = (reader.Read8() != 0); reader.Step(1); mName = reader.Read32(); int left = reader.ReadS16(); int top = reader.ReadS16(); int width = reader.ReadS16(); int height = reader.ReadS16(); mRect.set(left, top, (left + width), (top + height)); setBasePosition(bloAnchor.TopLeft); mAngle = 0.0d; mAlpha = 255; mInheritAlpha = true; }
protected override WaveBank DoTransform(WaveBank obj) { if (obj != null) { return(obj); } mReader.Keep(); mReader.PushAnchor(); if (mReader.Read32() != WSYS) { mareep.WriteError("WSYS: could not find header."); } var size = mReader.ReadS32(); mReader.Step(8); // unused var winfOffset = mReader.ReadS32(); var wbctOffset = mReader.ReadS32(); mareep.WriteMessage("WSYS: header found, size {0:F1} KB\n", ((double)size / 1024.0d)); var waveBank = new WaveBank(); waveBank.Name = mName; mReader.Goto(winfOffset); if (mReader.Read32() != WINF) { mareep.WriteError("WSYS: could not find WINF at 0x{0:X6}.", winfOffset); } var waveGroupCount = mReader.ReadS32(); if (waveGroupCount < 0) { mareep.WriteError("WSYS: bad wave-group count '{0}' in WINF.", waveGroupCount); } mareep.WriteMessage("WSYS: WINF found, {0} wave group(s).\n", waveGroupCount); var waveGroupOffsets = mReader.ReadS32s(waveGroupCount); mReader.Goto(wbctOffset); if (mReader.Read32() != WBCT) { mareep.WriteError("WSYS: could not find WBCT at 0x{0:X6}.", wbctOffset); } mReader.Step(4); // unused var sceneCount = mReader.ReadS32(); if (sceneCount != waveGroupCount) { mareep.WriteError("WSYS: WINF count ({0}) does not match WBCT count ({1}).", waveGroupCount, sceneCount); } var sceneOffsets = mReader.ReadS32s(sceneCount); for (var i = 0; i < waveGroupCount; ++i) { mReader.Goto(waveGroupOffsets[i]); var archiveName = mReader.ReadString <aCSTR>(112); var waveInfoCount = mReader.ReadS32(); if (waveInfoCount < 0) { mareep.WriteError("WSYS: bad wave count '{0}' in wave group #{1}.", waveInfoCount, i); } var waveInfoOffsets = mReader.ReadS32s(waveInfoCount); mReader.Goto(sceneOffsets[i]); if (mReader.Read32() != SCNE) { mareep.WriteError("WSYS: could not find SCNE at 0x{0:X6}.", sceneOffsets[i]); } mReader.Step(8); // unused var cdfOffset = mReader.ReadS32(); mReader.Goto(cdfOffset); if (mReader.Read32() != C_DF) { mareep.WriteError("WSYS: could not find C-DF at 0x{0:X6}.", cdfOffset); } var waveidCount = mReader.ReadS32(); if (waveidCount != waveInfoCount) { mareep.WriteError("WSYS: C-DF count ({0}) does not match wave-info count ({1}).", waveidCount, waveInfoCount); } var waveidOffsets = mReader.ReadS32s(waveidCount); var waveGroup = new WaveGroup(); waveGroup.ArchiveFileName = archiveName; for (var j = 0; j < waveInfoCount; ++j) { var wave = new Wave(); mReader.Goto(waveidOffsets[j]); var waveid = (mReader.ReadS32() & 0xFFFF); wave.WaveId = waveid; mReader.Goto(waveInfoOffsets[j]); mReader.Step(1); // unknown var format = (WaveFormat)mReader.Read8(); if (!format.IsDefined()) { mareep.WriteError("WSYS: group #{0}: wave #{1}: bad format '{2}'.", i, j, (byte)format); } else { wave.Format = format; } var key = mReader.Read8(); if (key < 0 || key > 127) { mareep.WriteError("WSYS: group #{0}: wave #{1}: bad root key '{2}'.", i, j, key); } else { wave.RootKey = key; } mReader.Step(1); // alignment var sampleRate = mReader.ReadF32(); if (sampleRate < 0.0f) { mareep.WriteError("WSYS: group #{0}: wave #{1}: bad sample rate '{2:F1}'.", i, j, sampleRate); } else { wave.SampleRate = sampleRate; } var waveStart = mReader.ReadS32(); if (waveStart < 0) { mareep.WriteError("WSYS: group #{0}: wave #{1}: bad wave start '{2}'.", i, j, waveStart); } else { wave.WaveStart = waveStart; } var waveSize = mReader.ReadS32(); if (waveSize < 0) { mareep.WriteError("WSYS: group #{0}: wave #{1}: bad wave size '{1}'.", i, j, waveSize); } else { wave.WaveSize = waveSize; } wave.Loop = (mReader.Read32() != 0); var loopStart = mReader.ReadS32(); if (loopStart < 0) { mareep.WriteError("WSYS: group #{0}: wave #{1}: bad loop start '{2}'.", i, j, loopStart); } else { wave.LoopStart = loopStart; } var loopEnd = mReader.ReadS32(); if (loopEnd < 0) { mareep.WriteError("WSYS: group #{0}: wave #{1}: bad loop end '{2}'.", i, j, loopEnd); } else { wave.LoopEnd = loopEnd; } var sampleCount = mReader.ReadS32(); wave.SampleCount = mareep.CalculateSampleCount(format, waveSize); if (loopStart > loopEnd) { mareep.WriteWarning("WSYS: group #{0}: wave #{1}: loop start '{2}' is greater than loop end '{3}'.\n", i, j, loopStart, loopEnd); } if (loopStart > wave.SampleCount) { mareep.WriteWarning("WSYS: group #{0}: wave #{1}: loop start '{2}' is greater than sample count '{3}'.\n", i, j, loopStart, wave.SampleCount); } if (loopEnd > wave.SampleCount) { mareep.WriteWarning("WSYS: group #{0}: wave #{1}: loop end '{2}' is greater than sample count '{3}'.\n", i, j, loopEnd, wave.SampleCount); } wave.HistoryLast = mReader.ReadS16(); wave.HistoryPenult = mReader.ReadS16(); // rest of the fields are unknown or runtime waveGroup.Add(wave); } waveBank.Add(waveGroup); } mReader.PopAnchor(); mReader.Back(); return(waveBank); }
static bool loadCompact(bloPane parent, aBinaryReader reader) { bloPane lastPane = parent; for (;;) { long start = reader.Position; ushort typeID = reader.Read16(); // this is actually a peek in SMS, but f**k that switch (typeID) { default: { Console.WriteLine(">>> Unknown '{0:X4}' section at 0x{1:X6}", typeID, start); return(false); } case cExitID: { return(true); } case cEndID: { reader.Step(2); return(true); } case cBeginID: { reader.Step(2); if (!loadCompact(lastPane, reader)) { return(false); } break; } case cPaneID: { lastPane = new bloPane(); lastPane.load(parent, reader, bloFormat.Compact); if (parent is bloScreen) { var oldrect = lastPane.getRectangle(); var newrect = new bloRectangle(0, 0, oldrect.width, oldrect.height); parent.setRectangle(newrect); } break; } case cWindowID: { lastPane = new bloWindow(); lastPane.load(parent, reader, bloFormat.Compact); break; } case cPictureID: { lastPane = new bloPicture(); lastPane.load(parent, reader, bloFormat.Compact); break; } case cTextboxID: { lastPane = new bloTextbox(); lastPane.load(parent, reader, bloFormat.Compact); break; } } } }
protected virtual void loadBlo1(aBinaryReader reader) { if (reader == null) { throw new ArgumentNullException("reader"); } int numparams = reader.Read8(); mVisible = (reader.Read8() != 0); reader.Step(2); mName = reader.Read32(); int left = reader.ReadS16(); int top = reader.ReadS16(); int width = reader.ReadS16(); int height = reader.ReadS16(); mRect.set(left, top, (left + width), (top + height)); numparams -= 6; if (numparams > 0) { mAngle = reader.Read16(); --numparams; } else { mAngle = 0.0d; } if (numparams > 0) { mAnchor = (bloAnchor)reader.Read8(); --numparams; } else { mAnchor = bloAnchor.TopLeft; } if (numparams > 0) { mAlpha = reader.Read8(); --numparams; } else { mAlpha = 255; } if (numparams > 0) { mInheritAlpha = (reader.Read8() != 0); --numparams; } else { mInheritAlpha = true; } reader.Skip(4); }