Esempio n. 1
0
        public FilterBase(IZMachineIO next)
        {
            if (next == null)
                throw new ArgumentNullException("primary");

            this.next = next;
        }
Esempio n. 2
0
        public TeeFilter(IZMachineIO next, IZMachineIO side)
            : base(next)
        {
            if (side == null)
                throw new ArgumentNullException("side");

            this.side = side;
        }
Esempio n. 3
0
        public FilterBase(IZMachineIO next)
        {
            if (next == null)
            {
                throw new ArgumentNullException("primary");
            }

            this.next = next;
        }
Esempio n. 4
0
        public TeeFilter(IZMachineIO next, IZMachineIO side)
            : base(next)
        {
            if (side == null)
            {
                throw new ArgumentNullException("side");
            }

            this.side = side;
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the ZLR engine from a given stream.
        /// The stream must remain open while the engine is in use.
        /// </summary>
        /// <param name="gameStream">A stream containing either a plain Z-code
        /// file or a Blorb file which in turn contains a Z-code resource.</param>
        /// <param name="io"></param>
        public ZMachine(Stream gameStream, IZMachineIO io)
        {
            if (gameStream == null)
            {
                throw new ArgumentNullException("gameStream");
            }
            if (io == null)
            {
                throw new ArgumentNullException("io");
            }

            this.io = io;

            // check for Blorb
            byte[] temp = new byte[12];
            gameStream.Seek(0, SeekOrigin.Begin);
            gameStream.Read(temp, 0, 12);
            if (temp[0] == 'F' && temp[1] == 'O' && temp[2] == 'R' && temp[3] == 'M' &&
                temp[8] == 'I' && temp[9] == 'F' && temp[10] == 'R' && temp[11] == 'S')
            {
                Blorb blorb = new Blorb(gameStream);
                if (blorb.GetStoryType() == "ZCOD")
                {
                    gameStream = blorb.GetStoryStream();
                }
                else
                {
                    throw new ArgumentException("Not a Z-code Blorb");
                }
            }

            this.gameFile = gameStream;

            zmem = new byte[gameStream.Length];
            gameStream.Seek(0, SeekOrigin.Begin);
            gameStream.Read(zmem, 0, (int)gameStream.Length);

            if (zmem.Length < 64)
            {
                throw new ArgumentException("Z-code file is too short: must be at least 64 bytes");
            }

            zversion = zmem[0];

            if (zversion != 5 && zversion != 8)
            {
                throw new ArgumentException("Z-code version must be 5 or 8");
            }

            io.SizeChanged += new EventHandler(io_SizeChanged);
        }
Esempio n. 6
0
 public InternalSaveFilter(IZMachineIO next)
     : base(next)
 {
 }
Esempio n. 7
0
 public NoFilesFilter(IZMachineIO next)
     : base(next)
 {
 }
Esempio n. 8
0
 public NoSoundFilter(IZMachineIO next)
     : base(next)
 {
 }
Esempio n. 9
0
 public DebuggingConsole(ZMachine zm, IZMachineIO io, string[] sourcePath)
 {
     this.zm         = zm;
     this.io         = io;
     this.sourcePath = sourcePath;
 }
Esempio n. 10
0
 public DebuggingConsole(ZMachine zm, IZMachineIO io, string[] sourcePath)
 {
     this.zm = zm;
     this.io = io;
     this.sourcePath = sourcePath;
 }
Esempio n. 11
0
 public NoSoundFilter(IZMachineIO next)
     : base(next)
 {
 }
Esempio n. 12
0
        /// <summary>
        /// Initializes a new instance of the ZLR engine from a given stream.
        /// The stream must remain open while the engine is in use.
        /// </summary>
        /// <param name="gameStream">A stream containing either a plain Z-code
        /// file or a Blorb file which in turn contains a Z-code resource.</param>
        /// <param name="io"></param>
        public ZMachine(Stream gameStream, IZMachineIO io)
        {
            if (gameStream == null)
                throw new ArgumentNullException("gameStream");
            if (io == null)
                throw new ArgumentNullException("io");

            this.io = io;

            // check for Blorb
            byte[] temp = new byte[12];
            gameStream.Seek(0, SeekOrigin.Begin);
            gameStream.Read(temp, 0, 12);
            if (temp[0] == 'F' && temp[1] == 'O' && temp[2] == 'R' && temp[3] == 'M' &&
                temp[8] == 'I' && temp[9] == 'F' && temp[10] == 'R' && temp[11] == 'S')
            {
                Blorb blorb = new Blorb(gameStream);
                if (blorb.GetStoryType() == "ZCOD")
                    gameStream = blorb.GetStoryStream();
                else
                    throw new ArgumentException("Not a Z-code Blorb");
            }

            this.gameFile = gameStream;

            zmem = new byte[gameStream.Length];
            gameStream.Seek(0, SeekOrigin.Begin);
            gameStream.Read(zmem, 0, (int)gameStream.Length);

            if (zmem.Length < 64)
                throw new ArgumentException("Z-code file is too short: must be at least 64 bytes");

            zversion = zmem[0];

            if (zversion < 1 || zversion > 8)
                throw new ArgumentException("Z-code version must be between 1 and 8");

            io.SizeChanged += new EventHandler(io_SizeChanged);
        }
Esempio n. 13
0
 public InternalSaveFilter(IZMachineIO next)
     : base(next)
 {
 }
Esempio n. 14
0
 public NoFilesFilter(IZMachineIO next)
     : base(next)
 {
 }