Exemplo n.º 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);
        }
Exemplo n.º 2
0
        private void loadFromStream(Stream stream)
        {
            int cylCount = (int)stream.Length / (256 * 16 * 2);

            if ((stream.Length % (256 * 16 * 2)) > 0)
            {
                _diskImage.SetPhysics(cylCount + 1, 2);
            }
            else
            {
                _diskImage.SetPhysics(cylCount, 2);
            }
            _diskImage.FormatTrdos();

            int i = 0;

            while (stream.Position < stream.Length)
            {
                byte[] snbuf = new byte[256];
                stream.Read(snbuf, 0, 256);
                _diskImage.WriteLogicalSector(i >> 13, (i >> 12) & 1, ((i >> 8) & 0x0F) + 1, snbuf);
                i += 0x100;
            }
        }