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 969B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. async function run_desmume(path, saves) {
  18. await cpconf("desmume", ".config/desmume");
  19. await shell.safe("desmume", path);
  20. }
  21. var emus = {
  22. nds: run_desmume,
  23. gba: run_visualboy,
  24. gbc: run_visualboy,
  25. };
  26. async function run(path, cb) {
  27. var ext = pathlib.extname(path).substr(1);
  28. var fn = emus[ext];
  29. if (!fn)
  30. throw new Error("Can't run games with extension "+ext+".");
  31. shell.safe("mkdir", "-p", "--", path+".save");
  32. await fn(path, path+".save");
  33. }