In mid-1990, the floppy disk of special issue 55 of the German Commodore 64 magazine "64'er" contained the "Amica Paint" graphics program – which was broken beyond usefulness. I'll describe what went wrong.
"Amica Paint" was devloped by Oliver Stiller and first published in 64'er special issue 27 in 1988, as a type-in program that filled 25 pages of the magazine.
Two years later, Amica Paint was published again in special issue 55, which this time came with a floppy disk. But this version was completely broken: Just drawing a simple line would cause severe glitches.
64'er issue 9/1990 published an erratum to fix Amica Paint, which described three ways (BASIC script, asm monitor and disk monitor) to patch 7 bytes in one of the executable files:
--- a/a.paint c000.txt
+++ b/a.paint c000.txt
@@ -67,8 +67,8 @@
00000420 a5 19 85 ef a5 1a 85 f0 4c 29 c4 20 11 c8 20 6c ........L). .. l
00000430 c8 08 20 ed c7 28 90 f6 60 01 38 00 20 20 41 4d .. ..(..`.8. AM
00000440 49 43 41 20 50 41 49 4e 54 20 56 31 2e 34 20 20 ICA PAINT V1.4
-00000450 01 38 03 20 20 20 4f 2e 53 54 49 4c 4c 45 52 20 .8. O.STILLER
-00000460 31 39 39 30 20 20 20 01 31 00 58 3d 30 30 30 20 1990 .1.X=000
+00000450 01 38 03 42 59 20 4f 2e 53 54 49 4c 4c 45 52 20 .8.BY O.STILLER
+00000460 31 39 38 36 2f 38 37 01 31 00 58 3d 30 30 30 20 1986/87.1.X=000
00000470 59 3d 30 30 30 20 20 20 20 20 20 20 20 20 00 01 Y=000 ..
00000480 31 00 42 49 54 54 45 20 57 41 52 54 45 4e 20 2e 1.BITTE WARTEN .
00000490 2e 2e 20 20 20 20 00 64 0a 01 00 53 43 48 57 41 .. .d...SCHWA
This changes the credits message from "O.STILLER 1990" to "BY O.STILLER 1986/87" – which is the original message from the previous publication.
64'er magazine had published the exact same application without any updates, but binary patched the credits message from "1986/87" to "1990", and unfortunately for them, Amica Paint contained code to detect exactly this kind of tampering:
.,C5F5 A0 14 LDY #$14 ; check 20 bytes
.,C5F7 A9 00 LDA #$00 ; init checksum with 0
.,C5F9 18 CLC
.,C5FA 88 DEY
.,C5FB 79 51 C4 ADC $C451,Y ; add character from message
.,C5FE 88 DEY
.,C5FF 18 CLC
.,C600 10 F9 BPL $C5FB ; loop
.,C602 EE FD C5 INC $C5FD
.,C605 C9 ED CMP #$ED ; checksum should be $ED
.,C607 F0 05 BEQ $C60E
.,C609 A9 A9 LDA #$A9
.,C60B 8D E4 C7 STA $C7E4 ; otherwise sabotage line drawing
.,C60E 60 RTS
The code checksums the message "BY O.STILLER 1986/87". If the checksum does not match, the code will overwrite an instruction in the following code:
.,C7DC 65 EC ADC $EC
.,C7DE 85 EC STA $EC
.,C7E0 90 02 BCC $C7E4
.,C7E2 E6 ED INC $ED
.,C7E4 A4 DD LDY $DD
.,C7E6 60 RTS
The "LDY $DD" instruction at $C7E4 will be overwritten with "LDA #$DD", which will cause the glitches in line drawing.
The proper fix would have been to change the comparison with $ED into a comparison with $4F, the checksum of the updated message – a single byte fix. But instead of properly debugging the issue, 64'er magazine published a patch to restore the original message, practically admitting that they had cheated by implying the re-release was not the exact same software.
Seriously man, your articles about C64 are fascinating to read.
Greetings,