// Token: 0x06000241 RID: 577 RVA: 0x00007240 File Offset: 0x00005440 public sfPresetHeader(ABinaryReader binaryReader) { this.achPresetName = binaryReader.ReadClampedString(20); this.wPreset = binaryReader.Read16(); this.wBank = binaryReader.Read16(); this.wPresetBagNdx = binaryReader.Read16(); this.dwLibrary = binaryReader.Read32(); this.dwGenre = binaryReader.Read32(); this.dwMorphology = binaryReader.Read32(); }
public uint unk6; // zeroes public Material(ABinaryReader binaryReader) { textureIndex = binaryReader.ReadS16(); unk1 = binaryReader.ReadS16(); wrapS = (WrapMode)binaryReader.Read8(); wrapT = (WrapMode)binaryReader.Read8(); unk3 = binaryReader.Read16(); unk4 = binaryReader.Read32(); unk5 = binaryReader.Read32(); unk6 = binaryReader.Read32(); }
// Token: 0x0600023D RID: 573 RVA: 0x00007168 File Offset: 0x00005368 public sfSample(ABinaryReader binaryReader) { this.achSampleName = binaryReader.ReadClampedString(20); this.dwStart = binaryReader.Read32(); this.dwEnd = binaryReader.Read32(); this.dwStartLoop = binaryReader.Read32(); this.dwEndLoop = binaryReader.Read32(); this.dwSampleRate = binaryReader.Read32(); this.byOriginalKey = binaryReader.Read8(); this.chCorrect = binaryReader.ReadS8(); this.wSampleLink = binaryReader.Read16(); this.sfSampleType = (SFSampleLink)binaryReader.Read16(); }
} // see CreateInverse public Texture(ABinaryReader binaryReader) { Width = binaryReader.Read16(); Height = binaryReader.Read16(); Format = (TextureFormat)binaryReader.Read8(); Unk1 = binaryReader.Read8(); if (binaryReader.Read16() != 0) { throw new Exception("Texture.unk4 != 0"); } uint offset = binaryReader.Read32(); data = new Color[Width * Height]; binaryReader.Goto(offset); switch (Format) { case TextureFormat.I4: ReadI4(binaryReader); break; case TextureFormat.I8: ReadI8(binaryReader); break; case TextureFormat.IA4: ReadIA4(binaryReader); break; case TextureFormat.IA8: ReadIA8(binaryReader); break; case TextureFormat.RGB565: ReadRGB565(binaryReader); break; case TextureFormat.RGB5A3: ReadRGB5A3(binaryReader); break; case TextureFormat.RGBA8: ReadRGB8(binaryReader); break; case TextureFormat.CMP: ReadCMP(binaryReader); break; default: throw new NotImplementedException(String.Format("Encountered an indexed texture Format {0}, which aren't implemented.", Format)); } binaryReader.Back(); }
public Batch(ABinaryReader binaryReader) { FaceCount = binaryReader.Read16(); int size = (binaryReader.Read16() << 5); Attributes = (BatchAttributes)(uint)binaryReader.Read32(); UseNormals = (binaryReader.Read8() != 0); positions = binaryReader.Read8(); int uvCount = binaryReader.Read8(); UseNBT = (binaryReader.Read8() != 0); Offset = binaryReader.Read32(); if (binaryReader.Read8s(8).Any(zero => zero != 0)) { #if AROOKAS_DEMOLISHER_CHECKPADDING throw new Exception(String.Format("Batch padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position)); #endif } int faces = 0; List <Primitive> primitives = new List <Primitive>(); binaryReader.Goto(Offset); while (faces < FaceCount && binaryReader.Position < Offset + size) { Primitive primitive = new Primitive(binaryReader, UseNBT, uvCount, Attributes); if (!primitive.Type.IsDefined()) { break; } primitives.Add(primitive); faces += primitive.FaceCount; } binaryReader.Back(); this.primitives = primitives.ToArray(); }
// stupid f*****g C# public Shader(ABinaryReader binaryReader) : this() { unk1 = binaryReader.Read24(); Tint = Color.FromRGBA8(binaryReader.Read32()); unk2 = binaryReader.Read8(); MaterialIndex = binaryReader.ReadS16s(8); unk3 = binaryReader.ReadS16s(8); if (unk3[0] != 0 || unk3[1] != -1) { throw new System.Exception("shader unk3!!"); } }
public Shader(ABinaryReader binaryReader) : this() // stupid f*****g C# { unk1 = binaryReader.Read24(); Tint = Color.FromRGBA8(binaryReader.Read32()); unk2 = binaryReader.Read8(); MaterialIndex = binaryReader.ReadS16s(8); unk3 = binaryReader.ReadS16s(8); if (unk3[0] != 0 || unk3[1] != -1) { throw new System.Exception("shader unk3!!"); } }
public static bool IsCompressed(string fileName) { if (fileName == null) { throw new ArgumentNullException("bytes"); } using (ABinaryReader binaryReader = new ABinaryReader(File.OpenRead(fileName), Endianness.Big, Encoding.GetEncoding(932))) { if (binaryReader.Length < 0x10) { return(false); } return(binaryReader.Read32() == Identifier); } }
// Token: 0x06000155 RID: 341 RVA: 0x00004F50 File Offset: 0x00003150 public static MIDI FromStream(Stream stream) { ABinaryReader abinaryReader = new ABinaryReader(stream, Endianness.Big); MIDI midi = new MIDI(); if (abinaryReader.ReadRawString(4) != "MThd") { throw new InvalidDataException("Missing header chunk in MIDI file."); } if (abinaryReader.Read32() != 6U) { throw new InvalidDataException("Invalid header size in MIDI file."); } MIDIFormat enumValue = (MIDIFormat)abinaryReader.Read16(); if (!enumValue.IsDefined <MIDIFormat>()) { throw new InvalidDataException("Invalid format in MIDI file."); } abinaryReader.Read16(); int num = (int)abinaryReader.Read16(); if ((num & 32768) != 0) { midi.division = new SMPTEDivision((SMPTEFrameRate)(-(int)(num >> 8)), num & 255); // TODO: Cannot infer type, so: (ModularType) -> (int) } else { midi.division = new TicksPerBeatDivision(num); } int num2 = 0; while (!abinaryReader.IsAtEndOfStream) { if (abinaryReader.ReadRawString(4) != "MTrk") { throw new InvalidDataException("Missing track chunk in MIDI file."); } ulong num3 = 0UL; uint num4 = abinaryReader.Read32(); abinaryReader.SetAnchor(); Track track = new Track(); byte b = 0; while (abinaryReader.Position < (long)((ulong)num4)) { ulong num5 = abinaryReader.ReadUIntVar(); byte b2 = abinaryReader.Read8(); if (b2 < 128) { if (b == 0) { throw new InvalidDataException("Encountered running status event with no previous status available."); } b2 = b; abinaryReader.Position -= 1L; } if (b2 >= 240 && b2 <= 247) { b = 0; } else if (b2 >= 128 && b2 <= 239) { b = b2; } num3 += num5; if (b2 == 255) { MetaEventType metaEventType = (MetaEventType)abinaryReader.Read8(); int num6 = (int)abinaryReader.ReadUIntVar(); if (!metaEventType.IsDefined <MetaEventType>()) { throw new InvalidDataException(string.Format("Encountered unsupported meta event type {0}.", metaEventType)); } MetaEventType metaEventType2 = metaEventType; if (metaEventType2 <= MetaEventType.EndOfTrack) { switch (metaEventType2) { case MetaEventType.SequenceNumber: if (num6 != 2) { throw new InvalidDataException("Invalid size in sequence-number event."); } track.Add(new SequenceNumberEvent(num5, (int)abinaryReader.Read16()), num3); continue; case MetaEventType.Text: track.Add(new TextEvent(num5, abinaryReader.ReadRawString(num6)), num3); continue; case MetaEventType.CopyrightNotice: track.Add(new CopyrightNoticeEvent(num5, abinaryReader.ReadRawString(num6)), num3); continue; case MetaEventType.Name: track.Add(new TrackNameEvent(num5, abinaryReader.ReadRawString(num6)), num3); continue; case MetaEventType.InstrumentName: track.Add(new InstrumentNameEvent(num5, abinaryReader.ReadRawString(num6)), num3); continue; case MetaEventType.Lyrics: track.Add(new LyricsEvent(num5, abinaryReader.ReadRawString(num6)), num3); continue; case MetaEventType.Marker: track.Add(new MarkerEvent(num5, abinaryReader.ReadRawString(num6)), num3); continue; case MetaEventType.CuePoint: track.Add(new CuePointEvent(num5, abinaryReader.ReadRawString(num6)), num3); continue; default: if (metaEventType2 != MetaEventType.ChannelPrefix) { if (metaEventType2 == MetaEventType.EndOfTrack) { if (num6 != 0) { throw new InvalidDataException("Invalid size in end-of-track event."); } track.Add(new EndOfTrackEvent(num5), num3); continue; } } else { if (num6 != 1) { throw new InvalidDataException("Invalid size in channel-prefix event."); } track.Add(new ChannelPrefixEvent(num5, abinaryReader.Read8()), num3); continue; } break; } } else if (metaEventType2 != MetaEventType.TempoChange) { switch (metaEventType2) { case MetaEventType.TimeSignature: if (num6 != 4) { throw new InvalidDataException("Invalid size in time-signature event."); } track.Add(new TimeSignatureEvent(num5, (int)abinaryReader.Read8(), (int)abinaryReader.Read8(), (int)abinaryReader.Read8(), (int)abinaryReader.Read8()), num3); continue; case MetaEventType.KeySignature: if (num6 != 2) { throw new InvalidDataException("Invalid size in key-signature event."); } track.Add(new KeySignatureEvent(num5, (int)abinaryReader.ReadS8(), (Scale)abinaryReader.Read8()), num3); continue; default: if (metaEventType2 == MetaEventType.SequencerSpecific) { byte[] array = abinaryReader.Read8s(num6); if (num6 == 0 || num6 < ((array[0] == 0) ? 3 : 1)) { throw new InvalidDataException("Invalid size in sequencer-specific event."); } bool flag = array[0] == 0; int manufacturerID = flag ? ((int)array[1] << 8 | (int)array[2]) : ((int)array[0]); track.Add(new SequencerSpecificEvent(num5, manufacturerID, flag, array.Duplicate(flag ? 3 : 1, array.Length - (flag ? 3 : 1))), num3); continue; } break; } } else { if (num6 != 3) { throw new InvalidDataException("Invalid size in tempo-change event."); } track.Add(new TempoChangeEvent(num5, abinaryReader.Read24()), num3); continue; } throw new NotImplementedException(string.Format("Encountered unimplemented meta event type {0}.", metaEventType)); } else if (b2 == 240 || b2 == 247) { byte[] array2 = abinaryReader.Read8s((int)abinaryReader.ReadUIntVar()); if (array2.Length == 0 || array2.Length < ((array2[0] == 0) ? 3 : 1)) { throw new InvalidDataException("Encountered a SysEx event with an invalid size."); } SystemExclusiveEventType type = SystemExclusiveEventType.Normal; bool flag2 = b2 == 247; bool flag3 = array2.Last <byte>() == 247; bool flag4 = array2[0] == 0; int manufacturerID2 = flag4 ? ((int)array2[1] << 8 | (int)array2[2]) : ((int)array2[0]); if (flag2) { type = (flag3 ? SystemExclusiveEventType.Terminating : SystemExclusiveEventType.Continuation); } if (flag3) { array2 = array2.Duplicate(array2.Length - 1); } track.Add(new SystemExclusiveEvent(num5, type, manufacturerID2, flag4, array2), num3); } else { ChannelEventType channelEventType = (ChannelEventType)(b2 & 240); byte channelNumber = (byte)(b2 & 15); if (!channelEventType.IsDefined <ChannelEventType>()) { throw new InvalidDataException(string.Format("Encountered undefined channel-event type {0}.", channelEventType)); } ChannelEventType channelEventType2 = channelEventType; if (channelEventType2 <= ChannelEventType.NoteAftertouch) { if (channelEventType2 == ChannelEventType.NoteOff) { track.Add(new NoteOffEvent(num5, (int)channelNumber, abinaryReader.Read8(), (int)abinaryReader.Read8()), num3); continue; } if (channelEventType2 == ChannelEventType.NoteOn) { track.Add(new NoteOnEvent(num5, (int)channelNumber, (int)abinaryReader.Read8(), (int)abinaryReader.Read8()), num3); continue; } if (channelEventType2 == ChannelEventType.NoteAftertouch) { track.Add(new NoteAftertouchEvent(num5, (int)channelNumber, (int)abinaryReader.Read8(), (int)abinaryReader.Read8()), num3); continue; } } else if (channelEventType2 <= ChannelEventType.ProgramChange) { if (channelEventType2 == ChannelEventType.Controller) { track.Add(new ControllerEvent(num5, (int)channelNumber, (int)abinaryReader.Read8(), (int)abinaryReader.Read8()), num3); continue; } if (channelEventType2 == ChannelEventType.ProgramChange) { track.Add(new ProgramChangeEvent(num5, (int)channelNumber, (int)abinaryReader.Read8()), num3); continue; } } else { if (channelEventType2 == ChannelEventType.ChannelAftertouch) { track.Add(new ChannelAftertouchEvent(num5, (int)channelNumber, (int)abinaryReader.Read8()), num3); continue; } if (channelEventType2 == ChannelEventType.PitchBend) { track.Add(new PitchBendEvent(num5, (int)channelNumber, (int)(abinaryReader.Read8() & 127) | (int)(abinaryReader.Read8() & 127) << 7), num3); continue; } } throw new NotImplementedException(string.Format("Encountered unimplemented channel event type {0}.", channelEventType)); } } midi.tracks.Add(track); abinaryReader.ResetAnchor(); num2++; } return(midi); }
public static bool IsCompressed(string fileName) { if (fileName == null) { throw new ArgumentNullException("bytes"); } using (ABinaryReader binaryReader = new ABinaryReader(File.OpenRead(fileName), Endianness.Big, Encoding.GetEncoding(932))) { if (binaryReader.Length < 0x10) { return false; } return binaryReader.Read32() == Identifier; } }