| 1456 | } |
| 1457 | |
| 1458 | s32 FolderMemoryCard::WriteWithoutCache(const u8* src, u32 adr, int size) |
| 1459 | { |
| 1460 | //const u32 block = adr / BlockSizeRaw; |
| 1461 | //const u32 cluster = adr / ClusterSizeRaw; |
| 1462 | //const u32 page = adr / PageSizeRaw; |
| 1463 | const u32 offset = adr % PageSizeRaw; |
| 1464 | const u32 end = offset + size; |
| 1465 | |
| 1466 | if (end > PageSizeRaw) |
| 1467 | { |
| 1468 | // is trying to store more than one page at a time |
| 1469 | // do this recursively so that each function call only has to care about one page |
| 1470 | const u32 toNextPage = PageSizeRaw - offset; |
| 1471 | Save(src + toNextPage, adr + toNextPage, size - toNextPage); |
| 1472 | size = toNextPage; |
| 1473 | } |
| 1474 | |
| 1475 | if (offset < PageSize) |
| 1476 | { |
| 1477 | // is trying to store (part of) an actual data block |
| 1478 | const u32 dataLength = std::min((u32)size, PageSize - offset); |
| 1479 | |
| 1480 | u8* dest = GetSystemBlockPointer(adr); |
| 1481 | if (dest != nullptr) |
| 1482 | { |
| 1483 | memcpy(dest, src, dataLength); |
| 1484 | } |
| 1485 | else |
| 1486 | { |
| 1487 | WriteToFile(src, adr, dataLength); |
| 1488 | } |
| 1489 | } |
| 1490 | |
| 1491 | if (end > PageSize) |
| 1492 | { |
| 1493 | // is trying to store ECC |
| 1494 | // simply ignore this, is automatically generated when reading |
| 1495 | } |
| 1496 | |
| 1497 | // return 0 on fail, 1 on success? |
| 1498 | return 1; |
| 1499 | } |
| 1500 | |
| 1501 | bool FolderMemoryCard::WriteToFile(const u8* src, u32 adr, u32 dataLength) |
| 1502 | { |