Skip to content

Commit 2be9449

Browse files
committed
Disks imported from HDFs are only marked as bootable when a boot block exists (#876)
1 parent bcf65d2 commit 2be9449

File tree

7 files changed

+45
-25
lines changed

7 files changed

+45
-25
lines changed

Emulator/VAmiga/Components/Zorro/HdController.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ HdController::spypeek16(u32 addr) const
261261
return u16(drive.numDrivers());
262262

263263
case EXPROM_SIZE + 4:
264-
264+
265265
// Should auto boot be disabled?
266-
if (df0.hasDisk() || drive.bootable == false) {
266+
if (df0.hasDisk() || !drive.hasBootBlock()) {
267267

268268
debug(HDR_DEBUG, "Disabling auto boot\n");
269269
return u16(true);

Emulator/VAmiga/FileSystems/BootBlockImage.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,11 +1183,11 @@ BootBlockImage::BootBlockImage(BootBlockId bootBlockID)
11831183

11841184
switch (bootBlockID) {
11851185

1186-
case BootBlockId::AMIGADOS_13: name = "AmigaDOS Standard Bootblock 1.3"; break;
1187-
case BootBlockId::AMIGADOS_20: name = "AmigaDOS Standard Bootblock 2.0"; break;
1188-
case BootBlockId::SCA: name = "SCA Virus"; break;
1189-
case BootBlockId::BYTE_BANDIT: name = "Byte Bandit 1 Virus"; break;
1190-
default: name = ""; break;
1186+
case BootBlockId::AMIGADOS_13: name = "AmigaDOS Standard Bootblock 1.3"; break;
1187+
case BootBlockId::AMIGADOS_20: name = "AmigaDOS Standard Bootblock 2.0"; break;
1188+
case BootBlockId::SCA: name = "SCA Virus"; break;
1189+
case BootBlockId::BYTE_BANDIT: name = "Byte Bandit 1 Virus"; break;
1190+
default: name = ""; break;
11911191
}
11921192

11931193
BootBlockImage bb = BootBlockImage(string(name));

Emulator/VAmiga/Media/DiskFiles/HDFFile.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ HDFFile::getPartitionDescriptor(isize part) const
160160
auto geo = getGeometryDescriptor();
161161
result = PartitionDescriptor(geo);
162162

163-
// Make the first partition bootable
164-
result.flags |= 1;
163+
// Make the first partition bootable if a boot block exists
164+
if (hasBootBlock()) result.flags |= 1;
165165
}
166166

167167
return result;
@@ -299,6 +299,17 @@ HDFFile::getInfo() const
299299
return info;
300300
}
301301

302+
bool
303+
HDFFile::hasBootBlock() const
304+
{
305+
if (data.size > 512) {
306+
for (isize i = 12; i < 512; i++) {
307+
if (data[i]) return true;
308+
}
309+
}
310+
return false;
311+
}
312+
302313
bool
303314
HDFFile::hasRDB() const
304315
{

Emulator/VAmiga/Media/DiskFiles/HDFFile.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ class HDFFile : public DiskFile {
115115

116116
// Returns the (predicted) geometry for this disk
117117
const GeometryDescriptor getGeometry() const { return geometry; }
118-
118+
119+
// Returns true if this image contains a boot block
120+
bool hasBootBlock() const;
121+
119122
// Returns true if this image contains a rigid disk block
120123
bool hasRDB() const;
121124

Emulator/VAmiga/Peripherals/Drive/HardDrive.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ HardDrive::operator= (const HardDrive& other) {
4646
CLONE(head)
4747
CLONE(state)
4848
CLONE(flags)
49-
CLONE(bootable)
5049

5150
if (RUA_ON_STEROIDS) {
5251

@@ -297,7 +296,6 @@ HardDrive::connect()
297296
debug(WT_DEBUG, "Creating default disk...\n");
298297
init(MB(10));
299298
format(FSVolumeType::OFS, defaultName());
300-
bootable = false;
301299
}
302300
}
303301

@@ -385,12 +383,8 @@ HardDrive::_dump(Category category, std::ostream& os) const
385383
os << HardDriveStateEnum::key(state) << std::endl;
386384
os << tab("Flags");
387385
os << DiskFlagsEnum::mask(flags) << std::endl;
388-
os << tab("Bootable");
389-
if (bootable) {
390-
os << bol(*bootable) << std::endl;
391-
} else {
392-
os << "Unknown" << std::endl;
393-
}
386+
os << tab("Boot block");
387+
os << bol(hasBootBlock()) << std::endl;
394388
os << tab("Capacity");
395389
os << dec(cap1) << "." << dec(cap2) << " MB" << std::endl;
396390
geometry.dump(os);
@@ -489,6 +483,17 @@ HardDrive::setProtectionFlag(bool value)
489483
if (hasDisk()) setFlag(DiskFlags::PROTECTED, value);
490484
}
491485

486+
bool
487+
HardDrive::hasBootBlock() const
488+
{
489+
if (data.size > 512) {
490+
for (isize i = 12; i < 512; i++) {
491+
if (data[i]) return true;
492+
}
493+
}
494+
return false;
495+
}
496+
492497
string
493498
HardDrive::defaultName(isize partition) const
494499
{

Emulator/VAmiga/Peripherals/Drive/HardDrive.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class HardDrive final : public Drive, public Inspectable<HardDriveInfo> {
9898

9999
// Disk state flags
100100
long flags = 0;
101-
optional <bool> bootable;
101+
// optional <bool> bootable;
102102

103103

104104
//
@@ -223,8 +223,7 @@ class HardDrive final : public Drive, public Inspectable<HardDriveInfo> {
223223
<< ptable
224224
<< drivers
225225
<< data
226-
<< flags
227-
<< bootable;
226+
<< flags;
228227

229228
} SERIALIZERS(serialize, override);
230229

@@ -264,6 +263,8 @@ class HardDrive final : public Drive, public Inspectable<HardDriveInfo> {
264263
void setModificationFlag(bool value) override;
265264
void setProtectionFlag(bool value) override;
266265

266+
bool hasBootBlock() const;
267+
267268

268269
//
269270
// Methods from Configurable

vAmiga.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3213,7 +3213,7 @@
32133213
CODE_SIGN_IDENTITY = "Apple Development";
32143214
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
32153215
CODE_SIGN_STYLE = Automatic;
3216-
CURRENT_PROJECT_VERSION = 250204;
3216+
CURRENT_PROJECT_VERSION = 250208;
32173217
DEVELOPMENT_TEAM = "";
32183218
ENABLE_HARDENED_RUNTIME = YES;
32193219
GCC_C_LANGUAGE_STANDARD = gnu17;
@@ -3229,7 +3229,7 @@
32293229
);
32303230
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
32313231
MACOSX_DEPLOYMENT_TARGET = 15.1;
3232-
MARKETING_VERSION = 3.3;
3232+
MARKETING_VERSION = 4.0b1;
32333233
PRODUCT_BUNDLE_IDENTIFIER = dirkwhoffmann.vAmiga.QuickLookPlugIn;
32343234
PRODUCT_NAME = "$(TARGET_NAME)";
32353235
SKIP_INSTALL = YES;
@@ -3247,7 +3247,7 @@
32473247
CODE_SIGN_IDENTITY = "Apple Development";
32483248
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
32493249
CODE_SIGN_STYLE = Automatic;
3250-
CURRENT_PROJECT_VERSION = 250204;
3250+
CURRENT_PROJECT_VERSION = 250208;
32513251
DEVELOPMENT_TEAM = "";
32523252
ENABLE_HARDENED_RUNTIME = YES;
32533253
GCC_C_LANGUAGE_STANDARD = gnu17;
@@ -3263,7 +3263,7 @@
32633263
);
32643264
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
32653265
MACOSX_DEPLOYMENT_TARGET = 15.1;
3266-
MARKETING_VERSION = 3.3;
3266+
MARKETING_VERSION = 4.0b1;
32673267
PRODUCT_BUNDLE_IDENTIFIER = dirkwhoffmann.vAmiga.QuickLookPlugIn;
32683268
PRODUCT_NAME = "$(TARGET_NAME)";
32693269
SKIP_INSTALL = YES;

0 commit comments

Comments
 (0)