This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
mario_kart_64:eeprom_map [2016/07/08 23:44] queueram [Record Checksum] correct code |
mario_kart_64:eeprom_map [2017/06/23 10:49] (current) shygoo ↷ Links adapted because of a move operation |
||
---|---|---|---|
Line 5: | Line 5: | ||
===== Top level structure ===== | ===== Top level structure ===== | ||
^ Offset ^ Length ^ Description ^ | ^ Offset ^ Length ^ Description ^ | ||
- | | 0x000 | 24 | Luigi raceway [[#record_format|record set]] | | + | | 0x000 | 24 | Luigi raceway [[#record_format|record set]] | |
| 0x018 | 24 | Moo Moo Farm record set | | | 0x018 | 24 | Moo Moo Farm record set | | ||
| 0x030 | 24 | Koopa Troopa Beach record set | | | 0x030 | 24 | Koopa Troopa Beach record set | | ||
Line 58: | Line 58: | ||
| 0x017 | 1 | [[#record_checksum|Record Checksum]] | | | 0x017 | 1 | [[#record_checksum|Record Checksum]] | | ||
- | {{:mk64:yjuty.png?200}} | + | {{mario_kart_64:yjuty.png?200}} |
===== Record Format ===== | ===== Record Format ===== | ||
Line 86: | Line 86: | ||
Each record contains a 1-byte checksum at offset 0x17 and is computed as follows: | Each record contains a 1-byte checksum at offset 0x17 and is computed as follows: | ||
<code c> | <code c> | ||
- | unsigned char ComputeRecordChecksum(unsigned char data[], int offset) | + | unsigned char RecordChecksum(unsigned char data[], int offset) |
{ | { | ||
int checksum = 0; | int checksum = 0; | ||
- | for (int rec = 0; rec < 7; rec++) | + | for (int rec = 0; rec < 7; rec++) { |
- | { | + | for (int i = 0; i < 3; i++) { |
- | for (int i = 0; i < 3; i++) | + | unsigned char val = data[offset + rec * 3 + i]; |
- | { | + | |
- | unsigned char val = data[offset + rec * 7+ i]; | + | |
checksum += (val * (i + 1)) + rec; | checksum += (val * (i + 1)) + rec; | ||
} | } | ||
Line 104: | Line 102: | ||
0x186 is a checksum of offsets 0x180-0x184 and is computed by procedure at 800B492C and 0x187 is computed by procedure at 800B49E4 | 0x186 is a checksum of offsets 0x180-0x184 and is computed by procedure at 800B492C and 0x187 is computed by procedure at 800B49E4 | ||
- | <code c>EEPROM[0x186] = (EEPROM[0x180] + 1 + ((EEPROM[0x181] + 1) * 2) + 1 + ((EEPROM[0x182] + 1) * 3) + 2 + ((EEPROM[0x183] + 1) * 4) + 3 + ((EEPROM[0x184] + 1) * 5) + 4) & 0xFF | + | <code c>eeprom[0x186] = (eeprom[0x180] + 1 + ((eeprom[0x181] + 1) * 2) + 1 + ((eeprom[0x182] + 1) * 3) + 2 + ((eeprom[0x183] + 1) * 4) + 3 + ((eeprom[0x184] + 1) * 5) + 4) & 0xFF |
- | EEPROM[0x187] = (EEPROM[0x186] + 0x5A) & 0xFF</code> | + | eeprom[0x187] = (eeprom[0x186] + 0x5A) & 0xFF</code> |
==== 0x1BE and 0x1F6 ==== | ==== 0x1BE and 0x1F6 ==== | ||
<code c> | <code c> | ||
- | // eeprom is base of EEPROM data | + | // eeprom: base of EEPROM data |
- | // offset is starting offset of data to checksum (either 0x188 or 0x1C0) | + | // offset: offset in eeprom to checksum (either 0x188 or 0x1C0) |
void Checksum1BEand1F6(unsigned char eeprom[], int offset) | void Checksum1BEand1F6(unsigned char eeprom[], int offset) | ||
{ | { | ||
int checksum = 0; | int checksum = 0; | ||
int blockOffset = offset; | int blockOffset = offset; | ||
- | for (int block = 0; block < 3; block++) | + | for (int block = 0; block < 3; block++) { |
- | { | + | |
int loopOffset = blockOffset + 1; | int loopOffset = blockOffset + 1; | ||
checksum += (eeprom[blockOffset] + 1) * (block + 1); | checksum += (eeprom[blockOffset] + 1) * (block + 1); | ||
- | for (int byteOff = 1; byteOff < 0x11; byteOff += 0x4) | + | for (int byteOff = 1; byteOff < 0x11; byteOff += 0x4) { |
- | { | + | |
int mult2 = (eeprom[loopOffset] + 1) * (block + 1); | int mult2 = (eeprom[loopOffset] + 1) * (block + 1); | ||
checksum += mult2 + byteOff; | checksum += mult2 + byteOff; |