Skip to content

Commit d3da2d7

Browse files
committed
Added support for FM Towns boot sectors
1 parent 0f8b6da commit d3da2d7

File tree

6 files changed

+91
-35
lines changed

6 files changed

+91
-35
lines changed

DiskImageTool/Assets/bootstrap.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<oemname name=" WATCOM " company="WATCOM International Corp" description="WATCOM SQL for OS/2"/>
6060
</bootstrap>
6161
<bootstrap crc32="C6CE8A87" jmp="EB3C90">
62-
<oemname name="..DOS4.0"/>
62+
<oemname name="..DOS4.0" verified="true"/>
6363
</bootstrap>
6464
<bootstrap crc32="6103A675" jmp="EB2A90">
6565
<oemname name="688AS EA" company="Electronic Arts" description="688 Attack Sub Master Disk"/>
@@ -313,6 +313,9 @@
313313
<bootstrap crc32="495551E6" jmp="EB2990" language="German">
314314
<oemname name="IBM 3.0" company="IBM" description="PC-DOS 3.0"/>
315315
</bootstrap>
316+
<bootstrap crc32="8E81944E" jmp="EB2990" language="French">
317+
<oemname name="IBM 3.0" company="IBM" description="PC-DOS 3.0" verified="true"/>
318+
</bootstrap>
316319
<bootstrap crc32="CB2078CC" jmp="E9EF00">
317320
<oemname name="IBM 3.1" verified="true"/>
318321
<oemname name="MSDOS3.0"/>
@@ -407,7 +410,7 @@
407410
<bootstrap crc32="4F2A959C" jmp="EB3490">
408411
<oemname name="IBM 3.3" company="IBM" description="PC-DOS 3.3" verified="true"/>
409412
<oemname name="MSDOS3.3" verified="true"/>
410-
<oemname name="IBMMS3.3"/>
413+
<oemname name="IBMMS3.3" verified="true"/>
411414
<oemname name="IBM 3.2"/>
412415
<oemname name="MSDOS3.2"/>
413416
<oemname name="IBM 3.3y" suggestion="false"/>
@@ -655,7 +658,7 @@
655658
<oemname name="MSDMF3.2" company="Microsoft" description="Microsoft Distribution Media Format"/>
656659
</bootstrap>
657660
<bootstrap crc32="4D47BE99" jmp="EB3490">
658-
<oemname name="MSDOS3.2"/>
661+
<oemname name="MSDOS3.2" verified="true"/>
659662
<oemname name="MSDOS3.3"/>
660663
</bootstrap>
661664
<bootstrap crc32="B7BE2F89" jmp="EB3490">
@@ -1084,6 +1087,9 @@
10841087
<bootstrap crc32="900A3D52" jmp="EB5390">
10851088
<oemname name="Tandy557" company="Tandy" verified="true"/>
10861089
</bootstrap>
1090+
<bootstrap crc32="62544610" jmp="EB5190">
1091+
<oemname name="Tandy557" company="Tandy" verified="true"/>
1092+
</bootstrap>
10871093
<bootstrap crc32="ED266093" jmp="EB5390">
10881094
<oemname name="Tandy557" company="Tandy" description="MS-DOS 2.11" verified="true"/>
10891095
<oemname name="Tandy211" company="Tandy" description="MS-DOS 2.11"/>

DiskImageTool/DiskImage/BootSector.vb

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
Private ReadOnly _BPB As BiosParameterBlock
1111
Private ReadOnly _FloppyImage As IFloppyImage
1212
Private ReadOnly _Offset As UInteger
13+
1314
Public Enum BootSectorOffsets As UInteger
15+
FMTownsSignature = 0
1416
JmpBoot = 0
1517
OEMName = 3
1618
DriveNumber = 36
@@ -24,6 +26,7 @@
2426
End Enum
2527

2628
Public Enum BootSectorSizes As UInteger
29+
FMTownsSignature = 4
2730
JmpBoot = 3
2831
OEMName = 8
2932
DriveNumber = 1
@@ -114,19 +117,19 @@
114117

115118
Public Property JmpBoot() As Byte()
116119
Get
117-
Return _FloppyImage.GetBytes(BootSectorOffsets.JmpBoot + _Offset, BootSectorSizes.JmpBoot)
120+
Return _FloppyImage.GetBytes(GetJmpBootOffset() + _Offset, BootSectorSizes.JmpBoot)
118121
End Get
119122
Set
120-
_FloppyImage.SetBytes(Value, BootSectorOffsets.JmpBoot + _Offset, BootSectorSizes.JmpBoot, 0)
123+
_FloppyImage.SetBytes(Value, GetJmpBootOffset() + _Offset, BootSectorSizes.JmpBoot, 0)
121124
End Set
122125
End Property
123126

124127
Public Property OEMName() As Byte()
125128
Get
126-
Return _FloppyImage.GetBytes(BootSectorOffsets.OEMName + _Offset, BootSectorSizes.OEMName)
129+
Return _FloppyImage.GetBytes(GetOEMNameOffset() + _Offset, GetOEMNameSize())
127130
End Get
128131
Set
129-
_FloppyImage.SetBytes(Value, BootSectorOffsets.OEMName + _Offset, BootSectorSizes.OEMName, 0)
132+
_FloppyImage.SetBytes(Value, GetOEMNameOffset() + _Offset, GetOEMNameSize(), 0)
130133
End Set
131134
End Property
132135

@@ -158,30 +161,30 @@
158161
End Property
159162

160163
Public Function CheckJumpInstruction(CheckNOP As Boolean) As Boolean
161-
Return CheckJumpInstruction(JmpBoot, CheckNOP)
164+
Return CheckJumpInstruction(JmpBoot, GetJmpBootOffset(), CheckNOP)
162165
End Function
163166

164167
Public Function CheckJumpInstruction(CheckNOP As Boolean, CheckDestination As Boolean) As Boolean
165-
Return CheckJumpInstruction(JmpBoot, CheckNOP, CheckDestination)
168+
Return CheckJumpInstruction(JmpBoot, GetJmpBootOffset(), CheckNOP, CheckDestination)
166169
End Function
167170

168-
Public Shared Function CheckJumpInstruction(Jmp() As Byte, CheckNOP As Boolean) As Boolean
169-
Return CheckJumpInstruction(Jmp, CheckNOP, False)
171+
Public Shared Function CheckJumpInstruction(Jmp() As Byte, JmpOffset As UInteger, CheckNOP As Boolean) As Boolean
172+
Return CheckJumpInstruction(Jmp, JmpOffset, CheckNOP, False)
170173
End Function
171174

172-
Public Shared Function CheckJumpInstruction(Jmp() As Byte, CheckNOP As Boolean, CheckDestination As Boolean) As Boolean
175+
Public Shared Function CheckJumpInstruction(Jmp() As Byte, JmpOffset As UInteger, CheckNOP As Boolean, CheckDestination As Boolean) As Boolean
173176
Dim Result As Boolean = False
174177

175178
If Jmp(0) = &HEB And (Not CheckNOP Or Jmp(2) = &H90) Then
176179
If CheckDestination Then
177-
Dim Offset As UShort = Jmp(1) + 2
180+
Dim Offset As UShort = Jmp(1) + JmpOffset + 2
178181
Result = (Offset < BootSectorOffsets.BootStrapSignature)
179182
Else
180183
Result = True
181184
End If
182185
ElseIf Jmp(0) = &HE9 Then
183186
If CheckDestination Then
184-
Dim Offset As UShort = BitConverter.ToUInt16(Jmp, 1) + 3
187+
Dim Offset As UShort = BitConverter.ToUInt16(Jmp, 1) + JmpOffset + 3
185188
Result = (Offset < BootSectorOffsets.BootStrapSignature)
186189
Else
187190
Result = True
@@ -199,7 +202,7 @@
199202
End Function
200203

201204
Public Function GetBootStrapCode(Jmp() As Byte) As Byte()
202-
Dim Offset = GetBootStrapOffset(Jmp)
205+
Dim Offset = GetBootStrapOffset(Jmp, GetBootStrapOffset())
203206

204207
Return GetBootStrapCode(Offset)
205208
End Function
@@ -213,32 +216,56 @@
213216
End If
214217
End Function
215218

216-
Public Shared Function GetBootStrapOffset(Jmp() As Byte) As UShort
219+
Private Shared Function GetBootStrapOffset(Jmp() As Byte, JmpOffset As UInteger) As UShort
217220
Dim Offset As UShort
218221

219222
If Jmp(0) = &HEB Then
220-
Offset = Jmp(1) + 2
223+
Offset = Jmp(1) + JmpOffset + 2
221224
ElseIf Jmp(0) = &HE9 Then
222-
Offset = BitConverter.ToUInt16(Jmp, 1) + 3
225+
Offset = BitConverter.ToUInt16(Jmp, 1) + JmpOffset + 3
223226
Else
224-
Offset = 0
227+
Offset = JmpOffset
225228
End If
226229

227230
If Offset >= BootSectorOffsets.BootStrapSignature Then
228-
Offset = 0
231+
Offset = JmpOffset
229232
End If
230233

231234
Return Offset
232235
End Function
233236

234237
Public Function GetBootStrapOffset() As UShort
235-
Return GetBootStrapOffset(JmpBoot)
238+
Return GetBootStrapOffset(JmpBoot, GetJmpBootOffset())
236239
End Function
237240

238241
Public Function GetFileSystemTypeString() As String
239242
Return CodePage437ToUnicode(FileSystemType)
240243
End Function
241244

245+
Public Function GetJmpBootOffset() As UInteger
246+
Dim Offset = BootSectorOffsets.JmpBoot
247+
If IsFMTowns() Then
248+
Offset += BootSectorSizes.FMTownsSignature
249+
End If
250+
Return Offset
251+
End Function
252+
253+
Public Function GetOEMNameOffset() As UInteger
254+
Dim Offset = BootSectorOffsets.OEMName
255+
If IsFMTowns() Then
256+
Offset += BootSectorSizes.FMTownsSignature
257+
End If
258+
Return Offset
259+
End Function
260+
261+
Public Function GetOEMNameSize() As UInteger
262+
Dim Size = BootSectorSizes.OEMName
263+
If IsFMTowns() Then
264+
Size -= BootSectorSizes.FMTownsSignature
265+
End If
266+
Return Size
267+
End Function
268+
242269
Public Function GetOEMNameString() As String
243270
Return CodePage437ToUnicode(OEMName)
244271
End Function
@@ -259,9 +286,23 @@
259286
Return ValidExtendedBootSignature.Contains(ExtendedBootSignature)
260287
End Function
261288

289+
Public Function IsFMTowns() As Boolean
290+
Dim Signature = _FloppyImage.GetBytes(BootSectorOffsets.FMTownsSignature, BootSectorSizes.FMTownsSignature)
291+
292+
If Signature(0) = &H49 AndAlso Signature(1) = &H50 AndAlso Signature(2) = &H4C AndAlso Signature(3) = &H34 Then
293+
Return True
294+
End If
295+
296+
Return False
297+
End Function
298+
262299
Public Function IsWin9xOEMName() As Boolean
263300
Dim OEMNameLocal = OEMName
264301

302+
If OEMNameLocal.Length < 8 Then
303+
Return False
304+
End If
305+
265306
Return OEMNameLocal(5) = &H49 And OEMNameLocal(6) = &H48 And OEMNameLocal(7) = &H43
266307
End Function
267308
End Class

DiskImageTool/FloppyDB.xml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7697,7 +7697,7 @@
76977697
</release>
76987698
</title>
76997699
<title name="Outpost: 1.1 Patch" publisher="Sierra On-Line, Inc.">
7700-
<release version="1.1, Int. 7.15.94" media="1.44M" status="V">
7700+
<release year="1994" version="1.1, Int. 7.15.94" media="1.44M" status="V">
77017701
<disk md5="748D8E2A415F43A6EB5504FC4506E4DD"/>
77027702
</release>
77037703
</title>
@@ -7712,7 +7712,7 @@
77127712
</release>
77137713
</title>
77147714
<title name="Outpost: Launch Control Disk" publisher="Sierra On-Line, Inc.">
7715-
<release version="1.0, Int. 6.24.94" media="1.44M" status="V">
7715+
<release year="1994" version="1.0, Int. 6.24.94" media="1.44M" status="V">
77167716
<disk md5="094FCC60243FCC2AB9C0CDF40F6A7995"/>
77177717
</release>
77187718
</title>
@@ -8728,7 +8728,7 @@
87288728
</release>
87298729
</title>
87308730
<title name="Red Baron: Customer Service Joystick Patch" publisher="Sierra On-Line, Inc.">
8731-
<release version="1.0, Int. 3.19.92" media="720K" status="V">
8731+
<release year="1992" version="1.0, Int. 3.19.92" media="720K" status="V">
87328732
<disk md5="8977FE97105A77A675885440E73037BE"/>
87338733
</release>
87348734
</title>
@@ -14076,7 +14076,7 @@
1407614076
</release>
1407714077
</title>
1407814078
<title name="Matterhorn Screamer!" publisher="Hi-Tech Expressions, Inc.">
14079-
<release media="360K" status="U">
14079+
<release year="1988" media="360K" status="U">
1408014080
<disk md5="7EEF7A78BDEBC4A44BC15AC227B7B861"/>
1408114081
</release>
1408214082
</title>
@@ -14530,13 +14530,15 @@
1453014530
<disk md5="D704D49BD809A2D3789C37CC078B5482" disk="2"/>
1453114531
</release>
1453214532
</title>
14533-
<title name="Double Dragon III: The Rosetta Stone" status="U" publisher="Tradewest, Inc.">
14534-
<release year="1992" media="360K">
14535-
<disk md5="2FF0E0BF273C043BBC2F8C6216E609F1" disk="1"/>
14536-
<disk md5="85E478D4DB793A79DAF207406E7E436F" disk="2"/>
14537-
</release>
14538-
<release year="1992" media="720K">
14539-
<disk md5="0C47D816F6B73FAEBD591FE95227A9FE"/>
14533+
<title name="Double Dragon III: The Rosetta Stone" publisher="Tradewest, Inc.">
14534+
<release year="1992" status="U">
14535+
<media media="360K">
14536+
<disk md5="2FF0E0BF273C043BBC2F8C6216E609F1" disk="1"/>
14537+
<disk md5="85E478D4DB793A79DAF207406E7E436F" disk="2"/>
14538+
</media>
14539+
<media media="720K">
14540+
<disk md5="0C47D816F6B73FAEBD591FE95227A9FE"/>
14541+
</media>
1454014542
</release>
1454114543
</title>
1454214544
<title name="Dune" publisher="Virgin Games, Inc.">

DiskImageTool/Forms/BootSectorForm.vb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ Public Class BootSectorForm
398398
End Sub
399399

400400
Private Sub PopulateOEMName()
401+
CboOEMName.MaxLength = _BootSector.GetOEMNameSize
402+
HexOEMName.MaskLength = _BootSector.GetOEMNameSize
403+
401404
Dim OEMName As New OEMNameData With {
402405
.Name = _BootSector.OEMName
403406
}

DiskImageTool/HexView/HexViews.vb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ Module HexViews
112112
ForeColor = Color.Black
113113
End If
114114

115-
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.JmpBoot, ForeColor)
115+
HighlightedRegions.AddBootSectorOffset(BootSectorDescription(BootSectorOffsets.JmpBoot), Disk.BootSector.GetJmpBootOffset, BootSectorSizes.JmpBoot, ForeColor)
116116
If Disk.IsValidImage Then
117117
If Disk.BootSector.CheckJumpInstruction(False) AndAlso Disk.BootSector.BPB.IsValid Then
118-
If BootStrapStart < 3 Or BootStrapStart >= BootSectorOffsets.OEMName + BootSectorSizes.OEMName Then
119-
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.OEMName, Color.Red)
118+
If BootStrapStart < 3 Or BootStrapStart >= Disk.BootSector.GetOEMNameOffset + Disk.BootSector.GetOEMNameSize Then
119+
HighlightedRegions.AddBootSectorOffset(BootSectorDescription(BootSectorOffsets.OEMName), Disk.BootSector.GetOEMNameOffset, Disk.BootSector.GetOEMNameSize, Color.Red)
120120
End If
121121
If BootStrapStart < 3 Or BootStrapStart >= BPBOoffsets.HiddenSectors + BPBSizes.HiddenSectors Then
122122
HighlightedRegions.AddBPBoffset(BPBOoffsets.BytesPerSector, Color.Blue)

DiskImageTool/HexView/HighlightedRegions.vb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
Me.Add(New HexViewHighlightRegion(Offset, Size, ForeColor, DiskImage.BootSectorDescription(Offset)))
1313
End Sub
1414

15+
Public Sub AddBootSectorOffset(Description As String, Offset As DiskImage.BootSector.BootSectorOffsets, Size As DiskImage.BootSector.BootSectorSizes, ForeColor As Color)
16+
Me.Add(New HexViewHighlightRegion(Offset, Size, ForeColor, Description))
17+
End Sub
18+
1519
Public Sub AddBPBoffset(Offset As DiskImage.BiosParameterBlock.BPBOoffsets, ForeColor As Color)
1620
Dim Name As String = [Enum].GetName(GetType(DiskImage.BiosParameterBlock.BPBOoffsets), Offset)
1721
Dim Size As DiskImage.BiosParameterBlock.BPBSizes

0 commit comments

Comments
 (0)