Changes

763 bytes added ,  18:42, 10 April 2016
Line 66: Line 66:     
The checksum stored in the above data frame header is then calculated using this checksum seed.
 
The checksum stored in the above data frame header is then calculated using this checksum seed.
 +
 +
First, the calc_checksum is initialized to 0. Then calc_checksum is added with ''all'' words in the data frame loaded as big-endian, with the data-frame checksum cleared to zero here. If the frame_size isn't word-aligned, the remaining <4-bytes are loaded as big-endian for adding as well.
 +
 +
Then this is run:
 +
  //During init before the above adding, shift and count are initialized:
 +
  //shift = (((u8*)&checksum_seed)[2] & 0xf) + 0x4;
 +
  //count = (((u8*)&checksum_seed)[3] & 0x7) + 0x2;
 +
  for(pos=0; pos<count; pos++)checksum = (checksum<<shift | checksum>>shift) ^ checksum_seed;//The u32 checksum_seed is byte-swapped on 3DS for this.
 +
 +
Lastly the calculated checksum is written to output as big-endian(hence on 3DS it's byte-swapped before writing to output).
    
==== Frames ====
 
==== Frames ====