whscullin / apple2js

An Apple II emulator originally written in Javascript, now being converted to TypeScript
http://www.scullinsteel.com/apple2/
MIT License
438 stars 57 forks source link

a bit more explanation on creating a static distribution #207

Open sadam029 opened 6 months ago

sadam029 commented 6 months ago

Hey, whscullin!

I love your emulator. Its allowed me to play some great old games from my childhood. I'm trying to host one of those old games that made a positive impact on me. I'm a pretty big noob with all of this, but I've isolated the game from the collection of games it came with. But, I'm having trouble understanding what/where to edit to create a static distribution that autoloads the game when accessed. Any advice or help would be greatly appreciated. Regardless, thanks again for your work on this emulator.

rgov commented 2 months ago

The loaded disk is put in the URL hash, e.g., https://www.scullinsteel.com/apple2/#crimson1. The onLoaded() function in apple2.ts checks for either #crimson1 or ?disk=crimson1 to know what to automatically load:

https://github.com/whscullin/apple2js/blob/838fda696ca08ec415a438f6b3eb8fb162ad6178/js/ui/apple2.ts#L1020-L1026

So if you don't want to modify the code, just add the disk you want to the URL accordingly. Or if you want a very minimal code modification, set the variable hash to a fixed string as desired.

If you follow the logic through you can see how it parses the hash and then calls either loadData(), which copies the program directly into RAM, or loadDisk(), which is a more complicated process.