From 3b9820d75b79888c9a7382e397a33b12c4f1b63c Mon Sep 17 00:00:00 2001 From: Kenta Yoshimura Date: Mon, 8 Apr 2019 01:11:32 +0900 Subject: [PATCH] Use alwaysinline with COLOR functions in gfx.h, MATH functions in tile.cpp, and CachedTile class in tile.cpp. --- gfx.h | 12 ++++++------ tile.cpp | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gfx.h b/gfx.h index 818f376d..38bd796b 100644 --- a/gfx.h +++ b/gfx.h @@ -129,7 +129,7 @@ extern struct SGFX GFX; 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 GREEN_MASK = 0x1F << GREEN_SHIFT_BITS; @@ -147,7 +147,7 @@ struct COLOR_ADD 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) + (C2 & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + @@ -157,7 +157,7 @@ struct COLOR_ADD 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) | (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)] )); } - static uint16 fn1_2(uint16 C1, uint16 C2) + static alwaysinline uint16 fn1_2(uint16 C1, uint16 C2) { return COLOR_ADD::fn1_2(C1, C2); } @@ -177,7 +177,7 @@ struct COLOR_ADD_BRIGHTNESS 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 rb2 = C2 & (THIRD_COLOR_MASK | FIRST_COLOR_MASK); @@ -192,7 +192,7 @@ struct COLOR_SUB 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) - (C2 & RGB_REMOVE_LOW_BITS_MASK)) >> 1]; diff --git a/tile.cpp b/tile.cpp index 01a7ae7f..a45a0196 100644 --- a/tile.cpp +++ b/tile.cpp @@ -335,7 +335,7 @@ namespace { public: CachedTile(uint32 tile) : Tile(tile) {} - void GetCachedTile() + alwaysinline void GetCachedTile() { TileAddr = BG.TileAddress + ((Tile & 0x3ff) << BG.TileShift); 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; } - void SelectPalette() const + alwaysinline void SelectPalette() const { if (BG.DirectColourMode) { @@ -372,7 +372,7 @@ namespace { GFX.ScreenColors = GFX.ClipColors ? BlackColourMap : GFX.RealScreenColors; } - uint8* Ptr() const + alwaysinline uint8* Ptr() const { return pCache; } @@ -386,7 +386,7 @@ namespace { struct NOMATH { - static uint16 Calc(uint16 Main, uint16 Sub, uint8 SD) + static alwaysinline uint16 Calc(uint16 Main, uint16 Sub, uint8 SD) { return Main; } @@ -396,7 +396,7 @@ namespace { template 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); } @@ -408,7 +408,7 @@ namespace { template 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); } @@ -419,7 +419,7 @@ namespace { template 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::Calc(Main, Sub, SD) : (SD & 0x20) ? Op::fn1_2(Main, Sub) : Op::fn(Main, GFX.FixedColour); }