-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
48 lines (30 loc) · 860 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"use strict";
let NES = require("./src/nes");
(function() {
let myNES = new NES;
function loadROM(path) {
let promise = new Promise(function(resolve, reject) {
if(process.browser) {
// Load using ajax.
let xhr = require("xhr2");
let romrequest = new xhr();
romrequest.onload = function() {
resolve(romrequest.response);
};
romrequest.open("GET", path, true);
romrequest.overrideMimeType("text/plain; charset=x-user-defined");
romrequest.send();
} else {
console.log("Sry, Node/iojs not implemented yet...");
}
});
return promise;
}
loadROM("smb.nes").then(function(rom) {
myNES.loadROM(rom);
if(process.browser) {
window.nes = myNES;
}
console.log(myNES);
});
})();