High color palette detection fix

Palette entries with high colors combined with bold/underline/etc settings (eg h17,underline) would make register_palette_entry() throw an exception.