f4a399c0af25 — Laurens Holst 7 years ago
Edge/FaceEdge: Avoid divide for y-major edges.
2 files changed, 26 insertions(+), 0 deletions(-)

M src/Edge.asm
M src/FaceEdge.asm
M src/Edge.asm +13 -0
@@ 74,10 74,23 @@ Left:
 	ld (ix + Edge.super.render),Edge_RenderLeft & 0FFH
 	ld (ix + Edge.super.render + 1),Edge_RenderLeft >> 8
 Continue:
+	cp c
+	jr z,XYEqual
+	jr nc,XMajor
+YMajor:
+	ld (ix + Edge.stepx),0
+	ld (ix + Edge.dx),a
+	jr Continue2
+XYEqual:
+	ld (ix + Edge.stepx),1
+	ld (ix + Edge.dx),0
+	jr Continue2
+XMajor:
 	ld e,a
 	call Math_Divide8x8
 	ld (ix + Edge.stepx),a
 	ld (ix + Edge.dx),b
+Continue2:
 	xor a
 	srl c
 	sbc a,c

          
M src/FaceEdge.asm +13 -0
@@ 74,10 74,23 @@ Left:
 	ld (ix + FaceEdge.super.render),FaceEdge_RenderLeft & 0FFH
 	ld (ix + FaceEdge.super.render + 1),FaceEdge_RenderLeft >> 8
 Continue:
+	cp c
+	jr z,XYEqual
+	jr nc,XMajor
+YMajor:
+	ld (ix + FaceEdge.stepx),0
+	ld (ix + FaceEdge.dx),a
+	jr Continue2
+XYEqual:
+	ld (ix + FaceEdge.stepx),1
+	ld (ix + FaceEdge.dx),0
+	jr Continue2
+XMajor:
 	ld e,a
 	call Math_Divide8x8
 	ld (ix + FaceEdge.stepx),a
 	ld (ix + FaceEdge.dx),b
+Continue2:
 	xor a
 	srl c
 	sbc a,c