diff --git a/wip-hugo/routines/circle/circle.inc b/wip-hugo/routines/circle/circle.inc index 13f4fb0..a55199c 100644 --- a/wip-hugo/routines/circle/circle.inc +++ b/wip-hugo/routines/circle/circle.inc @@ -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 diff --git a/wip-hugo/routines/circle/circle.s b/wip-hugo/routines/circle/circle.s index 0f23e5c..f87eb93 100644 --- a/wip-hugo/routines/circle/circle.s +++ b/wip-hugo/routines/circle/circle.s @@ -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: diff --git a/wip-hugo/routines/line/line.inc b/wip-hugo/routines/line/line.inc index 2d9c24b..fb6e999 100644 --- a/wip-hugo/routines/line/line.inc +++ b/wip-hugo/routines/line/line.inc @@ -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 diff --git a/wip-hugo/routines/line/line_down.s b/wip-hugo/routines/line/line_down.s index f489123..1580a45 100644 --- a/wip-hugo/routines/line/line_down.s +++ b/wip-hugo/routines/line/line_down.s @@ -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 diff --git a/wip-hugo/routines/line/line_down_inv.s b/wip-hugo/routines/line/line_down_inv.s index edc07d6..f57deee 100644 --- a/wip-hugo/routines/line/line_down_inv.s +++ b/wip-hugo/routines/line/line_down_inv.s @@ -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: diff --git a/wip-hugo/routines/line/line_up.s b/wip-hugo/routines/line/line_up.s index 82bd537..d6c93d6 100644 --- a/wip-hugo/routines/line/line_up.s +++ b/wip-hugo/routines/line/line_up.s @@ -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 diff --git a/wip-hugo/routines/line/line_up_inv.s b/wip-hugo/routines/line/line_up_inv.s index ab35f43..c847147 100644 --- a/wip-hugo/routines/line/line_up_inv.s +++ b/wip-hugo/routines/line/line_up_inv.s @@ -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: diff --git a/wip-hugo/routines/pixel/pixel.inc b/wip-hugo/routines/pixel/pixel.inc index 9c5f8d3..7534d23 100644 --- a/wip-hugo/routines/pixel/pixel.inc +++ b/wip-hugo/routines/pixel/pixel.inc @@ -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 diff --git a/wip-hugo/routines/pixel/pixel_calc.s b/wip-hugo/routines/pixel/pixel_calc.s new file mode 100644 index 0000000..fc4894d --- /dev/null +++ b/wip-hugo/routines/pixel/pixel_calc.s @@ -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 diff --git a/wip-hugo/routines/pixel/pixel_draw.s b/wip-hugo/routines/pixel/pixel_draw.s index 4dedf41..c4192a7 100755 --- a/wip-hugo/routines/pixel/pixel_draw.s +++ b/wip-hugo/routines/pixel/pixel_draw.s @@ -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 diff --git a/wip-hugo/source.s b/wip-hugo/source.s index 11cc962..7a59d20 100644 --- a/wip-hugo/source.s +++ b/wip-hugo/source.s @@ -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"