There exists a JavaScript port of DOSBox, suitable for running DOS applications and games in a web browser. The file system is delivered to the client browser as one big file with the filenames and offsets included in the page as a JSON object. I thought it would be neat if the data package could be split into multiple files so that levels could be easily swapped out without needing to duplicate the other files.
That turned to not be super difficult. I think I spent the most time just trying to get the build to work on Windows and then in WSL, but then I decided it would be easier just to work with an existing JS compilation. I wrote my own minimal packager, which was very easy since it just has to bolt one file on after the previous and keep track of where each starts, 31 lines of PowerShell in all. Then I went to work adjusting the loadPackage function and its associates to deal with multiple packages. I just stripped out some unnecessary stuff (mostly the enormous embedded SVG), added a filename parameter to loadPackage, and sprinkled in some PHP to fetch different packages based on the query string.
Sure enough, changing one part of the query string leaves the game the same except for replacing one level, which has its own package.
No comments:
Post a Comment