From d8a0f5cfa57668a8def4aa2fd102318c017881cc Mon Sep 17 00:00:00 2001 From: Krusty/Benediction Date: Thu, 8 Aug 2024 18:07:17 +0200 Subject: [PATCH] [bndbuild] Add impact dsk tool --- cpclib-bndbuild/src/executor.rs | 5 ++ cpclib-bndbuild/src/runners/impdisc.rs | 61 +++++++++++++++++++++++ cpclib-bndbuild/src/runners/mod.rs | 1 + cpclib-bndbuild/src/task.rs | 9 ++++ cpclib-bndbuild/tests/delegated/build.bnd | 6 ++- cpclib-bndbuild/tests/delegated/show.asm | 5 +- 6 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 cpclib-bndbuild/src/runners/impdisc.rs diff --git a/cpclib-bndbuild/src/executor.rs b/cpclib-bndbuild/src/executor.rs index 766a7190..94073a1c 100644 --- a/cpclib-bndbuild/src/executor.rs +++ b/cpclib-bndbuild/src/executor.rs @@ -8,6 +8,7 @@ use crate::runners::disc::DiscManagerRunner; use crate::runners::echo::EchoRunner; use crate::runners::imgconverter::ImgConverterRunner; use crate::runners::r#extern::ExternRunner; +use crate::runners::impdisc::ImpDskVersion; use crate::runners::martine::MartineVersion; use crate::runners::rm::RmRunner; use crate::runners::xfer::XferRunner; @@ -52,6 +53,10 @@ pub fn execute(task: &Task) -> Result<(), String> { Task::Echo(_) => ECHO_RUNNER.run(task.args()), Task::Extern(_) => EXTERN_RUNNER.run(task.args()), Task::ImgConverter(_) => IMGCONV_RUNNER.run(task.args()), + Task::ImpDsk(_) => DelegatedRunner { + app: ImpDskVersion::default().configuration(), + cmd: ImpDskVersion::default().get_command().to_owned() + }.run(task.args()), Task::Martine(_) => DelegatedRunner { app: MartineVersion::default().configuration(), cmd: MartineVersion::default().get_command().to_owned() diff --git a/cpclib-bndbuild/src/runners/impdisc.rs b/cpclib-bndbuild/src/runners/impdisc.rs new file mode 100644 index 00000000..2a71fd08 --- /dev/null +++ b/cpclib-bndbuild/src/runners/impdisc.rs @@ -0,0 +1,61 @@ +use crate::{delegated::{ArchiveFormat, DelegateApplicationDescription}, task::IMPDISC_CMDS}; + +pub enum ImpDskVersion { + V0_24 +} + +impl Default for ImpDskVersion { + fn default() -> Self { + ImpDskVersion::V0_24 + } +} + +impl ImpDskVersion { + pub fn get_command(&self) -> &str { + IMPDISC_CMDS[0] + } +} + +cfg_match! { + cfg(target_os = "linux") => + { + impl ImpDskVersion { + pub fn configuration(&self) -> DelegateApplicationDescription { + match self { + ImpDskVersion::V0_24 => + DelegateApplicationDescription { + download_url: "https://github.com/jeromelesaux/dsk/releases/download/v0.24/dsk-0.24-linux-amd64.zip", // we assume a modern CPU + folder : "ImpDsk_0_24", + archive_format: ArchiveFormat::Zip, + exec_fname: "binaries/dsk-linux-amd64", + compile: None + } + } + } + } + } + cfg(target_os = "windows") => + { + impl ImpDskVersion { + pub fn configuration(&self) -> DelegateApplicationDescription { + match self { + ImpDskVersion::V0_24 => + DelegateApplicationDescription { + download_url: "https://github.com/jeromelesaux/dsk/releases/download/v0.24/dsk-0.24-windows-amd64.zip", + folder : "ImpDsk_0_24", + archive_format: ArchiveFormat::Zip, + exec_fname: "binaries/dsk-windows-amd64.exe", + compile: None + } + } + } + } + + } + cfg(target_os = "macos") => + { + + } + _ => { + } +} \ No newline at end of file diff --git a/cpclib-bndbuild/src/runners/mod.rs b/cpclib-bndbuild/src/runners/mod.rs index 0f060c60..567dbc18 100644 --- a/cpclib-bndbuild/src/runners/mod.rs +++ b/cpclib-bndbuild/src/runners/mod.rs @@ -10,6 +10,7 @@ pub mod echo; pub mod emulator; pub mod r#extern; pub mod imgconverter; +pub mod impdisc; pub mod martine; pub mod rm; pub mod xfer; diff --git a/cpclib-bndbuild/src/task.rs b/cpclib-bndbuild/src/task.rs index 214952e5..993bae08 100644 --- a/cpclib-bndbuild/src/task.rs +++ b/cpclib-bndbuild/src/task.rs @@ -13,6 +13,7 @@ pub enum Task { Assembler(Assembler, StandardTask), BndBuild(StandardTask), Disc(StandardTask), + ImpDsk(StandardTask), Echo(StandardTask), Emulator(Emulator, StandardTask), Extern(StandardTask), @@ -30,6 +31,7 @@ pub const BASM_CMDS: &[&str] = &["basm", "assemble"]; pub const BNDBUILD_CMDS: &[&str] = &["bndbuild", "build"]; pub const CP_CMDS: &[&str] = &["cp", "copy"]; pub const DISC_CMDS: &[&str] = &["dsk", "disc"]; +pub const IMPDISC_CMDS: &[&str] = &["impdsk", "impdisc"]; pub const ECHO_CMDS: &[&str] = &["echo", "print"]; pub const EXTERN_CMDS: &[&str] = &["extern"]; pub const IMG2CPC_CMDS: &[&str] = &["img2cpc", "imgconverter"]; @@ -52,6 +54,7 @@ impl Display for Task { Task::Xfer(s) => (XFER_CMDS[0], s), Task::Emulator(e, s) => (e.get_command(), s), Task::Martine(s) => (MARTINE_CMDS[0], s), + Task::ImpDsk(s) => (IMPDISC_CMDS[0], s), }; write!( @@ -127,6 +130,9 @@ impl<'de> Deserialize<'de> for Task { else if IMG2CPC_CMDS.iter().contains(&code) { Ok(Task::ImgConverter(std)) } + else if IMPDISC_CMDS.iter().contains(&code) { + Ok(Task::ImpDsk(std)) + } else if MARTINE_CMDS.iter().contains(&code) { Ok(Task::Martine(std)) } @@ -181,6 +187,7 @@ impl Task { | Task::BndBuild(t) | Task::Cp(t) | Task::Disc(t) + | Task::ImpDsk(t) | Task::Echo(t) | Task::Extern(t) | Task::ImgConverter(t) @@ -200,6 +207,7 @@ impl Task { | Task::Xfer(t) | Task::Extern(t) | Task::Disc(t) + | Task::ImpDsk(t) | Task::BndBuild(t) | Task::Martine(t) | Task::Cp(t) @@ -233,6 +241,7 @@ impl Task { Task::Extern(_) => false, Task::BndBuild(_) => false, Task::Disc(_) => false, + Task::ImpDsk(_) => false, Task::Cp(_) => false } } diff --git a/cpclib-bndbuild/tests/delegated/build.bnd b/cpclib-bndbuild/tests/delegated/build.bnd index 3a27772a..f025ef7a 100644 --- a/cpclib-bndbuild/tests/delegated/build.bnd +++ b/cpclib-bndbuild/tests/delegated/build.bnd @@ -5,10 +5,14 @@ dep: show.sna cmd: ace show.sna -- tgt: show.sna +- tgt: show.sna SHOW.DSK dep: martine.scr/MARTIN.SCR martine.scr/MARTIN.PAL show.asm cmd: rasm show.asm -oi show.sna -map +- tgt: SHOW.SCR + dep: SHOW.DSK + cmd: impdsk -dsk SHOW.DSK -get -amsdosfile SHOW.SCR + - tgt: martine.scr/MARTIN.SCR martine.scr/MARTIN.PAL dep: martine-logo.png cmd: martine -in martine-logo.png -mode 1 -noheader -out martine.scr diff --git a/cpclib-bndbuild/tests/delegated/show.asm b/cpclib-bndbuild/tests/delegated/show.asm index a2d4e5d4..f45f6502 100644 --- a/cpclib-bndbuild/tests/delegated/show.asm +++ b/cpclib-bndbuild/tests/delegated/show.asm @@ -24,4 +24,7 @@ PAL incbin "martine.scr/MARTIN.PAL", 3, 1 incbin "martine.scr/MARTIN.PAL", 3+12, 1 incbin "martine.scr/MARTIN.PAL", 3+12+12, 1 - incbin "martine.scr/MARTIN.PAL", 3+12+12+12, 1 \ No newline at end of file + incbin "martine.scr/MARTIN.PAL", 3+12+12+12, 1 + + + save "SHOW.SCR", 0xc000, 0x4000, DSK, "SHOW.DSK" \ No newline at end of file