c64-livecoding/wip-hugo/routines/memory/line/line_up_inv.s
hugova 4d12f20a6e A Fix for D that gets the wrong initial value and the branch logic in line_* checked for the wrong value.
A new proc, line.s that can chose whitch line_* to use
A small test program in source.s
Wrote a smal test program in source.s  (all looks good exept line_up_inv)
2025-03-03 22:08:00 +01:00

83 lines
1.8 KiB
ArmAsm

;drawing line from 2 cordinates
.proc line_up_inv
;;# (X_pos, Y_pos) #
;;# * #
;;# * #
;;# * #
;;# (X_end, Y_end) #
;;NOTE THAT Y_pos <= Y_end, X_pos >= X_end. Min 45deg!
;;Not values but register position in memory
X_end = $04
Y_end = $05
X_pos = $FC
Y_pos = $FB
dx_2 = $0607
dy = $0c
V = $0809
D = $0a0b
;example values ~~~~~ SHOULD BE PRECOMPILED
;LDA #$60
;STA X_pos
;STA Y_pos
;LDA #$50
;STA X_end
;LDA #$90
;STA Y_end
;;~~~~~~~~~~
;We need to clear this memory
LDA #$00
STA <V
STA <dx_2
STA $FD ; for pixel_draw
;; V = 2*(dy -dx)
;; where: dy = Y_pos - Y_end, dx = X_end - X_start
LDA X_pos
SEC
SBC X_end
STA >V
STA >dx_2; >dy_2 = dy. Needed for dy_2 (not for V)
LDA Y_end
SEC
SBC Y_pos
STA dy
SEC
SBC >V
STA >V; <V = dx - dy
mult_16 >V, <V; V = 2*(dx -dy)
;dy_2 = dy*2
mult_16 >dx_2, <dx_2
;;D = 2*dx - dy + 2*255
;;Our D is bigger then wikipedia because D is unsigned.
LDA >dx_2
STA >D
LDA <dx_2
STA <D
Add_16 >D, <D, #$ff, #$01
Sub_16 >D, <D, dy, #$00
for_y:
jsr pixel_draw
;;Increment Y until Y_pos = Y_end and X_pos = X_end
INC Y_pos
LDY Y_pos
CPY Y_end
BEQ end
;;If D < %00000010 00000000: case_2
;;else case 1.
Lag_16 >D, <D, #$00, #$02, case_2
case_1:
DEC X_pos
Sub_16 >D, <D, >V, <V; D = D - V
JMP for_y
case_2:
Add_16 >D, <D, >dx_2, <dx_2;D = D + 2*dy
JMP for_y
end:
RTS
.endproc