;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- .proc line; user-procedure :clobbers (A X Y) :clobbers-arguments 4 .include "line.inc" ;; Fix line that is too long LDA #$C8 ;y_max = $C8 CMP Y_pos BCS do_not_fix_y_pos STA Y_pos do_not_fix_y_pos: LDA #$C8 CMP Y_pos ;y_max = $C8 BCS do_not_fix_y_end STA Y_end do_not_fix_y_end: ;;dx SEC LDA X_end SBC X_pos BCS dx_no_underflow;; X_end >= X_pos EOR #$ff ; Fix bit underflow ADC #$01 STA dx ;; line_* expect X_pos < X_end and now its not the case. ;; Lets move them around LDX X_pos LDY X_end STX X_end STY X_pos LDX Y_pos LDY Y_end STX Y_end STY Y_pos dx_no_underflow: STA dx SEC LDA Y_end SBC Y_pos BCS down ;normal Y_pos < Y_end up:; Y_pos > Y_end EOR #$ff ; Fix bit underflow ADC #$01 STA dy CMP dx BCC shallow; dy < dx steep: jsr line_up_inv RTS shallow: ;dy =< dx jsr line_up RTS down: 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