[Scummvm-git-logs] scummvm master -> 7a3ce2ff5cf3052b0241dbc58514e08138cf7560

sev- noreply at scummvm.org
Tue Jan 10 12:42:07 UTC 2023


This automated email contains information about 15 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d683688a55 DIRECTOR: Fix redraw when changing the stageColor
9109495484 DIRECTOR: LINGO: Stop reading property list after getting -1
ccd72e5e1b DIRECTOR: LINGO: Always let cb_assign write a property
97a6076168 DIRECTOR: LINGO: Allow setting any property on a factory object
48740a2ad1 DIRECTOR: Remove all palette reversing workarounds
cb68c05dcb GRAPHICS: Loosen palette checks on Surface::convertTo
699eb67daa DIRECTOR: Add observed 16-color Mac palette
9fb41d82d1 DIRECTOR: Add support for displaying 2-bit and 4-bit bitmaps
bbc464a7bc DIRECTOR: Fix matte display for 1-bit images
c5095c0e62 DIRECTOR: Fix several blend modes
26fad071c0 DIRECTOR: Read palette ID as signed int for D3
a5ed3bc202 DIRECTOR: Fix palette offset in BitmapCastMembers
f61e06a752 DIRECTOR: Fix Score::getCurrentPalette()
fb4d1f3bfe DIRECTOR: Make bitmap color correction ignore color cycling operations
7a3ce2ff5c DIRECTOR: Don't render color cycling in few frames mode


Commit: d683688a555e7e09cc4f6c5c82e3bdf63e181811
    https://github.com/scummvm/scummvm/commit/d683688a555e7e09cc4f6c5c82e3bdf63e181811
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: Fix redraw when changing the stageColor

Previously, there was a workaround which would set score->_nextFrame to
the current frame. This meant that setting the stageColor in an
exitFrame handler would loop that single frame and softlock the movie.
The new approach re-renders the sprites and window inline, as we do
in several other spots.

Fixes frame progressions in Yaken Rodem.

Changed paths:
    engines/director/lingo/lingo-the.cpp


diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index bf8e3505e0a..697b4decc09 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -1133,9 +1133,9 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
 	case kTheStageColor:
 		g_director->getCurrentWindow()->setStageColor(g_director->transformColor(d.asInt()));
 
-		// Queue an immediate update of the stage
-		if (!score->getNextFrame())
-			score->setCurrentFrame(score->getCurrentFrame());
+		// Redraw the stage
+		score->renderSprites(score->getCurrentFrame(), kRenderForceUpdate);
+		g_director->getCurrentWindow()->render();
 		break;
 	case kTheSwitchColorDepth:
 		setTheEntitySTUB(kTheSwitchColorDepth);


Commit: 9109495484ca1c2d4ca64fde5fd61b0dc7ce96e1
    https://github.com/scummvm/scummvm/commit/9109495484ca1c2d4ca64fde5fd61b0dc7ce96e1
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: LINGO: Stop reading property list after getting -1

This appears to be another space reclamation feature in Director;
there are examples of the property list being a -1 followed by
bytecode garbage from the previous field.

Changed paths:
    engines/director/lingo/lingo-bytecode.cpp


diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index 0ff165560f3..707fc6886bf 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -1075,12 +1075,17 @@ ScriptContext *LingoCompiler::compileLingoV4(Common::SeekableReadStreamEndian &s
 		warning("Lscr properties store missing");
 		return nullptr;
 	}
-
-	debugC(5, kDebugLoading, "Lscr property list:");
 	stream.seek(propertiesOffset);
+	if (debugChannelSet(5, kDebugLoading)) {
+		debugC(5, kDebugLoading, "Lscr property list:");
+		stream.hexdump(propertiesCount * 2);
+	}
 	for (uint16 i = 0; i < propertiesCount; i++) {
 		int16 index = stream.readSint16();
-		if (0 <= index && index < (int16)archive->names.size()) {
+		if (index == -1) {
+			debugC(5, kDebugLoading, "[end of list]");
+			break;
+		} else if (0 <= index && index < (int16)archive->names.size()) {
 			const char *name = archive->names[index].c_str();
 			debugC(5, kDebugLoading, "%d: %s", i, name);
 			_assemblyContext->_properties[name] = Datum();
@@ -1095,8 +1100,11 @@ ScriptContext *LingoCompiler::compileLingoV4(Common::SeekableReadStreamEndian &s
 		return nullptr;
 	}
 
-	debugC(5, kDebugLoading, "Lscr globals list:");
 	stream.seek(globalsOffset);
+	if (debugChannelSet(5, kDebugLoading)) {
+		debugC(5, kDebugLoading, "Lscr globals list:");
+		stream.hexdump(globalsCount * 2);
+	}
 	for (uint16 i = 0; i < globalsCount; i++) {
 		int16 index = stream.readSint16();
 		if (0 <= index && index < (int16)archive->names.size()) {


Commit: ccd72e5e1b4a778917ff0cfa9a0843133b94e7e6
    https://github.com/scummvm/scummvm/commit/ccd72e5e1b4a778917ff0cfa9a0843133b94e7e6
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: LINGO: Always let cb_assign write a property

This function needs to be able to deal with D3-style anonymous
objects, where no properties are defined in advance.

Changed paths:
    engines/director/lingo/lingo-bytecode.cpp


diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index 707fc6886bf..6bfebac8493 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -588,11 +588,9 @@ void LC::cb_theassign() {
 	Common::String name = g_lingo->readString();
 	Datum value = g_lingo->pop();
 	if (g_lingo->_state->me.type == OBJECT) {
-		if (g_lingo->_state->me.u.obj->hasProp(name)) {
-			g_lingo->_state->me.u.obj->setProp(name, value);
-		} else {
-			warning("cb_theassign: me object has no property '%s'", name.c_str());
-		}
+		// Don't bother checking if the property is defined, leave that to the object.
+		// For D3-style anonymous objects/factories, you are allowed to define whatever properties you like.
+		g_lingo->_state->me.u.obj->setProp(name, value);
 	} else {
 		warning("cb_theassign: no me object");
 	}


Commit: 97a6076168a3e1a4e559240f165fd8ef278e72e1
    https://github.com/scummvm/scummvm/commit/97a6076168a3e1a4e559240f165fd8ef278e72e1
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: LINGO: Allow setting any property on a factory object

Fixes game initialisation of Yaken Rodem.

Changed paths:
    engines/director/lingo/lingo-object.cpp


diff --git a/engines/director/lingo/lingo-object.cpp b/engines/director/lingo/lingo-object.cpp
index 274decc859f..0a5e26eaf15 100644
--- a/engines/director/lingo/lingo-object.cpp
+++ b/engines/director/lingo/lingo-object.cpp
@@ -402,6 +402,10 @@ bool ScriptContext::setProp(const Common::String &propName, const Datum &value)
 			debugC(3, kDebugLingoExec, "Getting prop '%s' from ancestor: <%s>", propName.c_str(), _properties["ancestor"].asString(true).c_str());
 			return _properties["ancestor"].u.obj->setProp(propName, value);
 		}
+	} else if (_objType == kFactoryObj) {
+		// D3 style anonymous objects/factories, set whatever properties you like 
+		_properties[propName] = value;
+		return true;
 	}
 	return false;
 }


Commit: 48740a2ad12079747d3dd1c64ce332c5ee213e6e
    https://github.com/scummvm/scummvm/commit/48740a2ad12079747d3dd1c64ce332c5ee213e6e
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: Remove all palette reversing workarounds

All of the builtin palette lookup tables have been reversed, to match
the original layout of the tables in the Director 4 projector executable.
This corresponds with the colour indexing used in Lingo.
Likewise, the code to load palettes from the cast no longer reads the
colours in reverse order, and shiftPalette no longer expects
the start index to be after the end index.

DirectorEngine::transformColor still exists to upgrade to 32-bit colour,
but no longer reverses the palette index.

The missing builtin 16-color palettes from Director 4 have been added.

Changed paths:
    engines/director/cast.cpp
    engines/director/castmember.cpp
    engines/director/channel.cpp
    engines/director/cursor.cpp
    engines/director/graphics-data.h
    engines/director/graphics.cpp
    engines/director/images.cpp
    engines/director/palette-fade.h
    engines/director/score.cpp


diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index 79ce2feb78c..65ea9d08dc7 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -866,8 +866,8 @@ Common::String Cast::getVideoPath(int castId) {
 
 PaletteV4 Cast::loadPalette(Common::SeekableReadStreamEndian &stream) {
 	uint16 steps = stream.size() / 6;
-	uint16 index = (steps * 3) - 1;
-	byte *_palette = new byte[index + 1];
+	uint16 index = 0;
+	byte *_palette = new byte[steps * 3];
 
 	debugC(3, kDebugLoading, "Cast::loadPalette(): %d steps, %d bytes", steps, (int)stream.size());
 
@@ -877,15 +877,15 @@ PaletteV4 Cast::loadPalette(Common::SeekableReadStreamEndian &stream) {
 	}
 
 	for (int i = 0; i < steps; i++) {
-		_palette[index - 2] = stream.readByte();
+		_palette[index] = stream.readByte();
 		stream.readByte();
 
-		_palette[index - 1] = stream.readByte();
+		_palette[index + 1] = stream.readByte();
 		stream.readByte();
 
-		_palette[index] = stream.readByte();
+		_palette[index + 2] = stream.readByte();
 		stream.readByte();
-		index -= 3;
+		index += 3;
 	}
 
 	return PaletteV4(0, _palette, steps);
diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 8acdcdd8d3a..67098b44855 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -387,13 +387,13 @@ Graphics::Surface *BitmapCastMember::getMatte(Common::Rect &bbox) {
 
 Common::String BitmapCastMember::formatInfo() {
 	return Common::String::format(
-		"initialRect: %dx%d@%d,%d, boundingRect: %dx%d@%d,%d, foreColor: %d, backColor: %d, regX: %d, regY: %d, pitch: %d, bitsPerPixel: %d",
+		"initialRect: %dx%d@%d,%d, boundingRect: %dx%d@%d,%d, foreColor: %d, backColor: %d, regX: %d, regY: %d, pitch: %d, bitsPerPixel: %d, palette: %d",
 		_initialRect.width(), _initialRect.height(),
 		_initialRect.left, _initialRect.top,
 		_boundingRect.width(), _boundingRect.height(),
 		_boundingRect.left, _boundingRect.top,
 		getForeColor(), getBackColor(),
-		_regX, _regY, _pitch, _bitsPerPixel
+		_regX, _regY, _pitch, _bitsPerPixel, _clut
 	);
 }
 
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 3071ae48ef6..4663233f359 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -107,8 +107,8 @@ Channel::~Channel() {
 
 DirectorPlotData Channel::getPlotData() {
 	DirectorPlotData pd(g_director, _sprite->_spriteType, _sprite->_ink, _sprite->_blend, _sprite->getBackColor(), _sprite->getForeColor());
-	pd.colorWhite = 255;
-	pd.colorBlack = 0;
+	pd.colorWhite = 0;
+	pd.colorBlack = 255;
 	pd.dst = nullptr;
 
 	pd.srf = getSurface();
diff --git a/engines/director/cursor.cpp b/engines/director/cursor.cpp
index 617030e24e7..dbb2d123377 100644
--- a/engines/director/cursor.cpp
+++ b/engines/director/cursor.cpp
@@ -106,7 +106,7 @@ void Cursor::readFromCast(Datum cursorCasts) {
 			if (!cursor) {
 				*dst = 3;
 			} else {
-				*dst = *mask ? 3 : (*cursor ? 1 : 0);
+				*dst = *mask ? (*cursor ? 0 : 1) : 3;
 				cursor++;
 				mask++;
 			}
diff --git a/engines/director/graphics-data.h b/engines/director/graphics-data.h
index a86a0e21a2f..c0d2e6f30f4 100644
--- a/engines/director/graphics-data.h
+++ b/engines/director/graphics-data.h
@@ -19,540 +19,607 @@
  *
  */
 
+// The following builtin palettes are extracted from the resource forks
+// in the Director for Windows 4 projector executable.
+
 static byte macPalette[768] = {
-	0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44,  //   0 (0x00)
-	0x55, 0x55, 0x55, 0x77, 0x77, 0x77, 0x88, 0x88, 0x88, 0xaa, 0xaa, 0xaa,  //   4 (0x04)
-	0xbb, 0xbb, 0xbb, 0xdd, 0xdd, 0xdd, 0xee, 0xee, 0xee, 0x00, 0x00, 0x11,  //   8 (0x08)
-	0x00, 0x00, 0x22, 0x00, 0x00, 0x44, 0x00, 0x00, 0x55, 0x00, 0x00, 0x77,  //  12 (0x0c)
-	0x00, 0x00, 0x88, 0x00, 0x00, 0xaa, 0x00, 0x00, 0xbb, 0x00, 0x00, 0xdd,  //  16 (0x10)
-	0x00, 0x00, 0xee, 0x00, 0x11, 0x00, 0x00, 0x22, 0x00, 0x00, 0x44, 0x00,  //  20 (0x14)
-	0x00, 0x55, 0x00, 0x00, 0x77, 0x00, 0x00, 0x88, 0x00, 0x00, 0xaa, 0x00,  //  24 (0x18)
-	0x00, 0xbb, 0x00, 0x00, 0xdd, 0x00, 0x00, 0xee, 0x00, 0x11, 0x00, 0x00,  //  28 (0x1c)
-	0x22, 0x00, 0x00, 0x44, 0x00, 0x00, 0x55, 0x00, 0x00, 0x77, 0x00, 0x00,  //  32 (0x20)
-	0x88, 0x00, 0x00, 0xaa, 0x00, 0x00, 0xbb, 0x00, 0x00, 0xdd, 0x00, 0x00,  //  36 (0x24)
-	0xee, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x66, 0x00, 0x00, 0x99,  //  40 (0x28)
-	0x00, 0x00, 0xcc, 0x00, 0x00, 0xff, 0x00, 0x33, 0x00, 0x00, 0x33, 0x33,  //  44 (0x2c)
-	0x00, 0x33, 0x66, 0x00, 0x33, 0x99, 0x00, 0x33, 0xcc, 0x00, 0x33, 0xff,  //  48 (0x30)
-	0x00, 0x66, 0x00, 0x00, 0x66, 0x33, 0x00, 0x66, 0x66, 0x00, 0x66, 0x99,  //  52 (0x34)
-	0x00, 0x66, 0xcc, 0x00, 0x66, 0xff, 0x00, 0x99, 0x00, 0x00, 0x99, 0x33,  //  56 (0x38)
-	0x00, 0x99, 0x66, 0x00, 0x99, 0x99, 0x00, 0x99, 0xcc, 0x00, 0x99, 0xff,  //  60 (0x3c)
-	0x00, 0xcc, 0x00, 0x00, 0xcc, 0x33, 0x00, 0xcc, 0x66, 0x00, 0xcc, 0x99,  //  64 (0x40)
-	0x00, 0xcc, 0xcc, 0x00, 0xcc, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0x33,  //  68 (0x44)
-	0x00, 0xff, 0x66, 0x00, 0xff, 0x99, 0x00, 0xff, 0xcc, 0x00, 0xff, 0xff,  //  72 (0x48)
-	0x33, 0x00, 0x00, 0x33, 0x00, 0x33, 0x33, 0x00, 0x66, 0x33, 0x00, 0x99,  //  76 (0x4c)
-	0x33, 0x00, 0xcc, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33,  //  80 (0x50)
-	0x33, 0x33, 0x66, 0x33, 0x33, 0x99, 0x33, 0x33, 0xcc, 0x33, 0x33, 0xff,  //  84 (0x54)
-	0x33, 0x66, 0x00, 0x33, 0x66, 0x33, 0x33, 0x66, 0x66, 0x33, 0x66, 0x99,  //  88 (0x58)
-	0x33, 0x66, 0xcc, 0x33, 0x66, 0xff, 0x33, 0x99, 0x00, 0x33, 0x99, 0x33,  //  92 (0x5c)
-	0x33, 0x99, 0x66, 0x33, 0x99, 0x99, 0x33, 0x99, 0xcc, 0x33, 0x99, 0xff,  //  96 (0x60)
-	0x33, 0xcc, 0x00, 0x33, 0xcc, 0x33, 0x33, 0xcc, 0x66, 0x33, 0xcc, 0x99,  // 100 (0x64)
-	0x33, 0xcc, 0xcc, 0x33, 0xcc, 0xff, 0x33, 0xff, 0x00, 0x33, 0xff, 0x33,  // 104 (0x68)
-	0x33, 0xff, 0x66, 0x33, 0xff, 0x99, 0x33, 0xff, 0xcc, 0x33, 0xff, 0xff,  // 108 (0x6c)
-	0x66, 0x00, 0x00, 0x66, 0x00, 0x33, 0x66, 0x00, 0x66, 0x66, 0x00, 0x99,  // 112 (0x70)
-	0x66, 0x00, 0xcc, 0x66, 0x00, 0xff, 0x66, 0x33, 0x00, 0x66, 0x33, 0x33,  // 116 (0x74)
-	0x66, 0x33, 0x66, 0x66, 0x33, 0x99, 0x66, 0x33, 0xcc, 0x66, 0x33, 0xff,  // 120 (0x78)
-	0x66, 0x66, 0x00, 0x66, 0x66, 0x33, 0x66, 0x66, 0x66, 0x66, 0x66, 0x99,  // 124 (0x7c)
-	0x66, 0x66, 0xcc, 0x66, 0x66, 0xff, 0x66, 0x99, 0x00, 0x66, 0x99, 0x33,  // 128 (0x80)
-	0x66, 0x99, 0x66, 0x66, 0x99, 0x99, 0x66, 0x99, 0xcc, 0x66, 0x99, 0xff,  // 132 (0x84)
-	0x66, 0xcc, 0x00, 0x66, 0xcc, 0x33, 0x66, 0xcc, 0x66, 0x66, 0xcc, 0x99,  // 136 (0x88)
-	0x66, 0xcc, 0xcc, 0x66, 0xcc, 0xff, 0x66, 0xff, 0x00, 0x66, 0xff, 0x33,  // 140 (0x8c)
-	0x66, 0xff, 0x66, 0x66, 0xff, 0x99, 0x66, 0xff, 0xcc, 0x66, 0xff, 0xff,  // 144 (0x90)
-	0x99, 0x00, 0x00, 0x99, 0x00, 0x33, 0x99, 0x00, 0x66, 0x99, 0x00, 0x99,  // 148 (0x94)
-	0x99, 0x00, 0xcc, 0x99, 0x00, 0xff, 0x99, 0x33, 0x00, 0x99, 0x33, 0x33,  // 152 (0x98)
-	0x99, 0x33, 0x66, 0x99, 0x33, 0x99, 0x99, 0x33, 0xcc, 0x99, 0x33, 0xff,  // 156 (0x9c)
-	0x99, 0x66, 0x00, 0x99, 0x66, 0x33, 0x99, 0x66, 0x66, 0x99, 0x66, 0x99,  // 160 (0xa0)
-	0x99, 0x66, 0xcc, 0x99, 0x66, 0xff, 0x99, 0x99, 0x00, 0x99, 0x99, 0x33,  // 164 (0xa4)
-	0x99, 0x99, 0x66, 0x99, 0x99, 0x99, 0x99, 0x99, 0xcc, 0x99, 0x99, 0xff,  // 168 (0xa8)
-	0x99, 0xcc, 0x00, 0x99, 0xcc, 0x33, 0x99, 0xcc, 0x66, 0x99, 0xcc, 0x99,  // 172 (0xac)
-	0x99, 0xcc, 0xcc, 0x99, 0xcc, 0xff, 0x99, 0xff, 0x00, 0x99, 0xff, 0x33,  // 176 (0xb0)
-	0x99, 0xff, 0x66, 0x99, 0xff, 0x99, 0x99, 0xff, 0xcc, 0x99, 0xff, 0xff,  // 180 (0xb4)
-	0xcc, 0x00, 0x00, 0xcc, 0x00, 0x33, 0xcc, 0x00, 0x66, 0xcc, 0x00, 0x99,  // 184 (0xb8)
-	0xcc, 0x00, 0xcc, 0xcc, 0x00, 0xff, 0xcc, 0x33, 0x00, 0xcc, 0x33, 0x33,  // 188 (0xbc)
-	0xcc, 0x33, 0x66, 0xcc, 0x33, 0x99, 0xcc, 0x33, 0xcc, 0xcc, 0x33, 0xff,  // 192 (0xc0)
-	0xcc, 0x66, 0x00, 0xcc, 0x66, 0x33, 0xcc, 0x66, 0x66, 0xcc, 0x66, 0x99,  // 196 (0xc4)
-	0xcc, 0x66, 0xcc, 0xcc, 0x66, 0xff, 0xcc, 0x99, 0x00, 0xcc, 0x99, 0x33,  // 200 (0xc8)
-	0xcc, 0x99, 0x66, 0xcc, 0x99, 0x99, 0xcc, 0x99, 0xcc, 0xcc, 0x99, 0xff,  // 204 (0xcc)
-	0xcc, 0xcc, 0x00, 0xcc, 0xcc, 0x33, 0xcc, 0xcc, 0x66, 0xcc, 0xcc, 0x99,  // 208 (0xd0)
-	0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xff, 0xcc, 0xff, 0x00, 0xcc, 0xff, 0x33,  // 212 (0xd4)
-	0xcc, 0xff, 0x66, 0xcc, 0xff, 0x99, 0xcc, 0xff, 0xcc, 0xcc, 0xff, 0xff,  // 216 (0xd8)
-	0xff, 0x00, 0x00, 0xff, 0x00, 0x33, 0xff, 0x00, 0x66, 0xff, 0x00, 0x99,  // 220 (0xdc)
-	0xff, 0x00, 0xcc, 0xff, 0x00, 0xff, 0xff, 0x33, 0x00, 0xff, 0x33, 0x33,  // 224 (0xe0)
-	0xff, 0x33, 0x66, 0xff, 0x33, 0x99, 0xff, 0x33, 0xcc, 0xff, 0x33, 0xff,  // 228 (0xe4)
-	0xff, 0x66, 0x00, 0xff, 0x66, 0x33, 0xff, 0x66, 0x66, 0xff, 0x66, 0x99,  // 232 (0xe8)
-	0xff, 0x66, 0xcc, 0xff, 0x66, 0xff, 0xff, 0x99, 0x00, 0xff, 0x99, 0x33,  // 236 (0xec)
-	0xff, 0x99, 0x66, 0xff, 0x99, 0x99, 0xff, 0x99, 0xcc, 0xff, 0x99, 0xff,  // 240 (0xf0)
-	0xff, 0xcc, 0x00, 0xff, 0xcc, 0x33, 0xff, 0xcc, 0x66, 0xff, 0xcc, 0x99,  // 244 (0xf4)
-	0xff, 0xcc, 0xcc, 0xff, 0xcc, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0x33,  // 248 (0xf8)
-	0xff, 0xff, 0x66, 0xff, 0xff, 0x99, 0xff, 0xff, 0xcc, 0xff, 0xff, 0xff   // 252 (0xfc)
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xcc, 0xff, 0xff, 0x99, 0xff, 0xff, 0x66,  //   0 (0x00)
+	0xff, 0xff, 0x33, 0xff, 0xff, 0x00, 0xff, 0xcc, 0xff, 0xff, 0xcc, 0xcc,  //   4 (0x04)
+	0xff, 0xcc, 0x99, 0xff, 0xcc, 0x66, 0xff, 0xcc, 0x33, 0xff, 0xcc, 0x00,  //   8 (0x08)
+	0xff, 0x99, 0xff, 0xff, 0x99, 0xcc, 0xff, 0x99, 0x99, 0xff, 0x99, 0x66,  //  12 (0x0c)
+	0xff, 0x99, 0x33, 0xff, 0x99, 0x00, 0xff, 0x66, 0xff, 0xff, 0x66, 0xcc,  //  16 (0x10)
+	0xff, 0x66, 0x99, 0xff, 0x66, 0x66, 0xff, 0x66, 0x33, 0xff, 0x66, 0x00,  //  20 (0x14)
+	0xff, 0x33, 0xff, 0xff, 0x33, 0xcc, 0xff, 0x33, 0x99, 0xff, 0x33, 0x66,  //  24 (0x18)
+	0xff, 0x33, 0x33, 0xff, 0x33, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xcc,  //  28 (0x1c)
+	0xff, 0x00, 0x99, 0xff, 0x00, 0x66, 0xff, 0x00, 0x33, 0xff, 0x00, 0x00,  //  32 (0x20)
+	0xcc, 0xff, 0xff, 0xcc, 0xff, 0xcc, 0xcc, 0xff, 0x99, 0xcc, 0xff, 0x66,  //  36 (0x24)
+	0xcc, 0xff, 0x33, 0xcc, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0xcc, 0xcc, 0xcc,  //  40 (0x28)
+	0xcc, 0xcc, 0x99, 0xcc, 0xcc, 0x66, 0xcc, 0xcc, 0x33, 0xcc, 0xcc, 0x00,  //  44 (0x2c)
+	0xcc, 0x99, 0xff, 0xcc, 0x99, 0xcc, 0xcc, 0x99, 0x99, 0xcc, 0x99, 0x66,  //  48 (0x30)
+	0xcc, 0x99, 0x33, 0xcc, 0x99, 0x00, 0xcc, 0x66, 0xff, 0xcc, 0x66, 0xcc,  //  52 (0x34)
+	0xcc, 0x66, 0x99, 0xcc, 0x66, 0x66, 0xcc, 0x66, 0x33, 0xcc, 0x66, 0x00,  //  56 (0x38)
+	0xcc, 0x33, 0xff, 0xcc, 0x33, 0xcc, 0xcc, 0x33, 0x99, 0xcc, 0x33, 0x66,  //  60 (0x3c)
+	0xcc, 0x33, 0x33, 0xcc, 0x33, 0x00, 0xcc, 0x00, 0xff, 0xcc, 0x00, 0xcc,  //  64 (0x40)
+	0xcc, 0x00, 0x99, 0xcc, 0x00, 0x66, 0xcc, 0x00, 0x33, 0xcc, 0x00, 0x00,  //  68 (0x44)
+	0x99, 0xff, 0xff, 0x99, 0xff, 0xcc, 0x99, 0xff, 0x99, 0x99, 0xff, 0x66,  //  72 (0x48)
+	0x99, 0xff, 0x33, 0x99, 0xff, 0x00, 0x99, 0xcc, 0xff, 0x99, 0xcc, 0xcc,  //  76 (0x4c)
+	0x99, 0xcc, 0x99, 0x99, 0xcc, 0x66, 0x99, 0xcc, 0x33, 0x99, 0xcc, 0x00,  //  80 (0x50)
+	0x99, 0x99, 0xff, 0x99, 0x99, 0xcc, 0x99, 0x99, 0x99, 0x99, 0x99, 0x66,  //  84 (0x54)
+	0x99, 0x99, 0x33, 0x99, 0x99, 0x00, 0x99, 0x66, 0xff, 0x99, 0x66, 0xcc,  //  88 (0x58)
+	0x99, 0x66, 0x99, 0x99, 0x66, 0x66, 0x99, 0x66, 0x33, 0x99, 0x66, 0x00,  //  92 (0x5c)
+	0x99, 0x33, 0xff, 0x99, 0x33, 0xcc, 0x99, 0x33, 0x99, 0x99, 0x33, 0x66,  //  96 (0x60)
+	0x99, 0x33, 0x33, 0x99, 0x33, 0x00, 0x99, 0x00, 0xff, 0x99, 0x00, 0xcc,  // 100 (0x64)
+	0x99, 0x00, 0x99, 0x99, 0x00, 0x66, 0x99, 0x00, 0x33, 0x99, 0x00, 0x00,  // 104 (0x68)
+	0x66, 0xff, 0xff, 0x66, 0xff, 0xcc, 0x66, 0xff, 0x99, 0x66, 0xff, 0x66,  // 108 (0x6c)
+	0x66, 0xff, 0x33, 0x66, 0xff, 0x00, 0x66, 0xcc, 0xff, 0x66, 0xcc, 0xcc,  // 112 (0x70)
+	0x66, 0xcc, 0x99, 0x66, 0xcc, 0x66, 0x66, 0xcc, 0x33, 0x66, 0xcc, 0x00,  // 116 (0x74)
+	0x66, 0x99, 0xff, 0x66, 0x99, 0xcc, 0x66, 0x99, 0x99, 0x66, 0x99, 0x66,  // 120 (0x78)
+	0x66, 0x99, 0x33, 0x66, 0x99, 0x00, 0x66, 0x66, 0xff, 0x66, 0x66, 0xcc,  // 124 (0x7c)
+	0x66, 0x66, 0x99, 0x66, 0x66, 0x66, 0x66, 0x66, 0x33, 0x66, 0x66, 0x00,  // 128 (0x80)
+	0x66, 0x33, 0xff, 0x66, 0x33, 0xcc, 0x66, 0x33, 0x99, 0x66, 0x33, 0x66,  // 132 (0x84)
+	0x66, 0x33, 0x33, 0x66, 0x33, 0x00, 0x66, 0x00, 0xff, 0x66, 0x00, 0xcc,  // 136 (0x88)
+	0x66, 0x00, 0x99, 0x66, 0x00, 0x66, 0x66, 0x00, 0x33, 0x66, 0x00, 0x00,  // 140 (0x8c)
+	0x33, 0xff, 0xff, 0x33, 0xff, 0xcc, 0x33, 0xff, 0x99, 0x33, 0xff, 0x66,  // 144 (0x90)
+	0x33, 0xff, 0x33, 0x33, 0xff, 0x00, 0x33, 0xcc, 0xff, 0x33, 0xcc, 0xcc,  // 148 (0x94)
+	0x33, 0xcc, 0x99, 0x33, 0xcc, 0x66, 0x33, 0xcc, 0x33, 0x33, 0xcc, 0x00,  // 152 (0x98)
+	0x33, 0x99, 0xff, 0x33, 0x99, 0xcc, 0x33, 0x99, 0x99, 0x33, 0x99, 0x66,  // 156 (0x9c)
+	0x33, 0x99, 0x33, 0x33, 0x99, 0x00, 0x33, 0x66, 0xff, 0x33, 0x66, 0xcc,  // 160 (0xa0)
+	0x33, 0x66, 0x99, 0x33, 0x66, 0x66, 0x33, 0x66, 0x33, 0x33, 0x66, 0x00,  // 164 (0xa4)
+	0x33, 0x33, 0xff, 0x33, 0x33, 0xcc, 0x33, 0x33, 0x99, 0x33, 0x33, 0x66,  // 168 (0xa8)
+	0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x33, 0x00, 0xff, 0x33, 0x00, 0xcc,  // 172 (0xac)
+	0x33, 0x00, 0x99, 0x33, 0x00, 0x66, 0x33, 0x00, 0x33, 0x33, 0x00, 0x00,  // 176 (0xb0)
+	0x00, 0xff, 0xff, 0x00, 0xff, 0xcc, 0x00, 0xff, 0x99, 0x00, 0xff, 0x66,  // 180 (0xb4)
+	0x00, 0xff, 0x33, 0x00, 0xff, 0x00, 0x00, 0xcc, 0xff, 0x00, 0xcc, 0xcc,  // 184 (0xb8)
+	0x00, 0xcc, 0x99, 0x00, 0xcc, 0x66, 0x00, 0xcc, 0x33, 0x00, 0xcc, 0x00,  // 188 (0xbc)
+	0x00, 0x99, 0xff, 0x00, 0x99, 0xcc, 0x00, 0x99, 0x99, 0x00, 0x99, 0x66,  // 192 (0xc0)
+	0x00, 0x99, 0x33, 0x00, 0x99, 0x00, 0x00, 0x66, 0xff, 0x00, 0x66, 0xcc,  // 196 (0xc4)
+	0x00, 0x66, 0x99, 0x00, 0x66, 0x66, 0x00, 0x66, 0x33, 0x00, 0x66, 0x00,  // 200 (0xc8)
+	0x00, 0x33, 0xff, 0x00, 0x33, 0xcc, 0x00, 0x33, 0x99, 0x00, 0x33, 0x66,  // 204 (0xcc)
+	0x00, 0x33, 0x33, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xcc,  // 208 (0xd0)
+	0x00, 0x00, 0x99, 0x00, 0x00, 0x66, 0x00, 0x00, 0x33, 0xee, 0x00, 0x00,  // 212 (0xd4)
+	0xdd, 0x00, 0x00, 0xbb, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x88, 0x00, 0x00,  // 216 (0xd8)
+	0x77, 0x00, 0x00, 0x55, 0x00, 0x00, 0x44, 0x00, 0x00, 0x22, 0x00, 0x00,  // 220 (0xdc)
+	0x11, 0x00, 0x00, 0x00, 0xee, 0x00, 0x00, 0xdd, 0x00, 0x00, 0xbb, 0x00,  // 224 (0xe0)
+	0x00, 0xaa, 0x00, 0x00, 0x88, 0x00, 0x00, 0x77, 0x00, 0x00, 0x55, 0x00,  // 228 (0xe4)
+	0x00, 0x44, 0x00, 0x00, 0x22, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xee,  // 232 (0xe8)
+	0x00, 0x00, 0xdd, 0x00, 0x00, 0xbb, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x88,  // 236 (0xec)
+	0x00, 0x00, 0x77, 0x00, 0x00, 0x55, 0x00, 0x00, 0x44, 0x00, 0x00, 0x22,  // 240 (0xf0)
+	0x00, 0x00, 0x11, 0xee, 0xee, 0xee, 0xdd, 0xdd, 0xdd, 0xbb, 0xbb, 0xbb,  // 244 (0xf4)
+	0xaa, 0xaa, 0xaa, 0x88, 0x88, 0x88, 0x77, 0x77, 0x77, 0x55, 0x55, 0x55,  // 248 (0xf8)
+	0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00,  // 252 (0xfc)
+};
+
+static byte mac16Palette[48] = {
+	0xff, 0xff, 0xff, 0xfc, 0xf3, 0x05, 0xff, 0x64, 0x02, 0xdd, 0x08, 0x06,  //   0 (0x00)
+	0xf2, 0x08, 0x84, 0x46, 0x00, 0xa5, 0x00, 0x00, 0xd4, 0x02, 0xab, 0xea,  //   4 (0x04)
+	0x1f, 0xb7, 0x14, 0x00, 0x64, 0x11, 0x56, 0x2c, 0x05, 0x90, 0x71, 0x3a,  //   8 (0x08)
+	0xc0, 0xc0, 0xc0, 0x80, 0x80, 0x80, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00,  //  12 (0x0c)
+};
+
+static byte rainbow16Palette[48] = {
+	0xff, 0xff, 0xff, 0x00, 0x0a, 0xff, 0x5f, 0x00, 0xff, 0xc5, 0x00, 0xff,  //   0 (0x00)
+	0xff, 0x00, 0xd2, 0xff, 0x00, 0x6c, 0xff, 0x00, 0x06, 0xff, 0x5f, 0x00,  //   4 (0x04)
+	0xff, 0xc5, 0x00, 0xd2, 0xff, 0x00, 0x6c, 0xff, 0x00, 0x06, 0xff, 0x00,  //   8 (0x08)
+	0x00, 0xff, 0x5f, 0x00, 0xff, 0xc5, 0x00, 0xd2, 0xff, 0x00, 0x00, 0x00,  //  12 (0x0c)
+};
+
+static byte grayscale16Palette[48] = {
+	0xff, 0xff, 0xff, 0xee, 0xee, 0xee, 0xdd, 0xdd, 0xdd, 0xcc, 0xcc, 0xcc,  //   0 (0x00)
+	0xba, 0xba, 0xba, 0xa9, 0xa9, 0xa9, 0x98, 0x98, 0x98, 0x87, 0x87, 0x87,  //   4 (0x04)
+	0x76, 0x76, 0x76, 0x65, 0x65, 0x65, 0x54, 0x54, 0x54, 0x43, 0x43, 0x43,  //   8 (0x08)
+	0x31, 0x31, 0x31, 0x20, 0x20, 0x20, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00,  //  12 (0x0c)
+};
+
+static byte pastels16Palette[48] = {
+	0xff, 0xff, 0xff, 0xfd, 0xbe, 0x47, 0xef, 0x65, 0x48, 0xc8, 0x37, 0x44,  //   0 (0x00)
+	0xe6, 0x43, 0x8b, 0x91, 0x46, 0xb8, 0x4b, 0x44, 0xdb, 0x46, 0xb9, 0xee,  //   4 (0x04)
+	0x5c, 0xcb, 0x53, 0x48, 0x8c, 0x50, 0x94, 0x78, 0x48, 0xf8, 0xd3, 0x49,  //   8 (0x08)
+	0xe9, 0x4b, 0x62, 0xba, 0x48, 0xb9, 0x88, 0x88, 0xe6, 0x00, 0x00, 0x00,  //  12 (0x0c)
+};
+
+static byte vivid16Palette[48] = {
+	0xff, 0xff, 0xff, 0xfc, 0xcc, 0x03, 0xf3, 0x44, 0x02, 0xc8, 0x04, 0x0d,  //   0 (0x00)
+	0xcb, 0x03, 0x4a, 0x96, 0x03, 0x95, 0x1b, 0x00, 0xc1, 0x01, 0x72, 0xe2,  //   4 (0x04)
+	0x17, 0xb3, 0x4d, 0x06, 0x74, 0x11, 0x4a, 0x33, 0x06, 0xf0, 0xe5, 0x04,  //   8 (0x08)
+	0xdc, 0x07, 0x06, 0xe1, 0x07, 0x89, 0x20, 0x20, 0xd7, 0x00, 0x00, 0x00,  //  12 (0x0c)
+};
+
+static byte ntsc16Palette[48] = {
+	0xff, 0xff, 0xff, 0xbe, 0xbe, 0xbe, 0xff, 0xe6, 0x00, 0x80, 0x80, 0x80,  //   0 (0x00)
+	0x56, 0x2c, 0x05, 0x7c, 0x60, 0x1b, 0x00, 0x9e, 0x00, 0x00, 0x64, 0x11,  //   4 (0x04)
+	0xde, 0x00, 0xbf, 0x46, 0x00, 0xa5, 0xfa, 0x00, 0x39, 0xff, 0x8c, 0x32,  //   8 (0x08)
+	0x00, 0x00, 0xea, 0x02, 0xab, 0xea, 0x64, 0x64, 0x64, 0x00, 0x00, 0x00,  //  12 (0x0c)
+};
+
+static byte metallic16Palette[48] = {
+	0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff,  //   0 (0x00)
+	0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x7f, 0x7f, 0x7f,  //   4 (0x04)
+	0xbf, 0xbf, 0xbf, 0x00, 0x7f, 0x7f, 0x7f, 0x00, 0x7f, 0x00, 0x00, 0x7f,  //   8 (0x08)
+	0x7f, 0x7f, 0x00, 0x00, 0x7f, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,  //  12 (0x0c)
 };
 
 static byte rainbowPalette[768] = {
-	0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x20, 0x20, 0x20, 0x30, 0x30, 0x30,  // 0 (0x00)
-	0x40, 0x40, 0x40, 0x50, 0x50, 0x50, 0x60, 0x60, 0x60, 0x70, 0x70, 0x70,  // 4 (0x04)
-	0x80, 0x80, 0x80, 0x90, 0x90, 0x90, 0xa0, 0xa0, 0xa0, 0xb0, 0xb0, 0xb0,  // 8 (0x08)
-	0xc0, 0xc0, 0xc0, 0xd0, 0xd0, 0xd0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0,  // 12 (0x0c)
-	0x00, 0x72, 0xff, 0x00, 0x79, 0xff, 0x00, 0x7f, 0xff, 0x00, 0x85, 0xff,  // 16 (0x10)
-	0x00, 0x8c, 0xff, 0x00, 0x92, 0xff, 0x00, 0x99, 0xff, 0x00, 0x9f, 0xff,  // 20 (0x14)
-	0x00, 0xa5, 0xff, 0x00, 0xac, 0xff, 0x00, 0xb2, 0xff, 0x00, 0xb8, 0xff,  // 24 (0x18)
-	0x00, 0xbf, 0xff, 0x00, 0xc5, 0xff, 0x00, 0xcc, 0xff, 0x00, 0xd2, 0xff,  // 28 (0x1c)
-	0x00, 0xd8, 0xff, 0x00, 0xdf, 0xff, 0x00, 0xe5, 0xff, 0x00, 0xeb, 0xff,  // 32 (0x20)
-	0x00, 0xf2, 0xff, 0x00, 0xf8, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xf8,  // 36 (0x24)
-	0x00, 0xff, 0xf2, 0x00, 0xff, 0xeb, 0x00, 0xff, 0xe5, 0x00, 0xff, 0xdf,  // 40 (0x28)
-	0x00, 0xff, 0xd8, 0x00, 0xff, 0xd2, 0x00, 0xff, 0xcc, 0x00, 0xff, 0xc5,  // 44 (0x2c)
-	0x00, 0xff, 0xbf, 0x00, 0xff, 0xb8, 0x00, 0xff, 0xb2, 0x00, 0xff, 0xac,  // 48 (0x30)
-	0x00, 0xff, 0xa5, 0x00, 0xff, 0x9f, 0x00, 0xff, 0x99, 0x00, 0xff, 0x92,  // 52 (0x34)
-	0x00, 0xff, 0x8c, 0x00, 0xff, 0x85, 0x00, 0xff, 0x7f, 0x00, 0xff, 0x79,  // 56 (0x38)
-	0x00, 0xff, 0x72, 0x00, 0xff, 0x6c, 0x00, 0xff, 0x66, 0x00, 0xff, 0x5f,  // 60 (0x3c)
-	0x00, 0xff, 0x59, 0x00, 0xff, 0x52, 0x00, 0xff, 0x4c, 0x00, 0xff, 0x46,  // 64 (0x40)
-	0x00, 0xff, 0x3f, 0x00, 0xff, 0x39, 0x00, 0xff, 0x33, 0x00, 0xff, 0x2c,  // 68 (0x44)
-	0x00, 0xff, 0x26, 0x00, 0xff, 0x1f, 0x00, 0xff, 0x19, 0x00, 0xff, 0x13,  // 72 (0x48)
-	0x00, 0xff, 0x0c, 0x00, 0xff, 0x06, 0x00, 0xff, 0x00, 0x06, 0xff, 0x00,  // 76 (0x4c)
-	0x0c, 0xff, 0x00, 0x13, 0xff, 0x00, 0x19, 0xff, 0x00, 0x1f, 0xff, 0x00,  // 80 (0x50)
-	0x26, 0xff, 0x00, 0x2c, 0xff, 0x00, 0x33, 0xff, 0x00, 0x39, 0xff, 0x00,  // 84 (0x54)
-	0x3f, 0xff, 0x00, 0x46, 0xff, 0x00, 0x4c, 0xff, 0x00, 0x52, 0xff, 0x00,  // 88 (0x58)
-	0x59, 0xff, 0x00, 0x5f, 0xff, 0x00, 0x66, 0xff, 0x00, 0x6c, 0xff, 0x00,  // 92 (0x5c)
-	0x72, 0xff, 0x00, 0x79, 0xff, 0x00, 0x7f, 0xff, 0x00, 0x85, 0xff, 0x00,  // 96 (0x60)
-	0x8c, 0xff, 0x00, 0x92, 0xff, 0x00, 0x99, 0xff, 0x00, 0x9f, 0xff, 0x00,  // 100 (0x64)
-	0xa5, 0xff, 0x00, 0xac, 0xff, 0x00, 0xb2, 0xff, 0x00, 0xb8, 0xff, 0x00,  // 104 (0x68)
-	0xbf, 0xff, 0x00, 0xc5, 0xff, 0x00, 0xcc, 0xff, 0x00, 0xd2, 0xff, 0x00,  // 108 (0x6c)
-	0xd8, 0xff, 0x00, 0xdf, 0xff, 0x00, 0xe5, 0xff, 0x00, 0xeb, 0xff, 0x00,  // 112 (0x70)
-	0xf2, 0xff, 0x00, 0xf8, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xf8, 0x00,  // 116 (0x74)
-	0xff, 0xf2, 0x00, 0xff, 0xeb, 0x00, 0xff, 0xe5, 0x00, 0xff, 0xdf, 0x00,  // 120 (0x78)
-	0xff, 0xd8, 0x00, 0xff, 0xd2, 0x00, 0xff, 0xcc, 0x00, 0xff, 0xc5, 0x00,  // 124 (0x7c)
-	0xff, 0xbf, 0x00, 0xff, 0xb8, 0x00, 0xff, 0xb2, 0x00, 0xff, 0xac, 0x00,  // 128 (0x80)
-	0xff, 0xa5, 0x00, 0xff, 0x9f, 0x00, 0xff, 0x99, 0x00, 0xff, 0x92, 0x00,  // 132 (0x84)
-	0xff, 0x8c, 0x00, 0xff, 0x85, 0x00, 0xff, 0x7f, 0x00, 0xff, 0x79, 0x00,  // 136 (0x88)
-	0xff, 0x72, 0x00, 0xff, 0x6c, 0x00, 0xff, 0x66, 0x00, 0xff, 0x5f, 0x00,  // 140 (0x8c)
-	0xff, 0x59, 0x00, 0xff, 0x52, 0x00, 0xff, 0x4c, 0x00, 0xff, 0x46, 0x00,  // 144 (0x90)
-	0xff, 0x3f, 0x00, 0xff, 0x39, 0x00, 0xff, 0x33, 0x00, 0xff, 0x2c, 0x00,  // 148 (0x94)
-	0xff, 0x26, 0x00, 0xff, 0x1f, 0x00, 0xff, 0x19, 0x00, 0xff, 0x13, 0x00,  // 152 (0x98)
-	0xff, 0x0c, 0x00, 0xff, 0x06, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x06,  // 156 (0x9c)
-	0xff, 0x00, 0x0c, 0xff, 0x00, 0x13, 0xff, 0x00, 0x19, 0xff, 0x00, 0x1f,  // 160 (0xa0)
-	0xff, 0x00, 0x26, 0xff, 0x00, 0x2c, 0xff, 0x00, 0x33, 0xff, 0x00, 0x39,  // 164 (0xa4)
-	0xff, 0x00, 0x3f, 0xff, 0x00, 0x46, 0xff, 0x00, 0x4c, 0xff, 0x00, 0x52,  // 168 (0xa8)
-	0xff, 0x00, 0x59, 0xff, 0x00, 0x5f, 0xff, 0x00, 0x66, 0xff, 0x00, 0x6c,  // 172 (0xac)
-	0xff, 0x00, 0x72, 0xff, 0x00, 0x79, 0xff, 0x00, 0x7f, 0xff, 0x00, 0x85,  // 176 (0xb0)
-	0xff, 0x00, 0x8c, 0xff, 0x00, 0x92, 0xff, 0x00, 0x99, 0xff, 0x00, 0x9f,  // 180 (0xb4)
-	0xff, 0x00, 0xa5, 0xff, 0x00, 0xac, 0xff, 0x00, 0xb2, 0xff, 0x00, 0xb8,  // 184 (0xb8)
-	0xff, 0x00, 0xbf, 0xff, 0x00, 0xc5, 0xff, 0x00, 0xcc, 0xff, 0x00, 0xd2,  // 188 (0xbc)
-	0xff, 0x00, 0xd8, 0xff, 0x00, 0xdf, 0xff, 0x00, 0xe5, 0xff, 0x00, 0xeb,  // 192 (0xc0)
-	0xff, 0x00, 0xf2, 0xff, 0x00, 0xf8, 0xff, 0x00, 0xff, 0xf8, 0x00, 0xff,  // 196 (0xc4)
-	0xf2, 0x00, 0xff, 0xeb, 0x00, 0xff, 0xe5, 0x00, 0xff, 0xdf, 0x00, 0xff,  // 200 (0xc8)
-	0xd8, 0x00, 0xff, 0xd2, 0x00, 0xff, 0xcc, 0x00, 0xff, 0xc5, 0x00, 0xff,  // 204 (0xcc)
-	0xbf, 0x00, 0xff, 0xb8, 0x00, 0xff, 0xb2, 0x00, 0xff, 0xac, 0x00, 0xff,  // 208 (0xd0)
-	0xa5, 0x00, 0xff, 0x9f, 0x00, 0xff, 0x99, 0x00, 0xff, 0x92, 0x00, 0xff,  // 212 (0xd4)
-	0x8c, 0x00, 0xff, 0x85, 0x00, 0xff, 0x7f, 0x00, 0xff, 0x79, 0x00, 0xff,  // 216 (0xd8)
-	0x72, 0x00, 0xff, 0x6c, 0x00, 0xff, 0x66, 0x00, 0xff, 0x5f, 0x00, 0xff,  // 220 (0xdc)
-	0x59, 0x00, 0xff, 0x52, 0x00, 0xff, 0x4c, 0x00, 0xff, 0x46, 0x00, 0xff,  // 224 (0xe0)
-	0x3f, 0x00, 0xff, 0x39, 0x00, 0xff, 0x33, 0x00, 0xff, 0x2c, 0x00, 0xff,  // 228 (0xe4)
-	0x26, 0x00, 0xff, 0x1f, 0x00, 0xff, 0x19, 0x00, 0xff, 0x13, 0x00, 0xff,  // 232 (0xe8)
-	0x0c, 0x00, 0xff, 0x06, 0x00, 0xff, 0x00, 0x03, 0xff, 0x00, 0x0a, 0xff,  // 236 (0xec)
-	0x00, 0x10, 0xff, 0x00, 0x17, 0xff, 0x00, 0x1d, 0xff, 0x00, 0x23, 0xff,  // 240 (0xf0)
-	0x00, 0x2a, 0xff, 0x00, 0x30, 0xff, 0x00, 0x36, 0xff, 0x00, 0x3d, 0xff,  // 244 (0xf4)
-	0x00, 0x43, 0xff, 0x00, 0x4a, 0xff, 0x00, 0x50, 0xff, 0x00, 0x56, 0xff,  // 248 (0xf8)
-	0x00, 0x5d, 0xff, 0x00, 0x63, 0xff, 0x00, 0x69, 0xff, 0xff, 0xff, 0xff   // 252 (0xfc)
+	0xff, 0xff, 0xff, 0x00, 0x69, 0xff, 0x00, 0x63, 0xff, 0x00, 0x5d, 0xff,  //   0 (0x00)
+	0x00, 0x56, 0xff, 0x00, 0x50, 0xff, 0x00, 0x4a, 0xff, 0x00, 0x43, 0xff,  //   4 (0x04)
+	0x00, 0x3d, 0xff, 0x00, 0x36, 0xff, 0x00, 0x30, 0xff, 0x00, 0x2a, 0xff,  //   8 (0x08)
+	0x00, 0x23, 0xff, 0x00, 0x1d, 0xff, 0x00, 0x17, 0xff, 0x00, 0x10, 0xff,  //  12 (0x0c)
+	0x00, 0x0a, 0xff, 0x00, 0x03, 0xff, 0x06, 0x00, 0xff, 0x0c, 0x00, 0xff,  //  16 (0x10)
+	0x13, 0x00, 0xff, 0x19, 0x00, 0xff, 0x1f, 0x00, 0xff, 0x26, 0x00, 0xff,  //  20 (0x14)
+	0x2c, 0x00, 0xff, 0x33, 0x00, 0xff, 0x39, 0x00, 0xff, 0x3f, 0x00, 0xff,  //  24 (0x18)
+	0x46, 0x00, 0xff, 0x4c, 0x00, 0xff, 0x52, 0x00, 0xff, 0x59, 0x00, 0xff,  //  28 (0x1c)
+	0x5f, 0x00, 0xff, 0x66, 0x00, 0xff, 0x6c, 0x00, 0xff, 0x72, 0x00, 0xff,  //  32 (0x20)
+	0x79, 0x00, 0xff, 0x7f, 0x00, 0xff, 0x85, 0x00, 0xff, 0x8c, 0x00, 0xff,  //  36 (0x24)
+	0x92, 0x00, 0xff, 0x99, 0x00, 0xff, 0x9f, 0x00, 0xff, 0xa5, 0x00, 0xff,  //  40 (0x28)
+	0xac, 0x00, 0xff, 0xb2, 0x00, 0xff, 0xb8, 0x00, 0xff, 0xbf, 0x00, 0xff,  //  44 (0x2c)
+	0xc5, 0x00, 0xff, 0xcc, 0x00, 0xff, 0xd2, 0x00, 0xff, 0xd8, 0x00, 0xff,  //  48 (0x30)
+	0xdf, 0x00, 0xff, 0xe5, 0x00, 0xff, 0xeb, 0x00, 0xff, 0xf2, 0x00, 0xff,  //  52 (0x34)
+	0xf8, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xf8, 0xff, 0x00, 0xf2,  //  56 (0x38)
+	0xff, 0x00, 0xeb, 0xff, 0x00, 0xe5, 0xff, 0x00, 0xdf, 0xff, 0x00, 0xd8,  //  60 (0x3c)
+	0xff, 0x00, 0xd2, 0xff, 0x00, 0xcc, 0xff, 0x00, 0xc5, 0xff, 0x00, 0xbf,  //  64 (0x40)
+	0xff, 0x00, 0xb8, 0xff, 0x00, 0xb2, 0xff, 0x00, 0xac, 0xff, 0x00, 0xa5,  //  68 (0x44)
+	0xff, 0x00, 0x9f, 0xff, 0x00, 0x99, 0xff, 0x00, 0x92, 0xff, 0x00, 0x8c,  //  72 (0x48)
+	0xff, 0x00, 0x85, 0xff, 0x00, 0x7f, 0xff, 0x00, 0x79, 0xff, 0x00, 0x72,  //  76 (0x4c)
+	0xff, 0x00, 0x6c, 0xff, 0x00, 0x66, 0xff, 0x00, 0x5f, 0xff, 0x00, 0x59,  //  80 (0x50)
+	0xff, 0x00, 0x52, 0xff, 0x00, 0x4c, 0xff, 0x00, 0x46, 0xff, 0x00, 0x3f,  //  84 (0x54)
+	0xff, 0x00, 0x39, 0xff, 0x00, 0x33, 0xff, 0x00, 0x2c, 0xff, 0x00, 0x26,  //  88 (0x58)
+	0xff, 0x00, 0x1f, 0xff, 0x00, 0x19, 0xff, 0x00, 0x13, 0xff, 0x00, 0x0c,  //  92 (0x5c)
+	0xff, 0x00, 0x06, 0xff, 0x00, 0x00, 0xff, 0x06, 0x00, 0xff, 0x0c, 0x00,  //  96 (0x60)
+	0xff, 0x13, 0x00, 0xff, 0x19, 0x00, 0xff, 0x1f, 0x00, 0xff, 0x26, 0x00,  // 100 (0x64)
+	0xff, 0x2c, 0x00, 0xff, 0x33, 0x00, 0xff, 0x39, 0x00, 0xff, 0x3f, 0x00,  // 104 (0x68)
+	0xff, 0x46, 0x00, 0xff, 0x4c, 0x00, 0xff, 0x52, 0x00, 0xff, 0x59, 0x00,  // 108 (0x6c)
+	0xff, 0x5f, 0x00, 0xff, 0x66, 0x00, 0xff, 0x6c, 0x00, 0xff, 0x72, 0x00,  // 112 (0x70)
+	0xff, 0x79, 0x00, 0xff, 0x7f, 0x00, 0xff, 0x85, 0x00, 0xff, 0x8c, 0x00,  // 116 (0x74)
+	0xff, 0x92, 0x00, 0xff, 0x99, 0x00, 0xff, 0x9f, 0x00, 0xff, 0xa5, 0x00,  // 120 (0x78)
+	0xff, 0xac, 0x00, 0xff, 0xb2, 0x00, 0xff, 0xb8, 0x00, 0xff, 0xbf, 0x00,  // 124 (0x7c)
+	0xff, 0xc5, 0x00, 0xff, 0xcc, 0x00, 0xff, 0xd2, 0x00, 0xff, 0xd8, 0x00,  // 128 (0x80)
+	0xff, 0xdf, 0x00, 0xff, 0xe5, 0x00, 0xff, 0xeb, 0x00, 0xff, 0xf2, 0x00,  // 132 (0x84)
+	0xff, 0xf8, 0x00, 0xff, 0xff, 0x00, 0xf8, 0xff, 0x00, 0xf2, 0xff, 0x00,  // 136 (0x88)
+	0xeb, 0xff, 0x00, 0xe5, 0xff, 0x00, 0xdf, 0xff, 0x00, 0xd8, 0xff, 0x00,  // 140 (0x8c)
+	0xd2, 0xff, 0x00, 0xcc, 0xff, 0x00, 0xc5, 0xff, 0x00, 0xbf, 0xff, 0x00,  // 144 (0x90)
+	0xb8, 0xff, 0x00, 0xb2, 0xff, 0x00, 0xac, 0xff, 0x00, 0xa5, 0xff, 0x00,  // 148 (0x94)
+	0x9f, 0xff, 0x00, 0x99, 0xff, 0x00, 0x92, 0xff, 0x00, 0x8c, 0xff, 0x00,  // 152 (0x98)
+	0x85, 0xff, 0x00, 0x7f, 0xff, 0x00, 0x79, 0xff, 0x00, 0x72, 0xff, 0x00,  // 156 (0x9c)
+	0x6c, 0xff, 0x00, 0x66, 0xff, 0x00, 0x5f, 0xff, 0x00, 0x59, 0xff, 0x00,  // 160 (0xa0)
+	0x52, 0xff, 0x00, 0x4c, 0xff, 0x00, 0x46, 0xff, 0x00, 0x3f, 0xff, 0x00,  // 164 (0xa4)
+	0x39, 0xff, 0x00, 0x33, 0xff, 0x00, 0x2c, 0xff, 0x00, 0x26, 0xff, 0x00,  // 168 (0xa8)
+	0x1f, 0xff, 0x00, 0x19, 0xff, 0x00, 0x13, 0xff, 0x00, 0x0c, 0xff, 0x00,  // 172 (0xac)
+	0x06, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x06, 0x00, 0xff, 0x0c,  // 176 (0xb0)
+	0x00, 0xff, 0x13, 0x00, 0xff, 0x19, 0x00, 0xff, 0x1f, 0x00, 0xff, 0x26,  // 180 (0xb4)
+	0x00, 0xff, 0x2c, 0x00, 0xff, 0x33, 0x00, 0xff, 0x39, 0x00, 0xff, 0x3f,  // 184 (0xb8)
+	0x00, 0xff, 0x46, 0x00, 0xff, 0x4c, 0x00, 0xff, 0x52, 0x00, 0xff, 0x59,  // 188 (0xbc)
+	0x00, 0xff, 0x5f, 0x00, 0xff, 0x66, 0x00, 0xff, 0x6c, 0x00, 0xff, 0x72,  // 192 (0xc0)
+	0x00, 0xff, 0x79, 0x00, 0xff, 0x7f, 0x00, 0xff, 0x85, 0x00, 0xff, 0x8c,  // 196 (0xc4)
+	0x00, 0xff, 0x92, 0x00, 0xff, 0x99, 0x00, 0xff, 0x9f, 0x00, 0xff, 0xa5,  // 200 (0xc8)
+	0x00, 0xff, 0xac, 0x00, 0xff, 0xb2, 0x00, 0xff, 0xb8, 0x00, 0xff, 0xbf,  // 204 (0xcc)
+	0x00, 0xff, 0xc5, 0x00, 0xff, 0xcc, 0x00, 0xff, 0xd2, 0x00, 0xff, 0xd8,  // 208 (0xd0)
+	0x00, 0xff, 0xdf, 0x00, 0xff, 0xe5, 0x00, 0xff, 0xeb, 0x00, 0xff, 0xf2,  // 212 (0xd4)
+	0x00, 0xff, 0xf8, 0x00, 0xff, 0xff, 0x00, 0xf8, 0xff, 0x00, 0xf2, 0xff,  // 216 (0xd8)
+	0x00, 0xeb, 0xff, 0x00, 0xe5, 0xff, 0x00, 0xdf, 0xff, 0x00, 0xd8, 0xff,  // 220 (0xdc)
+	0x00, 0xd2, 0xff, 0x00, 0xcc, 0xff, 0x00, 0xc5, 0xff, 0x00, 0xbf, 0xff,  // 224 (0xe0)
+	0x00, 0xb8, 0xff, 0x00, 0xb2, 0xff, 0x00, 0xac, 0xff, 0x00, 0xa5, 0xff,  // 228 (0xe4)
+	0x00, 0x9f, 0xff, 0x00, 0x99, 0xff, 0x00, 0x92, 0xff, 0x00, 0x8c, 0xff,  // 232 (0xe8)
+	0x00, 0x85, 0xff, 0x00, 0x7f, 0xff, 0x00, 0x79, 0xff, 0x00, 0x72, 0xff,  // 236 (0xec)
+	0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xe0, 0xd0, 0xd0, 0xd0, 0xc0, 0xc0, 0xc0,  // 240 (0xf0)
+	0xb0, 0xb0, 0xb0, 0xa0, 0xa0, 0xa0, 0x90, 0x90, 0x90, 0x80, 0x80, 0x80,  // 244 (0xf4)
+	0x70, 0x70, 0x70, 0x60, 0x60, 0x60, 0x50, 0x50, 0x50, 0x40, 0x40, 0x40,  // 248 (0xf8)
+	0x30, 0x30, 0x30, 0x20, 0x20, 0x20, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,  // 252 (0xfc)
 };
 
 static byte grayscalePalette[768] = {
-	0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03,  // 0 (0x00)
-	0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07,  // 4 (0x04)
-	0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b, 0x0b,  // 8 (0x08)
-	0x0c, 0x0c, 0x0c, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f, 0x0f,  // 12 (0x0c)
-	0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13,  // 16 (0x10)
-	0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17,  // 20 (0x14)
-	0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a, 0x1b, 0x1b, 0x1b,  // 24 (0x18)
-	0x1c, 0x1c, 0x1c, 0x1d, 0x1d, 0x1d, 0x1e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f,  // 28 (0x1c)
-	0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23, 0x23,  // 32 (0x20)
-	0x24, 0x24, 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, 0x27, 0x27, 0x27,  // 36 (0x24)
-	0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x2a, 0x2a, 0x2a, 0x2b, 0x2b, 0x2b,  // 40 (0x28)
-	0x2c, 0x2c, 0x2c, 0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x2f,  // 44 (0x2c)
-	0x30, 0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32, 0x33, 0x33, 0x33,  // 48 (0x30)
-	0x34, 0x34, 0x34, 0x35, 0x35, 0x35, 0x36, 0x36, 0x36, 0x37, 0x37, 0x37,  // 52 (0x34)
-	0x38, 0x38, 0x38, 0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b, 0x3b,  // 56 (0x38)
-	0x3c, 0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e, 0x3f, 0x3f, 0x3f,  // 60 (0x3c)
-	0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43,  // 64 (0x40)
-	0x44, 0x44, 0x44, 0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47, 0x47,  // 68 (0x44)
-	0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a, 0x4b, 0x4b, 0x4b,  // 72 (0x48)
-	0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, 0x4e, 0x4e, 0x4e, 0x4f, 0x4f, 0x4f,  // 76 (0x4c)
-	0x50, 0x50, 0x50, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53,  // 80 (0x50)
-	0x54, 0x54, 0x54, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x57, 0x57, 0x57,  // 84 (0x54)
-	0x58, 0x58, 0x58, 0x59, 0x59, 0x59, 0x5a, 0x5a, 0x5a, 0x5b, 0x5b, 0x5b,  // 88 (0x58)
-	0x5c, 0x5c, 0x5c, 0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f, 0x5f,  // 92 (0x5c)
-	0x60, 0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62, 0x63, 0x63, 0x63,  // 96 (0x60)
-	0x64, 0x64, 0x64, 0x65, 0x65, 0x65, 0x66, 0x66, 0x66, 0x67, 0x67, 0x67,  // 100 (0x64)
-	0x68, 0x68, 0x68, 0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b, 0x6b,  // 104 (0x68)
-	0x6c, 0x6c, 0x6c, 0x6d, 0x6d, 0x6d, 0x6e, 0x6e, 0x6e, 0x6f, 0x6f, 0x6f,  // 108 (0x6c)
-	0x70, 0x70, 0x70, 0x71, 0x71, 0x71, 0x72, 0x72, 0x72, 0x73, 0x73, 0x73,  // 112 (0x70)
-	0x74, 0x74, 0x74, 0x75, 0x75, 0x75, 0x76, 0x76, 0x76, 0x77, 0x77, 0x77,  // 116 (0x74)
-	0x78, 0x78, 0x78, 0x79, 0x79, 0x79, 0x7a, 0x7a, 0x7a, 0x7b, 0x7b, 0x7b,  // 120 (0x78)
-	0x7c, 0x7c, 0x7c, 0x7d, 0x7d, 0x7d, 0x7e, 0x7e, 0x7e, 0x7f, 0x7f, 0x7f,  // 124 (0x7c)
-	0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x82, 0x82, 0x82, 0x83, 0x83, 0x83,  // 128 (0x80)
-	0x84, 0x84, 0x84, 0x85, 0x85, 0x85, 0x86, 0x86, 0x86, 0x87, 0x87, 0x87,  // 132 (0x84)
-	0x88, 0x88, 0x88, 0x89, 0x89, 0x89, 0x8a, 0x8a, 0x8a, 0x8b, 0x8b, 0x8b,  // 136 (0x88)
-	0x8c, 0x8c, 0x8c, 0x8d, 0x8d, 0x8d, 0x8e, 0x8e, 0x8e, 0x8f, 0x8f, 0x8f,  // 140 (0x8c)
-	0x90, 0x90, 0x90, 0x91, 0x91, 0x91, 0x92, 0x92, 0x92, 0x93, 0x93, 0x93,  // 144 (0x90)
-	0x94, 0x94, 0x94, 0x95, 0x95, 0x95, 0x96, 0x96, 0x96, 0x97, 0x97, 0x97,  // 148 (0x94)
-	0x98, 0x98, 0x98, 0x99, 0x99, 0x99, 0x9a, 0x9a, 0x9a, 0x9b, 0x9b, 0x9b,  // 152 (0x98)
-	0x9c, 0x9c, 0x9c, 0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f, 0x9f,  // 156 (0x9c)
-	0xa0, 0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3,  // 160 (0xa0)
-	0xa4, 0xa4, 0xa4, 0xa5, 0xa5, 0xa5, 0xa6, 0xa6, 0xa6, 0xa7, 0xa7, 0xa7,  // 164 (0xa4)
-	0xa8, 0xa8, 0xa8, 0xa9, 0xa9, 0xa9, 0xaa, 0xaa, 0xaa, 0xab, 0xab, 0xab,  // 168 (0xa8)
-	0xac, 0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae, 0xaf, 0xaf, 0xaf,  // 172 (0xac)
-	0xb0, 0xb0, 0xb0, 0xb1, 0xb1, 0xb1, 0xb2, 0xb2, 0xb2, 0xb3, 0xb3, 0xb3,  // 176 (0xb0)
-	0xb4, 0xb4, 0xb4, 0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7, 0xb7,  // 180 (0xb4)
-	0xb8, 0xb8, 0xb8, 0xb9, 0xb9, 0xb9, 0xba, 0xba, 0xba, 0xbb, 0xbb, 0xbb,  // 184 (0xb8)
-	0xbc, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbe, 0xbf, 0xbf, 0xbf,  // 188 (0xbc)
-	0xc0, 0xc0, 0xc0, 0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3, 0xc3,  // 192 (0xc0)
-	0xc4, 0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6, 0xc7, 0xc7, 0xc7,  // 196 (0xc4)
-	0xc8, 0xc8, 0xc8, 0xc9, 0xc9, 0xc9, 0xca, 0xca, 0xca, 0xcb, 0xcb, 0xcb,  // 200 (0xc8)
-	0xcc, 0xcc, 0xcc, 0xcd, 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xcf, 0xcf,  // 204 (0xcc)
-	0xd0, 0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2, 0xd3, 0xd3, 0xd3,  // 208 (0xd0)
-	0xd4, 0xd4, 0xd4, 0xd5, 0xd5, 0xd5, 0xd6, 0xd6, 0xd6, 0xd7, 0xd7, 0xd7,  // 212 (0xd4)
-	0xd8, 0xd8, 0xd8, 0xd9, 0xd9, 0xd9, 0xda, 0xda, 0xda, 0xdb, 0xdb, 0xdb,  // 216 (0xd8)
-	0xdc, 0xdc, 0xdc, 0xdd, 0xdd, 0xdd, 0xde, 0xde, 0xde, 0xdf, 0xdf, 0xdf,  // 220 (0xdc)
-	0xe0, 0xe0, 0xe0, 0xe1, 0xe1, 0xe1, 0xe2, 0xe2, 0xe2, 0xe3, 0xe3, 0xe3,  // 224 (0xe0)
-	0xe4, 0xe4, 0xe4, 0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7, 0xe7,  // 228 (0xe4)
-	0xe8, 0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea, 0xeb, 0xeb, 0xeb,  // 232 (0xe8)
-	0xec, 0xec, 0xec, 0xed, 0xed, 0xed, 0xee, 0xee, 0xee, 0xef, 0xef, 0xef,  // 236 (0xec)
-	0xf0, 0xf0, 0xf0, 0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3, 0xf3,  // 240 (0xf0)
-	0xf4, 0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6, 0xf7, 0xf7, 0xf7,  // 244 (0xf4)
-	0xf8, 0xf8, 0xf8, 0xf9, 0xf9, 0xf9, 0xfa, 0xfa, 0xfa, 0xfb, 0xfb, 0xfb,  // 248 (0xf8)
-	0xfc, 0xfc, 0xfc, 0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff   // 252 (0xfc)
+	0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfd, 0xfd, 0xfd, 0xfc, 0xfc, 0xfc,  //   0 (0x00)
+	0xfb, 0xfb, 0xfb, 0xfa, 0xfa, 0xfa, 0xf9, 0xf9, 0xf9, 0xf8, 0xf8, 0xf8,  //   4 (0x04)
+	0xf7, 0xf7, 0xf7, 0xf6, 0xf6, 0xf6, 0xf5, 0xf5, 0xf5, 0xf4, 0xf4, 0xf4,  //   8 (0x08)
+	0xf3, 0xf3, 0xf3, 0xf2, 0xf2, 0xf2, 0xf1, 0xf1, 0xf1, 0xf0, 0xf0, 0xf0,  //  12 (0x0c)
+	0xef, 0xef, 0xef, 0xee, 0xee, 0xee, 0xed, 0xed, 0xed, 0xec, 0xec, 0xec,  //  16 (0x10)
+	0xeb, 0xeb, 0xeb, 0xea, 0xea, 0xea, 0xe9, 0xe9, 0xe9, 0xe8, 0xe8, 0xe8,  //  20 (0x14)
+	0xe7, 0xe7, 0xe7, 0xe6, 0xe6, 0xe6, 0xe5, 0xe5, 0xe5, 0xe4, 0xe4, 0xe4,  //  24 (0x18)
+	0xe3, 0xe3, 0xe3, 0xe2, 0xe2, 0xe2, 0xe1, 0xe1, 0xe1, 0xe0, 0xe0, 0xe0,  //  28 (0x1c)
+	0xdf, 0xdf, 0xdf, 0xde, 0xde, 0xde, 0xdd, 0xdd, 0xdd, 0xdc, 0xdc, 0xdc,  //  32 (0x20)
+	0xdb, 0xdb, 0xdb, 0xda, 0xda, 0xda, 0xd9, 0xd9, 0xd9, 0xd8, 0xd8, 0xd8,  //  36 (0x24)
+	0xd7, 0xd7, 0xd7, 0xd6, 0xd6, 0xd6, 0xd5, 0xd5, 0xd5, 0xd4, 0xd4, 0xd4,  //  40 (0x28)
+	0xd3, 0xd3, 0xd3, 0xd2, 0xd2, 0xd2, 0xd1, 0xd1, 0xd1, 0xd0, 0xd0, 0xd0,  //  44 (0x2c)
+	0xcf, 0xcf, 0xcf, 0xce, 0xce, 0xce, 0xcd, 0xcd, 0xcd, 0xcc, 0xcc, 0xcc,  //  48 (0x30)
+	0xcb, 0xcb, 0xcb, 0xca, 0xca, 0xca, 0xc9, 0xc9, 0xc9, 0xc8, 0xc8, 0xc8,  //  52 (0x34)
+	0xc7, 0xc7, 0xc7, 0xc6, 0xc6, 0xc6, 0xc5, 0xc5, 0xc5, 0xc4, 0xc4, 0xc4,  //  56 (0x38)
+	0xc3, 0xc3, 0xc3, 0xc2, 0xc2, 0xc2, 0xc1, 0xc1, 0xc1, 0xc0, 0xc0, 0xc0,  //  60 (0x3c)
+	0xbf, 0xbf, 0xbf, 0xbe, 0xbe, 0xbe, 0xbd, 0xbd, 0xbd, 0xbc, 0xbc, 0xbc,  //  64 (0x40)
+	0xbb, 0xbb, 0xbb, 0xba, 0xba, 0xba, 0xb9, 0xb9, 0xb9, 0xb8, 0xb8, 0xb8,  //  68 (0x44)
+	0xb7, 0xb7, 0xb7, 0xb6, 0xb6, 0xb6, 0xb5, 0xb5, 0xb5, 0xb4, 0xb4, 0xb4,  //  72 (0x48)
+	0xb3, 0xb3, 0xb3, 0xb2, 0xb2, 0xb2, 0xb1, 0xb1, 0xb1, 0xb0, 0xb0, 0xb0,  //  76 (0x4c)
+	0xaf, 0xaf, 0xaf, 0xae, 0xae, 0xae, 0xad, 0xad, 0xad, 0xac, 0xac, 0xac,  //  80 (0x50)
+	0xab, 0xab, 0xab, 0xaa, 0xaa, 0xaa, 0xa9, 0xa9, 0xa9, 0xa8, 0xa8, 0xa8,  //  84 (0x54)
+	0xa7, 0xa7, 0xa7, 0xa6, 0xa6, 0xa6, 0xa5, 0xa5, 0xa5, 0xa4, 0xa4, 0xa4,  //  88 (0x58)
+	0xa3, 0xa3, 0xa3, 0xa2, 0xa2, 0xa2, 0xa1, 0xa1, 0xa1, 0xa0, 0xa0, 0xa0,  //  92 (0x5c)
+	0x9f, 0x9f, 0x9f, 0x9e, 0x9e, 0x9e, 0x9d, 0x9d, 0x9d, 0x9c, 0x9c, 0x9c,  //  96 (0x60)
+	0x9b, 0x9b, 0x9b, 0x9a, 0x9a, 0x9a, 0x99, 0x99, 0x99, 0x98, 0x98, 0x98,  // 100 (0x64)
+	0x97, 0x97, 0x97, 0x96, 0x96, 0x96, 0x95, 0x95, 0x95, 0x94, 0x94, 0x94,  // 104 (0x68)
+	0x93, 0x93, 0x93, 0x92, 0x92, 0x92, 0x91, 0x91, 0x91, 0x90, 0x90, 0x90,  // 108 (0x6c)
+	0x8f, 0x8f, 0x8f, 0x8e, 0x8e, 0x8e, 0x8d, 0x8d, 0x8d, 0x8c, 0x8c, 0x8c,  // 112 (0x70)
+	0x8b, 0x8b, 0x8b, 0x8a, 0x8a, 0x8a, 0x89, 0x89, 0x89, 0x88, 0x88, 0x88,  // 116 (0x74)
+	0x87, 0x87, 0x87, 0x86, 0x86, 0x86, 0x85, 0x85, 0x85, 0x84, 0x84, 0x84,  // 120 (0x78)
+	0x83, 0x83, 0x83, 0x82, 0x82, 0x82, 0x81, 0x81, 0x81, 0x80, 0x80, 0x80,  // 124 (0x7c)
+	0x7f, 0x7f, 0x7f, 0x7e, 0x7e, 0x7e, 0x7d, 0x7d, 0x7d, 0x7c, 0x7c, 0x7c,  // 128 (0x80)
+	0x7b, 0x7b, 0x7b, 0x7a, 0x7a, 0x7a, 0x79, 0x79, 0x79, 0x78, 0x78, 0x78,  // 132 (0x84)
+	0x77, 0x77, 0x77, 0x76, 0x76, 0x76, 0x75, 0x75, 0x75, 0x74, 0x74, 0x74,  // 136 (0x88)
+	0x73, 0x73, 0x73, 0x72, 0x72, 0x72, 0x71, 0x71, 0x71, 0x70, 0x70, 0x70,  // 140 (0x8c)
+	0x6f, 0x6f, 0x6f, 0x6e, 0x6e, 0x6e, 0x6d, 0x6d, 0x6d, 0x6c, 0x6c, 0x6c,  // 144 (0x90)
+	0x6b, 0x6b, 0x6b, 0x6a, 0x6a, 0x6a, 0x69, 0x69, 0x69, 0x68, 0x68, 0x68,  // 148 (0x94)
+	0x67, 0x67, 0x67, 0x66, 0x66, 0x66, 0x65, 0x65, 0x65, 0x64, 0x64, 0x64,  // 152 (0x98)
+	0x63, 0x63, 0x63, 0x62, 0x62, 0x62, 0x61, 0x61, 0x61, 0x60, 0x60, 0x60,  // 156 (0x9c)
+	0x5f, 0x5f, 0x5f, 0x5e, 0x5e, 0x5e, 0x5d, 0x5d, 0x5d, 0x5c, 0x5c, 0x5c,  // 160 (0xa0)
+	0x5b, 0x5b, 0x5b, 0x5a, 0x5a, 0x5a, 0x59, 0x59, 0x59, 0x58, 0x58, 0x58,  // 164 (0xa4)
+	0x57, 0x57, 0x57, 0x56, 0x56, 0x56, 0x55, 0x55, 0x55, 0x54, 0x54, 0x54,  // 168 (0xa8)
+	0x53, 0x53, 0x53, 0x52, 0x52, 0x52, 0x51, 0x51, 0x51, 0x50, 0x50, 0x50,  // 172 (0xac)
+	0x4f, 0x4f, 0x4f, 0x4e, 0x4e, 0x4e, 0x4d, 0x4d, 0x4d, 0x4c, 0x4c, 0x4c,  // 176 (0xb0)
+	0x4b, 0x4b, 0x4b, 0x4a, 0x4a, 0x4a, 0x49, 0x49, 0x49, 0x48, 0x48, 0x48,  // 180 (0xb4)
+	0x47, 0x47, 0x47, 0x46, 0x46, 0x46, 0x45, 0x45, 0x45, 0x44, 0x44, 0x44,  // 184 (0xb8)
+	0x43, 0x43, 0x43, 0x42, 0x42, 0x42, 0x41, 0x41, 0x41, 0x40, 0x40, 0x40,  // 188 (0xbc)
+	0x3f, 0x3f, 0x3f, 0x3e, 0x3e, 0x3e, 0x3d, 0x3d, 0x3d, 0x3c, 0x3c, 0x3c,  // 192 (0xc0)
+	0x3b, 0x3b, 0x3b, 0x3a, 0x3a, 0x3a, 0x39, 0x39, 0x39, 0x38, 0x38, 0x38,  // 196 (0xc4)
+	0x37, 0x37, 0x37, 0x36, 0x36, 0x36, 0x35, 0x35, 0x35, 0x34, 0x34, 0x34,  // 200 (0xc8)
+	0x33, 0x33, 0x33, 0x32, 0x32, 0x32, 0x31, 0x31, 0x31, 0x30, 0x30, 0x30,  // 204 (0xcc)
+	0x2f, 0x2f, 0x2f, 0x2e, 0x2e, 0x2e, 0x2d, 0x2d, 0x2d, 0x2c, 0x2c, 0x2c,  // 208 (0xd0)
+	0x2b, 0x2b, 0x2b, 0x2a, 0x2a, 0x2a, 0x29, 0x29, 0x29, 0x28, 0x28, 0x28,  // 212 (0xd4)
+	0x27, 0x27, 0x27, 0x26, 0x26, 0x26, 0x25, 0x25, 0x25, 0x24, 0x24, 0x24,  // 216 (0xd8)
+	0x23, 0x23, 0x23, 0x22, 0x22, 0x22, 0x21, 0x21, 0x21, 0x20, 0x20, 0x20,  // 220 (0xdc)
+	0x1f, 0x1f, 0x1f, 0x1e, 0x1e, 0x1e, 0x1d, 0x1d, 0x1d, 0x1c, 0x1c, 0x1c,  // 224 (0xe0)
+	0x1b, 0x1b, 0x1b, 0x1a, 0x1a, 0x1a, 0x19, 0x19, 0x19, 0x18, 0x18, 0x18,  // 228 (0xe4)
+	0x17, 0x17, 0x17, 0x16, 0x16, 0x16, 0x15, 0x15, 0x15, 0x14, 0x14, 0x14,  // 232 (0xe8)
+	0x13, 0x13, 0x13, 0x12, 0x12, 0x12, 0x11, 0x11, 0x11, 0x10, 0x10, 0x10,  // 236 (0xec)
+	0x0f, 0x0f, 0x0f, 0x0e, 0x0e, 0x0e, 0x0d, 0x0d, 0x0d, 0x0c, 0x0c, 0x0c,  // 240 (0xf0)
+	0x0b, 0x0b, 0x0b, 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08,  // 244 (0xf4)
+	0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04,  // 248 (0xf8)
+	0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,  // 252 (0xfc)
 };
 
 static byte pastelsPalette[768] = {
-	0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x20, 0x20, 0x20, 0x30, 0x30, 0x30,  // 0 (0x00)
-	0x40, 0x40, 0x40, 0x50, 0x50, 0x50, 0x60, 0x60, 0x60, 0x70, 0x70, 0x70,  // 4 (0x04)
-	0x80, 0x80, 0x80, 0x90, 0x90, 0x90, 0xa0, 0xa0, 0xa0, 0xb0, 0xb0, 0xb0,  // 8 (0x08)
-	0xc0, 0xc0, 0xc0, 0xd0, 0xd0, 0xd0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0,  // 12 (0x0c)
-	0xe4, 0xe4, 0xee, 0xd9, 0xd9, 0xed, 0xcd, 0xcd, 0xec, 0xc2, 0xc2, 0xeb,  // 16 (0x10)
-	0xb6, 0xb6, 0xea, 0xab, 0xab, 0xe9, 0x9f, 0x9f, 0xe8, 0x94, 0x94, 0xe7,  // 20 (0x14)
-	0x88, 0x88, 0xe6, 0x7d, 0x7d, 0xe5, 0x71, 0x71, 0xe4, 0x66, 0x66, 0xe3,  // 24 (0x18)
-	0x5a, 0x5a, 0xe2, 0x4f, 0x4f, 0xe1, 0x44, 0x44, 0xe0, 0x50, 0x45, 0xdc,  // 28 (0x1c)
-	0x5c, 0x45, 0xd8, 0x68, 0x46, 0xd4, 0x74, 0x46, 0xd0, 0x7f, 0x46, 0xcc,  // 32 (0x20)
-	0x8b, 0x47, 0xc8, 0x97, 0x47, 0xc4, 0xa3, 0x48, 0xc1, 0xaf, 0x48, 0xbd,  // 36 (0x24)
-	0xba, 0x48, 0xb9, 0xc6, 0x49, 0xb5, 0xd2, 0x49, 0xb1, 0xde, 0x4a, 0xad,  // 40 (0x28)
-	0xea, 0x4a, 0xa9, 0xf6, 0x4b, 0xa6, 0xf4, 0x4b, 0x9f, 0xf3, 0x4b, 0x99,  // 44 (0x2c)
-	0xf2, 0x4b, 0x93, 0xf1, 0x4b, 0x8d, 0xf0, 0x4b, 0x87, 0xef, 0x4b, 0x81,  // 48 (0x30)
-	0xee, 0x4b, 0x7b, 0xec, 0x4b, 0x74, 0xeb, 0x4b, 0x6e, 0xea, 0x4b, 0x68,  // 52 (0x34)
-	0xe9, 0x4b, 0x62, 0xe8, 0x4b, 0x5c, 0xe7, 0x4b, 0x56, 0xe6, 0x4b, 0x50,  // 56 (0x38)
-	0xe5, 0x4b, 0x4a, 0xe7, 0x57, 0x49, 0xe9, 0x62, 0x49, 0xea, 0x6d, 0x49,  // 60 (0x3c)
-	0xec, 0x79, 0x49, 0xed, 0x84, 0x49, 0xef, 0x8f, 0x49, 0xf0, 0x9b, 0x49,  // 64 (0x40)
-	0xf2, 0xa6, 0x49, 0xf3, 0xb1, 0x49, 0xf5, 0xbd, 0x49, 0xf6, 0xc8, 0x49,  // 68 (0x44)
-	0xf8, 0xd3, 0x49, 0xf9, 0xdf, 0x49, 0xfb, 0xea, 0x49, 0xfd, 0xf6, 0x49,  // 72 (0x48)
-	0xf4, 0xec, 0x48, 0xec, 0xe2, 0x48, 0xe4, 0xd9, 0x48, 0xdc, 0xcf, 0x48,  // 76 (0x4c)
-	0xd4, 0xc5, 0x48, 0xcc, 0xbc, 0x48, 0xc4, 0xb2, 0x48, 0xbc, 0xa8, 0x48,  // 80 (0x50)
-	0xb4, 0x9f, 0x48, 0xac, 0x95, 0x48, 0xa4, 0x8b, 0x48, 0x9c, 0x82, 0x48,  // 84 (0x54)
-	0x94, 0x78, 0x48, 0x8c, 0x6e, 0x48, 0x84, 0x65, 0x48, 0x7f, 0x68, 0x49,  // 88 (0x58)
-	0x7b, 0x6b, 0x4a, 0x77, 0x6e, 0x4a, 0x72, 0x70, 0x4b, 0x6e, 0x73, 0x4b,  // 92 (0x5c)
-	0x6a, 0x76, 0x4c, 0x66, 0x79, 0x4c, 0x61, 0x7b, 0x4d, 0x5d, 0x7e, 0x4d,  // 96 (0x60)
-	0x59, 0x81, 0x4e, 0x55, 0x84, 0x4e, 0x50, 0x86, 0x4f, 0x4c, 0x89, 0x4f,  // 100 (0x64)
-	0x48, 0x8c, 0x50, 0x44, 0x8f, 0x51, 0x46, 0x93, 0x52, 0x48, 0x97, 0x52,  // 104 (0x68)
-	0x49, 0x9b, 0x52, 0x4b, 0x9f, 0x52, 0x4c, 0xa3, 0x52, 0x4e, 0xa7, 0x52,  // 108 (0x6c)
-	0x4f, 0xab, 0x52, 0x51, 0xaf, 0x52, 0x52, 0xb3, 0x52, 0x54, 0xb7, 0x52,  // 112 (0x70)
-	0x55, 0xbb, 0x52, 0x57, 0xbf, 0x52, 0x58, 0xc3, 0x52, 0x5a, 0xc7, 0x52,  // 116 (0x74)
-	0x5c, 0xcb, 0x53, 0x5a, 0xca, 0x5e, 0x59, 0xc9, 0x68, 0x57, 0xc9, 0x73,  // 120 (0x78)
-	0x56, 0xc8, 0x7d, 0x55, 0xc8, 0x87, 0x53, 0xc7, 0x92, 0x52, 0xc6, 0x9c,  // 124 (0x7c)
-	0x50, 0xc6, 0xa7, 0x4f, 0xc5, 0xb1, 0x4e, 0xc5, 0xbb, 0x4c, 0xc4, 0xc6,  // 128 (0x80)
-	0x4b, 0xc3, 0xd0, 0x49, 0xc3, 0xdb, 0x48, 0xc2, 0xe5, 0x47, 0xc2, 0xf0,  // 132 (0x84)
-	0x46, 0xb9, 0xee, 0x46, 0xb1, 0xed, 0x46, 0xa9, 0xec, 0x46, 0xa0, 0xeb,  // 136 (0x88)
-	0x46, 0x98, 0xea, 0x45, 0x90, 0xe9, 0x45, 0x87, 0xe8, 0x45, 0x7f, 0xe7,  // 140 (0x8c)
-	0x45, 0x77, 0xe6, 0x45, 0x6e, 0xe5, 0x44, 0x66, 0xe4, 0x44, 0x5e, 0xe3,  // 144 (0x90)
-	0x44, 0x55, 0xe2, 0x44, 0x4d, 0xe1, 0x44, 0x45, 0xe0, 0x48, 0x44, 0xdd,  // 148 (0x94)
-	0x4b, 0x44, 0xdb, 0x4f, 0x44, 0xd9, 0x52, 0x44, 0xd6, 0x55, 0x44, 0xd4,  // 152 (0x98)
-	0x59, 0x44, 0xd2, 0x5c, 0x44, 0xcf, 0x60, 0x44, 0xcd, 0x63, 0x44, 0xcb,  // 156 (0x9c)
-	0x66, 0x44, 0xc8, 0x6a, 0x44, 0xc6, 0x6d, 0x44, 0xc4, 0x71, 0x44, 0xc1,  // 160 (0xa0)
-	0x74, 0x44, 0xbf, 0x78, 0x44, 0xbd, 0x81, 0x45, 0xbb, 0x89, 0x45, 0xb9,  // 164 (0xa4)
-	0x91, 0x46, 0xb8, 0x9a, 0x46, 0xb6, 0xa2, 0x46, 0xb5, 0xaa, 0x47, 0xb3,  // 168 (0xa8)
-	0xb3, 0x47, 0xb2, 0xbb, 0x48, 0xb0, 0xc3, 0x48, 0xaf, 0xcc, 0x48, 0xad,  // 172 (0xac)
-	0xd4, 0x49, 0xac, 0xdc, 0x49, 0xaa, 0xe5, 0x4a, 0xa9, 0xed, 0x4a, 0xa7,  // 176 (0xb0)
-	0xf6, 0x4b, 0xa6, 0xf2, 0x49, 0x9f, 0xee, 0x47, 0x98, 0xea, 0x45, 0x91,  // 180 (0xb4)
-	0xe6, 0x43, 0x8b, 0xe2, 0x41, 0x84, 0xde, 0x3f, 0x7d, 0xda, 0x3d, 0x76,  // 184 (0xb8)
-	0xd6, 0x3b, 0x70, 0xd2, 0x39, 0x69, 0xce, 0x37, 0x62, 0xca, 0x35, 0x5b,  // 188 (0xbc)
-	0xc6, 0x33, 0x55, 0xc2, 0x31, 0x4e, 0xbe, 0x2f, 0x47, 0xba, 0x2d, 0x41,  // 192 (0xc0)
-	0xbd, 0x2f, 0x42, 0xc0, 0x31, 0x43, 0xc3, 0x33, 0x43, 0xc6, 0x35, 0x44,  // 196 (0xc4)
-	0xc8, 0x37, 0x44, 0xcb, 0x39, 0x45, 0xce, 0x3b, 0x45, 0xd1, 0x3d, 0x46,  // 200 (0xc8)
-	0xd4, 0x3f, 0x46, 0xd6, 0x41, 0x47, 0xd9, 0x43, 0x47, 0xdc, 0x45, 0x48,  // 204 (0xcc)
-	0xdf, 0x47, 0x48, 0xe2, 0x49, 0x49, 0xe5, 0x4b, 0x4a, 0xe7, 0x50, 0x49,  // 208 (0xd0)
-	0xe9, 0x54, 0x49, 0xea, 0x58, 0x49, 0xec, 0x5d, 0x48, 0xee, 0x61, 0x48,  // 212 (0xd4)
-	0xef, 0x65, 0x48, 0xf1, 0x6a, 0x48, 0xf3, 0x6e, 0x47, 0xf4, 0x72, 0x47,  // 216 (0xd8)
-	0xf6, 0x77, 0x47, 0xf8, 0x7b, 0x47, 0xf9, 0x7f, 0x46, 0xfb, 0x84, 0x46,  // 220 (0xdc)
-	0xfd, 0x88, 0x46, 0xff, 0x8d, 0x46, 0xfe, 0x94, 0x47, 0xfe, 0x9b, 0x47,  // 224 (0xe0)
-	0xfe, 0xa2, 0x47, 0xfe, 0xa9, 0x47, 0xfe, 0xb0, 0x47, 0xfd, 0xb7, 0x47,  // 228 (0xe4)
-	0xfd, 0xbe, 0x47, 0xfd, 0xc4, 0x47, 0xfd, 0xcb, 0x47, 0xfd, 0xd2, 0x47,  // 232 (0xe8)
-	0xfc, 0xd9, 0x47, 0xfc, 0xe0, 0x47, 0xfc, 0xe7, 0x47, 0xfc, 0xee, 0x47,  // 236 (0xec)
-	0xfc, 0xf5, 0x48, 0xfd, 0xf6, 0x55, 0xfd, 0xf7, 0x61, 0xfd, 0xf7, 0x6d,  // 240 (0xf0)
-	0xfd, 0xf8, 0x79, 0xfd, 0xf8, 0x85, 0xfd, 0xf9, 0x91, 0xfd, 0xfa, 0x9d,  // 244 (0xf4)
-	0xfe, 0xfa, 0xaa, 0xfe, 0xfb, 0xb6, 0xfe, 0xfb, 0xc2, 0xfe, 0xfc, 0xce,  // 248 (0xf8)
-	0xfe, 0xfd, 0xda, 0xfe, 0xfd, 0xe6, 0xfe, 0xfe, 0xf2, 0xff, 0xff, 0xff   // 252 (0xfc)
+	0xff, 0xff, 0xff, 0xfe, 0xfe, 0xf2, 0xfe, 0xfd, 0xe6, 0xfe, 0xfd, 0xda,  //   0 (0x00)
+	0xfe, 0xfc, 0xce, 0xfe, 0xfb, 0xc2, 0xfe, 0xfb, 0xb6, 0xfe, 0xfa, 0xaa,  //   4 (0x04)
+	0xfd, 0xfa, 0x9d, 0xfd, 0xf9, 0x91, 0xfd, 0xf8, 0x85, 0xfd, 0xf8, 0x79,  //   8 (0x08)
+	0xfd, 0xf7, 0x6d, 0xfd, 0xf7, 0x61, 0xfd, 0xf6, 0x55, 0xfc, 0xf5, 0x48,  //  12 (0x0c)
+	0xfc, 0xee, 0x47, 0xfc, 0xe7, 0x47, 0xfc, 0xe0, 0x47, 0xfc, 0xd9, 0x47,  //  16 (0x10)
+	0xfd, 0xd2, 0x47, 0xfd, 0xcb, 0x47, 0xfd, 0xc4, 0x47, 0xfd, 0xbe, 0x47,  //  20 (0x14)
+	0xfd, 0xb7, 0x47, 0xfe, 0xb0, 0x47, 0xfe, 0xa9, 0x47, 0xfe, 0xa2, 0x47,  //  24 (0x18)
+	0xfe, 0x9b, 0x47, 0xfe, 0x94, 0x47, 0xff, 0x8d, 0x46, 0xfd, 0x88, 0x46,  //  28 (0x1c)
+	0xfb, 0x84, 0x46, 0xf9, 0x7f, 0x46, 0xf8, 0x7b, 0x47, 0xf6, 0x77, 0x47,  //  32 (0x20)
+	0xf4, 0x72, 0x47, 0xf3, 0x6e, 0x47, 0xf1, 0x6a, 0x48, 0xef, 0x65, 0x48,  //  36 (0x24)
+	0xee, 0x61, 0x48, 0xec, 0x5d, 0x48, 0xea, 0x58, 0x49, 0xe9, 0x54, 0x49,  //  40 (0x28)
+	0xe7, 0x50, 0x49, 0xe5, 0x4b, 0x4a, 0xe2, 0x49, 0x49, 0xdf, 0x47, 0x48,  //  44 (0x2c)
+	0xdc, 0x45, 0x48, 0xd9, 0x43, 0x47, 0xd6, 0x41, 0x47, 0xd4, 0x3f, 0x46,  //  48 (0x30)
+	0xd1, 0x3d, 0x46, 0xce, 0x3b, 0x45, 0xcb, 0x39, 0x45, 0xc8, 0x37, 0x44,  //  52 (0x34)
+	0xc6, 0x35, 0x44, 0xc3, 0x33, 0x43, 0xc0, 0x31, 0x43, 0xbd, 0x2f, 0x42,  //  56 (0x38)
+	0xba, 0x2d, 0x41, 0xbe, 0x2f, 0x47, 0xc2, 0x31, 0x4e, 0xc6, 0x33, 0x55,  //  60 (0x3c)
+	0xca, 0x35, 0x5b, 0xce, 0x37, 0x62, 0xd2, 0x39, 0x69, 0xd6, 0x3b, 0x70,  //  64 (0x40)
+	0xda, 0x3d, 0x76, 0xde, 0x3f, 0x7d, 0xe2, 0x41, 0x84, 0xe6, 0x43, 0x8b,  //  68 (0x44)
+	0xea, 0x45, 0x91, 0xee, 0x47, 0x98, 0xf2, 0x49, 0x9f, 0xf6, 0x4b, 0xa6,  //  72 (0x48)
+	0xed, 0x4a, 0xa7, 0xe5, 0x4a, 0xa9, 0xdc, 0x49, 0xaa, 0xd4, 0x49, 0xac,  //  76 (0x4c)
+	0xcc, 0x48, 0xad, 0xc3, 0x48, 0xaf, 0xbb, 0x48, 0xb0, 0xb3, 0x47, 0xb2,  //  80 (0x50)
+	0xaa, 0x47, 0xb3, 0xa2, 0x46, 0xb5, 0x9a, 0x46, 0xb6, 0x91, 0x46, 0xb8,  //  84 (0x54)
+	0x89, 0x45, 0xb9, 0x81, 0x45, 0xbb, 0x78, 0x44, 0xbd, 0x74, 0x44, 0xbf,  //  88 (0x58)
+	0x71, 0x44, 0xc1, 0x6d, 0x44, 0xc4, 0x6a, 0x44, 0xc6, 0x66, 0x44, 0xc8,  //  92 (0x5c)
+	0x63, 0x44, 0xcb, 0x60, 0x44, 0xcd, 0x5c, 0x44, 0xcf, 0x59, 0x44, 0xd2,  //  96 (0x60)
+	0x55, 0x44, 0xd4, 0x52, 0x44, 0xd6, 0x4f, 0x44, 0xd9, 0x4b, 0x44, 0xdb,  // 100 (0x64)
+	0x48, 0x44, 0xdd, 0x44, 0x45, 0xe0, 0x44, 0x4d, 0xe1, 0x44, 0x55, 0xe2,  // 104 (0x68)
+	0x44, 0x5e, 0xe3, 0x44, 0x66, 0xe4, 0x45, 0x6e, 0xe5, 0x45, 0x77, 0xe6,  // 108 (0x6c)
+	0x45, 0x7f, 0xe7, 0x45, 0x87, 0xe8, 0x45, 0x90, 0xe9, 0x46, 0x98, 0xea,  // 112 (0x70)
+	0x46, 0xa0, 0xeb, 0x46, 0xa9, 0xec, 0x46, 0xb1, 0xed, 0x46, 0xb9, 0xee,  // 116 (0x74)
+	0x47, 0xc2, 0xf0, 0x48, 0xc2, 0xe5, 0x49, 0xc3, 0xdb, 0x4b, 0xc3, 0xd0,  // 120 (0x78)
+	0x4c, 0xc4, 0xc6, 0x4e, 0xc5, 0xbb, 0x4f, 0xc5, 0xb1, 0x50, 0xc6, 0xa7,  // 124 (0x7c)
+	0x52, 0xc6, 0x9c, 0x53, 0xc7, 0x92, 0x55, 0xc8, 0x87, 0x56, 0xc8, 0x7d,  // 128 (0x80)
+	0x57, 0xc9, 0x73, 0x59, 0xc9, 0x68, 0x5a, 0xca, 0x5e, 0x5c, 0xcb, 0x53,  // 132 (0x84)
+	0x5a, 0xc7, 0x52, 0x58, 0xc3, 0x52, 0x57, 0xbf, 0x52, 0x55, 0xbb, 0x52,  // 136 (0x88)
+	0x54, 0xb7, 0x52, 0x52, 0xb3, 0x52, 0x51, 0xaf, 0x52, 0x4f, 0xab, 0x52,  // 140 (0x8c)
+	0x4e, 0xa7, 0x52, 0x4c, 0xa3, 0x52, 0x4b, 0x9f, 0x52, 0x49, 0x9b, 0x52,  // 144 (0x90)
+	0x48, 0x97, 0x52, 0x46, 0x93, 0x52, 0x44, 0x8f, 0x51, 0x48, 0x8c, 0x50,  // 148 (0x94)
+	0x4c, 0x89, 0x4f, 0x50, 0x86, 0x4f, 0x55, 0x84, 0x4e, 0x59, 0x81, 0x4e,  // 152 (0x98)
+	0x5d, 0x7e, 0x4d, 0x61, 0x7b, 0x4d, 0x66, 0x79, 0x4c, 0x6a, 0x76, 0x4c,  // 156 (0x9c)
+	0x6e, 0x73, 0x4b, 0x72, 0x70, 0x4b, 0x77, 0x6e, 0x4a, 0x7b, 0x6b, 0x4a,  // 160 (0xa0)
+	0x7f, 0x68, 0x49, 0x84, 0x65, 0x48, 0x8c, 0x6e, 0x48, 0x94, 0x78, 0x48,  // 164 (0xa4)
+	0x9c, 0x82, 0x48, 0xa4, 0x8b, 0x48, 0xac, 0x95, 0x48, 0xb4, 0x9f, 0x48,  // 168 (0xa8)
+	0xbc, 0xa8, 0x48, 0xc4, 0xb2, 0x48, 0xcc, 0xbc, 0x48, 0xd4, 0xc5, 0x48,  // 172 (0xac)
+	0xdc, 0xcf, 0x48, 0xe4, 0xd9, 0x48, 0xec, 0xe2, 0x48, 0xf4, 0xec, 0x48,  // 176 (0xb0)
+	0xfd, 0xf6, 0x49, 0xfb, 0xea, 0x49, 0xf9, 0xdf, 0x49, 0xf8, 0xd3, 0x49,  // 180 (0xb4)
+	0xf6, 0xc8, 0x49, 0xf5, 0xbd, 0x49, 0xf3, 0xb1, 0x49, 0xf2, 0xa6, 0x49,  // 184 (0xb8)
+	0xf0, 0x9b, 0x49, 0xef, 0x8f, 0x49, 0xed, 0x84, 0x49, 0xec, 0x79, 0x49,  // 188 (0xbc)
+	0xea, 0x6d, 0x49, 0xe9, 0x62, 0x49, 0xe7, 0x57, 0x49, 0xe5, 0x4b, 0x4a,  // 192 (0xc0)
+	0xe6, 0x4b, 0x50, 0xe7, 0x4b, 0x56, 0xe8, 0x4b, 0x5c, 0xe9, 0x4b, 0x62,  // 196 (0xc4)
+	0xea, 0x4b, 0x68, 0xeb, 0x4b, 0x6e, 0xec, 0x4b, 0x74, 0xee, 0x4b, 0x7b,  // 200 (0xc8)
+	0xef, 0x4b, 0x81, 0xf0, 0x4b, 0x87, 0xf1, 0x4b, 0x8d, 0xf2, 0x4b, 0x93,  // 204 (0xcc)
+	0xf3, 0x4b, 0x99, 0xf4, 0x4b, 0x9f, 0xf6, 0x4b, 0xa6, 0xea, 0x4a, 0xa9,  // 208 (0xd0)
+	0xde, 0x4a, 0xad, 0xd2, 0x49, 0xb1, 0xc6, 0x49, 0xb5, 0xba, 0x48, 0xb9,  // 212 (0xd4)
+	0xaf, 0x48, 0xbd, 0xa3, 0x48, 0xc1, 0x97, 0x47, 0xc4, 0x8b, 0x47, 0xc8,  // 216 (0xd8)
+	0x7f, 0x46, 0xcc, 0x74, 0x46, 0xd0, 0x68, 0x46, 0xd4, 0x5c, 0x45, 0xd8,  // 220 (0xdc)
+	0x50, 0x45, 0xdc, 0x44, 0x44, 0xe0, 0x4f, 0x4f, 0xe1, 0x5a, 0x5a, 0xe2,  // 224 (0xe0)
+	0x66, 0x66, 0xe3, 0x71, 0x71, 0xe4, 0x7d, 0x7d, 0xe5, 0x88, 0x88, 0xe6,  // 228 (0xe4)
+	0x94, 0x94, 0xe7, 0x9f, 0x9f, 0xe8, 0xab, 0xab, 0xe9, 0xb6, 0xb6, 0xea,  // 232 (0xe8)
+	0xc2, 0xc2, 0xeb, 0xcd, 0xcd, 0xec, 0xd9, 0xd9, 0xed, 0xe4, 0xe4, 0xee,  // 236 (0xec)
+	0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xe0, 0xd0, 0xd0, 0xd0, 0xc0, 0xc0, 0xc0,  // 240 (0xf0)
+	0xb0, 0xb0, 0xb0, 0xa0, 0xa0, 0xa0, 0x90, 0x90, 0x90, 0x80, 0x80, 0x80,  // 244 (0xf4)
+	0x70, 0x70, 0x70, 0x60, 0x60, 0x60, 0x50, 0x50, 0x50, 0x40, 0x40, 0x40,  // 248 (0xf8)
+	0x30, 0x30, 0x30, 0x20, 0x20, 0x20, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,  // 252 (0xfc)
 };
 
 static byte vividPalette[768] = {
-	0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x20, 0x20, 0x20, 0x30, 0x30, 0x30,  // 0 (0x00)
-	0x40, 0x40, 0x40, 0x50, 0x50, 0x50, 0x60, 0x60, 0x60, 0x70, 0x70, 0x70,  // 4 (0x04)
-	0x80, 0x80, 0x80, 0x90, 0x90, 0x90, 0xa0, 0xa0, 0xa0, 0xb0, 0xb0, 0xb0,  // 8 (0x08)
-	0xc0, 0xc0, 0xc0, 0xd0, 0xd0, 0xd0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0,  // 12 (0x0c)
-	0xe0, 0xe0, 0xee, 0xd0, 0xd0, 0xec, 0xc0, 0xc0, 0xea, 0xb0, 0xb0, 0xe8,  // 16 (0x10)
-	0xa0, 0xa0, 0xe6, 0x90, 0x90, 0xe4, 0x80, 0x80, 0xe2, 0x70, 0x70, 0xe1,  // 20 (0x14)
-	0x60, 0x60, 0xdf, 0x50, 0x50, 0xdd, 0x40, 0x40, 0xdb, 0x30, 0x30, 0xd9,  // 24 (0x18)
-	0x20, 0x20, 0xd7, 0x10, 0x10, 0xd5, 0x00, 0x00, 0xd4, 0x10, 0x00, 0xce,  // 28 (0x1c)
-	0x20, 0x01, 0xc9, 0x30, 0x01, 0xc4, 0x40, 0x02, 0xbe, 0x50, 0x02, 0xb9,  // 32 (0x20)
-	0x60, 0x03, 0xb4, 0x70, 0x03, 0xae, 0x81, 0x04, 0xa9, 0x91, 0x04, 0xa4,  // 36 (0x24)
-	0xa1, 0x05, 0x9e, 0xb1, 0x05, 0x99, 0xc1, 0x06, 0x94, 0xd1, 0x06, 0x8e,  // 40 (0x28)
-	0xe1, 0x07, 0x89, 0xf2, 0x08, 0x84, 0xf0, 0x07, 0x7b, 0xef, 0x07, 0x73,  // 44 (0x2c)
-	0xed, 0x07, 0x6a, 0xec, 0x07, 0x62, 0xea, 0x07, 0x5a, 0xe9, 0x07, 0x51,  // 48 (0x30)
-	0xe7, 0x07, 0x49, 0xe6, 0x07, 0x40, 0xe4, 0x07, 0x38, 0xe3, 0x07, 0x30,  // 52 (0x34)
-	0xe1, 0x07, 0x27, 0xe0, 0x07, 0x1f, 0xde, 0x07, 0x16, 0xdd, 0x07, 0x0e,  // 56 (0x38)
-	0xdc, 0x07, 0x06, 0xdf, 0x17, 0x05, 0xe1, 0x27, 0x05, 0xe3, 0x36, 0x05,  // 60 (0x3c)
-	0xe5, 0x46, 0x05, 0xe7, 0x56, 0x05, 0xe9, 0x65, 0x05, 0xeb, 0x75, 0x05,  // 64 (0x40)
-	0xed, 0x85, 0x05, 0xef, 0x94, 0x05, 0xf1, 0xa4, 0x05, 0xf3, 0xb4, 0x05,  // 68 (0x44)
-	0xf5, 0xc3, 0x05, 0xf7, 0xd3, 0x05, 0xf9, 0xe3, 0x05, 0xfc, 0xf3, 0x05,  // 72 (0x48)
-	0xf0, 0xe5, 0x04, 0xe5, 0xd8, 0x04, 0xda, 0xcb, 0x04, 0xcf, 0xbd, 0x04,  // 76 (0x4c)
-	0xc4, 0xb0, 0x04, 0xb9, 0xa3, 0x04, 0xae, 0x95, 0x04, 0xa3, 0x88, 0x04,  // 80 (0x50)
-	0x98, 0x7b, 0x04, 0x8d, 0x6d, 0x04, 0x82, 0x60, 0x04, 0x77, 0x53, 0x04,  // 84 (0x54)
-	0x6c, 0x45, 0x04, 0x61, 0x38, 0x04, 0x56, 0x2b, 0x04, 0x50, 0x2f, 0x05,  // 88 (0x58)
-	0x4a, 0x33, 0x06, 0x44, 0x36, 0x07, 0x3f, 0x3a, 0x07, 0x39, 0x3e, 0x08,  // 92 (0x5c)
-	0x33, 0x41, 0x09, 0x2d, 0x45, 0x0a, 0x28, 0x49, 0x0a, 0x22, 0x4c, 0x0b,  // 96 (0x60)
-	0x1c, 0x50, 0x0c, 0x16, 0x54, 0x0d, 0x11, 0x57, 0x0d, 0x0b, 0x5b, 0x0e,  // 100 (0x64)
-	0x05, 0x5f, 0x0f, 0x00, 0x63, 0x10, 0x02, 0x69, 0x11, 0x04, 0x6f, 0x11,  // 104 (0x68)
-	0x06, 0x74, 0x11, 0x08, 0x7a, 0x11, 0x0a, 0x7f, 0x11, 0x0c, 0x85, 0x11,  // 108 (0x6c)
-	0x0e, 0x8a, 0x11, 0x10, 0x90, 0x12, 0x12, 0x95, 0x12, 0x14, 0x9b, 0x12,  // 112 (0x70)
-	0x16, 0xa0, 0x12, 0x18, 0xa6, 0x12, 0x1a, 0xab, 0x12, 0x1c, 0xb1, 0x12,  // 116 (0x74)
-	0x1f, 0xb7, 0x13, 0x1d, 0xb6, 0x22, 0x1b, 0xb5, 0x30, 0x19, 0xb4, 0x3e,  // 120 (0x78)
-	0x17, 0xb3, 0x4d, 0x15, 0xb3, 0x5b, 0x13, 0xb2, 0x69, 0x11, 0xb1, 0x77,  // 124 (0x7c)
-	0x0f, 0xb0, 0x86, 0x0d, 0xaf, 0x94, 0x0b, 0xaf, 0xa2, 0x09, 0xae, 0xb0,  // 128 (0x80)
-	0x07, 0xad, 0xbf, 0x05, 0xac, 0xcd, 0x03, 0xab, 0xdb, 0x02, 0xab, 0xea,  // 132 (0x84)
-	0x01, 0x9f, 0xe8, 0x01, 0x94, 0xe7, 0x01, 0x88, 0xe5, 0x01, 0x7d, 0xe4,  // 136 (0x88)
-	0x01, 0x72, 0xe2, 0x01, 0x66, 0xe1, 0x01, 0x5b, 0xdf, 0x00, 0x4f, 0xde,  // 140 (0x8c)
-	0x00, 0x44, 0xdc, 0x00, 0x39, 0xdb, 0x00, 0x2d, 0xd9, 0x00, 0x22, 0xd8,  // 144 (0x90)
-	0x00, 0x16, 0xd6, 0x00, 0x0b, 0xd5, 0x00, 0x00, 0xd4, 0x04, 0x00, 0xd0,  // 148 (0x94)
-	0x09, 0x00, 0xcd, 0x0d, 0x00, 0xca, 0x12, 0x00, 0xc7, 0x16, 0x00, 0xc4,  // 152 (0x98)
-	0x1b, 0x00, 0xc1, 0x20, 0x00, 0xbe, 0x24, 0x00, 0xba, 0x29, 0x00, 0xb7,  // 156 (0x9c)
-	0x2d, 0x00, 0xb4, 0x32, 0x00, 0xb1, 0x37, 0x00, 0xae, 0x3b, 0x00, 0xab,  // 160 (0xa0)
-	0x40, 0x00, 0xa8, 0x45, 0x00, 0xa5, 0x51, 0x00, 0xa2, 0x5c, 0x01, 0xa0,  // 164 (0xa4)
-	0x68, 0x01, 0x9e, 0x73, 0x02, 0x9c, 0x7f, 0x02, 0x9a, 0x8a, 0x03, 0x97,  // 168 (0xa8)
-	0x96, 0x03, 0x95, 0xa1, 0x04, 0x93, 0xad, 0x04, 0x91, 0xb8, 0x05, 0x8f,  // 172 (0xac)
-	0xc4, 0x05, 0x8c, 0xcf, 0x06, 0x8a, 0xdb, 0x06, 0x88, 0xe6, 0x07, 0x86,  // 176 (0xb0)
-	0xf2, 0x08, 0x84, 0xed, 0x07, 0x7c, 0xe8, 0x06, 0x75, 0xe3, 0x06, 0x6e,  // 180 (0xb4)
-	0xde, 0x05, 0x67, 0xda, 0x05, 0x60, 0xd5, 0x04, 0x58, 0xd0, 0x04, 0x51,  // 184 (0xb8)
-	0xcb, 0x03, 0x4a, 0xc6, 0x03, 0x43, 0xc2, 0x02, 0x3c, 0xbd, 0x02, 0x34,  // 188 (0xbc)
-	0xb8, 0x01, 0x2d, 0xb3, 0x01, 0x26, 0xae, 0x00, 0x1f, 0xaa, 0x00, 0x18,  // 192 (0xc0)
-	0xae, 0x00, 0x16, 0xb1, 0x00, 0x15, 0xb4, 0x01, 0x14, 0xb8, 0x01, 0x13,  // 196 (0xc4)
-	0xbb, 0x02, 0x12, 0xbe, 0x02, 0x10, 0xc1, 0x03, 0x0f, 0xc5, 0x03, 0x0e,  // 200 (0xc8)
-	0xc8, 0x04, 0x0d, 0xcb, 0x04, 0x0c, 0xce, 0x05, 0x0a, 0xd2, 0x05, 0x09,  // 204 (0xcc)
-	0xd5, 0x06, 0x08, 0xd8, 0x06, 0x07, 0xdc, 0x07, 0x06, 0xdf, 0x0e, 0x05,  // 208 (0xd0)
-	0xe1, 0x14, 0x05, 0xe3, 0x1a, 0x05, 0xe6, 0x20, 0x04, 0xe8, 0x26, 0x04,  // 212 (0xd4)
-	0xea, 0x2c, 0x04, 0xec, 0x32, 0x03, 0xef, 0x38, 0x03, 0xf1, 0x3e, 0x03,  // 216 (0xd8)
-	0xf3, 0x44, 0x02, 0xf5, 0x4a, 0x02, 0xf8, 0x50, 0x02, 0xfa, 0x56, 0x01,  // 220 (0xdc)
-	0xfc, 0x5c, 0x01, 0xff, 0x63, 0x01, 0xfe, 0x6d, 0x02, 0xfe, 0x76, 0x02,  // 224 (0xe0)
-	0xfe, 0x80, 0x02, 0xfd, 0x89, 0x02, 0xfd, 0x93, 0x02, 0xfd, 0x9c, 0x02,  // 228 (0xe4)
-	0xfd, 0xa6, 0x02, 0xfc, 0xaf, 0x03, 0xfc, 0xb9, 0x03, 0xfc, 0xc2, 0x03,  // 232 (0xe8)
-	0xfc, 0xcc, 0x03, 0xfb, 0xd5, 0x03, 0xfb, 0xdf, 0x03, 0xfb, 0xe8, 0x03,  // 236 (0xec)
-	0xfb, 0xf2, 0x04, 0xfc, 0xf3, 0x15, 0xfc, 0xf4, 0x26, 0xfc, 0xf5, 0x36,  // 240 (0xf0)
-	0xfc, 0xf6, 0x47, 0xfc, 0xf6, 0x58, 0xfd, 0xf7, 0x68, 0xfd, 0xf8, 0x79,  // 244 (0xf4)
-	0xfd, 0xf9, 0x8a, 0xfd, 0xfa, 0x9a, 0xfd, 0xfa, 0xab, 0xfe, 0xfb, 0xbc,  // 248 (0xf8)
-	0xfe, 0xfc, 0xcc, 0xfe, 0xfd, 0xdd, 0xfe, 0xfe, 0xee, 0xff, 0xff, 0xff   // 252 (0xfc)
+	0xff, 0xff, 0xff, 0xfe, 0xfe, 0xee, 0xfe, 0xfd, 0xdd, 0xfe, 0xfc, 0xcc,  //   0 (0x00)
+	0xfe, 0xfb, 0xbc, 0xfd, 0xfa, 0xab, 0xfd, 0xfa, 0x9a, 0xfd, 0xf9, 0x8a,  //   4 (0x04)
+	0xfd, 0xf8, 0x79, 0xfd, 0xf7, 0x68, 0xfc, 0xf6, 0x58, 0xfc, 0xf6, 0x47,  //   8 (0x08)
+	0xfc, 0xf5, 0x36, 0xfc, 0xf4, 0x26, 0xfc, 0xf3, 0x15, 0xfb, 0xf2, 0x04,  //  12 (0x0c)
+	0xfb, 0xe8, 0x03, 0xfb, 0xdf, 0x03, 0xfb, 0xd5, 0x03, 0xfc, 0xcc, 0x03,  //  16 (0x10)
+	0xfc, 0xc2, 0x03, 0xfc, 0xb9, 0x03, 0xfc, 0xaf, 0x03, 0xfd, 0xa6, 0x02,  //  20 (0x14)
+	0xfd, 0x9c, 0x02, 0xfd, 0x93, 0x02, 0xfd, 0x89, 0x02, 0xfe, 0x80, 0x02,  //  24 (0x18)
+	0xfe, 0x76, 0x02, 0xfe, 0x6d, 0x02, 0xff, 0x63, 0x01, 0xfc, 0x5c, 0x01,  //  28 (0x1c)
+	0xfa, 0x56, 0x01, 0xf8, 0x50, 0x02, 0xf5, 0x4a, 0x02, 0xf3, 0x44, 0x02,  //  32 (0x20)
+	0xf1, 0x3e, 0x03, 0xef, 0x38, 0x03, 0xec, 0x32, 0x03, 0xea, 0x2c, 0x04,  //  36 (0x24)
+	0xe8, 0x26, 0x04, 0xe6, 0x20, 0x04, 0xe3, 0x1a, 0x05, 0xe1, 0x14, 0x05,  //  40 (0x28)
+	0xdf, 0x0e, 0x05, 0xdc, 0x07, 0x06, 0xd8, 0x06, 0x07, 0xd5, 0x06, 0x08,  //  44 (0x2c)
+	0xd2, 0x05, 0x09, 0xce, 0x05, 0x0a, 0xcb, 0x04, 0x0c, 0xc8, 0x04, 0x0d,  //  48 (0x30)
+	0xc5, 0x03, 0x0e, 0xc1, 0x03, 0x0f, 0xbe, 0x02, 0x10, 0xbb, 0x02, 0x12,  //  52 (0x34)
+	0xb8, 0x01, 0x13, 0xb4, 0x01, 0x14, 0xb1, 0x00, 0x15, 0xae, 0x00, 0x16,  //  56 (0x38)
+	0xaa, 0x00, 0x18, 0xae, 0x00, 0x1f, 0xb3, 0x01, 0x26, 0xb8, 0x01, 0x2d,  //  60 (0x3c)
+	0xbd, 0x02, 0x34, 0xc2, 0x02, 0x3c, 0xc6, 0x03, 0x43, 0xcb, 0x03, 0x4a,  //  64 (0x40)
+	0xd0, 0x04, 0x51, 0xd5, 0x04, 0x58, 0xda, 0x05, 0x60, 0xde, 0x05, 0x67,  //  68 (0x44)
+	0xe3, 0x06, 0x6e, 0xe8, 0x06, 0x75, 0xed, 0x07, 0x7c, 0xf2, 0x08, 0x84,  //  72 (0x48)
+	0xe6, 0x07, 0x86, 0xdb, 0x06, 0x88, 0xcf, 0x06, 0x8a, 0xc4, 0x05, 0x8c,  //  76 (0x4c)
+	0xb8, 0x05, 0x8f, 0xad, 0x04, 0x91, 0xa1, 0x04, 0x93, 0x96, 0x03, 0x95,  //  80 (0x50)
+	0x8a, 0x03, 0x97, 0x7f, 0x02, 0x9a, 0x73, 0x02, 0x9c, 0x68, 0x01, 0x9e,  //  84 (0x54)
+	0x5c, 0x01, 0xa0, 0x51, 0x00, 0xa2, 0x45, 0x00, 0xa5, 0x40, 0x00, 0xa8,  //  88 (0x58)
+	0x3b, 0x00, 0xab, 0x37, 0x00, 0xae, 0x32, 0x00, 0xb1, 0x2d, 0x00, 0xb4,  //  92 (0x5c)
+	0x29, 0x00, 0xb7, 0x24, 0x00, 0xba, 0x20, 0x00, 0xbe, 0x1b, 0x00, 0xc1,  //  96 (0x60)
+	0x16, 0x00, 0xc4, 0x12, 0x00, 0xc7, 0x0d, 0x00, 0xca, 0x09, 0x00, 0xcd,  // 100 (0x64)
+	0x04, 0x00, 0xd0, 0x00, 0x00, 0xd4, 0x00, 0x0b, 0xd5, 0x00, 0x16, 0xd6,  // 104 (0x68)
+	0x00, 0x22, 0xd8, 0x00, 0x2d, 0xd9, 0x00, 0x39, 0xdb, 0x00, 0x44, 0xdc,  // 108 (0x6c)
+	0x00, 0x4f, 0xde, 0x01, 0x5b, 0xdf, 0x01, 0x66, 0xe1, 0x01, 0x72, 0xe2,  // 112 (0x70)
+	0x01, 0x7d, 0xe4, 0x01, 0x88, 0xe5, 0x01, 0x94, 0xe7, 0x01, 0x9f, 0xe8,  // 116 (0x74)
+	0x02, 0xab, 0xea, 0x03, 0xab, 0xdb, 0x05, 0xac, 0xcd, 0x07, 0xad, 0xbf,  // 120 (0x78)
+	0x09, 0xae, 0xb0, 0x0b, 0xaf, 0xa2, 0x0d, 0xaf, 0x94, 0x0f, 0xb0, 0x86,  // 124 (0x7c)
+	0x11, 0xb1, 0x77, 0x13, 0xb2, 0x69, 0x15, 0xb3, 0x5b, 0x17, 0xb3, 0x4d,  // 128 (0x80)
+	0x19, 0xb4, 0x3e, 0x1b, 0xb5, 0x30, 0x1d, 0xb6, 0x22, 0x1f, 0xb7, 0x13,  // 132 (0x84)
+	0x1c, 0xb1, 0x12, 0x1a, 0xab, 0x12, 0x18, 0xa6, 0x12, 0x16, 0xa0, 0x12,  // 136 (0x88)
+	0x14, 0x9b, 0x12, 0x12, 0x95, 0x12, 0x10, 0x90, 0x12, 0x0e, 0x8a, 0x11,  // 140 (0x8c)
+	0x0c, 0x85, 0x11, 0x0a, 0x7f, 0x11, 0x08, 0x7a, 0x11, 0x06, 0x74, 0x11,  // 144 (0x90)
+	0x04, 0x6f, 0x11, 0x02, 0x69, 0x11, 0x00, 0x63, 0x10, 0x05, 0x5f, 0x0f,  // 148 (0x94)
+	0x0b, 0x5b, 0x0e, 0x11, 0x57, 0x0d, 0x16, 0x54, 0x0d, 0x1c, 0x50, 0x0c,  // 152 (0x98)
+	0x22, 0x4c, 0x0b, 0x28, 0x49, 0x0a, 0x2d, 0x45, 0x0a, 0x33, 0x41, 0x09,  // 156 (0x9c)
+	0x39, 0x3e, 0x08, 0x3f, 0x3a, 0x07, 0x44, 0x36, 0x07, 0x4a, 0x33, 0x06,  // 160 (0xa0)
+	0x50, 0x2f, 0x05, 0x56, 0x2b, 0x04, 0x61, 0x38, 0x04, 0x6c, 0x45, 0x04,  // 164 (0xa4)
+	0x77, 0x53, 0x04, 0x82, 0x60, 0x04, 0x8d, 0x6d, 0x04, 0x98, 0x7b, 0x04,  // 168 (0xa8)
+	0xa3, 0x88, 0x04, 0xae, 0x95, 0x04, 0xb9, 0xa3, 0x04, 0xc4, 0xb0, 0x04,  // 172 (0xac)
+	0xcf, 0xbd, 0x04, 0xda, 0xcb, 0x04, 0xe5, 0xd8, 0x04, 0xf0, 0xe5, 0x04,  // 176 (0xb0)
+	0xfc, 0xf3, 0x05, 0xf9, 0xe3, 0x05, 0xf7, 0xd3, 0x05, 0xf5, 0xc3, 0x05,  // 180 (0xb4)
+	0xf3, 0xb4, 0x05, 0xf1, 0xa4, 0x05, 0xef, 0x94, 0x05, 0xed, 0x85, 0x05,  // 184 (0xb8)
+	0xeb, 0x75, 0x05, 0xe9, 0x65, 0x05, 0xe7, 0x56, 0x05, 0xe5, 0x46, 0x05,  // 188 (0xbc)
+	0xe3, 0x36, 0x05, 0xe1, 0x27, 0x05, 0xdf, 0x17, 0x05, 0xdc, 0x07, 0x06,  // 192 (0xc0)
+	0xdd, 0x07, 0x0e, 0xde, 0x07, 0x16, 0xe0, 0x07, 0x1f, 0xe1, 0x07, 0x27,  // 196 (0xc4)
+	0xe3, 0x07, 0x30, 0xe4, 0x07, 0x38, 0xe6, 0x07, 0x40, 0xe7, 0x07, 0x49,  // 200 (0xc8)
+	0xe9, 0x07, 0x51, 0xea, 0x07, 0x5a, 0xec, 0x07, 0x62, 0xed, 0x07, 0x6a,  // 204 (0xcc)
+	0xef, 0x07, 0x73, 0xf0, 0x07, 0x7b, 0xf2, 0x08, 0x84, 0xe1, 0x07, 0x89,  // 208 (0xd0)
+	0xd1, 0x06, 0x8e, 0xc1, 0x06, 0x94, 0xb1, 0x05, 0x99, 0xa1, 0x05, 0x9e,  // 212 (0xd4)
+	0x91, 0x04, 0xa4, 0x81, 0x04, 0xa9, 0x70, 0x03, 0xae, 0x60, 0x03, 0xb4,  // 216 (0xd8)
+	0x50, 0x02, 0xb9, 0x40, 0x02, 0xbe, 0x30, 0x01, 0xc4, 0x20, 0x01, 0xc9,  // 220 (0xdc)
+	0x10, 0x00, 0xce, 0x00, 0x00, 0xd4, 0x10, 0x10, 0xd5, 0x20, 0x20, 0xd7,  // 224 (0xe0)
+	0x30, 0x30, 0xd9, 0x40, 0x40, 0xdb, 0x50, 0x50, 0xdd, 0x60, 0x60, 0xdf,  // 228 (0xe4)
+	0x70, 0x70, 0xe1, 0x80, 0x80, 0xe2, 0x90, 0x90, 0xe4, 0xa0, 0xa0, 0xe6,  // 232 (0xe8)
+	0xb0, 0xb0, 0xe8, 0xc0, 0xc0, 0xea, 0xd0, 0xd0, 0xec, 0xe0, 0xe0, 0xee,  // 236 (0xec)
+	0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xe0, 0xd0, 0xd0, 0xd0, 0xc0, 0xc0, 0xc0,  // 240 (0xf0)
+	0xb0, 0xb0, 0xb0, 0xa0, 0xa0, 0xa0, 0x90, 0x90, 0x90, 0x80, 0x80, 0x80,  // 244 (0xf4)
+	0x70, 0x70, 0x70, 0x60, 0x60, 0x60, 0x50, 0x50, 0x50, 0x40, 0x40, 0x40,  // 248 (0xf8)
+	0x30, 0x30, 0x30, 0x20, 0x20, 0x20, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,  // 252 (0xfc)
 };
 
 static byte ntscPalette[768] = {
-	0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x20, 0x20, 0x20, 0x30, 0x30, 0x30,  // 0 (0x00)
-	0x40, 0x40, 0x40, 0x50, 0x50, 0x50, 0x60, 0x60, 0x60, 0x70, 0x70, 0x70,  // 4 (0x04)
-	0x80, 0x80, 0x80, 0x90, 0x90, 0x90, 0xa0, 0xa0, 0xa0, 0xb0, 0xb0, 0xb0,  // 8 (0x08)
-	0xc0, 0xc0, 0xc0, 0xd0, 0xd0, 0xd0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0,  // 12 (0x0c)
-	0xe0, 0xe3, 0xef, 0xd1, 0xd7, 0xee, 0xc2, 0xca, 0xed, 0xb3, 0xbe, 0xec,  // 16 (0x10)
-	0xa4, 0xb2, 0xec, 0x95, 0xa5, 0xeb, 0x86, 0x99, 0xea, 0x77, 0x8c, 0xe9,  // 20 (0x14)
-	0x68, 0x80, 0xe9, 0x59, 0x74, 0xe8, 0x4a, 0x67, 0xe7, 0x3b, 0x5b, 0xe6,  // 24 (0x18)
-	0x2c, 0x4f, 0xe6, 0x1d, 0x42, 0xe5, 0x0f, 0x36, 0xe4, 0x00, 0x29, 0xe3,  // 28 (0x1c)
-	0x00, 0x27, 0xd9, 0x00, 0x25, 0xcc, 0x00, 0x23, 0xbf, 0x00, 0x20, 0xb2,  // 32 (0x20)
-	0x00, 0x1e, 0xa5, 0x00, 0x1c, 0x98, 0x00, 0x19, 0x8b, 0x00, 0x17, 0x7e,  // 36 (0x24)
-	0x00, 0x14, 0x71, 0x00, 0x12, 0x64, 0x00, 0x10, 0x57, 0x00, 0x0d, 0x4a,  // 40 (0x28)
-	0x00, 0x0b, 0x3d, 0x00, 0x08, 0x30, 0x00, 0x06, 0x23, 0x00, 0x04, 0x16,  // 44 (0x2c)
-	0x06, 0x00, 0x0c, 0x0e, 0x01, 0x1a, 0x15, 0x02, 0x27, 0x1c, 0x03, 0x35,  // 48 (0x30)
-	0x24, 0x04, 0x42, 0x2b, 0x05, 0x50, 0x32, 0x06, 0x5d, 0x3a, 0x07, 0x6b,  // 52 (0x34)
-	0x41, 0x08, 0x78, 0x49, 0x09, 0x86, 0x50, 0x0a, 0x93, 0x57, 0x0b, 0xa1,  // 56 (0x38)
-	0x5f, 0x0c, 0xae, 0x66, 0x0d, 0xbc, 0x6d, 0x0e, 0xc9, 0x75, 0x0f, 0xd7,  // 60 (0x3c)
-	0x78, 0x19, 0xd7, 0x7d, 0x23, 0xd8, 0x83, 0x2d, 0xda, 0x88, 0x36, 0xdc,  // 64 (0x40)
-	0x8d, 0x40, 0xdd, 0x93, 0x4a, 0xdf, 0x98, 0x53, 0xe1, 0x9e, 0x5d, 0xe3,  // 68 (0x44)
-	0xa3, 0x67, 0xe4, 0xa8, 0x70, 0xe6, 0xae, 0x7a, 0xe8, 0xb3, 0x84, 0xe9,  // 72 (0x48)
-	0xb9, 0x8d, 0xeb, 0xbe, 0x97, 0xed, 0xc3, 0xa1, 0xef, 0xc9, 0xaa, 0xf0,  // 76 (0x4c)
-	0xe7, 0xad, 0xc3, 0xe3, 0xa1, 0xb8, 0xdf, 0x95, 0xad, 0xdb, 0x8a, 0xa2,  // 80 (0x50)
-	0xd7, 0x7e, 0x97, 0xd4, 0x73, 0x8c, 0xd0, 0x67, 0x81, 0xcc, 0x5c, 0x76,  // 84 (0x54)
-	0xc8, 0x50, 0x6b, 0xc4, 0x45, 0x60, 0xc1, 0x39, 0x55, 0xbd, 0x2e, 0x4a,  // 88 (0x58)
-	0xb9, 0x22, 0x3f, 0xb5, 0x17, 0x35, 0xb1, 0x0b, 0x2a, 0xa2, 0x16, 0x2f,  // 92 (0x5c)
-	0xa2, 0x16, 0x2f, 0x96, 0x14, 0x2b, 0x8b, 0x13, 0x28, 0x7f, 0x11, 0x25,  // 96 (0x60)
-	0x73, 0x0f, 0x21, 0x68, 0x0e, 0x1e, 0x5c, 0x0c, 0x1a, 0x51, 0x0b, 0x17,  // 100 (0x64)
-	0x45, 0x09, 0x14, 0x39, 0x07, 0x10, 0x2e, 0x06, 0x0d, 0x22, 0x04, 0x0a,  // 104 (0x68)
-	0x17, 0x03, 0x06, 0x17, 0x00, 0x04, 0x0b, 0x00, 0x02, 0x00, 0x00, 0x00,  // 108 (0x6c)
-	0x00, 0x00, 0x00, 0x0e, 0x05, 0x01, 0x1d, 0x09, 0x03, 0x2b, 0x0e, 0x05,  // 112 (0x70)
-	0x3a, 0x13, 0x07, 0x48, 0x18, 0x09, 0x57, 0x1d, 0x0b, 0x65, 0x22, 0x0c,  // 116 (0x74)
-	0x74, 0x27, 0x0e, 0x82, 0x2c, 0x10, 0x91, 0x31, 0x12, 0x9f, 0x36, 0x14,  // 120 (0x78)
-	0xae, 0x3b, 0x16, 0xbc, 0x40, 0x17, 0xcb, 0x45, 0x19, 0xd9, 0x4a, 0x1b,  // 124 (0x7c)
-	0xd9, 0x4e, 0x20, 0xd9, 0x54, 0x29, 0xd9, 0x5b, 0x31, 0xd9, 0x61, 0x3a,  // 128 (0x80)
-	0xd9, 0x68, 0x42, 0xd9, 0x6e, 0x4b, 0xd9, 0x75, 0x53, 0xd9, 0x7b, 0x5c,  // 132 (0x84)
-	0xd9, 0x82, 0x65, 0xd9, 0x88, 0x6d, 0xd9, 0x8f, 0x76, 0xd9, 0x95, 0x7e,  // 136 (0x88)
-	0xd9, 0x9c, 0x87, 0xd9, 0xa2, 0x8f, 0xd9, 0xa9, 0x98, 0xd9, 0xaf, 0xa1,  // 140 (0x8c)
-	0xf5, 0xee, 0x90, 0xf2, 0xeb, 0x87, 0xef, 0xe8, 0x7f, 0xeb, 0xe5, 0x76,  // 144 (0x90)
-	0xe8, 0xe2, 0x6d, 0xe5, 0xdf, 0x64, 0xe2, 0xdc, 0x5b, 0xdf, 0xd9, 0x52,  // 148 (0x94)
-	0xdb, 0xd6, 0x4a, 0xd8, 0xd3, 0x41, 0xd5, 0xd0, 0x38, 0xd2, 0xcd, 0x2f,  // 152 (0x98)
-	0xcf, 0xca, 0x26, 0xcb, 0xc7, 0x1d, 0xc8, 0xc4, 0x15, 0xc5, 0xc0, 0x0c,  // 156 (0x9c)
-	0xbf, 0xbb, 0x0b, 0xb3, 0xaf, 0x0b, 0xa7, 0xa3, 0x0a, 0x9b, 0x97, 0x09,  // 160 (0xa0)
-	0x8f, 0x8b, 0x08, 0x83, 0x80, 0x08, 0x77, 0x74, 0x07, 0x6a, 0x68, 0x06,  // 164 (0xa4)
-	0x5e, 0x5c, 0x05, 0x52, 0x50, 0x05, 0x46, 0x44, 0x04, 0x3a, 0x39, 0x03,  // 168 (0xa8)
-	0x2e, 0x2d, 0x02, 0x22, 0x21, 0x02, 0x16, 0x15, 0x01, 0x0a, 0x09, 0x00,  // 172 (0xac)
-	0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x28, 0x00,  // 176 (0xb0)
-	0x00, 0x35, 0x00, 0x00, 0x42, 0x00, 0x00, 0x50, 0x00, 0x00, 0x5d, 0x00,  // 180 (0xb4)
-	0x00, 0x6b, 0x00, 0x00, 0x78, 0x00, 0x00, 0x85, 0x01, 0x00, 0x93, 0x01,  // 184 (0xb8)
-	0x00, 0xa0, 0x01, 0x00, 0xae, 0x01, 0x00, 0xbb, 0x01, 0x01, 0xc8, 0x01,  // 188 (0xbc)
-	0x01, 0xda, 0x01, 0x0c, 0xdc, 0x0e, 0x18, 0xdd, 0x1a, 0x24, 0xdf, 0x26,  // 192 (0xc0)
-	0x30, 0xe0, 0x32, 0x3b, 0xe2, 0x3f, 0x47, 0xe4, 0x4b, 0x53, 0xe5, 0x57,  // 196 (0xc4)
-	0x5f, 0xe7, 0x63, 0x6b, 0xe8, 0x70, 0x76, 0xea, 0x7c, 0x82, 0xec, 0x88,  // 200 (0xc8)
-	0x8e, 0xed, 0x94, 0x9a, 0xef, 0xa1, 0xa5, 0xf0, 0xad, 0xb1, 0xf2, 0xb9,  // 204 (0xcc)
-	0xb3, 0xd1, 0xd5, 0xa9, 0xd0, 0xd5, 0x9f, 0xcf, 0xd5, 0x95, 0xce, 0xd5,  // 208 (0xd0)
-	0x8b, 0xcd, 0xd5, 0x81, 0xcc, 0xd5, 0x77, 0xcb, 0xd5, 0x6d, 0xca, 0xd5,  // 212 (0xd4)
-	0x63, 0xc9, 0xd5, 0x59, 0xc8, 0xd5, 0x4f, 0xc7, 0xd5, 0x45, 0xc6, 0xd5,  // 216 (0xd8)
-	0x3b, 0xc5, 0xd5, 0x30, 0xc4, 0xd5, 0x26, 0xc3, 0xd5, 0x1c, 0xc2, 0xd5,  // 220 (0xdc)
-	0x30, 0x4b, 0xc2, 0x29, 0x52, 0xa3, 0x21, 0x58, 0x84, 0x19, 0x5b, 0x65,  // 224 (0xe0)
-	0x1b, 0x6c, 0x55, 0x21, 0x83, 0x49, 0x27, 0x9a, 0x3c, 0x2d, 0xb1, 0x2d,  // 228 (0xe4)
-	0x46, 0xb7, 0x2f, 0x60, 0xbd, 0x31, 0x79, 0xc3, 0x33, 0x93, 0xc8, 0x35,  // 232 (0xe8)
-	0xac, 0xce, 0x37, 0xc6, 0xd4, 0x38, 0xe3, 0xdd, 0x3c, 0xdc, 0xc9, 0x3b,  // 236 (0xec)
-	0xd5, 0xb5, 0x3a, 0xcf, 0xa1, 0x39, 0xc8, 0x8d, 0x37, 0xc1, 0x7a, 0x36,  // 240 (0xf0)
-	0xba, 0x66, 0x35, 0xb4, 0x53, 0x33, 0xb0, 0x4f, 0x37, 0xac, 0x4b, 0x3a,  // 244 (0xf4)
-	0xa9, 0x47, 0x3e, 0xa5, 0x43, 0x41, 0xa1, 0x3d, 0x42, 0x9a, 0x30, 0x44,  // 248 (0xf8)
-	0x7b, 0x28, 0x52, 0x5d, 0x21, 0x5f, 0x59, 0x2b, 0x85, 0xff, 0xff, 0xff   // 252 (0xfc)
+	0xff, 0xff, 0xff, 0x59, 0x2b, 0x85, 0x5d, 0x21, 0x5f, 0x7b, 0x28, 0x52,  //   0 (0x00)
+	0x9a, 0x30, 0x44, 0xa1, 0x3d, 0x42, 0xa5, 0x43, 0x41, 0xa9, 0x47, 0x3e,  //   4 (0x04)
+	0xac, 0x4b, 0x3a, 0xb0, 0x4f, 0x37, 0xb4, 0x53, 0x33, 0xba, 0x66, 0x35,  //   8 (0x08)
+	0xc1, 0x7a, 0x36, 0xc8, 0x8d, 0x37, 0xcf, 0xa1, 0x39, 0xd5, 0xb5, 0x3a,  //  12 (0x0c)
+	0xdc, 0xc9, 0x3b, 0xe3, 0xdd, 0x3c, 0xc6, 0xd4, 0x38, 0xac, 0xce, 0x37,  //  16 (0x10)
+	0x93, 0xc8, 0x35, 0x79, 0xc3, 0x33, 0x60, 0xbd, 0x31, 0x46, 0xb7, 0x2f,  //  20 (0x14)
+	0x2d, 0xb1, 0x2d, 0x27, 0x9a, 0x3c, 0x21, 0x83, 0x49, 0x1b, 0x6c, 0x55,  //  24 (0x18)
+	0x19, 0x5b, 0x65, 0x21, 0x58, 0x84, 0x29, 0x52, 0xa3, 0x30, 0x4b, 0xc2,  //  28 (0x1c)
+	0x1c, 0xc2, 0xd5, 0x26, 0xc3, 0xd5, 0x30, 0xc4, 0xd5, 0x3b, 0xc5, 0xd5,  //  32 (0x20)
+	0x45, 0xc6, 0xd5, 0x4f, 0xc7, 0xd5, 0x59, 0xc8, 0xd5, 0x63, 0xc9, 0xd5,  //  36 (0x24)
+	0x6d, 0xca, 0xd5, 0x77, 0xcb, 0xd5, 0x81, 0xcc, 0xd5, 0x8b, 0xcd, 0xd5,  //  40 (0x28)
+	0x95, 0xce, 0xd5, 0x9f, 0xcf, 0xd5, 0xa9, 0xd0, 0xd5, 0xb3, 0xd1, 0xd5,  //  44 (0x2c)
+	0xb1, 0xf2, 0xb9, 0xa5, 0xf0, 0xad, 0x9a, 0xef, 0xa1, 0x8e, 0xed, 0x94,  //  48 (0x30)
+	0x82, 0xec, 0x88, 0x76, 0xea, 0x7c, 0x6b, 0xe8, 0x70, 0x5f, 0xe7, 0x63,  //  52 (0x34)
+	0x53, 0xe5, 0x57, 0x47, 0xe4, 0x4b, 0x3b, 0xe2, 0x3f, 0x30, 0xe0, 0x32,  //  56 (0x38)
+	0x24, 0xdf, 0x26, 0x18, 0xdd, 0x1a, 0x0c, 0xdc, 0x0e, 0x01, 0xda, 0x01,  //  60 (0x3c)
+	0x01, 0xc8, 0x01, 0x00, 0xbb, 0x01, 0x00, 0xae, 0x01, 0x00, 0xa0, 0x01,  //  64 (0x40)
+	0x00, 0x93, 0x01, 0x00, 0x85, 0x01, 0x00, 0x78, 0x00, 0x00, 0x6b, 0x00,  //  68 (0x44)
+	0x00, 0x5d, 0x00, 0x00, 0x50, 0x00, 0x00, 0x42, 0x00, 0x00, 0x35, 0x00,  //  72 (0x48)
+	0x00, 0x28, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00,  //  76 (0x4c)
+	0x0a, 0x09, 0x00, 0x16, 0x15, 0x01, 0x22, 0x21, 0x02, 0x2e, 0x2d, 0x02,  //  80 (0x50)
+	0x3a, 0x39, 0x03, 0x46, 0x44, 0x04, 0x52, 0x50, 0x05, 0x5e, 0x5c, 0x05,  //  84 (0x54)
+	0x6a, 0x68, 0x06, 0x77, 0x74, 0x07, 0x83, 0x80, 0x08, 0x8f, 0x8b, 0x08,  //  88 (0x58)
+	0x9b, 0x97, 0x09, 0xa7, 0xa3, 0x0a, 0xb3, 0xaf, 0x0b, 0xbf, 0xbb, 0x0b,  //  92 (0x5c)
+	0xc5, 0xc0, 0x0c, 0xc8, 0xc4, 0x15, 0xcb, 0xc7, 0x1d, 0xcf, 0xca, 0x26,  //  96 (0x60)
+	0xd2, 0xcd, 0x2f, 0xd5, 0xd0, 0x38, 0xd8, 0xd3, 0x41, 0xdb, 0xd6, 0x4a,  // 100 (0x64)
+	0xdf, 0xd9, 0x52, 0xe2, 0xdc, 0x5b, 0xe5, 0xdf, 0x64, 0xe8, 0xe2, 0x6d,  // 104 (0x68)
+	0xeb, 0xe5, 0x76, 0xef, 0xe8, 0x7f, 0xf2, 0xeb, 0x87, 0xf5, 0xee, 0x90,  // 108 (0x6c)
+	0xd9, 0xaf, 0xa1, 0xd9, 0xa9, 0x98, 0xd9, 0xa2, 0x8f, 0xd9, 0x9c, 0x87,  // 112 (0x70)
+	0xd9, 0x95, 0x7e, 0xd9, 0x8f, 0x76, 0xd9, 0x88, 0x6d, 0xd9, 0x82, 0x65,  // 116 (0x74)
+	0xd9, 0x7b, 0x5c, 0xd9, 0x75, 0x53, 0xd9, 0x6e, 0x4b, 0xd9, 0x68, 0x42,  // 120 (0x78)
+	0xd9, 0x61, 0x3a, 0xd9, 0x5b, 0x31, 0xd9, 0x54, 0x29, 0xd9, 0x4e, 0x20,  // 124 (0x7c)
+	0xd9, 0x4a, 0x1b, 0xcb, 0x45, 0x19, 0xbc, 0x40, 0x17, 0xae, 0x3b, 0x16,  // 128 (0x80)
+	0x9f, 0x36, 0x14, 0x91, 0x31, 0x12, 0x82, 0x2c, 0x10, 0x74, 0x27, 0x0e,  // 132 (0x84)
+	0x65, 0x22, 0x0c, 0x57, 0x1d, 0x0b, 0x48, 0x18, 0x09, 0x3a, 0x13, 0x07,  // 136 (0x88)
+	0x2b, 0x0e, 0x05, 0x1d, 0x09, 0x03, 0x0e, 0x05, 0x01, 0x00, 0x00, 0x00,  // 140 (0x8c)
+	0x00, 0x00, 0x00, 0x0b, 0x00, 0x02, 0x17, 0x00, 0x04, 0x17, 0x03, 0x06,  // 144 (0x90)
+	0x22, 0x04, 0x0a, 0x2e, 0x06, 0x0d, 0x39, 0x07, 0x10, 0x45, 0x09, 0x14,  // 148 (0x94)
+	0x51, 0x0b, 0x17, 0x5c, 0x0c, 0x1a, 0x68, 0x0e, 0x1e, 0x73, 0x0f, 0x21,  // 152 (0x98)
+	0x7f, 0x11, 0x25, 0x8b, 0x13, 0x28, 0x96, 0x14, 0x2b, 0xa2, 0x16, 0x2f,  // 156 (0x9c)
+	0xa2, 0x16, 0x2f, 0xb1, 0x0b, 0x2a, 0xb5, 0x17, 0x35, 0xb9, 0x22, 0x3f,  // 160 (0xa0)
+	0xbd, 0x2e, 0x4a, 0xc1, 0x39, 0x55, 0xc4, 0x45, 0x60, 0xc8, 0x50, 0x6b,  // 164 (0xa4)
+	0xcc, 0x5c, 0x76, 0xd0, 0x67, 0x81, 0xd4, 0x73, 0x8c, 0xd7, 0x7e, 0x97,  // 168 (0xa8)
+	0xdb, 0x8a, 0xa2, 0xdf, 0x95, 0xad, 0xe3, 0xa1, 0xb8, 0xe7, 0xad, 0xc3,  // 172 (0xac)
+	0xc9, 0xaa, 0xf0, 0xc3, 0xa1, 0xef, 0xbe, 0x97, 0xed, 0xb9, 0x8d, 0xeb,  // 176 (0xb0)
+	0xb3, 0x84, 0xe9, 0xae, 0x7a, 0xe8, 0xa8, 0x70, 0xe6, 0xa3, 0x67, 0xe4,  // 180 (0xb4)
+	0x9e, 0x5d, 0xe3, 0x98, 0x53, 0xe1, 0x93, 0x4a, 0xdf, 0x8d, 0x40, 0xdd,  // 184 (0xb8)
+	0x88, 0x36, 0xdc, 0x83, 0x2d, 0xda, 0x7d, 0x23, 0xd8, 0x78, 0x19, 0xd7,  // 188 (0xbc)
+	0x75, 0x0f, 0xd7, 0x6d, 0x0e, 0xc9, 0x66, 0x0d, 0xbc, 0x5f, 0x0c, 0xae,  // 192 (0xc0)
+	0x57, 0x0b, 0xa1, 0x50, 0x0a, 0x93, 0x49, 0x09, 0x86, 0x41, 0x08, 0x78,  // 196 (0xc4)
+	0x3a, 0x07, 0x6b, 0x32, 0x06, 0x5d, 0x2b, 0x05, 0x50, 0x24, 0x04, 0x42,  // 200 (0xc8)
+	0x1c, 0x03, 0x35, 0x15, 0x02, 0x27, 0x0e, 0x01, 0x1a, 0x06, 0x00, 0x0c,  // 204 (0xcc)
+	0x00, 0x04, 0x16, 0x00, 0x06, 0x23, 0x00, 0x08, 0x30, 0x00, 0x0b, 0x3d,  // 208 (0xd0)
+	0x00, 0x0d, 0x4a, 0x00, 0x10, 0x57, 0x00, 0x12, 0x64, 0x00, 0x14, 0x71,  // 212 (0xd4)
+	0x00, 0x17, 0x7e, 0x00, 0x19, 0x8b, 0x00, 0x1c, 0x98, 0x00, 0x1e, 0xa5,  // 216 (0xd8)
+	0x00, 0x20, 0xb2, 0x00, 0x23, 0xbf, 0x00, 0x25, 0xcc, 0x00, 0x27, 0xd9,  // 220 (0xdc)
+	0x00, 0x29, 0xe3, 0x0f, 0x36, 0xe4, 0x1d, 0x42, 0xe5, 0x2c, 0x4f, 0xe6,  // 224 (0xe0)
+	0x3b, 0x5b, 0xe6, 0x4a, 0x67, 0xe7, 0x59, 0x74, 0xe8, 0x68, 0x80, 0xe9,  // 228 (0xe4)
+	0x77, 0x8c, 0xe9, 0x86, 0x99, 0xea, 0x95, 0xa5, 0xeb, 0xa4, 0xb2, 0xec,  // 232 (0xe8)
+	0xb3, 0xbe, 0xec, 0xc2, 0xca, 0xed, 0xd1, 0xd7, 0xee, 0xe0, 0xe3, 0xef,  // 236 (0xec)
+	0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xe0, 0xd0, 0xd0, 0xd0, 0xc0, 0xc0, 0xc0,  // 240 (0xf0)
+	0xb0, 0xb0, 0xb0, 0xa0, 0xa0, 0xa0, 0x90, 0x90, 0x90, 0x80, 0x80, 0x80,  // 244 (0xf4)
+	0x70, 0x70, 0x70, 0x60, 0x60, 0x60, 0x50, 0x50, 0x50, 0x40, 0x40, 0x40,  // 248 (0xf8)
+	0x30, 0x30, 0x30, 0x20, 0x20, 0x20, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,  // 252 (0xfc)
 };
 
 static byte metallicPalette[768] = {
-	0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x33, 0x33, 0x33,  // 0 (0x00)
-	0x44, 0x44, 0x44, 0x55, 0x55, 0x55, 0x66, 0x66, 0x66, 0x77, 0x77, 0x77,  // 4 (0x04)
-	0x88, 0x88, 0x88, 0x99, 0x99, 0x99, 0xaa, 0xaa, 0xaa, 0xbb, 0xbb, 0xbb,  // 8 (0x08)
-	0xcc, 0xcc, 0xcc, 0xdd, 0xdd, 0xdd, 0xee, 0xee, 0xee, 0xff, 0xff, 0xff,  // 12 (0x0c)
-	0xf1, 0xf1, 0xf1, 0xe2, 0xe2, 0xe2, 0xd3, 0xd3, 0xd3, 0xc4, 0xc4, 0xc4,  // 16 (0x10)
-	0xb5, 0xb5, 0xb5, 0xa6, 0xa6, 0xa6, 0x97, 0x97, 0x97, 0x88, 0x88, 0x88,  // 20 (0x14)
-	0x79, 0x79, 0x79, 0x6a, 0x6a, 0x6a, 0x5c, 0x5c, 0x5c, 0x4d, 0x4d, 0x4d,  // 24 (0x18)
-	0x3e, 0x3e, 0x3e, 0x2f, 0x2f, 0x2f, 0x20, 0x20, 0x20, 0x11, 0x11, 0x11,  // 28 (0x1c)
-	0x00, 0x0f, 0x55, 0x0e, 0x1e, 0x61, 0x1d, 0x2c, 0x6c, 0x2c, 0x3a, 0x77,  // 32 (0x20)
-	0x3b, 0x48, 0x83, 0x4a, 0x56, 0x8e, 0x58, 0x65, 0x99, 0x67, 0x73, 0xa5,  // 36 (0x24)
-	0x76, 0x81, 0xb0, 0x85, 0x8f, 0xbb, 0x94, 0x9d, 0xc7, 0xa3, 0xac, 0xd2,  // 40 (0x28)
-	0xb1, 0xba, 0xdd, 0xc0, 0xc8, 0xe9, 0xcf, 0xd6, 0xf4, 0xde, 0xe5, 0xff,  // 44 (0x2c)
-	0xd0, 0xd7, 0xf5, 0xc2, 0xca, 0xea, 0xb4, 0xbd, 0xe0, 0xa6, 0xaf, 0xd5,  // 48 (0x30)
-	0x98, 0xa2, 0xca, 0x8a, 0x95, 0xc0, 0x7d, 0x87, 0xb5, 0x6f, 0x7a, 0xaa,  // 52 (0x34)
-	0x61, 0x6d, 0xa0, 0x53, 0x5f, 0x95, 0x45, 0x52, 0x8a, 0x37, 0x45, 0x80,  // 56 (0x38)
-	0x29, 0x37, 0x75, 0x1b, 0x2a, 0x6a, 0x0d, 0x1d, 0x60, 0x00, 0x0f, 0x55,  // 60 (0x3c)
-	0x03, 0x30, 0x03, 0x0f, 0x3e, 0x10, 0x1c, 0x4c, 0x1c, 0x28, 0x5a, 0x28,  // 64 (0x40)
-	0x34, 0x67, 0x35, 0x41, 0x75, 0x41, 0x4d, 0x83, 0x4d, 0x5a, 0x91, 0x5a,  // 68 (0x44)
-	0x66, 0x9f, 0x66, 0x72, 0xad, 0x72, 0x7f, 0xba, 0x7f, 0x8b, 0xc8, 0x8b,  // 72 (0x48)
-	0x97, 0xd6, 0x97, 0xa4, 0xe4, 0xa4, 0xb0, 0xf2, 0xb0, 0xbc, 0xff, 0xbc,  // 76 (0x4c)
-	0xb1, 0xf2, 0xb1, 0xa5, 0xe6, 0xa5, 0x9a, 0xd9, 0x9a, 0x8e, 0xcc, 0x8e,  // 80 (0x50)
-	0x82, 0xbf, 0x83, 0x77, 0xb2, 0x77, 0x6b, 0xa5, 0x6b, 0x60, 0x98, 0x60,  // 84 (0x54)
-	0x54, 0x8b, 0x54, 0x49, 0x7e, 0x49, 0x3d, 0x71, 0x3d, 0x31, 0x64, 0x31,  // 88 (0x58)
-	0x26, 0x57, 0x26, 0x1a, 0x4a, 0x1a, 0x0f, 0x3d, 0x0f, 0x03, 0x30, 0x03,  // 92 (0x5c)
-	0x76, 0x55, 0x12, 0x80, 0x5d, 0x1c, 0x8a, 0x66, 0x26, 0x93, 0x6e, 0x2f,  // 96 (0x60)
-	0x9d, 0x77, 0x39, 0xa7, 0x7f, 0x43, 0xb1, 0x88, 0x4c, 0xbb, 0x91, 0x56,  // 100 (0x64)
-	0xc5, 0x99, 0x5f, 0xce, 0xa2, 0x69, 0xd8, 0xaa, 0x73, 0xe2, 0xb3, 0x7c,  // 104 (0x68)
-	0xec, 0xbb, 0x86, 0xf6, 0xc4, 0x8f, 0xff, 0xd8, 0xb1, 0xff, 0xe1, 0xc2,  // 108 (0x6c)
-	0xff, 0xd5, 0xab, 0xff, 0xcc, 0x99, 0xf6, 0xc4, 0x8f, 0xec, 0xbb, 0x86,  // 112 (0x70)
-	0xe2, 0xb3, 0x7c, 0xd8, 0xaa, 0x73, 0xce, 0xa2, 0x69, 0xc5, 0x99, 0x5f,  // 116 (0x74)
-	0xbb, 0x91, 0x56, 0xb1, 0x88, 0x4c, 0xa7, 0x7f, 0x43, 0x9d, 0x77, 0x39,  // 120 (0x78)
-	0x93, 0x6e, 0x2f, 0x8a, 0x66, 0x26, 0x80, 0x5d, 0x1c, 0x76, 0x55, 0x12,  // 124 (0x7c)
-	0x44, 0x26, 0x19, 0x4f, 0x31, 0x23, 0x5b, 0x3c, 0x2d, 0x66, 0x48, 0x37,  // 128 (0x80)
-	0x71, 0x53, 0x41, 0x7d, 0x5e, 0x4b, 0x88, 0x69, 0x55, 0x93, 0x74, 0x5f,  // 132 (0x84)
-	0x9f, 0x80, 0x69, 0xaa, 0x8b, 0x73, 0xb5, 0x96, 0x7d, 0xc1, 0xa1, 0x87,  // 136 (0x88)
-	0xcc, 0xac, 0x91, 0xd7, 0xb8, 0x9b, 0xe3, 0xc3, 0xa5, 0xee, 0xd1, 0xb4,  // 140 (0x8c)
-	0xe3, 0xc6, 0xaa, 0xd9, 0xbb, 0xa1, 0xce, 0xb1, 0x97, 0xc3, 0xa6, 0x8d,  // 144 (0x90)
-	0xb9, 0x9b, 0x83, 0xae, 0x91, 0x7a, 0xa4, 0x86, 0x70, 0x99, 0x7b, 0x66,  // 148 (0x94)
-	0x8e, 0x71, 0x5d, 0x84, 0x66, 0x53, 0x79, 0x5b, 0x49, 0x6f, 0x51, 0x40,  // 152 (0x98)
-	0x64, 0x46, 0x36, 0x59, 0x3b, 0x2c, 0x4f, 0x31, 0x22, 0x44, 0x26, 0x19,  // 156 (0x9c)
-	0x51, 0x20, 0x1f, 0x5d, 0x2c, 0x2c, 0x68, 0x38, 0x38, 0x74, 0x44, 0x45,  // 160 (0xa0)
-	0x7f, 0x50, 0x51, 0x8b, 0x5c, 0x5d, 0x97, 0x67, 0x6a, 0xa2, 0x73, 0x76,  // 164 (0xa4)
-	0xae, 0x7f, 0x83, 0xba, 0x8b, 0x8f, 0xc5, 0x97, 0x9b, 0xd1, 0xa3, 0xa8,  // 168 (0xa8)
-	0xdd, 0xaf, 0xb4, 0xe8, 0xbb, 0xc1, 0xf4, 0xc6, 0xcd, 0xff, 0xd2, 0xda,  // 172 (0xac)
-	0xf5, 0xc7, 0xce, 0xea, 0xbc, 0xc2, 0xdf, 0xb1, 0xb7, 0xd4, 0xa6, 0xab,  // 176 (0xb0)
-	0xc9, 0x9b, 0x9f, 0xbe, 0x90, 0x94, 0xb3, 0x84, 0x88, 0xa8, 0x79, 0x7c,  // 180 (0xb4)
-	0x9d, 0x6e, 0x71, 0x92, 0x63, 0x65, 0x87, 0x58, 0x59, 0x7d, 0x4d, 0x4e,  // 184 (0xb8)
-	0x72, 0x42, 0x42, 0x67, 0x37, 0x37, 0x5c, 0x2b, 0x2b, 0x51, 0x20, 0x1f,  // 188 (0xbc)
-	0x44, 0x2a, 0x5c, 0x4e, 0x36, 0x67, 0x59, 0x41, 0x71, 0x64, 0x4c, 0x7b,  // 192 (0xc0)
-	0x6f, 0x58, 0x85, 0x79, 0x63, 0x8f, 0x84, 0x6e, 0x99, 0x8f, 0x7a, 0xa3,  // 196 (0xc4)
-	0x99, 0x85, 0xad, 0xa4, 0x90, 0xb7, 0xaf, 0x9c, 0xc1, 0xb9, 0xa7, 0xcb,  // 200 (0xc8)
-	0xc4, 0xb2, 0xd6, 0xcf, 0xbe, 0xe0, 0xda, 0xc9, 0xea, 0xe4, 0xd4, 0xf4,  // 204 (0xcc)
-	0xda, 0xca, 0xea, 0xd0, 0xbf, 0xe1, 0xc6, 0xb4, 0xd7, 0xbc, 0xaa, 0xce,  // 208 (0xd0)
-	0xb2, 0x9f, 0xc4, 0xa8, 0x94, 0xbb, 0x9e, 0x8a, 0xb2, 0x94, 0x7f, 0xa8,  // 212 (0xd4)
-	0x8a, 0x75, 0x9f, 0x80, 0x6a, 0x95, 0x76, 0x5f, 0x8c, 0x6c, 0x55, 0x82,  // 216 (0xd8)
-	0x62, 0x4a, 0x79, 0x58, 0x3f, 0x6f, 0x4e, 0x35, 0x66, 0x44, 0x2a, 0x5c,  // 220 (0xdc)
-	0x63, 0x73, 0xbc, 0x58, 0x6d, 0xa5, 0x4e, 0x67, 0x8e, 0x43, 0x61, 0x76,  // 224 (0xe0)
-	0x38, 0x5a, 0x5f, 0x4a, 0x7d, 0x5f, 0x58, 0x94, 0x63, 0x66, 0xab, 0x66,  // 228 (0xe4)
-	0x76, 0xb1, 0x69, 0x85, 0xb7, 0x6d, 0x96, 0xbd, 0x70, 0xa6, 0xc3, 0x74,  // 232 (0xe8)
-	0xb6, 0xc8, 0x77, 0xc7, 0xce, 0x7b, 0xdd, 0xda, 0x83, 0xd0, 0xbe, 0x7b,  // 236 (0xec)
-	0xc9, 0xb0, 0x77, 0xc2, 0xa2, 0x73, 0xbb, 0x94, 0x6f, 0xb4, 0x86, 0x6b,  // 240 (0xf0)
-	0xae, 0x79, 0x67, 0xaa, 0x73, 0x65, 0xa6, 0x6f, 0x66, 0xa3, 0x6d, 0x68,  // 244 (0xf4)
-	0x9f, 0x6c, 0x6a, 0x9b, 0x66, 0x69, 0x94, 0x58, 0x63, 0x75, 0x47, 0x5e,  // 248 (0xf8)
-	0x58, 0x37, 0x59, 0x5f, 0x42, 0x6c, 0x66, 0x4c, 0x80, 0xff, 0xff, 0xff   // 252 (0xfc)
+	0xff, 0xff, 0xff, 0x66, 0x4c, 0x80, 0x5f, 0x42, 0x6c, 0x58, 0x37, 0x59,  //   0 (0x00)
+	0x75, 0x47, 0x5e, 0x94, 0x58, 0x63, 0x9b, 0x66, 0x69, 0x9f, 0x6c, 0x6a,  //   4 (0x04)
+	0xa3, 0x6d, 0x68, 0xa6, 0x6f, 0x66, 0xaa, 0x73, 0x65, 0xae, 0x79, 0x67,  //   8 (0x08)
+	0xb4, 0x86, 0x6b, 0xbb, 0x94, 0x6f, 0xc2, 0xa2, 0x73, 0xc9, 0xb0, 0x77,  //  12 (0x0c)
+	0xd0, 0xbe, 0x7b, 0xdd, 0xda, 0x83, 0xc7, 0xce, 0x7b, 0xb6, 0xc8, 0x77,  //  16 (0x10)
+	0xa6, 0xc3, 0x74, 0x96, 0xbd, 0x70, 0x85, 0xb7, 0x6d, 0x76, 0xb1, 0x69,  //  20 (0x14)
+	0x66, 0xab, 0x66, 0x58, 0x94, 0x63, 0x4a, 0x7d, 0x5f, 0x38, 0x5a, 0x5f,  //  24 (0x18)
+	0x43, 0x61, 0x76, 0x4e, 0x67, 0x8e, 0x58, 0x6d, 0xa5, 0x63, 0x73, 0xbc,  //  28 (0x1c)
+	0x44, 0x2a, 0x5c, 0x4e, 0x35, 0x66, 0x58, 0x3f, 0x6f, 0x62, 0x4a, 0x79,  //  32 (0x20)
+	0x6c, 0x55, 0x82, 0x76, 0x5f, 0x8c, 0x80, 0x6a, 0x95, 0x8a, 0x75, 0x9f,  //  36 (0x24)
+	0x94, 0x7f, 0xa8, 0x9e, 0x8a, 0xb2, 0xa8, 0x94, 0xbb, 0xb2, 0x9f, 0xc4,  //  40 (0x28)
+	0xbc, 0xaa, 0xce, 0xc6, 0xb4, 0xd7, 0xd0, 0xbf, 0xe1, 0xda, 0xca, 0xea,  //  44 (0x2c)
+	0xe4, 0xd4, 0xf4, 0xda, 0xc9, 0xea, 0xcf, 0xbe, 0xe0, 0xc4, 0xb2, 0xd6,  //  48 (0x30)
+	0xb9, 0xa7, 0xcb, 0xaf, 0x9c, 0xc1, 0xa4, 0x90, 0xb7, 0x99, 0x85, 0xad,  //  52 (0x34)
+	0x8f, 0x7a, 0xa3, 0x84, 0x6e, 0x99, 0x79, 0x63, 0x8f, 0x6f, 0x58, 0x85,  //  56 (0x38)
+	0x64, 0x4c, 0x7b, 0x59, 0x41, 0x71, 0x4e, 0x36, 0x67, 0x44, 0x2a, 0x5c,  //  60 (0x3c)
+	0x51, 0x20, 0x1f, 0x5c, 0x2b, 0x2b, 0x67, 0x37, 0x37, 0x72, 0x42, 0x42,  //  64 (0x40)
+	0x7d, 0x4d, 0x4e, 0x87, 0x58, 0x59, 0x92, 0x63, 0x65, 0x9d, 0x6e, 0x71,  //  68 (0x44)
+	0xa8, 0x79, 0x7c, 0xb3, 0x84, 0x88, 0xbe, 0x90, 0x94, 0xc9, 0x9b, 0x9f,  //  72 (0x48)
+	0xd4, 0xa6, 0xab, 0xdf, 0xb1, 0xb7, 0xea, 0xbc, 0xc2, 0xf5, 0xc7, 0xce,  //  76 (0x4c)
+	0xff, 0xd2, 0xda, 0xf4, 0xc6, 0xcd, 0xe8, 0xbb, 0xc1, 0xdd, 0xaf, 0xb4,  //  80 (0x50)
+	0xd1, 0xa3, 0xa8, 0xc5, 0x97, 0x9b, 0xba, 0x8b, 0x8f, 0xae, 0x7f, 0x83,  //  84 (0x54)
+	0xa2, 0x73, 0x76, 0x97, 0x67, 0x6a, 0x8b, 0x5c, 0x5d, 0x7f, 0x50, 0x51,  //  88 (0x58)
+	0x74, 0x44, 0x45, 0x68, 0x38, 0x38, 0x5d, 0x2c, 0x2c, 0x51, 0x20, 0x1f,  //  92 (0x5c)
+	0x44, 0x26, 0x19, 0x4f, 0x31, 0x22, 0x59, 0x3b, 0x2c, 0x64, 0x46, 0x36,  //  96 (0x60)
+	0x6f, 0x51, 0x40, 0x79, 0x5b, 0x49, 0x84, 0x66, 0x53, 0x8e, 0x71, 0x5d,  // 100 (0x64)
+	0x99, 0x7b, 0x66, 0xa4, 0x86, 0x70, 0xae, 0x91, 0x7a, 0xb9, 0x9b, 0x83,  // 104 (0x68)
+	0xc3, 0xa6, 0x8d, 0xce, 0xb1, 0x97, 0xd9, 0xbb, 0xa1, 0xe3, 0xc6, 0xaa,  // 108 (0x6c)
+	0xee, 0xd1, 0xb4, 0xe3, 0xc3, 0xa5, 0xd7, 0xb8, 0x9b, 0xcc, 0xac, 0x91,  // 112 (0x70)
+	0xc1, 0xa1, 0x87, 0xb5, 0x96, 0x7d, 0xaa, 0x8b, 0x73, 0x9f, 0x80, 0x69,  // 116 (0x74)
+	0x93, 0x74, 0x5f, 0x88, 0x69, 0x55, 0x7d, 0x5e, 0x4b, 0x71, 0x53, 0x41,  // 120 (0x78)
+	0x66, 0x48, 0x37, 0x5b, 0x3c, 0x2d, 0x4f, 0x31, 0x23, 0x44, 0x26, 0x19,  // 124 (0x7c)
+	0x76, 0x55, 0x12, 0x80, 0x5d, 0x1c, 0x8a, 0x66, 0x26, 0x93, 0x6e, 0x2f,  // 128 (0x80)
+	0x9d, 0x77, 0x39, 0xa7, 0x7f, 0x43, 0xb1, 0x88, 0x4c, 0xbb, 0x91, 0x56,  // 132 (0x84)
+	0xc5, 0x99, 0x5f, 0xce, 0xa2, 0x69, 0xd8, 0xaa, 0x73, 0xe2, 0xb3, 0x7c,  // 136 (0x88)
+	0xec, 0xbb, 0x86, 0xf6, 0xc4, 0x8f, 0xff, 0xcc, 0x99, 0xff, 0xd5, 0xab,  // 140 (0x8c)
+	0xff, 0xe1, 0xc2, 0xff, 0xd8, 0xb1, 0xf6, 0xc4, 0x8f, 0xec, 0xbb, 0x86,  // 144 (0x90)
+	0xe2, 0xb3, 0x7c, 0xd8, 0xaa, 0x73, 0xce, 0xa2, 0x69, 0xc5, 0x99, 0x5f,  // 148 (0x94)
+	0xbb, 0x91, 0x56, 0xb1, 0x88, 0x4c, 0xa7, 0x7f, 0x43, 0x9d, 0x77, 0x39,  // 152 (0x98)
+	0x93, 0x6e, 0x2f, 0x8a, 0x66, 0x26, 0x80, 0x5d, 0x1c, 0x76, 0x55, 0x12,  // 156 (0x9c)
+	0x03, 0x30, 0x03, 0x0f, 0x3d, 0x0f, 0x1a, 0x4a, 0x1a, 0x26, 0x57, 0x26,  // 160 (0xa0)
+	0x31, 0x64, 0x31, 0x3d, 0x71, 0x3d, 0x49, 0x7e, 0x49, 0x54, 0x8b, 0x54,  // 164 (0xa4)
+	0x60, 0x98, 0x60, 0x6b, 0xa5, 0x6b, 0x77, 0xb2, 0x77, 0x82, 0xbf, 0x83,  // 168 (0xa8)
+	0x8e, 0xcc, 0x8e, 0x9a, 0xd9, 0x9a, 0xa5, 0xe6, 0xa5, 0xb1, 0xf2, 0xb1,  // 172 (0xac)
+	0xbc, 0xff, 0xbc, 0xb0, 0xf2, 0xb0, 0xa4, 0xe4, 0xa4, 0x97, 0xd6, 0x97,  // 176 (0xb0)
+	0x8b, 0xc8, 0x8b, 0x7f, 0xba, 0x7f, 0x72, 0xad, 0x72, 0x66, 0x9f, 0x66,  // 180 (0xb4)
+	0x5a, 0x91, 0x5a, 0x4d, 0x83, 0x4d, 0x41, 0x75, 0x41, 0x34, 0x67, 0x35,  // 184 (0xb8)
+	0x28, 0x5a, 0x28, 0x1c, 0x4c, 0x1c, 0x0f, 0x3e, 0x10, 0x03, 0x30, 0x03,  // 188 (0xbc)
+	0x00, 0x0f, 0x55, 0x0d, 0x1d, 0x60, 0x1b, 0x2a, 0x6a, 0x29, 0x37, 0x75,  // 192 (0xc0)
+	0x37, 0x45, 0x80, 0x45, 0x52, 0x8a, 0x53, 0x5f, 0x95, 0x61, 0x6d, 0xa0,  // 196 (0xc4)
+	0x6f, 0x7a, 0xaa, 0x7d, 0x87, 0xb5, 0x8a, 0x95, 0xc0, 0x98, 0xa2, 0xca,  // 200 (0xc8)
+	0xa6, 0xaf, 0xd5, 0xb4, 0xbd, 0xe0, 0xc2, 0xca, 0xea, 0xd0, 0xd7, 0xf5,  // 204 (0xcc)
+	0xde, 0xe5, 0xff, 0xcf, 0xd6, 0xf4, 0xc0, 0xc8, 0xe9, 0xb1, 0xba, 0xdd,  // 208 (0xd0)
+	0xa3, 0xac, 0xd2, 0x94, 0x9d, 0xc7, 0x85, 0x8f, 0xbb, 0x76, 0x81, 0xb0,  // 212 (0xd4)
+	0x67, 0x73, 0xa5, 0x58, 0x65, 0x99, 0x4a, 0x56, 0x8e, 0x3b, 0x48, 0x83,  // 216 (0xd8)
+	0x2c, 0x3a, 0x77, 0x1d, 0x2c, 0x6c, 0x0e, 0x1e, 0x61, 0x00, 0x0f, 0x55,  // 220 (0xdc)
+	0x11, 0x11, 0x11, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x2f, 0x3e, 0x3e, 0x3e,  // 224 (0xe0)
+	0x4d, 0x4d, 0x4d, 0x5c, 0x5c, 0x5c, 0x6a, 0x6a, 0x6a, 0x79, 0x79, 0x79,  // 228 (0xe4)
+	0x88, 0x88, 0x88, 0x97, 0x97, 0x97, 0xa6, 0xa6, 0xa6, 0xb5, 0xb5, 0xb5,  // 232 (0xe8)
+	0xc4, 0xc4, 0xc4, 0xd3, 0xd3, 0xd3, 0xe2, 0xe2, 0xe2, 0xf1, 0xf1, 0xf1,  // 236 (0xec)
+	0xff, 0xff, 0xff, 0xee, 0xee, 0xee, 0xdd, 0xdd, 0xdd, 0xcc, 0xcc, 0xcc,  // 240 (0xf0)
+	0xbb, 0xbb, 0xbb, 0xaa, 0xaa, 0xaa, 0x99, 0x99, 0x99, 0x88, 0x88, 0x88,  // 244 (0xf4)
+	0x77, 0x77, 0x77, 0x66, 0x66, 0x66, 0x55, 0x55, 0x55, 0x44, 0x44, 0x44,  // 248 (0xf8)
+	0x33, 0x33, 0x33, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00,  // 252 (0xfc)
+};
+
+static byte win16Palette[48] = {
+	0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff,  //   0 (0x00)
+	0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x7f, 0x7f, 0x7f,  //   4 (0x04)
+	0xc0, 0xc0, 0xc0, 0x00, 0xbf, 0xbf, 0xbf, 0x00, 0xbf, 0x00, 0x00, 0xbf,  //   8 (0x08)
+	0xbf, 0xbf, 0x00, 0x00, 0xbf, 0x00, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00,  //  12 (0x0c)
 };
 
 static byte winPalette[768] = {
-	0x00, 0x00, 0x00, 0xbf, 0x00, 0x00, 0x00, 0xbf, 0x00, 0xbf, 0xbf, 0x00,  // 0 (0x00)
-	0x00, 0x00, 0xbf, 0xbf, 0x00, 0xbf, 0x00, 0xbf, 0xbf, 0xc0, 0xc0, 0xc0,  // 4 (0x04)
-	0xc0, 0xdc, 0xc0, 0xa4, 0xc8, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0x99,  // 8 (0x08)
-	0x99, 0xd4, 0x99, 0x99, 0xd4, 0xff, 0xff, 0xcc, 0xff, 0xff, 0x99, 0x99,  // 12 (0x0c)
-	0x22, 0x22, 0x30, 0x00, 0x00, 0x11, 0x00, 0x00, 0x22, 0x00, 0x00, 0x44,  // 16 (0x10)
-	0x00, 0x00, 0x55, 0x00, 0x00, 0x77, 0x00, 0x00, 0x88, 0x00, 0x00, 0xaa,  // 20 (0x14)
-	0x00, 0x00, 0xdd, 0x00, 0x00, 0xee, 0x00, 0x11, 0x00, 0x00, 0x22, 0x00,  // 24 (0x18)
-	0x00, 0x44, 0x00, 0x00, 0x55, 0x00, 0x00, 0x77, 0x00, 0x00, 0x88, 0x00,  // 28 (0x1c)
-	0x00, 0xaa, 0x00, 0x00, 0xdd, 0x00, 0x00, 0xee, 0x00, 0x11, 0x00, 0x00,  // 32 (0x20)
-	0x22, 0x00, 0x00, 0x44, 0x00, 0x00, 0x55, 0x00, 0x00, 0x77, 0x00, 0x00,  // 36 (0x24)
-	0x90, 0x00, 0x00, 0xaa, 0x00, 0x00, 0xdd, 0x00, 0x00, 0xee, 0x00, 0x00,  // 40 (0x28)
-	0x00, 0x00, 0x33, 0x00, 0x00, 0x66, 0x00, 0x00, 0x99, 0x00, 0x00, 0xcc,  // 44 (0x2c)
-	0x00, 0x33, 0x00, 0x00, 0x33, 0x33, 0x00, 0x33, 0x66, 0x00, 0x33, 0xa1,  // 48 (0x30)
-	0x00, 0x33, 0xcc, 0x00, 0x33, 0xff, 0x00, 0x66, 0x00, 0x00, 0x66, 0x33,  // 52 (0x34)
-	0x00, 0x66, 0x66, 0x00, 0x66, 0x99, 0x00, 0x66, 0xcc, 0x00, 0x66, 0xff,  // 56 (0x38)
-	0x00, 0x99, 0x00, 0x00, 0x99, 0x33, 0x00, 0x99, 0x66, 0x00, 0x99, 0x99,  // 60 (0x3c)
-	0x00, 0x99, 0xcc, 0x00, 0x99, 0xff, 0x00, 0xcc, 0x00, 0x00, 0xcc, 0x33,  // 64 (0x40)
-	0x00, 0xcc, 0x66, 0x00, 0xcc, 0x99, 0x00, 0xcc, 0xcc, 0x00, 0xcc, 0xff,  // 68 (0x44)
-	0x00, 0xff, 0x33, 0x00, 0xff, 0x66, 0x00, 0xff, 0x99, 0x00, 0xff, 0xcc,  // 72 (0x48)
-	0x33, 0x00, 0x00, 0x33, 0x00, 0x33, 0x33, 0x00, 0x66, 0x33, 0x00, 0x99,  // 76 (0x4c)
-	0x33, 0x00, 0xcc, 0x33, 0x00, 0xff, 0x33, 0x33, 0x00, 0x33, 0x33, 0x3b,  // 80 (0x50)
-	0x33, 0x33, 0x66, 0x33, 0x33, 0x99, 0x33, 0x33, 0xcc, 0x33, 0x33, 0xff,  // 84 (0x54)
-	0x33, 0x66, 0x00, 0x33, 0x6e, 0x33, 0x33, 0x66, 0x66, 0x33, 0x66, 0x99,  // 88 (0x58)
-	0x33, 0x66, 0xcc, 0x33, 0x66, 0xff, 0x33, 0x99, 0x00, 0x33, 0x99, 0x33,  // 92 (0x5c)
-	0x33, 0x99, 0x66, 0x33, 0x99, 0x99, 0x33, 0x99, 0xcc, 0x33, 0x99, 0xff,  // 96 (0x60)
-	0x33, 0xcc, 0x00, 0x33, 0xcc, 0x33, 0x33, 0xcc, 0x66, 0x33, 0xcc, 0x99,  // 100 (0x64)
-	0x33, 0xcc, 0xcc, 0x33, 0xcc, 0xff, 0x33, 0xff, 0x00, 0x33, 0xff, 0x33,  // 104 (0x68)
-	0x33, 0xff, 0x66, 0x33, 0xff, 0x99, 0x33, 0xff, 0xcc, 0x33, 0xff, 0xff,  // 108 (0x6c)
-	0x66, 0x00, 0x00, 0x66, 0x00, 0x33, 0x66, 0x00, 0x66, 0x66, 0x00, 0x99,  // 112 (0x70)
-	0x66, 0x00, 0xcc, 0x66, 0x00, 0xff, 0x66, 0x33, 0x00, 0x66, 0x33, 0x33,  // 116 (0x74)
-	0x66, 0x33, 0x66, 0x66, 0x33, 0x99, 0x66, 0x33, 0xcc, 0x66, 0x33, 0xff,  // 120 (0x78)
-	0x66, 0x66, 0x00, 0x66, 0x66, 0x33, 0x66, 0x66, 0x66, 0x66, 0x66, 0x99,  // 124 (0x7c)
-	0x66, 0x66, 0xcc, 0x66, 0x66, 0xff, 0x66, 0x99, 0x00, 0x66, 0x99, 0x33,  // 128 (0x80)
-	0x66, 0x99, 0x66, 0x66, 0x99, 0x99, 0x66, 0x99, 0xcc, 0x66, 0x99, 0xff,  // 132 (0x84)
-	0x66, 0xcc, 0x00, 0x66, 0xcc, 0x33, 0x66, 0xcc, 0x66, 0x66, 0xcc, 0x99,  // 136 (0x88)
-	0x66, 0xcc, 0xcc, 0x66, 0xcc, 0xff, 0x66, 0xff, 0x00, 0x66, 0xff, 0x33,  // 140 (0x8c)
-	0x66, 0xff, 0x66, 0x66, 0xff, 0x99, 0x66, 0xff, 0xcc, 0x66, 0xff, 0xff,  // 144 (0x90)
-	0x99, 0x00, 0x00, 0x99, 0x00, 0x33, 0x99, 0x00, 0x66, 0x99, 0x00, 0x99,  // 148 (0x94)
-	0x99, 0x00, 0xcc, 0x99, 0x00, 0xff, 0x99, 0x33, 0x00, 0x99, 0x33, 0x33,  // 152 (0x98)
-	0x99, 0x33, 0x66, 0x99, 0x33, 0x99, 0x99, 0x33, 0xcc, 0x99, 0x33, 0xff,  // 156 (0x9c)
-	0xa1, 0x66, 0x00, 0x99, 0x66, 0x33, 0x99, 0x66, 0x66, 0x99, 0x66, 0x99,  // 160 (0xa0)
-	0x99, 0x66, 0xcc, 0x99, 0x66, 0xff, 0x99, 0x99, 0x00, 0x99, 0x99, 0x33,  // 164 (0xa4)
-	0x99, 0x99, 0x66, 0x99, 0x99, 0x99, 0x99, 0x99, 0xcc, 0x99, 0x99, 0xff,  // 168 (0xa8)
-	0x99, 0xcc, 0x00, 0x99, 0xcc, 0x33, 0x99, 0xcc, 0x66, 0x99, 0xcc, 0x99,  // 172 (0xac)
-	0x99, 0xcc, 0xcc, 0x99, 0xcc, 0xff, 0x99, 0xff, 0x00, 0x99, 0xff, 0x33,  // 176 (0xb0)
-	0x99, 0xff, 0x66, 0x99, 0xff, 0x99, 0x99, 0xff, 0xcc, 0x99, 0xff, 0xff,  // 180 (0xb4)
-	0xcc, 0x00, 0x00, 0xcc, 0x00, 0x33, 0xcc, 0x00, 0x66, 0xcc, 0x00, 0x99,  // 184 (0xb8)
-	0xcc, 0x00, 0xcc, 0xd4, 0x08, 0xff, 0xcc, 0x33, 0x00, 0xcc, 0x33, 0x33,  // 188 (0xbc)
-	0xcc, 0x33, 0x66, 0xcc, 0x33, 0x99, 0xcc, 0x33, 0xcc, 0xcc, 0x33, 0xff,  // 192 (0xc0)
-	0xcc, 0x66, 0x00, 0xcc, 0x66, 0x33, 0xcc, 0x66, 0x66, 0xcc, 0x66, 0x99,  // 196 (0xc4)
-	0xcc, 0x66, 0xcc, 0xcc, 0x66, 0xff, 0xcc, 0x99, 0x00, 0xcc, 0x99, 0x33,  // 200 (0xc8)
-	0xcc, 0x99, 0x66, 0xcc, 0x99, 0x99, 0xcc, 0x99, 0xcc, 0xcc, 0x99, 0xff,  // 204 (0xcc)
-	0xcc, 0xcc, 0x00, 0xcc, 0xcc, 0x33, 0xcc, 0xcc, 0x66, 0xcc, 0xcc, 0x99,  // 208 (0xd0)
-	0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xff, 0xcc, 0xff, 0x00, 0xcc, 0xff, 0x33,  // 212 (0xd4)
-	0xcc, 0xff, 0x66, 0xcc, 0xff, 0x99, 0xcc, 0xff, 0xcc, 0xcc, 0xff, 0xff,  // 216 (0xd8)
-	0xff, 0x00, 0x33, 0xff, 0x00, 0x66, 0xff, 0x00, 0x99, 0xff, 0x00, 0xcc,  // 220 (0xdc)
-	0xff, 0x33, 0x00, 0xff, 0x33, 0x33, 0xff, 0x33, 0x66, 0xff, 0x33, 0x99,  // 224 (0xe0)
-	0xff, 0x33, 0xcc, 0xff, 0x33, 0xff, 0xff, 0x66, 0x00, 0xff, 0x66, 0x33,  // 228 (0xe4)
-	0xff, 0x66, 0x66, 0xff, 0x66, 0x99, 0xff, 0x66, 0xcc, 0xff, 0x66, 0xff,  // 232 (0xe8)
-	0xff, 0x99, 0x00, 0xdd, 0xdd, 0xdd, 0xff, 0x99, 0xcc, 0xff, 0xcc, 0x66,  // 236 (0xec)
-	0x88, 0x00, 0x00, 0xcc, 0x00, 0xff, 0x00, 0x33, 0x99, 0x33, 0x66, 0x33,  // 240 (0xf0)
-	0x99, 0x66, 0x00, 0x33, 0x33, 0x33, 0xff, 0xfb, 0xf0, 0xa0, 0xa0, 0xa4,  // 244 (0xf4)
-	0x80, 0x80, 0x80, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00,  // 248 (0xf8)
-	0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff   // 252 (0xfc)
+	0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff,  //   0 (0x00)
+	0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x80, 0x80, 0x80,  //   4 (0x04)
+	0xa0, 0xa0, 0xa4, 0xff, 0xfb, 0xf0, 0x33, 0x33, 0x33, 0x99, 0x66, 0x00,  //   8 (0x08)
+	0x33, 0x66, 0x33, 0x00, 0x33, 0x99, 0xcc, 0x00, 0xff, 0x88, 0x00, 0x00,  //  12 (0x0c)
+	0xff, 0xcc, 0x66, 0xff, 0x99, 0xcc, 0xdd, 0xdd, 0xdd, 0xff, 0x99, 0x00,  //  16 (0x10)
+	0xff, 0x66, 0xff, 0xff, 0x66, 0xcc, 0xff, 0x66, 0x99, 0xff, 0x66, 0x66,  //  20 (0x14)
+	0xff, 0x66, 0x33, 0xff, 0x66, 0x00, 0xff, 0x33, 0xff, 0xff, 0x33, 0xcc,  //  24 (0x18)
+	0xff, 0x33, 0x99, 0xff, 0x33, 0x66, 0xff, 0x33, 0x33, 0xff, 0x33, 0x00,  //  28 (0x1c)
+	0xff, 0x00, 0xcc, 0xff, 0x00, 0x99, 0xff, 0x00, 0x66, 0xff, 0x00, 0x33,  //  32 (0x20)
+	0xcc, 0xff, 0xff, 0xcc, 0xff, 0xcc, 0xcc, 0xff, 0x99, 0xcc, 0xff, 0x66,  //  36 (0x24)
+	0xcc, 0xff, 0x33, 0xcc, 0xff, 0x00, 0xcc, 0xcc, 0xff, 0xcc, 0xcc, 0xcc,  //  40 (0x28)
+	0xcc, 0xcc, 0x99, 0xcc, 0xcc, 0x66, 0xcc, 0xcc, 0x33, 0xcc, 0xcc, 0x00,  //  44 (0x2c)
+	0xcc, 0x99, 0xff, 0xcc, 0x99, 0xcc, 0xcc, 0x99, 0x99, 0xcc, 0x99, 0x66,  //  48 (0x30)
+	0xcc, 0x99, 0x33, 0xcc, 0x99, 0x00, 0xcc, 0x66, 0xff, 0xcc, 0x66, 0xcc,  //  52 (0x34)
+	0xcc, 0x66, 0x99, 0xcc, 0x66, 0x66, 0xcc, 0x66, 0x33, 0xcc, 0x66, 0x00,  //  56 (0x38)
+	0xcc, 0x33, 0xff, 0xcc, 0x33, 0xcc, 0xcc, 0x33, 0x99, 0xcc, 0x33, 0x66,  //  60 (0x3c)
+	0xcc, 0x33, 0x33, 0xcc, 0x33, 0x00, 0xd4, 0x08, 0xff, 0xcc, 0x00, 0xcc,  //  64 (0x40)
+	0xcc, 0x00, 0x99, 0xcc, 0x00, 0x66, 0xcc, 0x00, 0x33, 0xcc, 0x00, 0x00,  //  68 (0x44)
+	0x99, 0xff, 0xff, 0x99, 0xff, 0xcc, 0x99, 0xff, 0x99, 0x99, 0xff, 0x66,  //  72 (0x48)
+	0x99, 0xff, 0x33, 0x99, 0xff, 0x00, 0x99, 0xcc, 0xff, 0x99, 0xcc, 0xcc,  //  76 (0x4c)
+	0x99, 0xcc, 0x99, 0x99, 0xcc, 0x66, 0x99, 0xcc, 0x33, 0x99, 0xcc, 0x00,  //  80 (0x50)
+	0x99, 0x99, 0xff, 0x99, 0x99, 0xcc, 0x99, 0x99, 0x99, 0x99, 0x99, 0x66,  //  84 (0x54)
+	0x99, 0x99, 0x33, 0x99, 0x99, 0x00, 0x99, 0x66, 0xff, 0x99, 0x66, 0xcc,  //  88 (0x58)
+	0x99, 0x66, 0x99, 0x99, 0x66, 0x66, 0x99, 0x66, 0x33, 0xa1, 0x66, 0x00,  //  92 (0x5c)
+	0x99, 0x33, 0xff, 0x99, 0x33, 0xcc, 0x99, 0x33, 0x99, 0x99, 0x33, 0x66,  //  96 (0x60)
+	0x99, 0x33, 0x33, 0x99, 0x33, 0x00, 0x99, 0x00, 0xff, 0x99, 0x00, 0xcc,  // 100 (0x64)
+	0x99, 0x00, 0x99, 0x99, 0x00, 0x66, 0x99, 0x00, 0x33, 0x99, 0x00, 0x00,  // 104 (0x68)
+	0x66, 0xff, 0xff, 0x66, 0xff, 0xcc, 0x66, 0xff, 0x99, 0x66, 0xff, 0x66,  // 108 (0x6c)
+	0x66, 0xff, 0x33, 0x66, 0xff, 0x00, 0x66, 0xcc, 0xff, 0x66, 0xcc, 0xcc,  // 112 (0x70)
+	0x66, 0xcc, 0x99, 0x66, 0xcc, 0x66, 0x66, 0xcc, 0x33, 0x66, 0xcc, 0x00,  // 116 (0x74)
+	0x66, 0x99, 0xff, 0x66, 0x99, 0xcc, 0x66, 0x99, 0x99, 0x66, 0x99, 0x66,  // 120 (0x78)
+	0x66, 0x99, 0x33, 0x66, 0x99, 0x00, 0x66, 0x66, 0xff, 0x66, 0x66, 0xcc,  // 124 (0x7c)
+	0x66, 0x66, 0x99, 0x66, 0x66, 0x66, 0x66, 0x66, 0x33, 0x66, 0x66, 0x00,  // 128 (0x80)
+	0x66, 0x33, 0xff, 0x66, 0x33, 0xcc, 0x66, 0x33, 0x99, 0x66, 0x33, 0x66,  // 132 (0x84)
+	0x66, 0x33, 0x33, 0x66, 0x33, 0x00, 0x66, 0x00, 0xff, 0x66, 0x00, 0xcc,  // 136 (0x88)
+	0x66, 0x00, 0x99, 0x66, 0x00, 0x66, 0x66, 0x00, 0x33, 0x66, 0x00, 0x00,  // 140 (0x8c)
+	0x33, 0xff, 0xff, 0x33, 0xff, 0xcc, 0x33, 0xff, 0x99, 0x33, 0xff, 0x66,  // 144 (0x90)
+	0x33, 0xff, 0x33, 0x33, 0xff, 0x00, 0x33, 0xcc, 0xff, 0x33, 0xcc, 0xcc,  // 148 (0x94)
+	0x33, 0xcc, 0x99, 0x33, 0xcc, 0x66, 0x33, 0xcc, 0x33, 0x33, 0xcc, 0x00,  // 152 (0x98)
+	0x33, 0x99, 0xff, 0x33, 0x99, 0xcc, 0x33, 0x99, 0x99, 0x33, 0x99, 0x66,  // 156 (0x9c)
+	0x33, 0x99, 0x33, 0x33, 0x99, 0x00, 0x33, 0x66, 0xff, 0x33, 0x66, 0xcc,  // 160 (0xa0)
+	0x33, 0x66, 0x99, 0x33, 0x66, 0x66, 0x33, 0x6e, 0x33, 0x33, 0x66, 0x00,  // 164 (0xa4)
+	0x33, 0x33, 0xff, 0x33, 0x33, 0xcc, 0x33, 0x33, 0x99, 0x33, 0x33, 0x66,  // 168 (0xa8)
+	0x33, 0x33, 0x3b, 0x33, 0x33, 0x00, 0x33, 0x00, 0xff, 0x33, 0x00, 0xcc,  // 172 (0xac)
+	0x33, 0x00, 0x99, 0x33, 0x00, 0x66, 0x33, 0x00, 0x33, 0x33, 0x00, 0x00,  // 176 (0xb0)
+	0x00, 0xff, 0xcc, 0x00, 0xff, 0x99, 0x00, 0xff, 0x66, 0x00, 0xff, 0x33,  // 180 (0xb4)
+	0x00, 0xcc, 0xff, 0x00, 0xcc, 0xcc, 0x00, 0xcc, 0x99, 0x00, 0xcc, 0x66,  // 184 (0xb8)
+	0x00, 0xcc, 0x33, 0x00, 0xcc, 0x00, 0x00, 0x99, 0xff, 0x00, 0x99, 0xcc,  // 188 (0xbc)
+	0x00, 0x99, 0x99, 0x00, 0x99, 0x66, 0x00, 0x99, 0x33, 0x00, 0x99, 0x00,  // 192 (0xc0)
+	0x00, 0x66, 0xff, 0x00, 0x66, 0xcc, 0x00, 0x66, 0x99, 0x00, 0x66, 0x66,  // 196 (0xc4)
+	0x00, 0x66, 0x33, 0x00, 0x66, 0x00, 0x00, 0x33, 0xff, 0x00, 0x33, 0xcc,  // 200 (0xc8)
+	0x00, 0x33, 0xa1, 0x00, 0x33, 0x66, 0x00, 0x33, 0x33, 0x00, 0x33, 0x00,  // 204 (0xcc)
+	0x00, 0x00, 0xcc, 0x00, 0x00, 0x99, 0x00, 0x00, 0x66, 0x00, 0x00, 0x33,  // 208 (0xd0)
+	0xee, 0x00, 0x00, 0xdd, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x90, 0x00, 0x00,  // 212 (0xd4)
+	0x77, 0x00, 0x00, 0x55, 0x00, 0x00, 0x44, 0x00, 0x00, 0x22, 0x00, 0x00,  // 216 (0xd8)
+	0x11, 0x00, 0x00, 0x00, 0xee, 0x00, 0x00, 0xdd, 0x00, 0x00, 0xaa, 0x00,  // 220 (0xdc)
+	0x00, 0x88, 0x00, 0x00, 0x77, 0x00, 0x00, 0x55, 0x00, 0x00, 0x44, 0x00,  // 224 (0xe0)
+	0x00, 0x22, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xee, 0x00, 0x00, 0xdd,  // 228 (0xe4)
+	0x00, 0x00, 0xaa, 0x00, 0x00, 0x88, 0x00, 0x00, 0x77, 0x00, 0x00, 0x55,  // 232 (0xe8)
+	0x00, 0x00, 0x44, 0x00, 0x00, 0x22, 0x00, 0x00, 0x11, 0x22, 0x22, 0x30,  // 236 (0xec)
+	0xff, 0x99, 0x99, 0xff, 0xcc, 0xff, 0x99, 0xd4, 0xff, 0x99, 0xd4, 0x99,  // 240 (0xf0)
+	0xff, 0xff, 0x99, 0xf0, 0xf0, 0xf0, 0xa4, 0xc8, 0xf0, 0xc0, 0xdc, 0xc0,  // 244 (0xf4)
+	0xc0, 0xc0, 0xc0, 0x00, 0xbf, 0xbf, 0xbf, 0x00, 0xbf, 0x00, 0x00, 0xbf,  // 248 (0xf8)
+	0xbf, 0xbf, 0x00, 0x00, 0xbf, 0x00, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00,  // 252 (0xfc)
+};
+
+// For 2-bit and 4-bit graphics, Director assumes a fixed palette and uses nearest-neighbour
+// remapping to the current movie palette.
+
+// The 2-bit palette is clear cut; white, light gray, dark gray, black.
+static byte grayscale4Palette[12] = {
+	0xff, 0xff, 0xff, 0xa3, 0xa3, 0xa3, 0x65, 0x65, 0x65, 0x00, 0x00, 0x00
 };
 
 
diff --git a/engines/director/graphics.cpp b/engines/director/graphics.cpp
index b65baa0a11d..6987a0efb1e 100644
--- a/engines/director/graphics.cpp
+++ b/engines/director/graphics.cpp
@@ -35,15 +35,11 @@ namespace Director {
 #include "director/graphics-data.h"
 
 /**
- * The sprites colors are in reverse order with respect to the ids in director.
- * The palette is in reverse order, this eases the code for loading files.
- * All other color ids can be converted with: 255 - colorId.
+ * Used to upgrade to 32-bit color if required.
  **/
 uint32 DirectorEngine::transformColor(uint32 color) {
 	if (_pixelformat.bytesPerPixel == 1)
-		return 255 - color;
-
-	color = 255 - color;
+		return color;
 
 	return _wm->findBestColor(_currentPalette[color * 3], _currentPalette[color * 3 + 1], _currentPalette[color * 3 + 2]);
 }
@@ -171,24 +167,23 @@ void DirectorEngine::shiftPalette(int startIndex, int endIndex, bool reverse) {
 	if (startIndex == endIndex)
 		return;
 
-	if (endIndex > startIndex)
+	if (startIndex > endIndex)
 		return;
 
-	// Palette indexes are in reverse order thanks to transformColor
 	byte temp[3] = { 0, 0, 0 };
-	int span = startIndex - endIndex + 1;
+	int span = endIndex - startIndex + 1;
 	if (reverse) {
-		memcpy(temp, _currentPalette + 3 * endIndex, 3);
-		memmove(_currentPalette + 3 * endIndex,
-			_currentPalette + 3 * endIndex + 3,
-			(span - 1) * 3);
-		memcpy(_currentPalette + 3 * startIndex, temp, 3);
-	} else {
 		memcpy(temp, _currentPalette + 3 * startIndex, 3);
-		memmove(_currentPalette + 3 * endIndex + 3,
-			_currentPalette + 3 * endIndex,
+		memmove(_currentPalette + 3 * startIndex,
+			_currentPalette + 3 * startIndex + 3,
 			(span - 1) * 3);
 		memcpy(_currentPalette + 3 * endIndex, temp, 3);
+	} else {
+		memcpy(temp, _currentPalette + 3 * endIndex, 3);
+		memmove(_currentPalette + 3 * startIndex + 3,
+			_currentPalette + 3 * startIndex,
+			(span - 1) * 3);
+		memcpy(_currentPalette + 3 * startIndex, temp, 3);
 	}
 
 	// Pass the palette to OSystem only for 8bpp mode
@@ -303,7 +298,7 @@ void inkDrawPixel(int x, int y, int src, void *data) {
 	case kInkTypeCopy: {
 		if (p->applyColor) {
 			if (sizeof(T) == 1) {
-				*dst = src == 0x00 ? p->foreColor : (src == 0xff ? p->backColor : *dst);
+				*dst = src == 0xff ? p->foreColor : (src == 0x00 ? p->backColor : *dst);
 			} else {
 				// TODO: Improve the efficiency of this composition
 				byte rSrc, gSrc, bSrc;
@@ -328,7 +323,7 @@ void inkDrawPixel(int x, int y, int src, void *data) {
 	case kInkTypeNotCopy:
 		if (p->applyColor) {
 			if (sizeof(T) == 1) {
-				*dst = src == 0x00 ? p->backColor : (src == 0xff ? p->foreColor : src);
+				*dst = src == 0xff ? p->backColor : (src == 0x00 ? p->foreColor : src);
 			} else {
 				// TODO: Improve the efficiency of this composition
 				byte rSrc, gSrc, bSrc;
@@ -350,22 +345,22 @@ void inkDrawPixel(int x, int y, int src, void *data) {
 		}
 		break;
 	case kInkTypeTransparent:
-		*dst = p->applyColor ? (~src & p->foreColor) | (*dst & src) : (*dst & src);
+		*dst = p->applyColor ? (src & p->foreColor) | (*dst & ~src) : (*dst & ~src);
 		break;
 	case kInkTypeNotTrans:
-		*dst = p->applyColor ? (src & p->foreColor) | (*dst & ~src) : (*dst & ~src);
+		*dst = p->applyColor ? (~src & p->foreColor) | (*dst & src) : (*dst & src);
 		break;
 	case kInkTypeReverse:
-		*dst ^= ~(src);
+		*dst ^= src;
 		break;
 	case kInkTypeNotReverse:
-		*dst ^= src;
+		*dst ^= ~(src);
 		break;
 	case kInkTypeGhost:
-		*dst = p->applyColor ? (src | p->backColor) & (*dst | ~src) : (*dst | ~src);
+		*dst = p->applyColor ? (~src | p->backColor) & (*dst | src) : *dst | src;
 		break;
 	case kInkTypeNotGhost:
-		*dst = p->applyColor ? (~src | p->backColor) & (*dst | src) : *dst | src;
+		*dst = p->applyColor ? (src | p->backColor) & (*dst | ~src) : (*dst | ~src);
 		break;
 		// Arithmetic ink types
 	default: {
diff --git a/engines/director/images.cpp b/engines/director/images.cpp
index 36f5a9e3f93..a046bbc3184 100644
--- a/engines/director/images.cpp
+++ b/engines/director/images.cpp
@@ -52,20 +52,20 @@ void DIBDecoder::destroy() {
 
 void DIBDecoder::loadPalette(Common::SeekableReadStream &stream) {
 	uint16 steps = stream.size() / 6;
-	uint16 index = (steps * 3) - 1;
+	uint16 index = 0;
 	_paletteColorCount = steps;
-	_palette = new byte[index + 1];
+	_palette = new byte[steps * 3];
 
 	for (uint8 i = 0; i < steps; i++) {
-		_palette[index - 2] = stream.readByte();
+		_palette[index] = stream.readByte();
 		stream.readByte();
 
-		_palette[index - 1] = stream.readByte();
+		_palette[index + 1] = stream.readByte();
 		stream.readByte();
 
-		_palette[index] = stream.readByte();
+		_palette[index + 2] = stream.readByte();
 		stream.readByte();
-		index -= 3;
+		index += 3;
 	}
 }
 
@@ -99,6 +99,15 @@ bool DIBDecoder::loadStream(Common::SeekableReadStream &stream) {
 
 	_surface = _codec->decodeFrame(subStream);
 
+	// For some reason, DIB cast members have the palette indexes reversed
+	if (bitsPerPixel == 8) {
+		for (int y = 0; y < _surface->h; y++) {
+			for (int x = 0; x < _surface->w; x++) {
+				*(byte *)_surface->getBasePtr(x, y) = 255 - *(byte *)_surface->getBasePtr(x, y);
+			}
+		}
+	}
+
 	return true;
 }
 
@@ -243,7 +252,7 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 				switch (_bitsPerPixel) {
 				case 1:
 					for (int c = 0; c < 8 && x < _surface->w; c++, x++) {
-						color = (pixels[(((y * _pitch) + x) / 8)] & (1 << (7 - c))) ? 0 : 0xff;
+						color = (pixels[(((y * _pitch) + x) / 8)] & (1 << (7 - c))) ? 0xff : 0x00;
 						if (paletted) {
 							*((byte *)_surface->getBasePtr(x, y)) = color;
 						} else {
diff --git a/engines/director/palette-fade.h b/engines/director/palette-fade.h
index 8964d8f6697..3260468ef30 100644
--- a/engines/director/palette-fade.h
+++ b/engines/director/palette-fade.h
@@ -20,7 +20,7 @@
  */
 
 static byte whitePalette[768] = {
-	0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  // 0 (0x00)
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  // 0 (0x00)
 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  // 4 (0x04)
 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  // 8 (0x08)
 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  // 12 (0x0c)
@@ -83,11 +83,11 @@ static byte whitePalette[768] = {
 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  // 240 (0xf0)
 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  // 244 (0xf4)
 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  // 248 (0xf8)
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff   // 252 (0xfc)
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00   // 252 (0xfc)
 };
 
 static byte blackPalette[768] = {
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // 0 (0x00)
+	0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // 0 (0x00)
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // 4 (0x04)
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // 8 (0x08)
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // 12 (0x0c)
@@ -150,7 +150,7 @@ static byte blackPalette[768] = {
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // 240 (0xf0)
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // 244 (0xf4)
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // 248 (0xf8)
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff   // 252 (0xfc)
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00   // 252 (0xfc)
 };
 
 // TODO: Timing here is measured empirically from DOSBox,
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index bb77312f017..86bd3a88bfc 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -737,7 +737,6 @@ void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
 		return;
 	// 30 (the maximum) is actually unbounded
 	int delay = speed == 30 ? 10 : 1000 / speed;
-	// Palette indexes are in reverse order thanks to transformColor
 	if (_frames[frameId]->_palette.colorCycling) {
 		// Cycle the colors of a chosen palette
 		int firstColor = _frames[frameId]->_palette.firstColor;
@@ -753,7 +752,7 @@ void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
 			g_director->draw();
 		} else {
 			// Do a full color cycle in one frame transition
-			int steps = firstColor - lastColor + 1;
+			int steps = lastColor - firstColor + 1;
 			for (int i = 0; i < _frames[frameId]->_palette.cycleCount; i++) {
 				for (int j = 0; j < steps; j++) {
 					g_director->shiftPalette(firstColor, lastColor, false);


Commit: cb68c05dcb7ef10b154eff18047f5601f05031a9
    https://github.com/scummvm/scummvm/commit/cb68c05dcb7ef10b154eff18047f5601f05031a9
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
GRAPHICS: Loosen palette checks on Surface::convertTo

Surface::ditherFloyd() supports having different palette counts;
as it is a private function wrapped by convertTo(), adjust the
short-circuit check in convertTo() so that the short circuit
happens if both palettes are equal in size and content.

Changed paths:
    graphics/surface.cpp


diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index 88a06af1275..1ceee0447b6 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -540,8 +540,8 @@ Graphics::Surface *Surface::convertTo(const PixelFormat &dstFormat, const byte *
 		if (dstFormat.bytesPerPixel == 1) { // Checking if dithering could be skipped
 			if (!srcPalette // No palette is specified
 					|| !dstPalette // No dst palette
-					|| srcPaletteCount != dstPaletteCount // palettes have different size
-					|| !memcmp(srcPalette, dstPalette, srcPaletteCount * 3)) { // palettes are different
+					|| (srcPaletteCount == dstPaletteCount // palettes are the same
+						&& !memcmp(srcPalette, dstPalette, srcPaletteCount * 3))) {
 				surface->copyFrom(*this);
 				return surface;
 			}


Commit: 699eb67daa70525722b5283026c3ac18333346c5
    https://github.com/scummvm/scummvm/commit/699eb67daa70525722b5283026c3ac18333346c5
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: Add observed 16-color Mac palette

The resource fork in the Director 4 projector has a 16-color palette
right next to the 256-color System - Mac one, and the colors seem to
match the default System 4 palette. Nevertheless, this palette appears
to be reasonably different (both in colors and ordering) from the one
actually used. Included is a palette determined empirically from
DOSBox screenshots.

Changed paths:
    engines/director/graphics-data.h


diff --git a/engines/director/graphics-data.h b/engines/director/graphics-data.h
index c0d2e6f30f4..081c93bf61d 100644
--- a/engines/director/graphics-data.h
+++ b/engines/director/graphics-data.h
@@ -89,13 +89,25 @@ static byte macPalette[768] = {
 	0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00,  // 252 (0xfc)
 };
 
-static byte mac16Palette[48] = {
+
+// Below is how the 16-color Mac palette is stored in the Director 4 for Windows resource fork 1:
+/* static byte mac16Palette[48] = {
 	0xff, 0xff, 0xff, 0xfc, 0xf3, 0x05, 0xff, 0x64, 0x02, 0xdd, 0x08, 0x06,  //   0 (0x00)
 	0xf2, 0x08, 0x84, 0x46, 0x00, 0xa5, 0x00, 0x00, 0xd4, 0x02, 0xab, 0xea,  //   4 (0x04)
 	0x1f, 0xb7, 0x14, 0x00, 0x64, 0x11, 0x56, 0x2c, 0x05, 0x90, 0x71, 0x3a,  //   8 (0x08)
 	0xc0, 0xc0, 0xc0, 0x80, 0x80, 0x80, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00,  //  12 (0x0c)
+}; */
+
+// Below is the palette that is actually expected to decode 4-bit images.
+// This was achieved by screenshot sampling; the actual storage is unknown.
+static byte mac16Palette[48] = {
+	0xff, 0xff, 0xff, 0xba, 0xba, 0xba, 0xff, 0xff, 0x00, 0x8a, 0x8a, 0x8a,  //   0 (0x00)
+	0x9a, 0xce, 0xff, 0x9a, 0x65, 0x31, 0x00, 0x9a, 0x00, 0x9a, 0xce, 0x00,  //   4 (0x04)
+	0xce, 0x00, 0xce, 0x9a, 0x00, 0x9a, 0xff, 0x00, 0x31, 0xff, 0x9a, 0x31,  //   8 (0x08)
+	0x00, 0x00, 0xef, 0x00, 0xff, 0xce, 0x65, 0x65, 0x65, 0x00, 0x00, 0x00,  //  12 (0x0c)
 };
 
+
 static byte rainbow16Palette[48] = {
 	0xff, 0xff, 0xff, 0x00, 0x0a, 0xff, 0x5f, 0x00, 0xff, 0xc5, 0x00, 0xff,  //   0 (0x00)
 	0xff, 0x00, 0xd2, 0xff, 0x00, 0x6c, 0xff, 0x00, 0x06, 0xff, 0x5f, 0x00,  //   4 (0x04)


Commit: 9fb41d82d1ef816f683e800d9acf191875384189
    https://github.com/scummvm/scummvm/commit/9fb41d82d1ef816f683e800d9acf191875384189
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: Add support for displaying 2-bit and 4-bit bitmaps

Changed paths:
    engines/director/castmember.cpp
    engines/director/director.h
    engines/director/graphics.cpp
    engines/director/images.cpp


diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 67098b44855..0b2a610ac50 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "graphics/macgui/macbutton.h"
+#include "graphics/surface.h"
 #include "image/image_decoder.h"
 #include "video/avi_decoder.h"
 #include "video/qt_decoder.h"
@@ -30,6 +31,7 @@
 #include "director/cursor.h"
 #include "director/channel.h"
 #include "director/movie.h"
+#include "director/score.h"
 #include "director/sprite.h"
 #include "director/sound.h"
 #include "director/window.h"
@@ -100,7 +102,7 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableRe
 	_pitch = 0;
 	_flags2 = 0;
 	_regX = _regY = 0;
-	_clut = kClutSystemMac;
+	_clut = 0;
 	_bitsPerPixel = 0;
 
 	if (version < kFileVer400) {
@@ -124,6 +126,9 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableRe
 		if (_pitch % 16)
 			_pitch += 16 - (_initialRect.width() % 16);
 
+		_pitch *= _bitsPerPixel;
+		_pitch >>= 3;
+
 	} else if (version >= kFileVer400 && version < kFileVer500) {
 		_flags1 = flags1;
 		_pitch = stream.readUint16();
@@ -153,9 +158,6 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableRe
 		if (_bitsPerPixel == 0)
 			_bitsPerPixel = 1;
 
-		if (_bitsPerPixel == 1)
-			_pitch *= 8;
-
 		int tail = 0;
 		byte buf[256];
 
@@ -219,8 +221,10 @@ BitmapCastMember::~BitmapCastMember() {
 	if (_img)
 		delete _img;
 
-	if (_ditheredImg)
+	if (_ditheredImg) {
+		_ditheredImg->free();
 		delete _ditheredImg;
+	}
 
 	if (_matte)
 		delete _matte;
@@ -241,6 +245,11 @@ Graphics::MacWidget *BitmapCastMember::createWidget(Common::Rect &bbox, Channel
 	int srcBpp = _img->getSurface()->format.bytesPerPixel;
 
 	const byte *pal = _img->getPalette();
+	if (_ditheredImg) {
+		_ditheredImg->free();
+		delete _ditheredImg;
+		_ditheredImg = nullptr;
+	}
 
 	if (dstBpp == 1) {
 		if (srcBpp > 1
@@ -255,6 +264,68 @@ Graphics::MacWidget *BitmapCastMember::createWidget(Common::Rect &bbox, Channel
 			_ditheredImg = _img->getSurface()->convertTo(g_director->_wm->_pixelformat, _img->getPalette(), _img->getPaletteColorCount(), g_director->_wm->getPalette(), g_director->_wm->getPaletteSize());
 
 			pal = g_director->_wm->getPalette();
+		} else {
+			// Convert indexed image to indexed palette
+			Movie *movie = g_director->getCurrentMovie();
+			Cast *cast = movie->getCast();
+			Score *score = movie->getScore();
+			// Get the current score palette
+			int currentPaletteId = score->resolvePaletteId(score->getCurrentPalette());
+			if (!currentPaletteId)
+				currentPaletteId = cast->_defaultPalette;
+			PaletteV4 *currentPalette = g_director->getPalette(currentPaletteId);
+			if (!currentPalette)
+				currentPalette = g_director->getPalette(kClutSystemMac);
+			// First, check if the palettes are different
+			switch (_bitsPerPixel) {
+			// 1bpp - this is preconverted to 0x00 and 0xff, change nothing.
+			case 1:
+				break;
+			// 2bpp - convert to nearest using the standard 2-bit palette.
+			case 2:
+				{
+					const PaletteV4 &srcPal = g_director->getLoaded4Palette();
+					_ditheredImg = _img->getSurface()->convertTo(g_director->_wm->_pixelformat, srcPal.palette, srcPal.length, currentPalette->palette, currentPalette->length, Graphics::kDitherNaive);
+				}
+				break;
+			// 4bpp - if using a builtin palette, use one of the corresponding 4-bit ones.
+			case 4:
+				{
+					const auto pals = g_director->getLoaded16Palettes();
+					// in D4 you aren't allowed to use custom palettes for 4-bit images, so uh...
+					// I guess default to the mac palette?
+					int palIndex = pals.contains(_clut) ? _clut : kClutSystemMac;
+					const PaletteV4 &srcPal = pals.getVal(palIndex);
+					_ditheredImg = _img->getSurface()->convertTo(g_director->_wm->_pixelformat, srcPal.palette, srcPal.length, currentPalette->palette, currentPalette->length, Graphics::kDitherNaive);
+				}
+				break;
+			// 8bpp - if using a different palette, convert using nearest colour matching
+			case 8:
+				if (_clut != currentPaletteId) {
+					const auto pals = g_director->getLoadedPalettes();
+					int palIndex = pals.contains(_clut) ? _clut : kClutSystemMac;
+					const PaletteV4 &srcPal = pals.getVal(palIndex);
+					_ditheredImg = _img->getSurface()->convertTo(g_director->_wm->_pixelformat, srcPal.palette, srcPal.length, currentPalette->palette, currentPalette->length, Graphics::kDitherNaive);
+				}
+				break;
+			default:
+				break;
+			}
+
+			// Finally, the first and last colours in the palette are special. No matter what the palette remap
+			// does, we need to scrub those to be the same.
+			if (_ditheredImg) {
+				const Graphics::Surface *src = _img->getSurface();
+				for (int y = 0; y < src->h; y++) {
+					for (int x = 0; x < src->w; x++) {
+						const int test = *(const byte *)src->getBasePtr(x, y);
+						if (test == 0 || test == (1 << _bitsPerPixel) - 1) {
+							*(byte *)_ditheredImg->getBasePtr(x, y) = test == 0 ? 0x00 : 0xff;
+						}
+					}
+				}
+			}
+
 		}
 	}
 
diff --git a/engines/director/director.h b/engines/director/director.h
index 7e4b34e6fb7..ef1ca7db74c 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -191,6 +191,8 @@ public:
 	void loadDefaultPalettes();
 
 	const Common::HashMap<int, PaletteV4> &getLoadedPalettes() { return _loadedPalettes; }
+	const Common::HashMap<int, PaletteV4> &getLoaded16Palettes() { return _loaded16Palettes; }
+	const PaletteV4 &getLoaded4Palette() { return _loaded4Palette; }
 
 	const Common::FSNode *getGameDataDir() const { return &_gameDataDir; }
 	const byte *getPalette() const { return _currentPalette; }
@@ -272,6 +274,8 @@ private:
 	PatternTile _builtinTiles[kNumBuiltinTiles];
 
 	Common::HashMap<int, PaletteV4> _loadedPalettes;
+	Common::HashMap<int, PaletteV4> _loaded16Palettes;
+	PaletteV4 _loaded4Palette;
 
 	Graphics::ManagedSurface *_surface;
 
diff --git a/engines/director/graphics.cpp b/engines/director/graphics.cpp
index 6987a0efb1e..63562becad9 100644
--- a/engines/director/graphics.cpp
+++ b/engines/director/graphics.cpp
@@ -113,6 +113,17 @@ void DirectorEngine::loadDefaultPalettes() {
 	_loadedPalettes[kClutNTSC] = PaletteV4(kClutNTSC, ntscPalette, 256);
 	_loadedPalettes[kClutMetallic] = PaletteV4(kClutMetallic, metallicPalette, 256);
 	_loadedPalettes[kClutSystemWin] = PaletteV4(kClutSystemWin, winPalette, 256);
+
+	_loaded16Palettes[kClutSystemMac] = PaletteV4(kClutSystemMac, mac16Palette, 16);
+	_loaded16Palettes[kClutRainbow] = PaletteV4(kClutRainbow, rainbow16Palette, 16);
+	_loaded16Palettes[kClutGrayscale] = PaletteV4(kClutGrayscale, grayscale16Palette, 16);
+	_loaded16Palettes[kClutPastels] = PaletteV4(kClutPastels, pastels16Palette, 16);
+	_loaded16Palettes[kClutVivid] = PaletteV4(kClutVivid, vivid16Palette, 16);
+	_loaded16Palettes[kClutNTSC] = PaletteV4(kClutNTSC, ntsc16Palette, 16);
+	_loaded16Palettes[kClutMetallic] = PaletteV4(kClutMetallic, metallic16Palette, 16);
+	_loaded16Palettes[kClutSystemWin] = PaletteV4(kClutSystemWin, win16Palette, 16);
+
+	_loaded4Palette = PaletteV4(kClutGrayscale, grayscale4Palette, 4);
 }
 
 PaletteV4 *DirectorEngine::getPalette(int id) {
diff --git a/engines/director/images.cpp b/engines/director/images.cpp
index a046bbc3184..2b8d572bc3f 100644
--- a/engines/director/images.cpp
+++ b/engines/director/images.cpp
@@ -120,15 +120,14 @@ BITDDecoder::BITDDecoder(int w, int h, uint16 bitsPerPixel, uint16 pitch, const
 	_pitch = pitch;
 	_version = version;
 
-	if (_pitch < w) {
-		warning("BITDDecoder: pitch is too small: %d < %d", _pitch, w);
+	int minPitch = ((w * bitsPerPixel) >> 3) + ((w * bitsPerPixel % 8) ? 1 : 0);
+	if (_pitch < minPitch) {
+		warning("BITDDecoder: pitch is too small (%d < %d), graphics will decode wrong", _pitch, minPitch);
 
-		_pitch = w;
+		_pitch = minPitch;
 	}
 
-	// HACK: Create a padded surface by adjusting w after create()
-	_surface->create(_pitch, h, g_director->_pixelformat);
-	_surface->w = w;
+	_surface->create(w, h, g_director->_pixelformat);
 
 	_palette = palette;
 
@@ -176,23 +175,8 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 	Common::Array<uint> pixels;
 	// If the stream has exactly the required number of bits for this image,
 	// we assume it is uncompressed.
-	// logic above does not fit the situation when _bitsPerPixel == 1, need to fix.
-	int bytesNeed = _surface->w * _surface->h * _bitsPerPixel / 8;
-	bool skipCompression = false;
-	if (_bitsPerPixel != 1) {
-		if (_version < kFileVer300) {
-			skipCompression = stream.size() >= bytesNeed;
-		} else if (_version < kFileVer400) {
-			// for D3, looks like it will round up the _surface->w to align 2
-			// not sure whether D2 will have the same logic.
-			// check lzone-mac data/r-c/tank.a-1 and lzone-mac data/r-a/station-b.01.
-			if (_surface->w & 1)
-				bytesNeed += _surface->h * _bitsPerPixel / 8;
-			skipCompression = stream.size() == bytesNeed;
-		}
-	}
 
-	if ((stream.size() == _pitch * _surface->h * _bitsPerPixel / 8) || skipCompression) {
+	if (stream.size() == (uint32)(_pitch * _surface->h)) {
 		debugC(6, kDebugImages, "Skipping compression");
 		for (int i = 0; i < stream.size(); i++) {
 			pixels.push_back((int)stream.readByte());
@@ -225,11 +209,11 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 		}
 	}
 
-	if (pixels.size() < (uint32)_surface->w * _surface->h * (_bitsPerPixel / 8)) {
-		int tail = (_surface->w * _surface->h * _bitsPerPixel / 8) - pixels.size();
+	if (pixels.size() < (uint32)(_pitch * _surface->h)) {
+		int tail = (_pitch * _surface->h) - pixels.size();
 
-		warning("BITDDecoder::loadStream(): premature end of stream (%d of %d pixels)",
-				pixels.size(), pixels.size() + tail);
+		warning("BITDDecoder::loadStream(): premature end of stream (srcSize: %d, targetSize: %d, expected: %d, w: %d, h: %d, pitch: %d, bitsPerPixel: %d)",
+				(int)stream.size(), pixels.size(), pixels.size() + tail, _surface->w, _surface->h, _pitch, _bitsPerPixel);
 
 		for (int i = 0; i < tail; i++)
 			pixels.push_back(0);
@@ -252,7 +236,7 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 				switch (_bitsPerPixel) {
 				case 1:
 					for (int c = 0; c < 8 && x < _surface->w; c++, x++) {
-						color = (pixels[(((y * _pitch) + x) / 8)] & (1 << (7 - c))) ? 0xff : 0x00;
+						color = (pixels[(y * _pitch) + (x >> 3)] & (1 << (7 - c))) ? 0xff : 0x00;
 						if (paletted) {
 							*((byte *)_surface->getBasePtr(x, y)) = color;
 						} else {
@@ -260,12 +244,32 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 						}
 					}
 					break;
-
+				case 2:
+					for (int c = 0; c < 4 && x < _surface->w; c++, x++) {
+						color = (pixels[(y * _pitch) + (x >> 2)] & (0x3 << (2 * (3 - c)))) >> (2 * (3 - c));
+						if (paletted) {
+							*((byte *)_surface->getBasePtr(x, y)) = color;
+						} else {
+							*((uint32 *)_surface->getBasePtr(x, y)) = g_director->transformColor(color);
+						}
+					}
+					break;
+				case 4:
+					for (int c = 0; c < 2 && x < _surface->w; c++, x++) {
+						color = (pixels[(y * _pitch) + (x >> 1)] & (0xf << (4 * (1 - c)))) >> (4 * (1 - c));
+						if (paletted) {
+							*((byte *)_surface->getBasePtr(x, y)) = color;
+						} else {
+							*((uint32 *)_surface->getBasePtr(x, y)) = g_director->transformColor(color);
+						}
+					}
+					break;
 				case 8:
 					// this calculation is wrong.. need a demo with colours.
 					if (paletted) {
-						*((byte *)_surface->getBasePtr(x, y)) = g_director->transformColor(pixels[(y * _surface->w) + x + (y * offset)]);
+						*((byte *)_surface->getBasePtr(x, y)) = pixels[(y * _surface->w) + x + (y * offset)];
 					} else {
+						// FIXME: this won't work if the palette for the image is not the current screen one
 						*((uint32 *)_surface->getBasePtr(x, y)) = g_director->transformColor(pixels[(y * _surface->w) + x + (y * offset)]);
 					}
 					x++;


Commit: bbc464a7bc950ce4860abc7bbd1dc26e5a16cd45
    https://github.com/scummvm/scummvm/commit/bbc464a7bc950ce4860abc7bbd1dc26e5a16cd45
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: Fix matte display for 1-bit images

Changed paths:
    engines/director/channel.cpp


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 4663233f359..0cf6231ebe2 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -162,7 +162,12 @@ const Graphics::Surface *Channel::getMask(bool forceMatte) {
 		// as they already have all non-enclosed white pixels transparent.
 		// Matte on text has a trivial enough effect to not worry about implementing.
 		if (_sprite->_cast->_type == kCastBitmap) {
-			return ((BitmapCastMember *)_sprite->_cast)->getMatte(bbox);
+			BitmapCastMember *bitmap = ((BitmapCastMember *)_sprite->_cast);
+			// 1-bit images only require a matte for the matte ink type
+			if (bitmap->_bitsPerPixel == 1 && _sprite->_ink != kInkTypeMatte) {
+				return nullptr;
+			}
+			return bitmap->getMatte(bbox);
 		} else {
 			return nullptr;
 		}


Commit: c5095c0e62917917ef69fcb0d60212727d7b102f
    https://github.com/scummvm/scummvm/commit/c5095c0e62917917ef69fcb0d60212727d7b102f
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: Fix several blend modes

Blend modes have been confirmed with visual inspection of a test card.

Fixes the end screens in Yaken Rodem.

Changed paths:
    engines/director/graphics.cpp


diff --git a/engines/director/graphics.cpp b/engines/director/graphics.cpp
index 63562becad9..7e9285ca5d0 100644
--- a/engines/director/graphics.cpp
+++ b/engines/director/graphics.cpp
@@ -352,14 +352,18 @@ void inkDrawPixel(int x, int y, int src, void *data) {
 										(~bSrc | bFor) & (bSrc | bBak));
 			}
 		} else {
-			*dst = src;
+			// Find the inverse of the colour and match it back to the palette if required
+			byte rSrc, gSrc, bSrc;
+			wm->decomposeColor<T>(src, rSrc, gSrc, bSrc);
+
+			*dst = wm->findBestColor(~rSrc, ~gSrc, ~bSrc);
 		}
 		break;
 	case kInkTypeTransparent:
-		*dst = p->applyColor ? (src & p->foreColor) | (*dst & ~src) : (*dst & ~src);
+		*dst = p->applyColor ? (~src | p->backColor) & (*dst | src) : *dst | src;
 		break;
 	case kInkTypeNotTrans:
-		*dst = p->applyColor ? (~src & p->foreColor) | (*dst & src) : (*dst & src);
+		*dst = p->applyColor ? (src | p->backColor) & (*dst | ~src) : (*dst | ~src);
 		break;
 	case kInkTypeReverse:
 		*dst ^= src;
@@ -368,10 +372,10 @@ void inkDrawPixel(int x, int y, int src, void *data) {
 		*dst ^= ~(src);
 		break;
 	case kInkTypeGhost:
-		*dst = p->applyColor ? (~src | p->backColor) & (*dst | src) : *dst | src;
+		*dst = p->applyColor ? (src & p->foreColor) | (*dst & ~src) : (*dst & ~src);
 		break;
 	case kInkTypeNotGhost:
-		*dst = p->applyColor ? (src | p->backColor) & (*dst | ~src) : (*dst | ~src);
+		*dst = p->applyColor ? (~src & p->foreColor) | (*dst & src) : (*dst & src);
 		break;
 		// Arithmetic ink types
 	default: {


Commit: 26fad071c079721e1c254c667d7691c4bf492072
    https://github.com/scummvm/scummvm/commit/26fad071c079721e1c254c667d7691c4bf492072
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: Read palette ID as signed int for D3

Changed paths:
    engines/director/frame.cpp


diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 35673c670a7..edcd3c0e165 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -161,7 +161,7 @@ void Frame::readChannels(Common::SeekableReadStreamEndian *stream, uint16 versio
 		}
 
 		// palette
-		_palette.paletteId = stream->readUint16();
+		_palette.paletteId = stream->readSint16();
 		// loop points for color cycling
 		_palette.firstColor = g_director->transformColor(stream->readByte() ^ 0x80);
 		_palette.lastColor = g_director->transformColor(stream->readByte() ^ 0x80);


Commit: a5ed3bc202b743ba7e00d1678e1f6a77532cc88e
    https://github.com/scummvm/scummvm/commit/a5ed3bc202b743ba7e00d1678e1f6a77532cc88e
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: Fix palette offset in BitmapCastMembers

When reading the palette ID from a BitmapCastMember, 0 or below
signifies a builtin palette and should be offset by -1. 1 or above
signifies a palette Cast ID.

Also make sure to compare like for like: a cast member ID needs to be
sent through resolvePaletteId to get the index in the actual palette
store.

Fixes palette swapping in the Lost Mind of Dr. Brain demo.

Changed paths:
    engines/director/castmember.cpp


diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 0b2a610ac50..39fb230ceae 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -116,7 +116,9 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableRe
 
 		if (_bytes & 0x8000) {
 			_bitsPerPixel = stream.readUint16();
-			_clut = stream.readSint16() - 1;
+			_clut = stream.readSint16();
+			if (_clut <= 0) // builtin palette
+				_clut -= 1;
 		} else {
 			_bitsPerPixel = 1;
 			_clut = kClutSystemMac;
@@ -144,7 +146,9 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableRe
 		if (stream.eos()) {
 			_bitsPerPixel = 0;
 		} else {
-			_clut = stream.readSint16() - 1;
+			_clut = stream.readSint16();
+			if (_clut <= 0) // builtin palette
+				_clut -= 1;
 			stream.readUint16();
 			/* uint16 unk1 = */ stream.readUint16();
 			stream.readUint16();
@@ -269,13 +273,16 @@ Graphics::MacWidget *BitmapCastMember::createWidget(Common::Rect &bbox, Channel
 			Movie *movie = g_director->getCurrentMovie();
 			Cast *cast = movie->getCast();
 			Score *score = movie->getScore();
-			// Get the current score palette
+			// Get the current score palette. Note that this is the ID of the palette in the list, not the cast member!
 			int currentPaletteId = score->resolvePaletteId(score->getCurrentPalette());
 			if (!currentPaletteId)
 				currentPaletteId = cast->_defaultPalette;
 			PaletteV4 *currentPalette = g_director->getPalette(currentPaletteId);
 			if (!currentPalette)
 				currentPalette = g_director->getPalette(kClutSystemMac);
+			int castPaletteId = score->resolvePaletteId(_clut);
+			if (!castPaletteId)
+				castPaletteId = cast->_defaultPalette;
 			// First, check if the palettes are different
 			switch (_bitsPerPixel) {
 			// 1bpp - this is preconverted to 0x00 and 0xff, change nothing.
@@ -294,16 +301,16 @@ Graphics::MacWidget *BitmapCastMember::createWidget(Common::Rect &bbox, Channel
 					const auto pals = g_director->getLoaded16Palettes();
 					// in D4 you aren't allowed to use custom palettes for 4-bit images, so uh...
 					// I guess default to the mac palette?
-					int palIndex = pals.contains(_clut) ? _clut : kClutSystemMac;
+					int palIndex = pals.contains(castPaletteId) ? castPaletteId : kClutSystemMac;
 					const PaletteV4 &srcPal = pals.getVal(palIndex);
 					_ditheredImg = _img->getSurface()->convertTo(g_director->_wm->_pixelformat, srcPal.palette, srcPal.length, currentPalette->palette, currentPalette->length, Graphics::kDitherNaive);
 				}
 				break;
 			// 8bpp - if using a different palette, convert using nearest colour matching
 			case 8:
-				if (_clut != currentPaletteId) {
+				if (castPaletteId != currentPaletteId) {
 					const auto pals = g_director->getLoadedPalettes();
-					int palIndex = pals.contains(_clut) ? _clut : kClutSystemMac;
+					int palIndex = pals.contains(castPaletteId) ? castPaletteId : kClutSystemMac;
 					const PaletteV4 &srcPal = pals.getVal(palIndex);
 					_ditheredImg = _img->getSurface()->convertTo(g_director->_wm->_pixelformat, srcPal.palette, srcPal.length, currentPalette->palette, currentPalette->length, Graphics::kDitherNaive);
 				}


Commit: f61e06a7520899f75a9a37de9dd184f7d062386c
    https://github.com/scummvm/scummvm/commit/f61e06a7520899f75a9a37de9dd184f7d062386c
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: Fix Score::getCurrentPalette()

Previously, this would return the palette for the current frame (if it
was specified). Real Director behaviour is to return the current
palette in use, i.e. taking into account changes made in previous
frames.

Changed paths:
    engines/director/score.cpp
    engines/director/score.h


diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 86bd3a88bfc..f8fd94c4dfe 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -100,7 +100,7 @@ Score::~Score() {
 }
 
 int Score::getCurrentPalette() {
-	return _frames[_currentFrame]->_palette.paletteId;
+	return _lastPalette;
 }
 
 int Score::resolvePaletteId(int id) {
@@ -533,6 +533,7 @@ void Score::renderFrame(uint16 frameId, RenderMode mode) {
 
 	if (!renderTransition(frameId)) {
 		bool skip = renderPrePaletteCycle(frameId, mode);
+		setLastPalette(frameId);
 		renderSprites(frameId, mode);
 		_window->render();
 		if (!skip)
@@ -560,6 +561,7 @@ bool Score::renderTransition(uint16 frameId) {
 		_window->_puppetTransition = nullptr;
 		return true;
 	} else if (currentFrame->_transType) {
+		setLastPalette(frameId);
 		_window->playTransition(frameId, currentFrame->_transDuration, currentFrame->_transArea, currentFrame->_transChunkSize, currentFrame->_transType, resolvePaletteId(currentFrame->_palette.paletteId));
 		return true;
 	} else {
@@ -707,7 +709,7 @@ bool Score::renderPrePaletteCycle(uint16 frameId, RenderMode mode) {
 	return false;
 }
 
-void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
+void Score::setLastPalette(uint16 frameId) {
 	if (_puppetPalette)
 		return;
 
@@ -721,8 +723,24 @@ void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
 	if (paletteChanged) {
 		_lastPalette = currentPalette;
 		_paletteTransitionIndex = 0;
+
+		// For color cycling mode, if there's a new palette, switch to it immediately
+//		if (_frames[frameId]->_palette.colorCycling)
+//			g_director->setPalette(resolvePaletteId(_lastPalette));
 	}
 
+}
+
+void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
+	if (_puppetPalette)
+		return;
+
+	// If the palette is defined in the frame and doesn't match
+	// the current one, set it
+	int currentPalette = _frames[frameId]->_palette.paletteId;
+	if (!currentPalette || !resolvePaletteId(currentPalette))
+		return;
+
 	// For palette cycling, the only thing that is checked is if
 	// the palette ID is the same. Different cycling configs with
 	// the same palette ID will persist any mutated state.
@@ -742,10 +760,6 @@ void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
 		int firstColor = _frames[frameId]->_palette.firstColor;
 		int lastColor = _frames[frameId]->_palette.lastColor;
 
-		// If we've just chosen this palette, set it immediately
-		if (paletteChanged)
-			g_director->setPalette(resolvePaletteId(currentPalette));
-
 		if (_frames[frameId]->_palette.overTime) {
 			// Do a single color step in one frame transition
 			g_director->shiftPalette(firstColor, lastColor, false);
diff --git a/engines/director/score.h b/engines/director/score.h
index dd9f7b21ae7..a36266ff3d4 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -112,6 +112,7 @@ public:
 	void renderFrame(uint16 frameId, RenderMode mode = kRenderModeNormal);
 	void renderSprites(uint16 frameId, RenderMode mode = kRenderModeNormal);
 	bool renderPrePaletteCycle(uint16 frameId, RenderMode mode = kRenderModeNormal);
+	void setLastPalette(uint16 frameId);
 	void renderPaletteCycle(uint16 frameId, RenderMode mode = kRenderModeNormal);
 	void renderCursor(Common::Point pos, bool forceUpdate = false);
 	void updateWidgets(bool hasVideoPlayback);
@@ -171,6 +172,7 @@ private:
 	uint16 _nextFrame;
 	int _currentLabel;
 	DirectorSound *_soundManager;
+	int _currentPalette;
 };
 
 } // End of namespace Director


Commit: fb4d1f3bfe1cdc618c9ffb20818b8f58f08a1d76
    https://github.com/scummvm/scummvm/commit/fb4d1f3bfe1cdc618c9ffb20818b8f58f08a1d76
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: Make bitmap color correction ignore color cycling operations

Fixes the logo sequence in Alice: An Interactive Museum.

Changed paths:
    engines/director/castmember.cpp
    engines/director/score.cpp
    engines/director/score.h


diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 39fb230ceae..ad15abed2c6 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -283,6 +283,10 @@ Graphics::MacWidget *BitmapCastMember::createWidget(Common::Rect &bbox, Channel
 			int castPaletteId = score->resolvePaletteId(_clut);
 			if (!castPaletteId)
 				castPaletteId = cast->_defaultPalette;
+
+			// Check if the palette is in the middle of a color fade event
+			bool isColorCycling = score->isPaletteColorCycling();
+
 			// First, check if the palettes are different
 			switch (_bitsPerPixel) {
 			// 1bpp - this is preconverted to 0x00 and 0xff, change nothing.
@@ -306,9 +310,9 @@ Graphics::MacWidget *BitmapCastMember::createWidget(Common::Rect &bbox, Channel
 					_ditheredImg = _img->getSurface()->convertTo(g_director->_wm->_pixelformat, srcPal.palette, srcPal.length, currentPalette->palette, currentPalette->length, Graphics::kDitherNaive);
 				}
 				break;
-			// 8bpp - if using a different palette, convert using nearest colour matching
+			// 8bpp - if using a different palette, and we're not doing a color cycling operation, convert using nearest colour matching
 			case 8:
-				if (castPaletteId != currentPaletteId) {
+				if (castPaletteId != currentPaletteId && !isColorCycling) {
 					const auto pals = g_director->getLoadedPalettes();
 					int palIndex = pals.contains(castPaletteId) ? castPaletteId : kClutSystemMac;
 					const PaletteV4 &srcPal = pals.getVal(palIndex);
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index f8fd94c4dfe..420ec5e266a 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -725,12 +725,16 @@ void Score::setLastPalette(uint16 frameId) {
 		_paletteTransitionIndex = 0;
 
 		// For color cycling mode, if there's a new palette, switch to it immediately
-//		if (_frames[frameId]->_palette.colorCycling)
-//			g_director->setPalette(resolvePaletteId(_lastPalette));
+		if (_frames[frameId]->_palette.colorCycling)
+			g_director->setPalette(resolvePaletteId(_lastPalette));
 	}
 
 }
 
+bool Score::isPaletteColorCycling() {
+	return _frames[_currentFrame]->_palette.colorCycling;
+}
+
 void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
 	if (_puppetPalette)
 		return;
diff --git a/engines/director/score.h b/engines/director/score.h
index a36266ff3d4..07953585b5e 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -113,6 +113,7 @@ public:
 	void renderSprites(uint16 frameId, RenderMode mode = kRenderModeNormal);
 	bool renderPrePaletteCycle(uint16 frameId, RenderMode mode = kRenderModeNormal);
 	void setLastPalette(uint16 frameId);
+	bool isPaletteColorCycling();
 	void renderPaletteCycle(uint16 frameId, RenderMode mode = kRenderModeNormal);
 	void renderCursor(Common::Point pos, bool forceUpdate = false);
 	void updateWidgets(bool hasVideoPlayback);


Commit: 7a3ce2ff5cf3052b0241dbc58514e08138cf7560
    https://github.com/scummvm/scummvm/commit/7a3ce2ff5cf3052b0241dbc58514e08138cf7560
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-10T13:41:53+01:00

Commit Message:
DIRECTOR: Don't render color cycling in few frames mode

Changed paths:
    engines/director/score.cpp


diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 420ec5e266a..f757da98467 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -769,6 +769,12 @@ void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
 			g_director->shiftPalette(firstColor, lastColor, false);
 			g_director->draw();
 		} else {
+			// Short circuit for few frames renderer
+			if (debugChannelSet(-1, kDebugFewFramesOnly)) {
+				g_director->setPalette(resolvePaletteId(currentPalette));
+				return;
+			}
+
 			// Do a full color cycle in one frame transition
 			int steps = lastColor - firstColor + 1;
 			for (int i = 0; i < _frames[frameId]->_palette.cycleCount; i++) {
@@ -858,8 +864,13 @@ void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
 			_paletteTransitionIndex++;
 			_paletteTransitionIndex %= frameCount;
 		} else {
-			// Do a full cycle in one frame transition
+			// Short circuit for few frames renderer
+			if (debugChannelSet(-1, kDebugFewFramesOnly)) {
+				g_director->setPalette(resolvePaletteId(currentPalette));
+				return;
+			}
 
+			// Do a full cycle in one frame transition
 			// For normal mode, we've already faded the palette in renderPrePaletteCycle
 			if (!_frames[frameId]->_palette.normal) {
 				byte *fadePal = nullptr;




More information about the Scummvm-git-logs mailing list