0d5cd8a87fd0 — Laurens Holst 6 years ago
Edge/FaceEdge: Pass span end coordinate to the material as well.
2 files changed, 44 insertions(+), 44 deletions(-)

M src/Edge.asm
M src/FaceEdge.asm
M src/Edge.asm +22 -22
@@ 149,6 149,17 @@ Loop:
 Edge_Render: PROC
 	ld d,(ix + Edge.x)
 	ld b,(ix + Edge.z)
+	ld a,(ix + Edge.x)
+	add a,(ix + Edge.stepx)
+	ld e,a
+	ld a,(ix + Edge.error)
+	add a,(ix + Edge.dx)
+	jr nc,NoOverflow
+	inc e
+	sub (ix + Edge.dy)
+NoOverflow:
+	ld (ix + Edge.error),a
+	ld (ix + Edge.x),e
 	push ix
 	ld a,(ix + Edge.material)
 	ld c,(ix + Edge.material + 1)

          
@@ 156,17 167,6 @@ Edge_Render: PROC
 	ld ixh,c
 	call Material_RenderPoint
 	pop ix
-	ld a,(ix + Edge.x)
-	add a,(ix + Edge.stepx)
-	ld c,a
-	ld a,(ix + Edge.error)
-	add a,(ix + Edge.dx)
-	jr nc,NoOverflow
-	inc c
-	sub (ix + Edge.dy)
-NoOverflow:
-	ld (ix + Edge.error),a
-	ld (ix + Edge.x),c
 	dec (ix + Edge.height)
 	jp nz,Renderable_Advance
 	jp Renderable_Next

          
@@ 177,6 177,17 @@ NoOverflow:
 Edge_RenderLeft: PROC
 	ld d,(ix + Edge.x)
 	ld b,(ix + Edge.z)
+	ld a,(ix + Edge.x)
+	sub (ix + Edge.stepx)
+	ld e,a
+	ld a,(ix + Edge.error)
+	add a,(ix + Edge.dx)
+	jr nc,NoOverflow
+	dec e
+	sub (ix + Edge.dy)
+NoOverflow:
+	ld (ix + Edge.error),a
+	ld (ix + Edge.x),e
 	push ix
 	ld a,(ix + Edge.material)
 	ld c,(ix + Edge.material + 1)

          
@@ 184,17 195,6 @@ Edge_RenderLeft: PROC
 	ld ixh,c
 	call Material_RenderPoint
 	pop ix
-	ld a,(ix + Edge.x)
-	sub (ix + Edge.stepx)
-	ld c,a
-	ld a,(ix + Edge.error)
-	add a,(ix + Edge.dx)
-	jr nc,NoOverflow
-	dec c
-	sub (ix + Edge.dy)
-NoOverflow:
-	ld (ix + Edge.error),a
-	ld (ix + Edge.x),c
 	dec (ix + Edge.height)
 	jp nz,Renderable_Advance
 	jp Renderable_Next

          
M src/FaceEdge.asm +22 -22
@@ 152,6 152,17 @@ Loop:
 FaceEdge_Render: PROC
 	ld d,(ix + FaceEdge.x)
 	ld b,(ix + FaceEdge.z)
+	ld a,(ix + FaceEdge.x)
+	add a,(ix + FaceEdge.stepx)
+	ld e,a
+	ld a,(ix + FaceEdge.error)
+	add a,(ix + FaceEdge.dx)
+	jr nc,NoOverflow
+	inc e
+	sub (ix + FaceEdge.dy)
+NoOverflow:
+	ld (ix + FaceEdge.error),a
+	ld (ix + FaceEdge.x),e
 	push ix
 	ld a,(ix + FaceEdge.face)
 	ld c,(ix + FaceEdge.face + 1)

          
@@ 159,17 170,6 @@ FaceEdge_Render: PROC
 	ld ixh,c
 	call Face_Render
 	pop ix
-	ld a,(ix + FaceEdge.x)
-	add a,(ix + FaceEdge.stepx)
-	ld c,a
-	ld a,(ix + FaceEdge.error)
-	add a,(ix + FaceEdge.dx)
-	jr nc,NoOverflow
-	inc c
-	sub (ix + FaceEdge.dy)
-NoOverflow:
-	ld (ix + FaceEdge.error),a
-	ld (ix + FaceEdge.x),c
 	dec (ix + FaceEdge.height)
 	jp nz,Renderable_Advance
 	jp Renderable_Next

          
@@ 180,6 180,17 @@ NoOverflow:
 FaceEdge_RenderLeft: PROC
 	ld d,(ix + FaceEdge.x)
 	ld b,(ix + FaceEdge.z)
+	ld a,(ix + FaceEdge.x)
+	sub (ix + FaceEdge.stepx)
+	ld e,a
+	ld a,(ix + FaceEdge.error)
+	add a,(ix + FaceEdge.dx)
+	jr nc,NoOverflow
+	dec e
+	sub (ix + FaceEdge.dy)
+NoOverflow:
+	ld (ix + FaceEdge.error),a
+	ld (ix + FaceEdge.x),e
 	push ix
 	ld a,(ix + FaceEdge.face)
 	ld c,(ix + FaceEdge.face + 1)

          
@@ 187,17 198,6 @@ FaceEdge_RenderLeft: PROC
 	ld ixh,c
 	call Face_Render
 	pop ix
-	ld a,(ix + FaceEdge.x)
-	sub (ix + FaceEdge.stepx)
-	ld c,a
-	ld a,(ix + FaceEdge.error)
-	add a,(ix + FaceEdge.dx)
-	jr nc,NoOverflow
-	dec c
-	sub (ix + FaceEdge.dy)
-NoOverflow:
-	ld (ix + FaceEdge.error),a
-	ld (ix + FaceEdge.x),c
 	dec (ix + FaceEdge.height)
 	jp nz,Renderable_Advance
 	jp Renderable_Next