Subversion Repositories pentevo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
716 lvd 1
#include "std.h"
2
 
3
#include "emul.h"
4
#include "vars.h"
5
 
6
#include "util.h"
7
 
8
static const unsigned char sn0[] = { 1, 2, 3, 4, 9 };
9
static const unsigned char sn[] = { 1, 2, 3, 4, 5 };
10
 
11
void FDD::format_pro()
12
{
13
   newdisk(80, 2);
14
 
15
   for(unsigned c = 0; c < cyls; c++)
16
   {
17
      for (unsigned h = 0; h < 2; h++)
18
      {
19
         t.seek(this, c, h, JUST_SEEK);
20
         t.s = 5;
21
         for(unsigned s = 0; s < 5; s++)
22
         {
23
            unsigned n = (c == 0 && h == 0) ? sn0[s] : sn[s];
24
            t.hdr[s].n = n; t.hdr[s].l = 3;
25
            t.hdr[s].c = c; t.hdr[s].s = h;
26
            t.hdr[s].c1 = t.hdr[s].c2 = 0;
27
            t.hdr[s].data = (unsigned char*)1;
28
         }
29
         t.format();
30
      }
31
   }
32
}
33
 
34
int FDD::read_pro()
35
{
36
   format_pro();
37
 
38
   for(unsigned c = 0; c < cyls; c++)
39
   {
40
      for (unsigned h = 0; h < 2; h++)
41
      {
42
         for (unsigned s = 0; s < 5; s++)
43
         {
44
            t.seek(this, c, h, LOAD_SECTORS);
45
            t.write_sector((c == 0 && h == 0) ? sn0[s] : sn[s], snbuf+(c*10 + h*5 + s)*1024);
46
         }
47
      }
48
   }
49
   return 1;
50
}
51
 
52
int FDD::write_pro(FILE *ff)
53
{
54
   for(unsigned c = 0; c < 80; c++)
55
   {
56
      for(unsigned h = 0; h < 2; h++)
57
      {
58
          t.seek(this, c, h, LOAD_SECTORS);
59
          for(unsigned s = 0; s < 5; s++)
60
          {
61
              if (fwrite(t.hdr[s].data, 1, 1024, ff) != 1024)
62
                 return 0;
63
          }
64
      }
65
   }
66
   return 1;
67
}