public ObcdBlock Read(ScummBlockHeader header, ScummBinaryReader reader)
        {
            var result = new ObcdBlock
            {
                Header = header
            };

            long endIndex = reader.BaseStream.Position + result.Header.ContentLength;
            while (reader.BaseStream.Position < endIndex)
            {
                var childHeader = reader.ReadBlockHeader();
                switch (childHeader.HeaderName)
                {
                    case "CDHD":
                        //if (result.Room != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        reader.BaseStream.Seek(childHeader.ContentLength, SeekOrigin.Current);
                        break;
                    case "VERB":
                        if (result.Verb != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.Verb = new VerbReader().Read(childHeader, reader);
                        break;
                    case "OBNA":
                        if (result.Name != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        var bytes = reader.ReadBytes((int)childHeader.ContentLength);
                        result.Name = System.Text.Encoding.ASCII.GetString(bytes);
                        result.Name = result.Name.TrimEnd('\0');
                        break;
                    default:
                        throw new UnexpectedObjectScriptBlockException(childHeader.HeaderName);
                }
            }
            return result;
        }
Example #2
0
        public LflfBlock Read(ScummBinaryReader reader)
        {
            var result = new LflfBlock
            {
                Header = reader.ReadBlockHeader()
            };

            long endIndex = reader.BaseStream.Position + result.Header.ContentLength;

            while (reader.BaseStream.Position < endIndex)
            {
                var childHeader = reader.ReadBlockHeader();
                switch (childHeader.HeaderName)
                {
                case "ROOM":
                    if (result.Room != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.Room = new RoomReader().Read(childHeader, reader);
                    break;

                case "SCRP":
                    result.Scripts.Add(new ScriptReader().Read(childHeader, reader));
                    break;

                case "SOUN":
                    result.Sounds.Add(new SoundReader().Read(childHeader, reader));
                    break;

                case "COST":
                    result.Costumes.Add(new CostumeReader().Read(childHeader, reader));
                    break;

                case "CHAR":
                    result.Charsets.Add(new CharsetReader().Read(childHeader, reader));
                    break;

                default:
                    throw new UnexpectedBlockException(childHeader.HeaderName);
                }
            }
            return(result);
        }
Example #3
0
 public ScummBlock Read(ScummBinaryReader reader)
 {
     var header = reader.ReadBlockHeader();
     var numRooms = reader.ReadByte();
     return new LoffBlock
     {
         Header = header,
         NumRooms = numRooms,
         RoomOffsets = ReadRoomOffsets(reader, numRooms)
     };
 }
Example #4
0
        private ScummFile Read(ScummBinaryReader reader)
        {
            var result = new ScummFile
            {
                Header = reader.ReadBlockHeader(),
                LoffBlock = (LoffBlock)new LoffReader().Read(reader),
                LflfBlocks = ReadLflfRecords(reader)
            };

            return result;
        }
Example #5
0
        private ScummFile Read(ScummBinaryReader reader)
        {
            var result = new ScummFile
            {
                Header     = reader.ReadBlockHeader(),
                LoffBlock  = (LoffBlock) new LoffReader().Read(reader),
                LflfBlocks = ReadLflfRecords(reader)
            };

            return(result);
        }
Example #6
0
        public ScummBlock Read(ScummBinaryReader reader)
        {
            var header   = reader.ReadBlockHeader();
            var numRooms = reader.ReadByte();

            return(new LoffBlock
            {
                Header = header,
                NumRooms = numRooms,
                RoomOffsets = ReadRoomOffsets(reader, numRooms)
            });
        }
        public ObcdBlock Read(ScummBlockHeader header, ScummBinaryReader reader)
        {
            var result = new ObcdBlock
            {
                Header = header
            };

            long endIndex = reader.BaseStream.Position + result.Header.ContentLength;

            while (reader.BaseStream.Position < endIndex)
            {
                var childHeader = reader.ReadBlockHeader();
                switch (childHeader.HeaderName)
                {
                case "CDHD":
                    //if (result.Room != null) throw new DuplicateBlockException(childHeader.HeaderName);
                    reader.BaseStream.Seek(childHeader.ContentLength, SeekOrigin.Current);
                    break;

                case "VERB":
                    if (result.Verb != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.Verb = new VerbReader().Read(childHeader, reader);
                    break;

                case "OBNA":
                    if (result.Name != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    var bytes = reader.ReadBytes((int)childHeader.ContentLength);
                    result.Name = System.Text.Encoding.ASCII.GetString(bytes);
                    result.Name = result.Name.TrimEnd('\0');
                    break;

                default:
                    throw new UnexpectedObjectScriptBlockException(childHeader.HeaderName);
                }
            }
            return(result);
        }
Example #8
0
        public RoomBlock Read(ScummBlockHeader header, ScummBinaryReader reader)
        {
            var result = new RoomBlock
            {
                Header = header
            };

            long endIndex = reader.BaseStream.Position + result.Header.ContentLength;
            while (reader.BaseStream.Position < endIndex)
            {
                var childHeader = reader.ReadBlockHeader();
                switch (childHeader.HeaderName)
                {
                    case "RMHD":
                        if (result.RoomHeader != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.RoomHeader = new RoomHeaderReader().Read(childHeader, reader);
                        break;
                    case "EPAL":
                        if (result.EgaPalette != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.EgaPalette = new EgaPaletteReader().Read(childHeader, reader);
                        break;
                    case "CLUT":
                        if (result.Clut != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.Clut = new ClutReader().Read(childHeader, reader);
                        break;
                    case "CYCL":
                        if (result.ColorCycle != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.ColorCycle = new ColorCycleReader().Read(childHeader, reader);
                        break;
                    case "TRNS":
                        if (result.Transparent != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.Transparent = new TransparentReader().Read(childHeader, reader);
                        break;
                    case "PALS":
                        if (result.Palette != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.Palette = new PaletteReader().Read(childHeader, reader);
                        break;
                    case "RMIM":
                        if (result.RoomImage != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.RoomImage = new RoomImageReader().Read(childHeader, reader);
                        break;
                    case "OBIM":
                        result.ObjImages.Add(new ObjImageReader().Read(childHeader, reader));
                        break;
                    case "OBCD":
                        result.ObjectScripts.Add(new ObjectScriptReader().Read(childHeader, reader));
                        break;
                    case "EXCD":
                        if (result.ExitScript != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.ExitScript = new ExitScriptReader().Read(childHeader, reader);
                        break;
                    case "ENCD":
                        if (result.EntryScript != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.EntryScript = new EntryScriptReader().Read(childHeader, reader);
                        break;
                    case "NLSC":
                        if (result.NumScripts != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.NumScripts = new NumScriptsReader().Read(childHeader, reader);
                        break;
                    case "LSCR":
                        result.LocalScripts.Add(new LocalScriptReader().Read(childHeader, reader));
                        break;
                    case "BOXD":
                        if (result.BoxData != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.BoxData = new BoxDataReader().Read(childHeader, reader);
                        break;
                    case "BOXM":
                        if (result.BoxMatrix != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.BoxMatrix = new BoxMatrixReader().Read(childHeader, reader);
                        break;
                    case "SCAL":
                        if (result.ScaleSlots != null) throw new DuplicateBlockException(childHeader.HeaderName);
                        result.ScaleSlots = new ScaleSlotsReader().Read(childHeader, reader);
                        break;
                    default:
                        throw new UnexpectedRoomBlockException(childHeader.HeaderName);
                }
            }
            return result;
        }
Example #9
0
        public RoomBlock Read(ScummBlockHeader header, ScummBinaryReader reader)
        {
            var result = new RoomBlock
            {
                Header = header
            };

            long endIndex = reader.BaseStream.Position + result.Header.ContentLength;

            while (reader.BaseStream.Position < endIndex)
            {
                var childHeader = reader.ReadBlockHeader();
                switch (childHeader.HeaderName)
                {
                case "RMHD":
                    if (result.RoomHeader != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.RoomHeader = new RoomHeaderReader().Read(childHeader, reader);
                    break;

                case "EPAL":
                    if (result.EgaPalette != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.EgaPalette = new EgaPaletteReader().Read(childHeader, reader);
                    break;

                case "CLUT":
                    if (result.Clut != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.Clut = new ClutReader().Read(childHeader, reader);
                    break;

                case "CYCL":
                    if (result.ColorCycle != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.ColorCycle = new ColorCycleReader().Read(childHeader, reader);
                    break;

                case "TRNS":
                    if (result.Transparent != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.Transparent = new TransparentReader().Read(childHeader, reader);
                    break;

                case "PALS":
                    if (result.Palette != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.Palette = new PaletteReader().Read(childHeader, reader);
                    break;

                case "RMIM":
                    if (result.RoomImage != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.RoomImage = new RoomImageReader().Read(childHeader, reader);
                    break;

                case "OBIM":
                    result.ObjImages.Add(new ObjImageReader().Read(childHeader, reader));
                    break;

                case "OBCD":
                    result.ObjectScripts.Add(new ObjectScriptReader().Read(childHeader, reader));
                    break;

                case "EXCD":
                    if (result.ExitScript != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.ExitScript = new ExitScriptReader().Read(childHeader, reader);
                    break;

                case "ENCD":
                    if (result.EntryScript != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.EntryScript = new EntryScriptReader().Read(childHeader, reader);
                    break;

                case "NLSC":
                    if (result.NumScripts != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.NumScripts = new NumScriptsReader().Read(childHeader, reader);
                    break;

                case "LSCR":
                    result.LocalScripts.Add(new LocalScriptReader().Read(childHeader, reader));
                    break;

                case "BOXD":
                    if (result.BoxData != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.BoxData = new BoxDataReader().Read(childHeader, reader);
                    break;

                case "BOXM":
                    if (result.BoxMatrix != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.BoxMatrix = new BoxMatrixReader().Read(childHeader, reader);
                    break;

                case "SCAL":
                    if (result.ScaleSlots != null)
                    {
                        throw new DuplicateBlockException(childHeader.HeaderName);
                    }
                    result.ScaleSlots = new ScaleSlotsReader().Read(childHeader, reader);
                    break;

                default:
                    throw new UnexpectedRoomBlockException(childHeader.HeaderName);
                }
            }
            return(result);
        }