;;; -*- 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. Min 45deg! .proc line_down_inv ;; Look at line_down for referense .include "line.inc"; Defines memory positions, ex X_pos LDA #$00 STA V + 1 STA dx_2 + 1 SEC LDA dy SBC dx Mult_16 A, V + 1 STA V Mult_16 dx_2, dx_2 + 1 ;; D = dx_2 - dy. (signed 16-bit) SEC LDA dx_2 SBC dy STA D LDA dx_2 + 1 SBC #$00 STA D + 1 ;; because C flag is wrong value we let dy_2 be 1 to small Sub_16 dx_2, dx_2 +1, #$01,#$00 selfmod: LDA dx_2 STA case_2 + 1 LDA dx_2 + 1 STA case_2 + 7 LDA V STA case_1 + 3 LDA V + 1 STA case_1 + 9 end_selfmod: LDA X_end STA X_pos LDA Y_end STA Y_pos JSR pixel_calc ;;only used first pixel. after this relative position is abused STA byte_to_paint INY Sub_16 btp_mem_pos, btp_mem_pos + 1, #$00, #$00, ! LDX dy INX CLC for_y: ; C =0 LDA byte_to_paint ORA (btp_mem_pos), Y STA (btp_mem_pos), Y increment_y_pos: DEY BNE increment_y_pos_end move_8px_down: LDY #$08 Sub_16 btp_mem_pos, btp_mem_pos + 1, #$3f ,#$01, ! increment_y_pos_end: DEX BEQ end ;Lag_16 D, D + 1, #$00, #$02, case_2 LDA D + 1 BMI case_2 case_1: Sub_16 D, D + 1, #V, #V + 1, ! increment_pixel_x: ASL byte_to_paint BCC for_y move_8px_left: Sub_16 btp_mem_pos, btp_mem_pos + 1, #$08, #$00,! ROL byte_to_paint JMP for_y case_2: Add_16 D, D + 1, #dx_2, #dx_2 + 1,! ;D = D + 2*dx CLC ; for_y shall always have C = 1 JMP for_y end: RTS .endproc