Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions librecomp/src/eep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ void save_write(RDRAM_ARG PTR(void) rdram_address, uint32_t offset, uint32_t cou
void save_read(RDRAM_ARG PTR(void) rdram_address, uint32_t offset, uint32_t count);

constexpr int eeprom_block_size = 8;
constexpr int eep4_size = 4096;
constexpr int eep4_block_count = eep4_size / eeprom_block_size;
constexpr int eep16_size = 16384;
constexpr int eep16_block_count = eep16_size / eeprom_block_size;

extern "C" void osEepromProbe_recomp(uint8_t* rdram, recomp_context* ctx) {
switch (recomp::get_save_type()) {
case recomp::SaveType::AllowAll:
case recomp::SaveType::Eep16k:
ctx->r2 = 0x02; // EEPROM_TYPE_16K
break;
case recomp::SaveType::Eep4k:
ctx->r2 = 0x01; // EEPROM_TYPE_4K
break;
default:
ctx->r2 = 0x00;
break;
}
}

Expand All @@ -34,9 +33,6 @@ extern "C" void osEepromWrite_recomp(uint8_t* rdram, recomp_context* ctx) {
gpr buffer = ctx->r6;
int32_t nbytes = eeprom_block_size;

assert(!(nbytes & 7));
assert(eep_address * eeprom_block_size + nbytes <= eep16_size);

save_write(rdram, buffer, eep_address * eeprom_block_size, nbytes);

ctx->r2 = 0;
Expand All @@ -52,8 +48,7 @@ extern "C" void osEepromLongWrite_recomp(uint8_t* rdram, recomp_context* ctx) {
gpr buffer = ctx->r6;
int32_t nbytes = ctx->r7;

assert(!(nbytes & 7));
assert(eep_address * eeprom_block_size + nbytes <= eep16_size);
assert((nbytes % eeprom_block_size) == 0);

save_write(rdram, buffer, eep_address * eeprom_block_size, nbytes);

Expand All @@ -70,9 +65,6 @@ extern "C" void osEepromRead_recomp(uint8_t* rdram, recomp_context* ctx) {
gpr buffer = ctx->r6;
int32_t nbytes = eeprom_block_size;

assert(!(nbytes & 7));
assert(eep_address * eeprom_block_size + nbytes <= eep16_size);

save_read(rdram, buffer, eep_address * eeprom_block_size, nbytes);

ctx->r2 = 0;
Expand All @@ -88,8 +80,7 @@ extern "C" void osEepromLongRead_recomp(uint8_t* rdram, recomp_context* ctx) {
gpr buffer = ctx->r6;
int32_t nbytes = ctx->r7;

assert(!(nbytes & 7));
assert(eep_address * eeprom_block_size + nbytes <= eep16_size);
assert((nbytes % eeprom_block_size) == 0);

save_read(rdram, buffer, eep_address * eeprom_block_size, nbytes);

Expand Down