mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-11-21 21:49:15 +01:00
[SC64][SW] Added support for "Only 64DD IPL" mode in deployer. Added ability to pipe commands in debug mode.
This commit is contained in:
parent
b3a9d5ff63
commit
5a8862eebc
@ -137,6 +137,11 @@ impl TryFrom<&[u8]> for Heartbeat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum UserInput {
|
||||||
|
Packet(sc64::DebugPacket),
|
||||||
|
EOF,
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! success {
|
macro_rules! success {
|
||||||
($($a: tt)*) => {
|
($($a: tt)*) => {
|
||||||
println!("{}", format!($($a)*).bright_blue());
|
println!("{}", format!($($a)*).bright_blue());
|
||||||
@ -164,11 +169,11 @@ impl Handler {
|
|||||||
self.encoding = encoding;
|
self.encoding = encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_user_input(&self) -> Option<sc64::DebugPacket> {
|
pub fn process_user_input(&self) -> Option<UserInput> {
|
||||||
let line = match self.line_rx.try_recv() {
|
let raw_line = match self.line_rx.try_recv() {
|
||||||
Ok(line) => {
|
Ok(line) => {
|
||||||
if line.len() == 0 {
|
if line.len() == 0 {
|
||||||
return None;
|
return Some(UserInput::EOF);
|
||||||
} else {
|
} else {
|
||||||
line
|
line
|
||||||
}
|
}
|
||||||
@ -176,6 +181,11 @@ impl Handler {
|
|||||||
Err(_) => return None,
|
Err(_) => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let line = raw_line.trim_end();
|
||||||
|
if line.len() == 0 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let token_count = line.matches("@").count();
|
let token_count = line.matches("@").count();
|
||||||
|
|
||||||
if (token_count % 2) != 0 {
|
if (token_count % 2) != 0 {
|
||||||
@ -235,7 +245,7 @@ impl Handler {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(packet)
|
Some(UserInput::Packet(packet))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_debug_packet(&mut self, debug_packet: sc64::DebugPacket) {
|
pub fn handle_debug_packet(&mut self, debug_packet: sc64::DebugPacket) {
|
||||||
@ -419,7 +429,7 @@ fn stdin_thread(line_tx: Sender<String>) {
|
|||||||
loop {
|
loop {
|
||||||
let mut line = String::new();
|
let mut line = String::new();
|
||||||
if stdin().read_line(&mut line).is_ok() {
|
if stdin().read_line(&mut line).is_ok() {
|
||||||
if line_tx.send(line.trim_end().to_string()).is_err() {
|
if line_tx.send(line.to_string()).is_err() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,6 @@ struct _64DDArgs {
|
|||||||
ddipl: PathBuf,
|
ddipl: PathBuf,
|
||||||
|
|
||||||
/// Path to the 64DD disk file (.ndd format, can be specified multiple times)
|
/// Path to the 64DD disk file (.ndd format, can be specified multiple times)
|
||||||
#[arg(required = true)]
|
|
||||||
disk: Vec<PathBuf>,
|
disk: Vec<PathBuf>,
|
||||||
|
|
||||||
/// Path to the ROM file
|
/// Path to the ROM file
|
||||||
@ -405,10 +404,11 @@ fn handle_64dd_command(connection: Connection, args: &_64DDArgs) -> Result<(), s
|
|||||||
let mut debug_handler = debug::new();
|
let mut debug_handler = debug::new();
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"{}\n{}\n{}",
|
"{}\n{}\n{}\n{}",
|
||||||
"========== [WARNING] ==========".bold().bright_yellow(),
|
"========== [WARNING] ==========".bold().bright_yellow(),
|
||||||
"Do not use this mode when real 64DD accessory is connected to the N64".bright_yellow(),
|
"Do not use this mode when real 64DD accessory is connected to the N64".bright_yellow(),
|
||||||
"Doing so might permanently damage either N64, 64DD or SC64".bright_yellow()
|
"Doing so might permanently damage either N64, 64DD or SC64".bright_yellow(),
|
||||||
|
"\"Only 64DD IPL\" mode should be safe on development units without IPL builtin".bright_green()
|
||||||
);
|
);
|
||||||
|
|
||||||
sc64.reset_state()?;
|
sc64.reset_state()?;
|
||||||
@ -474,6 +474,13 @@ fn handle_64dd_command(connection: Connection, args: &_64DDArgs) -> Result<(), s
|
|||||||
|
|
||||||
sc64.calculate_cic_parameters()?;
|
sc64.calculate_cic_parameters()?;
|
||||||
|
|
||||||
|
if args.disk.len() == 0 {
|
||||||
|
let dd_mode = sc64::DdMode::DdIpl;
|
||||||
|
println!("64DD mode set to [{dd_mode}]");
|
||||||
|
sc64.configure_64dd(dd_mode, None)?;
|
||||||
|
return Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
let disk_paths: Vec<String> = args
|
let disk_paths: Vec<String> = args
|
||||||
.disk
|
.disk
|
||||||
.iter()
|
.iter()
|
||||||
@ -493,7 +500,7 @@ fn handle_64dd_command(connection: Connection, args: &_64DDArgs) -> Result<(), s
|
|||||||
|
|
||||||
let dd_mode = sc64::DdMode::Full;
|
let dd_mode = sc64::DdMode::Full;
|
||||||
println!("64DD mode set to [{dd_mode} / {drive_type}]");
|
println!("64DD mode set to [{dd_mode} / {drive_type}]");
|
||||||
sc64.configure_64dd(dd_mode, drive_type)?;
|
sc64.configure_64dd(dd_mode, Some(drive_type))?;
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"{}: {}",
|
"{}: {}",
|
||||||
@ -587,8 +594,11 @@ fn handle_64dd_command(connection: Connection, args: &_64DDArgs) -> Result<(), s
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
} else if let Some(debug_packet) = debug_handler.process_user_input() {
|
} else if let Some(user_input) = debug_handler.process_user_input() {
|
||||||
sc64.send_debug_packet(debug_packet)?;
|
match user_input {
|
||||||
|
debug::UserInput::Packet(debug_packet) => sc64.send_debug_packet(debug_packet)?,
|
||||||
|
debug::UserInput::EOF => break,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,8 +650,11 @@ fn handle_debug_command(connection: Connection, args: &DebugArgs) -> Result<(),
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
} else if let Some(debug_packet) = debug_handler.process_user_input() {
|
} else if let Some(user_input) = debug_handler.process_user_input() {
|
||||||
sc64.send_debug_packet(debug_packet)?;
|
match user_input {
|
||||||
|
debug::UserInput::Packet(debug_packet) => sc64.send_debug_packet(debug_packet)?,
|
||||||
|
debug::UserInput::EOF => break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,13 +559,15 @@ impl SC64 {
|
|||||||
pub fn configure_64dd(
|
pub fn configure_64dd(
|
||||||
&mut self,
|
&mut self,
|
||||||
dd_mode: DdMode,
|
dd_mode: DdMode,
|
||||||
drive_type: DdDriveType,
|
drive_type: Option<DdDriveType>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.command_config_set(Config::DdMode(dd_mode))?;
|
self.command_config_set(Config::DdMode(dd_mode))?;
|
||||||
|
if let Some(drive_type) = drive_type {
|
||||||
self.command_config_set(Config::DdSdEnable(Switch::Off))?;
|
self.command_config_set(Config::DdSdEnable(Switch::Off))?;
|
||||||
self.command_config_set(Config::DdDriveType(drive_type))?;
|
self.command_config_set(Config::DdDriveType(drive_type))?;
|
||||||
self.command_config_set(Config::DdDiskState(DdDiskState::Ejected))?;
|
self.command_config_set(Config::DdDiskState(DdDiskState::Ejected))?;
|
||||||
self.command_config_set(Config::ButtonMode(ButtonMode::UsbPacket))?;
|
self.command_config_set(Config::ButtonMode(ButtonMode::UsbPacket))?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user