void checkPackets() { // 0xBD 0xE6


		if ((getByte(0) == 136)) {


			if ((bytesAvailable() >= 3) && (getByte(1) == 51)) {
				switch (getByte(2)) {
				case 1:
				case 2:
				case 15: {	// These are headers we can ignore (I hope)
					if (bytesAvailable() == 10) {
						consumeByte(10);
					}
					break;
				}

				case 4: { // This is a length header
					if (bytesAvailable() == 6) {
						dataSize = (getByte(5) << 8) + getByte(4);
						System.out.println("Data size set to " + dataSize);
						consumeByte(6);
					}
					break;
				}
				}
			}
		} else {
			// This bit is image data

			// Wait for a complete tile (16 bytes) before trying to process it
			if ((bytesAvailable() == 16) && (dataSize > 0))  {
				for (int offs = 0; offs < 8; offs++) {
					int b1 = getByte(offs * 2);
					int b2 = getByte(offs * 2 + 1);

					imageData[((tileY * 8 + offs) * IMAGE_WIDTH) + (tileX * 8) + 0] = palette[((b1 & 0x80) >> 6) + ((b2 & 0x80) >> 7)];
					imageData[((tileY * 8 + offs) * IMAGE_WIDTH) + (tileX * 8) + 1] = palette[((b1 & 0x40) >> 5) + ((b2 & 0x40) >> 6)];
					imageData[((tileY * 8 + offs) * IMAGE_WIDTH) + (tileX * 8) + 2] = palette[((b1 & 0x20) >> 4) + ((b2 & 0x20) >> 5)];
					imageData[((tileY * 8 + offs) * IMAGE_WIDTH) + (tileX * 8) + 3] = palette[((b1 & 0x10) >> 3) + ((b2 & 0x10) >> 4)];

					imageData[((tileY * 8 + offs) * IMAGE_WIDTH) + (tileX * 8) + 4] = palette[((b1 & 0x08) >> 2) + ((b2 & 0x08) >> 3)];
					imageData[((tileY * 8 + offs) * IMAGE_WIDTH) + (tileX * 8) + 5] = palette[((b1 & 0x04) >> 1) + ((b2 & 0x04) >> 2)];
					imageData[((tileY * 8 + offs) * IMAGE_WIDTH) + (tileX * 8) + 6] = palette[((b1 & 0x02) >> 0) + ((b2 & 0x02) >> 1)];
					imageData[((tileY * 8 + offs) * IMAGE_WIDTH) + (tileX * 8) + 7] = palette[((b1 & 0x01) << 1) + ((b2 & 0x01) >> 0)];

				}

				dataSize -= 16;

				tileX++;
				if (tileX == IMAGE_WIDTH >> 3) {
					tileX = 0;
					tileY++;

					if (tileY * 8 == IMAGE_HEIGHT - 8) {
						scrollImage();
						tileY--;
					}
				}

				consumeByte(16);
				source.newPixels();
				window.repaint();
			} else if (dataSize == 0) {
				consumeByte(1);
			}
		}

	}