• Hello MLAers! We've re-enabled auto-approval for accounts. If you are still waiting on account approval, please check this thread for more information.

Software detection of emulator

Hello everyone,

Does anyone know how to detect if an application is running in SheepShaver, Basilisk II, or Mini vMac? I'm writing a serial transfer utility and thought it would be nice to synchronize the real Macintosh's clock when it is connected to an emulated Mac.

For Basilisk II, I notice that it has a decent identifier in PDS slot #0.
Basilisk II.GIF

The following code works: (I have a library of common routines that start with 'EL_' that check for nil pointers etc. Substitute for whatever you have.)

bool EL_IsEmulator(void) { bool isEmulator = false; if (EL_IsTrapImplemented(_SlotManager)) { OSErr errorCheck; SpBlock slotSearch; EL_MemoryClear(&slotSearch, sizeof(SpBlock)); slotSearch.spCategory = 1; errorCheck = SNextTypeSRsrc(&slotSearch); if (errorCheck == noErr) { slotSearch.spID = 2; errorCheck = SGetCString(&slotSearch); if (errorCheck == noErr) { char* slotNameCStringPtr = (char*) slotSearch.spResult; if (EL_CStringCompare(slotNameCStringPtr, "Basilisk II Slot ROM", true, false) == 0) { isEmulator = true; } EL_DisposePtr(&slotNameCStringPtr); } } } return isEmulator; }

I assume this is a reliable approach. Does anyone know of a more preferred way?

Does anyone know how to detect SheepShaver or Mini vMac?

Thank you,

David
 
sheepshaver's probably similar, try using TattleTech to confirm that. as for MiniVMac, you'd have to figure out if a certain extension is running
 
Yes, look at the top of EXTNSLIB.I in the ImportFl source code: there's a function there (with the usual mini vmac slightly odd coding conventions) that will tell you whether or not the Mini vMac extension mechanism is present.
 
Thank you @Nixontheknight @rplacd and @cheesestraws

This code works at least on recent versions of both Mini vMac and Basilisk. Notice that Basilisk sets the Sony pointer to DEADBEEF. Ha.

At some point, maybe I'll check out Sheep Shaver as well.

typedef enum { kEmulatorType_Unknown = 0, kEmulatorType_None, kEmulatorType_Basilisk, kEmulatorType_MiniVMac, kEmulatorType_SheepShaver } EmulatorType; EmulatorType el_gEmulatorType = kEmulatorType_None; #define kEmulatorSonyIsBasilisk 0xDEADBEEF #define kEmulatorSonyCheckValue 0x841339E2 typedef struct { unsigned long shouldBeZero[4]; unsigned long checkValue; unsigned long pokeAddress; } EmulatorSonyRecord; #define LMGetSonyRecordPtr() (*(EmulatorSonyRecord**) 0x0134) void EL_EmulatorCheckFloppy(void) { EmulatorSonyRecord* sonyRecordPtr = LMGetSonyRecordPtr(); if ((unsigned long)sonyRecordPtr == kEmulatorSonyIsBasilisk) { el_gEmulatorType = kEmulatorType_Basilisk; } else { // Cannot be nil or point to an odd address if ( sonyRecordPtr != nil && (((unsigned long)sonyRecordPtr) & 1) == 0) { // Must have zeros and the proper check value if ( sonyRecordPtr->shouldBeZero[0] == 0 && sonyRecordPtr->shouldBeZero[1] == 0 && sonyRecordPtr->shouldBeZero[2] == 0 // && sonyRecordPtr->shouldBeZero[3] == 0 && sonyRecordPtr->checkValue == kEmulatorSonyCheckValue ) { if (sonyRecordPtr->pokeAddress != nil) { el_gEmulatorType = kEmulatorType_MiniVMac; } } } } }
 
Perhaps I am being overly fastidious, but I must admit to rather preferring the slot manager approach for Basilisk II - it feels rather more transparent and sane.
 
Perhaps I am being overly fastidious, but I must admit to rather preferring the slot manager approach for Basilisk II - it feels rather more transparent and sane.

I agree. It is definitive, compatible, and fitting.

I'm not sure how an emulated 128/512/Plus could indicate 'added hardware'. But, I imagine there is a way.

In my complete code, I first check the slot manager for Basilisk. If nothing, I then call the floppy routine.
 
Most emulators have a detection routine by poking a known memory address and reading back the result. Apple II emulators have a standardized way of doing this.
 
Check the driver list and look for an emulator specific driver? Not helpful unless there's an emulator specific device. DingusPPC doesn't have its own drivers yet but does have its own hard disk drives and CD-ROM drives.
 
Back
Top