From 0f4edbabe1c7df6b6ca9f615eb8925efc68765d5 Mon Sep 17 00:00:00 2001 From: nytpu Date: Tue, 1 Dec 2020 10:24:51 -0700 Subject: [PATCH] migrated to sourcehut --- .gitignore | 2 -- README.md | 19 ++----------------- UNLICENSE | 24 ------------------------ main.c | 50 -------------------------------------------------- 4 files changed, 2 insertions(+), 93 deletions(-) delete mode 100644 .gitignore delete mode 100644 UNLICENSE delete mode 100644 main.c diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 0b853c3..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -rgb555conv -*.tar.gz diff --git a/README.md b/README.md index 78472ca..9ca08cd 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,6 @@ # rgb555conv - converts 24 bit color to 15 bit color I got tired of manually converting 24 bit hex colors (like `0xRRGGBB`) into 15 bit BGR555 colors (like `0b0BBBBBGGGGGRRRRR`) so I slapped this together to do -it for me. Be warned that the 4 character color it outputs is in BGR format -for use on the Game Boy Color and the Game Boy Advance instead of RGB. It also -outputs a 24 bit representation of the 15 bit color (still in `0xRRGGBB`) for -use in things like your sprite software. +it for me. -It outputs a rounded down and rounded up variant, it's up to you to look at it -and decide which you like, because they may differ significantly. - -Also, note that I do **NO** input checking beyond making sure that the color is -provided in the first place, so use weird inputs at your own risk. - -## compiling: - -``` -git clone https://tildegit.org/nytpu/rgb555conv.git -cd rgb555conv -gcc -Wall -pedantic -W -o rgb555conv main.c -``` +[Migrated to sourcehut, view the code here](https://git.sr.ht/~nytpu/rgb555conv) diff --git a/UNLICENSE b/UNLICENSE deleted file mode 100644 index 68a49da..0000000 --- a/UNLICENSE +++ /dev/null @@ -1,24 +0,0 @@ -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to diff --git a/main.c b/main.c deleted file mode 100644 index 7608267..0000000 --- a/main.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include -#include - -typedef struct { - uint8_t r; - uint8_t g; - uint8_t b; -} rgb888; - - -int main (int argc, char *argv[]) -{ - if (argc != 2) { - printf("Please provide a single 24 bit color of the format `0xRRGGBB` as input.\n"); - return 1; - } - - uint32_t in_888 = strtol(argv[1], NULL, 16); - - printf(" Input, 24 bit color, 6 char hex: #%06X\n\n", in_888); - - rgb888 split; - split.r = ((in_888 & 0x00FF0000) >> 16) & 0xF8; - split.g = ((in_888 & 0x0000FF00) >> 8) & 0xF8; - split.b = (in_888 & 0x000000FF) & 0xF8; - - rgb888 unrounded; - unrounded.r = split.r & 0xF0; - unrounded.g = split.g & 0xF0; - unrounded.b = split.b & 0xF0; - - rgb888 rounded; - rounded.r = unrounded.r | 8; - rounded.g = unrounded.g | 8; - rounded.b = unrounded.b | 8; - - int16_t rgb555 = ((split.b & 0xF8) << 7) | ((split.g & 0xF8) << 2) | (split.r >> 3); - int16_t rgb555_unrounded = ((unrounded.b & 0xF8) << 7) | ((unrounded.g & 0xF8) << 2) | (unrounded.r >> 3); - int16_t rgb555_rounded = ((rounded.b & 0xF8) << 7) | ((rounded.g & 0xF8) << 2) | (rounded.r >> 3); - - printf("Output, 15 bit color, 6 char hex, rounded down: #%06X\n", (uint32_t) ((split.r & 0xF8) << 16) | ((split.g & 0xF8) << 8) | (split.b & 0xF8)); - printf(" Output, 15 bit color, 6 char hex, unrounded: #%06X\n", (uint32_t) ((split.r & 0xF8) << 16) | ((split.g & 0xF8) << 8) | (split.b & 0xF8)); - printf(" Output, 15 bit color, 6 char hex, rounded up: #%06X\n", (uint32_t) ((rounded.r & 0xF8) << 16) | ((rounded.g & 0xF8) << 8) | (rounded.b & 0xF8)); - - printf("Output, 15 bit color, 4 char hex, rounded down: 0x%04X\n", rgb555_unrounded); - printf(" Output, 15 bit color, 4 char hex, unrounded: 0x%04X\n", rgb555); - printf(" Output, 15 bit color, 4 char hex, rounded up: 0x%04X\n", rgb555_rounded); - return 0; -}