SARC: Difference between revisions
Jump to navigation
Jump to search
→Structure
imported>Leoetlino (→Tools) |
imported>Leoetlino |
||
Line 3: | Line 3: | ||
== Structure == | == Structure == | ||
The basic structure of SARC files is documented on the [[mk8:SARC (File Format)|MK8 wiki]]. | The basic structure of SARC files is documented on the [[mk8:SARC (File Format)|MK8 wiki]]. | ||
=== Hash algorithm === | |||
The algorithm given on the MK8 wiki is not fully correct: it fails to account for the fact that Nintendo's algorithm uses an unsigned 32-bit integer for the hash variable, and a '''''signed'' char variable'''. | |||
Here is more accurate implementation of the algorithm, written in C++: | |||
<source lang="c++"> | |||
const uint32_t multiplier = 0x65; | |||
const char* string = "月クッパ戦Lv3(クリア後).baglshpp"; | |||
uint32_t hash = 0; | |||
int i = 0; | |||
while (true) { | |||
char c = string[i++]; // *signed* char | |||
if (!c) | |||
break; | |||
hash = hash * multiplier + c; | |||
} | |||
</source> | |||
It appears that Nintendo's compiler treats a char as a signed type. | |||
== Usage in ''Breath of the Wild'' == | == Usage in ''Breath of the Wild'' == |