News for hackers. Stuff that matters.
Re:The Secret Feature of EM-DOSBOX on Internet Archive by TazeTSchnitzel on Saturday January 30, 2016 @04:11PM (#11003766)
Em-DOSBox is incredible. I'd previously wondered if it might be possible to run DOSBox in the browser with emscripten, but there seemed to be nothing working out there. Then the Internet Archive started hosting DOS games, and I wondered what they were using, thus I found Em-DOSBox.

At the same time, I was getting a bit of nostalgia for Windows 95, the first upgrade to Windows I ever used. And it turns out with a bit of fiddling you can run Windows 95 in DOSBox and have it mostly work.

Thus http://win95.ajf.me/ was born. Windows 95 running in the browser. It's still rather unbelievable. You can listen to CANYON.MID on an emulated Sound Blaster 16!

(Unlike the Internet Archive's games, this doesn't do any saving to local storage, sorry. I'm not sure it practically could, because it's not using a fake filesystem mapped to fopen() calls by intercepting DOS system calls, as DOSBox typically does, but rather DOSBox is giving Windows 95 a real disk image, so you'd have to stuff 131MB into localStorage.)

Re:The Secret Feature of EM-DOSBOX on Internet Archive by mstade on Saturday January 30, 2016 @08:31PM (#11004804)
Windows 95 in a browser? What a time to be alive..

I tried loading up Internet Explorer (3.0!) but it crashed the whole thing. This thing is very accurate.

Re:The Secret Feature of EM-DOSBOX on Internet Archive by digi_owl on Saturday January 30, 2016 @04:53PM (#11003943)
Things like this just make my mind spin when contemplating the number of layers invoked to get it working.

an OS running inside DOSBOX compiled to JS deliver over HTTP/TCP/IP to be interpreted by a browser (at this point perhaps a OS in its own right) running on top of a OS on top of a CPU.

It really feels like we are back in the leased terminal era...

Re:The Secret Feature of EM-DOSBOX on Internet Archive by TazeTSchnitzel on Saturday January 30, 2016 @05:04PM (#11003992)
Yep! And you can even run DOS apps inside Windows 95, so you can have Virtual 8086 Mode inside your virtual x86 CPU (DOSBox) inside your JavaScript virtual machine, inside a sandbox...

Disk access here is fun through the sheer number of layers. Consider a DOS prompt inside 95. When a DOS application tries to perform an I/O operation, it will make a DOS system call. DOS, in turn, will call the BIOS. This BIOS call will be intercepted by Windows 95 which, since it has no 32-bit disk driver (DOSBox doesn't simulate a real disk controller), will pass it on to DOS (the one underlying 95), which in turn will make a BIOS call. Everything before this point has been under DOSBox's x86 emulation. We then go through to the C++ fake BIOS of DOSBox, which handles the BIOS call by calling the C standard library I/O functions. However, those have been replaced by emscripten's shims, which will grab that data from the asm.js heap somewhere (or does it ferry it out to JS? I'm not sure.)

And DOSBox itself has been compiled to asm.js (which your browser may compile to machine code through JIT) and is running in your browser's JS VM. Which, if the browser you're using is on Windows, may be a 32-bit version, which is running under Windows's WOW64 (Windows 32-bit on Windows 64-bit)...

The layers never end!

http://i.imgur.com/lcZZ5YU.png

Re:The Secret Feature of EM-DOSBOX on Internet Archive by MrRadar on Saturday January 30, 2016 @06:58PM (#11004433)
Reminds me of The Birth and Death of Javascript: https://www.destroyallsoftware.com/talks/the-birth-and-death...
Re:The Secret Feature of EM-DOSBOX on Internet Archive by seanp2k2 on Saturday January 30, 2016 @04:57PM (#11003960)
Every few months someone finds a way to put another turtle on top, and some of those attempts stick.
Re:The Secret Feature of EM-DOSBOX on Internet Archive by breatheoften on Saturday January 30, 2016 @06:15PM (#11004255)
Wonder if it would work in iOS Safari running on the iOS simulator ...
Re:The Secret Feature of EM-DOSBOX on Internet Archive by jvilk on Saturday January 30, 2016 @07:49PM (#11004649)
Well, it's not infeasible. We don't use localStorage -- we use IndexedDB, which can store gigantic files. But I've never tried stuffing 100+MB into IndexedDB before.

(Sidenote: I'm the author of the BrowserFS library, and helped implement this feature.)

Re:The Secret Feature of EM-DOSBOX on Internet Archive by egeozcan on Sunday January 31, 2016 @04:15AM (#11005818)
I think your work is amazing and you should link to it: https://github.com/jvilk/BrowserFS
Re:The Secret Feature of EM-DOSBOX on Internet Archive by TazeTSchnitzel on Saturday January 30, 2016 @11:30PM (#11005228)
Keeping a copy of the disk around might actually be a good idea, as that means the browser has to hold on to it. I've found that in practice, Firefox and Chrome never hung onto the disk image in their cache.
Re:The Secret Feature of EM-DOSBOX on Internet Archive by StavrosK on Saturday January 30, 2016 @07:58PM (#11004687)
I can't believe the nostalgia. It's not just bringing back good memories, it's actually making me feel like I'm 16 again, in my old room, with all my old things around me.

It's amazing how much I'd associated the Windows 95 startup sound with that room... Thanks for that.

EDIT: Hey, can I mount win95.data on DOSBox locally? Do you know the command line?

Re:The Secret Feature of EM-DOSBOX on Internet Archive by TazeTSchnitzel on Saturday January 30, 2016 @11:32PM (#11005232)
The file is an emscripten package, I don't know if it's possible to extract it. If you want to try 95 on your local machine, I'd grab the install CD ISO from somewhere and use it in a proper virtual machine. Probably not VirtualBox, since it emulates graphics hardware 95 can't handle (so you're stuck at 640x480 at 4bpp) and lacks MIDI emulation (no music).

You could also try to run Windows 95 in DOSBox itself, just like this page does, but unfortunately DOSBox has a few issues with it. There are tutorials out there for doing it, though, and DOSBox supporting the right graphics and sound hardware is a big plus.

Re:The Secret Feature of EM-DOSBOX on Internet Archive by StavrosK on Sunday January 31, 2016 @05:49AM (#11005993)
Thanks for the information! I tried installing it in DOSBox and VirtualBox with no luck. Which emulator would you recommend?
Re:The Secret Feature of EM-DOSBOX on Internet Archive by TazeTSchnitzel on Sunday January 31, 2016 @10:09AM (#11006615)
You couldn't get it to install in VirtualBox? That's strange. Are you sure you were using a bootable ISO?
Re:The Secret Feature of EM-DOSBOX on Internet Archive by StavrosK on Sunday January 31, 2016 @08:11PM (#11009006)
Setup would just randomly hang in places, I'm afraid. The ISO booted fine, and I disabled VT-x, so that's not it either...

EDIT: Managed to get it running in the end, these two guides helped:

http://eduardprogramming.blogspot.gr/2014/01/20140120-window...

https://forums.virtualbox.org/viewtopic.php?t=9918

Re:The Secret Feature of EM-DOSBOX on Internet Archive by caf on Saturday January 30, 2016 @05:32PM (#11004116)
You might be able to just store the sectors that have been modified in localStorage, loading the unmodified ones from the original template.
Re:The Secret Feature of EM-DOSBOX on Internet Archive by runn1ng on Saturday January 30, 2016 @07:18PM (#11004520)
It's working really slow even on my own, pretty fast, computer.

But then, I am running Windows in DOSBox in JavaScript. I have no right to complain.

edit: welp, now I tried to run Internet Explorer 3.0 on the machine and it never finishes running, maxing out at 100% CPU and Chrome then wants to kill the tab.

And on Firefox, it crashes with "uncaught exception: SimulateInfiniteLoop". Well, it's not perfect!