public static void Hello() { Stack <object> .Hello(); ChunkMap.Hello(); }
void SetUp(byte[] data) { var WBIN = "WBIN"; int startoffs = 0; byte[] offbytes; cnt++; Chunks = new ChunkMap(this); if (data.Length < 12) { throw new ExWendickaBinTooShort(); } for (int i = 0; i < 4; i++) { if ((char)data[(data.Length - 12) + i] != WBIN[i]) { throw new ExWendickaNotRecognized(); } if ((char)data[(data.Length - 4) + i] != WBIN[i]) { throw new ExWendickaNotRecognized(); } } offbytes = new byte[4] { data[(data.Length - 8)], data[(data.Length - 7)], data[(data.Length - 6)], data[(data.Length - 5)] }; if (!BitConverter.IsLittleEndian) { Array.Reverse(offbytes); } startoffs = (data.Length - BitConverter.ToInt32(offbytes, 0)) - 4; #if QCLI && DEBUG foreach (byte b in offbytes) { Console.Write($"{b.ToString("X")}.{b}.{(char)b};\t"); } Console.WriteLine($"{BitConverter.ToInt32(offbytes, 0)} / {data.Length} / {startoffs}"); #endif if (startoffs < 0 || startoffs > data.Length - 12) { throw new ExWendickaFalseBineryOffset(startoffs); } var bt = QuickStream.StreamFromBytes(data); do { } while (bt.ReadByte() != 26); //var bitMain = bt.ReadByte(); //var bitInst = bt.ReadByte(); //if (bitMain != 1 || bitInst != 1) throw new ExWendickaNotYetSupported($"Tagging other than 8 bit ({bitMain}/{bitInst})"); Chunk CChunk; string ChunkName = ""; long ChunkStart; long ChunkPos() => bt.Position - ChunkStart; long ChunkLength; long ChunkEnd; void ChunkCheck(Chunk.Instruction.Param.DataKind i) { if (CChunk == null || ChunkName == "") { throw new ExWendickaChunkless($"{i}", bt.Position); } } Chunk.Instruction.Param.DataKind GetTag() => (Chunk.Instruction.Param.DataKind)bt.ReadByte(); do { var tag = GetTag(); Chat($"MainTag: {tag} / {(byte)tag}"); switch (tag) { case Chunk.Instruction.Param.DataKind.Einde: goto escape; case Chunk.Instruction.Param.DataKind.StartChunk: { byte ChuTag = bt.ReadByte(); while (ChuTag != 0) { Chat($"NEWCHUNK.TAG: {ChuTag}"); switch (ChuTag) { case 0: break; // Should never happen! case 1: ChunkName = bt.ReadString().ToUpper(); Chat($"NEWCHUNK: {ChunkName}"); CChunk = Chunks[ChunkName]; break; case 2: ChunkStart = bt.Position; ChunkLength = (long)bt.ReadInt(); ChunkEnd = ChunkStart + ChunkLength; if (ChunkStart < 0 || ChunkEnd > bt.Size) { throw new ExWendickaIllegalChunkSize(ChunkName, ChunkStart, ChunkLength, ChunkEnd); } break; } ChuTag = bt.ReadByte(); } } var bitMain = bt.ReadByte(); var bitInst = bt.ReadByte(); if (bitMain != 8 || bitInst != 8) { throw new ExWendickaNotYetSupported($"Tagging other than 8 bit ({bitMain}/{bitInst})"); } break; default: throw new ExWendickaNotYetSupported($"Main tag {tag}({(byte)tag})"); } } while (true); escape: bt.Close(); }
internal Chunk(ChunkMap Parent) { this.Parent = Parent; }