public static void superman_update_palette() {
        char[] palette_map = new char[32]; /* range of color table is 0-31 */

        int i;

        memset(palette_map, 0, sizeof(palette_map));

        /* Find colors used in the background tile plane */
        for (i = 0; i < 0x400; i += 0x40) {
            int i2;

            for (i2 = i; i2 < (i + 0x40); i2 += 2) {
                int tile;
                int color;

                color = 0;

                tile = supes_videoram.READ_WORD(0x800 + i2) & 0x3fff;
                if (tile != 0) {
                    color = supes_videoram.READ_WORD(0xc00 + i2) >> 11;
                }

                palette_map[color] |= Machine.gfx[0].pen_usage[tile];

            }
        }

        /* Find colors used in the sprite plane */
        for (i = 0x3fe; i >= 0; i -= 2) {
            int tile;
            int color;

            color = 0;

            tile = supes_videoram.READ_WORD(i) & 0x3fff;
            if (tile != 0) {
                color = supes_videoram.READ_WORD(0x400 + i) >> 11;
            }

            palette_map[color] |= Machine.gfx[0].pen_usage[tile];
        }

        /* Now tell the palette system about those colors */
        for (i = 0; i < 32; i++) {
            int usage = palette_map[i];
            int j;

            if (usage != 0) {
                palette_used_colors.write(i * 16 + 0, PALETTE_COLOR_TRANSPARENT);
                for (j = 1; j < 16; j++) {
                    if ((palette_map[i] & (1 << j)) != 0) {
                        palette_used_colors.write(i * 16 + j, PALETTE_COLOR_USED);
                    } else {
                        palette_used_colors.write(i * 16 + j, PALETTE_COLOR_UNUSED);
                    }
                }
            } else {
                memset(palette_used_colors, i * 16, PALETTE_COLOR_UNUSED, 16);
            }
        }

        palette_recalc();

    }