diff --git a/bin/demo1.bin b/bin/demo1.bin index ab5f0ea..38ffb19 100755 Binary files a/bin/demo1.bin and b/bin/demo1.bin differ diff --git a/bin/demo1_overclock.bin b/bin/demo1_overclock.bin new file mode 100755 index 0000000..7dde83b Binary files /dev/null and b/bin/demo1_overclock.bin differ diff --git a/bin/demo2.bin b/bin/demo2.bin index f34b198..ef25467 100755 Binary files a/bin/demo2.bin and b/bin/demo2.bin differ diff --git a/bin/demo2_overclock.bin b/bin/demo2_overclock.bin new file mode 100755 index 0000000..2da4b30 Binary files /dev/null and b/bin/demo2_overclock.bin differ diff --git a/bin/demo3.bin b/bin/demo3.bin index 9ec88dc..41b52ff 100755 Binary files a/bin/demo3.bin and b/bin/demo3.bin differ diff --git a/bin/demo3_overclock.bin b/bin/demo3_overclock.bin new file mode 100755 index 0000000..ec5127a Binary files /dev/null and b/bin/demo3_overclock.bin differ diff --git a/demo2.cpp b/demo2.cpp index dbac380..7f1bd61 100644 --- a/demo2.cpp +++ b/demo2.cpp @@ -1332,6 +1332,9 @@ int main() cFloor = 10; cCeiling = 10; + for (uint8_t i = 0; i < SUBSAMPLED_WIDTH; ++i) + zBuffer[i] = RCL_INFINITY; + player.setPositionSquare(0,5); player.mCamera.direction = 3 * RCL_UNITS_PER_SQUARE / 4; player.mCamera.height = RCL_CAMERA_COLL_HEIGHT_BELOW; diff --git a/demo3.cpp b/demo3.cpp index 9d5e818..f5d3d5a 100644 --- a/demo3.cpp +++ b/demo3.cpp @@ -473,7 +473,7 @@ uint16_t backgroundColumn = 0; ///< Precomputed background column. inline void pixelFunc(RCL_PixelInfo *pixel) { uint8_t color = 0; - int16_t intensity = 0; + uint8_t intensity = 0; if (pixel->isWall) { @@ -482,7 +482,7 @@ inline void pixelFunc(RCL_PixelInfo *pixel) intensity = pixel->depth / (RCL_UNITS_PER_SQUARE * 2) + ((pixel->hit.direction == 0 || pixel->hit.direction == 2) ? 4 : 0); - color = addIntensity(squareColors[pixel->hit.type],intensity); + color = plusIntensity(squareColors[pixel->hit.type],intensity); } else color = 30; @@ -492,7 +492,7 @@ inline void pixelFunc(RCL_PixelInfo *pixel) if (!pixel->isHorizon) { intensity = pixel->depth / RCL_UNITS_PER_SQUARE; - color = addIntensity(floorColors[(pixel->height / RCL_UNITS_PER_SQUARE) % FLOOR_COLORS],intensity); + color = plusIntensity(floorColors[(pixel->height / RCL_UNITS_PER_SQUARE) % FLOOR_COLORS],intensity); } else color = floorColors[0]; diff --git a/general.hpp b/general.hpp index 90c60bc..dd06ff5 100644 --- a/general.hpp +++ b/general.hpp @@ -200,22 +200,27 @@ void initPalette() /** Adds given intensity to a color. - - @param color input color - @param intensity intensity to add, can be negative, will be clamped - @return new color */ -inline uint8_t addIntensity(uint8_t color, int16_t intensity) +inline uint8_t addIntensity(uint8_t color, int8_t add) { - int16_t newValue = (color & 0b00001111) + intensity; // value as in HSV + uint8_t newValue = color + add; + + if ((newValue >> 4) == (color >> 4)) + return newValue; + else + return add > 0 ? (color | 0x0f) : 0; +} - if (newValue <= 0) - return 0; // black +static inline uint8_t plusIntensity(uint8_t color, uint8_t plus) +{ + uint8_t newValue = color + plus; + return ((newValue >> 4) == (color >> 4)) ? newValue : (color | 0x0f); +} - if (newValue >= 16) - newValue = 15; - - return (color & 0b11110000) | newValue; +static inline uint8_t minusIntensity(uint8_t color, uint8_t minus) +{ + uint8_t newValue = color - minus; + return ((newValue >> 4) == (color >> 4)) ? newValue : 0; } /** @@ -238,7 +243,7 @@ inline uint8_t sampleImage(const unsigned char *image, RCL_Unit x, RCL_Unit y) Draws a scaled sprite on screen in an optimized way. The sprite has to be square in resolution for that. */ -void inline drawSpriteSquare(const unsigned char *sprite, int16_t x, int16_t y, RCL_Unit depth, int16_t size, int16_t intensity) +static void inline drawSpriteSquare(const unsigned char *sprite, int16_t x, int16_t y, RCL_Unit depth, int16_t size, int16_t intensity) { if (size < 0 || size > 200 || // let's not mess up with the incoming array sprite[0] != sprite[1]) // only draw square sprites