Made math befor line-draw-loop faster. from 811183 cpu cykles to 809951

This commit is contained in:
hugova 2025-04-03 16:58:55 +02:00
parent 589fd5d738
commit f93557bfd9
8 changed files with 26 additions and 43 deletions

View file

@ -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

View file

@ -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

View file

@ -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|

View file

@ -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

View file

@ -43,11 +43,7 @@ end_selfmod:
jsr pixel_draw
Sub_16 >btp_mem_pos, <btp_mem_pos, #$01, #$00 ;; Y has always a offset of at least 1
LDY #$01
;; X = X_end - X_pos
LDA X_end
SEC
SBC X_pos
TAX
LDX dx
for_x:
LDA byte_to_paint
ORA (>btp_mem_pos), Y

View file

@ -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

View file

@ -9,5 +9,5 @@
X_pos = $FCFD
byte_to_paint = $FE
btp_mem_pos = $F9FA; byte to paint memory position
C = $7071
B =$7273
C = $F7F8
B = $F5F6

View file

@ -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