diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-05-05 21:39:32 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-05-05 21:40:34 +0100 |
commit | ca551c1700cf982fe96388491a096b515365894f (patch) | |
tree | e40b9a95cb1f0169c553c19da4ff52c16e73035a /tr8as.c | |
parent | f10e1ea20cbadd151b20175f48ac902eac4ee0d7 (diff) | |
download | tr8vm-ca551c1700cf982fe96388491a096b515365894f.tar.gz tr8vm-ca551c1700cf982fe96388491a096b515365894f.zip |
Use the MSB of the index to mark a transparent color
Because we use 1 byte to store 4bpp, we don't need a mask and we can
encode a "transparent" color in the bits we don't use.
Diffstat (limited to 'tr8as.c')
-rw-r--r-- | tr8as.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -495,12 +495,11 @@ static uint8_t parse_incpng(As *as, char **c) goto exit_parseinc; } - /* TODO: mask */ - uint16_t addr = as->addr; uint8_t index; - /* map RGB values to the palette indexes */ + /* map RGB values to the palette indexes; + * any index over 15 is "transparent" with index 128 */ for (int i = 0; i < x * y * 3; i += 3) { for (index = 0; index < 16; index++) @@ -512,7 +511,7 @@ static uint8_t parse_incpng(As *as, char **c) break; } if (index == 16) - as->out[addr++] = 0; + as->out[addr++] = 128; } as->addr = addr; |