c64-livecoding/host/routines/line/line_up_inv.s

86 lines
2 KiB
ArmAsm

;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;drawing line from 2 cordinates
;;# (X_end, Y_end) #
;;# * #
;;# * #
;;# * #
;;# (X_pos, Y_pos) #
;;NOTE THAT Y_pos >) Y_end, X_pos <= X_end. Min 45deg!
.proc line_up_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 dy_2, dy_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:
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,!
CLC
LDX dy
for_y:
LDA byte_to_paint
ORA (btp_mem_pos), Y
STA (btp_mem_pos), Y
decrement_y_pos:
DEY
BNE decrement_y_pos_end
move_8px_up:
LDY #$08
Sub_16 btp_mem_pos, btp_mem_pos + 1,#$3F , #$01,!
decrement_y_pos_end:
DEX
BEQ end
LDA D + 1
BMI case_2
case_1:
Sub_16 D, D + 1, #V, #V + 1,!
increment_pixel_x:
LSR byte_to_paint
BCC for_y
move_8px_left:
ROR byte_to_paint
;; C = 1 or 0
Add_16 btp_mem_pos, btp_mem_pos + 1, #$08, #$00
JMP for_y
case_2:
Add_16 D, D + 1, #dx_2, #dx_2 + 1,!
CLC
JMP for_y
end:
RTS
.endproc