diff --git a/wip-hugo/macros/16aritmatic.s b/wip-hugo/macros/16aritmatic.s index 2756c9d..820dae3 100755 --- a/wip-hugo/macros/16aritmatic.s +++ b/wip-hugo/macros/16aritmatic.s @@ -78,8 +78,13 @@ ROL low_ ROL hi_ .endif +.endmacro - +.macro Mov_16 a_low, a_hi, b_low, b_hi + LDA b_low + STA a_low + LDA b_hi + STA a_hi .endmacro ;;Larger then operation, uses the A register diff --git a/wip-hugo/routines/line/line_down.s b/wip-hugo/routines/line/line_down.s index 9f8a8d9..6ad1b9f 100644 --- a/wip-hugo/routines/line/line_down.s +++ b/wip-hugo/routines/line/line_down.s @@ -9,7 +9,26 @@ ;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Max 45deg! .proc line_down - .include "line.inc"; Defines memory positions, ex X_pos + + ;; TEMPORARY + ;; Hack because changing dx and dy makes other line draws bugg and idk why + ;; This is offcorse temporary + ;.include "line.inc"; Defines memory positions, ex X_pos + X_end = $04 + Y_end = $05 + X_pos = $FC + Y_pos = $FB + dx = $0c + dy = $06 + dy_2 = $0607 + dx_2 = dy_2 + V = $0809 + D = $0a0b + ;;These are also used in pixel_draw. Look there to find out more + byte_to_paint = $FE ;Byte with one 1 that corasponds to a pixel. + btp_mem_pos =$494A; byte to paint memory position ;Position of byte on screen + ;;END TEMPORARY + ;;We need to clear this memory LDA #$00 STA V - STA >dy_2; >dy_2 = dy. Needed for dy_2 (not for V) LDA dx - SEC - SBC >V - STA >V; V, V + mult_16 >V, dy_2, dy_2, dy_2 = dy (same address) ;; This is an Bresenham's line algorithm, se wikipedia bellow. ;;https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm @@ -42,44 +56,33 @@ ;; and to its branch logic later in the loop. ;;D = 2*dy - dx + 2*255 - LDA >dy_2 - STA >D - LDA D, dy_2, D, D, dy_2 - ;LDA #$A9 ; LDA (immediate) - ;STA case_2 - ;LDA >dy_2 - ;STA case_2 +1 - ;;; Modifies LDA V - ;LDA #$E9 ;SBC (immediate) - ;STA case_1 +2;LDA is +2 - ;LDA >V - ;STA case_1 +3 - ;;; Modifies SBC dy_2 + LDA >dy_2 + STA case_2 +1 + ;; Modifies LDA V + LDA >V + STA case_1 +3 + ;; Modifies SBC D, D, V, D, V, # C=1 JMP for_x increment_y_pos_end: case_2: ;; C =0 because LAG_16 so we can use ! - Add_16 >D, dy_2, D, dy_2, #