Improve DSiWare save generation

This commit is contained in:
Pk11 2022-02-21 23:57:02 -06:00
parent 682b570ef7
commit 586d30fafa

View File

@ -55,20 +55,24 @@ u32 BuildTwlSaveHeader(void* sav, u32 size) {
u16 n_sct = 1; u16 n_sct = 1;
u16 sct_track = 1; u16 sct_track = 1;
u16 sct_heads = 1; u16 sct_heads = 1;
while (true) { u16 n_sct_next = 0;
if (sct_heads < sct_track) { while (n_sct_next <= n_sct_max) {
u16 n_sct_next = sct_track * (sct_heads+1) * (sct_heads+1); n_sct_next = sct_track * (sct_heads + 1) * (sct_heads + 1);
if (n_sct_next < n_sct_max) { if (n_sct_next <= n_sct_max) {
sct_heads++; sct_heads++;
n_sct = n_sct_next; n_sct = n_sct_next;
} else break;
} else { sct_track++;
u16 n_sct_next = (sct_track+1) * sct_heads * sct_heads; n_sct_next = sct_track * sct_heads * sct_heads;
if (n_sct_next < n_sct_max) { if (n_sct_next <= n_sct_max) {
n_sct = n_sct_next;
}
}
}
n_sct_next = (sct_track + 1) * sct_heads * sct_heads;
if (n_sct_next <= n_sct_max) {
sct_track++; sct_track++;
n_sct = n_sct_next; n_sct = n_sct_next;
} else break;
}
} }
// sectors per cluster (should be identical to Nintendo) // sectors per cluster (should be identical to Nintendo)