support for nubus mac pseudo disk images

This commit is contained in:
Kelvin Sherlock 2021-01-18 15:32:22 -05:00
parent dc5ab08d4b
commit 0c7c9e9d1b
2 changed files with 24 additions and 10 deletions

View File

@ -240,9 +240,13 @@
} }
@end @end
#define CATEGORY_COUNT 6
#define SIZEOF(x) (sizeof(x) / sizeof(x[0]))
@interface MediaViewController () { @interface MediaViewController () {
MediaCategory *_data[5]; MediaCategory *_data[CATEGORY_COUNT];
NSArray *_root; NSArray *_root;
NSDictionary *_media; NSDictionary *_media;
} }
@ -258,20 +262,21 @@
if (first) return; if (first) return;
first++; first++;
MediaCategory *a, *b, *c, *d, *e; MediaCategory *a, *b, *c, *d, *e, *f;
a = [[MediaCategory alloc] initWithTitle: @"5.25\" Floppies"]; a = [[MediaCategory alloc] initWithTitle: @"5.25\" Floppies"];
b = [[MediaCategory alloc] initWithTitle: @"3.5\" Floppies"]; b = [[MediaCategory alloc] initWithTitle: @"3.5\" Floppies"];
c = [[MediaCategory alloc] initWithTitle: @"Hard Drives"]; c = [[MediaCategory alloc] initWithTitle: @"Hard Drives"];
d = [[MediaCategory alloc] initWithTitle: @"CD-ROMs"]; d = [[MediaCategory alloc] initWithTitle: @"CD-ROMs"];
e = [[MediaCategory alloc] initWithTitle: @"Cassettes"]; e = [[MediaCategory alloc] initWithTitle: @"Cassettes"];
f = [[MediaCategory alloc] initWithTitle: @"Hard Disk Images"];
_data[0] = a; _data[0] = a;
_data[1] = b; _data[1] = b;
_data[2] = c; _data[2] = c;
_data[3] = d; _data[3] = d;
_data[4] = e; _data[4] = e;
_data[5] = f;
_root = @[]; _root = @[];
@ -283,19 +288,21 @@ enum {
kIndexFloppy_3_5, kIndexFloppy_3_5,
kIndex_HardDrive, kIndex_HardDrive,
kIndexCDROM, kIndexCDROM,
kIndexCassette kIndexCassette,
kIndexDisk,
}; };
-(void)rebuildArgs { -(void)rebuildArgs {
static char* prefix[] = { static char* prefix[] = {
"flop", "flop", "hard", "cdrm", "cass" "flop", "flop", "hard", "cdrm", "cass", "disk"
}; };
static_assert(SIZEOF(prefix) == CATEGORY_COUNT, "Missing item");
NSMutableArray *args = [NSMutableArray new]; NSMutableArray *args = [NSMutableArray new];
unsigned counts[5] = { 0, 0, 0, 0, 0 }; unsigned counts[CATEGORY_COUNT] = { 0 };
for (unsigned j = 0; j < 5; ++j) { for (unsigned j = 0; j < CATEGORY_COUNT; ++j) {
MediaCategory *cat = _data[j]; MediaCategory *cat = _data[j];
NSInteger valid = [cat validCount]; NSInteger valid = [cat validCount];
@ -319,7 +326,7 @@ enum {
-(void)rebuildRoot { -(void)rebuildRoot {
NSMutableArray *tmp = [NSMutableArray new]; NSMutableArray *tmp = [NSMutableArray new];
int ix = 0; int ix = 0;
for (unsigned j = 0 ; j < 5; ++j) { for (unsigned j = 0 ; j < CATEGORY_COUNT; ++j) {
MediaCategory *cat = _data[j]; MediaCategory *cat = _data[j];
[cat setIndex: -1]; [cat setIndex: -1];
if ([cat count]) { if ([cat count]) {
@ -343,8 +350,10 @@ enum {
@"flop_3_5", @"flop_3_5",
@"hard", @"hard",
@"cdrm", @"cdrm",
@"cass" @"cass",
@"disk",
}; };
static_assert(SIZEOF(Keys) == CATEGORY_COUNT, "Missing item");
NSNumber *o; NSNumber *o;
MediaCategory *cat; MediaCategory *cat;
@ -355,7 +364,7 @@ enum {
if (_media == media) return; if (_media == media) return;
_media = media; _media = media;
for (unsigned j = 0; j < 5; ++j) { for (unsigned j = 0; j < CATEGORY_COUNT; ++j) {
o = [media objectForKey: Keys[j]]; o = [media objectForKey: Keys[j]];
i = [o unsignedIntValue]; i = [o unsignedIntValue];

View File

@ -324,6 +324,7 @@ static_assert(MAX_SLOTS <= sizeof(unsigned) * 8, "too many slot types");
unsigned hard = 0; unsigned hard = 0;
unsigned flop_5_25 = 0; unsigned flop_5_25 = 0;
unsigned flop_3_5 = 0; unsigned flop_3_5 = 0;
unsigned pseudo_disk = 0; // mac psuedo disk
#if 0 #if 0
for (SlotItem *item in _root) { for (SlotItem *item in _root) {
@ -334,6 +335,7 @@ static_assert(MAX_SLOTS <= sizeof(unsigned) * 8, "too many slot types");
_(hard, tmp); _(hard, tmp);
_(flop_5_25, tmp); _(flop_5_25, tmp);
_(flop_3_5, tmp); _(flop_3_5, tmp);
_(pseudo_disk, tmp);
} }
} }
#endif #endif
@ -349,6 +351,7 @@ static_assert(MAX_SLOTS <= sizeof(unsigned) * 8, "too many slot types");
_(hard, tmp); _(hard, tmp);
_(flop_5_25, tmp); _(flop_5_25, tmp);
_(flop_3_5, tmp); _(flop_3_5, tmp);
_(pseudo_disk, tmp);
} }
} }
} }
@ -360,6 +363,7 @@ static_assert(MAX_SLOTS <= sizeof(unsigned) * 8, "too many slot types");
_(hard, tmp); _(hard, tmp);
_(flop_5_25, tmp); _(flop_5_25, tmp);
_(flop_3_5, tmp); _(flop_3_5, tmp);
_(pseudo_disk, tmp);
} }
[self setMedia: @{ [self setMedia: @{
@ -368,6 +372,7 @@ static_assert(MAX_SLOTS <= sizeof(unsigned) * 8, "too many slot types");
@"hard": @(hard), @"hard": @(hard),
@"flop_5_25": @(flop_5_25), @"flop_5_25": @(flop_5_25),
@"flop_3_5": @(flop_3_5), @"flop_3_5": @(flop_3_5),
@"disk": @(pseudo_disk),
}]; }];
} }