Page 1 of 2

Menu-style OS X disk image chooser for Basilisk II

Posted: Tue Dec 02, 2008 5:44 pm
by emendelson
One of the frustrations of using Basilisk II under OS X is the barebones GUI for setting preferences. It works well enough for most options, but it doesn't make it easy to select and manage disk image files. (I'm referring to the ports of the main development line of Basilisk II, not Nigel Pearson's port which includes its own OS X-style Preferences menu.)

I've wasted some enjoyable time writing an Applescript that makes it easy to select and manage the disk images listed in .basilisk_ii_prefs. It lets you add and remove images, set a different image at the top of the list to become the startup drive, create new images and add them to the list in the preference file, and set the option to boot from a CD-ROM.

It should also work with SheepShaver by changing a single variable at the top of the script, but I haven't tested it with SheepShaver.

It's obviously the work of a beginner at Applescript, and an expert coder could probably reduce its size by two-thirds, but it seems to work. Run at your own risk, and please feel free to let me know of any problems. Download it here if you're interested:

http://www.columbia.edu/~em36/EmulatorD ... hooser.zip

Edit: Slightly improved version (better error handling) posted 20 August 2009.

Edit: Improved script posted 9 August 2019: viewtopic.php?p=63978#p63978

Posted: Tue Dec 02, 2008 9:38 pm
by Ronald P. Regensburg
Nice! It is certainly easier than the (indeed) awful interface of the GUI application.

I myself usually edit the prefs file directly in a text editor, especially for simple things like changing volumes.

SheepShaver for MacOSX already has an improved Prefs Editor to replace the GUI application, available as stand alone application and integrated in the latest unofficial SheepShaver for MacOSX builds. (See sticky topics in SheepShaver forum.)

Posted: Tue Dec 02, 2008 10:07 pm
by emendelson
Thanks for the good words. I use this with your excellent build, and am putting together a little "appliance" to use for working with old WordPerfect files.

I've already improved the script by adding to the file types that it will recognize as disk images, and by adding a button to launch the emulator after writing the prefs file. I'll post an improved version probably tomorrow - after some more testing. (I've also fixed a minor problem in some menus where choosing cancel shuts down the script, instead of going back to the main menu.

I've posted some messages asking if anyone could make a BasiliskIIPrefs to match the very good SheepShaverPrefs program. The SheepShaver program needs a few improvements, by the way: if the program is in the same folder with the disk image, it does not enter the full path - only the filename. And there is no GUI for selecting ROM files - you need to type a path. Maybe someday these will be fixed...!

Posted: Tue Dec 02, 2008 10:43 pm
by Ronald P. Regensburg
emendelson wrote:The SheepShaver program needs a few improvements, by the way: if the program is in the same folder with the disk image, it does not enter the full path - only the filename. And there is no GUI for selecting ROM files - you need to type a path. Maybe someday these will be fixed...!
All files that are in the same folder with the SheepShaver application will be found by SheepShaver with only the file name in prefs, no path needed. That is also true for the ROM file.

When launched with no prefs file present, SheepShaver will recognize a ROM file named "Mac OS ROM" in the same folder. But that obviously works only when SheepShaver is launched the first time, so the name should be entered before SheepShaver is quit.

In the stand alone version of the Prefs Editor one can simply drag the file icon into the text box to add the path, but that does not work in the integrated version.

(Maybe we should discuss SheepShaver in the Sheepshaver forum.)

Posted: Wed Dec 03, 2008 2:48 am
by emendelson
Updated the file with minor improvements; functionally basically the same.

Posted: Wed Dec 03, 2008 11:51 am
by Ronald P. Regensburg
I tested the last version of your script more thoroughly and I encountered a couple of problems:

1. After making changes, I see no way to save the changes and quit. If I dismiss the window using the little red button, I can only force quit and changes are not saved

2. For adding an existing volume, apparently only files with certain file name extensions can be selected. However, for BasiliskII (and for SheepShaver) the extension is irrelevant. BasiliskII happily uses disk image files without file name extension (even with extensions like .txt or .jpg). Maybe you should indicate which file name extensions are accepted by your script.

3. For creating a disk image you use .dmg as file name extension. When using .dmg, a user must be aware that the image should not be mounted in the emulator and in MacOSX at the same time. If you want to set a default extension, I think it is safer to use an extension like .dsk, that cannot be mounted in MacOSX by simple double clicking.

4. On my Intel iMac, the created images have a GUID partition table. I am not sure this will work correctly for all BasiliskII compatible MacOS versions. Normally, disks with GUID partition table can only be used as boot disk on Intel Macs or PPC Macs with 10.4 or later. A GUID partition table makes disk images problematic in SheepShaver. I tried a 7.5.3 installation and apparently it is no problem in BasiliskII, the image needed to be initialized and could be used as boor disk. Further investigation is needed.

Posted: Wed Dec 03, 2008 12:16 pm
by emendelson
Thanks for that testing. Quick comments:

1. Something must be wrong with my logic if you are not seeing a way to save changes. What it tries to do is this:

After you make changes, an option "Write changes etc." appears on the main menu, under "Add a disk", "Create a disk image", "Remove a disk", "Set a startup". That option should appear ONLY when the changes that you make would produce changes in the preferences file.

If you make changes, and the "Write changes to preference file" option does NOT appear, could you let me know what changes you made? Thanks.

2. You are right. I shall fix this. (Applescript does not seem to let me choose by extension, but by "file type", which is an attribute of the file - dimg, dmd3, etc. I shall probably go back to letting any file be chosen.)

3. Again, you are right. I shall fix this.

4. Interesting point. I create the disk by using the hdiutil command-line program built into OS X - the same program used by the Disk Utility program that comes with OS X. I'm not sure what method the other Basilisk GUI, etc. programs use when creating a disk, but will look into it.

Thank you again for this excellent feedback. The one thing I worry about is item 1. You certainly should see a "Write changes" option when you've made changes that would produce a preference file with different contents from the one on disk. I explicitly check to see whether the list of disks (and the order of the list) is different between the disk file and the choices you made. I also check whether you've changed the Boot-CD option. Please let me know if there's some way the logic went wrong!

Posted: Wed Dec 03, 2008 6:41 pm
by Cat_7
Hi,

In response to your point 4:
I believe the program "dd" is used

The required parameters are "if" and "of"
if=file Read input from file instead of the standard input.
of=file Write output to file instead of the standard output. Any regular output file is truncated unless the notrunc conversion value is specified. If an initial portion of the output file is seeked past (see the oseek operand), the output file is truncated at that point.

This is an example from the SheepShaver developers website:

dd if=/dev/zero of=name_of_your_hard_disk_image bs=1048576 count=size_in_megabytes

"dd" is available om my mac, but I'm not sure if that is standard. Better check it :lol:

Best,
Cat_7

Posted: Wed Dec 03, 2008 7:33 pm
by emendelson
That's VERY helpful - thank you!

dd is on my Mac too, but I've got the developer tools installed. I think it should be on all Macs, however, as it's in /bin, which I think is the same on all Macs. Will check on this.

I'll replace the hdiutil command in my script with dd after I do a bit of testing.

Thank you again!

Posted: Wed Dec 03, 2008 11:39 pm
by Ronald P. Regensburg
About point 1:

- I start the script. Dialog with choices for changes and "Exit" and "Select" button.
- I choose "Remove disk image from Basilisk II system" and click Select.
- In new dialog I select the disk image to be removed and click "Remove"
- I am back at the first dialog, but now with the removed image not anymore listed at the top and with "Exit" button replaced by "Abandon changes" button.

What can I do now? Neither "Abandon changes" or "Select" another change is the way to go.

Oh, I see. There is now a "Write changes to preferences file" item in the list that was not there before.

It was a list of possible changes only, I looked for further changes in the list, I did not see that writing the changes was added to the list, because I did not expect that and because I did not really read or understand the text that mentions that the item would be added to the list.

No doubt my dyslexia plays a role, but I think it would be more intuitive if a button "Write changes" would be added instead of a "Write changes" option in the list.

And BTW: Something should be done also with the close window button. If clicked, the only way out is a force quit of the script.

Posted: Thu Dec 04, 2008 1:08 am
by emendelson
At first I could not figure out how to use a button for "write changes" because Applescript only allows two buttons in that kind of list. But you are right that a button is far better than a "Write changes" item in the main list. So I have rewritten the script to use your suggestion. I've also added a line or two of code that should help eliminate the screen artifacts when Basilisk II is launched. (The new version is posted now at the same address, same filename.)

About the "close window button" - I don't see that button anywhere. I'm running Leopard, and that button is never visible in the dialogs. Could you tell me exactly where you see that button? Perhaps you are running Tiger, and the "close window button" appears there?

Posted: Thu Dec 04, 2008 11:59 am
by Ronald P. Regensburg
emendelson wrote:About the "close window button" - I don't see that button anywhere. I'm running Leopard, and that button is never visible in the dialogs. Could you tell me exactly where you see that button? Perhaps you are running Tiger, and the "close window button" appears there?
The little red thingy in the upper left corner of the window.

Posted: Thu Dec 04, 2008 12:17 pm
by emendelson
I know what it is - but it absolutely never appears when I run the script. There are either no buttons at all, or a green button only on the menus where you select a file. Could you post a screen shot? Do you have any special modifications to OS X?

Here's what I see:

Image

Posted: Thu Dec 04, 2008 4:39 pm
by Ronald P. Regensburg
I simply double click the script icon and this is what I see:

Image

This is on a Intel Core 2 Duo iMac with Leopard 10.5.5. To be certain that there is no interference by Finder additions and such, I disabled login items (login with shift key pressed).

Posted: Thu Dec 04, 2008 4:52 pm
by emendelson
This is very strange. I have an almost-new white MacBook, with a new installation of 10.5.5. I don't see the red button that you have on your system.

I set up a new account on my machine, switched to it, and ran the script - again, no red button!

(I did find, however, that my script doesn't correctly detect a situation where there is no existing .basilisk_ii_prefs file, and I have corrected that, and will upload a new version later.)

But I can't imagine why you have that red button. I don't have it on my account, on the new test account that I created - and I don't have it on the machine that's running Tiger either!

Posted: Thu Dec 04, 2008 5:55 pm
by Ronald P. Regensburg
Tried the script in a fresh new guest account and the little red button was there again.

Posted: Thu Dec 04, 2008 6:12 pm
by Ronald P. Regensburg
Tried the script on my PowerBook G4 with Tiger 10.4.11 and got:

Can't get «class psxf» "".

Posted: Thu Dec 04, 2008 7:40 pm
by emendelson
Tried the script on my PowerBook G4 with Tiger 10.4.11 and got:

Can't get «class psxf» "".
I *think* I know what that's about. Will look into it. Thanks for the report!

Posted: Thu Dec 04, 2008 11:07 pm
by emendelson
I'm completely puzzled by that red close button on the dialog in your system. It should NOT be there. Go to Google and perform an Image search for "applescript 'choose from list'" - all the dialog boxes that display that command have no red button, in fact no buttons at all. For example


http://files.macscripter.net/joy/images ... ptions.jpg

or


http://files.macscripter.net/joy/images/coverlover.jpg

There must be something installed in your system that adds the red button. But what?

Posted: Fri Dec 05, 2008 4:46 pm
by Ronald P. Regensburg
Well, it obviously is not something installed 'for this user', because the same happens in a virgin new guest account. So I tried a safe startup of my Mac (startup with shift key pressed). With a safe startup a file system check is run and, if I am not mistaken, only a minimum system is loaded with no third party additions. The little red button is still there.

I honestly cannot imagine what could be unusual about my system.

Posted: Fri Dec 05, 2008 5:19 pm
by Ronald P. Regensburg
I found the cause. You would not believe this, it is apparently related to localization. 8O

The little red button is not shown when the preferred language in 'International' system preferences is set to English, Swedish, Japanese or Chinese-Simplified, but the red button does show up with the preferred language set to German, French, Polish, Russian, Chinese-Traditional and (my language) Dutch.

I did not try more languages. :P

Posted: Fri Dec 05, 2008 5:40 pm
by Ronald P. Regensburg
Another discovery:

When I open the script in Script Editor and save it, using "Save as...", again as application and with none of the three options checked, the red button is not shown anymore in any of the languages I tried above. :!:

Posted: Fri Dec 05, 2008 8:05 pm
by emendelson
This sounds like a bug in OS X - and you're right: I'm amazed at it! (And I got exactly the same results when I tried it - with Nederlands at the top of the list of preferred languages, the red button appeared.)

What happens if you save the script as an "Application Bundle" instead of an "Application"?

An "Application Bundle" launches more quickly under OS X than an "Application". (An "Application Bundle" works only under OS X, I think, while an "Application" can work under OS 8/9 in addition to OS X.)

Posted: Fri Dec 05, 2008 9:10 pm
by Ronald P. Regensburg
If I save as Application Bundle, the red button is still there. If I save that one as Application, the red button has gone, and if I save that one again as Application Bundle the red button is again there.

Posted: Wed Dec 17, 2008 1:17 pm
by emendelson
I've updated this script to add better error-checking. It now warns when a disk image listed in the prefs file can't be found, and has other minor improvements. Same filename as in the first message in the thread.