forked from geraldholdsworth/DiscImageManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiscImage_MMB.pas
80 lines (78 loc) · 2.27 KB
/
DiscImage_MMB.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//++++++++++++++++++++++++ MMB +++++++++++++++++++++++++++++++++++++++++++++++++
{-------------------------------------------------------------------------------
Identifies an MMB
-------------------------------------------------------------------------------}
function TDiscImage.ID_MMB: Boolean;
{var
c,i,ptr : Integer;}
begin
Result:=False;
{ if FFormat=diInvalidImg then
begin
ResetVariables;
//Check it is of the correct length (511 images * 200K + 0x2000 bytes)
if GetDataLength=$63D0000 then
begin
FFormat:=diMMFS<<4;
//Check the status bytes (last byte of each 16 byte entry)
c:=0;
for i:=1 to 512 do
begin
ptr:=ReadByte((16*i)-1);
if(ptr=$00)or(ptr=$0F)or(ptr=$F0)or(ptr=$FF)then inc(c);
end;
if c<511 then FFormat:=diInvalidImg;
end;
end;
Result:=GetMajorFormatNumber=diMMFS;}
end;
{-------------------------------------------------------------------------------
Read MMB file
-------------------------------------------------------------------------------}
function TDiscImage.ReadMMBDisc: Boolean;
{var
i,j,
dir : Integer;
ptr : Cardinal;
c : Byte;
d : TDisc; }
begin
Result:=False;
{ //511 entries in an MMB file
SetLength(Result,511);
//Now go through them and read them in
for i:=0 to 510 do
begin
//Inform the user
UpdateProgress('Reading disc '+IntToStr(i));
//Reset the entry
ResetDir(Result[i]);
//Pointer to each header entry
ptr:=16+16*i;
//If formatted, or locked, read the disc
if(ReadByte(ptr+15)=$0F)or(ReadByte(ptr+15)=$00)then
begin
//First read the title from the header
for j:=0 to 11 do
begin
c:=ReadByte(ptr+j);
if(c>31)and(c<127)then Result[i].Directory:=Result[i].Directory+chr(c);
end;
Result[i].Title:=Result[i].Directory;
Result[i].Directory:=IntToStr(i)+': '+Result[i].Directory;
if ReadByte(ptr+15)=$00 then Result[i].Locked:=True
else Result[i].Locked:=False;
//Now read the disc, using the DFS routines
d:=ReadDFSDisc(i);
//Then transfer this across to the the one we are building up
if Length(d)>0 then
for dir:=0 to Length(d)-1 do
if Length(d[dir].Entries)>0 then
Result[i].Entries:=d[dir].Entries;
end
else //Entry is empty
Result[i].Directory:=IntToStr(i)+': empty';
end;
disc_name[0]:='MMFS File';
disc_size[0]:=511; }
end;