fixed render artifacts and possibble crashed related to it in graphicsBlitAtlasImage
This commit is contained in:
25
graphics.c
25
graphics.c
@@ -40,16 +40,7 @@ void graphicsInit() {
|
|||||||
void graphicsBlitAtlasImage(int atlasX, int atlasY, int destX, int destY, int w, int h, bool center) {
|
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);
|
// 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");
|
// 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;
|
|
||||||
// }
|
|
||||||
|
|
||||||
int screen_width = (int)screenImage->Width;
|
int screen_width = (int)screenImage->Width;
|
||||||
int screen_height = (int)screenImage->Height;
|
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) {
|
if (destX < 0) {
|
||||||
destX = 0;
|
atlasX -= destX;
|
||||||
w = destX + w;
|
w = destX + w;
|
||||||
|
destX = 0;
|
||||||
}
|
}
|
||||||
if (destX + w > screen_width) {
|
if (destX + w > screen_width) {
|
||||||
w = screen_width - destX;
|
w = screen_width - destX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destY < 0) {
|
if (destY < 0) {
|
||||||
destY = 0;
|
atlasY -= destY;
|
||||||
h = destY + h;
|
h = destY + h;
|
||||||
|
destY = 0;
|
||||||
}
|
}
|
||||||
if (destY + h > screen_height) {
|
if (destY + h > screen_height) {
|
||||||
h = screen_height - destY;
|
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);
|
//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);
|
||||||
// assert(destX >= 0 && destY >= 0);
|
|
||||||
|
|
||||||
// asm_inline("int $3");
|
// asm_inline("int $3");
|
||||||
/*unsigned char buf[512];
|
/*unsigned char buf[512];
|
||||||
|
Reference in New Issue
Block a user