Use heuristics to setup table shift.

This commit is contained in:
2025-10-02 04:40:16 +01:00
parent 05491bd935
commit 5c7610c1c0
3 changed files with 14 additions and 3 deletions

View File

@@ -231,10 +231,21 @@ void *aaruf_create(const char *filepath, const uint32_t media_type, const uint32
ctx->userDataDdtHeader.start = 0;
ctx->userDataDdtHeader.blockAlignmentShift = parsed_options.block_alignment;
ctx->userDataDdtHeader.dataShift = parsed_options.data_shift;
ctx->userDataDdtHeader.tableShift = parsed_options.table_shift;
ctx->userDataDdtHeader.sizeType = 1;
ctx->userDataDdtHeader.entries = ctx->userDataDdtHeader.blocks / (1 << ctx->userDataDdtHeader.tableShift);
if(parsed_options.table_shift == -1)
{
uint64_t total_sectors = user_sectors + overflow_sectors + negative_sectors;
if(total_sectors < 0x8388608ULL)
ctx->userDataDdtHeader.tableShift = 0;
else
ctx->userDataDdtHeader.tableShift = 22;
}
else
ctx->userDataDdtHeader.tableShift = parsed_options.table_shift;
if(ctx->userDataDdtHeader.blocks % (1 << ctx->userDataDdtHeader.tableShift) != 0) ctx->userDataDdtHeader.entries++;
TRACE("Initializing primary/single DDT");