;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;drawing line from 2 cordinates ;;# (X_pos, Y_pos) # ;;# * # ;;# * # ;;# * # ;;# (X_end, Y_end) # ;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Max 45deg! .proc line_down .include "line.inc"; Defines memory positions, ex X_pos ;;We need to clear this memory LDA #$00 STA V Mult_16 >V, 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 ;; We need to compute the Value D = 2*dy - dx, ;; but it may be or get negative. ;; IN the loop we may set D = D -V ;; Because math D needs to be at least >=V. ;; V_max = %00000001 11111111 ;; We therefor need to add this offset to V 00000001 11111111 ;; and to its branch logic later in the loop. ;;D = 2*dy - dx + 2*255 Mov_16 >D, dy_2, D, D, dy_2 LDA >dy_2 STA case_2 +1 ;; Modifies LDA V LDA >V STA case_1 +1 ;; Modifies SBC btp_mem_pos), Y STA (>btp_mem_pos), Y increment_pixel_x: LSR byte_to_paint ; Rotates the pixel one bit to the left ON THE SCREEN. BCC increment_pixel_x_end; We need to move to the next chunk move_8px_left: ;; Next chunk is 8 addresses away. Look in pixel_draw for more detail. ;; -8. ;; C = 1 therefore you se 07 Add_16 >btp_mem_pos, D, D Sub_16_A >D, V, # C=1 LDY #$00 ;; Switch to chunk bellow ; C = 1 ; So we subtract #$3F, #$01 +C Add_16 >btp_mem_pos, D, dy_2, #