Skip to content

Commit

Permalink
Add non-compliant save types
Browse files Browse the repository at this point in the history
* Renames non-compliant SRAM save type.
* Add non-compliant Flashram save type.
  • Loading branch information
networkfusion committed Jan 22, 2025
1 parent 6698550 commit bdc6abf
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 17 deletions.
3 changes: 2 additions & 1 deletion docs/04_config_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ type: *enum* | default: `0`
- `3` - SRAM 256 kib save is enabled
- `4` - FlashRAM 1 Mib save is enabled
- `5` - SRAM 768 kib save is enabled
- `6` - SRAM 1 Mib save is enabled
- `6` - SRAM 1 Mib (original hardware non-compliant) save is enabled
- `7` - FlashRAM (original hardware non-compliant) save is enabled

Use this setting for selecting save type that will be emulated. Only one save type can be enabled.
Any successful write to this config will disable automatic save writeback to USB or SD card when previously enabled.
Expand Down
3 changes: 2 additions & 1 deletion sw/bootloader/src/sc64.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ typedef enum {
SAVE_TYPE_SRAM = 3,
SAVE_TYPE_FLASHRAM = 4,
SAVE_TYPE_SRAM_BANKED = 5,
SAVE_TYPE_SRAM_1M = 6
SAVE_TYPE_SRAM_1M_NONCOMPLIANT = 6,
SAVE_TYPE_FRAM_NONCOMPLIANT = 7
} sc64_save_type_t;

typedef enum {
Expand Down
5 changes: 4 additions & 1 deletion sw/controller/src/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,12 @@ static bool cfg_set_save_type (save_type_t save_type) {
case SAVE_TYPE_SRAM_BANKED:
cfg_change_scr_bits(CFG_SCR_SRAM_BANKED | CFG_SCR_SRAM_ENABLED, true);
break;
case SAVE_TYPE_SRAM_1M:
case SAVE_TYPE_SRAM_1M_NONCOMPLIANT:
cfg_change_scr_bits(CFG_SCR_SRAM_ENABLED, true);
break;
case SAVE_TYPE_FLASHRAM_NONCOMPLIANT:
cfg_change_scr_bits(CFG_SCR_FLASHRAM_ENABLED, true);
break;
default:
save_type = SAVE_TYPE_NONE;
break;
Expand Down
3 changes: 2 additions & 1 deletion sw/controller/src/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ typedef enum {
SAVE_TYPE_SRAM = 3,
SAVE_TYPE_FLASHRAM = 4,
SAVE_TYPE_SRAM_BANKED = 5,
SAVE_TYPE_SRAM_1M = 6,
SAVE_TYPE_SRAM_1M_NONCOMPLIANT = 6,
SAVE_TYPE_FLASHRAM_NONCOMPLIANT = 7,
__SAVE_TYPE_COUNT
} save_type_t;

Expand Down
6 changes: 5 additions & 1 deletion sw/controller/src/writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ static save_type_t writeback_get_address_length (uint32_t *address, uint32_t *le
*address = SRAM_FLASHRAM_ADDRESS;
*length = SRAM_BANKED_LENGTH;
break;
case SAVE_TYPE_SRAM_1M:
case SAVE_TYPE_SRAM_1M_NONCOMPLIANT:
*address = SRAM_FLASHRAM_ADDRESS;
*length = SRAM_1M_LENGTH;
break;
case SAVE_TYPE_FLASHRAM_NONCOMPLIANT:
*address = SRAM_FLASHRAM_ADDRESS;
*length = FLASHRAM_LENGTH;
break;
default:
*address = 0;
*length = 0;
Expand Down
9 changes: 6 additions & 3 deletions sw/deployer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,9 @@ enum SaveType {
Eeprom16k,
Sram,
SramBanked,
Sram1m,
Sram1mNonCompliant,
Flashram,
FlashramNonCompliant,
}

impl From<n64::SaveType> for SaveType {
Expand All @@ -340,8 +341,9 @@ impl From<n64::SaveType> for SaveType {
n64::SaveType::Eeprom16k => Self::Eeprom16k,
n64::SaveType::Sram => Self::Sram,
n64::SaveType::SramBanked => Self::SramBanked,
n64::SaveType::Sram1m => Self::Sram1m,
n64::SaveType::Sram1mNonCompliant => Self::Sram1mNonCompliant,
n64::SaveType::Flashram => Self::Flashram,
n64::SaveType::FlashramNonCompliant => Self::FlashramNonCompliant,
}
}
}
Expand All @@ -354,8 +356,9 @@ impl From<SaveType> for sc64::SaveType {
SaveType::Eeprom16k => Self::Eeprom16k,
SaveType::Sram => Self::Sram,
SaveType::SramBanked => Self::SramBanked,
SaveType::Sram1m => Self::Sram1m,
SaveType::Sram1mNonCompliant => Self::Sram1mNonCompliant,
SaveType::Flashram => Self::Flashram,
SaveType::FlashramNonCompliant => Self::FlashramNonCompliant,
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions sw/deployer/src/n64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ pub enum SaveType {
Sram,
SramBanked,
Flashram,
Sram1m,
Sram1mNonCompliant,
FlashramNonCompliant,
}

const HASH_CHUNK_LENGTH: usize = 1 * 1024 * 1024;
Expand All @@ -31,7 +32,8 @@ pub fn guess_save_type<T: Read + Seek>(
3 => SaveType::Sram,
4 => SaveType::SramBanked,
5 => SaveType::Flashram,
6 => SaveType::Sram1m,
6 => SaveType::Sram1mNonCompliant,
7 => SaveType::FlashramNonCompliant,
_ => SaveType::None,
},
None,
Expand Down
6 changes: 4 additions & 2 deletions sw/deployer/src/sc64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ impl SC64 {
SaveType::Sram => (SAVE_ADDRESS, SRAM_LENGTH),
SaveType::Flashram => (SAVE_ADDRESS, FLASHRAM_LENGTH),
SaveType::SramBanked => (SAVE_ADDRESS, SRAM_BANKED_LENGTH),
SaveType::Sram1m => (SAVE_ADDRESS, SRAM_1M_LENGTH),
SaveType::Sram1mNonCompliant => (SAVE_ADDRESS, SRAM_1M_LENGTH),
SaveType::FlashramNonCompliant => (SAVE_ADDRESS, FLASHRAM_LENGTH),
};

if length != save_length {
Expand All @@ -468,7 +469,8 @@ impl SC64 {
SaveType::Sram => (SAVE_ADDRESS, SRAM_LENGTH),
SaveType::Flashram => (SAVE_ADDRESS, FLASHRAM_LENGTH),
SaveType::SramBanked => (SAVE_ADDRESS, SRAM_BANKED_LENGTH),
SaveType::Sram1m => (SAVE_ADDRESS, SRAM_1M_LENGTH),
SaveType::Sram1mNonCompliant => (SAVE_ADDRESS, SRAM_1M_LENGTH),
SaveType::FlashramNonCompliant => (SAVE_ADDRESS, FLASHRAM_LENGTH),
};

self.memory_read_chunked(writer, address, save_length)
Expand Down
12 changes: 8 additions & 4 deletions sw/deployer/src/sc64/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ pub enum SaveType {
Sram,
Flashram,
SramBanked,
Sram1m,
Sram1mNonCompliant,
FlashramNonCompliant,
}

impl Display for SaveType {
Expand All @@ -299,7 +300,8 @@ impl Display for SaveType {
Self::Sram => "SRAM 256k",
Self::SramBanked => "SRAM 768k",
Self::Flashram => "FlashRAM 1M",
Self::Sram1m => "SRAM 1M",
Self::Sram1mNonCompliant => "SRAM 1M (non-compliant)",
Self::FlashramNonCompliant => "FlashRAM 1M (non-compliant)",
})
}
}
Expand All @@ -314,7 +316,8 @@ impl TryFrom<u32> for SaveType {
3 => Self::Sram,
4 => Self::Flashram,
5 => Self::SramBanked,
6 => Self::Sram1m,
6 => Self::Sram1mNonCompliant,
7 => Self::FlashramNonCompliant,
_ => return Err(Error::new("Unknown save type code")),
})
}
Expand All @@ -329,7 +332,8 @@ impl From<SaveType> for u32 {
SaveType::Sram => 3,
SaveType::Flashram => 4,
SaveType::SramBanked => 5,
SaveType::Sram1m => 6,
SaveType::Sram1mNonCompliant => 6,
SaveType::FlashramNonCompliant => 7,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion web/features.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ <h4>Save support</h4>
<li>SRAM 256&nbsp;kbit</li>
<li>SRAM 3x256&nbsp;kbit</li>
<li>FlashRAM 1&nbsp;Mbit</li>
<li>SRAM 1&nbsp;Mbit</li>
<li>SRAM 1&nbsp;Mbit (original hardware non-compliant)</li>
<li>FlashRAM 1&nbsp;Mbit (original hardware non-compliant)</li>
<li>Automatic writeback after ~1 second to the microSD card or USB interface</li>
</ul>

Expand Down

0 comments on commit bdc6abf

Please sign in to comment.