Add more variable for triangle_drawing
This commit is contained in:
parent
737ebbbe51
commit
3bdf52d1a8
3 changed files with 30 additions and 10 deletions
|
@ -1,15 +1,25 @@
|
||||||
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
|
||||||
|
|
||||||
;;The triangles 3 corner-positions, they may be in any given order.
|
;; The triangles 3 corner-positions, they may be in any given order.
|
||||||
|
;; This is inputs to the subrotine!
|
||||||
A_X = $EA
|
A_X = $EA
|
||||||
A_Y = $E9
|
A_Y = $E9
|
||||||
B_X = $E8
|
B_X = $E8
|
||||||
B_Y = $E7
|
B_Y = $E7
|
||||||
C_X = $E6
|
C_X = $E6
|
||||||
C_Y = $E5
|
C_Y = $E5
|
||||||
|
|
||||||
|
|
||||||
;; Differense in height (after these points have been sorted look in triangle.s for more detail)
|
;; Differense in height (after these points have been sorted look in triangle.s for more detail)
|
||||||
AB = $E4
|
AB = $E4
|
||||||
BC = $E3
|
BC = $E3
|
||||||
|
;; We need some values for Bresenham's line algorithm, see triangle.s and line_down.s
|
||||||
|
V_l = $E2 ;16-bit value (uses E3)
|
||||||
|
V_r = $E0 ;16-bit value (used E1)
|
||||||
|
dy_2_l = $DE ;16-bit value (used DF)
|
||||||
|
dy_2_l = $DC ;16-bit value (used DD)
|
||||||
|
D_l = $DA ;16-bit value (uses DB)
|
||||||
|
D_r = $D8 ;16-bit value (uses D9)
|
||||||
|
|
||||||
;; These come from mem.inc
|
;; These come from mem.inc
|
||||||
;; Takes up FF - F5
|
;; Takes up FF - F5
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
;; Each side of the sub-triangle can have 4 posiboul states (look at how line is implemented)
|
;; Each side of the sub-triangle can have 4 posiboul states (look at how line is implemented)
|
||||||
|
|
||||||
;;Lets first sort the edges such as
|
;;Lets first sort the edges such as
|
||||||
;; (i) A is at the highest point
|
;; (i) A is at the left point
|
||||||
;; (ii) B is at the middle point
|
;; (ii) B is at the middle point
|
||||||
;; (iii) C is at the lowest point
|
;; (iii) C is at the lowest point
|
||||||
;; Lets also calculate the height-differense for the new points:
|
;; Lets also calculate the height-differense for the new points:
|
||||||
|
@ -25,11 +25,12 @@
|
||||||
SEC
|
SEC
|
||||||
LDA B_Y
|
LDA B_Y
|
||||||
SBC A_Y
|
SBC A_Y
|
||||||
STA AB
|
|
||||||
BCC AB_overflow_end
|
BCC AB_overflow_end
|
||||||
|
STA AB
|
||||||
;; A_Y > B_Y
|
;; A_Y > B_Y
|
||||||
AB_overflow:
|
AB_overflow:
|
||||||
EOR #$ff ; Fix byte underflow
|
EOR #$ff ; Fix byte underflow
|
||||||
|
STA AB
|
||||||
;; swop A and B
|
;; swop A and B
|
||||||
LDX B_Y
|
LDX B_Y
|
||||||
LDY A_Y
|
LDY A_Y
|
||||||
|
@ -44,11 +45,12 @@ AB_overflow_end:
|
||||||
SEC
|
SEC
|
||||||
LDA C_Y
|
LDA C_Y
|
||||||
SBC B_Y
|
SBC B_Y
|
||||||
STA BC
|
|
||||||
BCC BC_overflow_end
|
BCC BC_overflow_end
|
||||||
|
STA BC
|
||||||
;; B_Y > C_Y
|
;; B_Y > C_Y
|
||||||
BC_overflow:
|
BC_overflow:
|
||||||
EOR #$ff ; Fix byte underflow
|
EOR #$ff ; Fix byte underflow
|
||||||
|
STA BC
|
||||||
;; swop A and B
|
;; swop A and B
|
||||||
LDX C_Y
|
LDX C_Y
|
||||||
LDY B_Y
|
LDY B_Y
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
|
|
||||||
;; This is a help program for triangle.s to draw the upper triangle
|
;; This is a help program for triangle.s to draw the upper triangle
|
||||||
|
|
||||||
;; We know that (se triangle.inc)
|
;; We know that (se triangle.inc) and triangle.s
|
||||||
;; (i) A is at the highest point
|
;; The upper triangle has hight AB
|
||||||
;; (ii) B is at the middle point
|
;; Its tip is A
|
||||||
;; (iii) C is at the lowest point
|
|
||||||
|
|
||||||
;; This triangle has 10 posibol cases, see table bellow
|
;; This triangle has 10 posibol cases, see table bellow
|
||||||
;; ----------------------------------------------------
|
;; ----------------------------------------------------
|
||||||
|
@ -24,8 +23,17 @@
|
||||||
;; ----------------------------------------------------
|
;; ----------------------------------------------------
|
||||||
|
|
||||||
.scope upper_triangle
|
.scope upper_triangle
|
||||||
LDA #$00
|
|
||||||
;; Lets for the sake of it say its a lr triangle
|
;; Lets for the sake of it say its a lr triangle
|
||||||
;; we need to compute V_l, V_r, dy_2l, dy_2_r, D_l, and D_r
|
;; lets also say B is on the left and C is on the right
|
||||||
|
;; we need to compute V_l, V_r, dy_2_l, dy_2_r, D_l, and D_r
|
||||||
|
|
||||||
|
;;We need to clear this memory
|
||||||
|
LDA #$00
|
||||||
|
STA V_l + 1
|
||||||
|
STA V_r + 1
|
||||||
|
STA dy_2_l + 1
|
||||||
|
STA dy_2_l + 1
|
||||||
|
STA $FD ; for pixel_draw
|
||||||
|
|
||||||
|
;; ..
|
||||||
.endscope
|
.endscope
|
||||||
|
|
Loading…
Add table
Reference in a new issue