diff --git a/src/Sprites.cpp b/src/Sprites.cpp index 8b81ce3..d6860e7 100644 --- a/src/Sprites.cpp +++ b/src/Sprites.cpp @@ -148,10 +148,11 @@ void Sprites::drawBitmap(int16_t x, int16_t y, Arduboy2Base::sBuffer[ofs] = data; } if (yOffset != 0 && sRow < 7) { - data = Arduboy2Base::sBuffer[ofs + WIDTH]; - data &= (*((unsigned char *) (&mask_data) + 1)); - data |= (*((unsigned char *) (&bitmap_data) + 1)); - Arduboy2Base::sBuffer[ofs + WIDTH] = data; + const size_t index = static_cast(ofs + WIDTH); + data = Arduboy2Base::sBuffer[index]; + data &= (uint8_t)(mask_data >> 8); + data |= (uint8_t)(bitmap_data >> 8); + Arduboy2Base::sBuffer[index] = data; } ofs++; bofs++; @@ -170,7 +171,8 @@ void Sprites::drawBitmap(int16_t x, int16_t y, Arduboy2Base::sBuffer[ofs] |= (uint8_t)(bitmap_data); } if (yOffset != 0 && sRow < 7) { - Arduboy2Base::sBuffer[ofs + WIDTH] |= (*((unsigned char *) (&bitmap_data) + 1)); + const size_t index = static_cast(ofs + WIDTH); + Arduboy2Base::sBuffer[index] |= (uint8_t)(bitmap_data >> 8); } ofs++; bofs++; @@ -189,7 +191,8 @@ void Sprites::drawBitmap(int16_t x, int16_t y, Arduboy2Base::sBuffer[ofs] &= ~(uint8_t)(bitmap_data); } if (yOffset != 0 && sRow < 7) { - Arduboy2Base::sBuffer[ofs + WIDTH] &= ~(*((unsigned char *) (&bitmap_data) + 1)); + const size_t index = static_cast(ofs + WIDTH); + Arduboy2Base::sBuffer[index] &= ~(uint8_t)(bitmap_data >> 8); } ofs++; bofs++; @@ -223,10 +226,11 @@ void Sprites::drawBitmap(int16_t x, int16_t y, Arduboy2Base::sBuffer[ofs] = data; } if (yOffset != 0 && sRow < 7) { - data = Arduboy2Base::sBuffer[ofs + WIDTH]; - data &= (*((unsigned char *) (&mask_data) + 1)); - data |= (*((unsigned char *) (&bitmap_data) + 1)); - Arduboy2Base::sBuffer[ofs + WIDTH] = data; + const size_t index = static_cast(ofs + WIDTH); + data = Arduboy2Base::sBuffer[index]; + data &= (uint8_t)(mask_data >> 8); + data |= (uint8_t)(bitmap_data >> 8); + Arduboy2Base::sBuffer[index] = data; } ofs++; mask_ofs++; diff --git a/src/SpritesB.cpp b/src/SpritesB.cpp index 27924ae..5f7c1b9 100644 --- a/src/SpritesB.cpp +++ b/src/SpritesB.cpp @@ -159,10 +159,11 @@ void SpritesB::drawBitmap(int16_t x, int16_t y, Arduboy2Base::sBuffer[ofs] = data; } if (yOffset != 0 && sRow < 7) { - data = Arduboy2Base::sBuffer[ofs + WIDTH]; - data &= (*((unsigned char *) (&mask_data) + 1)); - data |= (*((unsigned char *) (&bitmap_data) + 1)); - Arduboy2Base::sBuffer[ofs + WIDTH] = data; + const size_t index = static_cast(ofs + WIDTH); + data = Arduboy2Base::sBuffer[index]; + data &= (uint8_t)(mask_data >> 8); + data |= (uint8_t)(bitmap_data >> 8); + Arduboy2Base::sBuffer[index] = data; } ofs++; mask_ofs += ofs_step;