From 7448909da8f7d8a737a78d7c9966401ebdafa015 Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Wed, 24 Apr 2019 16:13:24 +0930 Subject: [PATCH] more documentation of similarities and avoiding them where practicable. --- c64/kernal/chrout.s | 11 +++++----- c64/kernal/cint.s | 14 ++++++------ src/similarity.c | 12 +++++++++++ strings/18692885 | 5 +++++ strings/424153494320 | 4 ++++ strings/4241534943205632 | 8 +++++++ strings/60AD8D02 | 7 ++++++ strings/7702E8 | 3 +++ strings/860291F3 | 3 +++ strings/88B1D1C891D188 | 44 ++++++++++++++++++++++++++++++++++++++ strings/88B1F3C891F388 | 44 ++++++++++++++++++++++++++++++++++++++ strings/8D02C903D0 | 4 ++++ strings/8D8C02A90E8D8602A9 | 1 + strings/A6C6EC8902 | 3 +++ strings/B1D1C920 | 4 ++++ strings/E6C911D0 | 3 +++ strings/E6C913D0 | 3 +++ 17 files changed, 161 insertions(+), 12 deletions(-) create mode 100644 strings/18692885 create mode 100644 strings/424153494320 create mode 100644 strings/4241534943205632 create mode 100644 strings/60AD8D02 create mode 100644 strings/7702E8 create mode 100644 strings/860291F3 create mode 100644 strings/88B1D1C891D188 create mode 100644 strings/88B1F3C891F388 create mode 100644 strings/8D02C903D0 create mode 100644 strings/8D8C02A90E8D8602A9 create mode 100644 strings/A6C6EC8902 create mode 100644 strings/B1D1C920 create mode 100644 strings/E6C911D0 create mode 100644 strings/E6C913D0 diff --git a/c64/kernal/chrout.s b/c64/kernal/chrout.s index 7f255c68..66321455 100644 --- a/c64/kernal/chrout.s +++ b/c64/kernal/chrout.s @@ -88,12 +88,13 @@ no_need_to_extend: dey cpy current_screen_x bne - - ;; Put space in the inserted gap - lda #$20 - sta (current_screen_line_ptr),y ;; Increase insert mode count (which causes quote-mode like behaviour) inc insert_mode + + ;; Put space in the inserted gap + lda #$20 + sta (current_screen_line_ptr),y jmp chrout_done not_94: @@ -566,10 +567,10 @@ scroll_copy_loop2: ;; Fill in scrolled up area ldx load_or_scroll_temp_pointer+0 scroll_copy_loop3: - lda #$20 - sta (current_screen_line_ptr),y lda text_colour sta (current_screen_line_colour_ptr),y + lda #$20 + sta (current_screen_line_ptr),y iny dex bne scroll_copy_loop3 diff --git a/c64/kernal/cint.s b/c64/kernal/cint.s index 987e3682..48c85877 100644 --- a/c64/kernal/cint.s +++ b/c64/kernal/cint.s @@ -26,18 +26,18 @@ cint: ;; Making some numbers up here: Repeat every ~1/10th sec ;; But require key to be held for ~1/3sec before ;; repeating (Compute's Mapping the 64 p58) - lda #22-2 ; Fudge factor to match speed - sta key_first_repeat_delay + ldx #22-2 ; Fudge factor to match speed + stx key_first_repeat_delay ;; Set current colour for text (Compute's Mapping the 64 p215) - lda #$0e ; light blue by default - sta $0286 + ldx #$0e ; light blue by default + stx $0286 ;; Set maximum keyboard buffer size (Compute's Mapping the 64 p215) - lda #10 - sta key_buffer_size + ldx #10 + stx key_buffer_size ;; Put non-zero value in enable_case_switch - sta enable_case_switch + stx enable_case_switch ;; Fallthrough/jump to screen clear routine (Compute's Mapping the 64 p215) jmp clear_screen diff --git a/src/similarity.c b/src/similarity.c index e2da0275..b0eeee8e 100644 --- a/src/similarity.c +++ b/src/similarity.c @@ -108,6 +108,12 @@ int main(int argc,char **argv) // Ignore matches of no more than 3 bytes, // since that is the max length of a 6502 instruction int single_instruction=0; + if (k==5) { + if (f1[i]==0xa9&&f1[i+2]==0x8d) break; // LDA #$xx / STA $nnnn + } + if (k==4) { + if (f1[i]==0xa9&&f1[i+2]==0x85) break; // LDA #$xx / STA $nn + } if (k==3) { // Reject some very common instruction fragments @@ -118,6 +124,12 @@ int main(int argc,char **argv) if (f1[i]==0xb0) break; if (f1[i]==0x90) break; if (f1[i]==0x10) break; + // Any single byte followed by a branch + if (f1[i+1]==0xd0) break; + if (f1[i+1]==0xf0) break; + if (f1[i+1]==0xb0) break; + if (f1[i+1]==0x90) break; + if (f1[i+1]==0x10) break; // Any 2-byte opcode followed by a branch if (f1[i+2]==0xd0) break; if (f1[i+2]==0xf0) break; diff --git a/strings/18692885 b/strings/18692885 new file mode 100644 index 00000000..a94f3448 --- /dev/null +++ b/strings/18692885 @@ -0,0 +1,5 @@ +CLC / ADC #40 / STA $nn + +Add 40 to a ZP location. No creativity here. +Effectivelhy only one insstruction. +Not copyrightable. diff --git a/strings/424153494320 b/strings/424153494320 new file mode 100644 index 00000000..4af9e654 --- /dev/null +++ b/strings/424153494320 @@ -0,0 +1,4 @@ +string "BASIC " + +Since we are writing a BASIC language interprettor, such a string is expected. +BASIC appears in many other works. It cannot be copyrighted as a word. diff --git a/strings/4241534943205632 b/strings/4241534943205632 new file mode 100644 index 00000000..0c273391 --- /dev/null +++ b/strings/4241534943205632 @@ -0,0 +1,8 @@ +String "BASIC V2" + +As we are implementing a V2 class BASIC interprettor, it is +natural for us to include this string. +There are many BASIC intreprettors, and the word cannot be +copyrighted, nor it is reasonable to contemplate that a party +could be constrained from having a BASIC with version 2, or +displaying that information anywhere. Not copyrightable. diff --git a/strings/60AD8D02 b/strings/60AD8D02 new file mode 100644 index 00000000..fba2598d --- /dev/null +++ b/strings/60AD8D02 @@ -0,0 +1,7 @@ +RTS + LDA $028D + +RTS is a very common instruction, as is loading A from absolute address. +The RTS is the end of a routine, and the LDA $028D thus the start of +another. Thus this would occur whenever a routine begins with loading +A from $028D, immediately after another routine. Nothing creative. +Not copyrightable. diff --git a/strings/7702E8 b/strings/7702E8 new file mode 100644 index 00000000..cd69c818 --- /dev/null +++ b/strings/7702E8 @@ -0,0 +1,3 @@ +Something with $0277 / INX + +Only one whole instruction here. Not copyrightable. diff --git a/strings/860291F3 b/strings/860291F3 new file mode 100644 index 00000000..3136753e --- /dev/null +++ b/strings/860291F3 @@ -0,0 +1,3 @@ +something with $0286 / STA ($F3),Y + +Only one whole instruction. Not copyrightable. diff --git a/strings/88B1D1C891D188 b/strings/88B1D1C891D188 new file mode 100644 index 00000000..b60ab987 --- /dev/null +++ b/strings/88B1D1C891D188 @@ -0,0 +1,44 @@ +Copy screen + colour RAM to the right one place + +This sequence of instructions: + +loop: + DEY + LDA ($D1),Y + INY + STA ($D1),Y + DEY + LDA ($F3),Y + INY + STA ($F3),Y + DEY + CPY $D3 + BNE loop + LDA #$20 + STA ($D1),Y + +is the obvious any minimal way to copy the screen and colour RAM data. +The constants $D1 and $F3 are fixed by the publicly documented interface +of the KERNAL to point to the screen and colour RAM of the screen. + +The Y register is the only register that can be used to post-increment an +indirect address on the 6502. + +Thus the only efficient manner to copy a string to the right one byte +is to read, increment Y by one to get the destination address, store, +then decrement Y again so that it points to the source offset, now read +the colour RAM byte, add one to Y so that we point to the destination, +and then write it. + +Similarly the check against $D3 (current column of cursor on screen) is also +necessary for working out when to terminate the loop. The storing of $20 +into the screen RAM is also required to effect the insertion of a space. + +In fact, about the only variant possible would be to swap the $D1 and $F3 +constants so that the colour RAM is copied before the screen RAM in each +loop, instead of after it. + +It is telling that this routine was the result of independent implementation +of this routine, without looking at the KERNALs routine, in terms of supporting +the argument that the routine is the obvious manner in which to do this. + diff --git a/strings/88B1F3C891F388 b/strings/88B1F3C891F388 new file mode 100644 index 00000000..b60ab987 --- /dev/null +++ b/strings/88B1F3C891F388 @@ -0,0 +1,44 @@ +Copy screen + colour RAM to the right one place + +This sequence of instructions: + +loop: + DEY + LDA ($D1),Y + INY + STA ($D1),Y + DEY + LDA ($F3),Y + INY + STA ($F3),Y + DEY + CPY $D3 + BNE loop + LDA #$20 + STA ($D1),Y + +is the obvious any minimal way to copy the screen and colour RAM data. +The constants $D1 and $F3 are fixed by the publicly documented interface +of the KERNAL to point to the screen and colour RAM of the screen. + +The Y register is the only register that can be used to post-increment an +indirect address on the 6502. + +Thus the only efficient manner to copy a string to the right one byte +is to read, increment Y by one to get the destination address, store, +then decrement Y again so that it points to the source offset, now read +the colour RAM byte, add one to Y so that we point to the destination, +and then write it. + +Similarly the check against $D3 (current column of cursor on screen) is also +necessary for working out when to terminate the loop. The storing of $20 +into the screen RAM is also required to effect the insertion of a space. + +In fact, about the only variant possible would be to swap the $D1 and $F3 +constants so that the colour RAM is copied before the screen RAM in each +loop, instead of after it. + +It is telling that this routine was the result of independent implementation +of this routine, without looking at the KERNALs routine, in terms of supporting +the argument that the routine is the obvious manner in which to do this. + diff --git a/strings/8D02C903D0 b/strings/8D02C903D0 new file mode 100644 index 00000000..6d57bf28 --- /dev/null +++ b/strings/8D02C903D0 @@ -0,0 +1,4 @@ +something with $028D / CMP #$03 / BNE somewhere + +Only one whole instruction. Nothing creative. +Not copyrightable. diff --git a/strings/8D8C02A90E8D8602A9 b/strings/8D8C02A90E8D8602A9 new file mode 100644 index 00000000..c06c4458 --- /dev/null +++ b/strings/8D8C02A90E8D8602A9 @@ -0,0 +1 @@ +STA $028C / LDA #$0E / STA $0286 / LDA diff --git a/strings/A6C6EC8902 b/strings/A6C6EC8902 new file mode 100644 index 00000000..d67df7a1 --- /dev/null +++ b/strings/A6C6EC8902 @@ -0,0 +1,3 @@ +Use X register to compare contents of a ZP and absolute address location + +Nothing copyrightable here in this simple comparison of memory contents. diff --git a/strings/B1D1C920 b/strings/B1D1C920 new file mode 100644 index 00000000..1f0da1c4 --- /dev/null +++ b/strings/B1D1C920 @@ -0,0 +1,4 @@ +LDA ($D1),Y / CMP #$20 + +Compare a byte read from a pointer with a specific value. +No creativity here. Not copyrightable. diff --git a/strings/E6C911D0 b/strings/E6C911D0 new file mode 100644 index 00000000..105c3ae5 --- /dev/null +++ b/strings/E6C911D0 @@ -0,0 +1,3 @@ +Fragment / CMP #$11 / BNE somewhere + +Only one whole intruction here. Not copyrightable. diff --git a/strings/E6C913D0 b/strings/E6C913D0 new file mode 100644 index 00000000..bf3b93e1 --- /dev/null +++ b/strings/E6C913D0 @@ -0,0 +1,3 @@ +Fragment / CMP #$13 / BNE somewhere + +Only one whole intruction here. Not copyrightable.