Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite RGBGFX in C++ #981

Merged
merged 118 commits into from
Jul 2, 2022
Merged

Rewrite RGBGFX in C++ #981

merged 118 commits into from
Jul 2, 2022

Commits on Jun 12, 2022

  1. Reimplement basic RGBGFX features in C++

    Currently missing from the old version:
    - `-f` ("fixing" the input image to be indexed)
    - `-m` (the code for detecting mirrored tiles is missing, but all of the
            "plumbing" is otherwise there)
    - `-C`
    - `-d`
    - `-x` (though I need to check the exact functionality the old one has)
    - Also the man page is still a draft and needs to be fleshed out
    
    More planned features are not implemented yet either:
    - Explicit palette spec
    - Better error messages, also error "images"
    - Better 8x16 support, as well as other "dedup unit" sizes
    - Support for arbitrary number of palettes & colors per palette
    - Other output formats (for example, a "full" palette map for "streaming"
      use cases like gb-open-world)
    - Quantization?
    
    Some things may also be bugged:
    - Transparency support
    - Tile offsets (not exposed yet)
    - Tile counts per bank (not exposed yet)
    
    ...and performance remains to be checked.
    We need to set up some tests, honestly.
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    ea69624 View commit details
    Browse the repository at this point in the history
  2. Switch clang-format to C++17

    Be consistent with what we settled on in code
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    723e52c View commit details
    Browse the repository at this point in the history
  3. Fix duplicated CGB color calculation in pal sorting

    And also the inverted alpha channel condition causing the wrong colors
    to be treated as transparent
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    8b36aa5 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f96cff0 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    8d6fdda View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    4e46e6b View commit details
    Browse the repository at this point in the history
  7. Fix compiling with Clang

    Force version.c to be compiled as C++ (bodge, will need a proper fix for `version.c`)
    Remove user-defined `ProtoPalette` assignment operator (same as default, anyway)
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    32aee3d View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    9bab36e View commit details
    Browse the repository at this point in the history
  9. Tag AssignedProtos iterator as forward

    That's what it actually is, oops
    (Required for `minmax_element`)
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    d999b68 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    5cf048b View commit details
    Browse the repository at this point in the history
  11. Fix unchecked narrowing conversion of tile IDs

    The conversion is OK because of the tile amount cap
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    da92a5e View commit details
    Browse the repository at this point in the history
  12. Print file paths in a platform-independent way

    Conversion may be unspecified, but Windows better do the right thing (or else.)
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    f2735f2 View commit details
    Browse the repository at this point in the history
  13. Use MinGW C++ compiler as well

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    c97e5fb View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    c8a0ccb View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    38b928d View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    65b5af1 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    03308bc View commit details
    Browse the repository at this point in the history
  18. Skip initializing the PNG pixel array

    We are about to set all of the pixels anyway
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    7c2df08 View commit details
    Browse the repository at this point in the history
  19. Correctly handle "multiple" overlap between proto-palettes

    As explained by the comment
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    75353ce View commit details
    Browse the repository at this point in the history
  20. Implement -C

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    372751d View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    d737fd8 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    28ce49b View commit details
    Browse the repository at this point in the history
  23. Optimize AssignedProtos::empty() to stop early

    Also allow counting an `AssignedProtos`'s number of proto-palettes
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    7e4cc10 View commit details
    Browse the repository at this point in the history
  24. Fully implement decanting step

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    484e9e7 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    7d51d9e View commit details
    Browse the repository at this point in the history
  26. Flesh out man page

    Describe current options, and add some TODOs for functionality to be implemented
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    dc58c88 View commit details
    Browse the repository at this point in the history
  27. Remove <filesystem>

    Should fix compilation with GCC before 9
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    0ae984a View commit details
    Browse the repository at this point in the history
  28. Change UseTab to ForIndentation

    This fixes many whitespace issues
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    f405dfc View commit details
    Browse the repository at this point in the history
  29. Revamp number parsing and remove <charconv>

    Support all intended formats and allow partial parsing
    <charconv> is not available in GCC 7
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    18c76d7 View commit details
    Browse the repository at this point in the history
  30. Explicitly specify queue template param

    GCC 7 fails to deduce the contained type
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    4241243 View commit details
    Browse the repository at this point in the history
  31. Set C++ compiler in CI as well

    Duh
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    7ff7be5 View commit details
    Browse the repository at this point in the history
  32. Avoid using transform_reduce

    Not available in libstdc++ 7, apparently
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    e16dcfe View commit details
    Browse the repository at this point in the history
  33. Use cinttypes instead of inttypes.h

    Fixes build on some compilers for some reason I fail to understand
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    672829d View commit details
    Browse the repository at this point in the history
  34. Fix Windows-breaking use of struct vs class

    MSVC's (broken) ABI breaks otherwise.
    What the f@!$#ck, Microsoft?
    (Thank you based Clang for warning, by the way.)
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    44c97de View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    15a0236 View commit details
    Browse the repository at this point in the history
  36. Implement -m

    Though none of the code involved has been tested in any capacity yet, lol
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    2d8a022 View commit details
    Browse the repository at this point in the history
  37. Remove old C headers

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    f4b0c21 View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    dfe8f6d View commit details
    Browse the repository at this point in the history
  39. Add different verbosity levels

    And also some ASCII art, perhaps?
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    9ada975 View commit details
    Browse the repository at this point in the history
  40. Parse base tile IDs

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    69ae8bc View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    04c3296 View commit details
    Browse the repository at this point in the history
  42. Parse bank capacities

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    c676843 View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    a2a1ae8 View commit details
    Browse the repository at this point in the history
  44. Implement max palette count

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    3b6ef78 View commit details
    Browse the repository at this point in the history
  45. Clean up palette packing a bit

    Rename a poorly-named attribute, and add a bunch of debug logging
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    eb35b3f View commit details
    Browse the repository at this point in the history
  46. Correct "is this palette empty?" function

    This notably caused decantation to delete non-empty palettes, which crashes
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    0e97539 View commit details
    Browse the repository at this point in the history
  47. Fix -TAP being non-functional

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    fca8a7c View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    8e1ae7d View commit details
    Browse the repository at this point in the history
  49. Configuration menu
    Copy the full SHA
    d80fc31 View commit details
    Browse the repository at this point in the history
  50. Implement transparency handling

    Though none of this has been tested so far...
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    39fc7bb View commit details
    Browse the repository at this point in the history
  51. Configuration menu
    Copy the full SHA
    093defe View commit details
    Browse the repository at this point in the history
  52. Make some style corrections

    Co-Authored-By: Rangi <[email protected]>
    ISSOtm and Rangi42 committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    3e33d99 View commit details
    Browse the repository at this point in the history
  53. Configuration menu
    Copy the full SHA
    4e5ba9e View commit details
    Browse the repository at this point in the history
  54. Record "seed" when generating images as well

    For reproducibility
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    11c1a3b View commit details
    Browse the repository at this point in the history
  55. Fix transparency handling

    Ensure that the color count is properly used, and that
    transparency is not counted as a color when packing palettes
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    9c16d72 View commit details
    Browse the repository at this point in the history
  56. Configuration menu
    Copy the full SHA
    4b06b4f View commit details
    Browse the repository at this point in the history
  57. Ignore tested sub-projects

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    02d20dc View commit details
    Browse the repository at this point in the history
  58. Rename convert to process

    More consistent with its "main" function's name
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    3cccf57 View commit details
    Browse the repository at this point in the history
  59. Implement "at-files" for RGBGFX

    Useful for persisting flags outside of the build system
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    22393a2 View commit details
    Browse the repository at this point in the history
  60. Clean up randtilegen

    Apply review comments
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    939e290 View commit details
    Browse the repository at this point in the history
  61. Implement preliminary version of "reverse" feature

    Not hooked to all RGBGFX flags yet, but good enough for most use cases
    (and as a base for future development, should I need to `reset --hard`.)
    
    TODOs marked appropriately.
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    0ba49ec View commit details
    Browse the repository at this point in the history
  62. Configuration menu
    Copy the full SHA
    4893f73 View commit details
    Browse the repository at this point in the history
  63. Configuration menu
    Copy the full SHA
    d0b6949 View commit details
    Browse the repository at this point in the history
  64. Handle processing errors appropriately

    Alter the return status accordingly, and print the error counts on exit
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    ef57cad View commit details
    Browse the repository at this point in the history
  65. Implement some external palette specs

    PSP, ACT, and ACO are complete
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    3fb2bc0 View commit details
    Browse the repository at this point in the history
  66. Switch from colon separators to semicolon

    As documented, oops
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    c2a0f75 View commit details
    Browse the repository at this point in the history
  67. Configuration menu
    Copy the full SHA
    1c7ef91 View commit details
    Browse the repository at this point in the history
  68. Configuration menu
    Copy the full SHA
    6f3fe36 View commit details
    Browse the repository at this point in the history
  69. Retire -f

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    4e0aba4 View commit details
    Browse the repository at this point in the history
  70. Document output formats

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    ed8d5b8 View commit details
    Browse the repository at this point in the history
  71. Configuration menu
    Copy the full SHA
    780581a View commit details
    Browse the repository at this point in the history
  72. Remove placeholder palette output format from -p

    This is now described in its own section
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    5dea29f View commit details
    Browse the repository at this point in the history
  73. Assert that row size is not null

    Silences some static analysis warning
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    af7591c View commit details
    Browse the repository at this point in the history
  74. Remove negative values in parseNumber checking

    Including removal of a dead & useless check.
    By the way, fuck integer promotion.
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    a1f39bd View commit details
    Browse the repository at this point in the history
  75. Configuration menu
    Copy the full SHA
    aacac11 View commit details
    Browse the repository at this point in the history
  76. Fix erroneous tabs in rgbgfx usage text

    Thanks @GreenAndEievui!
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    7066255 View commit details
    Browse the repository at this point in the history
  77. Configuration menu
    Copy the full SHA
    5b87ef3 View commit details
    Browse the repository at this point in the history
  78. Remove incorrect check for reversed image width

    That check was when the image width was in tiles, and another check right below
    is the correct equivalent for the new pixel-unit argument
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    5c6d40d View commit details
    Browse the repository at this point in the history
  79. Move randtilegen to test/gfx subdir

    It's tool-specific, so categorize it where it belongs
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    4a9d647 View commit details
    Browse the repository at this point in the history
  80. Make randtilegen report the file names it fails to open

    Which of the two is erroring out can be inferred from the file name,
    anyway.
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    b00ed27 View commit details
    Browse the repository at this point in the history
  81. Avoid initializing the PNG row

    It gets overwritten right after, and uncovers an error in the interlaced read
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    44b9373 View commit details
    Browse the repository at this point in the history
  82. Fix reading interlaced PNGs

    Either we let libpng handle the transform, or we don't.
    But make up your mind!
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    6287396 View commit details
    Browse the repository at this point in the history
  83. Report when an input "tile" contains too many colors

    Which otherwise trips a later assertion in debug mode (phew!)
    and crashes in release mode (oops)
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    080f31f View commit details
    Browse the repository at this point in the history
  84. Add rgbgfx test program

    Co-Authored-By: ISSOtm <[email protected]>
    evie-calico and ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    204668f View commit details
    Browse the repository at this point in the history
  85. Avoid sorting proto-palettes breaking mappings

    The sorting was performed without updating the mappings, which broke the world.
    We can instead sort the IDs as they are inserted into the packing queue,
    which should also be faster than moving the actual proto-pal objects around.
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    c23d27e View commit details
    Browse the repository at this point in the history
  86. Configuration menu
    Copy the full SHA
    829df4b View commit details
    Browse the repository at this point in the history
  87. Fix memory leak in test driver program

    Teeny tiny
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    95d0285 View commit details
    Browse the repository at this point in the history
  88. Fix ProtoPalette::compare

    Some disjoint sets were mistakenly reported not as such
    For example, {0} was considered to include {1}.
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    6fa68d1 View commit details
    Browse the repository at this point in the history
  89. Configuration menu
    Copy the full SHA
    1f14be1 View commit details
    Browse the repository at this point in the history
  90. Fix alpha channel checking in RGBGFX test driver

    Compare CGB colors only, including ignoring RGB components if alpha says
    the color is transparent
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    05e2ca6 View commit details
    Browse the repository at this point in the history
  91. Configuration menu
    Copy the full SHA
    8688a65 View commit details
    Browse the repository at this point in the history
  92. Fix grayscale sorting not setting palette size

    A black+white palette would turn into white+transparent, removing black pixels
    from the palette (the third slot would be empty, and the 4th slot be set directly)
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    d77bab0 View commit details
    Browse the repository at this point in the history
  93. Add RGBGFX tests

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    b86ca10 View commit details
    Browse the repository at this point in the history
  94. Configuration menu
    Copy the full SHA
    d25d124 View commit details
    Browse the repository at this point in the history
  95. Configuration menu
    Copy the full SHA
    3f55fcf View commit details
    Browse the repository at this point in the history
  96. Print RGBGFX test names

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    76a2ffb View commit details
    Browse the repository at this point in the history
  97. Configuration menu
    Copy the full SHA
    2b5e26c View commit details
    Browse the repository at this point in the history
  98. Configuration menu
    Copy the full SHA
    cd950d6 View commit details
    Browse the repository at this point in the history
  99. Ignore -b and -N when reversing without tilemap

    These offsets should only be applied to a tile ID read as input... but this ain't one!
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    501dbfc View commit details
    Browse the repository at this point in the history
  100. Allow testing RGBGFX with specific images as input

    No such tests yet, but the infrastructure will be there.
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    2f76bdb View commit details
    Browse the repository at this point in the history
  101. Add corrupted PNGs to check error handling

    This is not intended to test libpng as much as checking that
    we behave correctly if libpng gives us an error
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    c827328 View commit details
    Browse the repository at this point in the history
  102. Implement "palette map" output

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    da3b6f3 View commit details
    Browse the repository at this point in the history
  103. Configuration menu
    Copy the full SHA
    0c33716 View commit details
    Browse the repository at this point in the history
  104. Configuration menu
    Copy the full SHA
    6846238 View commit details
    Browse the repository at this point in the history
  105. Configuration menu
    Copy the full SHA
    157c29e View commit details
    Browse the repository at this point in the history
  106. Fix RGBGFX number parsing

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    1fb4654 View commit details
    Browse the repository at this point in the history
  107. Use an iterator zip

    Simplifies iterating over tiles and attributes at the same time
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    2f77a15 View commit details
    Browse the repository at this point in the history
  108. Implement bit flipping with a lookup table

    Should improve performance.
    This version is cooler, and also does not suffer from iteration limits
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    311a355 View commit details
    Browse the repository at this point in the history
  109. Configuration menu
    Copy the full SHA
    d60b754 View commit details
    Browse the repository at this point in the history
  110. Improve flag set generation of RGBGFX tests

    Less duplication = good
    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    0e64812 View commit details
    Browse the repository at this point in the history
  111. Configuration menu
    Copy the full SHA
    400eacf View commit details
    Browse the repository at this point in the history
  112. Configuration menu
    Copy the full SHA
    9573b54 View commit details
    Browse the repository at this point in the history
  113. Implement slicing input image

    ISSOtm committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    00345f1 View commit details
    Browse the repository at this point in the history
  114. Configuration menu
    Copy the full SHA
    bdfb864 View commit details
    Browse the repository at this point in the history
  115. Configuration menu
    Copy the full SHA
    afba692 View commit details
    Browse the repository at this point in the history

Commits on Jul 2, 2022

  1. Configuration menu
    Copy the full SHA
    82cbe52 View commit details
    Browse the repository at this point in the history
  2. Cancel -U option

    As it turns out, it is really difficult to implement, and can be dealt with later.
    ISSOtm committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    630c744 View commit details
    Browse the repository at this point in the history
  3. Update completion scripts

    Also correct minor blunders in the man page
    ISSOtm committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    577c3b3 View commit details
    Browse the repository at this point in the history