diff --git a/th01/formats/ptn.cpp b/th01/formats/ptn.cpp index 53e3304b..fad21105 100644 --- a/th01/formats/ptn.cpp +++ b/th01/formats/ptn.cpp @@ -57,15 +57,11 @@ ptn_error_t ptn_load_palette_show(int slot, const char *fn) arc_file_get(ptn->unused_zero); arc_file_get(ptn->planes); for(y = 0; y < PTN_H; y++) { - // Color #15 (1111) is always the transparent one, meaning that - // transparent dots are 1 in all 4 bitplanes. The alpha mask - // therefore simply is the negation of ANDing all bitplanes - // together. Nifty! - ptn->alpha[y] = ~( - ptn->planes.B[y] - & ptn->planes.R[y] - & ptn->planes.G[y] - & ptn->planes.E[y] + ptn->alpha[y] = ptn_alpha_from( + ptn->planes.B[y], + ptn->planes.R[y], + ptn->planes.G[y], + ptn->planes.E[y] ); } } diff --git a/th01/formats/ptn.hpp b/th01/formats/ptn.hpp index bf4c72d7..92444768 100644 --- a/th01/formats/ptn.hpp +++ b/th01/formats/ptn.hpp @@ -5,6 +5,18 @@ /// color #15. Can also be used to store the backgrounds of frequently updated /// VRAM regions, using the functions for raw allocation and VRAM snapping. +} + +// Color #15 (1111) is always the transparent one, meaning that transparent +// dots are 1 in all 4 bitplanes. The alpha mask therefore simply is the +// negation of ANDing all bitplanes together. Nifty! +template inline T ptn_alpha_from(T B, T R, T G, T E) +{ + return ~((B) & (R) & (G) & (E)); +} + +extern "C" { + #define PTN_W 32 #define PTN_H 32