make isv nicer

This commit is contained in:
Mateusz Faderewski 2024-07-02 21:48:08 +02:00
parent 98f37af879
commit 3f639855d5
3 changed files with 68 additions and 33 deletions

View File

@ -739,35 +739,35 @@ fn handle_info_command(connection: Connection) -> Result<(), sc64::Error> {
let datetime = state.datetime.format("%Y-%m-%d %H:%M:%S");
println!("{}", "SummerCart64 state information:".bold());
println!(" Firmware version: v{}.{}.{}", major, minor, revision);
println!(" RTC datetime: {}", datetime);
println!(" Boot mode: {}", state.boot_mode);
println!(" Save type: {}", state.save_type);
println!(" CIC seed: {}", state.cic_seed);
println!(" TV type: {}", state.tv_type);
println!(" Bootloader switch: {}", state.bootloader_switch);
println!(" ROM write: {}", state.rom_write_enable);
println!(" ROM shadow: {}", state.rom_shadow_enable);
println!(" ROM extended: {}", state.rom_extended_enable);
println!(" 64DD mode: {}", state.dd_mode);
println!(" 64DD SD card mode: {}", state.dd_sd_enable);
println!(" 64DD drive type: {}", state.dd_drive_type);
println!(" 64DD disk state: {}", state.dd_disk_state);
println!(" Button mode: {}", state.button_mode);
println!(" Button state: {}", state.button_state);
println!(" LED blink: {}", state.led_enable);
println!(" IS-Viewer 64 offset: 0x{:08X}", state.isv_address);
println!(" Firmware version: v{}.{}.{}", major, minor, revision);
println!(" RTC datetime: {}", datetime);
println!(" Boot mode: {}", state.boot_mode);
println!(" Save type: {}", state.save_type);
println!(" CIC seed: {}", state.cic_seed);
println!(" TV type: {}", state.tv_type);
println!(" Bootloader switch: {}", state.bootloader_switch);
println!(" ROM write: {}", state.rom_write_enable);
println!(" ROM shadow: {}", state.rom_shadow_enable);
println!(" ROM extended: {}", state.rom_extended_enable);
println!(" 64DD mode: {}", state.dd_mode);
println!(" 64DD SD card mode: {}", state.dd_sd_enable);
println!(" 64DD drive type: {}", state.dd_drive_type);
println!(" 64DD disk state: {}", state.dd_disk_state);
println!(" Button mode: {}", state.button_mode);
println!(" Button state: {}", state.button_state);
println!(" LED blink: {}", state.led_enable);
println!(" IS-Viewer 64: {}", state.isviewer);
println!("{}", "SummerCart64 diagnostic information:".bold());
println!(
" Last PI address: 0x{:08X}",
" Last PI address: 0x{:08X}",
state.fpga_debug_data.last_pi_address
);
println!(
" PI FIFO flags: {}",
" PI FIFO flags: {}",
state.fpga_debug_data.pi_fifo_flags
);
println!(" Current CIC step: {}", state.fpga_debug_data.cic_step);
println!(" Diagnostic data: {}", state.diagnostic_data);
println!(" Current CIC step: {}", state.fpga_debug_data.cic_step);
println!(" Diagnostic data: {}", state.diagnostic_data);
Ok(())
}

View File

@ -14,8 +14,8 @@ pub use self::{
server::ServerEvent,
types::{
BootMode, ButtonMode, ButtonState, CicSeed, DataPacket, DdDiskState, DdDriveType, DdMode,
DebugPacket, DiagnosticData, DiskPacket, DiskPacketKind, FpgaDebugData, MemoryTestPattern,
MemoryTestPatternResult, SaveType, SaveWriteback, Switch, TvType,
DebugPacket, DiagnosticData, DiskPacket, DiskPacketKind, FpgaDebugData, ISViewer,
MemoryTestPattern, MemoryTestPatternResult, SaveType, SaveWriteback, Switch, TvType,
},
};
@ -45,7 +45,7 @@ pub struct DeviceState {
pub rom_write_enable: Switch,
pub rom_shadow_enable: Switch,
pub dd_mode: DdMode,
pub isv_address: u32,
pub isviewer: ISViewer,
pub boot_mode: BootMode,
pub save_type: SaveType,
pub cic_seed: CicSeed,
@ -549,7 +549,7 @@ impl SC64 {
rom_write_enable: get_config!(self, RomWriteEnable)?,
rom_shadow_enable: get_config!(self, RomShadowEnable)?,
dd_mode: get_config!(self, DdMode)?,
isv_address: get_config!(self, IsvAddress)?,
isviewer: get_config!(self, ISViewer)?,
boot_mode: get_config!(self, BootMode)?,
save_type: get_config!(self, SaveType)?,
cic_seed: get_config!(self, CicSeed)?,
@ -599,10 +599,10 @@ impl SC64 {
}
}
self.command_config_set(Config::RomWriteEnable(Switch::On))?;
self.command_config_set(Config::IsvAddress(offset))?;
self.command_config_set(Config::ISViewer(ISViewer::Enabled(offset)))?;
} else {
self.command_config_set(Config::RomWriteEnable(Switch::Off))?;
self.command_config_set(Config::IsvAddress(0))?;
self.command_config_set(Config::ISViewer(ISViewer::Disabled))?;
}
Ok(())
}

View File

@ -7,7 +7,7 @@ pub enum ConfigId {
RomWriteEnable,
RomShadowEnable,
DdMode,
IsvAddress,
ISViewer,
BootMode,
SaveType,
CicSeed,
@ -25,7 +25,7 @@ pub enum Config {
RomWriteEnable(Switch),
RomShadowEnable(Switch),
DdMode(DdMode),
IsvAddress(u32),
ISViewer(ISViewer),
BootMode(BootMode),
SaveType(SaveType),
CicSeed(CicSeed),
@ -45,7 +45,7 @@ impl From<ConfigId> for u32 {
ConfigId::RomWriteEnable => 1,
ConfigId::RomShadowEnable => 2,
ConfigId::DdMode => 3,
ConfigId::IsvAddress => 4,
ConfigId::ISViewer => 4,
ConfigId::BootMode => 5,
ConfigId::SaveType => 6,
ConfigId::CicSeed => 7,
@ -69,7 +69,7 @@ impl TryFrom<(ConfigId, u32)> for Config {
ConfigId::RomWriteEnable => Self::RomWriteEnable(config.try_into()?),
ConfigId::RomShadowEnable => Self::RomShadowEnable(config.try_into()?),
ConfigId::DdMode => Self::DdMode(config.try_into()?),
ConfigId::IsvAddress => Self::IsvAddress(config),
ConfigId::ISViewer => Self::ISViewer(config.try_into()?),
ConfigId::BootMode => Self::BootMode(config.try_into()?),
ConfigId::SaveType => Self::SaveType(config.try_into()?),
ConfigId::CicSeed => Self::CicSeed(config.try_into()?),
@ -91,7 +91,7 @@ impl From<Config> for [u32; 2] {
Config::RomWriteEnable(val) => [ConfigId::RomWriteEnable.into(), val.into()],
Config::RomShadowEnable(val) => [ConfigId::RomShadowEnable.into(), val.into()],
Config::DdMode(val) => [ConfigId::DdMode.into(), val.into()],
Config::IsvAddress(val) => [ConfigId::IsvAddress.into(), val.into()],
Config::ISViewer(val) => [ConfigId::ISViewer.into(), val.into()],
Config::BootMode(val) => [ConfigId::BootMode.into(), val.into()],
Config::SaveType(val) => [ConfigId::SaveType.into(), val.into()],
Config::CicSeed(val) => [ConfigId::CicSeed.into(), val.into()],
@ -199,6 +199,41 @@ impl From<DdMode> for u32 {
}
}
pub enum ISViewer {
Disabled,
Enabled(u32),
}
impl Display for ISViewer {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Disabled => f.write_str("Not listening"),
Self::Enabled(offset) => {
f.write_fmt(format_args!("Listening at 0x{:08X}", 0x1000_0000 + offset))
}
}
}
}
impl TryFrom<u32> for ISViewer {
type Error = Error;
fn try_from(value: u32) -> Result<Self, Self::Error> {
Ok(match value {
0 => Self::Disabled,
offset => Self::Enabled(offset),
})
}
}
impl From<ISViewer> for u32 {
fn from(value: ISViewer) -> Self {
match value {
ISViewer::Disabled => 0,
ISViewer::Enabled(offset) => offset,
}
}
}
pub enum BootMode {
Menu,
Rom,