示例#1
0
            static List <PicturePatternDrawLocation> ReadPositions(Stream stream, PictureOpcode opcode, PicturePatternFlags patternFlags, ref byte patternNumber)
            {
                List <PicturePatternDrawLocation> list = new List <PicturePatternDrawLocation>();
                Vector2i position;

                ReadPatternNumber(stream, patternFlags, ref patternNumber);
                position = ReadAbsoluteCoordinates(stream);
                list.Add(new PicturePatternDrawLocation(patternNumber, position));

                while (PeekContinue(stream))
                {
                    ReadPatternNumber(stream, patternFlags, ref patternNumber);

                    switch (opcode)
                    {
                    case PictureOpcode.DrawRelativePatterns: position = ReadShortRelativeCoordinates(stream, position); break;

                    case PictureOpcode.DrawAbsolutePatterns: position = ReadAbsoluteCoordinates(stream); break;

                    case PictureOpcode.DrawRelativeMediumPatterns: position = ReadMediumRelativeCoordinates(stream, position); break;

                    default: throw new NotSupportedException();
                    }
                    list.Add(new PicturePatternDrawLocation(patternNumber, position));
                }
                return(list);
            }
示例#2
0
 /// <summary>Initialise the instruction.</summary>
 /// <param name="opcode"></param>
 /// <param name="patternFlags"></param>
 /// <param name="drawLocations"></param>
 public DrawPatterns(PictureOpcode opcode, PicturePatternFlags patternFlags, List <PicturePatternDrawLocation> drawLocations)
     : base(opcode)
 {
     if (drawLocations == null)
     {
         throw new ArgumentNullException("drawLocations");
     }
     this.PatternFlags  = patternFlags;
     this.DrawLocations = drawLocations;
 }
示例#3
0
        /// <summary>Read an instruction from the stream.</summary>
        /// <param name="stream"></param>
        /// <param name="patternFlags"></param>
        /// <param name="patternNumber"></param>
        /// <returns></returns>
        public static PictureInstruction ReadInstruction(Stream stream, ref PicturePatternFlags patternFlags, ref byte patternNumber)
        {
            PictureOpcode opcode = (PictureOpcode)ReadByte(stream);

            switch (opcode)
            {
            case PictureOpcode.SetColor: return(new SetColor(stream));

            case PictureOpcode.DisableVisual: return(new DisableVisual());

            case PictureOpcode.SetPriority: return(new SetPriority(stream));

            case PictureOpcode.DisablePriority: return(new DisablePriority());

            case PictureOpcode.DrawFloodfill: return(new DrawFloodfill(stream));

            case PictureOpcode.SetPatternFlags: return(new SetPatternFlags(stream, ref patternFlags));

            case PictureOpcode.SetControl: return(new SetControl(stream));

            case PictureOpcode.DisableControl: return(new DisableControl());

            case PictureOpcode.DrawRelativeMediumLines:
            case PictureOpcode.DrawRelativeLongLines:
            case PictureOpcode.DrawRelativeShortLines: return(new DrawLines(opcode, stream));

            case PictureOpcode.DrawRelativeMediumPatterns:
            case PictureOpcode.DrawRelativePatterns:
            case PictureOpcode.DrawAbsolutePatterns: return(new DrawPatterns(opcode, stream, patternFlags, ref patternNumber));

            case PictureOpcode.ExtendedOpcode:
                var extendedOpcode = (PictureExtendedOpcode)ReadByte(stream);
                switch (extendedOpcode)
                {
                case PictureExtendedOpcode.SetPaletteEntry:
                case PictureExtendedOpcode.SetPalette: return(new SetPalette(stream, extendedOpcode));

                case PictureExtendedOpcode.Mono0: return(new Mono0(stream));

                case PictureExtendedOpcode.Mono1:
                case PictureExtendedOpcode.Mono2:
                case PictureExtendedOpcode.Mono3: return(new Mono123(stream, extendedOpcode));

                default: throw new Exception(String.Format("Unknown extended opcode 0x{0:X2} ({1})", (int)opcode, opcode));
                }

            case PictureOpcode.Quit: return(new Quit());

            default: throw new Exception(String.Format("Unknown opcode 0x{0:X2} ({1}).", (int)opcode, opcode));
            }
        }
示例#4
0
            /// <summary>Initialise the instruction.</summary>
            /// <param name="opcode"></param>
            /// <param name="stream"></param>
            public DrawLines(PictureOpcode opcode, Stream stream)
                : base(opcode)
            {
                Points = new List <Vector2i>();
                Start  = ReadAbsoluteCoordinates(stream);

                Vector2i point = Start;

                while (PeekContinue(stream))
                {
                    switch (opcode)
                    {
                    case PictureOpcode.DrawRelativeMediumLines: point = ReadMediumRelativeCoordinates(stream, point); break;

                    case PictureOpcode.DrawRelativeLongLines: point = ReadAbsoluteCoordinates(stream); break;

                    case PictureOpcode.DrawRelativeShortLines: point = ReadShortRelativeCoordinates(stream, point); break;

                    default: throw new NotSupportedException();
                    }
                    Points.Add(point);
                }
            }
示例#5
0
 /// <summary>Initialise the instruction.</summary>
 /// <param name="opcode"></param>
 public PictureInstruction(PictureOpcode opcode)
 {
     Opcode         = opcode;
     ExtendedOpcode = null;
 }
示例#6
0
 /// <summary>Initialise the instruction.</summary>
 /// <param name="opcode"></param>
 /// <param name="stream"></param>
 /// <param name="patternFlags"></param>
 /// <param name="patternNumber"></param>
 public DrawPatterns(PictureOpcode opcode, Stream stream, PicturePatternFlags patternFlags, ref byte patternNumber)
     : this(opcode, patternFlags, ReadPositions(stream, opcode, patternFlags, ref patternNumber))
 {
 }
 /// <summary>Initialise the instruction.</summary>
 /// <param name="opcode"></param>
 public PictureInstruction(PictureOpcode opcode)
 {
     Opcode = opcode;
     ExtendedOpcode = null;
 }
            static List<PicturePatternDrawLocation> ReadPositions(Stream stream, PictureOpcode opcode, PicturePatternFlags patternFlags, ref byte patternNumber)
            {
                List<PicturePatternDrawLocation> list = new List<PicturePatternDrawLocation>();
                Vector2i position;

                ReadPatternNumber(stream, patternFlags, ref patternNumber);
                position = ReadAbsoluteCoordinates(stream);
                list.Add(new PicturePatternDrawLocation(patternNumber, position));

                while (PeekContinue(stream)) {
                    ReadPatternNumber(stream, patternFlags, ref patternNumber);

                    switch (opcode) {
                        case PictureOpcode.DrawRelativePatterns: position = ReadShortRelativeCoordinates(stream, position); break;
                        case PictureOpcode.DrawAbsolutePatterns: position = ReadAbsoluteCoordinates(stream); break;
                        case PictureOpcode.DrawRelativeMediumPatterns: position = ReadMediumRelativeCoordinates(stream, position); break;
                        default: throw new NotSupportedException();
                    }
                    list.Add(new PicturePatternDrawLocation(patternNumber, position));
                }
                return list;
            }
 /// <summary>Initialise the instruction.</summary>
 /// <param name="opcode"></param>
 /// <param name="patternFlags"></param>
 /// <param name="drawLocations"></param>
 public DrawPatterns(PictureOpcode opcode, PicturePatternFlags patternFlags, List<PicturePatternDrawLocation> drawLocations)
     : base(opcode)
 {
     if (drawLocations == null)
         throw new ArgumentNullException("drawLocations");
     this.PatternFlags = patternFlags;
     this.DrawLocations = drawLocations;
 }
 /// <summary>Initialise the instruction.</summary>
 /// <param name="opcode"></param>
 /// <param name="stream"></param>
 /// <param name="patternFlags"></param>
 /// <param name="patternNumber"></param>
 public DrawPatterns(PictureOpcode opcode, Stream stream, PicturePatternFlags patternFlags, ref byte patternNumber)
     : this(opcode, patternFlags, ReadPositions(stream, opcode, patternFlags, ref patternNumber))
 {
 }
            /// <summary>Initialise the instruction.</summary>
            /// <param name="opcode"></param>
            /// <param name="stream"></param>
            public DrawLines(PictureOpcode opcode, Stream stream)
                : base(opcode)
            {
                Points = new List<Vector2i>();
                Start = ReadAbsoluteCoordinates(stream);

                Vector2i point = Start;

                while (PeekContinue(stream)) {
                    switch (opcode) {
                        case PictureOpcode.DrawRelativeMediumLines: point = ReadMediumRelativeCoordinates(stream, point); break;
                        case PictureOpcode.DrawRelativeLongLines: point = ReadAbsoluteCoordinates(stream); break;
                        case PictureOpcode.DrawRelativeShortLines: point = ReadShortRelativeCoordinates(stream, point); break;
                        default: throw new NotSupportedException();
                    }
                    Points.Add(point);
                }
            }