Mirror backgrounds correctly
[ScratchNES.git] / src / CPU / build-lookups.js
1 /*
2 * build-lookups.js
3 * builds lookup tables for bitwise operations
4 */
5
6 var fs = require("fs");
7
8 emit("EOR", function(a,b){return a^b});
9 emit("ORA", function(a,b){return a|b});
10 emit("AND", function(a,b){return a&b});
11 emit("hex", function(a,b){return ("00" + ((a<<4)|b).toString(16)).substr(-2, 2)});
12 emit("bitmask", function(a,b){return ("00000000"+((a<<4)|b).toString(2)).substr(-8,8)});
13 emit("obitmask", function(a,b){return "1" + (("00000000"+((a<<4)|b).toString(2)).substr(-8,8))});
14 emit("dobitmask", function(a,b){return 2 * ("1" + (("00000000"+((a<<4)|b).toString(2)).substr(-8,8)))});
15
16 function emit(name, func) {
17 var emission = [];
18
19 for(var i = 0; i < 256; ++i) {
20 var a = (i & 0xF0) >> 4;
21 var b = (i & 0x0F) >> 0;
22 emission.push(func(a,b));
23 }
24
25 fs.writeFileSync("bin/" + name + ".txt", emission.join("\n"));
26 }
This page took 0.079069 seconds and 5 git commands to generate.