;;; -*- 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 ;; 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 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 +3 ;; 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. Add_16 >btp_mem_pos, D, D, V, # C=1 LDY #$00 ;; Switch to chunk bellow Add_16 >btp_mem_pos, D, dy_2, #