Skip to content

Commit ca396fc

Browse files
committed
Hotfix for division by zero exceptions in the soft graphics drivers.
1 parent ae277d2 commit ca396fc

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/Graphics_SoftFP.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,8 @@ static void DrawSprite2D(VertexFixed* V0, VertexFixed* V1, VertexFixed* V2) {
581581
int delTY = (FixedMul(V2->v, IntToFixed(curTexHeight)) >> FP_SHIFT) - begTY;
582582

583583
int width = maxX - minX, height = maxY - minY;
584+
if (width == 0) width == 1;
585+
if (height == 0) height == 1;
584586

585587
int fast = delTX == width && delTY == height &&
586588
(begTX + delTX < curTexWidth) &&

src/Graphics_SoftGPU.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ static void DrawSprite2D(Vertex* V0, Vertex* V1, Vertex* V2) {
401401
int delTY = (int)(V2->v * curTexHeight) - begTY;
402402

403403
int width = maxX - minX, height = maxY - minY;
404+
if (width == 0) width == 1;
405+
if (height == 0) height == 1;
404406

405407
int fast = delTX == width && delTY == height &&
406408
(begTX + delTX < curTexWidth ) &&

src/Graphics_SoftMin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ static void DrawSprite2D(Vertex* V0, Vertex* V1, Vertex* V2) {
388388
int delTY = (int)(V2->v * curTexHeight) - begTY;
389389

390390
int width = maxX - minX, height = maxY - minY;
391+
if (width == 0) width == 1;
392+
if (height == 0) height == 1;
391393

392394
int fast = delTX == width && delTY == height &&
393395
(begTX + delTX < curTexWidth ) &&

0 commit comments

Comments
 (0)