From fc8d0283b1a41004e928099858a335a39583f775 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 2 Oct 2024 00:28:04 +0200 Subject: [PATCH] Remove the applesauce.cc and test, as it's not used any more. --- build.py | 1 - lib/usb/applesauce.cc | 64 ---------------------------------- lib/usb/applesauce.h | 3 -- lib/usb/applesauceusb.cc | 1 - tests/applesauce.cc | 74 ---------------------------------------- tests/build.py | 1 - 6 files changed, 144 deletions(-) delete mode 100644 lib/usb/applesauce.cc delete mode 100644 tests/applesauce.cc diff --git a/build.py b/build.py index ac1a8cea..1d894c96 100644 --- a/build.py +++ b/build.py @@ -85,7 +85,6 @@ cxxlibrary( "./lib/proto.cc", "./lib/readerwriter.cc", "./lib/sector.cc", - "./lib/usb/applesauce.cc", "./lib/usb/applesauceusb.cc", "./lib/usb/fluxengineusb.cc", "./lib/usb/greaseweazle.cc", diff --git a/lib/usb/applesauce.cc b/lib/usb/applesauce.cc deleted file mode 100644 index 39006e6c..00000000 --- a/lib/usb/applesauce.cc +++ /dev/null @@ -1,64 +0,0 @@ -#include "lib/globals.h" -#include "usb.h" -#include "protocol.h" -#include "lib/core/bytes.h" -#include "greaseweazle.h" -#include "lib/fluxmap.h" -#include "lib/decoders/fluxmapreader.h" -#include "lib/a2r.h" - -static double a2r_to_ticks(double a2rticks) -{ - return a2rticks * A2R_NS_PER_TICK / NS_PER_TICK; -} - -static double ticks_to_a2r(double flticks) -{ - return flticks * NS_PER_TICK / A2R_NS_PER_TICK; -} - -Bytes fluxEngineToApplesauce(const Bytes& fldata) -{ - Fluxmap fluxmap(fldata); - FluxmapReader fmr(fluxmap); - Bytes asdata; - ByteWriter bw(asdata); - - while (!fmr.eof()) - { - unsigned ticks; - if (!fmr.findEvent(F_BIT_PULSE, ticks)) - break; - - uint32_t applesauceTicks = ticks_to_a2r(ticks); - while (applesauceTicks >= 255) - { - bw.write_8(255); - applesauceTicks -= 255; - } - bw.write_8(applesauceTicks); - } - - return asdata; -} - -Bytes applesauceToFluxEngine(const Bytes& asdata) -{ - ByteReader br(asdata); - Fluxmap fluxmap; - - unsigned a2rTicksSinceLastPulse = 0; - while (!br.eof()) - { - uint8_t b = br.read_8(); - a2rTicksSinceLastPulse += b; - if (b != 255) - { - fluxmap.appendInterval(a2r_to_ticks(a2rTicksSinceLastPulse)); - fluxmap.appendPulse(); - a2rTicksSinceLastPulse = 0; - } - } - - return fluxmap.rawBytes(); -} diff --git a/lib/usb/applesauce.h b/lib/usb/applesauce.h index 2cef0151..9c080075 100644 --- a/lib/usb/applesauce.h +++ b/lib/usb/applesauce.h @@ -4,6 +4,3 @@ #define APPLESAUCE_PID 0x0483 #define APPLESAUCE_ID ((APPLESAUCE_VID << 16) | APPLESAUCE_PID) - -extern Bytes applesauceToFluxEngine(const Bytes& asdata); -extern Bytes fluxEngineToApplesauce(const Bytes& fldata); diff --git a/lib/usb/applesauceusb.cc b/lib/usb/applesauceusb.cc index d1716be6..c3d0551d 100644 --- a/lib/usb/applesauceusb.cc +++ b/lib/usb/applesauceusb.cc @@ -4,7 +4,6 @@ #include "lib/core/bytes.h" #include "lib/usb/usb.pb.h" #include "lib/core/utils.h" -#include "applesauce.h" #include "serial.h" #include "usb.h" #include "lib/decoders/fluxmapreader.h" diff --git a/tests/applesauce.cc b/tests/applesauce.cc deleted file mode 100644 index 63ab4951..00000000 --- a/tests/applesauce.cc +++ /dev/null @@ -1,74 +0,0 @@ -#include -#include -#include -#include "lib/core/globals.h" -#include "lib/fluxmap.h" -#include "lib/usb/applesauce.h" - -static void test_convert(const Bytes& asbytes, const Bytes& flbytes) -{ - Bytes astoflbytes = applesauceToFluxEngine(asbytes); - Bytes fltoasbytes = fluxEngineToApplesauce(flbytes); - - if (astoflbytes != flbytes) - { - std::cout << "Applesauce to FluxEngine conversion failed.\n"; - std::cout << "Applesauce bytes:" << std::endl; - hexdump(std::cout, asbytes); - std::cout << std::endl << "Produced this:" << std::endl; - hexdump(std::cout, astoflbytes); - std::cout << std::endl << "Expected this:" << std::endl; - hexdump(std::cout, flbytes); - abort(); - } - - if (fltoasbytes != asbytes) - { - std::cout << "FluxEngine to Applesauce conversion failed.\n"; - std::cout << "FluxEngine bytes:" << std::endl; - hexdump(std::cout, flbytes); - std::cout << std::endl << "Produced this:" << std::endl; - hexdump(std::cout, fltoasbytes); - std::cout << std::endl << "Expected this:" << std::endl; - hexdump(std::cout, asbytes); - abort(); - } -} - -static void test_conversions() -{ - /* Simple one-byte intervals. */ - - test_convert(Bytes{0x20, 0x20, 0x20, 0x20}, Bytes{0xb0, 0xb0, 0xb0, 0xb0}); - - /* Long, multibyte intervals. */ - - test_convert(Bytes{0xff, 0x1f, 0x20, 0xff, 0xff, 0x20}, - Bytes{0x3f, - 0x3f, - 0x3f, - 0x3f, - 0x3f, - 0x3f, - 0xb3, - 0xb0, - 0x3f, - 0x3f, - 0x3f, - 0x3f, - 0x3f, - 0x3f, - 0x3f, - 0x3f, - 0x3f, - 0x3f, - 0x3f, - 0x3f, - 0xb9}); -} - -int main(int argc, const char* argv[]) -{ - test_conversions(); - return 0; -} diff --git a/tests/build.py b/tests/build.py index a4b5f999..76ac35ae 100644 --- a/tests/build.py +++ b/tests/build.py @@ -18,7 +18,6 @@ tests = [ "agg", "amiga", "applesingle", - "applesauce", "bitaccumulator", "bytes", "compression",