From f64d28168b6b6a9dcad65db2f1dfab44ca45b25e Mon Sep 17 00:00:00 2001 From: hugova Date: Thu, 17 Jul 2025 13:49:09 +0200 Subject: [PATCH] make line_down draw from other end of line. Reduses one CMP instruction --- wip-hugo/routines/line/line_down.s | 42 +++++++++++++++++------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/wip-hugo/routines/line/line_down.s b/wip-hugo/routines/line/line_down.s index b0cf736..6c2070d 100644 --- a/wip-hugo/routines/line/line_down.s +++ b/wip-hugo/routines/line/line_down.s @@ -73,27 +73,34 @@ selfmod: LDA V + 1 STA case_1 + 7 end_selfmod: + LDA X_end + STA X_pos + LDA Y_end + STA Y_pos + JSR pixel_calc ;;only used first pixel. after this relative position is abused STA byte_to_paint ;; X = X_end - X_pos LDX dx + Sub_16 btp_mem_pos, btp_mem_pos + 1, #$00, #$00,! ;; Y has always a offset of at least 1 = C + $0000 + INY for_x: ;; Paints A to address in |btp_mem_pos* + Y| ;; Y is pixel position in the chunk. Therefor it may be that Y = 0, 1, 2, 3, 4, ,5 ,6 ,7. LDA byte_to_paint ;A byte containing a single 1. Coresponds to X position in the chunk. ORA (btp_mem_pos), Y STA (btp_mem_pos), Y -increment_pixel_x: - LSR byte_to_paint ; Rotates the pixel one bit to the left ON THE SCREEN. - BCC increment_pixel_x_end; We need to move to the next chunk -move_8px_left: - ;; Restores byte to paint to #%10000000 - ROR byte_to_paint +decrement_pixel_x: + ASL byte_to_paint ; Rotates the pixel one bit to the left ON THE SCREEN. + BCC decrement_pixel_x_end; We need to move to the next chunk +move_8px_right: + ;; Restores byte to paint to #%00000001 + ROL byte_to_paint ;; Next chunk is 8 addresses away. Look in pixel_draw for more detail. ;; -8. - ;; C = 1 therefore you se 07 - Add_16 btp_mem_pos, btp_mem_pos + 1, #$08, #$00, ! -increment_pixel_x_end: + ;; C = 0 + Sub_16 btp_mem_pos, btp_mem_pos + 1, #$07, #$00, ! +decrement_pixel_x_end: DEX BEQ end ;We keep track on when to stop line draw with the X registry. ;;If D < %00000010 00000000: case_2 @@ -105,20 +112,19 @@ case_1: ;; C =1 so we can use ! ;; A = >D Sub_16_A D, D + 1, #>V, # C=1 - LDY #$00 +move_8px_up: ; Z=1 --> C=1 + LDY #$08 ;; Switch to chunk bellow ; C = 1 - ; So we subtract #$3F, #$01 +C - Add_16 btp_mem_pos, btp_mem_pos + 1, #$3F, #$01, !; +320 + ; So we subtract #$40, #$01 + Sub_16 btp_mem_pos, btp_mem_pos + 1, #$40, #$01, !; +320 JMP for_x -increment_y_pos_end: +decrement_y_pos_end: case_2: - Add_16 D, D + 1, #>dy_2, #dy_2, #