From 89c9bc41295437f402ee091fd0652cfbb6879268 Mon Sep 17 00:00:00 2001 From: hugova Date: Wed, 26 Mar 2025 12:14:55 +0100 Subject: [PATCH] Add self modifying code to draw_line for 2% performance improvments --- wip-hugo/routines/line/line_down.s | 30 +++++++++++++++++++++++++ wip-hugo/routines/line/line_test_time.s | 4 ++-- wip-hugo/source.s | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/wip-hugo/routines/line/line_down.s b/wip-hugo/routines/line/line_down.s index 8143a52..9f8a8d9 100644 --- a/wip-hugo/routines/line/line_down.s +++ b/wip-hugo/routines/line/line_down.s @@ -51,6 +51,36 @@ jsr pixel_draw ;;only used first pixel. after this relative position is abused LDX X_pos + + ;; Self modifying code. Makes LDA instructions take 1 cycle less. + ;; Code will run without this but slower! + ;; Modifies LDA instructions for dy_2 and SBC for V + ;;Note: The offsets like +2 etc is because there are instructions betwean the label and the + ;address that needs to be modified + + ;;; dy_2 + ;;; Modifies LDA >dy_2 + ;LDA #$A9 ; LDA (immediate) + ;STA case_2 + ;LDA >dy_2 + ;STA case_2 +1 + ;;; Modifies LDA V + ;LDA #$E9 ;SBC (immediate) + ;STA case_1 +2;LDA is +2 + ;LDA >V + ;STA case_1 +3 + ;;; Modifies SBC