This Basic code get the checksum from a 8 bytes cluster and add the address to avoid an address decay.
But, the CRC can be wrong in case of tow values are swapped in the same line !
08 00 00 00 00 00 00 0B = 19 = $13
0B 00 00 00 00 00 00 08 = 19 = $13
00 0B 00 00 00 00 00 08 = 19 = $13
00 0B 00 00 00 00 08 00 = 19 = $13
Just have a second look to this kind of line.
The right CRC will be :
(DATA1)+(DATA2+1)+(DATA3+2)+(DATA4+3)+ (DATA5+4)+ (DATA6+5)+ (DATA7+6)+ (DATA8+7)
In this case, each data can be calculate from his location.
Code: Select all
1 REM [HEX: \
31,FF,FF,CD,76,FC,CD,C9,\
FC,CD,EB,FC,CD,A8,FC,CD,\
27,FC,CD,D6,FA,20,F8,CD,\
59,FB,CD,93,FB,CD,27,FC,\
00,21,10,7C,40,40,40,00 ]
5 LET F=0
10 FOR A=16514 TO 16514+(5*8) STEP 8
20 RAND PEEK A+PEEK (A+1)+PEEK (A+2)+PEEK (A+3)+PEEK (A+4)+PEEK (A+5)+PEEK (A+6)+PEEK (A+7)+F
30 PRINT 43486+A;"= ";CHR$ (PEEK 16435+28);CHR$(INT(PEEK 16434/16)+28) ;CHR$ ((PEEK 16434-INT(PEEK 16434/16)*16)+28)
31 LET F=F+8
32 IF F=256 THEN LET F=0
40 NEXT A