diff --git a/.appveyor.yml b/.appveyor.yml index aefd7714..9435da5d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -15,7 +15,7 @@ install: build_script: - make - - zip -9 fluxengine.zip fluxengine.exe brother120tool.exe cwftoflux.exe fluxtovcd.exe fluxtoau.exe + - zip -9 fluxengine.zip fluxengine.exe brother120tool.exe artifacts: - path: fluxengine.zip diff --git a/mkninja.sh b/mkninja.sh index 0e1ed2d1..4a8dae08 100644 --- a/mkninja.sh +++ b/mkninja.sh @@ -89,6 +89,33 @@ buildprogram() { echo build $prog$EXTENSION : strip $prog-debug$EXTENSION } +buildsimpleprogram() { + local prog + prog=$1 + shift + + local flags + flags= + while true; do + case $1 in + -*) + flags="$flags $1" + shift + ;; + + *) + break + esac + done + + local src + src=$1 + shift + + buildlibrary lib$prog.a $flags $src + buildprogram $prog lib$prog.a "$@" +} + runtest() { local prog prog=$1 @@ -152,7 +179,10 @@ buildlibrary libbackend.a \ lib/zilogmcz/decoder.cc \ buildlibrary libfrontend.a \ + src/fe-cwftoflux.cc \ src/fe-erase.cc \ + src/fe-fluxtoau.cc \ + src/fe-fluxtovcd.cc \ src/fe-inspect.cc \ src/fe-readadfs.cc \ src/fe-readaeslanier.cc \ @@ -183,40 +213,14 @@ buildprogram fluxengine \ libbackend.a \ libfmt.a \ -buildlibrary libbrother120tool.a \ - -Idep/emu \ - tools/brother120tool.cc \ - buildlibrary libemu.a \ dep/emu/fnmatch.c -buildprogram brother120tool \ - libbrother120tool.a \ - libemu.a \ - libfmt.a \ - -buildlibrary libcwftoflux.a \ - tools/cwftoflux.cc \ - -buildprogram cwftoflux \ - libcwftoflux.a \ - libbackend.a \ - libfmt.a \ - -buildlibrary libfluxtovcd.a \ - tools/fluxtovcd.cc \ - -buildprogram fluxtovcd \ - libfluxtovcd.a \ - libbackend.a \ - libfmt.a \ - -buildlibrary libfluxtoau.a \ - tools/fluxtoau.cc \ - -buildprogram fluxtoau \ - libfluxtoau.a \ +buildsimpleprogram brother120tool \ + -Idep/emu \ + tools/brother120tool.cc \ libbackend.a \ + libemu.a \ libfmt.a \ runtest dataspec-test tests/dataspec.cc diff --git a/tools/cwftoflux.cc b/src/fe-cwftoflux.cc similarity index 96% rename from tools/cwftoflux.cc rename to src/fe-cwftoflux.cc index 458282a3..27ca3bb2 100644 --- a/tools/cwftoflux.cc +++ b/src/fe-cwftoflux.cc @@ -37,7 +37,7 @@ static double clockRate; static void syntax() { - std::cout << "Syntax: cwftoflux \n"; + std::cout << "Syntax: fluxengine convert cwftoflux \n"; exit(0); } @@ -116,7 +116,7 @@ static void read_track() sqlWriteFlux(outputDb, track_number, trackheader.side, fluxmap); } -int main(int argc, const char* argv[]) +int mainConvertCwfToFlux(int argc, const char* argv[]) { if (argc != 3) syntax(); diff --git a/tools/fluxtoau.cc b/src/fe-fluxtoau.cc similarity index 91% rename from tools/fluxtoau.cc rename to src/fe-fluxtoau.cc index 4e31b512..2ed06107 100644 --- a/tools/fluxtoau.cc +++ b/src/fe-fluxtoau.cc @@ -10,7 +10,7 @@ #include "fmt/format.h" #include -FlagGroup flags { &hardwareFluxSourceFlags }; +static FlagGroup flags { &hardwareFluxSourceFlags }; static DataSpecFlag source( { "--source", "-s" }, @@ -30,7 +30,7 @@ static SettableFlag withIndex( { "--with-index" }, "place index markers in the right hand channel"); -int main(int argc, const char* argv[]) +int mainConvertFluxToAu(int argc, const char* argv[]) { flags.parseFlags(argc, argv); @@ -94,5 +94,7 @@ int main(int argc, const char* argv[]) of.write((const char*) data.cbegin(), data.size()); } + std::cerr << "Done. Warning: do not play this file, or you will break your speakers" + " and/or ears!\n"; return 0; } diff --git a/tools/fluxtovcd.cc b/src/fe-fluxtovcd.cc similarity index 95% rename from tools/fluxtovcd.cc rename to src/fe-fluxtovcd.cc index 9a5db0e9..afe261fb 100644 --- a/tools/fluxtovcd.cc +++ b/src/fe-fluxtovcd.cc @@ -10,7 +10,7 @@ #include "fmt/format.h" #include -FlagGroup flags { &hardwareFluxSourceFlags }; +static FlagGroup flags { &hardwareFluxSourceFlags }; static DataSpecFlag source( { "--source", "-s" }, @@ -26,7 +26,7 @@ static SettableFlag highDensityFlag( { "--high-density", "--hd" }, "set the drive to high density mode"); -int main(int argc, const char* argv[]) +int mainConvertFluxToVcd(int argc, const char* argv[]) { flags.parseFlags(argc, argv); diff --git a/src/fluxengine.cc b/src/fluxengine.cc index 9fd0a622..26ce9a00 100644 --- a/src/fluxengine.cc +++ b/src/fluxengine.cc @@ -3,6 +3,9 @@ typedef int command_cb(int agrc, const char* argv[]); extern command_cb mainErase; +extern command_cb mainConvertCwfToFlux; +extern command_cb mainConvertFluxToAu; +extern command_cb mainConvertFluxToVcd; extern command_cb mainInspect; extern command_cb mainReadADFS; extern command_cb mainReadAESLanier; @@ -15,9 +18,9 @@ extern command_cb mainReadDFS; extern command_cb mainReadF85; extern command_cb mainReadFB100; extern command_cb mainReadIBM; -extern command_cb mainReadVictor9K; extern command_cb mainReadMac; extern command_cb mainReadMx; +extern command_cb mainReadVictor9K; extern command_cb mainReadZilogMCZ; extern command_cb mainRpm; extern command_cb mainSeek; @@ -36,16 +39,18 @@ struct Command static command_cb mainRead; static command_cb mainWrite; +static command_cb mainConvert; static std::vector commands = { { "erase", mainErase, "Permanently but rapidly erases some or all of a disk." }, + { "convert", mainConvert, "Converts various types of data file.", }, { "inspect", mainInspect, "Low-level analysis and inspection of a disk." }, + { "read", mainRead, "Reads a disk, producing a sector image.", }, { "rpm", mainRpm, "Measures the disk rotational speed.", }, { "seek", mainSeek, "Moves the disk head.", }, { "testbulktransport", mainTestBulkTransport, "Measures your USB bandwidth.", }, { "upgradefluxfile", mainUpgradeFluxFile, "Upgrades a flux file from a previous version of this software.", }, - { "read", mainRead, "Reads a disk, producing a sector image.", }, { "write", mainWrite, "Writes a sector image to a disk.", }, { "writeflux", mainWriteFlux, "Writes a raw flux file. Warning: you can't use this to copy disks.", }, { "writetestpattern", mainWriteTestPattern, "Writes a machine-generated test pattern to a disk.", }, @@ -75,10 +80,17 @@ static std::vector writeables = { "brother", mainWriteBrother, "Writes 120kB and 240kB Brother word processor disks.", }, }; -static void readWriteHelp(std::vector& subcommands, const std::string& command) +static std::vector convertables = +{ + { "cwftoflux", mainConvertCwfToFlux, "Converts CatWeasel stream files to flux.", }, + { "fluxtoau", mainConvertFluxToAu, "Converts (one track of a) flux file to an .au audio file.", }, + { "fluxtovcd", mainConvertFluxToVcd, "Converts (one track of a) flux file to a VCD file.", }, +}; + +static void extendedHelp(std::vector& subcommands, const std::string& command) { std::cout << "fluxengine: syntax: fluxengine " << command << " [...]\n" - "These formats are supported:\n"; + "These subcommands are supported:\n"; for (Command& c : subcommands) std::cout << " " << c.name << ": " << c.help << "\n"; @@ -86,15 +98,15 @@ static void readWriteHelp(std::vector& subcommands, const std::string& exit(0); } -static int mainReadWrite(std::vector& subcommands, const std::string& command, +static int mainExtended(std::vector& subcommands, const std::string& command, int argc, const char* argv[]) { if (argc == 1) - readWriteHelp(subcommands, command); + extendedHelp(subcommands, command); std::string format = argv[1]; if (format == "--help") - readWriteHelp(subcommands, command); + extendedHelp(subcommands, command); for (Command& c : subcommands) { @@ -107,10 +119,13 @@ static int mainReadWrite(std::vector& subcommands, const std::string& c } static int mainRead(int argc, const char* argv[]) -{ return mainReadWrite(readables, "read", argc, argv); } +{ return mainExtended(readables, "read", argc, argv); } static int mainWrite(int argc, const char* argv[]) -{ return mainReadWrite(writeables, "write", argc, argv); } +{ return mainExtended(writeables, "write", argc, argv); } + +static int mainConvert(int argc, const char* argv[]) +{ return mainExtended(convertables, "convert", argc, argv); } static void help() {