Browse Source

NESPalette now has a static .Default[] array containing a system-wide palette. This is now used by NESBank instead of __default_pi (which is also removed from ISurface)

dev-tmpl
Bryan Miller 6 years ago
parent
commit
958450729e
3 changed files with 15 additions and 13 deletions
  1. +2
    -10
      app/js/ifaces/ISurface.js
  2. +3
    -3
      app/js/models/NESBank.js
  3. +10
    -0
      app/js/models/NESPalette.js

+ 2
- 10
app/js/ifaces/ISurface.js View File





export default class ISurface{ export default class ISurface{
constructor(){
this.__default_pi = [
"#080808",
"#343434",
"#a2a2a2",
"#efefef",
"#666666" // Out of bounds color.
];
}
constructor(){}


get width(){return 0;} get width(){return 0;}
get height(){return 0;} get height(){return 0;}
throw new TypeError("Expected integer index."); throw new TypeError("Expected integer index.");
if (prop < 0) if (prop < 0)
throw new RangeError("Index is out of bounds."); throw new RangeError("Index is out of bounds.");
return obj.__default_pi[4];
return this.getColor(-1,-1);
}, },


set: function(obj, prop, value){ set: function(obj, prop, value){

+ 3
- 3
app/js/models/NESBank.js View File

throw new TypeError("Expected integer index."); throw new TypeError("Expected integer index.");
prop = parseInt(prop); prop = parseInt(prop);
if (prop < 0 || prop >= len) if (prop < 0 || prop >= len)
return this.__default_pi[4];
return NESPalette.Default[4];
var res = LRIdx2TileIdxCo(prop); var res = LRIdx2TileIdxCo(prop);
var list = (res.lid === 0) ? obj.__LP : obj.__RP; var list = (res.lid === 0) ? obj.__LP : obj.__RP;
if (this.__palette !== null){ if (this.__palette !== null){
return this.__palette.get_palette_color(pi, ci); return this.__palette.get_palette_color(pi, ci);
} }
return this.__default_pi[ci];
return NESPalette.Default[ci];
} }


getColorIndex(x, y){ getColorIndex(x, y){
var list = (res.lid === 0) ? this.__LP : this.__RP; var list = (res.lid === 0) ? this.__LP : this.__RP;
return { return {
pi: list[res.index].paletteIndex, pi: list[res.index].paletteIndex,
ci: list[res.index].getPixelIndex(res.x, res.y);
ci: list[res.index].getPixelIndex(res.x, res.y)
}; };
} }



+ 10
- 0
app/js/models/NESPalette.js View File

"#000000", "#000000",
"#000000" "#000000"
]; ];

NESPalette.Default = [
"#080808",
"#343434",
"#a2a2a2",
"#efefef",
"#666666" // Out of bounds color.
];



Loading…
Cancel
Save