Exemplo n.º 1
0
        private void save_RAMP(Stream stream, byte chPageNo, byte[] chData)
        {
            var memory = _spec.BusManager.FindDevice <IMemoryDevice>();

            UInt16 wFlags = 0;

            using (var ms = new MemoryStream())
            {
                ZipLib.Zip.Compression.Streams.DeflaterOutputStream deflater = new ZipLib.Zip.Compression.Streams.DeflaterOutputStream(ms);
                deflater.Write(chData, 0, chData.Length);
                deflater.Finish();
                deflater.Flush();
                byte[] dataCompressed = ms.ToArray();
                if (dataCompressed.Length < chData.Length)
                {
                    chData  = dataCompressed;
                    wFlags |= ZXSTRF_COMPRESSED;
                }
            }

            StreamHelper.Write(stream, Encoding.ASCII.GetBytes("RAMP"));
            int size = 3 + chData.Length;

            StreamHelper.Write(stream, size);

            StreamHelper.Write(stream, wFlags);
            StreamHelper.Write(stream, chPageNo);
            StreamHelper.Write(stream, chData);
        }
Exemplo n.º 2
0
        private void save_B128(Stream stream)
        {
            var betaDisk = _spec.BusManager.FindDevice <IBetaDiskDevice>();

            if (betaDisk != null)
            {
                int dwFlags =
                    (betaDisk.DOSEN ? ZXSTBETAF_PAGED : 0);

                byte   chNumDrives = 0;
                byte   chSysReg    = 0x3f;
                byte   chTrackReg  = 0;
                byte   chSectorReg = 0;
                byte   chDataReg   = 0;
                byte   chStatusReg = 0xe0;
                byte[] chRomData   = new byte[0];

                if (chRomData.Length > 0)
                {
                    using (var ms = new MemoryStream())
                    {
                        ZipLib.Zip.Compression.Streams.DeflaterOutputStream deflater = new ZipLib.Zip.Compression.Streams.DeflaterOutputStream(ms);
                        deflater.Write(chRomData, 0, chRomData.Length);
                        deflater.Finish();
                        deflater.Flush();
                        byte[] dataCompressed = ms.ToArray();
                        if (dataCompressed.Length < chRomData.Length)
                        {
                            chRomData = dataCompressed;
                            dwFlags  |= ZXSTBETAF_COMPRESSED;
                        }
                    }
                }

                StreamHelper.Write(stream, Encoding.ASCII.GetBytes("B128"));
                int size = 10;
                StreamHelper.Write(stream, size);

                StreamHelper.Write(stream, dwFlags);
                StreamHelper.Write(stream, chNumDrives);
                StreamHelper.Write(stream, chSysReg);
                StreamHelper.Write(stream, chTrackReg);
                StreamHelper.Write(stream, chSectorReg);
                StreamHelper.Write(stream, chDataReg);
                StreamHelper.Write(stream, chStatusReg);
                StreamHelper.Write(stream, chRomData);
            }
        }
Exemplo n.º 3
0
        private void save_RAMP(Stream stream, byte chPageNo, byte[] chData)
        {
            var memory = _spec.BusManager.FindDevice<IMemoryDevice>();

            UInt16 wFlags = 0;

            using (var ms = new MemoryStream())
            {
                ZipLib.Zip.Compression.Streams.DeflaterOutputStream deflater = new ZipLib.Zip.Compression.Streams.DeflaterOutputStream(ms);
                deflater.Write(chData, 0, chData.Length);
                deflater.Finish();
                deflater.Flush();
                byte[] dataCompressed = ms.ToArray();
                if (dataCompressed.Length < chData.Length)
                {
                    chData = dataCompressed;
                    wFlags |= ZXSTRF_COMPRESSED;
                }
            }

            StreamHelper.Write(stream, Encoding.ASCII.GetBytes("RAMP"));
            int size = 3 + chData.Length;
            StreamHelper.Write(stream, size);

            StreamHelper.Write(stream, wFlags);
            StreamHelper.Write(stream, chPageNo);
            StreamHelper.Write(stream, chData);
        }
Exemplo n.º 4
0
        private void save_B128(Stream stream)
        {
            var betaDisk = _spec.BusManager.FindDevice<IBetaDiskDevice>();
            if (betaDisk != null)
            {
                int dwFlags =
                    (betaDisk.DOSEN ? ZXSTBETAF_PAGED : 0);

                byte chNumDrives = 0;
                byte chSysReg = 0x3f;
                byte chTrackReg = 0;
                byte chSectorReg = 0;
                byte chDataReg = 0;
                byte chStatusReg = 0xe0;
                byte[] chRomData = new byte[0];

                if (chRomData.Length > 0)
                {
                    using (var ms = new MemoryStream())
                    {
                        ZipLib.Zip.Compression.Streams.DeflaterOutputStream deflater = new ZipLib.Zip.Compression.Streams.DeflaterOutputStream(ms);
                        deflater.Write(chRomData, 0, chRomData.Length);
                        deflater.Finish();
                        deflater.Flush();
                        byte[] dataCompressed = ms.ToArray();
                        if (dataCompressed.Length < chRomData.Length)
                        {
                            chRomData = dataCompressed;
                            dwFlags |= ZXSTBETAF_COMPRESSED;
                        }
                    }
                }

                StreamHelper.Write(stream, Encoding.ASCII.GetBytes("B128"));
                int size = 10;
                StreamHelper.Write(stream, size);

                StreamHelper.Write(stream, dwFlags);
                StreamHelper.Write(stream, chNumDrives);
                StreamHelper.Write(stream, chSysReg);
                StreamHelper.Write(stream, chTrackReg);
                StreamHelper.Write(stream, chSectorReg);
                StreamHelper.Write(stream, chDataReg);
                StreamHelper.Write(stream, chStatusReg);
                StreamHelper.Write(stream, chRomData);
            }
        }