@@ -115,8 +115,7 @@ bool loadPreLoadSettings(configuration* conf, const char* pckPath, const char* r
115115 int right = fileCount;
116116
117117 while (left <= right) {
118- int mid = left + ((right - left) / 2 );
119- fseek (file, 16 + mid * 16 , SEEK_SET);
118+ fseek (file, 16 + left * 16 , SEEK_SET);
120119 fread (buf, 1 , 4 , file);
121120 int cmp = strcmp (buf, romTid);
122121 if (cmp == 0 ) { // TID matches, check CRC
@@ -127,15 +126,11 @@ bool loadPreLoadSettings(configuration* conf, const char* pckPath, const char* r
127126 fread (&offset, 1 , sizeof (offset), file);
128127 fread (&size, 1 , sizeof (size), file);
129128 break ;
130- } else if (crc < headerCRC) {
131- left = mid + 1 ;
132129 } else {
133- right = mid - 1 ;
130+ left++ ;
134131 }
135- } else if (cmp < 0 ) {
136- left = mid + 1 ;
137132 } else {
138- right = mid - 1 ;
133+ left++ ;
139134 }
140135 }
141136
@@ -279,8 +274,7 @@ void loadAsyncLoadSettings(configuration* conf, const char* romTid, const u16 he
279274 int right = fileCount;
280275
281276 while (left <= right) {
282- int mid = left + ((right - left) / 2);
283- fseek(file, 16 + mid * 16, SEEK_SET);
277+ fseek(file, 16 + left * 16, SEEK_SET);
284278 fread(buf, 1, 4, file);
285279 int cmp = strcmp(buf, romTid);
286280 if (cmp == 0) { // TID matches, check CRC
@@ -291,15 +285,11 @@ void loadAsyncLoadSettings(configuration* conf, const char* romTid, const u16 he
291285 fread(&offset, 1, sizeof(offset), file);
292286 fread(&size, 1, sizeof(size), file);
293287 break;
294- } else if (crc < headerCRC) {
295- left = mid + 1;
296288 } else {
297- right = mid - 1 ;
289+ left++ ;
298290 }
299- } else if (cmp < 0) {
300- left = mid + 1;
301291 } else {
302- right = mid - 1 ;
292+ left++ ;
303293 }
304294 }
305295
0 commit comments