Skip to content

Commit

Permalink
[bndbuild] Add impact dsk tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Krusty/Benediction committed Aug 8, 2024
1 parent 23765b5 commit d8a0f5c
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 2 deletions.
5 changes: 5 additions & 0 deletions cpclib-bndbuild/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
61 changes: 61 additions & 0 deletions cpclib-bndbuild/src/runners/impdisc.rs
Original file line number Diff line number Diff line change
@@ -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") =>
{

}
_ => {
}
}
1 change: 1 addition & 0 deletions cpclib-bndbuild/src/runners/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions cpclib-bndbuild/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub enum Task {
Assembler(Assembler, StandardTask),
BndBuild(StandardTask),
Disc(StandardTask),
ImpDsk(StandardTask),
Echo(StandardTask),
Emulator(Emulator, StandardTask),
Extern(StandardTask),
Expand All @@ -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"];
Expand All @@ -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!(
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -233,6 +241,7 @@ impl Task {
Task::Extern(_) => false,
Task::BndBuild(_) => false,
Task::Disc(_) => false,
Task::ImpDsk(_) => false,
Task::Cp(_) => false
}
}
Expand Down
6 changes: 5 additions & 1 deletion cpclib-bndbuild/tests/delegated/build.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion cpclib-bndbuild/tests/delegated/show.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
incbin "martine.scr/MARTIN.PAL", 3+12+12+12, 1


save "SHOW.SCR", 0xc000, 0x4000, DSK, "SHOW.DSK"

0 comments on commit d8a0f5c

Please sign in to comment.