;;; -*- 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 +1 STA dy_2 +1 ;; V = 2*(dx -dy) SEC LDA dx SBC dy Mult_16 A, V +1 STA V ;dy_2 = dy*2 Mult_16 dy_2, dy_2 +1 ;dy_2 = dy (same address) ;; D = dy_2 - dx. (signed 16-bit) SEC LDA dy_2 SBC dx STA D LDA dy_2 + 1 SBC #$00 STA D + 1 ;; because C flag is wrong value we let dy_2 be 1 to small Sub_16 dy_2, dy_2 +1, #$01,#$00 selfmod: ;; Self modifying code. Makes LDA and SBC instructions each take 1 cycle less. ;; You can remove this if you run the loop without # at dy_2 and V. ;;Note: The offsets like +2 etc is because there are instructions betwean the label and the ;; address that needs to be modified. ;; dy_2 ;; Modifies LDA >dy_2 LDA dy_2 STA case_2 + 1 ;; Modifies LDA V LDA V STA case_1 + 3 ;; Modifies SBC