Skip to content

Commit fbb0fc8

Browse files
committed
Implemented support for the FAT32/BIGDOS file system in DiskExplorer
1 parent cce82cd commit fbb0fc8

File tree

10 files changed

+173
-236
lines changed

10 files changed

+173
-236
lines changed

GenOpCodes/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2019.3.2.610")>
35-
<Assembly: AssemblyFileVersion("2019.3.2.610")>
34+
<Assembly: AssemblyVersion("2019.3.2.612")>
35+
<Assembly: AssemblyFileVersion("2019.3.2.612")>

RunTests/ModuleMain.vb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ Module ModuleMain
6565
For i As Integer = 0 To dataLen - 1 Step 2
6666
v1 = cpu.RAM16(0, i).ToString("X4")
6767
v2 = BitConverter.ToInt16(validData, i).ToString("X4")
68-
If v1 <> v2 Then
69-
invalidData.Add($"0000:{i:X4} {v1} <> {v2}")
70-
End If
68+
If v1 <> v2 Then invalidData.Add($"0000:{i:X4} {v1} <> {v2}")
7169
Next
70+
7271
If invalidData.Any() Then
7372
txt = $" > FAILED [{invalidData.Count}/{dataLen}]"
7473
Console.WriteLine(txt.PadLeft(p - prefix.Length + txt.Length))

RunTests/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2019.3.2.938")>
35-
<Assembly: AssemblyFileVersion("2019.3.2.938")>
34+
<Assembly: AssemblyVersion("2019.3.2.940")>
35+
<Assembly: AssemblyFileVersion("2019.3.2.940")>

x8086NetEmu/Adapters/Disk/FileSystem/FileSystemStructs.vb

Lines changed: 57 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Imports System.Runtime.InteropServices
22

3-
Public Structure FAT12
3+
Public Class FAT12
44
Public Enum EntryAttributes As Byte
55
[ReadOnly] = 2 ^ 0
66
Hidden = 2 ^ 1
@@ -16,7 +16,7 @@ Public Structure FAT12
1616
Public SectorsPerCluster As Byte
1717
Public ReservedSectors As UInt16
1818
Public NumberOfFATCopies As Byte
19-
Public RootEntries As UInt16
19+
Public MaxRootEntries As UInt16
2020
Public TotalSectors As UInt16
2121
Public MediaDescriptor As Byte
2222
Public SectorsPerFAT As UInt16
@@ -64,6 +64,12 @@ Public Structure FAT12
6464
Public StartingCluster As UInt16
6565
Public FileSize As UInt32
6666

67+
Public ReadOnly Property StartingClusterValue As Integer
68+
Get
69+
Return StartingCluster
70+
End Get
71+
End Property
72+
6773
Public ReadOnly Property FileName As String
6874
Get
6975
Return Text.Encoding.ASCII.GetString(FileNameChars).TrimEnd()
@@ -134,7 +140,7 @@ Public Structure FAT12
134140
End Function
135141

136142
Public Shared Operator =(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
137-
Return d1.Attribute = d2.Attribute AndAlso d1.StartingCluster = d2.StartingCluster
143+
Return d1.Attribute = d2.Attribute AndAlso d1.StartingClusterValue = d2.StartingClusterValue
138144
End Operator
139145

140146
Public Shared Operator <>(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
@@ -157,58 +163,13 @@ Public Structure FAT12
157163
End Get
158164
End Property
159165
End Structure
160-
End Structure
161-
162-
Public Structure FAT16
163-
Public Enum EntryAttributes As Byte
164-
[ReadOnly] = 2 ^ 0
165-
Hidden = 2 ^ 1
166-
System = 2 ^ 2
167-
VolumeName = 2 ^ 3
168-
Directory = 2 ^ 4
169-
ArchiveFlag = 2 ^ 5
170-
End Enum
171-
172-
<StructLayout(LayoutKind.Sequential, Pack:=1)>
173-
Public Structure ParameterBlock
174-
Public BytesPerSector As UInt16
175-
Public SectorsPerCluster As Byte
176-
Public ReservedSectors As UInt16
177-
Public NumberOfFATCopies As Byte
178-
Public RootEntries As UInt16
179-
Public TotalSectors As UInt16
180-
Public MediaDescriptor As Byte
181-
Public SectorsPerFAT As UInt16
182-
Public SectorsPerTrack As UInt16
183-
Public HeadsPerCylinder As UInt16
184-
Public HiddenSectors As UInt32
185-
Public TotalSectorsBig As UInt32
186-
End Structure
187-
188-
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)>
189-
Public Structure ExtendedParameterBlock
190-
Public DriveNumber As Byte
191-
Public Reserved As Byte
192-
Public ExtendedBootSignature As Byte
193-
Public SerialNumber As UInt32
194-
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=11)> Private ReadOnly VolumeLabelChars() As Byte
195-
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Private ReadOnly FileSystemTypeChars() As Byte
166+
End Class
196167

197-
Public ReadOnly Property VolumeLabel As String
198-
Get
199-
Return Text.Encoding.ASCII.GetString(VolumeLabelChars).TrimEnd()
200-
End Get
201-
End Property
202-
203-
Public ReadOnly Property FileSystemType As String
204-
Get
205-
Return Text.Encoding.ASCII.GetString(FileSystemTypeChars).TrimEnd()
206-
End Get
207-
End Property
208-
End Structure
168+
Public Class FAT16
169+
Inherits FAT12
209170

210171
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)>
211-
Public Structure DirectoryEntry
172+
Public Shadows Structure DirectoryEntry
212173
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public FileNameChars() As Byte
213174
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Private ReadOnly FileExtensionChars() As Byte
214175
Public Attribute As EntryAttributes
@@ -223,6 +184,12 @@ Public Structure FAT16
223184
Public StartingCluster As UInt16
224185
Public FileSize As UInt32
225186

187+
Public ReadOnly Property StartingClusterValue As Integer
188+
Get
189+
Return StartingCluster
190+
End Get
191+
End Property
192+
226193
Public ReadOnly Property FileName As String
227194
Get
228195
Return Text.Encoding.ASCII.GetString(FileNameChars).TrimEnd()
@@ -293,100 +260,70 @@ Public Structure FAT16
293260
End Function
294261

295262
Public Shared Operator =(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
296-
Return d1.Attribute = d2.Attribute AndAlso d1.StartingCluster = d2.StartingCluster
263+
Return d1.Attribute = d2.Attribute AndAlso d1.StartingClusterValue = d2.StartingClusterValue
297264
End Operator
298265

299266
Public Shared Operator <>(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
300267
Return Not d1 = d2
301268
End Operator
302269
End Structure
270+
End Class
303271

304-
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)>
305-
Public Structure BootSector
306-
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public JumpCode() As Byte
307-
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Private ReadOnly OemIdChars() As Byte
308-
<MarshalAs(UnmanagedType.Struct)> Public BIOSParameterBlock As ParameterBlock
309-
<MarshalAs(UnmanagedType.Struct)> Public ExtendedBIOSParameterBlock As ExtendedParameterBlock
310-
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=448)> Public BootStrapCode() As Byte
311-
Public Signature As UInt16
312-
313-
Public ReadOnly Property OemId As String
314-
Get
315-
Return Text.Encoding.ASCII.GetString(OemIdChars).TrimEnd()
316-
End Get
317-
End Property
318-
End Structure
319-
End Structure
320-
321-
Public Structure FAT32
322-
Public Enum EntryAttributes As Byte
323-
[ReadOnly] = 2 ^ 0
324-
Hidden = 2 ^ 1
325-
System = 2 ^ 2
326-
VolumeName = 2 ^ 3
327-
Directory = 2 ^ 4
328-
ArchiveFlag = 2 ^ 5
329-
End Enum
272+
Public Class FAT32
273+
Inherits FAT12
330274

331275
<StructLayout(LayoutKind.Sequential, Pack:=1)>
332-
Public Structure ParameterBlock
276+
Public Shadows Structure ParameterBlock
333277
Public BytesPerSector As UInt16
334278
Public SectorsPerCluster As Byte
335279
Public ReservedSectors As UInt16
336280
Public NumberOfFATCopies As Byte
337-
Public RootEntries As UInt16
338-
Public TotalSectors As UInt16
281+
Public MaxRootEntries As UInt16 ' Not used
282+
Public TotalSectors As UInt16 ' Not used
339283
Public MediaDescriptor As Byte
340-
Public NotUsed As UInt16
284+
Public SectorsPerFAT As UInt16
341285
Public SectorsPerTrack As UInt16
342286
Public HeadsPerCylinder As UInt16
343287
Public HiddenSectors As UInt32
344-
Public TotalSectorsBig As UInt32
345-
Public SectorsPerFAT As UInt32
288+
Public SectorsInPartition As UInt32
289+
Public SectorsPerFATNew As UInt32
346290
Public FATHandlingFlags As UInt16
347-
Public DriveVersion As UInt16
348-
Public ClusterFSIS As UInt32
349-
Public SectorBBS As UInt16
291+
Public Version As UInt16
292+
Public ClusterStartRootDirectory As UInt32
293+
Public SectorStartFileSystemInformationSector As UInt16
294+
Public SectorStartBackupBootSector As UInt16
350295
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=12)> Private Reserved() As Byte
351296
End Structure
352297

353298
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)>
354-
Public Structure ExtendedParameterBlock
355-
Public DriveNumber As Byte
356-
Public CurrentHead As Byte
357-
Public ExtendedBootSignature As Byte
358-
Public SerialNumber As UInt32
359-
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=11)> Private ReadOnly VolumeLabelChars() As Byte
360-
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Private ReadOnly FileSystemTypeChars() As Byte
299+
Public Shadows Structure DirectoryEntry
300+
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public FileNameChars() As Byte
301+
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Private ReadOnly FileExtensionChars() As Byte
302+
Public Attribute As Byte
303+
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public Unused01() As Byte
304+
Public StartingCluster As UInt16
305+
Public CreationTime As UInt16
306+
Public CreationDate As UInt16
307+
Public StartingClusterLowWord As UInt16
308+
Public FileSize As UInt32
361309

362-
Public ReadOnly Property VolumeLabel As String
310+
Public ReadOnly Property StartingClusterValue As Integer
363311
Get
364-
Return Text.Encoding.ASCII.GetString(VolumeLabelChars).TrimEnd()
312+
Return (StartingCluster << 8) Or StartingClusterLowWord
365313
End Get
366314
End Property
367315

368-
Public ReadOnly Property FileSystemType As String
316+
Public ReadOnly Property LastWriteTime As UInt16
369317
Get
370-
Return Text.Encoding.ASCII.GetString(FileSystemTypeChars).TrimEnd()
318+
Return CreationTime
371319
End Get
372320
End Property
373-
End Structure
374321

375-
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)>
376-
Public Structure DirectoryEntry
377-
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public FileNameChars() As Byte
378-
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Private ReadOnly FileExtensionChars() As Byte
379-
Public Attribute As EntryAttributes
380-
Public ReservedNT As Byte
381-
Public Creation As Byte
382-
Public CreationTime As UInt16
383-
Public CreationDate As UInt16
384-
Public LastAccessDate As UInt16
385-
Public ReservedFAT32 As UInt16
386-
Public LastWriteTime As UInt16
387-
Public LastWriteDate As UInt16
388-
Public StartingCluster As UInt16
389-
Public FileSize As UInt32
322+
Public ReadOnly Property LastWriteDate As UInt16
323+
Get
324+
Return CreationDate
325+
End Get
326+
End Property
390327

391328
Public ReadOnly Property FileName As String
392329
Get
@@ -422,6 +359,7 @@ Public Structure FAT32
422359
Get
423360
Dim t() As Integer = FSTimeToNative(LastWriteTime)
424361
Dim d() As Integer = FSDateToNative(LastWriteDate)
362+
425363
Try
426364
Return New DateTime(d(0), d(1), d(2), t(0), t(1), t(2))
427365
Catch
@@ -458,7 +396,7 @@ Public Structure FAT32
458396
End Function
459397

460398
Public Shared Operator =(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
461-
Return d1.Attribute = d2.Attribute AndAlso d1.StartingCluster = d2.StartingCluster
399+
Return d1.Attribute = d2.Attribute AndAlso d1.StartingClusterValue = d2.StartingClusterValue
462400
End Operator
463401

464402
Public Shared Operator <>(d1 As DirectoryEntry, d2 As DirectoryEntry) As Boolean
@@ -467,12 +405,12 @@ Public Structure FAT32
467405
End Structure
468406

469407
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)>
470-
Public Structure BootSector
408+
Public Shadows Structure BootSector
471409
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public JumpCode() As Byte
472410
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Private ReadOnly OemIdChars() As Byte
473411
<MarshalAs(UnmanagedType.Struct)> Public BIOSParameterBlock As ParameterBlock
474412
<MarshalAs(UnmanagedType.Struct)> Public ExtendedBIOSParameterBlock As ExtendedParameterBlock
475-
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=448)> Public BootStrapCode() As Byte
413+
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=420)> Public BootStrapCode() As Byte
476414
Public Signature As UInt16
477415

478416
Public ReadOnly Property OemId As String
@@ -481,4 +419,4 @@ Public Structure FAT32
481419
End Get
482420
End Property
483421
End Structure
484-
End Structure
422+
End Class

0 commit comments

Comments
 (0)