bryc / rare-n64-chksm Goto Github PK
View Code? Open in Web Editor NEWReversed checksum algorithm for Rare games (Banjo Kazooie/Tooie, GoldenEye, Perfect Dark)
Reversed checksum algorithm for Rare games (Banjo Kazooie/Tooie, GoldenEye, Perfect Dark)
Hello, while working on decompiling 007 goldeneye we decomped the checksum generation function and thought you could maybe find it useful. The function is matching.
Its a tad shorter than the implementation you had but im not sure how much of that was accounting for the other games.
Ive also included the calling function and struct that we have been using for save_data.
Credits to trevor for this.
void gamefileGenerateCRC(u8 *addressA, u8 *addressB, save_data *retval)
{
u8 *byte;
s32 shift = 0; // Shift value
s64 polynormal = 0x8F809F473108B3C1;
s32 checksum1 = 0; // Final checksum #1
s32 checksum2 = 0; // Final checksum #2
for(byte = addressA; byte < addressB; byte++,shift += 7)
{
polynormal += *byte << (shift & 0xF) ;
checksum1 ^= randomGetNextFrom(&polynormal);
}
for(byte = addressB - 1; byte >= addressA; byte--,shift += 3)
{
polynormal += *byte << (shift & 0xF) ;
checksum2 ^= randomGetNextFrom(&polynormal);
}
retval->chksum1 = checksum1;
retval->chksum2 = checksum2;
}
Called by
void sub_GAME_7F01D7A0(save_data *save)
{
if (save >= &saves[0] && save < &saves[5])
{
if (gamefileGamePakProbe() != 0)
{
gamefileGenerateCRC(&save->completion_bitflags, save + 1, save);
joyGamePakLongWrite((((u32)((save - &saves[0]) * 0x60) >> 3) + 4), save, sizeof(save_data));
}
}
}
save_data struct
typedef struct save_data
{
s32 chksum1;
s32 chksum2;
u8 completion_bitflags;
u8 flag_007;
u8 music_vol;
u8 sfx_vol;
u16 options;
u8 unlocked_cheats_1;
u8 unlocked_cheats_2;
u8 unlocked_cheats_3;
char padding;
u8 times[(SP_LEVEL_MAX-1) * 4];
} save_data;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.