Beispiel #1
0
        private void loadFromStream(Stream stream)
        {
            ZXST_Header header = new ZXST_Header();
            header.Deserialize(stream);

            if (header.MajorVersion != 1)
                throw new NotSupportedException(string.Format("Sorry, but MajorVersion={0} is not supported", header.MajorVersion));

            //int num = 0;

            InitStd128K();
            bool eof = false;
            do
            {
                byte[] data = new byte[8];
                eof |= stream.Read(data, 0, data.Length) != data.Length;

                UInt32 id = BitConverter.ToUInt32(data, 0);
                UInt32 size = BitConverter.ToUInt32(data, 4);
                data = new byte[size];
                eof |= stream.Read(data, 0, data.Length) != data.Length;

                if (!eof)
                {
                    string strId = Encoding.ASCII.GetString(BitConverter.GetBytes(id));
                    //using (FileStream fs = new FileStream((num++).ToString("D2")+"_" + strId.Replace('\0', '_') + ".block", FileMode.Create, FileAccess.Write, FileShare.Read))
                    //    fs.Write(data, 0, data.Length);

                    switch (strId)
                    {
                        case "Z80R":
                            apply_Z80R(data);
                            break;
                        case "SPCR":
                            apply_SPCR(data, header);
                            break;
                        case "AY\0\0":
                            apply_AY(data);
                            break;
                        case "RAMP":
                            apply_RAMP(data);
                            break;
                        case "B128":
                            applyB128(data);
                            break;
                        //case "KEYB":
                        //    break;
                        default:
                            //LogAgent.Info("SzxSerializer: skip block '{0}' (unsupported)", strId);
                            break;
                    }
                }
            }
            while (!eof);
        }
Beispiel #2
0
        private void loadFromStream(Stream stream)
        {
            ZXST_Header header = new ZXST_Header();

            header.Deserialize(stream);

            if (header.MajorVersion != 1)
            {
                throw new NotSupportedException(string.Format("Sorry, but MajorVersion={0} is not supported", header.MajorVersion));
            }

            //int num = 0;

            InitStd128K();
            bool eof = false;

            do
            {
                byte[] data = new byte[8];
                eof |= stream.Read(data, 0, data.Length) != data.Length;

                UInt32 id   = BitConverter.ToUInt32(data, 0);
                UInt32 size = BitConverter.ToUInt32(data, 4);
                data = new byte[size];
                eof |= stream.Read(data, 0, data.Length) != data.Length;

                if (!eof)
                {
                    string strId = Encoding.ASCII.GetString(BitConverter.GetBytes(id));
                    //using (FileStream fs = new FileStream((num++).ToString("D2")+"_" + strId.Replace('\0', '_') + ".block", FileMode.Create, FileAccess.Write, FileShare.Read))
                    //    fs.Write(data, 0, data.Length);

                    switch (strId)
                    {
                    case "Z80R":
                        apply_Z80R(data);
                        break;

                    case "SPCR":
                        apply_SPCR(data, header);
                        break;

                    case "AY\0\0":
                        apply_AY(data);
                        break;

                    case "RAMP":
                        apply_RAMP(data);
                        break;

                    case "B128":
                        applyB128(data);
                        break;

                    //case "KEYB":
                    //    break;
                    default:
                        //LogAgent.Info("SzxSerializer: skip block '{0}' (unsupported)", strId);
                        break;
                    }
                }
            }while (!eof);
        }