;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-

.proc line; X_pos =< X_end skall alltid gälla
        .include "line.inc"
       ; dx_ = $0c
       ; dy_ = $06
        ;;dx
        SEC
        LDA X_end
        SBC X_pos
        STA dx
        BCC dx_no_underflow;; X_end >= X_pos
        EOR #$ff ; Fix bit underflow
        dx_no_underflow:
        SEC
        LDA Y_pos
        SBC Y_end
        STA dy
        BCC down ;normal  Y_pos < Y_end
up:; Y_pos > Y_end
        STA dy
        CMP dx
        BCC shallow; dy < dx
steep:
        jsr line_up_inv
        RTS
shallow: ;dy =< dx
        lda dx
        jsr line_up
        RTS
down:
        EOR #$ff ; Fix bit underflow
        STA dy
        CMP dx
        BCC shallow_; dy < dx
steep_:
        jsr line_down_inv
        RTS
shallow_: ;dy < dx
        jsr line_down
        RTS

        .include "line_down.s"
        .include "line_down_inv.s"
        .include "line_up.s"
        .include "line_up_inv.s"
.endproc