From 0940d9f9f91852e02da5883531e0822952a0fc61 Mon Sep 17 00:00:00 2001 From: hugova Date: Sun, 2 Mar 2025 16:51:55 +0100 Subject: [PATCH] 1. A fix for a bug where D gets the wrong initial value (2 bytes where flipped) 2. Implemented line drawing for the other 3 cases --- wip-hugo/routines/memory/line_down.s | 14 ++-- wip-hugo/routines/memory/line_down_inv.s | 87 ++++++++++++++++++++++++ wip-hugo/routines/memory/line_up.s | 85 +++++++++++++++++++++++ wip-hugo/routines/memory/line_up_inv.s | 85 +++++++++++++++++++++++ wip-hugo/source.s | 2 +- 5 files changed, 263 insertions(+), 10 deletions(-) create mode 100644 wip-hugo/routines/memory/line_down_inv.s create mode 100644 wip-hugo/routines/memory/line_up.s create mode 100644 wip-hugo/routines/memory/line_up_inv.s diff --git a/wip-hugo/routines/memory/line_down.s b/wip-hugo/routines/memory/line_down.s index 6ced07d..0c8a4fa 100644 --- a/wip-hugo/routines/memory/line_down.s +++ b/wip-hugo/routines/memory/line_down.s @@ -1,12 +1,11 @@ ;;drawing line from 2 cordinates .proc line - ;;# (X_pos, Y_pos) # + ;;# (X_pos, Y_pos) # ;;# * # ;;# * # ;;# * # ;;# (X_end, Y_end) # - ;; - ;;NOTE THAT X_pos <= X_end and line is going downwords max 45deg! + ;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Max 45deg! ;;Not values but register position in memory X_end = $04 @@ -53,10 +52,9 @@ STA >D LDA D, D, D, D, dx_2, D, dx_2, D, dy_2, D, dy_2, dx_2 + LDA #$00 + STA dx_2, dx_2 + STA >D + LDA D, D, dy_2, >D ==0, then: case_2 + LDA 0 then: case_1 + CMP #$00 + BEQ case_2 +case_1: + INC X_pos + ;; D = D - 2*dx + Sub_16 >D, dy_2, D, dx_2, = Y_end. Max 45deg! + +;;Not values but register position in memory + X_end = $04 + Y_end = $05 + X_pos = $FC + Y_pos = $FB + dy_2 = $0607 + dx = $08 + D = $0a0b + + ;;Set values + LDA #$00 + STA $FD ; for pixel_draw + + ;example values ~~~~~ SHOULD BE PRECOMPILED + LDA #$90 + STA X_pos + STA Y_pos + + LDA #$aa + STA X_end + LDA #$80 + STA Y_end + ;;~~~~~~~~~~ + + ;;2*dy = 2*(Y_pos-Y_end) + LDA Y_pos + SEC + SBC Y_end + STA >dy_2 + LDA #$00 + STA dy_2, dy_2 + STA >D + LDA D, D, dx_2, >D ==0, then: case_2 + LDA 0 then: case_1 + CMP #$00 + BEQ case_2 +case_1: + DEC Y_pos + Sub_16 >D, dx_2, D, dy_2, = 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 = $08 + D = $0a0b + + ;;Set values + LDA #$00 + STA $FD ; for pixel_draw + + ;example values ~~~~~ SHOULD BE PRECOMPILED + LDA #$60 + STA X_pos + STA Y_pos + + LDA #$50 + STA X_end + LDA #$90 + STA Y_end + ;;~~~~~~~~~~ + + ;;2*dx = 2*(X_pos - X_end) + LDA X_pos + SEC + SBC X_end + STA >dx_2 + LDA #$00 + STA dx_2, dx_2 + STA >D + LDA D, D, dy_2, >D ==0, then: case_2 + LDA 0 then: case_1 + CMP #$00 + BEQ case_2 +case_1: + DEC X_pos + Sub_16 >D, dy_2, D, dx_2,