Skip to content

Commit

Permalink
Fix 16K EEPROM reads and writes
Browse files Browse the repository at this point in the history
  • Loading branch information
nopjne committed Aug 5, 2023
1 parent fef5986 commit 1b37868
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/virtualdisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buf,
}
} else if (cluster == EEPROMFLIP_CLUSTER_START) {
uint32_t address = (((uint32_t)cluster - (EEPROMFLIP_CLUSTER_START)) * CLUSTER_SIZE) + (cluster_offset * SECTOR_SIZE);
ReadEepromData(address / 64, buf);
ReadEepromData(address / 8, buf);
} else if (cluster >= FLASHRAMFLIP_CLUSTER_START) {
// Read SRAM/FRAM -- check if the cart responds to Flashram info request first, if not treat as SRAM.
// Also support Dezaemon's banked SRAM.
Expand Down Expand Up @@ -589,7 +589,7 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buf,

} else if (cluster == EEPROM_CLUSTER_START) {
uint32_t address = (((uint32_t)cluster - (FLASHRAM_CLUSTER_START)) * CLUSTER_SIZE) + (cluster_offset * SECTOR_SIZE);
ReadEepromData(address / 64, buf);
ReadEepromData(address / 8, buf);
}
}
}
Expand Down Expand Up @@ -649,7 +649,7 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
return 512; // Not writable.
} else if (cluster == EEPROMFLIP_CLUSTER_START) {
uint32_t address = (((uint32_t)cluster - (EEPROMFLIP_CLUSTER_START)) * CLUSTER_SIZE) + (cluster_offset * SECTOR_SIZE);
WriteEepromData(address / 64, buffer);
WriteEepromData(address / 8, buffer);
} else if ((cluster >= FLASHRAMFLIP_CLUSTER_START) && (cluster < FLASHRAMFLIP_CLUSTER_START + 4)) {
// Read SRAM/FRAM -- check if the cart responds to Flashram info request first, if not treat as SRAM.
// Also support Dezaemon's banked SRAM.
Expand Down Expand Up @@ -679,7 +679,7 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*

} else if (cluster == EEPROM_CLUSTER_START) {
uint32_t address = (((uint32_t)cluster - (FLASHRAM_CLUSTER_START)) * CLUSTER_SIZE) + (cluster_offset * SECTOR_SIZE);
WriteEepromData(address / 64, buffer);
WriteEepromData(address / 8, buffer);
}
}
}
Expand Down

0 comments on commit 1b37868

Please sign in to comment.