public void writeToPalette(int address, int value) {
        address &= 0x1F;
        if (address == 0x10) {
            bgPalette[0] = (byte) value;
        } else if ((address & 0x10) != 0) {
            sprPalette[address & 0x0F] = (byte) value;
        } else {
            bgPalette[address & 0x0F] = (byte) value;
        }
    }