diff --git a/src/textures/bitmap.cpp b/src/textures/bitmap.cpp index 4da12b9c35..cf419d70da 100644 --- a/src/textures/bitmap.cpp +++ b/src/textures/bitmap.cpp @@ -185,96 +185,30 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in typedef void (*CopyFunc)(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf); +#define COPY_FUNCS(op) \ + { \ + iCopyColors, \ + iCopyColors, \ + iCopyColors, \ + iCopyColors, \ + iCopyColors, \ + iCopyColors, \ + iCopyColors, \ + iCopyColors, \ + iCopyColors \ + } static const CopyFunc copyfuncs[][9]={ - { - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors - }, - { - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors - }, - { - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors - }, - { - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors - }, - { - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors - }, - { - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors - }, - { - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors - }, - { - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors, - iCopyColors - }, + COPY_FUNCS(bCopy), + COPY_FUNCS(bBlend), + COPY_FUNCS(bAdd), + COPY_FUNCS(bSubtract), + COPY_FUNCS(bReverseSubtract), + COPY_FUNCS(bModulate), + COPY_FUNCS(bCopyAlpha), + COPY_FUNCS(bCopyNewAlpha), + COPY_FUNCS(bOverwrite) }; +#undef COPY_FUNCS //=========================================================================== // @@ -487,6 +421,7 @@ static const CopyPalettedFunc copypalettedfuncs[]= iCopyPaletted, iCopyPaletted, iCopyPaletted, + iCopyPaletted, iCopyPaletted }; diff --git a/src/textures/bitmap.h b/src/textures/bitmap.h index da039fd0f8..dc125bf87e 100644 --- a/src/textures/bitmap.h +++ b/src/textures/bitmap.h @@ -318,6 +318,7 @@ enum ECopyOp OP_REVERSESUBTRACT, OP_MODULATE, OP_COPYALPHA, + OP_COPYNEWALPHA, OP_OVERWRITE }; @@ -330,6 +331,13 @@ struct FCopyInfo fixed_t invalpha; }; +struct bOverwrite +{ + static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; } + static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } + static __forceinline bool ProcessAlpha0() { return true; } +}; + struct bCopy { static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; } @@ -337,11 +345,18 @@ struct bCopy static __forceinline bool ProcessAlpha0() { return false; } }; -struct bOverwrite +struct bCopyNewAlpha { static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; } + static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = (s*i->alpha) >> FRACBITS; } + static __forceinline bool ProcessAlpha0() { return false; } +}; + +struct bCopyAlpha +{ + static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; } static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } - static __forceinline bool ProcessAlpha0() { return true; } + static __forceinline bool ProcessAlpha0() { return false; } }; struct bBlend @@ -379,13 +394,5 @@ struct bModulate static __forceinline bool ProcessAlpha0() { return false; } }; -struct bCopyAlpha -{ - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; } - static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } - static __forceinline bool ProcessAlpha0() { return false; } -}; - - #endif diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index c1fc95492a..5799ad04ea 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -1180,7 +1180,7 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part, bool silent, i } else if (sc.Compare("style")) { - static const char *styles[] = {"copy", "translucent", "add", "subtract", "reversesubtract", "modulate", "copyalpha", NULL }; + static const char *styles[] = {"copy", "translucent", "add", "subtract", "reversesubtract", "modulate", "copyalpha", "copynewalpha", NULL }; sc.MustGetString(); part.op = sc.MustMatchString(styles); bComplex |= (part.op != OP_COPY);