c64-livecoding/wip-hugo/routines/line/line_up.s
2025-07-23 18:05:37 +02:00

87 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 X_pos <= X_end, Y_pos >= Y_end. Max 45deg!
.proc line_up
;; Look at line_down for referense
.include "line.inc"; Defines memory positions, ex X_pos
LDA #$00
STA V + 1
STA dy_2 + 1
SEC
LDA dx
SBC dy
Mult_16 A, V + 1
STA V
Mult_16 dy_2, dy_2 + 1
;; D = dy_2 - dx. (signed 16-bit)
SEC
LDA dy_2
SBC dx
STA D
LDA dy_2 + 1
SBC #$00
STA D + 1
selfmod:
LDA dy_2
STA case_2 + 1
LDA dy_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
Sub_16 btp_mem_pos, btp_mem_pos + 1, #$00, #$00, !
;LDY #$01
INY
LDX dx
for_x:
LDA byte_to_paint
ORA (btp_mem_pos), Y
STA (btp_mem_pos), Y
increment_pixel_x:
LSR byte_to_paint
BCC increment_pixel_x_end
move_8px_left:
ROR byte_to_paint
Add_16 btp_mem_pos, btp_mem_pos + 1, #$08, #$00,!
increment_pixel_x_end:
DEX
;CPX X_end
BEQ end
;;If D < 0 goto case_2
LDA D + 1
BMI case_2
case_1:
Sub_16 D, D + 1, #V, #V + 1,!
decrement_y_pos:
DEY
BNE for_x
move_8px_up:
LDY #$08
; C = 0 eller 1
Sub_16 btp_mem_pos, btp_mem_pos + 1, #$40, #$01
jmp for_x
decrement_y_pos_end:
case_2:
; C =0
Add_16 D, D + 1, #dy_2, #dy_2 + 1,!
JMP for_x
end:
RTS
.endproc