User can now specify wether the selected disk image is a CDROM (required for some games e.g. Diablo 2)

This commit is contained in:
Maximilian Irlinger 2014-03-02 14:32:57 +01:00
parent a3abfdc041
commit fd62819e49
13 changed files with 771 additions and 206 deletions

View File

@ -0,0 +1,23 @@
//
// DiskType.h
// SheepShaver
//
// Created by maximilian on 01.02.14.
// Copyright 2014 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface DiskType : NSObject {
NSString* _path;
BOOL _isCDROM;
}
-(NSString*)path;
-(BOOL)isCDROM;
-(void)setPath:(NSString*)thePath;
-(void)setIsCDROM:(BOOL)cdrom;
@end

View File

@ -0,0 +1,35 @@
//
// DiskType.m
// SheepShaver
//
// Created by maximilian on 01.02.14.
// Copyright 2014 __MyCompanyName__. All rights reserved.
//
#import "DiskType.h"
@implementation DiskType
-(NSString*)path
{
return _path;
}
-(BOOL)isCDROM
{
return _isCDROM;
}
-(void)setPath:(NSString*)thePath
{
_path = [thePath copy];
}
-(void)setIsCDROM:(BOOL)cdrom
{
_isCDROM=cdrom;
}
-(NSString*)description {
return [NSString stringWithFormat:@"DiskType, path:%@ isCDROM:%@", _path, _isCDROM];
}
@end

View File

View File

0
SheepShaver/src/MacOSX/Launcher/English.lproj/MainMenu.nib/info.nib generated Normal file → Executable file
View File

View File

View File

View File

File diff suppressed because it is too large Load Diff

Binary file not shown.

4
SheepShaver/src/MacOSX/Launcher/VMSettingsController.h Normal file → Executable file
View File

@ -31,6 +31,10 @@
IBOutlet NSTextField *diskSaveSizeField;
NSMutableArray *diskArray;
IBOutlet NSView *isCDROM;
IBOutlet NSButton *isCDROMcheckbox;
//NSMutableArray *cdromArray;
// Setup
IBOutlet NSTableView *disks;
IBOutlet NSComboBox *bootFrom;

83
SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm Normal file → Executable file
View File

@ -26,8 +26,11 @@
#import "VMSettingsController.h"
#import "DiskType.h"
#include <unistd.h>
const int CDROMRefNum = -62; // RefNum of driver
#ifdef STANDALONE_PREFS
@ -62,12 +65,28 @@ void prefs_exit()
- (int) numberOfRowsInTableView: (NSTableView *) table
{
//NSLog(@"Count of diskArray: %d", [diskArray count]);
return [diskArray count];
}
- (id) tableView: (NSTableView *) table objectValueForTableColumn: (NSTableColumn *) col row: (int) row
{
return [diskArray objectAtIndex: row];
DiskType *d = (DiskType*)[diskArray objectAtIndex:row];
if([[col identifier] isEqualTo:@"isCDROMcol"])
{
return [NSString stringWithFormat:@"%d", [d isCDROM]];
}
return [d path];
}
-(void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
if ([[tableColumn identifier] isEqual:@"isCDROMcol"]) {
DiskType *d = (DiskType*)[diskArray objectAtIndex:row];
[d setIsCDROM:![d isCDROM]];
}
}
static NSString *getStringFromPrefs(const char *key)
@ -85,11 +104,27 @@ static NSString *getStringFromPrefs(const char *key)
const char *dsk;
int index = 0;
while ((dsk = PrefsFindString("disk", index++)) != NULL)
[diskArray addObject: [NSString stringWithUTF8String: dsk ]];
[disks setDataSource: self];
[disks reloadData];
{
DiskType *disk = [[DiskType alloc] init];
[disk setPath:[NSString stringWithUTF8String: dsk ]];
[disk setIsCDROM:NO];
[diskArray addObject:disk];
}
/* Fetch all CDROMs */
index = 0;
while ((dsk=PrefsFindString("cdrom", index++))!=NULL) {
DiskType *disk = [[DiskType alloc] init];
[disk setPath:[NSString stringWithUTF8String: dsk ]];
[disk setIsCDROM:YES];
[diskArray addObject:disk];
}
[disks setDataSource: self];
[disks reloadData];
int bootdriver = PrefsFindInt32("bootdriver"), active = 0;
switch (bootdriver) {
case 0: active = 0; break;
@ -212,6 +247,7 @@ static NSString *makeRelativeIfNecessary(NSString *path)
{
NSOpenPanel *open = [NSOpenPanel openPanel];
[open setCanChooseDirectories:YES];
[open setAccessoryView:isCDROM];
[open setAllowsMultipleSelection:NO];
[open setTreatsFilePackagesAsDirectories:YES];
[open beginSheetForDirectory: [[NSFileManager defaultManager] currentDirectoryPath]
@ -225,8 +261,19 @@ static NSString *makeRelativeIfNecessary(NSString *path)
- (void) _addDiskEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo
{
if (theReturnCode == NSOKButton) {
[diskArray addObject: makeRelativeIfNecessary([open filename])];
[disks reloadData];
DiskType *d=[[DiskType alloc] init];
[d setPath:makeRelativeIfNecessary([open filename])];
if([isCDROMcheckbox state]==NSOnState)
{
[d setIsCDROM:YES];
}
else {
[d setIsCDROM:NO];
}
[diskArray addObject: d];
[disks reloadData];
}
}
@ -261,7 +308,11 @@ static NSString *makeRelativeIfNecessary(NSString *path)
snprintf(cmd, sizeof(cmd), "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", [[save filename] UTF8String], [diskSaveSizeField intValue]);
int ret = system(cmd);
if (ret == 0) {
[diskArray addObject: makeRelativeIfNecessary([save filename])];
DiskType *d=[[DiskType alloc] init];
[d setPath:makeRelativeIfNecessary([save filename])];
[d setIsCDROM:NO];
[diskArray addObject: d];
[disks reloadData];
}
}
@ -350,12 +401,24 @@ static NSString *makeRelativeIfNecessary(NSString *path)
- (void) saveChanges: (id) sender
{
// Remove all disks
while (PrefsFindString("disk"))
PrefsRemoveItem("disk");
// Remove all cdroms
while (PrefsFindString("cdrom"))
PrefsRemoveItem("cdrom");
// Write all disks
for (int i = 0; i < [diskArray count]; i++) {
PrefsAddString("disk", [[diskArray objectAtIndex:i] UTF8String]);
DiskType *d = [diskArray objectAtIndex:i];
if([d isCDROM])
PrefsAddString("cdrom", [[d path] UTF8String]);
else
PrefsAddString("disk", [[d path] UTF8String]);
}
PrefsReplaceInt32("bootdriver", ([bootFrom indexOfSelectedItem] == 1 ? CDROMRefNum : 0));
PrefsReplaceString("rom", [[romFile stringValue] UTF8String]);
PrefsReplaceString("extfs", [[unixRoot stringValue] UTF8String]);

View File

@ -129,6 +129,7 @@
08CD42DC14B7B85B009CA2A2 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08CD42DB14B7B85B009CA2A2 /* Cocoa.framework */; };
08CD42E814B7B8AA009CA2A2 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08CD42E714B7B8AA009CA2A2 /* Carbon.framework */; };
08D93A16159FE174003B04EC /* clip_macosx64.mm in Sources */ = {isa = PBXBuildFile; fileRef = 08D93A15159FE174003B04EC /* clip_macosx64.mm */; };
A7B1921418C35D4700791D8D /* DiskType.m in Sources */ = {isa = PBXBuildFile; fileRef = A7B1921318C35D4700791D8D /* DiskType.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -448,6 +449,8 @@
08CD42DB14B7B85B009CA2A2 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
08CD42E714B7B8AA009CA2A2 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
08D93A15159FE174003B04EC /* clip_macosx64.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = clip_macosx64.mm; sourceTree = "<group>"; };
A7B1921218C35D4700791D8D /* DiskType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiskType.h; sourceTree = "<group>"; };
A7B1921318C35D4700791D8D /* DiskType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DiskType.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -940,6 +943,8 @@
0856D2D614A9A704000B1711 /* Launcher */ = {
isa = PBXGroup;
children = (
A7B1921218C35D4700791D8D /* DiskType.h */,
A7B1921318C35D4700791D8D /* DiskType.m */,
0856D30714A9A704000B1711 /* VMSettingsWindow.nib */,
0856D31114A9A704000B1711 /* VMSettingsController.h */,
0856D31214A9A704000B1711 /* VMSettingsController.mm */,
@ -1452,6 +1457,7 @@
0873A80214AC515D004F12B7 /* utils_macosx.mm in Sources */,
083E370C16EFE85000CCCA59 /* disk_sparsebundle.cpp in Sources */,
083E372216EFE87200CCCA59 /* tinyxml2.cpp in Sources */,
A7B1921418C35D4700791D8D /* DiskType.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};