Should be the same as the other checksums.
This is how Motec described it (LOL):
Code: Select all
/*
* Checksum is done as follows:
* Sum bytes 1 to 7 and 16 bit can ID
* Add hi byte of result to low byte
* use low byte result as checksum WTF !!!!!!!!!
*/
canID = 0xAA;
byte1 = roll;
...
checksum = byte1 + byte2 + byte3 + byte4 + byte5 + byte6 + byte7 + canID;
checksum = (checksum / 0x100) + (checksum & 0xff);
checksum = checksum & 0xff;
That's pretty much what the assembly is doing:
Code: Select all
int __fastcall can_checksum_calc(int a1, int a2, int a3, int a4)
{
int *mailbox_struct; // r7@1
int v5; // r3@1
int v6; // r6@2
int i; // r7@4
__int16 v8; // r4@6
mailbox_struct = &can_routine_table[6 * a1];
v5 = *(mailbox_struct + 0x15);
if ( a4 )
v6 = mailbox_struct[3]; // This is the can ID like 0xAA, etc.
else
LOWORD(v6) = 0;
for ( i = 0; i < v5; i = (i + 1) & 0xFF )
LOWORD(v6) = v6 + *(a2 + i);
v8 = (v6 >> 8) + v6;
if ( a3 == 4 )
LOBYTE(v8) = (((((v6 >> 8) + v6) & 0xFF) >> 4) + ((BYTE2(v6) + v6) & 0xF)) & 0xF;
return v8;