Skip to content

Support for custom CGA color overrides - #1794

Merged
johnnovak merged 19 commits into
mainfrom
jnovak/custom-cga-palette
Jul 20, 2022
Merged

johnnovak merged 19 commits into
mainfrom
jnovak/custom-cga-palette

Conversation

@johnnovak

@johnnovak johnnovak commented Jul 16, 2022 •

Copy link
Copy Markdown
Member

Overview

This change allows the user to redefine the interpretation of CGA/EGA RGBI colours. There are two main motivations for introducing the feature:

Emulate Amiga palettes

Amiga ports of Sierra and LucasArts games feature improved EGA-like palettes that better represent certain colours (e.g. skin tones). ScummVM has an option to use the Amiga palettes even in DOS versions of the supported games, and this was the primary motivation for adding the feature.

Emulate the actual colours you would see on CRT monitors

CGA and EGA cards had no DAC; they output the colour information via digital TTL signals. In a nutshell, the graphics adapter only output colour indices (from 0 to 15 in case of CGA or CGA-like modes), then the interpretation of colours was up to the monitor hardware. One notable difference was the interpretation of the brown colour at index 6: old monitors displayed it as dark yellow instead of brown, and Tandy monitors even had a "brown adjustment" potentiometer so the user could dial in the exact green channel level. The tandy preset emulates this behaviour.

Some CGA monitors had interesting quirks: the contrast control of the IBM 5133 monitor effectively controlled the dimming of the first 8 non-bright colours only; the upper 8 bright colours were left completely intact. Also, the interpretation of all colours were a bit different from the canonical CGA/EGA palette (as emulated by VGA cards). The ibm5153 preset emulates this archetypal CGA monitor

Lastly, sRGB standardisation wasn't a thing yet in the 80s and early 90s. The gamma levels and colour gamuts of CRT monitor models from different (or even the same) manufacturers were all over the place. The exact colours displayed by these monitors depended not just on how the monitor interpreted the digital RGBI colours in the circuitry, but also the gamma and colour reproduction of the CRT screen. It turns out that the measured colour output of these old monitors can be quite a bit nicer and less garish than just naively displaying the canonical emulated CGA palette on modern sRGB displays. The tandy-warm palette is a good example of this (and is my #1 favourite).

Limitations

Only 6-bit colour components are allowed because this was the least invasive way of adding the feature to the existing code. This is not a problem at all for emulating the Amiga palettes, as the original Amiga chipset used only 4-bit components. For emulating the actual measured output of a monitor this is a slight of a limitation, but given this is a relatively niche feature and 262k colours can still quite faithfully represent the colour output of these monitors, I don't think this would warrant an extensive refactorisation of the codebase just to support 8-bit per component overrides.

The colour overrides can only be set at startup. Again, support could be added to switch the palettes at runtime, but that would be quite a bit of work. I think we should do it in the future anyway once we have the long awaited OSD functionality in place but probably it can wait until then.

Examples

I suggest to open the images pairwise in two browser tabs, and switch between them to appreciate the differences.

Defender of the Crown

I'm really fond of tandy-warm. I've picked these colours off a camera capture of a real Tandy EGA monitor. This palette subdues all colours a little, making them a bit warmer and less radioactive. The difference is very noticeable on the green — a big improvement over the harsh greens you'd get with the default palette on modern sRGB displays.

default

dotc-3-default

dotc-1-default

dotc-4-default

tandy-warm

dotc-3-tandy-warm

dotc-1-tandy-warm

dotc-4-tandy-warm

Gold Rush!

The "Amigaish" colourscheme introduced by the Sarien AGI interpreter is a mix between EGA and Amiga/Apple IIgs colours. Notice how the sky has a more natural colour and the skin tones are much improved.

default

gold-rush-agi-amigaish

agi-amigaish

gold-rush-default

Maniac Mansion

The Amiga ports of EGA LucasArts games feature an improved palette that might be preferable to some. In particular, the characters portraits are not suffering from severe sunburn anymore...

default

maniac-default

scumm-amiga

maniac-scumm-amiga

Zak McKracken and the Alien Mindbenders Enhanced

The ibm5153 palette softens the EGA colours a little, and the colodore brings back those C64 memories. Now you can play the game with C64-like graphics and 3-channel Tandy music with no loading times!

default

zak-default

ibm5153 (contrast 80)

zak-ibm5153-c80

colodore

zak-colodore

@johnnovak
johnnovak requested review from Wengier and kcgen July 16, 2022 08:36
@johnnovak johnnovak changed the title Custom CGA colors Support for custom CGA colors overrides Jul 16, 2022
@johnnovak johnnovak changed the title Support for custom CGA colors overrides Support for custom CGA color overrides Jul 16, 2022
@lgtm-com

lgtm-com Bot commented Jul 16, 2022

Copy link
Copy Markdown

This pull request introduces 26 alerts when merging 79af68c into c4679e0 - view on LGTM.com

new alerts:

  • 25 for Local variable hides global variable
  • 1 for Comparison of narrow type with wide type in loop condition

@johnnovak
johnnovak requested a review from GranMinigun July 19, 2022 05:39
Comment thread src/ints/int10_modes.cpp Resolved
Comment thread src/ints/int10_modes.cpp Resolved
Comment thread src/ints/int10_modes.cpp Resolved
Comment thread src/ints/int10_modes.cpp Resolved
Comment thread src/ints/int10_modes.cpp Resolved
Comment thread src/gui/render.cpp Resolved
Comment thread src/gui/render.cpp Resolved
Comment thread src/ints/int10_modes.cpp Resolved
Comment thread src/ints/int10_modes.cpp Resolved
Comment thread src/ints/int10_modes.cpp Resolved
Comment thread src/ints/int10_modes.cpp Resolved
Comment thread src/ints/int10_modes.cpp Resolved
Comment thread src/ints/int10_modes.cpp Resolved
Comment thread src/ints/int10_modes.cpp Resolved
@johnnovak
johnnovak force-pushed the jnovak/custom-cga-palette branch from ce7b152 to fda4915 Compare July 20, 2022 03:15
@lgtm-com

lgtm-com Bot commented Jul 20, 2022

Copy link
Copy Markdown

This pull request introduces 26 alerts when merging fda4915 into f2b1855 - view on LGTM.com

new alerts:

  • 25 for Local variable hides global variable
  • 1 for Comparison of narrow type with wide type in loop condition

@lgtm-com

lgtm-com Bot commented Jul 20, 2022

Copy link
Copy Markdown

This pull request introduces 26 alerts when merging 39786af into f2b1855 - view on LGTM.com

new alerts:

  • 25 for Local variable hides global variable
  • 1 for Comparison of narrow type with wide type in loop condition

johnnovak added 11 commits July 20, 2022 17:30
The hardcoded monochrome text palettes seem to be wrong as they're not
using the "dark grey" (or "bright black") colour. The MDA specs clearly
state that four intensity levels were supported by the display adapter
(but not necessarily by all monitors) which include the "dark grey"
colour.

`VGA_ATTR_SetEGAMonitorPalette` generated the correct palette in MONO
mode (this is how an EGA card emulates the MDA mono text mode (07h)),
so we're changing the hardcoded `mono_text` palette to reflect that and
reference it.

The `mono_text_s3` palette has also been adjusted by an educated
guess; it's most likely correct.
@johnnovak
johnnovak force-pushed the jnovak/custom-cga-palette branch from 39786af to 2549b03 Compare July 20, 2022 07:32
@johnnovak

Copy link
Copy Markdown
Member Author

Thanks for the review @kcgen. Build all green & ready for merging, as far as I'm concerned.

@lgtm-com

lgtm-com Bot commented Jul 20, 2022

Copy link
Copy Markdown

This pull request introduces 26 alerts when merging 2549b03 into 2b95fd5 - view on LGTM.com

new alerts:

  • 25 for Local variable hides global variable
  • 1 for Comparison of narrow type with wide type in loop condition

@kcgen

kcgen commented Jul 20, 2022 •

Copy link
Copy Markdown
Contributor

Thanks for the review @kcgen. Build all green & ready for merging, as far as I'm concerned.

Oh, check out the LGTM scanner: #1794 (comment)

(It's catching some variable names shadowing global variables)

Use the 'view on lgtm' link, then expand the int10_modes diff, which will show the 26 lines highlighted in red.

@johnnovak

Copy link
Copy Markdown
Member Author

It's catching some variable names shadowing global variables

That global was a leftover I forgot about. Removed, should be fine now.

@kcgen
kcgen self-requested a review July 20, 2022 09:21

@kcgen kcgen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another really nice refinement, @johnnovak !

@johnnovak
johnnovak merged commit 651db64 into main Jul 20, 2022
@johnnovak johnnovak added the enhancement New feature or enhancement of existing features label Jul 20, 2022
@lgtm-com

lgtm-com Bot commented Jul 20, 2022

Copy link
Copy Markdown

This pull request introduces 21 alerts when merging b6268a2 into 2b95fd5 - view on LGTM.com

new alerts:

  • 20 for Local variable hides global variable
  • 1 for Comparison of narrow type with wide type in loop condition

@kcgen

kcgen commented Jul 20, 2022

Copy link
Copy Markdown
Contributor

Oh, looks like the LGTM warnings dropped from 26 to 21 after that last commit.

Do we still have those 21 left? (the CI actions can be a mit of a maze; sorry if I'm not seeing it!)

@johnnovak

Copy link
Copy Markdown
Member Author

Oh, looks like the LGTM warnings dropped from 26 to 21 after that last commit.

Do we still have those 21 left? (the CI actions can be a mit of a maze; sorry if I'm not seeing it!)

Sorry @kcgen, didn't see that before I merged. I'll raise a separate cleanup PR.

@kcgen
kcgen deleted the jnovak/custom-cga-palette branch July 30, 2022 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or enhancement of existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants