SS Wrapper & Modifying OS9

About SheepShaver, a PPC Mac emulator for Windows, MacOS X, and Linux that can run System 7.5.3 to MacOS 9.0.4.

Moderators: Cat_7, Ronald P. Regensburg, ClockWise

User avatar
classicmacreborn
Inquisitive Elf
Posts: 38
Joined: Tue Jan 24, 2017 6:58 am

SS Wrapper & Modifying OS9

Post by classicmacreborn »

Hi everyone,

I'm new here. Forgive me, I'm not sure I'm in the right place or on the right forum. I've been having fun with this little project of mine and was hoping I could get some advice and opinions. There aren't a whole lot of resources out there for OS9 development and system-level stuff.

I recently made a super simple wrapper that creates self-contained OS X app packages using SS. I didn't want to use the existing SheepShaver Wrapper because it has issues with fullscreen- which is very important for games. The basic idea is to have classic Mac games play like native .app packages in OS X without revealing to the user that it's using emulation at all. The custom one is ridiculously simple, but it wound up working pretty well. It's just a launcher .app package that loads an internal sheepvm in fullscreen, and then an alias of the application is in the startup items in OS9. It's pretty thrown-together right now but it works surprisingly well. I'm really interested in taking it a step further and modifying OS9.

In order to act like a truly native app, it needs to get rid of the booting screen, and shut down the emulation when the application is closed without giving the user access to the operating system. I can think of 3 ways to do this:

1 (easiest): For startup, replace the startup screen with an all-black screen with the text "Loading". Then replace all of the extension icons to all-black- hiding the extensions loading during boot. I've had some success with this. You have to use a resource editor for the extension. They are not normal icons, and the actual PICTs are scattered about depending on which extension you're looking at. For shutdown, have an os9 script in startup items that launches the app, then issues a shut down command when the app has been closed. It's kind of gimmicky, and I could definitely see it slipping up in different situations. But it kind of works.

2: Have OS9 talk to SheepShaver somehow. I'm not really sure how to do this. I haven't delve into the SS source code right now. I might do it though. Startup should be easier than shut down. I could overlay a splash screen, and have a script in startup items that tells SS when to remove the splash screen. For shut down, there could be something to monitor the application to determine when it has been quit, and tells SS to overlay another splash screen to hide OS9's user interface.

3: Modify OS9 directly. Definitely the hardest solution but probably the most reliable- if it's feasible. I'm not sure where to start. Any advice would be greatly appreciated. I have done a little binary stuff, which may or may not be necessary. The idea would be to prevent OS9/Platinum from displaying any user interface components to the user. Certain things like the file menu are mandatory, since so many fullscreen applications use them. But the desktop shouldn't ever be displayed, and if the user somehow winds up exiting the application mistakenly or through a bug, it shouldn't give them any access to the OS's user interface. I've seen a lot of Windows kiosks that are able to do this pretty well- locking the user into an application. It doesn't seem Apple gives a whole lot of flexibility for these kinds of things back in the OS9 days though. But then again, I do recall there being a lot of software back in the day that did some pretty core modifications to OS9. Again, any advice is super valuable.

I'm really having fun with this project and love the idea of preserving old Mac history. Thanks everyone!!!
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SS Wrapper & Modifying OS9

Post by adespoton »

I did this a bit a decade or so ago :) One thing I did was replaced the Finder with the app I wanted to launch, just like with System 6 and earlier. Type/Creator: FNDR/MACS on the application, and then it'll load as soon as the boot process is done.

You already know how to replace the MacOS with a different graphic resource; you can also just modify the CLUT resource in various bits so that all the colors used are black. This will automatically make everything load as black.

You can also try creating a file with a PICT resource ID 0 called StartupScreen; I can't recall if this still worked for OS 9, but it was the way floppy-booted games used to load right to the game with only a custom boot image back in the day -- Dark Castle and Beyond Dark Castle do this IIRC.

The StartupScreen image needs a specific Type and creator; can't recall what they are, but it loads a split second after the welcome screen and covers over a lot of the other messaging.

Good luck!
User avatar
classicmacreborn
Inquisitive Elf
Posts: 38
Joined: Tue Jan 24, 2017 6:58 am

Re: SS Wrapper & Modifying OS9

Post by classicmacreborn »

Hah! Replace the finder! That's genius!! Never thought of that.
That works extremely well. I had a boot time issue where the finder lagged for a few seconds and it fixed that too.

Now looking into a way to order it to shut down the system when the application is quit. The system always relaunches the Finder after it's quit. I was using a script that used the Finder to list all applications and then asked it to shut down when a certain application is not running. So I have to find a workaround.

Looks like the finder sends an apple event call to the system to do a shut down. I'm thinking there should be a way to make a replacement Finder application that loads the desired application and sends a call to system to do a shut down when the application is quit.
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SS Wrapper & Modifying OS9

Post by adespoton »

There's an app called nofinder that will do this, and I think the gryphel project has something too.
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Re: SS Wrapper & Modifying OS9

Post by emendelson »

adespoton wrote:There's an app called nofinder that will do this, and I think the gryphel project has something too.
I've been searching for Nofinder, but it seems that I'm a personal no-finder of that software. Can anyone post a link? Thanks!
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SS Wrapper & Modifying OS9

Post by adespoton »

These might help, although they're designed for use with Mini vMac (which can run up to Mac OS 7.5.5 as a Mac II with sound and color now, any screen size):
http://www.gryphel.com/c/minivmac/extras/index.html

I'm pretty sure UnFinder is on here somewhere: https://www.info-mac.org/viewforum.php?f=94

However, doing a search, I discovered that there's a PPC OS X era app by the same name that makes searching for it even more difficult.

Remind me enough and I'll see if I can find it in my collection. There was minifinder, nofinder, unfinder and others, back in the day. They were all System 6 Finder replacements with slightly different features. One of them did nothing other than launch an app when launched, and shut down the OS when that app quit and the "Finder" resumed focus. Not sure how well that would behave under OS 9.
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SS Wrapper & Modifying OS9

Post by adespoton »

OK; I found my copies of Mighty Finder, MiniFinder and Tiny Finder. They're all from 1985/86 though, so probably not as good as the Gryphel apps if those will work for you. Haven't found NoFinder and UnFinder yet.
User avatar
classicmacreborn
Inquisitive Elf
Posts: 38
Joined: Tue Jan 24, 2017 6:58 am

Re: SS Wrapper & Modifying OS9

Post by classicmacreborn »

Wow! Yeah, if you have some replacement Finders, it could possibly save me countless hours of reading Inside Macintosh (although I might do it anyway hehe). Even if they don't run in OS9 they could still provide some great insights. That would be amazing. Thanks so much!!

Scraped Google for Unfinder. Can't find it on the info-mac forums. There's one link to an old ftp site with "Unfinder.sit.bin" but it's a dead link now.

---

But I did find some other minifinders and made some notes:

Nofinder: http://www.macgui.com/downloads/?file_id=22180
- Works in OS9. It acts as a normal Finder when it's a finder in the system folder though. Even uses the OS6 font set. Very interesting.

FaberFinder on Gryphel site:
http://www.gryphel.com/c/sw/sysutils/fa ... index.html
- Looks like it still runs on OS9. Doesn't launch applications when acting as a Finder.

Found some more finders on this page:
http://home.earthlink.net/~gamba2/bootdisks.html

Minisubstitute 1.7.1
- Works in OS9, works as hoped when replacing finder, opens applications, shut down works properly. The GUI is very minimal, no popup windows. There is a bit of a lag after startup, and isn't scriptable. But might be one of the best so far.

Shortfinder 1.5b2
- Fully functions in OS9. Unfortunately, it also acts as a normal Finder when in the System Folder. Not scriptable.

Substitute 1.6
- Works in OS9, doesn't act like a normal finder when installed as a finder (which is good). But it has a popup dialog box with their 'about' info that cannot be closed, and shut down does not function, since it forces the user to "close all applications" - and of course there are applications in OS9 that run in the background.

Getting warmer.

Still very interested in any other finder replacements anyone can find!!
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SS Wrapper & Modifying OS9

Post by adespoton »

If you have issues with popup dialogs, I can probably open the app up in Resourcerer and nop the call to the dialog. I'm sure the original authors wouldn't mind at this point.
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Re: SS Wrapper & Modifying OS9

Post by emendelson »

This is terrifically helpful. Thank you!
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SS Wrapper & Modifying OS9

Post by adespoton »

Hmm... I just had another idea: if I can find my copy of ResHacker, I could generate a patch that will replace the A9F4 trap reference from the File menu with a call to the shutdown trap reference. Can't recall offhand what the shutdown value is, but the *Shutdown app in the Apple menu likely spells it out pretty clearly.

Then we could just patch any app we want to use in a wrapper, and it would shut down the OS instead of quitting to Finder.
User avatar
classicmacreborn
Inquisitive Elf
Posts: 38
Joined: Tue Jan 24, 2017 6:58 am

Re: SS Wrapper & Modifying OS9

Post by classicmacreborn »

Hah, oh wow that would be amazing!! The best solution is by far using the application itself as a Finder, and that's basically the only missing thing from the equation.
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Re: SS Wrapper & Modifying OS9

Post by emendelson »

What are the chances that it might be possible to use a startup script that would run an application and then shut down the system when that application closes?

I use a startup script for the system I use for running WordPerfect for the Mac; the script performs various housekeeping tasks before launching WP. But I haven't explored a way to shut down the system when WP quits. Can it be done?
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SS Wrapper & Modifying OS9

Post by adespoton »

Yes; an Applescript can do the task, but there will be a noticeable delay introduced at multiple levels. In pre-os x, the script needs to keep polling to see if the process it launched is still running.

I still haven't figured out what the correct toolbox call is to shut down; looks like I may have to dig into the Finder code. I found the ExitToShell calls in some standard software (LodeRunner Online is my test case), and they should be easy to patch. I presume Shutdown is another A9 call, but I'm not sure which one yet. I also had the idea that SheepShaver probably knows, as it intercepts it for application termination. So I may look through the source to see what trap it is looking for.
User avatar
classicmacreborn
Inquisitive Elf
Posts: 38
Joined: Tue Jan 24, 2017 6:58 am

Re: SS Wrapper & Modifying OS9

Post by classicmacreborn »

Yeah, the applescript doesn't work very well. The scripts are relatively unreliable, there's a delay, and boot time is slower. It doesn't give you that seamless experience of a native-esque app like DOSBox, etc.
nathan8299
Space Cadet
Posts: 5
Joined: Tue Feb 14, 2017 9:45 am

Re: SS Wrapper & Modifying OS9

Post by nathan8299 »

Would something like this be similar to the Classic Environment that was on PPC Macs that would use the Apple menu bar in a full screen rootless environment ?

It would be awesome to finally have programs like the Mac versions of FoxPro and Visual FoxPro on intel Mac OS X.
User avatar
classicmacreborn
Inquisitive Elf
Posts: 38
Joined: Tue Jan 24, 2017 6:58 am

Re: SS Wrapper & Modifying OS9

Post by classicmacreborn »

I guess you could say it's kind of like the classic environment. The only difference being that it would be designed mainly for fullscreen apps instead of having platinum's windows load in OS X.

But the basic idea is to have (fullscreen) OS9 apps that run as similarly as possible to native OSX apps.
Temporary Joe
Student Driver
Posts: 11
Joined: Thu Jul 04, 2013 10:02 pm

Re: SS Wrapper & Modifying OS9

Post by Temporary Joe »

I've been tinkering around at trying to build self-contained packages with SheepShaver. I was going to post some of this on Mac Garden as its own topic, but I think here would be better.

///
So I use SheepShaver a lot and I'm starting to want to do packages that will auto-launch and auto shut off. Obviously, auto launching isn't a huge deal (Startup Items) but shutting down is another issue. I found that items like Barrack (which I've been playing a lot, it will serve as the app in question for this topic), you could quit the emulator by clicking the red X in Windows mode (the window), which will then trigger the emulator for Shut Down, and then Quitting the game will shut off the emulator. But I want to make it so that quitting an application will shut off the emulator, possibly by using AppleScript tricks to trigger an exception if Application X quits. Problem is, if I trigger the script at startup, it will already execute before the application launches, so that's a no go.

I tested this with a Shut Down script sent to execute after Barrack. Unfortunately, the Script Editor interrupted just after Barrack started, claiming it "could not read the file because the the script is not editable (it was saved as run-only)". Yeah, no ****, Sherlock, it was supposed to be a runtime application. You can go back into Barrack, but then it kicks you into the Finder. SheepShaver will then hang or automatically quit when the Finder is opened. I can remove the script when it pauses to tell me this script from the startup, so no harm done, though I'm not sure how I can remove it if need be if that option wasn't there.

It seems like it should be simple to do--basically trigger an exception that crashes the emulator and will cause it to quit by quitting the internal application, just like Mini vMac had that thing with AutoQuit. Supposedly, AutQuit7 is supposed to work with SheepShaver and Basilisk, with systems beyond 7. Well, it didn't. The AutQuit "starting" hung on the screen after Barrack, and opening the System Folder afterward would trigger a Type 10 error.

Then I tried changing AutQuit7 in the Startup Items (the instructions said to use an alias) to open after Barrack and it STILL didn't work, though at least the System Folder opened normally.

//
That's what I had typed out before I came over here. Reading from this topic I wonder if I could try to hack the individual application so instead of sending the Quit application system call, it triggers an exception that will crash SheepShaver (instead of making it hang).
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SS Wrapper & Modifying OS9

Post by adespoton »

What I always do is select Shut Down from the Apple menu when I want to shut things down.

An alternative is to replace the Finder with an app that, when launched, automatically shuts the guest OS down.
Temporary Joe
Student Driver
Posts: 11
Joined: Thu Jul 04, 2013 10:02 pm

Re: SS Wrapper & Modifying OS9

Post by Temporary Joe »

adespoton wrote:What I always do is select Shut Down from the Apple menu when I want to shut things down.
Won't work for full screen games.
An alternative is to replace the Finder with an app that, when launched, automatically shuts the guest OS down.
Right, but problem with replacing the Finder with the app itself is that the Finder's default behavior is to re-launch when it quits.
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: SS Wrapper & Modifying OS9

Post by adespoton »

In most full screen games in OS 9, if you move your mouse to the top of the screen, the menu bar appears.

And by "replace the Finder", I mean replace it with a lightweight finder replacement app; you can even do this with Barrack by changing its type and creator codes to FNDR/MACS -- but as it doesn't have the ability to shut down, this could cause issues when you quit it.

Another option is to open it up in a resource editor and re-link the Quit menu item to trigger the shutdown toolbox call instead of the quit one. You can then even rename Quit to Shut Down :)

Probably easier to replace the Finder though, for instance by creating an AppleScript application, renaming it Finder, changing the T/C to FNDR/MACS, and having its only purpose be to launch Barrack on a clean boot, and to shut down if it has already launched Barrack. You could even leave it with a modal dialog with a shut down button so that when you quit Barrack, you see the quit button and can click it.
User avatar
classicmacreborn
Inquisitive Elf
Posts: 38
Joined: Tue Jan 24, 2017 6:58 am

Re: SS Wrapper & Modifying OS9

Post by classicmacreborn »

I've been back on this project again as of recently.

I've tried installing QuicKeyes and pairing command-q with the Finder shut down event. It works well when IN the Finder. However, this of course doesn't work with a custom finder, as it relies on the vanilla finder to handle the shutdown event.

I'm guessing it will be difficult to handle the shut down event without the Finder. Unless anyone knows of any system or toolbox events...

I'm wondering if it's possible to issue to the shut down event to the Finder even if it's not launched, or somehow endow the custom Finder with shut down powers (Infotron in my case).

I have about average familiarity with ResEdit, but I'm not sure where to start on re-linking the quit menu item to trigger shutdown, as adespoton mentioned.

Another option I'm thinking of is to modify the default action to relaunch the Finder after quitting and have it initiate the shut down event... Any tips on this would also be welcome.

Edit: I'm trying something new. I've replaced the Finder with the desired application, and then set the finder to a background-only application and put it in startup items. Hopefully this will give me access to Finder's shut down procedure from a script, but something tells me the Finder will just break. We'll see...
User avatar
classicmacreborn
Inquisitive Elf
Posts: 38
Joined: Tue Jan 24, 2017 6:58 am

Re: SS Wrapper & Modifying OS9

Post by classicmacreborn »

Okay, here's a simple solution to the launch and quit. You can use a simple AppleScript tell Finder to open the application as a file. The shut down event will only be triggered when the application is closed.

Code: Select all

tell application "Finder"
	open file "[PATH TO APP]"
	shut down
end tell
It works properly when put in Startup Items. Launches the application and then shuts down SS and quits when the application is quit.

The next step is to jail the user in the application by quitting the Finder, then relaunching it when the application is quit and issuing the shut down event. Haven't got that working yet, but I'm on it...

Edit: got the Finder to quit after launching the application by making the script into a Background-Only Application (BOA). The Finder only relaunches when the script gets focus, so making it faceless works perfectly. Furthermore, it still issues the shutdown command after the application is quit. It seems like this is working really well!!

Edit 2: it appears that the tell is asynchronous when run as a startup item (or it may be due to being a BOA). So it would issue the quit immediately after launching the application (which it should) then trigger the shut down event immediately afterward (and fail to shut down). The solution was to use two separate tells in AppleScript:

Code: Select all

-- Only works as a Background-Only Application (BOA)
tell application "Finder"
	open file "Mac OS 9:Infotronapp"
	quit
end tell

tell application "Finder"
	activate
	shut down
end tell
There are still a few kinks, but I'll keep posting.
spiffyguy22
Space Cadet
Posts: 1
Joined: Thu Aug 31, 2023 4:14 pm

Re: SS Wrapper & Modifying OS9

Post by spiffyguy22 »

classicmacreborn wrote: Sat Jan 05, 2019 9:04 pm

Code: Select all

-- Only works as a Background-Only Application (BOA)
tell application "Finder"
	open file "Mac OS 9:Infotronapp"
	quit
end tell

tell application "Finder"
	activate
	shut down
end tell
Hi there, I know this is an old post, but I was curious what you meant by "Background-Only Application (BOA)" in your post...

When I use your script and run it as an application, It opens the app just fine, quits the finder just fine... BUT after quitting the app, the finder is still closed and I get a cursor wheel that it's "thinking" and after about a 30 second timeout of staring at that wheel cursor... I get an alert that says "AppleEvent Timed out" with two buttons that say "Edit" and "Ok"

I am using Script Editor (I think 1.1) on Mac OS 9 and when I save the script and choose "Application" I only see 2 checkmarks "Stay Open" and "Never Show Startup Screen." I have tried different combinations of those to see if I can get it working to shut down Mac OS after the app/game runs but it doesn't work.

Still trying things but wanted to ask if anyone has ideas on what this "Background-Only Application" specifically means.

Thanks.
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Re: SS Wrapper & Modifying OS9

Post by emendelson »

I'm a bit late to respond to this, but I think a "background-only application" is only possible under OS X/macOS. (It's the effect of a setting in the plist.info file in the app.) I can't imagine how the author of the post created an OS 9 "background-only app," and he seems to have been inactive since 2020. It seems physically impossible. But maybe I'm wrong...
Post Reply