Porting the PCE emulator to the browser
The Internet Archive recently added the original Macintosh to the list of classic computers of which they provide emulation, so you can play with the software titles in their archive in your browser, without installing anything. This is great because it provides the same level of accessibility and convenience to emulation as you'd expect of playing a media file or viewing a document.
When you start up the emulated computer on these pages of the Internet Archive, you're running the PCE emulator, originally a piece of software intended to run natively on desktop operating systems, which has been adapted and recompiled to run in your web browser. As the person who did the initial work of porting this emulator, I thought it would be worthwhile to provide a run-down of the tools and gross hacks which made this possible.
Finally, there was the issue of mouse pointer integration. At this point, moving your mouse around the browser window resulted in the relative mouse movements being passed to the emulator, which in turn are provided to Mac OS as emulated hardware mouse movements. Mac OS moves the mouse in on the emulator's screen, but it's not necessarily in the same place as your OS' real mouse pointer. I felt I could do better, so I added a super gross hack to actually update the emulated Mac OS mouse position to match your real mouse cursor's position on the screen. You can see that happening here. I realised that in classic Mac OS, the mouse position is stored in a few fixed absolute locations in the computer's memory, called 'low memory globals'. Basically, I directly write the mouse position value into the emulated computer's memory. Gross, right? But it works great, as you can see by drawing some stuff in Kid Pix. The mouse responds perfectly. You can read more about low memory globals in this folklore.org story.
I'm really glad Classic Mac emulation made its way onto archive.org, because I think everybody should have the opportunity to experience computing history, and the original Macintosh is an essential piece of that history.
If you're wondering about my rationale for porting emulators to the browser, have a read of my previous post on the subject.