A fix of line_up_inv such that X_pos < X_end like all other line_* implementations.

This commit is contained in:
hugova 2025-03-04 21:00:21 +01:00
parent 4d12f20a6e
commit 494e9dc5f9

View file

@ -1,11 +1,11 @@
;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!
;;# * #
;;# * #
;;# * #
;;# (X_pos, Y_pos) #
;;NOTE THAT Y_pos >) Y_end, X_pos <= X_end. Min 45deg!
;;Not values but register position in memory
X_end = $04
@ -17,16 +17,6 @@
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
@ -35,14 +25,14 @@
;; V = 2*(dy -dx)
;; where: dy = Y_pos - Y_end, dx = X_end - X_start
LDA X_pos
LDA X_end
SEC
SBC X_end
SBC X_pos
STA >V
STA >dx_2; >dy_2 = dy. Needed for dy_2 (not for V)
LDA Y_end
LDA Y_pos
SEC
SBC Y_pos
SBC Y_end
STA dy
SEC
SBC >V
@ -63,7 +53,7 @@
for_y:
jsr pixel_draw
;;Increment Y until Y_pos = Y_end and X_pos = X_end
INC Y_pos
DEC Y_pos
LDY Y_pos
CPY Y_end
BEQ end
@ -72,7 +62,7 @@ for_y:
;;else case 1.
Lag_16 >D, <D, #$00, #$02, case_2
case_1:
DEC X_pos
INC X_pos
Sub_16 >D, <D, >V, <V; D = D - V
JMP for_y
case_2: