WebAssembly port of Previous

NeXT Computer, Inc. -> Emulation / Virtualization

Title: WebAssembly port of Previous
Post by: mihai on January 10, 2024, 12:59:05 AM
I've begun a WebAssembly/Emscripten port of Previous, an early version is running at https://infinitemac.org/1994/NeXTSTEP%203.3.

Currently only the frame buffer, disk and mouse input is hooked up, but it's looking promising. https://github.com/mihaip/infinite-mac/issues/121 is tracking the remaining work.

This is a spin-off of my work to get classic Mac OS running on the web -- I started to explore getting early versions of Mac OS X running, but the complexity and resource requirements of porting QEMU were daunting, so I figured its ancestor would be interesting too.

The site tries to make good use of the web (e.g. disk images are streamed as needed). There is also a CD-ROM library that makes it possible to mount things from archive.org. Are there canonical CD-ROMs that would be interesting to include?
Title: Re: WebAssembly port of Previous
Post by: andreas_g on January 11, 2024, 07:26:28 AM
Very interesting project! Please keep us updated.
Title: Re: WebAssembly port of Previous
Post by: eukara on January 11, 2024, 11:57:29 AM
As for discs to include, a lot of software had to be installed onto the hard disk.
It might make sense to create a custom system image (akin to what archive.org does with its emscripten ports of dosbox with win3.1) that has a stripped down interface [optional] and is only set up to run one app in autostart.

However someone else might know of something I don't  :-X
 You'll definitely need something pre-installed like Opener.app to deal with the Peanuts CD-ROMs and similar.
Title: Re: WebAssembly port of Previous
Post by: mikeboss on January 11, 2024, 03:08:33 PM
impressive. most impressive.
Title: Re: WebAssembly port of Previous
Post by: itomato on January 11, 2024, 03:37:30 PM
YES! Well done!
Title: Re: WebAssembly port of Previous
Post by: mihai on January 12, 2024, 12:18:20 AM
It looks like CD-ROM mounting is working too, here's the first Peanuts CD: https://infinitemac.org/1994/NeXTSTEP%203.3?infinite_hd=false&saved_hd=false&cdrom=https%3A%2F%2Farchive.org%2Fdownload%2FPeanutsNeXTISO%2FPeanuts-1.iso (you can specify CD-ROM URLs to mount via the custom instance dialog at https://infinitemac.org/run).

Support insertion at runtime seems feasible too (if I can update the ConfigureParams and call SCSI_Insert, similar to what the SDL GUI does). Though I'm not able to start with an empty CD-ROM drive -- if if I leave bDiskInserted1 to FALSE in the config file and then insert the disk via the SDL GUI after startup, it does not get mounted (this is under NeXTSTEP 3.3).
Title: Re: WebAssembly port of Previous
Post by: andreas_g on January 12, 2024, 12:07:16 PM
Quote from: mihai on January 12, 2024, 12:18:20 AMThough I'm not able to start with an empty CD-ROM drive -- if if I leave bDiskInserted1 to FALSE in the config file and then insert the disk via the SDL GUI after startup, it does not get mounted (this is under NeXTSTEP 3.3).

I just tested with the latest version of Previous and for me booting with an empty CD-ROM drive and then inserting a disk automatically mounts it. These are the values in my configuration file:
szImageName1 = /
nDeviceType1 = 2
bDiskInserted1 = FALSE
bWriteProtected1 = TRUE
Title: Re: WebAssembly port of Previous
Post by: wizard on January 12, 2024, 01:45:17 PM
I would think having the early versions of the OS with the original demos would be cool from an historical perspective too.
Title: Re: WebAssembly port of Previous
Post by: mihai on January 13, 2024, 10:28:28 AM
Quote from: andreas_g on January 12, 2024, 12:07:16 PMI just tested with the latest version of Previous and for me booting with an empty CD-ROM drive and then inserting a disk automatically mounts it.

Thanks. I had been using a build from branch_softfloat from a couple of weeks ago. I updated to the latest 3.0 release and it seems to work now.

The boot process says "Waiting for drive to come ready" and there's a ~10 second delay, is there a way to avoid that?
Title: Re: WebAssembly port of Previous
Post by: andreas_g on January 14, 2024, 02:28:48 AM
Quote from: mihai on January 13, 2024, 10:28:28 AMThe boot process says "Waiting for drive to come ready" and there's a ~10 second delay, is there a way to avoid that?

The only way to avoid that is to insert a CD into the drive.
Title: Re: WebAssembly port of Previous
Post by: mihai on January 16, 2024, 01:15:22 AM
CD-ROM insertion after boot is working now, and the CD-ROMs "drawer" at the bottom has been populated with a few disks from archive.org. I also hooked up keyboard input.

Title: Re: WebAssembly port of Previous
Post by: K-Town Computeum on January 18, 2024, 07:27:09 AM
This is really awesome. Thank you @mihai for this great work!
Title: Re: WebAssembly port of Previous
Post by: wizard on January 19, 2024, 01:42:43 AM
You might want to make the hard drive image larger, I noticed only 27mb free at bootup.
Title: Re: WebAssembly port of Previous
Post by: mihai on January 20, 2024, 10:46:08 AM
Quote from: wizard on January 19, 2024, 01:42:43 AMYou might want to make the hard drive image larger, I noticed only 27mb free at bootup.

I noticed this too (when I was trying to install the 3.3 patch). I end up committing the disk images into version control (https://github.com/mihaip/infinite-mac/tree/main/Images), and was trying to avoid having a very large binary blob. However, I can probably do a compression pass, since most of it will be empty.
Title: Re: WebAssembly port of Previous
Post by: mihai on January 20, 2024, 01:55:02 PM
Out of curiosity, what is required to get the clock in the NeXTSTEP 3.3 to be correct? I've installed the Y2K patch (the boot kernel is now displayed as "NeXT Mach 3.3: Tue Jul 13 10:33:44 PDT 1999: root(rebuilder):mk-171.14.0bj~22/RC_m68k/RELEASE_M68K") and newrtc.timecntr is correctly initialized with the current host time.

However, during the boot process I get the "WARNING: preposterous time in Real Time Clock - - CHECK AND RESET THE DATE" message and it's reset to Nov 11, 1994. This happens with a native build too (on my Apple Silicon Mac).
Title: Re: WebAssembly port of Previous
Post by: andreas_g on January 20, 2024, 02:26:20 PM
Quote from: mihai on January 20, 2024, 01:55:02 PMOut of curiosity, what is required to get the clock in the NeXTSTEP 3.3 to be correct? I've installed the Y2K patch (the boot kernel is now displayed as "NeXT Mach 3.3: Tue Jul 13 10:33:44 PDT 1999: root(rebuilder):mk-171.14.0bj~22/RC_m68k/RELEASE_M68K") and newrtc.timecntr is correctly initialized with the current host time.

However, during the boot process I get the "WARNING: preposterous time in Real Time Clock - - CHECK AND RESET THE DATE" message and it's reset to Nov 11, 1994. This happens with a native build too (on my Apple Silicon Mac).

NeXTstep reads the timestamp from the filesystem. If the difference between that and the real time clock is too big it will set the real time clock to the filesystem time.

Best solution would be to enable networking and use the NTP feature.
Title: Re: WebAssembly port of Previous
Post by: mihai on January 20, 2024, 04:28:45 PM
Quote from: andreas_g on January 20, 2024, 02:26:20 PMNeXTstep reads the timestamp from the filesystem. If the difference between that and the real time clock is too big it will set the real time clock to the filesystem time.

Thanks. Do you happen to know what the maximum allowed difference is? I can periodically rebuild the disk image to pick up a more recent persisted date if it's on the order of months.

Enabling networking would be nice, but it needs additional support from the host/JavaScript side, so that's a bigger task.
Title: Re: WebAssembly port of Previous
Post by: andreas_g on January 21, 2024, 01:53:46 AM
Quote from: mihai on January 20, 2024, 04:28:45 PMDo you happen to know what the maximum allowed difference is?

It is two days.
Title: Re: WebAssembly port of Previous
Post by: cuby on January 21, 2024, 07:18:07 AM
IIRC mount checks the "last modified" date in the file system superblock, so it would probably suffice to change that date (a 4-byte Unix timestamp if I'm not mistaken) instead of recreating the whole disk image. However, I don't think there's a tool that can do this...
Title: Re: WebAssembly port of Previous
Post by: Rob Blessin Black Hole on January 22, 2024, 09:55:39 PM
Hello Mihai: Simply Incredible work ,absolutely amazing!  So under Preferences the calendar Icon, if you set a password for the me account and log out , then a login panel will appear where you can login as as root.  If you scroll all the way left you can set unix expert preferences and large file support. with root login you can then easily install the Y2k patch :) Also you would want to set a password for root before networking so it doesn't muck with netinfo. I'm looking at this tinkering that it is mostly outer icon shells this is one heck of a start .... just tried to launch nextlibrary bookshelves sysadmin bookshelves ... I'm not knocking anything as this is te coolest thing I've seen and I often wondered if it was possible to have a web based NeXTsolution.
Title: Re: WebAssembly port of Previous
Post by: mihai on January 24, 2024, 01:27:45 AM
I've deployed an updated version that has a larger disk image (1GB), right-click support and a few other tweaks. I also implemented support for grayscale blitting, so you can now run it as a regular Turbo: https://infinitemac.org/1994/NeXTSTEP%203.3?machine=NeXTstation+Turbo (https://infinitemac.org/run is the GUI for configuring custom instances).

Forgot to mention that Previous-side modifications are in https://github.com/mihaip/previous, if anyone is curious.

I'll be looking into adding support for all the of the machines that Previous supports. What is the best/most pristine source of 0.8, 0.9 and other early releases? https://winworldpc.com/product/nextstep/0x appears to be have already-installed hard disk images, I was not sure if there are other options?
Title: Re: WebAssembly port of Previous
Post by: mihai on February 09, 2024, 02:21:43 AM
I've added a somewhat cleaned up 0.8 image: https://infinitemac.org/1988/NeXTStep%200.8

It works well except that double-clicking is not registering and key events are showing repeated keys (in Terminal). Will need to look into how input events are being polled in the JS build under 0.8 (the native build does not have this issue).
Title: Re: WebAssembly port of Previous
Post by: andreas_g on February 09, 2024, 02:53:48 AM
Quote from: mihai on February 09, 2024, 02:21:43 AMIt works well except that double-clicking is not registering and key events are showing repeated keys (in Terminal). Will need to look into how input events are being polled in the JS build under 0.8 (the native build does not have this issue).

These issues are most likely timing related. Somehow the web assembly port of Previous runs way too fast. Not sure why, but it seems the timing system is broken. The delay between two clicks gets too long from the guest system's perspective and it sees keys pressed so long that it starts auto-repeating.
Title: Re: WebAssembly port of Previous
Post by: mihai on February 10, 2024, 01:24:24 AM
Quote from: andreas_g on February 09, 2024, 02:53:48 AMThese issues are most likely timing related. Somehow the web assembly port of Previous runs way too fast. Not sure why, but it seems the timing system is broken. The delay between two clicks gets too long from the guest system's perspective and it sees keys pressed so long that it starts auto-repeating.

Thanks for the pointer, that was indeed it. I was missing the host_real_time_offset check in the JS implementation, once I added that (https://github.com/mihaip/previous/commit/7a7523d3f1b18f996963c918f3452a49a86336e0) it's behaving better.
Title: Re: WebAssembly port of Previous
Post by: mihai on February 25, 2024, 12:38:51 AM
I've incorporated the other disk images that mikeboss had gathered in this thread (https://www.nextcomputers.org/forums/index.php?topic=3406). There's a filtered view of just NeXT images at https://infinitemac.org/?filter=next. I would appreciate any corrections for release dates (I used the kernel build time shown in verbose boots for ones where precise dates were not available) and changes to highlight in the description.

I also updated to the 3.1 release of Previous. andreas_g, is there a benefit to enabling ADB support for the Turbo machines? It would require some changes on my side (for the alternate key mappings) so I've thus far not done it.
Title: Re: WebAssembly port of Previous
Post by: andreas_g on February 25, 2024, 07:00:15 AM
Quote from: mihai on February 25, 2024, 12:38:51 AMandreas_g, is there a benefit to enabling ADB support for the Turbo machines?

It seems the ADB mouse is a bit less jumpy and the keyboard is a bit less susceptible to stuck modifier keys. But the benefits are minimal.
Title: Re: WebAssembly port of Previous
Post by: mihai on March 26, 2024, 01:31:15 AM
I've written up a blog post with a few more technical details about the WebAssembly Previous port: https://blog.persistent.info/2024/03/infinite-mac-nextstep.html

Thanks again to andreas_g and everyone else that helped!
Title: Re: WebAssembly port of Previous
Post by: user341 on March 26, 2024, 03:26:18 PM
Wow, great work! Thanks so much!
Title: Re: WebAssembly port of Previous
Post by: ramalhais on April 22, 2024, 06:51:04 PM
Awesome stuff!
Title: Re: WebAssembly port of Previous
Post by: jeffberg on August 27, 2024, 11:13:59 PM
Hey Mihai, thanks for working on this. Your blog post actually revitalized my interest in getting a VM of OpenStep running again. Since I tried it last time (and back when I used to have some Black Hardware), I had it going in VirtualBox (intel version). But now that I have Apple Silicon Macs, it's a little trickier to get going. But your blog post led me to Previous and down the rabbit hole I fell.

As part of this, I am trying to go to my roots (past my roots?) as I have had several jobs doing iOS development. So I am working on some simple software in Project Builder for OpenSTEP. It's been a fun journey using ancient versions of Objective C and Foundation.

Surprisingly enough, all the code still works on modern Mac OS X (although the NIBs don't). But I am trying to build this little app and upgrade it from OpenSTEP to Mac OS X Jaguar and up the chain until the same app runs on macOS Sonoma  :P

Anyway, why am I mentioning this? I was wondering how much effort it would be to provide 1 image in infinite Mac that has OS 4.2 with the Developer Tools installed. It would be fun to be able to build my app from source via the browser.

I had another question (and maybe its in the blog post) but does the infinitemac version do a netboot to a remote image or does it download the entire disk before it starts the boot process?

Here is the app if you're curious: https://github.com/jeffreybergier/NotSoulver
Title: Re: WebAssembly port of Previous
Post by: mihai on August 28, 2024, 12:02:17 AM
Quote from: jeffberg on August 27, 2024, 11:13:59 PMAnyway, why am I mentioning this? I was wondering how much effort it would be to provide 1 image in infinite Mac that has OS 4.2 with the Developer Tools installed. It would be fun to be able to build my app from source via the browser.

I haven't touched the NeXTStep/Previous parts of the site in a few months, but it shouldn't take too long. I've filed https://github.com/mihaip/infinite-mac/issues/336 to track this, if you'd like to subscribe to get updates.

Quote from: jeffberg on August 27, 2024, 11:13:59 PMI had another question (and maybe its in the blog post) but does the infinitemac version do a netboot to a remote image or does it download the entire disk before it starts the boot process?

As far as the guest OS is concerned, it's booting from a local disk. I have modified versions of all the emulators that turn file I/O from the disk image into requests that the JavaScript side intercepts. The disk are chunked into 256K blocks that are content-hashed and stored under distinct URLs, and the JS side has an index file that lets it know which chunks to load. The original Infinite Mac blog post at https://blog.persistent.info/2022/03/blog-post.html has some notes, and I revised the approach to be more efficient last year, https://blog.persistent.info/2023/08/infinite-mac-cd-roms.html describes it.
Title: Re: WebAssembly port of Previous
Post by: jeffberg on August 28, 2024, 12:11:23 AM
This is so cool! Keep up the good work!
Title: Re: WebAssembly port of Previous
Post by: jeffberg on August 28, 2024, 12:12:38 AM
Ah, one more question, are the NeXT emulators on infinite Mac connected to the network? In Omniweb nothing seems to load.
Title: Re: WebAssembly port of Previous
Post by: mihai on August 28, 2024, 12:25:36 AM
There's no internet access from the guest OS. I have a limited form of networking in the Mac OS 7 and 8 emulators (where multiple instances in the same "zone" can see each other), https://blog.persistent.info/2022/07/infinite-mac-networking.html has some details.

Go to top  Forum index