Exemplo n.º 1
0
 //public bool IsEmpty { get { return level == null; } }
 /// <summary>
 /// Creates a new empty structure object.
 /// </summary>
 /// <param name="level"></param>
 private Structure(int index, Level level)
 {
     this.level = level;
     this.Index = index;
     data       = new StructureData(this);
     data.ClearToEmpty();
     data[0, 0] = 0x00;
     CalculateRomBytes();
 }
Exemplo n.º 2
0
        public void LoadData(Stream s)
        {
            if (EditInProgress)
            {
                throw new InvalidOperationException("Attempted to perform a LoadData operation while an edit operation is in progress.");
            }

            data.ClearToEmpty();

            int  y             = 0;
            Byte rowDescriptor = 0;

            while (y < 16 && (rowDescriptor = (byte)s.ReadByte()) != StructTerminator)
            {
                // The row descriptor byte contains both the x-coordinate and length.
                int x     = rowDescriptor / 16;
                int count = rowDescriptor % 16;
                if (count == 0)
                {
                    count = 16;             // A value of zero is a special case, indicates a length of 16
                }
                // Bytes will be copied to buffer
                while (x < 16 && count > 0)
                {
                    data[x, y] = (byte)s.ReadByte();
                    x++;
                    count--;
                }
                // Any remaining bytes are erroneous but will be read so that following structs can be properly loaded.
                while (count > 0)
                {
                    s.ReadByte();
                    count--;
                }

                y++;
            }

            FinalizeEdit();
        }