public static bool MyInit() { if (ClassicData != null) { return(true); } //d2 = true; string dir = "c:\\games\\d1x-rebirth\\data"; string d2dir = "c:\\games\\descent2"; string hogFile = Path.Combine(dir, "descent.hog"), palFile = "palette.256"; if (d2) { hogFile = Path.Combine(d2dir, "descent2.hog"); palFile = "groupa.256"; } hog = new Hog(hogFile); byte[] vgapal = hog.ItemData(palFile); pal = ClassicLoader.VgaPalConv(vgapal); pal32 = new Color32[256]; for (int i = 0; i < 256; i++) { pal32[i] = new Color32(pal[i * 3], pal[i * 3 + 1], pal[i * 3 + 2], 255); } palu = new uint[256]; for (int i = 0; i < 256; i++) { palu[i] = ((uint)pal[i * 3] << 0) | ((uint)pal[i * 3 + 1] << 8) | ((uint)pal[i * 3 + 2] << 16) | (255u << 24); } var pigFile = Path.Combine(dir, "descent.pig"); if (d2) { pigFile = Path.Combine(d2dir, "groupa.pig"); } pig = new Pig(pigFile); if (d2) { pig.ReadD2Sound(Path.Combine(d2dir, "descent2.s11")); byte[] data = File.ReadAllBytes(Path.Combine(d2dir, "descent2.ham")); ClassicData = new ClassicData(); ClassicData.Read(new BinaryReader(new MemoryStream(data, 8, data.Length - 8)), Version.D2); } else { pig.ReadTableData(out ClassicData); } shader = Shader.Find("Standard"); //shader = Shader.Find("Diffuse"); return(true); }
public void ReadTableData(out ClassicData v) { v = new ClassicData(); v.Read(new BinaryReader(new MemoryStream(data, 4, Bits.GetInt32(data, 0) - 4))); }