Fix tonccpy missing last byte in DS mode

Cleanup in image.cpp is unrelated
This commit is contained in:
Pk11
2021-01-16 19:44:31 -06:00
parent 3fa981f04b
commit 3af2a29cfe
2 changed files with 7 additions and 6 deletions
+3 -4
View File
@@ -88,15 +88,14 @@ void Image::draw(int x, int y, bool top, int layer, bool copyPal) {
if(copyPal)
tonccpy((top ? BG_PALETTE : BG_PALETTE_SUB) + _palOfs, _palette.data(), _palette.size() * 2);
u8 *dst = (u8 *)bgGetGfxPtr(top ? layer : layer + 4);
int width = 256;
u8 *dst = (u8 *)bgGetGfxPtr(top ? layer : layer + 4) + y * 256 + x;
// If full width and X is 0, copy it all in one go
if(_width == width && x == 0) {
if(_width == 256 && x == 0) {
tonccpy(dst, _bitmap.data(), _width * _height);
} else {
for(int i = 0; i < _height; i++) {
tonccpy(dst + (y + i) * 256 + x, _bitmap.data() + i * _width, _width);
tonccpy(dst + i * 256, _bitmap.data() + i * _width, _width);
}
}
}
+4 -2
View File
@@ -70,8 +70,10 @@ void tonccpy(void *dst, const void *src, uint size) {
}
// Tail: 1 byte.
if(size & 1)
*dst16 = (*dst16 & ~0xFF) | *src8;
if(size & 1) {
*dst16 &= ~0xFF;
*dst16 |= *src8;
}
}
//# toncset.c