add pixel_calc that does the same as picel_draw without the drawing pixel part

This commit is contained in:
hugova 2025-07-14 12:24:35 +02:00
parent d09f417a49
commit 3a5a16cc06
11 changed files with 98 additions and 28 deletions

View file

@ -8,8 +8,8 @@
t2 = $E1
X_math = radius
Y_math = $E2
;; E8 - EA is used by pixel.inc
byte_to_paint_qaa = byte_to_paint
;; E9 - EA is used by pixel.inc
byte_to_paint_qaa = $E8
byte_to_paint_qcb = $E3
byte_to_paint_qca = $E4
byte_to_paint_qdb = $E5

View file

@ -45,7 +45,10 @@ draw_upper_px_in_circle:
SBC radius
STA Y_pos
JSR pixel_draw
JSR pixel_calc
;; A = byte_to_paint (small_X_offset)
;; Y =small_y_offset
;; btp_mem_pos (bigg_X_offset + bigg_Y-offset)
;; initial pixel for 2 half-quarter arias
LDA btp_mem_pos
@ -69,7 +72,12 @@ draw_left_px_in_circle: ;similar as above
SBC radius
STA X_pos
JSR pixel_draw
JSR pixel_calc
;; A = byte_to_paint (small_X_offset)
;; Y =small_y_offset
;; btp_mem_pos (bigg_X_offset + bigg_Y-offset)
STA byte_to_paint_qca
LDA btp_mem_pos
STA btp_mem_pos_qca
STA btp_mem_pos_qba
@ -77,9 +85,6 @@ draw_left_px_in_circle: ;similar as above
STA btp_mem_pos_qca + 1
STA btp_mem_pos_qba + 1
LDA byte_to_paint
STA byte_to_paint_qca
LDA temp__
STA X_pos
draw_lower_px_in_circle: ;similar as above
@ -88,7 +93,12 @@ draw_lower_px_in_circle: ;similar as above
ADC radius
STA Y_pos
JSR pixel_draw
JSR pixel_calc
;; A = byte_to_paint (small_X_offset)
;; Y =small_y_offset
;; btp_mem_pos (bigg_X_offset + bigg_Y-offset)
STA byte_to_paint_qdb
STA byte_to_paint_qcb
LDA btp_mem_pos
STA btp_mem_pos_qdb
@ -97,10 +107,6 @@ draw_lower_px_in_circle: ;similar as above
STA btp_mem_pos_qdb + 1
STA btp_mem_pos_qcb + 1
LDA byte_to_paint
STA byte_to_paint_qdb
STA byte_to_paint_qcb
STY Y_qdb
STY Y_qaa
@ -111,7 +117,11 @@ draw_right_px_in_circle:; similar as above
LDA X_pos
ADC radius
STA X_pos
JSR pixel_draw
JSR pixel_calc
;; A = byte_to_paint (small_X_offset)
;; Y =small_y_offset
;; btp_mem_pos (bigg_X_offset + bigg_Y-offset)
STA byte_to_paint_qaa
LDA btp_mem_pos
STA btp_mem_pos_qda
@ -123,7 +133,6 @@ draw_right_px_in_circle:; similar as above
LDX #$08 ; X=8 always expected inside the loop
SEC
while_x_bigger_then_y: ; C=1 here because above and branching logic
draw_pixels:
@ -230,13 +239,13 @@ change_x:
DEC X_math
STA t1 ; t1 = t2
qaa_x:
ASL byte_to_paint
ASL byte_to_paint_qaa
BCC qaa_x_end
qaa_x_overflow:
Sub_16 btp_mem_pos_qaa, btp_mem_pos_qaa + 1, #$08, #$00, ! ;-8
Sub_16 btp_mem_pos_qda, btp_mem_pos_qda + 1, #$08, #$00, ! ;-8
;; Restores byte to paint
INC byte_to_paint
INC byte_to_paint_qaa
qaa_x_end:
qca_x:

View file

@ -4,9 +4,10 @@
X_end = ARGVEC + 2
Y_end = ARGVEC + 3
;; private args
dx = $E0
dy = $E2
dy_2 = dy ; 16-bit value (uses E1)
dx_2 = dx ; 16-bit value (uses E3)
V = $E4 ; 16-bit value (uses E5)
D = $E6 ; 16-bit value (uses E7)
dx = $E0
dy = $E2
dy_2 = dy ; 16-bit value (uses E1)
dx_2 = dx ; 16-bit value (uses E3)
V = $E4 ; 16-bit value (uses E5)
D = $E6 ; 16-bit value (uses E7)
byte_to_paint = $E8

View file

@ -62,7 +62,8 @@ selfmod:
LDA V + 1
STA case_1 + 7
end_selfmod:
JSR pixel_draw ;;only used first pixel. after this relative position is abused
JSR pixel_calc ;;only used first pixel. after this relative position is abused
STA byte_to_paint
;; X = X_end - X_pos
LDX dx
LDY #$00

View file

@ -39,7 +39,8 @@ selfmod:
LDA V + 1
STA case_1 + 7
end_selfmod:
jsr pixel_draw
JSR pixel_calc ;;only used first pixel. after this relative position is abused
STA byte_to_paint
LDY #$00
LDX dy
for_y:

View file

@ -40,7 +40,8 @@ selfmod:
LDA V + 1
STA case_1 + 7
end_selfmod:
jsr pixel_draw
JSR pixel_calc ;;only used first pixel. after this relative position is abused
STA byte_to_paint
Sub_16 btp_mem_pos, btp_mem_pos + 1, #$01, #$00 ;; Y has always a offset of at least 1
LDY #$01
LDX dx

View file

@ -39,7 +39,8 @@ selfmod:
LDA V + 1
STA case_1 + 7
end_selfmod:
jsr pixel_draw
JSR pixel_calc ;;only used first pixel. after this relative position is abused
STA byte_to_paint
LDY #$00
LDX dy
for_y:

View file

@ -4,6 +4,5 @@
Y_pos = ARGVEC + 0
X_pos = ARGVEC + 1
;; Private args
byte_to_paint = $E8
btp_mem_pos = $E9 ; 16-bit value (uses EA), byte to paint memory position
Bitmap = $4000

View file

@ -0,0 +1,57 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;;Calculates values needed to draw a pixel on screen!
.proc pixel_calc
.include "pixel.inc"
;;FIND position to write byte_to_paint (btp_mem_pos)
;; + + + + + > X
;; +
;; +
;;\/
;; Y
;; The screen has a wierd memory to pixel maping!
;; Each line of 8 pixels is one byte
;; 8 consecutive bytes in memory makes up a chunk and are 'under each other' on the screen
;; the chunks are orderd from the left to the right and then looping downwards.
;; Therefore we have that: btp_mem_pos = big_x_offset + smal_y_offset + big_y_offset + bitmap_offset
;; We use a lookup-table for big_y_offset + bitmap_offset (see END.s)
;; (Y_pos / 8 floor)*2
LDA Y_pos
LSR A
LSR A
;; We need to remove the last digit if its still there
;; same as LSR ASR
AND #%11111110
TAX
;; big_y_offset + big_x_offset
CLC
;;A = big_x_offset
LDA #%11111000
AND X_pos
ADC big_y_offset, X
STA btp_mem_pos
LDA #$00
INX
ADC big_y_offset, X
STA btp_mem_pos + 1
;; + small_y_offset
LDA #%00000111 ; A = y (mod 8)
AND Y_pos ;; offset to add
TAY
calc_byte_to_paint: ;; aka small_x_offset
LDA X_pos
AND #%00000111
TAX
;;this is the same as: byte_to_paint = 2^X
LDA binary_factor, X;; (see END.s)
;; A = byte_to_paint (small_X_offset)
;; Y =small_y_offset
;; btp_mem_pos (bigg_X_offset + bigg_Y-offset)
RTS
.endproc

View file

@ -49,7 +49,6 @@ calc_byte_to_paint: ;; aka small_x_offset
TAX
;;this is the same as: byte_to_paint = 2^X
LDA binary_factor, X;; (see END.s)
STA byte_to_paint ;; should be removed, here for other code!
draw: ;;Let draw some stuff
ORA (btp_mem_pos), Y

View file

@ -26,6 +26,7 @@ JMP exit
.include "routines/circle/circle.s"
.include "routines/triangle/triangle.s"
.include "routines/pixel/pixel_draw.s"
.include "routines/pixel/pixel_calc.s"
.include "routines/text/char_draw.s"
.include "routines/memory/memset.s"
.include "routines/memory/memcpy.s"