From 8b6d0ba6982be23fd77c6dc2a7537304850f0267 Mon Sep 17 00:00:00 2001 From: HF Date: Fri, 31 Jan 2020 00:59:23 +0100 Subject: [PATCH] change pixel bitmask from 0x1F to 0x3F to allow 64 color palette --- src/core/Palette.js | 4 ++-- src/core/Tile.js | 2 +- src/core/tilesBackup.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/Palette.js b/src/core/Palette.js index 868681f..d1b955f 100644 --- a/src/core/Palette.js +++ b/src/core/Palette.js @@ -83,7 +83,7 @@ class Palette { let pos = 0; for (let i = 0; i < length; i++) { - value = (buffer[i] & 0x1F); + value = (buffer[i] & 0x3F); colors[pos++] = this.abgr[value]; } return colors; @@ -105,7 +105,7 @@ class Palette { for (let i = 0; i < length; i++) { value = buffer[i]; - color = (value & 0x1F) * 3; + color = (value & 0x3F) * 3; colors[c++] = this.rgb[color++]; colors[c++] = this.rgb[color++]; colors[c++] = this.rgb[color]; diff --git a/src/core/Tile.js b/src/core/Tile.js index 7e00228..e19656d 100644 --- a/src/core/Tile.js +++ b/src/core/Tile.js @@ -87,7 +87,7 @@ function addIndexedSubtiletoTile( let channelOffset = (chunkOffset + row * TILE_SIZE * subtilesInTile) * 3; const max = channelOffset + TILE_SIZE * 3; while (channelOffset < max) { - clr = (subtile[pos++] & 0x1F) * 3; + clr = (subtile[pos++] & 0x3F) * 3; buffer[channelOffset++] = palette.rgb[clr++]; buffer[channelOffset++] = palette.rgb[clr++]; buffer[channelOffset++] = palette.rgb[clr]; diff --git a/src/core/tilesBackup.js b/src/core/tilesBackup.js index e441ff4..d8c52b7 100644 --- a/src/core/tilesBackup.js +++ b/src/core/tilesBackup.js @@ -120,7 +120,7 @@ export async function incrementialBackupRedis( if (!tileBuffer) { tileBuffer = new Uint32Array(TILE_SIZE * TILE_SIZE); } - const color = palette.abgr[curChunk[pxl] & 0x1F]; + const color = palette.abgr[curChunk[pxl] & 0x3F]; tileBuffer[pxl] = color; } pxl += 1;