You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

emulate.js 824B

1234567891011121314151617181920212223242526272829303132333435
  1. var shell = require("./shell");
  2. var pathlib = require("path");
  3. var os = require("os");
  4. var fs = require("fs");
  5. var EventEmitter = require("events");
  6. exports.run = run;
  7. // Reset to default config
  8. async function cpconf(from, to) {
  9. to = pathlib.join(os.homedir(), to);
  10. from = pathlib.join("emuconf", from);
  11. await shell.safe("rm", "-rf", "--", to);
  12. await shell.safe("cp", "-r", "--", from, to);
  13. }
  14. async function run_visualboy(path, saves) {
  15. await shell.safe("vba", "--config", "emuconf/vba/vba.cfg", path);
  16. }
  17. var emus = {
  18. gba: run_visualboy,
  19. gbc: run_visualboy,
  20. };
  21. async function run(path, cb) {
  22. var ext = pathlib.extname(path).substr(1);
  23. var fn = emus[ext];
  24. if (!fn)
  25. throw new Error("Can't run games with extension "+ext+".");
  26. shell.safe("mkdir", "-p", "--", path+".save");
  27. await fn(path, path+".save");
  28. }