While implementing a difficulty selector for Keen Galaxy levels in Emscripten DOSBox, I needed to inject a file into the virtual filesystem at runtime - not from a downloaded, manifested package. At first, I tried calling FS_createDataFile right before using the pre-supplied loadPackage function, but something necessary was missing, because the file wasn't added and an error was logged to the console. Inspecting the loadPackage function carefully, I found that it checks calledRun on the DOSBox module and, if that's not set, queues the operation with Module["preRun"].push (initializing Module["preRun"] to an empty array if it's absent).
I refactored that pre-run queuing out into its own function, altered the loadPackage function to use that, and called the new function with the data file creation as the callback.
No comments:
Post a Comment