From 86ea5fba390f961aeeee858ab0895c97bc496788 Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Wed, 24 Apr 2019 19:56:17 +0930 Subject: [PATCH] address all detected similarities to C64 BASIC ROM. --- Makefile | 1 + c64/kernal/scan_keyboard.s | 6 +++--- strings/02A9008D | 4 ++++ strings/034C08 | 3 +++ strings/0DD0034C | 4 ++++ strings/1001CAC8 | 3 +++ strings/41534943 | 4 ++++ strings/48A00098 | 4 ++++ strings/49FF2980 | 3 +++ strings/642663 | 4 ++++ strings/68A8B9 | 4 ++++ strings/68AAA5 | 5 +++++ strings/8A48A9 | 4 ++++ strings/981865 | 5 +++++ strings/984820 | 6 ++++++ strings/9D0002E8 | 3 +++ strings/A002A900 | 4 ++++ strings/A9282CA9 | 43 ++++++++++++++++++++++++++++++++++++++ strings/AA9848 | 5 +++++ strings/C922D006A5 | 4 ++++ strings/D71860 | 5 +++++ strings/D71880 | 5 +++++ strings/E90085 | 4 ++++ 23 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 strings/02A9008D create mode 100644 strings/034C08 create mode 100644 strings/0DD0034C create mode 100644 strings/1001CAC8 create mode 100644 strings/41534943 create mode 100644 strings/48A00098 create mode 100644 strings/49FF2980 create mode 100644 strings/642663 create mode 100644 strings/68A8B9 create mode 100644 strings/68AAA5 create mode 100644 strings/8A48A9 create mode 100644 strings/981865 create mode 100644 strings/984820 create mode 100644 strings/9D0002E8 create mode 100644 strings/A002A900 create mode 100644 strings/A9282CA9 create mode 100644 strings/AA9848 create mode 100644 strings/C922D006A5 create mode 100644 strings/D71860 create mode 100644 strings/D71880 create mode 100644 strings/E90085 diff --git a/Makefile b/Makefile index 9dd2f7e1..ae9da204 100644 --- a/Makefile +++ b/Makefile @@ -45,3 +45,4 @@ test: newkern newbasic testsimilarity: newkern newbasic src/similarity src/similarity kernal newrom + src/similarity basic newrom diff --git a/c64/kernal/scan_keyboard.s b/c64/kernal/scan_keyboard.s index 9bf7b038..bd84f067 100644 --- a/c64/kernal/scan_keyboard.s +++ b/c64/kernal/scan_keyboard.s @@ -284,7 +284,7 @@ next_row: lda #$00 sta key_bucky_state lda ScanResult+6 - eor #$ff + eor #%10000000 and #%10000000 ;// Left shift rol rol @@ -294,7 +294,7 @@ next_row: ;; Right shift lda ScanResult+1 - eor #$ff + eor #$10 lsr lsr lsr @@ -305,7 +305,7 @@ next_row: ;; Control lda ScanResult+0 - eor #$ff + eor #$04 and #$04 ora key_bucky_state sta key_bucky_state diff --git a/strings/02A9008D b/strings/02A9008D new file mode 100644 index 00000000..fd92d6b6 --- /dev/null +++ b/strings/02A9008D @@ -0,0 +1,4 @@ +Fragment / LDA #$00 / STA $xxxx + +Store zero in a memory location somewhere. +Not copyrightable. diff --git a/strings/034C08 b/strings/034C08 new file mode 100644 index 00000000..e345755f --- /dev/null +++ b/strings/034C08 @@ -0,0 +1,3 @@ +fragment / JMP $xx08 + +Not even a whole instruction. Not copyrightable. diff --git a/strings/0DD0034C b/strings/0DD0034C new file mode 100644 index 00000000..741b355e --- /dev/null +++ b/strings/0DD0034C @@ -0,0 +1,4 @@ +fragment / BNE / JMP somewhere + +Conditionally jump somewhere. Would be a single instruction +on many architectures. Not copyrightable. diff --git a/strings/1001CAC8 b/strings/1001CAC8 new file mode 100644 index 00000000..36326460 --- /dev/null +++ b/strings/1001CAC8 @@ -0,0 +1,3 @@ +Conditionally decrement X before incrementing Y + +Simple register manipulation. Not copyrightable. diff --git a/strings/41534943 b/strings/41534943 new file mode 100644 index 00000000..741ccdfa --- /dev/null +++ b/strings/41534943 @@ -0,0 +1,4 @@ +"ASIC" part of the word BASIC + +Part of a word, the name of a common programming language. +Not copyrightable. diff --git a/strings/48A00098 b/strings/48A00098 new file mode 100644 index 00000000..0b2ed118 --- /dev/null +++ b/strings/48A00098 @@ -0,0 +1,4 @@ +PHA / LDY #$00 / TYA + +Save A on stack, load Y and A both with zero. +Simple register manipulation. Not copyrightable. diff --git a/strings/49FF2980 b/strings/49FF2980 new file mode 100644 index 00000000..4883c0e5 --- /dev/null +++ b/strings/49FF2980 @@ -0,0 +1,3 @@ +EOR #$FF / AND #$80 + +Single instruction. Not copyrightable. diff --git a/strings/642663 b/strings/642663 new file mode 100644 index 00000000..4b582a56 --- /dev/null +++ b/strings/642663 @@ -0,0 +1,4 @@ +List of ASCII/PETSCII keys corresponding to C64 key combinations + +This is a list of facts, so is not copyrightable. +Also too short to have any specific meaning. diff --git a/strings/68A8B9 b/strings/68A8B9 new file mode 100644 index 00000000..d07e02be --- /dev/null +++ b/strings/68A8B9 @@ -0,0 +1,4 @@ +Restore Y from stack, load A from memory location offset by Y + +The 6502 is register poor, so it is very common to pull a register +from the stack and then use it in some way. Not copyrightable. diff --git a/strings/68AAA5 b/strings/68AAA5 new file mode 100644 index 00000000..345531dd --- /dev/null +++ b/strings/68AAA5 @@ -0,0 +1,5 @@ +PLA / TAX / LDA $nn + +Restore X register value, load A from ZP memory location. +Rather common fiddling of register values. +Not copyrightable. diff --git a/strings/8A48A9 b/strings/8A48A9 new file mode 100644 index 00000000..260421cd --- /dev/null +++ b/strings/8A48A9 @@ -0,0 +1,4 @@ +TXA / PHA / LDA #$xx + +Save X on stack, load A register with a value. +Simple register manipulation. Not copyrightable. diff --git a/strings/981865 b/strings/981865 new file mode 100644 index 00000000..5cf71c21 --- /dev/null +++ b/strings/981865 @@ -0,0 +1,5 @@ +TYA / CLC / ADC $nn + +Perform addition to contents of Y register. +Would be a single instruction on many architectures. +Nothing creative. Not copyrightable. diff --git a/strings/984820 b/strings/984820 new file mode 100644 index 00000000..060ac951 --- /dev/null +++ b/strings/984820 @@ -0,0 +1,6 @@ +TYA / PHA / JSR $xxxx + +Save Y on stack and call a routine. +This is common when calling routines that might corrupt +a given register. +Not creative. Not copyrightable. diff --git a/strings/9D0002E8 b/strings/9D0002E8 new file mode 100644 index 00000000..880de876 --- /dev/null +++ b/strings/9D0002E8 @@ -0,0 +1,3 @@ +STA $0200,X / INX + +Loop fragment. Not copyrightable diff --git a/strings/A002A900 b/strings/A002A900 new file mode 100644 index 00000000..6bc4c896 --- /dev/null +++ b/strings/A002A900 @@ -0,0 +1,4 @@ +LDX #$02 / LDA #$00 + +Load X and A registers with values. +Not copyrightable. diff --git a/strings/A9282CA9 b/strings/A9282CA9 new file mode 100644 index 00000000..878f9d8f --- /dev/null +++ b/strings/A9282CA9 @@ -0,0 +1,43 @@ +LDA #$28 / BIT $nnnn + +It is a common convention in 6502 programming to allow easy +skipping over the next two bytes, to use the BIT instruction +(opcode $2C) for this. This allows code like: + +entry1: + LDA #$01 + .byte $2C +entry2: + LDA #$02 + .byte $2C +entry3: + LDA #$03 + ... + ; Do something based on value of A + +This works because the BIT $nnnn instruction eats the two bytes +that follows it as arguments, thus preventing the later LDA #$xx +instructions from being run. This typically saves some bytes +compared to do it any other way. + +It is used on all 6502 platforms, for example this discussion +on the trick for the Atari 2600: + +http://atariage.com/forums/topic/100922-two-player-sprites-without-vdel/ + +It is not copyrightable. + +Here is an example as we have used it to save space when determining +the correct width of a line: + + ;; Get pointers to screen/colour RAM source + lda screen_line_link_table+0 + bmi + + lda #40 + .byte $2C ; BIT $nnnn to skip next instruction + * + lda #80 + sta load_or_scroll_temp_pointer+0 + sta load_save_verify_end_address+0 + +Only one of the LDA #40 or LDA #80 instructions will be executed. diff --git a/strings/AA9848 b/strings/AA9848 new file mode 100644 index 00000000..6052d96a --- /dev/null +++ b/strings/AA9848 @@ -0,0 +1,5 @@ +TAX / TYA / PHA + +Manipulate registers. +Such transfering values to/from registers and the stack is common +on 6502. Not copyrightable. diff --git a/strings/C922D006A5 b/strings/C922D006A5 new file mode 100644 index 00000000..331d7b7e --- /dev/null +++ b/strings/C922D006A5 @@ -0,0 +1,4 @@ +CMP #$22 / BNE / LDA $nn + +Take a branch based on value of A. +Very common. Not copyrightable. diff --git a/strings/D71860 b/strings/D71860 new file mode 100644 index 00000000..17243e56 --- /dev/null +++ b/strings/D71860 @@ -0,0 +1,5 @@ +fragment / CLC / RTS + +Return from subroutine with C clear. +C flag is frequently used as a convention for returning success +of failure from a routine, and thus is encountered quite often. diff --git a/strings/D71880 b/strings/D71880 new file mode 100644 index 00000000..b9e0db6f --- /dev/null +++ b/strings/D71880 @@ -0,0 +1,5 @@ +fragment / CLC / RTS + +Clear carry flag before returning from a routine. +The C flag is often used to indicate success/failure in +routines. Thus is is not surprising and is not copyrightable. diff --git a/strings/E90085 b/strings/E90085 new file mode 100644 index 00000000..c99530d3 --- /dev/null +++ b/strings/E90085 @@ -0,0 +1,4 @@ +SBC #$00 / LDA + +Perform very small part of an arithmetic calculation. +Not copyrightable.