Inheritance: ImageData
Beispiel #1
0
 public override ImageData Clone()
 {
     var data = new ImageData1 { IsBomp = IsBomp };
     data.Data = new byte[Data.Length];
     Array.Copy(Data, data.Data, Data.Length);
     foreach (var zplane in ZPlanes)
     {
         data.ZPlanes.Add(zplane.Clone());
     }
     Array.Copy(Colors, data.Colors, Colors.Length);
     Array.Copy(CharMap, data.CharMap, CharMap.Length);
     Array.Copy(ObjectMap, data.ObjectMap, ObjectMap.Length);
     Array.Copy(PicMap, data.PicMap, PicMap.Length);
     Array.Copy(ColorMap, data.ColorMap, ColorMap.Length);
     Array.Copy(MaskMap, data.MaskMap, MaskMap.Length);
     Array.Copy(MaskChar, data.MaskChar, MaskChar.Length);
     return data;
 }
Beispiel #2
0
        public override ImageData Clone()
        {
            var data = new ImageData1 {
                IsBomp = IsBomp
            };

            data.Data = new byte[Data.Length];
            Array.Copy(Data, data.Data, Data.Length);
            foreach (var zplane in ZPlanes)
            {
                data.ZPlanes.Add(zplane.Clone());
            }
            Array.Copy(Colors, data.Colors, Colors.Length);
            Array.Copy(CharMap, data.CharMap, CharMap.Length);
            Array.Copy(ObjectMap, data.ObjectMap, ObjectMap.Length);
            Array.Copy(PicMap, data.PicMap, PicMap.Length);
            Array.Copy(ColorMap, data.ColorMap, ColorMap.Length);
            Array.Copy(MaskMap, data.MaskMap, MaskMap.Length);
            Array.Copy(MaskChar, data.MaskChar, MaskChar.Length);
            return(data);
        }
Beispiel #3
0
        public override Room ReadRoom(long offset)
        {
            _reader.BaseStream.Seek(offset, SeekOrigin.Begin);
            var size = _reader.ReadUInt16();
            var tmp = _reader.ReadBytes(2);
            var header = ReadRMHD();

            var room = new Room { Header = header, Size = size };

            // 6
            var img = new ImageData1();
            room.Image = img;
            img.Colors = _reader.ReadBytes(4);
            var charmapOffset = _reader.ReadUInt16();
            var picMapOffset = _reader.ReadUInt16();
            var colorMapOffset = _reader.ReadUInt16();
            var maskMapOffset = _reader.ReadUInt16();
            var maskOffset = _reader.ReadUInt16();

            // 20
            var numObjects = _reader.ReadByte();
            // 21
            var boxesOffset = _reader.ReadByte();
            // 22
            var numSounds = _reader.ReadByte();
            // 23
            var numScripts = _reader.ReadByte();
            // 24
            var exitScriptOffset = _reader.ReadUInt16();
            // 26
            var entryScriptOffset = _reader.ReadUInt16();
            var exitScriptLength = entryScriptOffset - entryScriptOffset;
            var entryScriptLength = size - entryScriptOffset;
            // 28
            var objImgOffsets = _reader.ReadUInt16s(numObjects);
            var objScriptOffsets = _reader.ReadUInt16s(numObjects);
            // load sounds
            var soundIds = _reader.ReadBytes(numSounds);
            // load scripts
            var scriptIds = _reader.ReadBytes(numScripts);

            var width = header.Width / 8;
            var height = header.Height / 8;
            DecodeV1Gfx(offset + charmapOffset, img.CharMap, 2048);
            DecodeV1Gfx(offset + picMapOffset, img.PicMap, width * height);
            DecodeV1Gfx(offset + colorMapOffset, img.ColorMap, width * height);
            DecodeV1Gfx(offset + maskMapOffset, img.MaskMap, width * height);

            // Read the mask data. The 16bit length value seems to always be 8 too big.
            // See bug #1837375 for details on this.
            _reader.BaseStream.Seek(offset + maskOffset, SeekOrigin.Begin);
            DecodeV1Gfx(offset + maskOffset + 2, img.MaskChar, _reader.ReadUInt16() - 8);

            // read exit script
            if (exitScriptOffset > 0)
            {
                room.ExitScript.Data = ReadBytes(offset + exitScriptOffset, exitScriptLength);
            }
            else
            {
                room.ExitScript.Data = new byte[0];
            }

            // read entry script
            if (entryScriptOffset > 0)
            {
                room.EntryScript.Data = ReadBytes(offset + entryScriptOffset, entryScriptLength);
            }
            else
            {
                room.EntryScript.Data = new byte[0];
            }

            // read boxes
            ReadBoxes(offset + boxesOffset, room);

            // read objects
            if (numObjects > 0)
            {
                var firstOffset = objScriptOffsets.Min();
                for (var i = 0; i < numObjects; i++)
                {
                    var objOffset = objScriptOffsets[i];
                    var obj = ReadObject(offset + objOffset);
                    room.Objects.Add(obj);
                }

                for (var i = 0; i < numObjects; i++)
                {
                    var objImgOffset = objImgOffsets[i];
                    if (firstOffset != objImgOffset)
                    {
                        img = new ImageData1();
                        var obj = room.Objects[i];
                        DecodeV1Gfx(offset + objImgOffset, img.ObjectMap, (obj.Width / 8) * (obj.Height / 8) * 3);
                        obj.Images.Add(img);
                    }
                }
            }

            return room;
        }
Beispiel #4
0
 public override void RoomChanged(Room room)
 {
     _v1 = room.Image as ImageData1;
     _objectMode = true;
 }
Beispiel #5
0
 public override void RoomChanged(Room room)
 {
     _v1         = room.Image as ImageData1;
     _objectMode = true;
 }