From f93557bfd99ef05d28906626cdadf4900e3cf3a8 Mon Sep 17 00:00:00 2001 From: hugova Date: Thu, 3 Apr 2025 16:58:55 +0200 Subject: [PATCH] Made math befor line-draw-loop faster. from 811183 cpu cykles to 809951 --- wip-hugo/routines/line/line.inc | 18 +++++++++--------- wip-hugo/routines/line/line.s | 20 +++++++++----------- wip-hugo/routines/line/line_down.s | 6 +----- wip-hugo/routines/line/line_down_inv.s | 6 +----- wip-hugo/routines/line/line_up.s | 6 +----- wip-hugo/routines/line/line_up_inv.s | 5 +---- wip-hugo/routines/memory/mem.inc | 6 +++--- wip-hugo/source.s | 2 +- 8 files changed, 26 insertions(+), 43 deletions(-) diff --git a/wip-hugo/routines/line/line.inc b/wip-hugo/routines/line/line.inc index 1965bb4..b651a58 100644 --- a/wip-hugo/routines/line/line.inc +++ b/wip-hugo/routines/line/line.inc @@ -1,17 +1,17 @@ ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;Not values but register position in memory - X_end = $04 - Y_end = $05 + X_end = $EF + Y_end = $F0 + dx = $F3 + dy = $F1 + dy_2 = $F1F2 + dx_2 = $F3F4 + V = $EDEE + D = $EBEC ;;These come from mem.inc + ;; Takes up FF - F5 X_pos = $FC Y_pos = $FB - dx = $0c - dy = $06 - dy_2 = $0607 - dx_2 = $0cF3 - V = $0809 - D = $0a0b - ;;These come from mem.inc byte_to_paint = $FE ;Byte with one 1 that corisponds to a pixel. btp_mem_pos =$F9FA; byte to paint memory position ;Position of byte on screen diff --git a/wip-hugo/routines/line/line.s b/wip-hugo/routines/line/line.s index 15f05df..5b656e8 100644 --- a/wip-hugo/routines/line/line.s +++ b/wip-hugo/routines/line/line.s @@ -2,40 +2,38 @@ .proc line; X_pos =< X_end skall alltid gälla .include "line.inc" - dx_ = $0c - dy_ = $06 + ; dx_ = $0c + ; dy_ = $06 ;;dx SEC LDA X_end SBC X_pos - STA dx_ + STA dx BCC dx_no_underflow;; X_end >= X_pos EOR #$ff ; Fix bit underflow dx_no_underflow: SEC LDA Y_pos SBC Y_end - STA dy_ + STA dy BCC down ;normal Y_pos < Y_end up:; Y_pos > Y_end - STA dy_ - CMP dx_ + STA dy + CMP dx BCC shallow; dy < dx steep: jsr line_up_inv RTS shallow: ;dy =< dx - lda dx_ + lda dx jsr line_up RTS down: EOR #$ff ; Fix bit underflow - STA dy_ - CMP dx_ + STA dy + CMP dx BCC shallow_; dy < dx steep_: - ;LDA dx - jsr line_down_inv RTS shallow_: ;dy < dx diff --git a/wip-hugo/routines/line/line_down.s b/wip-hugo/routines/line/line_down.s index afed9d4..e90ab7a 100644 --- a/wip-hugo/routines/line/line_down.s +++ b/wip-hugo/routines/line/line_down.s @@ -65,11 +65,7 @@ selfmod: end_selfmod: JSR pixel_draw ;;only used first pixel. after this relative position is abused ;; X = X_end - X_pos - LDA X_end - SEC - SBC X_pos - TAX - ;LDX X_pos + LDX dx LDY #$00 for_x: ;; Paints A to address in |btp_mem_pos* + Y| diff --git a/wip-hugo/routines/line/line_down_inv.s b/wip-hugo/routines/line/line_down_inv.s index df8b909..4e91f71 100644 --- a/wip-hugo/routines/line/line_down_inv.s +++ b/wip-hugo/routines/line/line_down_inv.s @@ -41,11 +41,7 @@ selfmod: end_selfmod: jsr pixel_draw LDY #$00 - LDA Y_end - SEC - SBC Y_pos - TAX - ;LDX Y_pos + LDX dy for_y: LDA byte_to_paint ORA (>btp_mem_pos), Y diff --git a/wip-hugo/routines/line/line_up.s b/wip-hugo/routines/line/line_up.s index e8da686..3296bd3 100644 --- a/wip-hugo/routines/line/line_up.s +++ b/wip-hugo/routines/line/line_up.s @@ -43,11 +43,7 @@ end_selfmod: jsr pixel_draw Sub_16 >btp_mem_pos, btp_mem_pos), Y diff --git a/wip-hugo/routines/line/line_up_inv.s b/wip-hugo/routines/line/line_up_inv.s index 04d1b6f..d29a63c 100644 --- a/wip-hugo/routines/line/line_up_inv.s +++ b/wip-hugo/routines/line/line_up_inv.s @@ -41,10 +41,7 @@ selfmod: end_selfmod: jsr pixel_draw LDY #$00 - LDA Y_pos - SEC - SBC Y_end - TAX + LDX dy for_y: LDA byte_to_paint ORA (>btp_mem_pos), Y diff --git a/wip-hugo/routines/memory/mem.inc b/wip-hugo/routines/memory/mem.inc index 5d8458c..6093345 100644 --- a/wip-hugo/routines/memory/mem.inc +++ b/wip-hugo/routines/memory/mem.inc @@ -8,6 +8,6 @@ Y_pos = $FB X_pos = $FCFD byte_to_paint = $FE - btp_mem_pos =$F9FA; byte to paint memory position - C = $7071 - B =$7273 + btp_mem_pos = $F9FA; byte to paint memory position + C = $F7F8 + B = $F5F6 diff --git a/wip-hugo/source.s b/wip-hugo/source.s index 17e6df9..8650072 100755 --- a/wip-hugo/source.s +++ b/wip-hugo/source.s @@ -6,7 +6,7 @@ .include "routines/memory/mem.inc" ;;Code to run .include "STARTUP.s" -.include "routines/line/line_test.s" +.include "routines/line/line_test_time.s" ;.include "routines/memory/memcpy_test.s" exit: jmp exit