c64-livecoding/wip-hugo/routines/line/line.s

75 lines
1.5 KiB
ArmAsm

;;; -*- 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 Y_pos
CMP #$C8 ;;y_max = $C8
BCC do_not_fix_y_pos
LDA #$C8
STA Y_pos
do_not_fix_y_pos:
LDA Y_end
CMP #$C8 ;;y_max = $C8
BCC do_not_fix_y_end
LDA #$C8
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
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_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