BII support like in SheepShaver for self-contained bundles?

About BasiliskII, a 68k Mac emulator for Windows, MacOSX, and Linux that can run System 7.x through MacOS 8.1.

Moderators: Cat_7, Ronald P. Regensburg

Post Reply
Gryffin
Student Driver
Posts: 19
Joined: Thu Oct 16, 2008 12:46 pm

BII support like in SheepShaver for self-contained bundles?

Post by Gryffin »

Myrd wrote:I've committed a new feature to SheepShaver CVS. Currently, it is for Mac OS X and Unix only.

The idea is to allow for self-contained SheepShaver VMs, in a similar fashion to, for example, VMWare Fusion VMs.
Any chance this feature could be ported to BasiliskII?
MetalSnake
Granny Smith
Posts: 120
Joined: Fri Nov 09, 2007 5:42 pm

Re: New Feature: Self-contained .sheepvm bundles

Post by MetalSnake »

Does Basilisk II support something like this now?
User avatar
adespoton
Forum All-Star
Posts: 4226
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: New Feature: Self-contained .sheepvm bundles

Post by adespoton »

Not officially, but I've cobbled together an equivalent. Basilisk II can load everything from the command line, so you can create a script that points to locally-referenced files for nvram, disk images, config file and ROM. Use something like Platypus to convert the script into an application, and you can even embed the BII binary inside, along with the other goodies, if you want. Otherwise, it'll just run using the default BII app, and you can have as many scripts as you want.
MetalSnake
Granny Smith
Posts: 120
Joined: Fri Nov 09, 2007 5:42 pm

Re: New Feature: Self-contained .sheepvm bundles

Post by MetalSnake »

Thanks, I'm trying that workaround now.

if I call

Code: Select all

./BasiliskII --config configFile 
I should have all the needed settings, like rom file, disk images etc. in that configFile, right?

But then it doesn't work, if I add

Code: Select all

--rom romFile 
it starts, but without any disk images.

So what is the configFile in the --config parameter supposed to be if it's not the equivalent to ~/.basilisk_ii_prefs?

edit: the problem are the relative paths. But I can't figure out how I need to write the script.

Code: Select all

#!/bin/sh

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"
./BasiliskII —-config basilisk_ii_prefs
This results in "ERROR: Cannot open ROM file."
BasiliskII, the config file and rom are in the Resources Folder of the .App that Platypus created.

What am I doing wrong?
User avatar
adespoton
Forum All-Star
Posts: 4226
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: New Feature: Self-contained .sheepvm bundles

Post by adespoton »

I don't have access right now, but when I get home I'll pull up my script. CWD defaults to the location of the binary; I seem to recall I called cwd, stripped the MacOS folder and CD'd to ../Resources, at which point everything can be done as relative references.

Actually, I might have already pasted that script on here somewhere.
MetalSnake
Granny Smith
Posts: 120
Joined: Fri Nov 09, 2007 5:42 pm

Re: New Feature: Self-contained .sheepvm bundles

Post by MetalSnake »

Couldn't find a cwd command, besides in FTP which is just the cd command.

So, my first 2 lines

Code: Select all

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"
is just going to the location of the binary (well, the sh script) and doing the rest from there. I can run ./BasiliskII --config basilisk_ii_prefs but it doesn't find the ROM set in the prefs file even though it's right there. If I use ./BasiliskII --rom and point to the rom file like I do in the prefs file it works.
I don't understand it. Why does it not work when called with --config?
MetalSnake
Granny Smith
Posts: 120
Joined: Fri Nov 09, 2007 5:42 pm

Re: BII support like in SheepShaver for self-contained bundl

Post by MetalSnake »

@adespoton could you find anything yet?
User avatar
adespoton
Forum All-Star
Posts: 4226
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: BII support like in SheepShaver for self-contained bundl

Post by adespoton »

Yes; finally at my Mac when I can pull this up:

Code: Select all

#!/bin/sh
mypath=`dirname "$0"`
res="../Resources"
cd "$mypath"
mv "$res/nvram" ~/.basilisk_ii_xpram
"./MacOS 7.6.1" --config "../Resources/Config"
mv ~/.basilisk_ii_xpram "$res/xpram"
That's what I do for BII -- I've put that script in the MacOS folder and told the Info.plist that this is the binary to launch. As you can see, this script also manages the xpram file, so you can have multiple BII instances running at the same time.
peter_j
Tinkerer
Posts: 61
Joined: Sat Jul 02, 2016 12:28 pm

Re: BII support like in SheepShaver for self-contained bundl

Post by peter_j »

adespoton wrote:Yes; finally at my Mac when I can pull this up:

Code: Select all

#!/bin/sh
mypath=`dirname "$0"`
res="../Resources"
cd "$mypath"
mv "$res/nvram" ~/.basilisk_ii_xpram
"./MacOS 7.6.1" --config "../Resources/Config"
mv ~/.basilisk_ii_xpram "$res/xpram"
That's what I do for BII -- I've put that script in the MacOS folder and told the Info.plist that this is the binary to launch. As you can see, this script also manages the xpram file, so you can have multiple BII instances running at the same time.
Maybe I am just too rusty, but I don't quite get how this script lets you run more than one simultaneous machine/BII-instance in terms of the xpram. Please correct me if I am wrong.

The mv copies/moves the one xpram to your home folder where Basilisk expects to find it. You open instance two, which overwrites the one in the home folder. The files are copied back on quit.

This would only work if the xpram is immediately read by BII on start, and written to only on exit, overwriting the file completely. If that is the case all is well. Else you would have BII one's file interfering with BII two's xpram potentially.
User avatar
adespoton
Forum All-Star
Posts: 4226
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: BII support like in SheepShaver for self-contained bundl

Post by adespoton »

Yes -- it's a quick hack. However, it's also a bit more subtle than that -- the xpram gets written back after the BII process is spun up, not after it quits. This means that any changes made during the initial boot process will be written back, but any changes made during execution will be reverted on next execution.

So if you want to change something in xpram, you'll have to manually copy the xpram back after you shut down to replace the copy in the application bundle.

The result is that you want to wait until one BII instance is fully running before launching another, or else you might end up with the wrong xpram being written back, which can really mess things up (not just failure to boot, but subtle things like corrupted memory/disk images). Usually the OS's sanity check at boot is enough to prevent this issue, but if you change the file in mid-operation and then the OS reads from it... bad things can happen.
peter_j
Tinkerer
Posts: 61
Joined: Sat Jul 02, 2016 12:28 pm

Re: BII support like in SheepShaver for self-contained bundl

Post by peter_j »

adespoton wrote:Yes -- it's a quick hack. However, it's also a bit more subtle than that -- the xpram gets written back after the BII process is spun up, not after it quits.
I'm still battling with this, probably because of pure ignorance on the Unix side. Please excuse the long full paths.

Shell script named MacOS_8.1.sh:

Code: Select all

cd "/Users/peter/BasiliskConfigs/Runfolder_MacOS_8.1"
mv "/Users/peter/BasiliskConfigs/Runfolder_MacOS_8.1/xpram" "/Users/peter/.basilisk_ii_xpram"
echo Starting emulator
"/Users/peter/BasiliskConfigs/Runfolder_MacOS_8.1/BasiliskII_2014.app/Contents/MacOS/BasiliskII"  --config "/Users/peter/BasiliskConfigs/Runfolder_MacOS_8.1/prefs"
echo Emulator Closing
echo Copying back
mv "/Users/peter/.basilisk_ii_xpram" "/Users/peter/BasiliskConfigs/Runfolder_MacOS_8.1/xpram"
echo Done
This produces this output:

Code: Select all

Peters-MacBook-Pro:~ peter$ ./MacOS_8.1.sh
Starting emulator
Basilisk II V1.0 by Christian Bauer et al.
<snip whole lot of Basilisk stuff>
Sorting out untranslated instructions count...

Rank  Opc      Count Name
Emulator Closing
Copying back
Done
What I see is that the final copy-back happens only AFTER the emulator quits. Am I missing something here?
peter_j
Tinkerer
Posts: 61
Joined: Sat Jul 02, 2016 12:28 pm

Re: BII support like in SheepShaver for self-contained bundl

Post by peter_j »

Got it!! :smile:

Finally, after many searches, it all becomes simple. You can substitute another folder for your HOME folder in the shell script, and Basilisk puts the xpram in the new folder. Like so:

Code: Select all

HOME="/Users/peter/test/"
More testing to be done, but if this is correct it solves a whole bunch of problems ( and means a whole lot of re-coding for me! ). ( I'm feeling a bit stupid ).
User avatar
adespoton
Forum All-Star
Posts: 4226
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: BII support like in SheepShaver for self-contained bundl

Post by adespoton »

Well what do you know...

Code: Select all

#!/bin/sh
mypath=`dirname "$0"`
res="../Resources"
cd "$mypath"
HOME="$mypath/$res"
./BasiliskII --config "$HOME/Config"
This works perfectly! The xprram file got written to the Resources folder!

I'm changing all my scripts over now :)
User avatar
sentient06
Mac Mechanic
Posts: 188
Joined: Tue Mar 29, 2011 8:57 pm
Location: London, UK

Re: BII support like in SheepShaver for self-contained bundl

Post by sentient06 »

adespoton, suppose I have several virtual machines in either self-contained wrappers or different config files. Is there a reason why I'd like to keep the xpram file?
I want to know if your interest is simply to keep these xpram files separate for each bundle so you don't have to manually remove it or if there is something useful about it.
I am researching to improve my UI config application. It deletes xpram automatically every time Basilisk II shuts down. I wonder if I should change the behaviour.
User avatar
adespoton
Forum All-Star
Posts: 4226
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: BII support like in SheepShaver for self-contained bundl

Post by adespoton »

I like to keep the xpram around because things like screen resolution and depth are set in there, as well as menu blink, mouse tracking, key repeat rate and parameters specific to the OS version booted last time. Being able to load from xpram avoids having to re-configure all that info after next boot, and speeds up the boot process.
Post Reply