Always read CTR carts in 1MB chunks

This fixes #346
This commit is contained in:
d0k3 2018-04-18 01:24:27 +02:00
parent e09c9b6e1d
commit 3a7c7432ca

View File

@ -140,9 +140,15 @@ u32 ReadCartSectors(void* buffer, u32 sector, u32 count, CartData* cdata) {
if (!count) return 0; if (!count) return 0;
// actual cart reads // actual cart reads
if (cdata->cart_type & CART_CTR) { if (cdata->cart_type & CART_CTR) {
Cart_Dummy(); // don't read more than 1MB at once
Cart_Dummy(); const u32 max_read = 0x800;
CTR_CmdReadData(sector, 0x200, count, buffer8); u8* buff = buffer8;
for (u32 i = 0; i < count; i += max_read) {
Cart_Dummy();
Cart_Dummy();
CTR_CmdReadData(sector + i, 0x200, min(max_read, count - i), buff);
buff += max_read * 0x200;
}
// overwrite the card2 savegame with 0xFF // overwrite the card2 savegame with 0xFF
u32 card2_offset = getle32(cdata->header + 0x200); u32 card2_offset = getle32(cdata->header + 0x200);
if ((card2_offset != 0xFFFFFFFF) && if ((card2_offset != 0xFFFFFFFF) &&