Skip to content

Commit 1445ba5

Browse files
committed
Disable async prefetching for HGSS
1 parent bedf77b commit 1445ba5

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

cardengine_arm9/source/cardEngine.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static u32 readNum = 0;
6565
static bool alreadySetMpu = false;
6666

6767
static bool flagsSet = false;
68+
static bool hgssFix = false;
6869
extern u32 ROMinRAM;
6970
extern u32 ROM_TID;
7071
extern u32 ARM9_LEN;
@@ -280,6 +281,7 @@ int cardRead (u32* cacheStruct) {
280281
|| (ROM_TID & 0x00FFFFFF) == 0x475049) // Pokemon SoulSilver
281282
{
282283
cacheSlots = HGSS_CACHE_SLOTS; // Use smaller cache size to avoid timing issues
284+
hgssFix = true;
283285
}
284286
else if (consoleModel > 0) cacheSlots = dev_CACHE_SLOTS;
285287

@@ -320,10 +322,10 @@ int cardRead (u32* cacheStruct) {
320322

321323
accessCounter++;
322324

323-
processAsyncCommand();
325+
if (!hgssFix) processAsyncCommand();
324326

325327
if(page == src && len > _128KB_READ_SIZE && dst < 0x02700000 && dst > 0x02000000 && ((u32)dst)%4==0) {
326-
getAsyncSector();
328+
if (!hgssFix) getAsyncSector();
327329

328330
// read directly at arm7 level
329331
commandRead = 0x025FFB08;
@@ -347,7 +349,7 @@ int cardRead (u32* cacheStruct) {
347349
u32 nextSector = sector+_128KB_READ_SIZE;
348350
// read max CACHE_READ_SIZE via the main RAM cache
349351
if(slot==-1) {
350-
getAsyncSector();
352+
if (!hgssFix) getAsyncSector();
351353

352354
// send a command to the arm7 to fill the RAM cache
353355
commandRead = 0x025FFB08;
@@ -370,20 +372,22 @@ int cardRead (u32* cacheStruct) {
370372

371373
updateDescriptor(slot, sector);
372374

373-
triggerAsyncPrefetch(nextSector);
375+
if (!hgssFix) triggerAsyncPrefetch(nextSector);
374376
} else {
375-
if(cacheCounter[slot] == 0x0FFFFFFF) {
376-
// prefetch successfull
377-
getAsyncSector();
378-
379-
triggerAsyncPrefetch(nextSector);
380-
} else {
381-
int i;
382-
for(i=0; i<10; i++) {
383-
if(asyncQueue[i]==sector) {
384-
// prefetch successfull
385-
triggerAsyncPrefetch(nextSector);
386-
break;
377+
if (!hgssFix) {
378+
if(cacheCounter[slot] == 0x0FFFFFFF) {
379+
// prefetch successfull
380+
getAsyncSector();
381+
382+
triggerAsyncPrefetch(nextSector);
383+
} else {
384+
int i;
385+
for(i=0; i<10; i++) {
386+
if(asyncQueue[i]==sector) {
387+
// prefetch successfull
388+
triggerAsyncPrefetch(nextSector);
389+
break;
390+
}
387391
}
388392
}
389393
}

0 commit comments

Comments
 (0)