├── .gitignore ├── .editorconfig ├── .clangd ├── app ├── shared │ ├── CMakeLists.txt │ ├── shared.hpp │ ├── usage.cpp │ ├── usage.hpp │ ├── xdgdirs.cpp │ ├── lineread.hpp │ ├── cfgload.hpp │ ├── cfgload.cpp │ ├── xdgdirs.hpp │ ├── filesys.hpp │ ├── shared.cpp │ ├── gfxdef_builder.hpp │ └── gfxdefman.hpp ├── png2chr │ ├── CMakeLists.txt │ ├── app.hpp.cfg │ ├── app.hpp │ ├── setup.hpp │ └── main.cpp ├── chr2png │ ├── CMakeLists.txt │ ├── app.hpp.cfg │ ├── app.hpp │ ├── setup.hpp │ └── main.cpp └── palview │ ├── CMakeLists.txt │ ├── app.hpp.cfg │ ├── app.hpp │ ├── main.cpp │ └── setup.hpp ├── lib └── chrgfx │ ├── image_types.hpp │ ├── gfxdef.cpp │ ├── chrgfx.hpp │ ├── imageformat_png.hpp │ ├── types.hpp │ ├── rgb_layout.cpp │ ├── gfxdef.hpp │ ├── chrconv.hpp │ ├── app.hpp │ ├── rgb_layout.hpp │ ├── app.hpp.cfg │ ├── paldef.cpp │ ├── CMakeLists.txt │ ├── palconv.hpp │ ├── builtin_defs.hpp │ ├── paldef.hpp │ ├── chrdef.cpp │ ├── colconv.hpp │ ├── imageformat_png.cpp │ ├── imaging.hpp │ ├── coldef.hpp │ ├── coldef.cpp │ ├── chrdef.hpp │ ├── utils.hpp │ ├── custom.hpp │ ├── utils.cpp │ ├── colconv.cpp │ ├── image.hpp │ ├── chrconv.cpp │ ├── custom.cpp │ ├── builtin_defs.cpp │ ├── palconv.cpp │ └── imaging.cpp ├── Doxyfile ├── LICENSE ├── .clang-format ├── CMakeLists.txt ├── graphics.md ├── share ├── gfxdefs └── README.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .cache/ 2 | .vscode/ 3 | build/ 4 | work 5 | docs/ 6 | **/src/app.hpp 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | end_of_line = lf 3 | insert_final_newline = true 4 | charset = utf-8 5 | trim_trailing_whitespace = true 6 | 7 | [*.{c,h,cpp,hpp}] 8 | indent_style = tab 9 | indent_size = 2 10 | -------------------------------------------------------------------------------- /.clangd: -------------------------------------------------------------------------------- 1 | CompileFlags: 2 | Add: [-xc++, -std=c++17, -Wall] 3 | Diagnostics: 4 | ClangTidy: 5 | Add: [performance*, modernize*] 6 | Remove: [modernize-use-trailing-return-type, modernize-avoid-c-arrays] 7 | CheckOptions: 8 | readability-identifier-naming.VariableCase: SnakeCase 9 | 10 | -------------------------------------------------------------------------------- /app/shared/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_library(PNG_LIB png) 2 | 3 | if(NOT PNG_LIB) 4 | message(FATAL_ERROR "libpng not found") 5 | endif() 6 | 7 | include(CheckIncludeFileCXX) 8 | check_include_file_cxx("png++/png.hpp" PNGPP_H) 9 | if(NOT PNGPP_H) 10 | message(FATAL_ERROR "png++ not found") 11 | endif() 12 | -------------------------------------------------------------------------------- /lib/chrgfx/image_types.hpp: -------------------------------------------------------------------------------- 1 | #include "image.hpp" 2 | 3 | /** 4 | These are convenience aliases to re-contextualize these types with terms that more commonly appear in applications 5 | likely to be used by chrgfx 6 | */ 7 | 8 | namespace chrgfx 9 | { 10 | 11 | using rgb_color = motoi::pixel_type::rgb; 12 | 13 | using pixel = motoi::pixel_type::index; 14 | 15 | using palette = motoi::color_map_8bpp; 16 | 17 | using image = motoi::image; 18 | 19 | } // namespace chrgfx 20 | -------------------------------------------------------------------------------- /lib/chrgfx/gfxdef.cpp: -------------------------------------------------------------------------------- 1 | #include "gfxdef.hpp" 2 | #ifdef DEBUG 3 | #include 4 | #endif 5 | 6 | using namespace std; 7 | 8 | namespace chrgfx 9 | { 10 | gfxdef::gfxdef(string id, string description) : 11 | m_id(std::move(id)), 12 | m_desc(std::move(description)) 13 | { 14 | #ifdef DEBUG 15 | cerr << "NEW GFXDEF: " << m_id << '\n'; 16 | #endif 17 | }; 18 | 19 | string const & gfxdef::id() const 20 | { 21 | return m_id; 22 | }; 23 | 24 | string const & gfxdef::desc() const 25 | { 26 | return m_desc; 27 | } 28 | 29 | } // namespace chrgfx -------------------------------------------------------------------------------- /Doxyfile: -------------------------------------------------------------------------------- 1 | # Doxyfile 1.8.13 2 | DOXYFILE_ENCODING = UTF-8 3 | PROJECT_NAME = chrgfx 4 | PROJECT_NUMBER = 1 5 | PROJECT_BRIEF = "A library with CLI utilities for converting tile (aka CHR) based graphics used in retro video games to and from PNG, with support for a wide range of hardware via external graphics definitions." 6 | OUTPUT_DIRECTORY = docs 7 | TAB_SIZE = 2 8 | USE_MDFILE_AS_MAINPAGE = ./README.md 9 | GENERATE_LATEX = NO 10 | GENERATE_HTML = YES 11 | RECURSIVE = YES 12 | 13 | INPUT = README.md chrgfx/inc 14 | FILE_PATTERNS = *.hpp *.cpp *.md 15 | ALIASES += "break=@warning \b BREAK: " 16 | -------------------------------------------------------------------------------- /lib/chrgfx/chrgfx.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file chrgfx.hpp 3 | * @author Damian Rogers / damian@motoi.pro 4 | * @copyright ©2022 Motoi Productions / Released under MIT License 5 | * @brief libchrgfx global include 6 | */ 7 | 8 | #ifndef __CHRGFX__CHRGFX_HPP 9 | #define __CHRGFX__CHRGFX_HPP 10 | 11 | #include "builtin_defs.hpp" 12 | #include "chrconv.hpp" 13 | #include "chrdef.hpp" 14 | #include "colconv.hpp" 15 | #include "coldef.hpp" 16 | #include "custom.hpp" 17 | #include "gfxdef.hpp" 18 | #include "image.hpp" 19 | #include "image_types.hpp" 20 | #include "imageformat_png.hpp" 21 | #include "imaging.hpp" 22 | #include "palconv.hpp" 23 | #include "paldef.hpp" 24 | #include "rgb_layout.hpp" 25 | #include "types.hpp" 26 | #include "utils.hpp" 27 | 28 | #endif -------------------------------------------------------------------------------- /lib/chrgfx/imageformat_png.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file imageformat_png.hpp 3 | * @author Damian Rogers / damian@motoi.pro 4 | * @copyright ©2022 Motoi Productions / Released under MIT License 5 | * @brief Functions for converting to/from PNG format 6 | */ 7 | 8 | #ifndef __CHRGFX__IMAGEFORMAT_PNG_HPP 9 | #define __CHRGFX__IMAGEFORMAT_PNG_HPP 10 | 11 | #include "image_types.hpp" 12 | #include "types.hpp" 13 | #include 14 | #include 15 | #include 16 | 17 | namespace chrgfx 18 | { 19 | image from_png(png::image const & png_image); 20 | 21 | png::image to_png(image const & basic_image, std::optional trns_index = std::nullopt); 22 | 23 | } // namespace chrgfx 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /app/png2chr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(png2chr 2 | DESCRIPTION "Convert PNG image input to encoded tile graphics" 3 | VERSION 2.0.0 4 | LANGUAGES CXX) 5 | 6 | add_executable(png2chr) 7 | 8 | target_include_directories(png2chr 9 | PRIVATE "${PROJECT_SOURCE_DIR}/../shared" 10 | PRIVATE "${PROJECT_SOURCE_DIR}/../../lib" 11 | ) 12 | 13 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/app.hpp.cfg" "${CMAKE_CURRENT_SOURCE_DIR}/app.hpp" ESCAPE_QUOTES) 14 | 15 | target_sources(png2chr 16 | PRIVATE 17 | main.cpp 18 | ${PROJECT_SOURCE_DIR}/../shared/cfgload.cpp 19 | ${PROJECT_SOURCE_DIR}/../shared/shared.cpp 20 | ${PROJECT_SOURCE_DIR}/../shared/usage.cpp 21 | ${PROJECT_SOURCE_DIR}/../shared/xdgdirs.cpp 22 | ) 23 | 24 | target_link_libraries(png2chr PRIVATE chrgfx) 25 | 26 | install(TARGETS png2chr RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) 27 | -------------------------------------------------------------------------------- /app/chr2png/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(chr2png 2 | DESCRIPTION "Convert encoded tile graphics to PNG image" 3 | VERSION 2.0.0 4 | LANGUAGES CXX) 5 | 6 | add_executable(chr2png) 7 | 8 | target_include_directories(chr2png 9 | PRIVATE "${PROJECT_SOURCE_DIR}/../shared" 10 | PRIVATE "${PROJECT_SOURCE_DIR}/../../lib" 11 | ) 12 | 13 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/app.hpp.cfg" "${CMAKE_CURRENT_SOURCE_DIR}/app.hpp" ESCAPE_QUOTES) 14 | 15 | target_sources(chr2png 16 | PRIVATE 17 | main.cpp 18 | ${PROJECT_SOURCE_DIR}/../shared/cfgload.cpp 19 | ${PROJECT_SOURCE_DIR}/../shared/shared.cpp 20 | ${PROJECT_SOURCE_DIR}/../shared/usage.cpp 21 | ${PROJECT_SOURCE_DIR}/../shared/xdgdirs.cpp 22 | ) 23 | 24 | target_link_libraries(chr2png PRIVATE chrgfx) 25 | 26 | 27 | 28 | install(TARGETS chr2png RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) 29 | -------------------------------------------------------------------------------- /lib/chrgfx/types.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file types.hpp 3 | * @author Motoi Productions (Damian Rogers damian@motoi.pro) 4 | * @brief Commonly used typedefs 5 | * 6 | * Updates: 7 | * 20200101 Initial 8 | */ 9 | 10 | #ifndef __MOTOI__TYPES_HPP 11 | #define __MOTOI__TYPES_HPP 12 | 13 | #include 14 | #include 15 | 16 | using uchar = unsigned char; 17 | using uint = unsigned int; 18 | using ushort = unsigned short; 19 | using ulong = unsigned long; 20 | 21 | using uint8 = uint8_t; 22 | using uint16 = uint16_t; 23 | using uint32 = uint32_t; 24 | 25 | using int8 = int8_t; 26 | using int16 = int16_t; 27 | using int32 = int32_t; 28 | 29 | using byte_t = uint8_t; 30 | using byte = byte_t; 31 | 32 | template 33 | using uptr = std::unique_ptr; 34 | template 35 | using sptr = std::shared_ptr; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /lib/chrgfx/rgb_layout.cpp: -------------------------------------------------------------------------------- 1 | #include "rgb_layout.hpp" 2 | 3 | using namespace std; 4 | 5 | namespace chrgfx 6 | { 7 | 8 | rgb_layout::rgb_layout(pair const & red, pair const & green, pair const & blue) : 9 | m_red(red), 10 | m_green(green), 11 | m_blue(blue) 12 | { 13 | } 14 | 15 | short rgb_layout::red_offset() const 16 | { 17 | return m_red.first; 18 | } 19 | 20 | uint rgb_layout::red_size() const 21 | { 22 | return m_red.second; 23 | } 24 | 25 | short rgb_layout::green_offset() const 26 | { 27 | return m_green.first; 28 | } 29 | 30 | uint rgb_layout::green_size() const 31 | { 32 | return m_green.second; 33 | } 34 | 35 | short rgb_layout::blue_offset() const 36 | { 37 | return m_blue.first; 38 | } 39 | 40 | uint rgb_layout::blue_size() const 41 | { 42 | return m_blue.second; 43 | } 44 | 45 | } // namespace chrgfx 46 | -------------------------------------------------------------------------------- /lib/chrgfx/gfxdef.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file gfxdef.hpp 3 | * @author Damian Rogers / damian@motoi.pro 4 | * @copyright ©2022 Motoi Productions / Released under MIT License 5 | * @brief Graphics format definition base class 6 | */ 7 | 8 | #ifndef __CHRGFX__GFXDEF_HPP 9 | #define __CHRGFX__GFXDEF_HPP 10 | 11 | #include 12 | 13 | namespace chrgfx 14 | { 15 | /** 16 | * @brief Abstract encoding class 17 | */ 18 | class gfxdef 19 | { 20 | protected: 21 | gfxdef(std::string id, std::string description = ""); 22 | 23 | std::string m_id; 24 | std::string m_desc; 25 | 26 | public: 27 | gfxdef(gfxdef &&) = default; 28 | gfxdef(gfxdef const &) = default; 29 | gfxdef & operator=(gfxdef const &) = default; 30 | gfxdef & operator=(gfxdef &&) = default; 31 | 32 | [[nodiscard]] std::string const & id() const; 33 | 34 | [[nodiscard]] std::string const & desc() const; 35 | }; 36 | 37 | } // namespace chrgfx 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /app/palview/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(palview 2 | DESCRIPTION "Visualize an encoded color palette" 3 | VERSION 1.0.0 4 | LANGUAGES CXX) 5 | 6 | add_executable(palview) 7 | 8 | target_include_directories(palview 9 | PRIVATE "${PROJECT_SOURCE_DIR}/../shared" 10 | PRIVATE "${PROJECT_SOURCE_DIR}/../../lib" 11 | ) 12 | 13 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/app.hpp.cfg" "${CMAKE_CURRENT_SOURCE_DIR}/app.hpp" ESCAPE_QUOTES) 14 | 15 | target_sources(palview 16 | PRIVATE 17 | app.hpp 18 | main.cpp 19 | ${PROJECT_SOURCE_DIR}/../shared/cfgload.cpp 20 | ${PROJECT_SOURCE_DIR}/../shared/filesys.hpp 21 | ${PROJECT_SOURCE_DIR}/../shared/gfxdef_builder.hpp 22 | ${PROJECT_SOURCE_DIR}/../shared/gfxdefman.hpp 23 | ${PROJECT_SOURCE_DIR}/../shared/shared.cpp 24 | ${PROJECT_SOURCE_DIR}/../shared/strutil.hpp 25 | ${PROJECT_SOURCE_DIR}/../shared/xdgdirs.cpp 26 | ${PROJECT_SOURCE_DIR}/../shared/usage.cpp 27 | ) 28 | 29 | target_link_libraries(palview PRIVATE chrgfx) 30 | 31 | install(TARGETS palview RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Damian Rogers 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /lib/chrgfx/chrconv.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file chrconv.hpp 3 | * @author Damian Rogers / damian@motoi.pro 4 | * @copyright ©2022 Motoi Productions / Released under MIT License 5 | * @brief Tile format conversion functions 6 | */ 7 | 8 | #ifndef __CHRGFX__CHRCONV_HPP 9 | #define __CHRGFX__CHRCONV_HPP 10 | 11 | #include "chrdef.hpp" 12 | #include "image_types.hpp" 13 | #include "types.hpp" 14 | 15 | namespace chrgfx 16 | { 17 | 18 | /** 19 | * @brief Encode a basic tile with the given tile definition 20 | * 21 | * @param chrdef Pointer to tile encoding definition 22 | * @param in_tile Pointer to input basic tile 23 | * @param out_tile Pointer to output encoded tile 24 | * 25 | */ 26 | void encode_chr(chrdef const & chrdef, pixel const * in_tile, byte_t * out_tile); 27 | 28 | /** 29 | * @brief Decode an encoded tile with the given tile definition 30 | * 31 | * @param chrdef Pointer to tile encoding definition 32 | * @param in_tile Pointer to input encoded tile 33 | * @param out_tile Pointer to output basic tile 34 | * 35 | */ 36 | void decode_chr(chrdef const & chrdef, byte_t const * in_tile, pixel * out_tile); 37 | 38 | } // namespace chrgfx 39 | 40 | #endif -------------------------------------------------------------------------------- /lib/chrgfx/app.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Damian R (damian@motoi.pro) 3 | * @brief 4 | * @version 3.0.1 5 | * 6 | * @copyright ©2017 Motoi Productions / Released under MIT License 7 | * 8 | */ 9 | 10 | #ifndef __MOTOI__APP_HPP 11 | #define __MOTOI__APP_HPP 12 | 13 | #include 14 | #include 15 | 16 | /* 17 | These values should be set within CMakeLists.txt 18 | */ 19 | namespace APP 20 | { 21 | static unsigned int const VERSION_MAJOR {3}; 22 | static unsigned int const VERSION_MINOR {0}; 23 | static unsigned int const VERSION_PATCH {1}; 24 | static char const * VERSION {"3.0.1"}; 25 | 26 | static char const * NAME {"chrgfx"}; 27 | static char const * COPYRIGHT {"©2017 Motoi Productions / Released under MIT License"}; 28 | static char const * CONTACT {"Damian R (damian@motoi.pro)"}; 29 | static char const * WEBSITE {"https://github.com/drojaazu"}; 30 | static char const * BRIEF {""}; 31 | 32 | std::string app_info() 33 | { 34 | std::stringstream ss; 35 | ss << APP::NAME << ' ' << APP::VERSION << '\n'; 36 | ss << APP::COPYRIGHT << '\n'; 37 | ss << APP::CONTACT << " / " << APP::WEBSITE << '\n'; 38 | 39 | return ss.str(); 40 | } 41 | 42 | } // namespace APP 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/chrgfx/rgb_layout.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rgb_layout.hpp 3 | * @author Damian Rogers / damian@motoi.pro 4 | * @copyright ©2022 Motoi Productions / Released under MIT License 5 | * @brief RGB color levels data layout 6 | */ 7 | 8 | #ifndef __CHRGFX__RGB_LAYOUT_HPP 9 | #define __CHRGFX__RGB_LAYOUT_HPP 10 | 11 | #include "types.hpp" 12 | #include 13 | 14 | using std::pair; 15 | 16 | namespace chrgfx 17 | { 18 | /** 19 | * @brief Defines the bit positions of RGB channel data 20 | * @note Positive shift values shift right; negative values shift left 21 | */ 22 | class rgb_layout 23 | { 24 | public: 25 | rgb_layout(pair const & red, pair const & green, pair const & blue); 26 | 27 | [[nodiscard]] short red_offset() const; 28 | 29 | [[nodiscard]] uint red_size() const; 30 | 31 | [[nodiscard]] short green_offset() const; 32 | 33 | [[nodiscard]] uint green_size() const; 34 | 35 | [[nodiscard]] short blue_offset() const; 36 | 37 | [[nodiscard]] uint blue_size() const; 38 | 39 | protected: 40 | pair m_red; 41 | pair m_green; 42 | pair m_blue; 43 | }; 44 | 45 | } // namespace chrgfx 46 | 47 | #endif -------------------------------------------------------------------------------- /app/chr2png/app.hpp.cfg: -------------------------------------------------------------------------------- 1 | /** 2 | * @author @PROJECT_CONTACT@ 3 | * @brief @PROJECT_DESCRIPTION@ 4 | * @version @PROJECT_VERSION@ 5 | * 6 | * @copyright @PROJECT_COPYRIGHT@ 7 | * 8 | */ 9 | 10 | #ifndef __MOTOI__APP_HPP 11 | #define __MOTOI__APP_HPP 12 | 13 | #include 14 | #include 15 | 16 | /* 17 | These values should be set within CMakeLists.txt 18 | */ 19 | namespace APP 20 | { 21 | static unsigned int const VERSION_MAJOR {@PROJECT_VERSION_MAJOR@}; 22 | static unsigned int const VERSION_MINOR {@PROJECT_VERSION_MINOR@}; 23 | static unsigned int const VERSION_PATCH {@PROJECT_VERSION_PATCH@}; 24 | static char const * VERSION {"@PROJECT_VERSION@"}; 25 | 26 | static char const * NAME {"@PROJECT_NAME@"}; 27 | static char const * COPYRIGHT {"@PROJECT_COPYRIGHT@"}; 28 | static char const * CONTACT {"@PROJECT_CONTACT@"}; 29 | static char const * WEBSITE {"@PROJECT_WEBSITE@"}; 30 | static char const * BRIEF {"@PROJECT_DESCRIPTION@"}; 31 | 32 | std::string app_info() 33 | { 34 | std::stringstream ss; 35 | ss << APP::NAME << ' ' << APP::VERSION << '\n'; 36 | ss << APP::COPYRIGHT << '\n'; 37 | ss << APP::CONTACT << " / " << APP::WEBSITE << '\n'; 38 | 39 | return ss.str(); 40 | } 41 | 42 | } // namespace APP 43 | #endif 44 | -------------------------------------------------------------------------------- /app/palview/app.hpp.cfg: -------------------------------------------------------------------------------- 1 | /** 2 | * @author @PROJECT_CONTACT@ 3 | * @brief @PROJECT_DESCRIPTION@ 4 | * @version @PROJECT_VERSION@ 5 | * 6 | * @copyright @PROJECT_COPYRIGHT@ 7 | * 8 | */ 9 | 10 | #ifndef __MOTOI__APP_HPP 11 | #define __MOTOI__APP_HPP 12 | 13 | #include 14 | #include 15 | 16 | /* 17 | These values should be set within CMakeLists.txt 18 | */ 19 | namespace APP 20 | { 21 | static unsigned int const VERSION_MAJOR {@PROJECT_VERSION_MAJOR@}; 22 | static unsigned int const VERSION_MINOR {@PROJECT_VERSION_MINOR@}; 23 | static unsigned int const VERSION_PATCH {@PROJECT_VERSION_PATCH@}; 24 | static char const * VERSION {"@PROJECT_VERSION@"}; 25 | 26 | static char const * NAME {"@PROJECT_NAME@"}; 27 | static char const * COPYRIGHT {"@PROJECT_COPYRIGHT@"}; 28 | static char const * CONTACT {"@PROJECT_CONTACT@"}; 29 | static char const * WEBSITE {"@PROJECT_WEBSITE@"}; 30 | static char const * BRIEF {"@PROJECT_DESCRIPTION@"}; 31 | 32 | std::string app_info() 33 | { 34 | std::stringstream ss; 35 | ss << APP::NAME << ' ' << APP::VERSION << '\n'; 36 | ss << APP::COPYRIGHT << '\n'; 37 | ss << APP::CONTACT << " / " << APP::WEBSITE << '\n'; 38 | 39 | return ss.str(); 40 | } 41 | 42 | } // namespace APP 43 | #endif 44 | -------------------------------------------------------------------------------- /app/png2chr/app.hpp.cfg: -------------------------------------------------------------------------------- 1 | /** 2 | * @author @PROJECT_CONTACT@ 3 | * @brief @PROJECT_DESCRIPTION@ 4 | * @version @PROJECT_VERSION@ 5 | * 6 | * @copyright @PROJECT_COPYRIGHT@ 7 | * 8 | */ 9 | 10 | #ifndef __MOTOI__APP_HPP 11 | #define __MOTOI__APP_HPP 12 | 13 | #include 14 | #include 15 | 16 | /* 17 | These values should be set within CMakeLists.txt 18 | */ 19 | namespace APP 20 | { 21 | static unsigned int const VERSION_MAJOR {@PROJECT_VERSION_MAJOR@}; 22 | static unsigned int const VERSION_MINOR {@PROJECT_VERSION_MINOR@}; 23 | static unsigned int const VERSION_PATCH {@PROJECT_VERSION_PATCH@}; 24 | static char const * VERSION {"@PROJECT_VERSION@"}; 25 | 26 | static char const * NAME {"@PROJECT_NAME@"}; 27 | static char const * COPYRIGHT {"@PROJECT_COPYRIGHT@"}; 28 | static char const * CONTACT {"@PROJECT_CONTACT@"}; 29 | static char const * WEBSITE {"@PROJECT_WEBSITE@"}; 30 | static char const * BRIEF {"@PROJECT_DESCRIPTION@"}; 31 | 32 | std::string app_info() 33 | { 34 | std::stringstream ss; 35 | ss << APP::NAME << ' ' << APP::VERSION << '\n'; 36 | ss << APP::COPYRIGHT << '\n'; 37 | ss << APP::CONTACT << " / " << APP::WEBSITE << '\n'; 38 | 39 | return ss.str(); 40 | } 41 | 42 | } // namespace APP 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/chrgfx/app.hpp.cfg: -------------------------------------------------------------------------------- 1 | /** 2 | * @author @PROJECT_CONTACT@ 3 | * @brief @PROJECT_DESCRIPTION@ 4 | * @version @PROJECT_VERSION@ 5 | * 6 | * @copyright @PROJECT_COPYRIGHT@ 7 | * 8 | */ 9 | 10 | #ifndef __MOTOI__APP_HPP 11 | #define __MOTOI__APP_HPP 12 | 13 | #include 14 | #include 15 | 16 | /* 17 | These values should be set within CMakeLists.txt 18 | */ 19 | namespace APP 20 | { 21 | static unsigned int const VERSION_MAJOR {@PROJECT_VERSION_MAJOR@}; 22 | static unsigned int const VERSION_MINOR {@PROJECT_VERSION_MINOR@}; 23 | static unsigned int const VERSION_PATCH {@PROJECT_VERSION_PATCH@}; 24 | static char const * VERSION {"@PROJECT_VERSION@"}; 25 | 26 | static char const * NAME {"@PROJECT_NAME@"}; 27 | static char const * COPYRIGHT {"@PROJECT_COPYRIGHT@"}; 28 | static char const * CONTACT {"@PROJECT_CONTACT@"}; 29 | static char const * WEBSITE {"@PROJECT_WEBSITE@"}; 30 | static char const * BRIEF {"@PROJECT_DESCRIPTION@"}; 31 | 32 | std::string app_info() 33 | { 34 | std::stringstream ss; 35 | ss << APP::NAME << ' ' << APP::VERSION << '\n'; 36 | ss << APP::COPYRIGHT << '\n'; 37 | ss << APP::CONTACT << " / " << APP::WEBSITE << '\n'; 38 | 39 | return ss.str(); 40 | } 41 | 42 | } // namespace APP 43 | #endif 44 | -------------------------------------------------------------------------------- /app/palview/app.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Damian R (damian@motoi.pro) 3 | * @brief Visualize an encoded color palette 4 | * @version 1.0.0 5 | * 6 | * @copyright ©2017 Motoi Productions / Released under MIT License 7 | * 8 | */ 9 | 10 | #ifndef __MOTOI__APP_HPP 11 | #define __MOTOI__APP_HPP 12 | 13 | #include 14 | #include 15 | 16 | /* 17 | These values should be set within CMakeLists.txt 18 | */ 19 | namespace APP 20 | { 21 | static unsigned int const VERSION_MAJOR {1}; 22 | static unsigned int const VERSION_MINOR {0}; 23 | static unsigned int const VERSION_PATCH {0}; 24 | static char const * VERSION {"1.0.0"}; 25 | 26 | static char const * NAME {"palview"}; 27 | static char const * COPYRIGHT {"©2017 Motoi Productions / Released under MIT License"}; 28 | static char const * CONTACT {"Damian R (damian@motoi.pro)"}; 29 | static char const * WEBSITE {"https://github.com/drojaazu"}; 30 | static char const * BRIEF {"Visualize an encoded color palette"}; 31 | 32 | std::string app_info() 33 | { 34 | std::stringstream ss; 35 | ss << APP::NAME << ' ' << APP::VERSION << '\n'; 36 | ss << APP::COPYRIGHT << '\n'; 37 | ss << APP::CONTACT << " / " << APP::WEBSITE << '\n'; 38 | 39 | return ss.str(); 40 | } 41 | 42 | } // namespace APP 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/chrgfx/paldef.cpp: -------------------------------------------------------------------------------- 1 | #include "paldef.hpp" 2 | 3 | using namespace std; 4 | 5 | namespace chrgfx 6 | { 7 | 8 | paldef::paldef(string const & id, 9 | uint const entry_datasize, 10 | uint const length, 11 | optional const datasize, 12 | string const & description) : 13 | gfxdef(id, description), 14 | m_length(length), 15 | m_entry_datasize(entry_datasize), 16 | m_entry_datasize_bytes(m_entry_datasize / 8 + (m_entry_datasize % 8 > 0 ? 1 : 0)), 17 | m_datasize(datasize ? datasize.value() : entry_datasize * length), 18 | m_datasize_bytes(m_datasize / 8 + (m_datasize % 8 > 0 ? 1 : 0)) {}; 19 | 20 | paldef::paldef(string const & id, uint const entry_datasize, uint const length, string const & description) : 21 | paldef(id, entry_datasize, length, std::nullopt, description) {}; 22 | 23 | uint paldef::length() const 24 | { 25 | return m_length; 26 | } 27 | 28 | uint paldef::entry_datasize() const 29 | { 30 | return m_entry_datasize; 31 | } 32 | 33 | uint paldef::entry_datasize_bytes() const 34 | { 35 | return m_entry_datasize_bytes; 36 | } 37 | 38 | uint paldef::datasize() const 39 | { 40 | return m_datasize; 41 | } 42 | 43 | uint paldef::datasize_bytes() const 44 | { 45 | return m_datasize_bytes; 46 | } 47 | 48 | } // namespace chrgfx -------------------------------------------------------------------------------- /app/shared/shared.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHRGFX__SHARED_SHARED_HPP 2 | #define CHRGFX__SHARED_SHARED_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "usage.hpp" 9 | 10 | // these are intentionally mutable 11 | extern std::string short_opts; 12 | extern std::vector