joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.78k stars 381 forks source link

Convenient one-click "Dump Palette" command #4036

Closed robotjunkyard closed 1 year ago

robotjunkyard commented 1 year ago

Is your feature request related to a problem? Please describe.

Not really a problem, but I've lately been peeking at and collecting color palettes of various classic-era games over the last few weeks, especially 256-color games or close to it (320x200x256 DOS games, Super NES games, etc) as a matter of curiosity and learning whatever I can about how some games' designs worked within limitations like this.

What you want

Current video mode permitting, a menu command to dump the current indexed color palette into a file. Maybe as a raw text file of newline-separated hexadecimal numbers, or perhaps a color-indexed PNG file in which its picture is of the squares of all the captured palette's colors.

Describe alternatives you've considered

I tried the Screenshot command hoping it would dump the screenshot as a PNG file with indexed color (from tinkering around with GIMP, this is a supported option of the PNG format), but dosbox-x just outputs a regular full-color style PNG. This would also be a solution in lieu of a palette-specific dump command.

Additional information

I did search past issues for this, found it was previously discussed not as a feature request but as a question someone asked: https://github.com/joncampbell123/dosbox-x/issues/3025 . The two solutions in that issue involve either dropping into the debugger (so that's not a "one-click and I'm done" solution), and an Imagemagick command to slurp colors from a screenshot (which absolutely would not capture all 256 of the colors in their in-memory order).

Have you checked that no similar feature request(s) exist?

Code of Conduct & Contributing Guidelines

joncampbell123 commented 1 year ago

I suppose a snapshot mode could be added to represent exactly the video RAM and the final hardware palette following all translation through the pel mask, etc. as a PNG, and the bit depth could be done to match the video mode appropriately.

The snapshot will not capture any Demoscene-ish "copper" effects or Lemmings-like mid-frame palette changes though.

joncampbell123 commented 1 year ago

There is a "Capture raw screenshot" command now that includes the raw palette and raw pixels. It doesn't do all modes but it does do all of the graphics modes (why would you want a raw snapshot of text mode?).

The palette translated by the hardware is the PNG palette and the actual raw palette in hardware is stored as a custom 'oPAL' PNG chunk.

joncampbell123 commented 1 year ago

Of course another case the "raw screenshot" command doesn't support are SVGA 15/16/24/32bpp display modes, because those don't have a palette and they're translated to RGBX for normal screenshot anyway.