Use alwaysinline with COLOR functions in gfx.h, MATH functions in tile.cpp, and CachedTile class in tile.cpp.

This commit is contained in:
Kenta Yoshimura 2019-04-08 01:11:32 +09:00
parent c71429c2b7
commit 3b9820d75b
2 changed files with 14 additions and 14 deletions

12
gfx.h
View File

@ -129,7 +129,7 @@ extern struct SGFX GFX;
struct COLOR_ADD struct COLOR_ADD
{ {
static uint16 fn(uint16 C1, uint16 C2) static alwaysinline uint16 fn(uint16 C1, uint16 C2)
{ {
const int RED_MASK = 0x1F << RED_SHIFT_BITS; const int RED_MASK = 0x1F << RED_SHIFT_BITS;
const int GREEN_MASK = 0x1F << GREEN_SHIFT_BITS; const int GREEN_MASK = 0x1F << GREEN_SHIFT_BITS;
@ -147,7 +147,7 @@ struct COLOR_ADD
return retval; return retval;
} }
static uint16 fn1_2(uint16 C1, uint16 C2) static alwaysinline uint16 fn1_2(uint16 C1, uint16 C2)
{ {
return ((((C1 & RGB_REMOVE_LOW_BITS_MASK) + return ((((C1 & RGB_REMOVE_LOW_BITS_MASK) +
(C2 & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + (C2 & RGB_REMOVE_LOW_BITS_MASK)) >> 1) +
@ -157,7 +157,7 @@ struct COLOR_ADD
struct COLOR_ADD_BRIGHTNESS struct COLOR_ADD_BRIGHTNESS
{ {
static uint16 fn(uint16 C1, uint16 C2) static alwaysinline uint16 fn(uint16 C1, uint16 C2)
{ {
return ((brightness_cap[ (C1 >> RED_SHIFT_BITS) + (C2 >> RED_SHIFT_BITS) ] << RED_SHIFT_BITS) | 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 >> GREEN_SHIFT_BITS) & 0x1f) + ((C2 >> GREEN_SHIFT_BITS) & 0x1f)] << GREEN_SHIFT_BITS) |
@ -168,7 +168,7 @@ struct COLOR_ADD_BRIGHTNESS
(brightness_cap[ (C1 & 0x1f) + (C2 & 0x1f)] )); (brightness_cap[ (C1 & 0x1f) + (C2 & 0x1f)] ));
} }
static uint16 fn1_2(uint16 C1, uint16 C2) static alwaysinline uint16 fn1_2(uint16 C1, uint16 C2)
{ {
return COLOR_ADD::fn1_2(C1, C2); return COLOR_ADD::fn1_2(C1, C2);
} }
@ -177,7 +177,7 @@ struct COLOR_ADD_BRIGHTNESS
struct COLOR_SUB struct COLOR_SUB
{ {
static uint16 fn(uint16 C1, uint16 C2) static alwaysinline uint16 fn(uint16 C1, uint16 C2)
{ {
int rb1 = (C1 & (THIRD_COLOR_MASK | FIRST_COLOR_MASK)) | ((0x20 << 0) | (0x20 << RED_SHIFT_BITS)); int rb1 = (C1 & (THIRD_COLOR_MASK | FIRST_COLOR_MASK)) | ((0x20 << 0) | (0x20 << RED_SHIFT_BITS));
int rb2 = C2 & (THIRD_COLOR_MASK | FIRST_COLOR_MASK); int rb2 = C2 & (THIRD_COLOR_MASK | FIRST_COLOR_MASK);
@ -192,7 +192,7 @@ struct COLOR_SUB
return retval; return retval;
} }
static uint16 fn1_2(uint16 C1, uint16 C2) static alwaysinline uint16 fn1_2(uint16 C1, uint16 C2)
{ {
return GFX.ZERO[((C1 | RGB_HI_BITS_MASKx2) - return GFX.ZERO[((C1 | RGB_HI_BITS_MASKx2) -
(C2 & RGB_REMOVE_LOW_BITS_MASK)) >> 1]; (C2 & RGB_REMOVE_LOW_BITS_MASK)) >> 1];

View File

@ -335,7 +335,7 @@ namespace {
public: public:
CachedTile(uint32 tile) : Tile(tile) {} CachedTile(uint32 tile) : Tile(tile) {}
void GetCachedTile() alwaysinline void GetCachedTile()
{ {
TileAddr = BG.TileAddress + ((Tile & 0x3ff) << BG.TileShift); TileAddr = BG.TileAddress + ((Tile & 0x3ff) << BG.TileShift);
if (Tile & 0x100) if (Tile & 0x100)
@ -356,12 +356,12 @@ namespace {
} }
} }
bool IsBlankTile() const alwaysinline bool IsBlankTile() const
{ {
return ((Tile & H_FLIP) ? BG.BufferedFlip[TileNumber] : BG.Buffered[TileNumber]) == BLANK_TILE; return ((Tile & H_FLIP) ? BG.BufferedFlip[TileNumber] : BG.Buffered[TileNumber]) == BLANK_TILE;
} }
void SelectPalette() const alwaysinline void SelectPalette() const
{ {
if (BG.DirectColourMode) if (BG.DirectColourMode)
{ {
@ -372,7 +372,7 @@ namespace {
GFX.ScreenColors = GFX.ClipColors ? BlackColourMap : GFX.RealScreenColors; GFX.ScreenColors = GFX.ClipColors ? BlackColourMap : GFX.RealScreenColors;
} }
uint8* Ptr() const alwaysinline uint8* Ptr() const
{ {
return pCache; return pCache;
} }
@ -386,7 +386,7 @@ namespace {
struct NOMATH struct NOMATH
{ {
static uint16 Calc(uint16 Main, uint16 Sub, uint8 SD) static alwaysinline uint16 Calc(uint16 Main, uint16 Sub, uint8 SD)
{ {
return Main; return Main;
} }
@ -396,7 +396,7 @@ namespace {
template<class Op> template<class Op>
struct REGMATH struct REGMATH
{ {
static uint16 Calc(uint16 Main, uint16 Sub, uint8 SD) static alwaysinline uint16 Calc(uint16 Main, uint16 Sub, uint8 SD)
{ {
return Op::fn(Main, (SD & 0x20) ? Sub : GFX.FixedColour); return Op::fn(Main, (SD & 0x20) ? Sub : GFX.FixedColour);
} }
@ -408,7 +408,7 @@ namespace {
template<class Op> template<class Op>
struct MATHF1_2 struct MATHF1_2
{ {
static uint16 Calc(uint16 Main, uint16 Sub, uint8 SD) static alwaysinline uint16 Calc(uint16 Main, uint16 Sub, uint8 SD)
{ {
return GFX.ClipColors ? Op::fn(Main, GFX.FixedColour) : Op::fn1_2(Main, GFX.FixedColour); return GFX.ClipColors ? Op::fn(Main, GFX.FixedColour) : Op::fn1_2(Main, GFX.FixedColour);
} }
@ -419,7 +419,7 @@ namespace {
template<class Op> template<class Op>
struct MATHS1_2 struct MATHS1_2
{ {
static uint16 Calc(uint16 Main, uint16 Sub, uint8 SD) static alwaysinline uint16 Calc(uint16 Main, uint16 Sub, uint8 SD)
{ {
return GFX.ClipColors ? REGMATH<Op>::Calc(Main, Sub, SD) : (SD & 0x20) ? Op::fn1_2(Main, Sub) : Op::fn(Main, GFX.FixedColour); return GFX.ClipColors ? REGMATH<Op>::Calc(Main, Sub, SD) : (SD & 0x20) ? Op::fn1_2(Main, Sub) : Op::fn(Main, GFX.FixedColour);
} }