From 25e65d8197502b8a99c277ac8bd4a45926bb0e45 Mon Sep 17 00:00:00 2001 From: hugova Date: Thu, 24 Jul 2025 21:46:31 +0200 Subject: [PATCH 1/5] modify linetest to highlight out of bound bad behaviour of line --- wip-hugo/routines/line/line_test_extensive.s | 78 +++++++++++--------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/wip-hugo/routines/line/line_test_extensive.s b/wip-hugo/routines/line/line_test_extensive.s index 6fa69ed..2790b51 100644 --- a/wip-hugo/routines/line/line_test_extensive.s +++ b/wip-hugo/routines/line/line_test_extensive.s @@ -6,16 +6,16 @@ .include "../memory/mem.inc" Y_pos_ = $0D X_pos_ = $0E - Y_end_ = $10 - X_end_ = $11 + Y_end_ = $0F + X_end_ = $0C LDA #$d2 STA X_pos_ LDA #$62 STA Y_pos_ LDA #$ff - STA X_end + STA X_end_ LDA #$0 - STA Y_end + STA Y_end_ ;; Full angle test @loop: @@ -23,16 +23,17 @@ STA Y_pos LDA X_pos_ STA X_pos + LDA X_end_ + STA X_end + LDA Y_end_ + STA Y_end jsr line - INC Y_end - LDA Y_end - CMP #$bb + INC Y_end_ + LDA Y_end_ + CMP #$ff bne @loop - - hihi: - jmp hihi clear_screen: ;;Lets clear bitmap VIC_bank = $4000 @@ -48,18 +49,23 @@ long_line_test_a: LDA #$60 STA Y_pos_ LDA #$ff - STA X_end + STA X_end_ LDA #$0 - STA Y_end + STA Y_end_ @loop: LDA Y_pos_ STA Y_pos LDA X_pos_ STA X_pos + LDA X_end_ + STA X_end + LDA Y_end_ + STA Y_end + jsr line - INC Y_end - LDA Y_end - CMP #$bb + INC Y_end_ + LDA Y_end_ + CMP #$ff BNE @loop clear_screen_: @@ -68,24 +74,28 @@ clear_screen_: Mov_16 length, length + 1, #<$1f40, #>$1f40 LDA #$00 jsr memset -long_line_test_b: -LDA #$00 -STA X_pos_ -LDA #$00 -STA Y_pos_ -LDA #$ff -STA X_end -LDA #$60 -STA Y_end -@loop: -LDA Y_pos_ -STA Y_pos -LDA X_pos_ -STA X_pos -jsr line -INC Y_pos_ -LDA Y_pos_ -CMP #$bb -BNE @loop +long_line_test_b: + LDA #$00 + STA X_pos_ + LDA #$00 + STA Y_pos_ + LDA #$ff + STA X_end_ + LDA #$60 + STA Y_end_ +@loop: + LDA Y_pos_ + STA Y_pos + LDA X_pos_ + STA X_pos + LDA X_end_ + STA X_end + LDA Y_end_ + STA Y_end + jsr line + INC Y_pos_ + LDA Y_pos_ + CMP #$ff + BNE @loop .endscope From f7d4a4e83fe5b103e4c3dd5ed4cdc835bf70430d Mon Sep 17 00:00:00 2001 From: hugova Date: Thu, 24 Jul 2025 21:48:26 +0200 Subject: [PATCH 2/5] modify linedraw to not draw outside screen aria. --- wip-hugo/routines/line/line.inc | 1 + wip-hugo/routines/line/line.s | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/wip-hugo/routines/line/line.inc b/wip-hugo/routines/line/line.inc index fb6e999..31a4b58 100644 --- a/wip-hugo/routines/line/line.inc +++ b/wip-hugo/routines/line/line.inc @@ -11,3 +11,4 @@ V = $E4 ; 16-bit value (uses E5) D = $E6 ; 16-bit value (uses E7) byte_to_paint = $E8 + ;; E9 in use of pixel_calc diff --git a/wip-hugo/routines/line/line.s b/wip-hugo/routines/line/line.s index 796214e..320a1a9 100644 --- a/wip-hugo/routines/line/line.s +++ b/wip-hugo/routines/line/line.s @@ -1,8 +1,24 @@ ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- .proc line; user-procedure :clobbers (A X Y) :clobbers-arguments 4 -;X_pos =< X_end skall alltid gälla + .include "line.inc" + +;; Fix line that is too long + LDA Y_pos + CMP #$C8 ;;y_max = $C8 + BCC do_not_fix_y_pos + LDA #$C8 + STA Y_pos +do_not_fix_y_pos: + LDA Y_end + CMP #$C8 ;;y_max = $C8 + BCC do_not_fix_y_end + LDA #$C8 + STA Y_end +do_not_fix_y_end: + + ;;dx SEC LDA X_end From cd0a91b34ea061b3e109f4fb0aaef4da276d30ef Mon Sep 17 00:00:00 2001 From: hugova Date: Fri, 25 Jul 2025 09:00:32 +0200 Subject: [PATCH 3/5] modify line.s to make it work if X_pos > X_end --- .gitignore | 3 +- wip-hugo/routines/line/line.s | 17 +++++++++-- wip-hugo/routines/line/line_test_extensive.s | 32 ++++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 9f406fc..537ecd2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ *.lst *.lst *.note -./build/* +*.lbl +build/* diff --git a/wip-hugo/routines/line/line.s b/wip-hugo/routines/line/line.s index 320a1a9..9768771 100644 --- a/wip-hugo/routines/line/line.s +++ b/wip-hugo/routines/line/line.s @@ -23,10 +23,23 @@ do_not_fix_y_end: SEC LDA X_end SBC X_pos - STA dx - BCC dx_no_underflow;; X_end >= X_pos + BCS dx_no_underflow;; X_end >= X_pos EOR #$ff ; Fix bit underflow + STA dx + ;; line_* expect X_pos < X_end and now its not the case. + ;; Lets move them around + LDX X_pos + LDY X_end + STX X_end + STY X_pos + LDX Y_pos + LDY Y_end + STX Y_end + STY Y_pos + + dx_no_underflow: + STA dx SEC LDA Y_pos SBC Y_end diff --git a/wip-hugo/routines/line/line_test_extensive.s b/wip-hugo/routines/line/line_test_extensive.s index 2790b51..4f79005 100644 --- a/wip-hugo/routines/line/line_test_extensive.s +++ b/wip-hugo/routines/line/line_test_extensive.s @@ -98,4 +98,36 @@ long_line_test_b: LDA Y_pos_ CMP #$ff BNE @loop + +clear_screen__: + ;;Paint the bitmap black. More bitmap: https://www.c64-wiki.com/wiki/53272, https://www.c64-wiki.com/wiki/Screen_RAM#Moving_of_screen_RAM + Mov_16 A_start, A_start + 1, #VIC_bank + Mov_16 length, length + 1, #<$1f40, #>$1f40 + LDA #$00 + jsr memset + +long_line_test_b_pos_end_swapped: + LDA #$00 + STA X_end_ + LDA #$00 + STA Y_end_ + LDA #$ff + STA X_pos_ + LDA #$60 + STA Y_pos_ +@loop: + LDA Y_end_ + STA Y_end + LDA X_end_ + STA X_end + LDA X_pos_ + STA X_pos + LDA Y_pos_ + STA Y_pos + jsr line + INC Y_end_ + LDA Y_end_ + CMP #$ff + BNE @loop + .endscope From 2715c7aab273008d6224a123890c89bf0777b694 Mon Sep 17 00:00:00 2001 From: hugova Date: Fri, 25 Jul 2025 09:25:37 +0200 Subject: [PATCH 4/5] remove build dir from github --- wip-hugo/build/program.lbl | 159 ------------------------------------- 1 file changed, 159 deletions(-) delete mode 100644 wip-hugo/build/program.lbl diff --git a/wip-hugo/build/program.lbl b/wip-hugo/build/program.lbl deleted file mode 100644 index 5a6fe18..0000000 --- a/wip-hugo/build/program.lbl +++ /dev/null @@ -1,159 +0,0 @@ -al 001315 .__BSS_LOAD__ -al 001315 .__BSS_RUN__ -al 000000 .__BSS_SIZE__ -al 000001 .__EXEHDR__ -al 000001 .__LOADADDR__ -al 000000 .__ZP_FILEOFFS__ -al 000002 .__ZP_LAST__ -al 0000FE .__ZP_SIZE__ -al 000002 .__ZP_START__ -al 0012D5 .big_y_offset -al 00129F .binary_factor -al 001294 .log -al 00128B .inverse_factor_value -al 00128A .for_i_end -al 001282 .R_pos -al 001286 .R_neg -al 001275 .for_i -al 00126B .div -al 00126A .endloop -al 00125D .loop -al 00125F .start -al 001258 .mult -al 001248 .change_length -al 001251 .y_overflow -al 001241 .loop -al 00123F .memcpy -al 001200 .big_set_end -al 001208 .small_set -al 000F01 .big_set -al 000EFA .memset -al 000ED0 .move_data -al 000EA7 .calculate_screen_position -al 000E8D .calculate_petski_position -al 000E8D .char_draw -al 000E84 .calc_byte_to_paint -al 000E66 .pixel_calc -al 000E61 .draw -al 000E59 .calc_byte_to_paint -al 000E3B .pixel_draw -al 000E39 .draw_lower_triangle -al 000E2D .draw_upper_triangle -al 000E16 .BC_overflow -al 000E2D .BC_overflow_end -al 000DF9 .AB_overflow -al 000E0D .AB_overflow_end -al 000DF0 .triangle -al 000DEF .end -al 000DCA .qbb_y_overflow -al 000DE6 .qbb_y_end -al 000DC4 .qbb_y -al 000DAA .qdb_overflow -al 000DC4 .qdb_y_end -al 000DA6 .qdb_y -al 000D8C .qca_x_overflow -al 000DA6 .qca_x_end -al 000D88 .qca_x -al 000D6E .qaa_x_overflow -al 000D88 .qaa_x_end -al 000D6A .qaa_x -al 000D66 .change_x -al 000DE6 .endif -al 000D66 .if -al 000D3D .qcb_x_overflow -al 000D58 .qcb_x_end -al 000D39 .qcb_x -al 000D1F .qdb_x_overflow -al 000D39 .qdb_x_end -al 000D1B .qdb_x -al 000CFF .qda_y_overflow -al 000D1B .qda_y_end -al 000CF9 .qda_y -al 000CDF .qaa_y_underflow -al 000CF9 .qaa_y_end -al 000CDB .qaa_y -al 000CD9 .change_Y -al 000CD1 .draw_qab -al 000CC9 .draw_qbb -al 000CC3 .draw_qdb -al 000CBB .draw_qcb -al 000CB5 .draw_qca -al 000CAD .draw_qda -al 000CA7 .draw_qba -al 000C9F .draw_qaa -al 000C9F .draw_pixels -al 000C9F .while_x_bigger_then_y -al 000C85 .draw_right_px_in_circle -al 000C64 .draw_lower_px_in_circle -al 000C46 .draw_left_px_in_circle -al 000C28 .draw_upper_px_in_circle -al 000C1C .circle -al 000BF9 .move_8px_left -al 000BF5 .increment_pixel_x -al 000C1B .end -al 000BD4 .move_8px_up -al 000BE2 .decrement_y_pos_end -al 000BD1 .decrement_y_pos -al 000BCB .for_y -al 000BB6 .end_selfmod -al 000BE9 .case_1 -al 000C0B .case_2 -al 000BA2 .selfmod -al 000B64 .decrement_y_pos_end -al 000B52 .move_8px_up -al 000B4F .decrement_y_pos -al 000B73 .end -al 000B2E .move_8px_left -al 000B3C .increment_pixel_x_end -al 000B2A .increment_pixel_x -al 000B24 .for_x -al 000B10 .end_selfmod -al 000B43 .case_1 -al 000B64 .case_2 -al 000AFC .selfmod -al 000AB7 .move_8px_left -al 000AB3 .increment_pixel_x -al 000AD8 .end -al 000A92 .move_8px_down -al 000AA0 .increment_y_pos_end -al 000A8F .increment_y_pos -al 000A89 .for_y -al 000A68 .end_selfmod -al 000AA7 .case_1 -al 000AC8 .case_2 -al 000A54 .selfmod -al 000A16 .decrement_y_pos_end -al 000A04 .move_8px_up -al 000A01 .decrement_y_pos -al 000A25 .end -al 0009E0 .move_8px_right -al 0009EE .decrement_pixel_x_end -al 0009DC .decrement_pixel_x -al 0009D6 .for_x -al 0009B6 .end_selfmod -al 0009F5 .case_1 -al 000A16 .case_2 -al 0009A2 .selfmod -al 000974 .line_down -al 000A26 .line_down_inv -al 00096C .steep_ -al 000970 .shallow_ -al 000AD9 .line_up -al 000B74 .line_up_inv -al 00095A .steep -al 00095E .shallow -al 000954 .up -al 000964 .down -al 00094B .dx_no_underflow -al 000940 .line -al 00093D .exit -al 000928 .@loop -al 000916 .long_line_test_b -al 000901 .clear_screen_ -al 0008EA .@loop -al 0008D8 .long_line_test_a -al 0008C3 .clear_screen -al 0008C0 .hihi -al 0008A9 .@loop -al 000897 .NMI_routine_end -al 000896 .NMI_routine From 97a7a131a2e6070e35c6d3df86e444fd6205cf3d Mon Sep 17 00:00:00 2001 From: hugova Date: Fri, 25 Jul 2025 09:32:34 +0200 Subject: [PATCH 5/5] disable unused lookup-tabels for lower memory footprint --- wip-hugo/END.s | 166 ++++++++++++++++++++++++------------------------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/wip-hugo/END.s b/wip-hugo/END.s index bc46e95..efe0282 100644 --- a/wip-hugo/END.s +++ b/wip-hugo/END.s @@ -1,75 +1,75 @@ -inverse_factor_value: ;lookup 00000001 --gives--> 10000000 , etc etc. only 1st 1 in binary numbers -NOP -.byte %10000000, %01000000; (inverse factor value) -NOP -.byte %00100000; (inverse factor value) -NOP -NOP;.byte $0; (log) -NOP;.byte $1; (log) -.byte %00010000; (inverse factor value) -log: -NOP -.byte $0; (log) -.byte $1; (log) -NOP -.byte $2 -NOP -NOP -.byte %00001000; (inverse factor value) -.byte $3 -NOP -NOP -;; i put another lookup table where nops normaly are' +;inverse_factor_value: ;lookup 00000001 --gives--> 10000000 , etc etc. only 1st 1 in binary numbers +;NOP +;.byte %10000000, %01000000; (inverse factor value) +;NOP +;.byte %00100000; (inverse factor value) +;NOP +;NOP;.byte $0; (log) +;NOP;.byte $1; (log) +;.byte %00010000; (inverse factor value) +;log: +;NOP +;.byte $0; (log) +;.byte $1; (log) +;NOP +;.byte $2 +;NOP +;NOP +;.byte %00001000; (inverse factor value) +;.byte $3 +;NOP +;NOP +;;; i put another lookup table where nops normaly are' binary_factor: .byte %10000000, %01000000, %00100000, %00010000, %00001000, %00000100, %00000010, %00000001; (binary factor) ;; ^(log) -NOP -NOP -NOP -NOP -.byte %00000100; (inverse factor value) -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -.byte $5 -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -.byte %00000010; (inverse factor value) - -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -.byte $6 +;NOP +;NOP +;NOP +;NOP +;.byte %00000100; (inverse factor value) +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;.byte $5 ;(log) +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;.byte %00000010; (inverse factor value) +; +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;.byte $6; (log) ;; i put another lookup table where nops normaly are Bitmap = $4000 ;;This is used by pixel_draw! look at it for more detail @@ -124,17 +124,17 @@ big_y_offset: .hibytes $1CC0 + Bitmap .lobytes $1E00 + Bitmap .hibytes $1E00 + Bitmap -NOP -NOP -NOP -NOP -.byte %00000001 -NOP -NOP -NOP -NOP -NOP -NOP -NOP -NOP -.byte $7 +;NOP +;NOP +;NOP +;NOP +;.byte %00000001; (inverse factor value) +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;NOP +;.byte $7; (log)