Skip to content

Commit

Permalink
Make blending work with RGB555.
Browse files Browse the repository at this point in the history
  • Loading branch information
bearoso committed Mar 7, 2019
1 parent aba8dc5 commit 58aa23b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#ifndef _GFX_H_
#define _GFX_H_

#include "port.h"

struct SGFX
{
uint16 *Screen;
Expand Down Expand Up @@ -146,13 +148,15 @@ extern struct SGFX GFX;
(((C1) ^ (C2)) & RGB_LOW_BITS_MASK))

#else

inline uint16 COLOR_ADD(uint16 C1, uint16 C2)
{
return ((brightness_cap[ (C1 >> 11) + (C2 >> 11) ] << 11) |
(brightness_cap[((C1 >> 6) & 0x1f) + ((C2 >> 6) & 0x1f)] << 6 ) |
(brightness_cap[ (C1 & 0x1f) + (C2 & 0x1f) ] ));
return ((brightness_cap[ (C1 >> RED_SHIFT_BITS) + (C2 >> RED_SHIFT_BITS) ] << RED_SHIFT_BITS) |
(brightness_cap[((C1 >> GREEN_SHIFT_BITS) & 0x1f) + ((C2 >> GREEN_SHIFT_BITS) & 0x1f)] << GREEN_SHIFT_BITS) |
(brightness_cap[ (C1 & 0x1f) + (C2 & 0x1f)] ));
}
#endif

#endif // GFX_MULTI_FORMAT

#define COLOR_SUB1_2(C1, C2) \
GFX.ZERO[(((C1) | RGB_HI_BITS_MASKx2) - \
Expand Down
8 changes: 8 additions & 0 deletions pixform.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ extern uint32 SPARE_RGB_BIT_MASK;
#define MAX_RED_RGB565 31
#define MAX_GREEN_RGB565 63
#define MAX_BLUE_RGB565 31
#define RED_SHIFT_BITS_RGB565 11
#define GREEN_SHIFT_BITS_RGB565 6
#define RED_LOW_BIT_MASK_RGB565 0x0800
#define GREEN_LOW_BIT_MASK_RGB565 0x0020
#define BLUE_LOW_BIT_MASK_RGB565 0x0001
Expand All @@ -69,6 +71,8 @@ extern uint32 SPARE_RGB_BIT_MASK;
#define MAX_RED_RGB555 31
#define MAX_GREEN_RGB555 31
#define MAX_BLUE_RGB555 31
#define RED_SHIFT_BITS_RGB555 10
#define GREEN_SHIFT_BITS_RGB555 5
#define RED_LOW_BIT_MASK_RGB555 0x0400
#define GREEN_LOW_BIT_MASK_RGB555 0x0020
#define BLUE_LOW_BIT_MASK_RGB555 0x0001
Expand Down Expand Up @@ -197,6 +201,8 @@ extern uint32 SPARE_RGB_BIT_MASK;
#define MAX_RED_D(F) CONCAT(MAX_RED_, F)
#define MAX_GREEN_D(F) CONCAT(MAX_GREEN_, F)
#define MAX_BLUE_D(F) CONCAT(MAX_BLUE_, F)
#define RED_SHIFT_BITS_D(F) CONCAT(RED_SHIFT_BITS_, F)
#define GREEN_SHIFT_BITS_D(F) CONCAT(GREEN_SHIFT_BITS_, F)
#define RED_LOW_BIT_MASK_D(F) CONCAT(RED_LOW_BIT_MASK_, F)
#define GREEN_LOW_BIT_MASK_D(F) CONCAT(GREEN_LOW_BIT_MASK_, F)
#define BLUE_LOW_BIT_MASK_D(F) CONCAT(BLUE_LOW_BIT_MASK_, F)
Expand All @@ -211,6 +217,8 @@ extern uint32 SPARE_RGB_BIT_MASK;
#define MAX_RED MAX_RED_D(PIXEL_FORMAT)
#define MAX_GREEN MAX_GREEN_D(PIXEL_FORMAT)
#define MAX_BLUE MAX_BLUE_D(PIXEL_FORMAT)
#define RED_SHIFT_BITS RED_SHIFT_BITS_D(PIXEL_FORMAT)
#define GREEN_SHIFT_BITS GREEN_SHIFT_BITS_D(PIXEL_FORMAT)
#define RED_LOW_BIT_MASK RED_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define GREEN_LOW_BIT_MASK GREEN_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define BLUE_LOW_BIT_MASK BLUE_LOW_BIT_MASK_D(PIXEL_FORMAT)
Expand Down

0 comments on commit 58aa23b

Please sign in to comment.