浏览代码

Fixed a mistake from the last NESTile update

dev
Bryan Miller 5 年前
父节点
当前提交
b948d1ff52
共有 1 个文件被更改,包括 8 次插入9 次删除
  1. +8
    -9
      app/js/models/NESTile.js

+ 8
- 9
app/js/models/NESTile.js 查看文件

this.__paletteIndex = 0; this.__paletteIndex = 0;
this.__data = new Uint8Array(16); this.__data = new Uint8Array(16);


var self = this;
this.__pixels = new Proxy(this.__data, {
this.__pixels = new Proxy(this, {
get: function(obj, prop){ get: function(obj, prop){
if (prop === "length") if (prop === "length")
return 64; return 64;
throw new RangeError("Index out of bounds."); throw new RangeError("Index out of bounds.");
var dindex = Math.floor(prop*0.125); var dindex = Math.floor(prop*0.125);
var bitoffset = 7 - (prop%8); var bitoffset = 7 - (prop%8);
var v = (obj[dindex] & (1 << bitoffset)) >> bitoffset;
v += 2*((obj[8+dindex] & (1 << bitoffset)) >> bitoffset);
var v = (obj.__data[dindex] & (1 << bitoffset)) >> bitoffset;
v += 2*((obj.__data[8+dindex] & (1 << bitoffset)) >> bitoffset);
return v; return v;
}, },


var dindex = Math.floor(prop*0.125); var dindex = Math.floor(prop*0.125);
var bitoffset = (prop % 8); var bitoffset = (prop % 8);
if (value == 1 || value == 3){ if (value == 1 || value == 3){
obj[dindex] |= BitMask(bitoffset);
obj.__data[dindex] |= BitMask(bitoffset);
} else { } else {
obj[dindex] &= BitMask(bitoffset, true);
obj.__data[dindex] &= BitMask(bitoffset, true);
} }
if (value == 2 || value == 3){ if (value == 2 || value == 3){
obj[8+dindex] |= BitMask(bitoffset);
obj.__data[8+dindex] |= BitMask(bitoffset);
} else { } else {
obj[8+dindex] &= BitMask(bitoffset, true);
obj.__data[8+dindex] &= BitMask(bitoffset, true);
} }
if (!BLOCK_CHANGE_EMIT) if (!BLOCK_CHANGE_EMIT)
self.emit("data_changed");
obj.emit("data_changed");
return true; return true;
} }
}); });

正在加载...
取消
保存