From e51571e3ace5142a49c08eb0b507e999de0b3a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Sun, 13 Nov 2022 21:15:50 +0000 Subject: [PATCH] feat: better palette handling --- examples/web/index.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/examples/web/index.ts b/examples/web/index.ts index 85367731..a1d02154 100644 --- a/examples/web/index.ts +++ b/examples/web/index.ts @@ -34,8 +34,18 @@ const BACKGROUNDS = [ ]; const PALETTES = [ - ["ffffff", "c0c0c0", "606060", "000000"], - ["b6a571", "8b7e56", "554d35", "201d13"] + { + name: "basic", + colors: ["ffffff", "c0c0c0", "606060", "000000"] + }, + { + name: "hogwards", + colors: ["b6a571", "8b7e56", "554d35", "201d13"] + }, + { + name: "pacman", + colors: ["ffff00", "ffb897", "3732ff", "000000"] + } ]; const KEYS_NAME: Record<string, number> = { @@ -466,7 +476,8 @@ class GameboyEmulator extends EmulatorBase implements Emulator { } updatePalette() { - this.gameBoy?.set_palette_colors_ws(PALETTES[this.paletteIndex]); + const palette = PALETTES[this.paletteIndex]; + this.gameBoy?.set_palette_colors_ws(palette.colors); this.paletteIndex += 1; this.paletteIndex %= PALETTES.length; } -- GitLab