Skip to content

Commit

Permalink
Work on HardDrive APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jul 12, 2024
1 parent 9f6bec2 commit 92f4bd1
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 128 deletions.
2 changes: 1 addition & 1 deletion Emulator/Components/Zorro/HdController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void
HdController::cacheInfo(HdcInfo &result) const
{
result.pluggedIn = pluggedIn();
result.state = state;
result.state = getHdcState();
}

void
Expand Down
9 changes: 3 additions & 6 deletions Emulator/Components/Zorro/HdController.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,10 @@ class HdController : public ZorroBoard, public Inspectable<HdcInfo, HdcStats> {
//

public:

// const HdcStats &getStats() { return stats; }
// void clearStats() { stats = { }; }


// Returns the current controller state
HdcState getHdcState() { return hdcState; }
HdcState getHdcState() const { return hdcState; }

// Informs whether the controller is compatible with a certain Kickstart
bool isCompatible(u32 crc32);
bool isCompatible();
Expand Down
20 changes: 8 additions & 12 deletions Emulator/VAmiga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,27 +1122,23 @@ VAmiga::VAmiga() {

hd0.emu = emu;
hd0.drive = &emu->main.hd0;
hd0.controller.emu = emu;
hd0.controller.controller = &emu->main.hd0con;

hd1.emu = emu;
hd1.drive = &emu->main.hd1;
hd1.controller.emu = emu;
hd1.controller.controller = &emu->main.hd1con;

hd2.emu = emu;
hd2.drive = &emu->main.hd2;
hd2.controller.emu = emu;
hd2.controller.controller = &emu->main.hd2con;

hd3.emu = emu;
hd3.drive = &emu->main.hd3;

hd0con.emu = emu;
hd0con.controller = &emu->main.hd0con;

hd1con.emu = emu;
hd1con.controller = &emu->main.hd1con;

hd2con.emu = emu;
hd2con.controller = &emu->main.hd2con;

hd3con.emu = emu;
hd3con.controller = &emu->main.hd3con;
hd3.controller.emu = emu;
hd3.controller.controller = &emu->main.hd3con;

host.emu = emu;
host.host = &emu->host;
Expand Down
54 changes: 26 additions & 28 deletions Emulator/VAmiga.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,12 +585,38 @@ struct FloppyDriveAPI : public API {
// Peripherals (HardDrive)
//

class HdControllerAPI : public API {

friend class VAmiga;

class HdController *controller = nullptr;

public:

/** @brief Provides details about the currently selected chip revision.
*/
// const HdcTraits &getTraits() const;

/** @brief Returns the component's current state.
*/
const HdcInfo &getInfo() const;
const HdcInfo &getCachedInfo() const;

/** @brief Returns statistical information about the components.
*/
const HdcStats &getStats() const;
};

struct HardDriveAPI : public API {

friend class VAmiga;

class HardDrive *drive = nullptr;

public:

HdControllerAPI controller;

/** @brief Returns the component's current configuration.
*/
const HardDriveConfig &getConfig() const;
Expand All @@ -614,33 +640,6 @@ struct HardDriveAPI : public API {
};


//
// Peripherals (HardDrive)
//

class HdControllerAPI : public API {

friend class VAmiga;

class HdController *controller = nullptr;

public:

/** @brief Provides details about the currently selected chip revision.
*/
// const HdcTraits &getTraits() const;

/** @brief Returns the component's current state.
*/
const HdcInfo &getInfo() const;
const HdcInfo &getCachedInfo() const;

/** @brief Returns statistical information about the components.
*/
const HdcStats &getStats() const;
};


//
// Peripherals (Joystick)
//
Expand Down Expand Up @@ -1352,7 +1351,6 @@ class VAmiga : public API {
// Peripherals
FloppyDriveAPI df0, df1, df2, df3;
HardDriveAPI hd0, hd1, hd2, hd3;
HdControllerAPI hd0con, hd1con, hd2con, hd3con;
KeyboardAPI keyboard;

// Misc
Expand Down
44 changes: 22 additions & 22 deletions Proxy/EmulatorProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@
HardDriveProxy *hd1;
HardDriveProxy *hd2;
HardDriveProxy *hd3;
/*
HdControllerProxy *hd0con;
HdControllerProxy *hd1con;
HdControllerProxy *hd2con;
HdControllerProxy *hd3con;
*/
KeyboardProxy *keyboard;
MemProxy *mem;
PaulaProxy *paula;
Expand Down Expand Up @@ -198,10 +200,12 @@
@property (readonly, strong) HardDriveProxy *hd1;
@property (readonly, strong) HardDriveProxy *hd2;
@property (readonly, strong) HardDriveProxy *hd3;
/*
@property (readonly, strong) HdControllerProxy *hd0con;
@property (readonly, strong) HdControllerProxy *hd1con;
@property (readonly, strong) HdControllerProxy *hd2con;
@property (readonly, strong) HdControllerProxy *hd3con;
*/
@property (readonly, strong) KeyboardProxy *keyboard;
@property (readonly, strong) MemProxy *mem;
@property (readonly, strong) PaulaProxy *paula;
Expand Down Expand Up @@ -701,33 +705,40 @@
@end


//
// HdController
//

@interface HdControllerProxy : CoreComponentProxy { }

@property (readonly) HdcInfo info;
@property (readonly) HdcStats stats;

@end


//
// HardDrive
//

@interface HardDriveProxy : CoreComponentProxy { }
@interface HardDriveProxy : CoreComponentProxy {

HdControllerProxy *controller;
}

@property (readonly, strong) HdControllerProxy *controller;

@property (readonly) HardDriveInfo info;
@property (readonly) HardDriveTraits traits;

/*
@property (readonly) NSInteger nr;
@property (readonly) BOOL isConnected;
@property (readonly) NSInteger currentCyl;
@property (readonly) NSInteger currentHead;
@property (readonly) NSInteger currentOffset;
*/

- (BOOL)getFlag:(DiskFlags)mask;
- (void)setFlag:(DiskFlags)mask value:(BOOL)value;

@property (readonly) HdcState hdcState;
@property (readonly) BOOL isCompatible;
@property (readonly) BOOL writeThroughEnabled;
- (NSString *)nameOfPartition:(NSInteger)nr;
- (NSInteger)lowerCylOfPartition:(NSInteger)nr;
- (NSInteger)upperCylOfPartition:(NSInteger)nr;
// @property (readonly) HardDriveState state;
- (void)attachFile:(NSURL *)path exception:(ExceptionWrapper *)ex;
- (void)attach:(HDFFileProxy *)hdf exception:(ExceptionWrapper *)ex;
- (void)attach:(NSInteger)c h:(NSInteger)h s:(NSInteger)s b:(NSInteger)b exception:(ExceptionWrapper *)ex;
Expand All @@ -740,17 +751,6 @@

@end

//
// HdController
//

@interface HdControllerProxy : CoreComponentProxy { }

@property (readonly) HdcInfo info;
@property (readonly) HdcStats stats;

@end


//
// FileSystem
Expand Down
73 changes: 17 additions & 56 deletions Proxy/EmulatorProxy.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,19 @@ - (NSString *)readTrackBits:(NSInteger)track

@implementation HardDriveProxy

@synthesize controller;

- (instancetype)initWith:(void *)ref
{
if (self = [super init]) {

HardDriveAPI *hd = (HardDriveAPI *)ref;
obj = ref;
controller = [[HdControllerProxy alloc] initWith:&hd->controller];
}
return self;
}

- (HardDriveAPI *)drive
{
return (HardDriveAPI *)obj;
Expand All @@ -1313,58 +1326,6 @@ - (HardDriveInfo)info
return [self drive]->getInfo();
}

/*
- (NSInteger)nr
{
return [self drive]->drive->objid;
}
- (BOOL)isConnected
{
return [self drive]->drive->isConnected();
}
- (NSInteger)currentCyl
{
return [self drive]->drive->currentCyl();
}
- (NSInteger)currentHead
{
return [self drive]->drive->currentHead();
}
- (NSInteger)currentOffset
{
return [self drive]->drive->currentOffset();
}
- (BOOL)hasDisk
{
return [self drive]->drive->hasDisk();
}
- (BOOL)hasModifiedDisk
{
return [self drive]->drive->hasModifiedDisk();
}
- (BOOL)hasProtectedDisk
{
return [self drive]->drive->hasProtectedDisk();
}
- (BOOL)hasUnmodifiedDisk
{
return [self drive]->drive->hasUnmodifiedDisk();
}
- (BOOL)hasUnprotectedDisk
{
return [self drive]->drive->hasUnprotectedDisk();
}
*/

- (BOOL)getFlag:(DiskFlags)mask
{
return [self drive]->getFlag(mask);
Expand Down Expand Up @@ -1405,10 +1366,12 @@ - (NSInteger)bsize
return [self drive]->drive->getGeometry().bsize;
}

/*
- (HdcState)hdcState
{
return [self drive]->drive->getHdcState();
}
*/

- (BOOL)isCompatible
{
Expand Down Expand Up @@ -2598,10 +2561,6 @@ @implementation EmulatorProxy
@synthesize hd1;
@synthesize hd2;
@synthesize hd3;
@synthesize hd0con;
@synthesize hd1con;
@synthesize hd2con;
@synthesize hd3con;
@synthesize keyboard;
@synthesize mem;
@synthesize paula;
Expand Down Expand Up @@ -2647,10 +2606,12 @@ - (instancetype) init
hd1 = [[HardDriveProxy alloc] initWith:&vamiga->hd1];
hd2 = [[HardDriveProxy alloc] initWith:&vamiga->hd2];
hd3 = [[HardDriveProxy alloc] initWith:&vamiga->hd3];
/*
hd0con = [[HdControllerProxy alloc] initWith:&vamiga->hd0con];
hd1con = [[HdControllerProxy alloc] initWith:&vamiga->hd1con];
hd2con = [[HdControllerProxy alloc] initWith:&vamiga->hd2con];
hd3con = [[HdControllerProxy alloc] initWith:&vamiga->hd3con];
*/
keyboard = [[KeyboardProxy alloc] initWith:&vamiga->keyboard];
mem = [[MemProxy alloc] initWith:&vamiga->mem];
paula = [[PaulaProxy alloc] initWith:&vamiga->paula];
Expand Down
6 changes: 3 additions & 3 deletions Proxy/ProxyExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ extension HardDriveProxy {

var name: String

switch hdcState {
switch controller.info.state {

case .UNDETECTED, .INITIALIZING:
name = "hdrETemplate"

Expand All @@ -457,7 +457,7 @@ extension HardDriveProxy {

var toolTip: String? {

switch hdcState {
switch controller.info.state {

case .UNDETECTED:
return "The hard drive is waiting to be initialized by the OS."
Expand Down

0 comments on commit 92f4bd1

Please sign in to comment.