Exemple #1
0
        static ushort ReadFile(ushort seg, string fn)
        {
            Console.Write("Reading ");
            Console.Write(fn);
            Console.Write(' ');

            ushort pos = FDC.SearchFile(fn);

            if (pos == 0)
            {
                Console.WriteLine();
                Console.WriteLine("ERROR: can not find!");
                return(0);
            }

            new Inline("push es");
            Registers.ES = seg;
            ushort ret = 0;

            for (;;)
            {
                FDC.ReadSectors((ushort)(pos + 31), 1, 0);
                ret++;
                Registers.ES += 0x20;
                Console.Write(".");
                pos = FDC.GetFAT(pos);
                if (pos == 0x0fff)
                {
                    break;
                }
            }
            new Inline("pop es");
            Console.WriteLine();
            return(ret);
        }
Exemple #2
0
        /// <summary>
        /// Read sectors.
        /// </summary>
        /// <param name="pos">start sector</param>
        /// <param name="count">number of sectors to read</param>
        /// <param name="ptr">es:bx = read address (es = 64kb align, bx = 512 bytes align)</param>
        public static void ReadSectors(ushort pos, ushort count, ushort ptr)
        {
            new Inline("push es");

            while (count > 0)
            {
                ushort ptr2 = (ushort)(0 - (short)ptr);
                ptr2--;
                ptr2 >>= 9;
                ptr2++;
                if (ptr2 > count)
                {
                    ptr2 = count;
                }

                while (ptr2 > 0)
                {
                    byte track     = (byte)(pos / 0x24);
                    byte track_rem = (byte)(pos % 0x24);
                    byte head      = (byte)(track_rem / 0x12);
                    byte sector    = (byte)(track_rem % 0x12);
                    byte n         = (byte)(0x12 - sector);
                    if (n > ptr2)
                    {
                        n = (byte)ptr2;
                    }

                    if (!FDC.Read(n, ptr, track, (byte)(sector + 1), head, 0))
                    {
                        FDC.Reset(0);
                        continue;
                    }

                    ptr   += (ushort)(n << 9);
                    pos   += n;
                    count -= n;
                    ptr2  -= n;
                }

                Registers.ES += 0x1000;
                ptr           = 0;
            }

            new Inline("pop es");
        }
Exemple #3
0
        public static ushort SearchFile(string fn)
        {
            new Inline("push es");
            Registers.ES = FDC.FATSeg;
            ushort ptr = 0, ret = 0;
            string fn2 = FDC.ConvertFileName(fn);

            for (ushort i = 0; i < FDC.RDE; i++, ptr += 0x20)
            {
                if (Str.StartsWith(fn2, ptr))
                {
                    Registers.DI = (ushort)(ptr + 0x1a);                      // start sector
                    new Inline("mov ax, [es:di]");
                    ret = Registers.AX;
                    break;
                }
            }
            new Inline("pop es");
            return(ret);
        }