예제 #1
0
        protected bool addFile(byte[] buf, int hdrIndex, int dataIndex)
        {
            byte[] s9 = new byte[256];
            _diskImage.ReadLogicalSector(0, 0, 9, s9);
            int len = buf[hdrIndex + 13];
            int pos = s9[0xE4] * 0x10;

            byte[] dir = new byte[256];
            _diskImage.ReadLogicalSector(0, 0, 1 + pos / 0x100, dir);
            if ((s9[0xE5] | (s9[0xE6] << 8)) < len)   // disk full
            {
                Locator.Resolve <IUserMessage>()
                .Error("HOBETA loader\n\nDisk full! Create empty disk and repeat operation!");
                return(false);
            }
            for (int i = 0; i < 14; i++)
            {
                dir[(pos & 0xFF) + i] = buf[hdrIndex + i];
            }
            ushort x = (ushort)(s9[0xE1] | (s9[0xE2] << 8));

            dir[(pos & 0xFF) + 14] = (byte)x;
            dir[(pos & 0xFF) + 15] = (byte)(x >> 8);

            _diskImage.WriteLogicalSector(0, 0, 1 + pos / 0x100, dir);

            pos      = s9[0xE1] + 16 * s9[0xE2];
            s9[0xE1] = (byte)((pos + len) & 0x0F);
            s9[0xE2] = (byte)((pos + len) >> 4);
            s9[0xE4]++;

            x        = (ushort)(s9[0xE5] | (s9[0xE6] << 8));
            x       -= (ushort)len;
            s9[0xE5] = (byte)x;
            s9[0xE6] = (byte)(x >> 8);

            _diskImage.WriteLogicalSector(0, 0, 9, s9);

            // goto next track
            for (int i = 0; i < len; i++, pos++)
            {
                for (int j = 0; j < 0x100 && (dataIndex + i * 0x100 + j) < buf.Length; j++)
                {
                    s9[j] = buf[dataIndex + i * 0x100 + j];
                }
                _diskImage.WriteLogicalSector(pos / 32, (pos / 16) & 1, (pos & 0x0F) + 1, s9);
            }
            return(true);
        }
예제 #2
0
        protected virtual void SaveToStream(Stream stream)
        {
            // save at least 80 cylinders
            var cylCount = m_diskImage.CylynderCount < 80 ?
                           80 : m_diskImage.CylynderCount;
            var secSize = 128 << (SectorSizeCode & 3);

            for (var c = 0; c < cylCount; c++)
            {
                for (var h = 0; h < 2; h++)
                {
                    var il = GetSectorMap(c, h);
                    for (var s = 0; s < il.Length; s++)
                    {
                        var buffer = new byte[secSize];
                        if (c < m_diskImage.CylynderCount)
                        {
                            if (m_diskImage.GetLogicalSectorSizeCode(c, h, il[s]) != (SectorSizeCode & 3))
                            {
                                throw new NotSupportedException(
                                          string.Format(
                                              "Cannot save because disk contains data which is not supported by {0}",
                                              FormatName));
                            }
                            m_diskImage
                            .ReadLogicalSector(c, h, il[s], buffer);
                        }
                        stream.Write(buffer, 0, buffer.Length);
                    }
                }
            }
        }
예제 #3
0
 private void saveToStream(Stream stream)
 {
     for (int i = 0; i < 256 * 16 * 2 * _diskImage.CylynderCount; i += 0x100)
     {
         byte[] snbuf = new byte[256];
         _diskImage.ReadLogicalSector(i >> 13, (i >> 12) & 1, ((i >> 8) & 0x0F) + 1, snbuf);
         stream.Write(snbuf, 0, 256);
     }
 }