| import {EventCaller} from "/app/js/EventCaller.js" | |||||
| export class NESPalette { | |||||
| export class NESPalette extends EventCaller{ | |||||
| constructor(){ | constructor(){ | ||||
| super(); | |||||
| this.__BGColor = 63; // Index to the background color ALL palettes MUST share. | this.__BGColor = 63; // Index to the background color ALL palettes MUST share. | ||||
| this.__palette = [ | this.__palette = [ | ||||
| // Tile/Background Palettes | // Tile/Background Palettes | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| this.emit("palettes_changed", [{type:"ALL"}]); | |||||
| return this; | return this; | ||||
| } | } | ||||
| if (sci < 0 || sci >= 64){ | if (sci < 0 || sci >= 64){ | ||||
| throw new RangeError("System color index is out of bounds."); | throw new RangeError("System color index is out of bounds."); | ||||
| } | } | ||||
| if (pci == 0) | |||||
| if (pci == 0){ | |||||
| this.__BGColor = sci; | this.__BGColor = sci; | ||||
| else | |||||
| this.emit("palettes_changed", [{type:"ALL", cindex:0}]); | |||||
| } else { | |||||
| this.__palette[(p*3) + (pci-1)] = sci; | this.__palette[(p*3) + (pci-1)] = sci; | ||||
| this.emit("palettes_changes", [{type:(p < 4) ? "TILE" : "SPRITE", pindex:p, cindex:pci}]); | |||||
| } | |||||
| return this; | return this; | ||||
| } | } | ||||