fixed render artifacts and possibble crashed related to it in graphicsBlitAtlasImage

This commit is contained in:
rgimad
2025-01-06 13:26:50 +03:00
parent b5dbcecfac
commit b9fa56512b
2 changed files with 9 additions and 16 deletions

BIN
dino

Binary file not shown.

View File

@@ -40,16 +40,7 @@ void graphicsInit() {
void graphicsBlitAtlasImage(int atlasX, int atlasY, int destX, int destY, int w, int h, bool center) {
// debug_printf("start graphicsBlitAtlasImage ax = %d ay = %d dx = %d dy = %d w = %d h = %d %x %x\n", atlasX, atlasY, destX, destY, w, h, screenImage, spriteAtlas);
// // asm_inline("int $3");
// if (destX < 0 || destY < 0) {
// return;
// }
// // assert(destX + w <= screenImage->Width && destY + h <= screenImage->Height);
// if (destX + w > screenImage->Width || destY + h > screenImage->Height) {
// return;
// }
// asm_inline("int $3");
int screen_width = (int)screenImage->Width;
int screen_height = (int)screenImage->Height;
@@ -64,26 +55,28 @@ void graphicsBlitAtlasImage(int atlasX, int atlasY, int destX, int destY, int w,
}
if (destX < 0) {
destX = 0;
atlasX -= destX;
w = destX + w;
destX = 0;
}
if (destX + w > screen_width) {
w = screen_width - destX;
}
if (destY < 0) {
destY = 0;
atlasY -= destY;
h = destY + h;
destY = 0;
}
if (destY + h > screen_height) {
h = screen_height - destY;
}
//printf("start graphicsBlitAtlasImage ax = %d ay = %d dx = %d dy = %d w = %d h = %d %x %x\n\n", atlasX, atlasY, destX, destY, w, h, screenImage, spriteAtlas);
if (w <= 0 || h <= 0) {
return;
}
// assert(destX + w <= screen_width && destY + h <= screen_height);
// assert(destX >= 0 && destY >= 0);
//printf("start graphicsBlitAtlasImage ax = %d ay = %d dx = %d dy = %d w = %d h = %d %x %x\n\n", atlasX, atlasY, destX, destY, w, h, screenImage, spriteAtlas);
// asm_inline("int $3");
/*unsigned char buf[512];