diff --git a/wip-hugo/routines/triangle/triangle.inc b/wip-hugo/routines/triangle/triangle.inc index 9f66a22..779abea 100644 --- a/wip-hugo/routines/triangle/triangle.inc +++ b/wip-hugo/routines/triangle/triangle.inc @@ -1,15 +1,25 @@ ;;; -*- 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_Y = $E9 B_X = $E8 B_Y = $E7 C_X = $E6 C_Y = $E5 + + ;; Differense in height (after these points have been sorted look in triangle.s for more detail) AB = $E4 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 ;; Takes up FF - F5 diff --git a/wip-hugo/routines/triangle/triangle.s b/wip-hugo/routines/triangle/triangle.s index 1dcbd8f..3615df3 100644 --- a/wip-hugo/routines/triangle/triangle.s +++ b/wip-hugo/routines/triangle/triangle.s @@ -14,7 +14,7 @@ ;; Each side of the sub-triangle can have 4 posiboul states (look at how line is implemented) ;;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 ;; (iii) C is at the lowest point ;; Lets also calculate the height-differense for the new points: @@ -25,11 +25,12 @@ SEC LDA B_Y SBC A_Y - STA AB BCC AB_overflow_end + STA AB ;; A_Y > B_Y AB_overflow: EOR #$ff ; Fix byte underflow + STA AB ;; swop A and B LDX B_Y LDY A_Y @@ -44,11 +45,12 @@ AB_overflow_end: SEC LDA C_Y SBC B_Y - STA BC BCC BC_overflow_end + STA BC ;; B_Y > C_Y BC_overflow: EOR #$ff ; Fix byte underflow + STA BC ;; swop A and B LDX C_Y LDY B_Y diff --git a/wip-hugo/routines/triangle/upper_triangle.s b/wip-hugo/routines/triangle/upper_triangle.s index 19ba595..7385b2e 100644 --- a/wip-hugo/routines/triangle/upper_triangle.s +++ b/wip-hugo/routines/triangle/upper_triangle.s @@ -2,10 +2,9 @@ ;; This is a help program for triangle.s to draw the upper triangle -;; We know that (se triangle.inc) -;; (i) A is at the highest point -;; (ii) B is at the middle point -;; (iii) C is at the lowest point +;; We know that (se triangle.inc) and triangle.s +;; The upper triangle has hight AB +;; Its tip is A ;; This triangle has 10 posibol cases, see table bellow ;; ---------------------------------------------------- @@ -24,8 +23,17 @@ ;; ---------------------------------------------------- .scope upper_triangle - LDA #$00 ;; 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