diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index e5682830..011019d2 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -19,9 +19,10 @@ jobs: repository: 'davidgiven/fluxengine-testdata' path: 'fluxengine-testdata' - name: apt - run: sudo apt update && sudo apt install libudev-dev libsqlite3-dev protobuf-compiler libwxgtk3.0-gtk3-dev libfmt-dev + run: | + sudo apt install libudev-dev libsqlite3-dev protobuf-compiler libwxgtk3.0-gtk3-dev libfmt-dev libprotobuf-dev wx-common - name: make - run: CXXFLAGS="-Wp,-D_GLIBCXX_ASSERTIONS" make -j2 -C fluxengine + run: CXXFLAGS="-Wp,-D_GLIBCXX_ASSERTIONS" make -j`nproc` -C fluxengine build-macos-current: runs-on: macos-latest @@ -37,7 +38,7 @@ jobs: - name: brew run: brew install sqlite pkg-config libusb protobuf wxwidgets fmt make coreutils dylibbundler libjpeg - name: make - run: gmake -j2 -C fluxengine + run: gmake -j`nproc` -C fluxengine - name: Upload build artifacts uses: actions/upload-artifact@v2 @@ -58,17 +59,20 @@ jobs: install: >- diffutils make + mingw-w64-i686-binutils mingw-w64-i686-fmt mingw-w64-i686-gcc mingw-w64-i686-libusb + mingw-w64-i686-nsis mingw-w64-i686-pkg-config mingw-w64-i686-protobuf + mingw-w64-i686-python mingw-w64-i686-sqlite3 mingw-w64-i686-wxWidgets mingw-w64-i686-zlib - mingw-w64-i686-nsis - zip + mingw-w64-i686-imagemagick vim + zip - name: update-protobuf run: | pacman -U --noconfirm https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-protobuf-21.9-1-any.pkg.tar.zst @@ -81,7 +85,7 @@ jobs: repository: 'davidgiven/fluxengine-testdata' path: 'fluxengine-testdata' - name: build - run: make -j2 -C fluxengine + run: MAGICK_TIME_LIMIT=100 make -j`nproc` -C fluxengine - name: nsis run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e9272a53..f19cfb8d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,17 +23,20 @@ jobs: install: >- diffutils make + mingw-w64-i686-binutils mingw-w64-i686-fmt mingw-w64-i686-gcc mingw-w64-i686-libusb + mingw-w64-i686-nsis mingw-w64-i686-pkg-config mingw-w64-i686-protobuf + mingw-w64-i686-python mingw-w64-i686-sqlite3 mingw-w64-i686-wxWidgets mingw-w64-i686-zlib - mingw-w64-i686-nsis - zip + mingw-w64-i686-imagemagick vim + zip - uses: actions/checkout@v3 - name: update-protobuf @@ -42,7 +45,7 @@ jobs: - name: build run: | - make -j2 + MAGICK_TIME_LIMIT=100 make -j`nproc` - name: nsis run: | diff --git a/.hgignore b/.hgignore index 08435644..a377f988 100644 --- a/.hgignore +++ b/.hgignore @@ -1,4 +1,5 @@ .obj +.git streams .*\.flux .*\.img diff --git a/Makefile b/Makefile index 5adfb4b5..db6d782c 100644 --- a/Makefile +++ b/Makefile @@ -1,305 +1,65 @@ -#Special Windows settings. +CC = gcc +CXX = g++ -std=c++17 +CFLAGS = -g -O3 +LDFLAGS = -ifeq ($(OS), Windows_NT) - MINGWBIN = /mingw32/bin - CCPREFIX = $(MINGWBIN)/ - LUA = $(MINGWBIN)/lua - PKG_CONFIG = $(MINGWBIN)/pkg-config - WX_CONFIG = /usr/bin/sh $(MINGWBIN)/wx-config --static=yes - PROTOC = $(MINGWBIN)/protoc - PLATFORM = WINDOWS - LDFLAGS += \ - -static - CXXFLAGS += \ - -std=c++17 \ - -fext-numeric-literals \ - -Wno-deprecated-enum-float-conversion \ - -Wno-deprecated-enum-enum-conversion - -#Required to get the gcc run - time libraries on the path. - export PATH := $(PATH):$(MINGWBIN) - EXT ?= .exe -endif - -#Special OSX settings. - -ifeq ($(shell uname),Darwin) - PLATFORM = OSX - LDFLAGS += \ - -framework IOKit \ - -framework Foundation -endif - -ifeq ($(shell uname),FreeBSD) - PLATFORM = FreeBSD - CFLAGS += -I/usr/local/include -endif - -#Check the Make version. - - -ifeq ($(findstring 4.,$(MAKE_VERSION)),) -$(error You need GNU Make 4.x for this (if you're on OSX, use gmake).) -endif - -#Normal settings. - -OBJDIR ?= .obj -CCPREFIX ?= -LUA ?= lua -CC ?= $(CCPREFIX)gcc -CXX ?= $(CCPREFIX)g++ -AR ?= $(CCPREFIX)ar -PKG_CONFIG ?= pkg-config -WX_CONFIG ?= wx-config -PROTOC ?= protoc -CFLAGS ?= -g -O3 -CXXFLAGS += -std=c++17 -LDFLAGS ?= -PLATFORM ?= UNIX -TESTS ?= yes -EXT ?= +OBJ = .obj DESTDIR ?= PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin -CFLAGS += \ - -Iarch \ - -Ilib \ - -I. \ - -I$(OBJDIR)/arch \ - -I$(OBJDIR)/lib \ - -I$(OBJDIR) \ - -Wno-deprecated-declarations \ +# Special Windows settings. -LDFLAGS += \ - -lz \ - -lfmt +ifeq ($(OS), Windows_NT) + EXT ?= .exe + MINGWBIN = /mingw32/bin + CCPREFIX = $(MINGWBIN)/ + PKG_CONFIG = $(MINGWBIN)/pkg-config + WX_CONFIG = /usr/bin/sh $(MINGWBIN)/wx-config --static=yes + PROTOC = $(MINGWBIN)/protoc + WINDRES = windres + LDFLAGS += \ + -static + CXXFLAGS += \ + -fext-numeric-literals \ + -Wno-deprecated-enum-float-conversion \ + -Wno-deprecated-enum-enum-conversion -.SUFFIXES: -.DELETE_ON_ERROR: - -define nl - -endef - -empty := -space := $(empty) $(empty) - -use-library = $(eval $(use-library-impl)) -define use-library-impl -$1: $(call $3_LIB) -$1: private LDFLAGS += $(call $3_LDFLAGS) -$2: private CFLAGS += $(call $3_CFLAGS) -endef - -use-pkgconfig = $(eval $(use-pkgconfig-impl)) -define use-pkgconfig-impl -ifneq ($(strip $(shell $(PKG_CONFIG) $3; echo $$?)),0) -$$(error Missing required pkg-config dependency: $3) + # Required to get the gcc run - time libraries on the path. + export PATH := $(PATH):$(MINGWBIN) endif -$(1): private LDFLAGS += $(shell $(PKG_CONFIG) --libs $(3)) -$(2): private CFLAGS += $(shell $(PKG_CONFIG) --cflags $(3)) -endef - -.PHONY: all binaries tests clean install install-bin -all: binaries tests docs - -PROTOS = \ - arch/aeslanier/aeslanier.proto \ - arch/agat/agat.proto \ - arch/amiga/amiga.proto \ - arch/apple2/apple2.proto \ - arch/brother/brother.proto \ - arch/c64/c64.proto \ - arch/f85/f85.proto \ - arch/fb100/fb100.proto \ - arch/ibm/ibm.proto \ - arch/macintosh/macintosh.proto \ - arch/micropolis/micropolis.proto \ - arch/mx/mx.proto \ - arch/northstar/northstar.proto \ - arch/rolandd20/rolandd20.proto \ - arch/smaky6/smaky6.proto \ - arch/tids990/tids990.proto \ - arch/victor9k/victor9k.proto \ - arch/zilogmcz/zilogmcz.proto \ - lib/common.proto \ - lib/config.proto \ - lib/decoders/decoders.proto \ - lib/drive.proto \ - lib/encoders/encoders.proto \ - lib/fl2.proto \ - lib/fluxsink/fluxsink.proto \ - lib/fluxsource/fluxsource.proto \ - lib/imagereader/imagereader.proto \ - lib/imagewriter/imagewriter.proto \ - lib/layout.proto \ - lib/usb/usb.proto \ - lib/vfs/vfs.proto \ - tests/testproto.proto \ - -PROTO_HDRS = $(patsubst %.proto, $(OBJDIR)/%.pb.h, $(PROTOS)) -PROTO_SRCS = $(patsubst %.proto, $(OBJDIR)/%.pb.cc, $(PROTOS)) -PROTO_OBJS = $(patsubst %.cc, %.o, $(PROTO_SRCS)) -PROTO_CFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) -$(PROTO_SRCS): | $(PROTO_HDRS) -$(PROTO_OBJS): CFLAGS += $(PROTO_CFLAGS) -PROTO_LIB = $(OBJDIR)/libproto.a -$(PROTO_LIB): $(PROTO_OBJS) -PROTO_LDFLAGS := $(shell $(PKG_CONFIG) --libs protobuf) -pthread -.PRECIOUS: $(PROTO_HDRS) $(PROTO_SRCS) - -include dep/agg/build.mk -include dep/libusbp/build.mk -include dep/stb/build.mk -include dep/emu/build.mk -include dep/fatfs/build.mk -include dep/adflib/build.mk -include dep/hfsutils/build.mk -include scripts/build.mk - -include lib/build.mk -include arch/build.mk -include src/build.mk -include src/gui/build.mk -include tools/build.mk -include tests/build.mk - -do-encodedecodetest = $(eval $(do-encodedecodetest-impl)) -define do-encodedecodetest-impl - -tests: $(OBJDIR)/$1$$(subst $$(space),_,$3).flux.encodedecode -$(OBJDIR)/$1$$(subst $$(space),_,$3).flux.encodedecode: scripts/encodedecodetest.sh $(FLUXENGINE_BIN) $2 - @mkdir -p $(dir $$@) - @echo ENCODEDECODETEST $1 flux $(FLUXENGINE_BIN) $2 $3 - @scripts/encodedecodetest.sh $1 flux $(FLUXENGINE_BIN) $2 $3 > $$@ - -tests: $(OBJDIR)/$1$$(subst $$(space),_,$3).scp.encodedecode -$(OBJDIR)/$1$$(subst $$(space),_,$3).scp.encodedecode: scripts/encodedecodetest.sh $(FLUXENGINE_BIN) $2 - @mkdir -p $(dir $$@) - @echo ENCODEDECODETEST $1 scp $(FLUXENGINE_BIN) $2 $3 - @scripts/encodedecodetest.sh $1 scp $(FLUXENGINE_BIN) $2 $3 > $$@ - -endef - -$(call do-encodedecodetest,agat,,--drive.tpi=96) -$(call do-encodedecodetest,amiga,,--drive.tpi=135) -$(call do-encodedecodetest,apple2,,--140 --drive.tpi=96) -$(call do-encodedecodetest,atarist,,--360 --drive.tpi=135) -$(call do-encodedecodetest,atarist,,--370 --drive.tpi=135) -$(call do-encodedecodetest,atarist,,--400 --drive.tpi=135) -$(call do-encodedecodetest,atarist,,--410 --drive.tpi=135) -$(call do-encodedecodetest,atarist,,--720 --drive.tpi=135) -$(call do-encodedecodetest,atarist,,--740 --drive.tpi=135) -$(call do-encodedecodetest,atarist,,--800 --drive.tpi=135) -$(call do-encodedecodetest,atarist,,--820 --drive.tpi=135) -$(call do-encodedecodetest,bk) -$(call do-encodedecodetest,brother,,--120 --drive.tpi=135) -$(call do-encodedecodetest,brother,,--240 --drive.tpi=135) -$(call do-encodedecodetest,commodore,scripts/commodore1541_test.textpb,--171 --drive.tpi=96) -$(call do-encodedecodetest,commodore,scripts/commodore1541_test.textpb,--192 --drive.tpi=96) -$(call do-encodedecodetest,commodore,,--800 --drive.tpi=135) -$(call do-encodedecodetest,commodore,,--1620 --drive.tpi=135) -$(call do-encodedecodetest,hplif,,--264 --drive.tpi=135) -$(call do-encodedecodetest,hplif,,--608 --drive.tpi=135) -$(call do-encodedecodetest,hplif,,--616 --drive.tpi=135) -$(call do-encodedecodetest,hplif,,--770 --drive.tpi=135) -$(call do-encodedecodetest,ibm,,--1200 --drive.tpi=96) -$(call do-encodedecodetest,ibm,,--1232 --drive.tpi=96) -$(call do-encodedecodetest,ibm,,--1440 --drive.tpi=135) -$(call do-encodedecodetest,ibm,,--1680 --drive.tpi=135) -$(call do-encodedecodetest,ibm,,--180 --drive.tpi=96) -$(call do-encodedecodetest,ibm,,--160 --drive.tpi=96) -$(call do-encodedecodetest,ibm,,--320 --drive.tpi=96) -$(call do-encodedecodetest,ibm,,--360 --drive.tpi=96) -$(call do-encodedecodetest,ibm,,--720_96 --drive.tpi=96) -$(call do-encodedecodetest,ibm,,--720_135 --drive.tpi=135) -$(call do-encodedecodetest,mac,scripts/mac400_test.textpb,--400 --drive.tpi=135) -$(call do-encodedecodetest,mac,scripts/mac800_test.textpb,--800 --drive.tpi=135) -$(call do-encodedecodetest,n88basic,,--drive.tpi=96) -$(call do-encodedecodetest,rx50,,--drive.tpi=96) -$(call do-encodedecodetest,tids990,,--drive.tpi=48) -$(call do-encodedecodetest,victor9k,,--612 --drive.tpi=96) -$(call do-encodedecodetest,victor9k,,--1224 --drive.tpi=96) - -do-corpustest = $(eval $(do-corpustest-impl)) -define do-corpustest-impl - -tests: $(OBJDIR)/corpustest/$2 -$(OBJDIR)/corpustest/$2: $(FLUXENGINE_BIN) \ - ../fluxengine-testdata/data/$1 ../fluxengine-testdata/data/$2 - @mkdir -p $(OBJDIR)/corpustest - @echo CORPUSTEST $1 $2 $3 - @$(FLUXENGINE_BIN) read $3 -s ../fluxengine-testdata/data/$1 -o $$@ > $$@.log - @cmp $$@ ../fluxengine-testdata/data/$2 - -endef - -ifneq ($(wildcard ../fluxengine-testdata/data),) - -$(call do-corpustest,amiga.flux,amiga.adf,amiga --drive.tpi=135) -$(call do-corpustest,atarist360.flux,atarist360.st,atarist --360 --drive.tpi=135) -$(call do-corpustest,atarist720.flux,atarist720.st,atarist --720 --drive.tpi=135) -$(call do-corpustest,brother120.flux,brother120.img,brother --120 --drive.tpi=135) -$(call do-corpustest,cmd-fd2000.flux,cmd-fd2000.img,commodore --1620 --drive.tpi=135) -$(call do-corpustest,ibm1232.flux,ibm1232.img,ibm --1232 --drive.tpi=96) -$(call do-corpustest,ibm1440.flux,ibm1440.img,ibm --1440 --drive.tpi=135) -$(call do-corpustest,mac800.flux,mac800.dsk,mac --800 --drive.tpi=135) -$(call do-corpustest,micropolis315.flux,micropolis315.img,micropolis --315 --drive.tpi=100) -$(call do-corpustest,northstar87-synthetic.flux,northstar87-synthetic.nsi,northstar --87 --drive.tpi=48) -$(call do-corpustest,northstar175-synthetic.flux,northstar175-synthetic.nsi,northstar --175 --drive.tpi=48) -$(call do-corpustest,northstar350-synthetic.flux,northstar350-synthetic.nsi,northstar --350 --drive.tpi=48) -$(call do-corpustest,victor9k_ss.flux,victor9k_ss.img,victor9k --612 --drive.tpi=96) -$(call do-corpustest,victor9k_ds.flux,victor9k_ds.img,victor9k --1224 --drive.tpi=96) +# Special OSX settings. +ifeq ($(shell uname),Darwin) + LDFLAGS += \ + -framework IOKit \ + -framework Foundation endif -$(OBJDIR)/%.a: - @mkdir -p $(dir $@) - @echo AR $@ - @$(AR) rc $@ $^ +.PHONY: all +all: +all README.md -%.exe: - @mkdir -p $(dir $@) - @echo LINK $@ - @$(CXX) -o $@ $(filter %.o,$^) $(filter %.a,$^) $(LDFLAGS) $(filter %.a,$^) $(LDFLAGS) +.PHONY: binaries tests +binaries: all +tests: all + +README.md: $(OBJ)/scripts+mkdocindex/scripts+mkdocindex$(EXT) + @echo MKDOC $@ + @csplit -s -f$(OBJ)/README. README.md '//' '%%' + @(cat $(OBJ)/README.00 && $< && cat $(OBJ)/README.01) > README.md -$(OBJDIR)/%.o: %.cpp - @mkdir -p $(dir $@) - @echo CXX $< - @$(CXX) $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $(@:.o=.d) -c -o $@ $< +.PHONY: tests -$(OBJDIR)/%.o: %.cc - @mkdir -p $(dir $@) - @echo CXX $< - @$(CXX) $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $(@:.o=.d) -c -o $@ $< +.PHONY: install install-bin +install:: all install-bin -$(OBJDIR)/%.o: $(OBJDIR)/%.cc - @mkdir -p $(dir $@) - @echo CXX $< - @$(CXX) $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $(@:.o=.d) -c -o $@ $< +install-bin: + @echo "INSTALL" + $(hide) install -D -v "$(OBJ)/src+fluxengine/src+fluxengine" "$(DESTDIR)$(BINDIR)/fluxengine" + $(hide) install -D -v "$(OBJ)/src/gui+gui/gui+gui" "$(DESTDIR)$(BINDIR)/fluxengine-gui" + $(hide) install -D -v "$(OBJ)/tools+brother120tool/tools+brother120tool" "$(DESTDIR)$(BINDIR)/brother120tool" + $(hide) install -D -v "$(OBJ)/tools+brother240tool/tools+brother240tool" "$(DESTDIR)$(BINDIR)/brother240tool" + $(hide) install -D -v "$(OBJ)/tools+upgrade-flux-file/tools+upgrade-flux-file" "$(DESTDIR)$(BINDIR)/upgrade-flux-file" -$(OBJDIR)/%.o: %.c - @mkdir -p $(dir $@) - @echo CC $< - @$(CC) $(CFLAGS) $(CFLAGS) -MMD -MP -MF $(@:.o=.d) -c -o $@ $< - -$(OBJDIR)/%.pb.h: %.proto - @mkdir -p $(dir $@) - @echo PROTOC $@ - @$(PROTOC) -I. --cpp_out=$(OBJDIR) $< - -clean: - rm -rf $(OBJDIR) - -install: install-bin # install-man install-docs ... - -install-bin: fluxengine$(EXT) fluxengine-gui$(EXT) brother120tool$(EXT) brother240tool$(EXT) upgrade-flux-file$(EXT) - install -d "$(DESTDIR)$(BINDIR)" - for target in $^; do \ - install $$target "$(DESTDIR)$(BINDIR)/$$target"; \ - done - --include $(OBJS:%.o=%.d) +include build/ab.mk diff --git a/arch/aeslanier/decoder.cc b/arch/aeslanier/decoder.cc index f79a25bf..7cca2e3b 100644 --- a/arch/aeslanier/decoder.cc +++ b/arch/aeslanier/decoder.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "decoders/decoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" #include "aeslanier.h" -#include "crc.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" -#include "sector.h" -#include "bytes.h" +#include "lib/crc.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/sector.h" +#include "lib/bytes.h" #include "fmt/format.h" #include diff --git a/arch/agat/agat.cc b/arch/agat/agat.cc index 870f9021..7cfadf19 100644 --- a/arch/agat/agat.cc +++ b/arch/agat/agat.cc @@ -1,7 +1,7 @@ -#include "globals.h" -#include "decoders/decoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" #include "agat.h" -#include "bytes.h" +#include "lib/bytes.h" #include "fmt/format.h" uint8_t agatChecksum(const Bytes& bytes) diff --git a/arch/agat/decoder.cc b/arch/agat/decoder.cc index d0d592c9..413e7467 100644 --- a/arch/agat/decoder.cc +++ b/arch/agat/decoder.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "decoders/decoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" #include "agat.h" -#include "crc.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" -#include "sector.h" -#include "bytes.h" +#include "lib/crc.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/sector.h" +#include "lib/bytes.h" #include "fmt/format.h" #include diff --git a/arch/amiga/amiga.cc b/arch/amiga/amiga.cc index d2e95079..569e6b90 100644 --- a/arch/amiga/amiga.cc +++ b/arch/amiga/amiga.cc @@ -1,7 +1,7 @@ -#include "globals.h" -#include "decoders/decoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" #include "amiga.h" -#include "bytes.h" +#include "lib/bytes.h" #include "fmt/format.h" uint32_t amigaChecksum(const Bytes& bytes) diff --git a/arch/amiga/amiga.h b/arch/amiga/amiga.h index da705bed..838691f9 100644 --- a/arch/amiga/amiga.h +++ b/arch/amiga/amiga.h @@ -1,7 +1,7 @@ #ifndef AMIGA_H #define AMIGA_H -#include "encoders/encoders.h" +#include "lib/encoders/encoders.h" #define AMIGA_SECTOR_RECORD 0xaaaa44894489LL diff --git a/arch/amiga/decoder.cc b/arch/amiga/decoder.cc index e4117cfa..52406019 100644 --- a/arch/amiga/decoder.cc +++ b/arch/amiga/decoder.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" #include "protocol.h" -#include "decoders/decoders.h" -#include "sector.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" #include "amiga.h" -#include "bytes.h" +#include "lib/bytes.h" #include "fmt/format.h" #include "lib/decoders/decoders.pb.h" #include diff --git a/arch/amiga/encoder.cc b/arch/amiga/encoder.cc index 0d49382f..93af788b 100644 --- a/arch/amiga/encoder.cc +++ b/arch/amiga/encoder.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" #include "amiga.h" -#include "crc.h" -#include "readerwriter.h" -#include "image.h" +#include "lib/crc.h" +#include "lib/readerwriter.h" +#include "lib/image.h" #include "arch/amiga/amiga.pb.h" #include "lib/encoders/encoders.pb.h" diff --git a/arch/apple2/apple2.h b/arch/apple2/apple2.h index 861ad865..a7eec2a6 100644 --- a/arch/apple2/apple2.h +++ b/arch/apple2/apple2.h @@ -2,8 +2,8 @@ #define APPLE2_H #include -#include "decoders/decoders.h" -#include "encoders/encoders.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" #define APPLE2_SECTOR_RECORD 0xd5aa96 #define APPLE2_DATA_RECORD 0xd5aaad diff --git a/arch/apple2/decoder.cc b/arch/apple2/decoder.cc index ce1e5b28..0a8cfbd5 100644 --- a/arch/apple2/decoder.cc +++ b/arch/apple2/decoder.cc @@ -1,13 +1,13 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" #include "protocol.h" -#include "decoders/decoders.h" -#include "sector.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" #include "apple2.h" #include "arch/apple2/apple2.pb.h" #include "lib/decoders/decoders.pb.h" -#include "bytes.h" +#include "lib/bytes.h" #include "fmt/format.h" #include #include diff --git a/arch/apple2/encoder.cc b/arch/apple2/encoder.cc index 3f5eff33..f67c3301 100644 --- a/arch/apple2/encoder.cc +++ b/arch/apple2/encoder.cc @@ -1,14 +1,14 @@ -#include "globals.h" +#include "lib/globals.h" #include "arch/apple2/apple2.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" -#include "sector.h" -#include "readerwriter.h" -#include "image.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" +#include "lib/sector.h" +#include "lib/readerwriter.h" +#include "lib/image.h" #include "fmt/format.h" #include "lib/encoders/encoders.pb.h" #include -#include "bytes.h" +#include "lib/bytes.h" static int encode_data_gcr(uint8_t data) { diff --git a/arch/brother/decoder.cc b/arch/brother/decoder.cc index 6adcc682..b1921cee 100644 --- a/arch/brother/decoder.cc +++ b/arch/brother/decoder.cc @@ -1,12 +1,12 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" #include "brother.h" -#include "sector.h" -#include "bytes.h" -#include "crc.h" +#include "lib/sector.h" +#include "lib/bytes.h" +#include "lib/crc.h" #include const FluxPattern SECTOR_RECORD_PATTERN(32, BROTHER_SECTOR_RECORD); diff --git a/arch/brother/encoder.cc b/arch/brother/encoder.cc index d69158ea..9a2699ea 100644 --- a/arch/brother/encoder.cc +++ b/arch/brother/encoder.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" #include "brother.h" -#include "crc.h" -#include "readerwriter.h" -#include "image.h" +#include "lib/crc.h" +#include "lib/readerwriter.h" +#include "lib/image.h" #include "arch/brother/brother.pb.h" #include "lib/encoders/encoders.pb.h" diff --git a/arch/build.mk b/arch/build.mk deleted file mode 100644 index 6dbe319b..00000000 --- a/arch/build.mk +++ /dev/null @@ -1,43 +0,0 @@ -LIBARCH_SRCS = \ - arch/aeslanier/decoder.cc \ - arch/agat/agat.cc \ - arch/agat/decoder.cc \ - arch/agat/encoder.cc \ - arch/amiga/amiga.cc \ - arch/amiga/decoder.cc \ - arch/amiga/encoder.cc \ - arch/apple2/decoder.cc \ - arch/apple2/encoder.cc \ - arch/brother/decoder.cc \ - arch/brother/encoder.cc \ - arch/c64/c64.cc \ - arch/c64/decoder.cc \ - arch/c64/encoder.cc \ - arch/f85/decoder.cc \ - arch/fb100/decoder.cc \ - arch/ibm/decoder.cc \ - arch/ibm/encoder.cc \ - arch/macintosh/decoder.cc \ - arch/macintosh/encoder.cc \ - arch/micropolis/decoder.cc \ - arch/micropolis/encoder.cc \ - arch/mx/decoder.cc \ - arch/northstar/decoder.cc \ - arch/northstar/encoder.cc \ - arch/rolandd20/decoder.cc \ - arch/smaky6/decoder.cc \ - arch/tids990/decoder.cc \ - arch/tids990/encoder.cc \ - arch/victor9k/decoder.cc \ - arch/victor9k/encoder.cc \ - arch/zilogmcz/decoder.cc \ - -LIBARCH_OBJS = $(patsubst %.cc, $(OBJDIR)/%.o, $(LIBARCH_SRCS)) -OBJS += $(LIBARCH_OBJS) -$(LIBARCH_SRCS): | $(PROTO_HDRS) -$(LIBARCH_SRCS): CFLAGS += $(PROTO_CFLAGS) -LIBARCH_LIB = $(OBJDIR)/libarch.a -LIBARCH_LDFLAGS = -$(LIBARCH_LIB): $(LIBARCH_OBJS) - -$(call use-pkgconfig, $(LIBARCH_LIB), $(LIBARCH_OBJS), fmt) diff --git a/arch/build.py b/arch/build.py new file mode 100644 index 00000000..5e901433 --- /dev/null +++ b/arch/build.py @@ -0,0 +1,26 @@ +from build.c import cxxlibrary +from build.protobuf import proto, protocc + +proto( + name="arch_proto", + srcs=[ + "./aeslanier/aeslanier.proto", + "./agat/agat.proto", + "./amiga/amiga.proto", + "./apple2/apple2.proto", + "./brother/brother.proto", + "./c64/c64.proto", + "./f85/f85.proto", + "./fb100/fb100.proto", + "./ibm/ibm.proto", + "./macintosh/macintosh.proto", + "./micropolis/micropolis.proto", + "./mx/mx.proto", + "./northstar/northstar.proto", + "./rolandd20/rolandd20.proto", + "./smaky6/smaky6.proto", + "./tids990/tids990.proto", + "./victor9k/victor9k.proto", + "./zilogmcz/zilogmcz.proto", + ], +) diff --git a/arch/c64/c64.cc b/arch/c64/c64.cc index 6d78a861..a1c1a6eb 100644 --- a/arch/c64/c64.cc +++ b/arch/c64/c64.cc @@ -1,4 +1,4 @@ -#include "globals.h" +#include "lib/globals.h" #include "c64.h" /* diff --git a/arch/c64/c64.h b/arch/c64/c64.h index 968af367..32033632 100644 --- a/arch/c64/c64.h +++ b/arch/c64/c64.h @@ -1,8 +1,8 @@ #ifndef C64_H #define C64_H -#include "decoders/decoders.h" -#include "encoders/encoders.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" #define C64_SECTOR_RECORD 0xffd49 #define C64_DATA_RECORD 0xffd57 diff --git a/arch/c64/decoder.cc b/arch/c64/decoder.cc index a64b699d..39f039f6 100644 --- a/arch/c64/decoder.cc +++ b/arch/c64/decoder.cc @@ -1,12 +1,12 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" #include "protocol.h" -#include "decoders/decoders.h" -#include "sector.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" #include "c64.h" -#include "crc.h" -#include "bytes.h" +#include "lib/crc.h" +#include "lib/bytes.h" #include "fmt/format.h" #include #include diff --git a/arch/c64/encoder.cc b/arch/c64/encoder.cc index 2ca81e2a..0028effd 100644 --- a/arch/c64/encoder.cc +++ b/arch/c64/encoder.cc @@ -1,17 +1,17 @@ -#include "globals.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" #include "c64.h" -#include "crc.h" -#include "sector.h" -#include "readerwriter.h" -#include "image.h" +#include "lib/crc.h" +#include "lib/sector.h" +#include "lib/readerwriter.h" +#include "lib/image.h" #include "fmt/format.h" #include "arch/c64/c64.pb.h" #include "lib/encoders/encoders.pb.h" #include "lib/layout.h" #include -#include "bytes.h" +#include "lib/bytes.h" static bool lastBit; diff --git a/arch/f85/decoder.cc b/arch/f85/decoder.cc index 78b54e50..646e053f 100644 --- a/arch/f85/decoder.cc +++ b/arch/f85/decoder.cc @@ -1,12 +1,12 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" #include "protocol.h" -#include "decoders/decoders.h" -#include "sector.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" #include "f85.h" -#include "crc.h" -#include "bytes.h" +#include "lib/crc.h" +#include "lib/bytes.h" #include "fmt/format.h" #include #include diff --git a/arch/fb100/decoder.cc b/arch/fb100/decoder.cc index db231be0..aa1cee57 100644 --- a/arch/fb100/decoder.cc +++ b/arch/fb100/decoder.cc @@ -1,13 +1,13 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" #include "protocol.h" -#include "decoders/decoders.h" -#include "sector.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" #include "fb100.h" -#include "crc.h" -#include "bytes.h" -#include "decoders/rawbits.h" +#include "lib/crc.h" +#include "lib/bytes.h" +#include "lib/decoders/rawbits.h" #include "fmt/format.h" #include #include diff --git a/arch/ibm/decoder.cc b/arch/ibm/decoder.cc index cd6709f6..86f77bf2 100644 --- a/arch/ibm/decoder.cc +++ b/arch/ibm/decoder.cc @@ -1,12 +1,12 @@ -#include "globals.h" -#include "decoders/decoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" #include "ibm.h" -#include "crc.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" -#include "sector.h" +#include "lib/crc.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/sector.h" #include "arch/ibm/ibm.pb.h" -#include "proto.h" +#include "lib/proto.h" #include "lib/layout.h" #include diff --git a/arch/ibm/encoder.cc b/arch/ibm/encoder.cc index 231d78f0..dad5cad1 100644 --- a/arch/ibm/encoder.cc +++ b/arch/ibm/encoder.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" #include "ibm.h" -#include "crc.h" -#include "readerwriter.h" -#include "image.h" +#include "lib/crc.h" +#include "lib/readerwriter.h" +#include "lib/image.h" #include "arch/ibm/ibm.pb.h" #include "lib/encoders/encoders.pb.h" #include "fmt/format.h" diff --git a/arch/macintosh/decoder.cc b/arch/macintosh/decoder.cc index 76eaf9bb..78b0ad7a 100644 --- a/arch/macintosh/decoder.cc +++ b/arch/macintosh/decoder.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" #include "protocol.h" -#include "decoders/decoders.h" -#include "sector.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" #include "macintosh.h" -#include "bytes.h" +#include "lib/bytes.h" #include "fmt/format.h" #include #include diff --git a/arch/macintosh/encoder.cc b/arch/macintosh/encoder.cc index 38ce3c78..ba06cb79 100644 --- a/arch/macintosh/encoder.cc +++ b/arch/macintosh/encoder.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" #include "macintosh.h" -#include "crc.h" -#include "readerwriter.h" -#include "image.h" +#include "lib/crc.h" +#include "lib/readerwriter.h" +#include "lib/image.h" #include "fmt/format.h" #include "lib/encoders/encoders.pb.h" #include "lib/layout.h" diff --git a/arch/micropolis/decoder.cc b/arch/micropolis/decoder.cc index 508fc2ef..725b536e 100644 --- a/arch/micropolis/decoder.cc +++ b/arch/micropolis/decoder.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" -#include "decoders/decoders.h" -#include "sector.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" #include "micropolis.h" -#include "bytes.h" +#include "lib/bytes.h" #include "fmt/format.h" #include "lib/decoders/decoders.pb.h" @@ -67,28 +67,32 @@ static uint8_t b(uint32_t field, uint8_t pos) static uint8_t eccNextBit(uint32_t ecc, uint8_t data_bit) { // This is 0x81932080 which is 0x0104C981 with reversed bits - return b(ecc, 7) ^ b(ecc, 13) ^ b(ecc, 16) ^ b(ecc, 17) ^ b(ecc, 20) - ^ b(ecc, 23) ^ b(ecc, 24) ^ b(ecc, 31) ^ data_bit; + return b(ecc, 7) ^ b(ecc, 13) ^ b(ecc, 16) ^ b(ecc, 17) ^ b(ecc, 20) ^ + b(ecc, 23) ^ b(ecc, 24) ^ b(ecc, 31) ^ data_bit; } uint32_t vectorGraphicEcc(const Bytes& bytes) { uint32_t e = 0; - Bytes payloadBytes = bytes.slice(0, bytes.size()-4); + Bytes payloadBytes = bytes.slice(0, bytes.size() - 4); ByteReader payload(payloadBytes); - while (!payload.eof()) { + while (!payload.eof()) + { uint8_t byte = payload.read_8(); - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 8; i++) + { e = (e << 1) | eccNextBit(e, byte >> 7); byte <<= 1; } } - Bytes trailerBytes = bytes.slice(bytes.size()-4); + Bytes trailerBytes = bytes.slice(bytes.size() - 4); ByteReader trailer(trailerBytes); uint32_t res = e; - while (!trailer.eof()) { + while (!trailer.eof()) + { uint8_t byte = trailer.read_8(); - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 8; i++) + { res = (res << 1) | eccNextBit(e, byte >> 7); e <<= 1; byte <<= 1; @@ -101,13 +105,15 @@ uint32_t vectorGraphicEcc(const Bytes& bytes) static bool vectorGraphicEccFix(Bytes& bytes, uint32_t syndrome) { uint32_t ecc = syndrome; - int pos = (MICROPOLIS_ENCODED_SECTOR_SIZE-5)*8+7; + int pos = (MICROPOLIS_ENCODED_SECTOR_SIZE - 5) * 8 + 7; bool aligned = false; - while ((ecc & 0xff000000) == 0) { + while ((ecc & 0xff000000) == 0) + { pos += 8; ecc <<= 8; } - for (; pos >= 0; pos--) { + for (; pos >= 0; pos--) + { bool bit = ecc & 1; ecc >>= 1; if (bit) @@ -119,7 +125,7 @@ static bool vectorGraphicEccFix(Bytes& bytes, uint32_t syndrome) } if (pos < 0) return false; - bytes[pos/8] ^= ecc >> 16; + bytes[pos / 8] ^= ecc >> 16; return true; } @@ -199,9 +205,11 @@ public: bool eccPresent = bytes[274] == 0xaa; uint32_t ecc = 0; - if (_config.ecc_type() == MicropolisDecoderProto::VECTOR && eccPresent) { + if (_config.ecc_type() == MicropolisDecoderProto::VECTOR && eccPresent) + { ecc = vectorGraphicEcc(bytes.slice(0, 274)); - if (ecc != 0) { + if (ecc != 0) + { vectorGraphicEccFix(bytes, ecc); ecc = vectorGraphicEcc(bytes.slice(0, 274)); } diff --git a/arch/micropolis/encoder.cc b/arch/micropolis/encoder.cc index 6a44b2c7..4c177b48 100644 --- a/arch/micropolis/encoder.cc +++ b/arch/micropolis/encoder.cc @@ -1,9 +1,9 @@ -#include "globals.h" +#include "lib/globals.h" #include "micropolis.h" -#include "sector.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" -#include "image.h" +#include "lib/sector.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" +#include "lib/image.h" #include "lib/encoders/encoders.pb.h" static void write_sector(std::vector& bits, @@ -49,7 +49,8 @@ static void write_sector(std::vector& bits, uint8_t eccPresent = 0; uint32_t ecc = 0; - if (eccType == MicropolisEncoderProto::VECTOR) { + if (eccType == MicropolisEncoderProto::VECTOR) + { eccPresent = 0xaa; ecc = vectorGraphicEcc(sectorData + Bytes(4)); } @@ -98,23 +99,25 @@ public: unsigned prev_cursor = 0; unsigned cursor = 0; - for (const auto& sectorData : sectors) { + for (const auto& sectorData : sectors) + { indexes.push_back(cursor); prev_cursor = cursor; write_sector(bits, cursor, sectorData, _config.ecc_type()); } - indexes.push_back(prev_cursor + (cursor - prev_cursor)/2); + indexes.push_back(prev_cursor + (cursor - prev_cursor) / 2); indexes.push_back(cursor); if (cursor != bits.size()) error("track data mismatched length"); std::unique_ptr fluxmap(new Fluxmap); - nanoseconds_t clockPeriod = calculatePhysicalClockPeriod( - _config.clock_period_us() * 1e3, - _config.rotational_period_ms() * 1e6); + nanoseconds_t clockPeriod = + calculatePhysicalClockPeriod(_config.clock_period_us() * 1e3, + _config.rotational_period_ms() * 1e6); auto pos = bits.begin(); - for (int i = 1; i < indexes.size(); i++) { + for (int i = 1; i < indexes.size(); i++) + { auto end = bits.begin() + indexes[i]; fluxmap->appendBits(std::vector(pos, end), clockPeriod); fluxmap->appendIndex(); diff --git a/arch/mx/decoder.cc b/arch/mx/decoder.cc index 1768eaab..1404f0bf 100644 --- a/arch/mx/decoder.cc +++ b/arch/mx/decoder.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "decoders/decoders.h" -#include "mx/mx.h" -#include "crc.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" -#include "sector.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" +#include "arch/mx/mx.h" +#include "lib/crc.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/sector.h" #include const int SECTOR_SIZE = 256; diff --git a/arch/mx/mx.h b/arch/mx/mx.h index 1aae9d0e..b773ec98 100644 --- a/arch/mx/mx.h +++ b/arch/mx/mx.h @@ -1,7 +1,7 @@ #ifndef MX_H #define MX_H -#include "decoders/decoders.h" +#include "lib/decoders/decoders.h" extern std::unique_ptr createMxDecoder(const DecoderProto& config); diff --git a/arch/northstar/decoder.cc b/arch/northstar/decoder.cc index 4a2d2253..31e10c08 100644 --- a/arch/northstar/decoder.cc +++ b/arch/northstar/decoder.cc @@ -11,13 +11,13 @@ * sure that the hardSectorId is correct. */ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" -#include "decoders/decoders.h" -#include "sector.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" #include "northstar.h" -#include "bytes.h" +#include "lib/bytes.h" #include "lib/decoders/decoders.pb.h" #include "fmt/format.h" diff --git a/arch/northstar/encoder.cc b/arch/northstar/encoder.cc index 2be6dc39..6d20e9c6 100644 --- a/arch/northstar/encoder.cc +++ b/arch/northstar/encoder.cc @@ -1,10 +1,10 @@ -#include "globals.h" +#include "lib/globals.h" #include "northstar.h" -#include "sector.h" -#include "bytes.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" -#include "image.h" +#include "lib/sector.h" +#include "lib/bytes.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" +#include "lib/image.h" #include "lib/encoders/encoders.pb.h" #define GAP_FILL_SIZE_SD 30 diff --git a/arch/smaky6/decoder.cc b/arch/smaky6/decoder.cc index 476afcb3..ebe45256 100644 --- a/arch/smaky6/decoder.cc +++ b/arch/smaky6/decoder.cc @@ -1,12 +1,12 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" #include "protocol.h" -#include "decoders/decoders.h" -#include "sector.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" #include "smaky6.h" -#include "bytes.h" -#include "crc.h" +#include "lib/bytes.h" +#include "lib/crc.h" #include "fmt/format.h" #include "lib/decoders/decoders.pb.h" #include diff --git a/arch/tids990/decoder.cc b/arch/tids990/decoder.cc index 49753f61..5653f475 100644 --- a/arch/tids990/decoder.cc +++ b/arch/tids990/decoder.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" -#include "tids990/tids990.h" -#include "crc.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" -#include "sector.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" +#include "arch/tids990/tids990.h" +#include "lib/crc.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/sector.h" #include #include diff --git a/arch/tids990/encoder.cc b/arch/tids990/encoder.cc index 7b43cfcf..3531a17c 100644 --- a/arch/tids990/encoder.cc +++ b/arch/tids990/encoder.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" #include "tids990.h" -#include "crc.h" -#include "readerwriter.h" -#include "image.h" +#include "lib/crc.h" +#include "lib/readerwriter.h" +#include "lib/image.h" #include "arch/tids990/tids990.pb.h" #include "lib/encoders/encoders.pb.h" #include diff --git a/arch/victor9k/decoder.cc b/arch/victor9k/decoder.cc index 77af32e4..cc823306 100644 --- a/arch/victor9k/decoder.cc +++ b/arch/victor9k/decoder.cc @@ -1,12 +1,12 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" #include "protocol.h" -#include "decoders/decoders.h" -#include "sector.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" #include "victor9k.h" -#include "crc.h" -#include "bytes.h" +#include "lib/crc.h" +#include "lib/bytes.h" #include "fmt/format.h" #include #include diff --git a/arch/victor9k/encoder.cc b/arch/victor9k/encoder.cc index c00ee592..dcaa7066 100644 --- a/arch/victor9k/encoder.cc +++ b/arch/victor9k/encoder.cc @@ -1,17 +1,17 @@ -#include "globals.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" #include "victor9k.h" -#include "crc.h" -#include "sector.h" -#include "readerwriter.h" -#include "image.h" +#include "lib/crc.h" +#include "lib/sector.h" +#include "lib/readerwriter.h" +#include "lib/image.h" #include "fmt/format.h" #include "arch/victor9k/victor9k.pb.h" #include "lib/encoders/encoders.pb.h" #include "lib/layout.h" #include -#include "bytes.h" +#include "lib/bytes.h" static bool lastBit; diff --git a/arch/zilogmcz/decoder.cc b/arch/zilogmcz/decoder.cc index c1541e59..8af6dea6 100644 --- a/arch/zilogmcz/decoder.cc +++ b/arch/zilogmcz/decoder.cc @@ -1,12 +1,12 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" #include "protocol.h" -#include "decoders/decoders.h" -#include "sector.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" #include "zilogmcz.h" -#include "bytes.h" -#include "crc.h" +#include "lib/bytes.h" +#include "lib/crc.h" #include "fmt/format.h" #include #include diff --git a/build.py b/build.py new file mode 100644 index 00000000..b6616437 --- /dev/null +++ b/build.py @@ -0,0 +1,310 @@ +from build.ab import export +from build.c import clibrary, cxxlibrary +from build.protobuf import proto, protocc +from build.pkg import package +from build.utils import test +from glob import glob +import config +import re + +package(name="protobuf_lib", package="protobuf") +package(name="z_lib", package="zlib") +package(name="fmt_lib", package="fmt") +package(name="sqlite3_lib", package="sqlite3") + +clibrary(name="protocol", hdrs={"protocol.h": "./protocol.h"}) + +proto(name="fl2_proto", srcs=["lib/fl2.proto"]) +protocc(name="fl2_proto_lib", srcs=["+fl2_proto"]) + +cxxlibrary( + name="lib", + srcs=[ + "./lib/bitmap.cc", + "./lib/bytes.cc", + "./lib/config.cc", + "./lib/crc.cc", + "./lib/csvreader.cc", + "./lib/decoders/decoders.cc", + "./lib/decoders/fluxdecoder.cc", + "./lib/decoders/fluxmapreader.cc", + "./lib/decoders/fmmfm.cc", + "./lib/encoders/encoders.cc", + "./lib/fl2.cc", + "./lib/flags.cc", + "./lib/fluxmap.cc", + "./lib/fluxsink/a2rfluxsink.cc", + "./lib/fluxsink/aufluxsink.cc", + "./lib/fluxsink/fl2fluxsink.cc", + "./lib/fluxsink/fluxsink.cc", + "./lib/fluxsink/hardwarefluxsink.cc", + "./lib/fluxsink/scpfluxsink.cc", + "./lib/fluxsink/vcdfluxsink.cc", + "./lib/fluxsource/a2rfluxsource.cc", + "./lib/fluxsource/cwffluxsource.cc", + "./lib/fluxsource/erasefluxsource.cc", + "./lib/fluxsource/fl2fluxsource.cc", + "./lib/fluxsource/fluxsource.cc", + "./lib/fluxsource/flx.cc", + "./lib/fluxsource/flxfluxsource.cc", + "./lib/fluxsource/hardwarefluxsource.cc", + "./lib/fluxsource/kryoflux.cc", + "./lib/fluxsource/kryofluxfluxsource.cc", + "./lib/fluxsource/memoryfluxsource.cc", + "./lib/fluxsource/scpfluxsource.cc", + "./lib/fluxsource/testpatternfluxsource.cc", + "./lib/globals.cc", + "./lib/hexdump.cc", + "./lib/image.cc", + "./lib/imagereader/d64imagereader.cc", + "./lib/imagereader/d88imagereader.cc", + "./lib/imagereader/dimimagereader.cc", + "./lib/imagereader/diskcopyimagereader.cc", + "./lib/imagereader/fdiimagereader.cc", + "./lib/imagereader/imagereader.cc", + "./lib/imagereader/imdimagereader.cc", + "./lib/imagereader/imgimagereader.cc", + "./lib/imagereader/jv3imagereader.cc", + "./lib/imagereader/nfdimagereader.cc", + "./lib/imagereader/nsiimagereader.cc", + "./lib/imagereader/td0imagereader.cc", + "./lib/imagewriter/d64imagewriter.cc", + "./lib/imagewriter/d88imagewriter.cc", + "./lib/imagewriter/diskcopyimagewriter.cc", + "./lib/imagewriter/imagewriter.cc", + "./lib/imagewriter/imdimagewriter.cc", + "./lib/imagewriter/imgimagewriter.cc", + "./lib/imagewriter/ldbsimagewriter.cc", + "./lib/imagewriter/nsiimagewriter.cc", + "./lib/imagewriter/rawimagewriter.cc", + "./lib/layout.cc", + "./lib/ldbs.cc", + "./lib/logger.cc", + "./lib/proto.cc", + "./lib/readerwriter.cc", + "./lib/sector.cc", + "./lib/usb/fluxengineusb.cc", + "./lib/usb/greaseweazle.cc", + "./lib/usb/greaseweazleusb.cc", + "./lib/usb/serial.cc", + "./lib/usb/usb.cc", + "./lib/usb/usbfinder.cc", + "./lib/utils.cc", + "./lib/vfs/acorndfs.cc", + "./lib/vfs/amigaffs.cc", + "./lib/vfs/appledos.cc", + "./lib/vfs/applesingle.cc", + "./lib/vfs/brother120fs.cc", + "./lib/vfs/cbmfs.cc", + "./lib/vfs/cpmfs.cc", + "./lib/vfs/fatfs.cc", + "./lib/vfs/fluxsectorinterface.cc", + "./lib/vfs/imagesectorinterface.cc", + "./lib/vfs/lif.cc", + "./lib/vfs/machfs.cc", + "./lib/vfs/microdos.cc", + "./lib/vfs/philefs.cc", + "./lib/vfs/prodos.cc", + "./lib/vfs/roland.cc", + "./lib/vfs/smaky6fs.cc", + "./lib/vfs/vfs.cc", + "./lib/vfs/zdos.cc", + "./arch/aeslanier/decoder.cc", + "./arch/agat/agat.cc", + "./arch/agat/decoder.cc", + "./arch/agat/encoder.cc", + "./arch/amiga/amiga.cc", + "./arch/amiga/decoder.cc", + "./arch/amiga/encoder.cc", + "./arch/apple2/decoder.cc", + "./arch/apple2/encoder.cc", + "./arch/brother/decoder.cc", + "./arch/brother/encoder.cc", + "./arch/c64/c64.cc", + "./arch/c64/decoder.cc", + "./arch/c64/encoder.cc", + "./arch/f85/decoder.cc", + "./arch/fb100/decoder.cc", + "./arch/ibm/decoder.cc", + "./arch/ibm/encoder.cc", + "./arch/macintosh/decoder.cc", + "./arch/macintosh/encoder.cc", + "./arch/micropolis/decoder.cc", + "./arch/micropolis/encoder.cc", + "./arch/mx/decoder.cc", + "./arch/northstar/decoder.cc", + "./arch/northstar/encoder.cc", + "./arch/rolandd20/decoder.cc", + "./arch/smaky6/decoder.cc", + "./arch/tids990/decoder.cc", + "./arch/tids990/encoder.cc", + "./arch/victor9k/decoder.cc", + "./arch/victor9k/encoder.cc", + "./arch/zilogmcz/decoder.cc", + ], + hdrs={ + "arch/ibm/ibm.h": "./arch/ibm/ibm.h", + "arch/apple2/data_gcr.h": "./arch/apple2/data_gcr.h", + "arch/apple2/apple2.h": "./arch/apple2/apple2.h", + "arch/smaky6/smaky6.h": "./arch/smaky6/smaky6.h", + "arch/tids990/tids990.h": "./arch/tids990/tids990.h", + "arch/zilogmcz/zilogmcz.h": "./arch/zilogmcz/zilogmcz.h", + "arch/amiga/amiga.h": "./arch/amiga/amiga.h", + "arch/f85/data_gcr.h": "./arch/f85/data_gcr.h", + "arch/f85/f85.h": "./arch/f85/f85.h", + "arch/mx/mx.h": "./arch/mx/mx.h", + "arch/aeslanier/aeslanier.h": "./arch/aeslanier/aeslanier.h", + "arch/northstar/northstar.h": "./arch/northstar/northstar.h", + "arch/brother/data_gcr.h": "./arch/brother/data_gcr.h", + "arch/brother/brother.h": "./arch/brother/brother.h", + "arch/brother/header_gcr.h": "./arch/brother/header_gcr.h", + "arch/macintosh/data_gcr.h": "./arch/macintosh/data_gcr.h", + "arch/macintosh/macintosh.h": "./arch/macintosh/macintosh.h", + "arch/agat/agat.h": "./arch/agat/agat.h", + "arch/fb100/fb100.h": "./arch/fb100/fb100.h", + "arch/victor9k/data_gcr.h": "./arch/victor9k/data_gcr.h", + "arch/victor9k/victor9k.h": "./arch/victor9k/victor9k.h", + "arch/rolandd20/rolandd20.h": "./arch/rolandd20/rolandd20.h", + "arch/micropolis/micropolis.h": "./arch/micropolis/micropolis.h", + "arch/c64/data_gcr.h": "./arch/c64/data_gcr.h", + "arch/c64/c64.h": "./arch/c64/c64.h", + "lib/a2r.h": "./lib/a2r.h", + "lib/bitmap.h": "./lib/bitmap.h", + "lib/bytes.h": "./lib/bytes.h", + "lib/config.h": "./lib/config.h", + "lib/crc.h": "./lib/crc.h", + "lib/csvreader.h": "./lib/csvreader.h", + "lib/decoders/decoders.h": "./lib/decoders/decoders.h", + "lib/decoders/fluxdecoder.h": "./lib/decoders/fluxdecoder.h", + "lib/decoders/fluxmapreader.h": "./lib/decoders/fluxmapreader.h", + "lib/decoders/rawbits.h": "./lib/decoders/rawbits.h", + "lib/encoders/encoders.h": "./lib/encoders/encoders.h", + "lib/scp.h": "./lib/scp.h", + "lib/fl2.h": "./lib/fl2.h", + "lib/flags.h": "./lib/flags.h", + "lib/flux.h": "./lib/flux.h", + "lib/fluxmap.h": "./lib/fluxmap.h", + "lib/fluxsink/fluxsink.h": "./lib/fluxsink/fluxsink.h", + "lib/fluxsource/fluxsource.h": "lib/fluxsource/fluxsource.h", + "lib/fluxsource/flx.h": "lib/fluxsource/flx.h", + "lib/fluxsource/kryoflux.h": "lib/fluxsource/kryoflux.h", + "lib/globals.h": "./lib/globals.h", + "lib/image.h": "./lib/image.h", + "lib/imagereader/imagereader.h": "./lib/imagereader/imagereader.h", + "lib/imagewriter/imagewriter.h": "./lib/imagewriter/imagewriter.h", + "lib/layout.h": "./lib/layout.h", + "lib/ldbs.h": "./lib/ldbs.h", + "lib/logger.h": "./lib/logger.h", + "lib/proto.h": "./lib/proto.h", + "lib/readerwriter.h": "./lib/readerwriter.h", + "lib/sector.h": "./lib/sector.h", + "lib/usb/greaseweazle.h": "./lib/usb/greaseweazle.h", + "lib/usb/usb.h": "./lib/usb/usb.h", + "lib/usb/usbfinder.h": "./lib/usb/usbfinder.h", + "lib/utils.h": "./lib/utils.h", + "lib/vfs/applesingle.h": "./lib/vfs/applesingle.h", + "lib/vfs/sectorinterface.h": "./lib/vfs/sectorinterface.h", + "lib/vfs/vfs.h": "./lib/vfs/vfs.h", + }, + deps=[ + "+fl2_proto_lib", + "+protocol", + "lib+config_proto_lib", + "dep/adflib", + "dep/agg", + "dep/fatfs", + "dep/hfsutils", + "dep/libusbp", + "dep/stb", + ], +) + +corpustests = [] +if not glob("../fluxengine-testdata/data"): + print("fluxengine-testdata not found; skipping corpus tests") +else: + corpus = [ + ("agat", "", ""), + ("amiga", "", ""), + ("apple2", "", "--140 40track_drive"), + ("atarist", "", "--360"), + ("atarist", "", "--370"), + ("atarist", "", "--400"), + ("atarist", "", "--410"), + ("atarist", "", "--720"), + ("atarist", "", "--740"), + ("atarist", "", "--800"), + ("atarist", "", "--820"), + ("bk", "", ""), + ("brother", "", "--120 40track_drive"), + ("brother", "", "--240"), + ( + "commodore", + "scripts/commodore1541_test.textpb", + "--171 40track_drive", + ), + ( + "commodore", + "scripts/commodore1541_test.textpb", + "--192 40track_drive", + ), + ("commodore", "", "--800"), + ("commodore", "", "--1620"), + ("hplif", "", "--264"), + ("hplif", "", "--608"), + ("hplif", "", "--616"), + ("hplif", "", "--770"), + ("ibm", "", "--1200"), + ("ibm", "", "--1232"), + ("ibm", "", "--1440"), + ("ibm", "", "--1680"), + ("ibm", "", "--180 40track_drive"), + ("ibm", "", "--160 40track_drive"), + ("ibm", "", "--320 40track_drive"), + ("ibm", "", "--360 40track_drive"), + ("ibm", "", "--720_96"), + ("ibm", "", "--720_135"), + ("mac", "scripts/mac400_test.textpb", "--400"), + ("mac", "scripts/mac800_test.textpb", "--800"), + ("n88basic", "", ""), + ("rx50", "", ""), + ("tids990", "", ""), + ("victor9k", "", "--612"), + ("victor9k", "", "--1224"), + ] + + for c in corpus: + name = re.sub(r"[^a-zA-Z0-9]", "_", "".join(c), 0) + corpustests += [ + test( + name=f"corpustest_{name}_{format}", + ins=["src+fluxengine"], + deps=["scripts/encodedecodetest.sh"], + commands=[ + "{deps[0]} " + + c[0] + + " " + + format + + " {ins[0]} '" + + c[1] + + "' '" + + c[2] + + "' $(dir {outs[0]}) > /dev/null" + ], + label="CORPUSTEST", + ) + for format in ["scp", "flux"] + ] + +export( + name="all", + items={ + "fluxengine$(EXT)": "src+fluxengine", + "fluxengine-gui$(EXT)": "src/gui", + "brother120tool$(EXT)": "tools+brother120tool", + "brother240tool$(EXT)": "tools+brother240tool", + "upgrade-flux-file$(EXT)": "tools+upgrade-flux-file", + } + | ({"FluxEngine.pkg": "src/gui+fluxengine_pkg"} if config.osx else {}), + deps=["tests", "src/formats+docs", "scripts+mkdocindex"] + corpustests, +) diff --git a/build/_objectify.py b/build/_objectify.py new file mode 100644 index 00000000..17148954 --- /dev/null +++ b/build/_objectify.py @@ -0,0 +1,19 @@ +import sys +from functools import partial + +if len(sys.argv) != 3: + sys.exit("Usage: %s " % sys.argv[0]) +filename = sys.argv[1] +symbol = sys.argv[2] + +print("const uint8_t " + symbol + "[] = {") +n = 0 +with open(filename, "rb") as in_file: + for c in iter(partial(in_file.read, 1), b""): + print("0x%02X," % ord(c), end="") + n += 1 + if n % 16 == 0: + print() +print("};") + +print("const size_t " + symbol + "_len = sizeof(" + symbol + ");") diff --git a/build/ab.mk b/build/ab.mk new file mode 100644 index 00000000..7614259f --- /dev/null +++ b/build/ab.mk @@ -0,0 +1,42 @@ +ifeq ($(findstring 4.,$(MAKE_VERSION)),) +$(error You need GNU Make 4.x for this (if you're on OSX, use gmake).) +endif + +OBJ ?= .obj +PYTHON ?= python3 +CC ?= gcc +CXX ?= g++ +AR ?= ar +CFLAGS ?= -g -Og +LDFLAGS ?= -g +hide = @ +PKG_CONFIG ?= pkg-config +ECHO ?= echo + +ifeq ($(OS), Windows_NT) + EXT ?= .exe +endif +EXT ?= + +include $(OBJ)/build.mk + +.PHONY: update-ab +update-ab: + @echo "Press RETURN to update ab from the repository, or CTRL+C to cancel." \ + && read a \ + && (curl -L https://github.com/davidgiven/ab/releases/download/dev/distribution.tar.xz | tar xvJf -) \ + && echo "Done." + +.PHONY: clean +clean:: + @echo CLEAN + $(hide) rm -rf $(OBJ) bin + +export PYTHONHASHSEED = 1 +build-files = $(shell find . -name 'build.py') build/*.py config.py +$(OBJ)/build.mk: Makefile $(build-files) + @echo "AB" + @mkdir -p $(OBJ) + $(hide) $(PYTHON) -X pycache_prefix=$(OBJ) build/ab.py -t +all -o $@ \ + build.py || rm -f $@ + diff --git a/build/ab.py b/build/ab.py new file mode 100644 index 00000000..27654568 --- /dev/null +++ b/build/ab.py @@ -0,0 +1,486 @@ +from collections.abc import Iterable, Sequence +from os.path import * +from types import SimpleNamespace +import argparse +import copy +import functools +import importlib +import importlib.abc +import importlib.util +import inspect +import re +import sys +import types +import pathlib +import builtins +import os + +defaultGlobals = {} +targets = {} +unmaterialisedTargets = set() +materialisingStack = [] +outputFp = None +cwdStack = [""] + +sys.path += ["."] +old_import = builtins.__import__ + + +def new_import(name, *args, **kwargs): + if name not in sys.modules: + path = name.replace(".", "/") + ".py" + if isfile(path): + sys.stderr.write(f"loading {path}\n") + loader = importlib.machinery.SourceFileLoader(name, path) + + spec = importlib.util.spec_from_loader( + name, loader, origin="built-in" + ) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + cwdStack.append(dirname(path)) + spec.loader.exec_module(module) + cwdStack.pop() + + return old_import(name, *args, **kwargs) + + +builtins.__import__ = new_import + + +class ABException(BaseException): + pass + + +class ParameterList(Sequence): + def __init__(self, parent=[]): + self.data = parent + + def __getitem__(self, i): + return self.data[i] + + def __len__(self): + return len(self.data) + + def __str__(self): + return " ".join(self.data) + + def __add__(self, other): + newdata = self.data.copy() + other + return ParameterList(newdata) + + def __repr__(self): + return f"" + + +class Invocation: + name = None + callback = None + types = None + ins = None + outs = None + binding = None + + def materialise(self, replacing=False): + if self in unmaterialisedTargets: + if not replacing and (self in materialisingStack): + print("Found dependency cycle:") + for i in materialisingStack: + print(f" {i.name}") + print(f" {self.name}") + sys.exit(1) + + materialisingStack.append(self) + + # Perform type conversion to the declared rule parameter types. + + try: + self.args = {} + for k, v in self.binding.arguments.items(): + if k != "kwargs": + t = self.types.get(k, None) + if t: + v = t(v).convert(self) + self.args[k] = v + else: + for kk, vv in v.items(): + t = self.types.get(kk, None) + if t: + vv = t(vv).convert(self) + self.args[kk] = vv + + # Actually call the callback. + + cwdStack.append(self.cwd) + self.callback(**self.args) + cwdStack.pop() + except BaseException as e: + print( + f"Error materialising {self} ({id(self)}): {self.callback}" + ) + print(f"Arguments: {self.args}") + raise e + + if self.outs is None: + raise ABException(f"{self.name} didn't set self.outs") + + if self in unmaterialisedTargets: + unmaterialisedTargets.remove(self) + + materialisingStack.pop() + + def __repr__(self): + return "" % self.name + + +def Rule(func): + sig = inspect.signature(func) + + @functools.wraps(func) + def wrapper(*, name=None, replaces=None, **kwargs): + cwd = None + if name: + if ("+" in name) and not name.startswith("+"): + (cwd, _) = name.split("+", 1) + if not cwd: + cwd = cwdStack[-1] + + if name: + i = Invocation() + if name.startswith("./"): + name = join(cwd, name) + elif "+" not in name: + name = cwd + "+" + name + + i.name = name + i.localname = name.split("+")[-1] + + if name in targets: + raise ABException(f"target {i.name} has already been defined") + targets[name] = i + elif replaces: + i = replaces + name = i.name + else: + raise ABException("you must supply either name or replaces") + + i.cwd = cwd + i.types = func.__annotations__ + i.callback = func + setattr(i, func.__name__, SimpleNamespace()) + + i.binding = sig.bind(name=name, self=i, **kwargs) + i.binding.apply_defaults() + + unmaterialisedTargets.add(i) + if replaces: + i.materialise(replacing=True) + return i + + defaultGlobals[func.__name__] = wrapper + return wrapper + + +class Type: + def __init__(self, value): + self.value = value + + +class Targets(Type): + def convert(self, invocation): + value = self.value + if type(value) is str: + value = [value] + if type(value) is list: + value = targetsof(value, cwd=invocation.cwd) + return value + + +class Target(Type): + def convert(self, invocation): + value = self.value + if not value: + return None + return targetof(value, cwd=invocation.cwd) + + +class TargetsMap(Type): + def convert(self, invocation): + value = self.value + if type(value) is dict: + return { + k: targetof(v, cwd=invocation.cwd) for k, v in value.items() + } + raise ABException(f"wanted a dict of targets, got a {type(value)}") + + +def flatten(*xs): + def recurse(xs): + for x in xs: + if isinstance(x, Iterable) and not isinstance(x, (str, bytes)): + yield from recurse(x) + else: + yield x + + return list(recurse(xs)) + + +def fileinvocation(s): + i = Invocation() + i.name = s + i.outs = [s] + targets[s] = i + return i + + +def targetof(s, cwd): + if isinstance(s, Invocation): + s.materialise() + return s + + if s in targets: + t = targets[s] + t.materialise() + return t + + if s.startswith(".+"): + s = cwd + s[1:] + elif s.startswith("./"): + s = normpath(join(cwd, s)) + elif s.endswith("/"): + return fileinvocation(s) + elif s.startswith("$"): + return fileinvocation(s) + + if "+" not in s: + if isdir(s): + s = s + "+" + basename(s) + else: + return fileinvocation(s) + + (path, target) = s.split("+", 2) + loadbuildfile(join(path, "build.py")) + if not s in targets: + raise ABException(f"build file at {path} doesn't contain +{target}") + i = targets[s] + i.materialise() + return i + + +def targetsof(*xs, cwd): + return flatten([targetof(x, cwd) for x in flatten(xs)]) + + +def filenamesof(*xs): + s = [] + for t in flatten(xs): + if type(t) == str: + t = normpath(t) + s += [t] + else: + s += [f for f in [normpath(f) for f in filenamesof(t.outs)]] + return s + + +def targetnamesof(*xs): + s = [] + for x in flatten(xs): + if type(x) == str: + x = normpath(x) + if x not in s: + s += [x] + else: + if x.name not in s: + s += [x.name] + return s + + +def filenameof(x): + xs = filenamesof(x) + if len(xs) != 1: + raise ABException("expected a single item") + return xs[0] + + +def stripext(path): + return splitext(path)[0] + + +def emit(*args): + outputFp.write(" ".join(flatten(args))) + outputFp.write("\n") + + +def templateexpand(s, invocation): + class Converter: + def __getitem__(self, key): + if key == "self": + return invocation + f = filenamesof(invocation.args[key]) + if isinstance(f, Sequence): + f = ParameterList(f) + return f + + return eval("f%r" % s, invocation.callback.__globals__, Converter()) + + +def emitter_rule(name, ins, outs, deps=[]): + emit("") + emit(".PHONY:", name) + if outs: + emit(name, ":", filenamesof(outs), ";") + emit(filenamesof(outs), "&:", filenamesof(ins), filenamesof(deps)) + else: + emit(name, "&:", filenamesof(ins), filenamesof(deps)) + + +def emitter_endrule(name): + pass + + +def emitter_label(s): + emit("\t$(hide)", "$(ECHO)", s) + + +def emitter_exec(cs): + for c in cs: + emit("\t$(hide)", c) + + +def unmake(*ss): + return [ + re.sub(r"\$\(([^)]*)\)", r"$\1", s) for s in flatten(filenamesof(ss)) + ] + + +@Rule +def simplerule( + self, + name, + ins: Targets = [], + outs=[], + deps: Targets = [], + commands=[], + label="RULE", + **kwargs, +): + self.ins = ins + self.outs = outs + self.deps = deps + emitter_rule(self.name, ins + deps, outs) + emitter_label(templateexpand("{label} {name}", self)) + + dirs = [] + for out in filenamesof(outs): + dir = dirname(out) + if dir and dir not in dirs: + dirs += [dir] + + cs = [("mkdir -p %s" % dir) for dir in dirs] + for c in commands: + cs += [templateexpand(c, self)] + emitter_exec(cs) + emitter_endrule(self.name) + + +@Rule +def normalrule( + self, + name=None, + ins: Targets = [], + deps: Targets = [], + outs=[], + label="RULE", + objdir=None, + commands=[], + **kwargs, +): + objdir = objdir or join("$(OBJ)", name) + + self.normalrule.objdir = objdir + simplerule( + replaces=self, + ins=ins, + deps=deps, + outs=[join(objdir, f) for f in outs], + label=label, + commands=commands, + **kwargs, + ) + + +@Rule +def export(self, name=None, items: TargetsMap = {}, deps: Targets = []): + cs = [] + self.ins = items.values() + self.outs = [] + for dest, src in items.items(): + destf = filenameof(dest) + dir = dirname(destf) + if dir: + cs += ["mkdir -p " + dir] + + srcs = filenamesof(src) + if len(srcs) != 1: + raise ABException( + "a dependency of an export must have exactly one output file" + ) + + cs += ["cp %s %s" % (srcs[0], destf)] + self.outs += [destf] + + emitter_rule(self.name, items.values(), self.outs, deps) + emitter_label(f"EXPORT {self.name}") + + emitter_exec(cs) + + if self.outs: + emit("clean::") + emit("\t$(hide) rm -f " + (" ".join(filenamesof(self.outs)))) + self.outs += deps + + emitter_endrule(self.name) + + +def loadbuildfile(filename): + filename = filename.replace("/", ".").removesuffix(".py") + builtins.__import__(filename) + + +def load(filename): + loadbuildfile(filename) + callerglobals = inspect.stack()[1][0].f_globals + for k, v in defaultGlobals.items(): + callerglobals[k] = v + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("-o", "--output") + parser.add_argument("files", nargs="+") + parser.add_argument("-t", "--targets", action="append") + args = parser.parse_args() + if not args.targets: + raise ABException("no targets supplied") + + global outputFp + outputFp = open(args.output, "wt") + + for k in ("Rule", "Targets", "load", "filenamesof", "stripext"): + defaultGlobals[k] = globals()[k] + + global __name__ + sys.modules["build.ab"] = sys.modules[__name__] + __name__ = "build.ab" + + for f in args.files: + loadbuildfile(f) + + for t in flatten([a.split(",") for a in args.targets]): + if t not in targets: + raise ABException("target %s is not defined" % t) + targets[t].materialise() + emit("AB_LOADED = 1\n") + + +main() diff --git a/build/c.py b/build/c.py new file mode 100644 index 00000000..eef55ed1 --- /dev/null +++ b/build/c.py @@ -0,0 +1,265 @@ +from os.path import basename, join +from build.ab import ( + ABException, + Rule, + Targets, + TargetsMap, + filenameof, + flatten, + filenamesof, + normalrule, + stripext, +) +from os.path import * +from types import SimpleNamespace + + +def cfileimpl(self, name, srcs, deps, suffix, commands, label, kind, cflags): + outleaf = stripext(basename(filenameof(srcs[0]))) + suffix + + normalrule( + replaces=self, + ins=srcs, + deps=deps, + outs=[outleaf], + label=label, + commands=commands, + cflags=cflags, + ) + + +@Rule +def cfile( + self, + name, + srcs: Targets = [], + deps: Targets = [], + cflags=[], + suffix=".o", + commands=["$(CC) -c -o {outs[0]} {ins[0]} $(CFLAGS) {cflags}"], + label="CC", +): + cfileimpl(self, name, srcs, deps, suffix, commands, label, "cfile", cflags) + + +@Rule +def cxxfile( + self, + name, + srcs: Targets = [], + deps: Targets = [], + cflags=[], + suffix=".o", + commands=["$(CXX) -c -o {outs[0]} {ins[0]} $(CFLAGS) {cflags}"], + label="CXX", +): + cfileimpl( + self, name, srcs, deps, suffix, commands, label, "cxxfile", cflags + ) + + +def findsources(name, srcs, deps, cflags, filerule): + objs = [] + for s in flatten(srcs): + objs += [ + filerule( + name=join(name, f.removeprefix("$(OBJ)/")), + srcs=[f], + deps=deps, + cflags=cflags, + ) + for f in filenamesof(s) + if f.endswith(".c") or f.endswith(".cc") or f.endswith(".cpp") + ] + if any(f.endswith(".o") for f in filenamesof(s)): + objs += [s] + + return objs + + +def libraryimpl( + self, name, srcs, deps, hdrs, cflags, ldflags, commands, label, kind +): + if not srcs and not hdrs: + raise ABException( + "clibrary contains no sources and no exported headers" + ) + + libraries = [d for d in deps if hasattr(d, "clibrary")] + for library in libraries: + if library.clibrary.cflags: + cflags += library.clibrary.cflags + if library.clibrary.ldflags: + ldflags += library.clibrary.ldflags + + for f in filenamesof(srcs): + if f.endswith(".h"): + deps += [f] + + hdrcs = [] + hdrins = list(hdrs.values()) + hdrouts = [] + i = 0 + for dest, src in hdrs.items(): + s = filenamesof(src) + if len(s) != 1: + raise ABException( + "a dependency of an export must have exactly one output file" + ) + + hdrcs += ["cp {ins[" + str(i) + "]} {outs[" + str(i) + "]}"] + hdrouts += [dest] + i = i + 1 + + if not hasattr(self, "clibrary"): + self.clibrary = SimpleNamespace() + if srcs: + hr = None + if hdrcs: + hr = normalrule( + name=f"{name}_hdrs", + ins=hdrins, + outs=hdrouts, + label="HEADERS", + commands=hdrcs, + ) + hr.materialise() + + actualsrcs = findsources( + name, + srcs, + deps + ([f"{name}_hdrs"] if hr else []), + cflags + ([f"-I{hr.normalrule.objdir}"] if hr else []), + kind, + ) + + normalrule( + replaces=self, + ins=actualsrcs, + outs=[basename(name) + ".a"], + label=label, + commands=commands if actualsrcs else [], + ) + + self.clibrary.ldflags = ldflags + self.clibrary.cflags = ["-I" + hr.normalrule.objdir] if hr else [] + else: + r = normalrule( + replaces=self, + ins=hdrins, + outs=hdrouts, + label="HEADERS", + commands=hdrcs, + ) + r.materialise() + + self.clibrary.ldflags = ldflags + self.clibrary.cflags = ["-I" + r.normalrule.objdir] + + +@Rule +def clibrary( + self, + name, + srcs: Targets = [], + deps: Targets = [], + hdrs: TargetsMap = {}, + cflags=[], + ldflags=[], + commands=["$(AR) cqs {outs[0]} {ins}"], + label="LIB", +): + return libraryimpl( + self, name, srcs, deps, hdrs, cflags, ldflags, commands, label, cfile + ) + + +@Rule +def cxxlibrary( + self, + name, + srcs: Targets = [], + deps: Targets = [], + hdrs: TargetsMap = {}, + cflags=[], + ldflags=[], + commands=["$(AR) cqs {outs[0]} {ins}"], + label="LIB", +): + return libraryimpl( + self, name, srcs, deps, hdrs, cflags, ldflags, commands, label, cxxfile + ) + + +def programimpl( + self, name, srcs, deps, cflags, ldflags, commands, label, filerule, kind +): + libraries = [d for d in deps if hasattr(d, "clibrary")] + for library in libraries: + if library.clibrary.cflags: + cflags += library.clibrary.cflags + if library.clibrary.ldflags: + ldflags += library.clibrary.ldflags + + deps += [f for f in filenamesof(srcs) if f.endswith(".h")] + + ars = [f for f in filenamesof(libraries) if f.endswith(".a")] + normalrule( + replaces=self, + ins=(findsources(name, srcs, deps, cflags, filerule) + ars + ars), + outs=[basename(name) + "$(EXT)"], + deps=deps, + label=label, + commands=commands, + ldflags=ldflags, + ) + + +@Rule +def cprogram( + self, + name, + srcs: Targets = [], + deps: Targets = [], + cflags=[], + ldflags=[], + commands=["$(CC) -o {outs[0]} {ins} {ldflags} $(LDFLAGS)"], + label="CLINK", +): + programimpl( + self, + name, + srcs, + deps, + cflags, + ldflags, + commands, + label, + cfile, + "cprogram", + ) + + +@Rule +def cxxprogram( + self, + name, + srcs: Targets = [], + deps: Targets = [], + cflags=[], + ldflags=[], + commands=["$(CXX) -o {outs[0]} {ins} {ldflags} $(LDFLAGS)"], + label="CXXLINK", +): + programimpl( + self, + name, + srcs, + deps, + cflags, + ldflags, + commands, + label, + cxxfile, + "cxxprogram", + ) diff --git a/build/pkg.py b/build/pkg.py new file mode 100644 index 00000000..c1c98f47 --- /dev/null +++ b/build/pkg.py @@ -0,0 +1,38 @@ +from build.ab import Rule, emit, Target +from types import SimpleNamespace +import os +import subprocess + +emit( + """ +PKG_CONFIG ?= pkg-config +PACKAGES := $(shell $(PKG_CONFIG) --list-all | cut -d' ' -f1) +""" +) + + +@Rule +def package(self, name, package=None, fallback: Target = None): + emit("ifeq ($(filter %s, $(PACKAGES)),)" % package) + if fallback: + emit(f"PACKAGE_CFLAGS_{package} :=", fallback.clibrary.cflags) + emit(f"PACKAGE_LDFLAGS_{package} := ", fallback.clibrary.ldflags) + emit(f"PACKAGE_DEP_{package} := ", fallback.name) + else: + emit(f"$(error Required package '{package}' not installed.)") + emit("else") + emit( + f"PACKAGE_CFLAGS_{package} := $(shell $(PKG_CONFIG) --cflags {package})" + ) + emit( + f"PACKAGE_LDFLAGS_{package} := $(shell $(PKG_CONFIG) --libs {package})" + ) + emit(f"PACKAGE_DEP_{package} := ") + emit("endif") + + self.clibrary = SimpleNamespace() + self.clibrary.cflags = [f"$(PACKAGE_CFLAGS_{package})"] + self.clibrary.ldflags = [f"$(PACKAGE_LDFLAGS_{package})"] + + self.ins = [] + self.outs = [f"$(PACKAGE_DEP_{package})"] diff --git a/build/protobuf.py b/build/protobuf.py new file mode 100644 index 00000000..8dc7337b --- /dev/null +++ b/build/protobuf.py @@ -0,0 +1,65 @@ +from os.path import join +from build.ab import Rule, Targets, emit, normalrule, filenamesof, flatten +from build.c import cxxlibrary +import build.pkg +from types import SimpleNamespace + +emit( + """ +PROTOC ?= protoc +ifeq ($(filter protobuf, $(PACKAGES)),) +$(error Required package 'protobuf' not installed.)" +endif +""" +) + + +@Rule +def proto(self, name, srcs: Targets = [], deps: Targets = []): + normalrule( + replaces=self, + ins=srcs, + outs=[f"{name}.descriptor"], + deps=deps, + commands=[ + "$(PROTOC) --include_source_info --descriptor_set_out={outs[0]} {ins}" + ], + label="PROTO", + ) + self.proto.srcs = filenamesof(srcs) + flatten( + [s.proto.srcs for s in flatten(deps)] + ) + + +@Rule +def protocc(self, name, srcs: Targets = [], deps: Targets = []): + outs = [] + protos = [] + for f in flatten([s.proto.srcs for s in flatten(srcs + deps)]): + if f.endswith(".proto"): + cc = f.replace(".proto", ".pb.cc") + h = f.replace(".proto", ".pb.h") + protos += [f] + srcs += [f] + outs += [cc, h] + + r = normalrule( + name=f"{name}_srcs", + ins=protos, + outs=outs, + deps=deps, + commands=["$(PROTOC) --cpp_out={self.normalrule.objdir} {ins}"], + label="PROTOCC", + ) + + r.materialise() + headers = { + f: join(r.normalrule.objdir, f) for f in outs if f.endswith(".pb.h") + } + + cxxlibrary( + replaces=self, + srcs=[f"{name}_srcs"], + hdrs=headers, + cflags=[f"-I{r.normalrule.objdir}"], + ) diff --git a/build/utils.py b/build/utils.py new file mode 100644 index 00000000..e1a227aa --- /dev/null +++ b/build/utils.py @@ -0,0 +1,43 @@ +from build.ab import Rule, normalrule, Target, filenameof, Targets +from os.path import basename + + +@Rule +def objectify(self, name, src: Target, symbol): + normalrule( + replaces=self, + ins=["build/_objectify.py", src], + outs=[basename(filenameof(src)) + ".h"], + commands=["$(PYTHON) {ins[0]} {ins[1]} " + symbol + " > {outs}"], + label="OBJECTIFY", + ) + + +@Rule +def test( + self, + name, + command: Target = None, + commands=None, + ins: Targets = [], + deps: Targets = [], + label="TEST", +): + if command: + normalrule( + replaces=self, + ins=[command], + outs=["sentinel"], + commands=["{ins[0]}", "touch {outs}"], + deps=deps, + label=label, + ) + else: + normalrule( + replaces=self, + ins=ins, + outs=["sentinel"], + commands=commands + ["touch {outs}"], + deps=deps, + label=label, + ) diff --git a/config.py b/config.py new file mode 100644 index 00000000..08073692 --- /dev/null +++ b/config.py @@ -0,0 +1,5 @@ +import platform + +windows = platform.system() == "Windows" +osx = platform.system() == "Darwin" +unix = not windows diff --git a/dep/adflib/build.mk b/dep/adflib/build.mk deleted file mode 100644 index 8ccff26e..00000000 --- a/dep/adflib/build.mk +++ /dev/null @@ -1,22 +0,0 @@ -ADFLIB_SRCS = \ - dep/adflib/src/adf_bitm.c \ - dep/adflib/src/adf_cache.c \ - dep/adflib/src/adf_dir.c \ - dep/adflib/src/adf_disk.c \ - dep/adflib/src/adf_dump.c \ - dep/adflib/src/adf_env.c \ - dep/adflib/src/adf_file.c \ - dep/adflib/src/adf_hd.c \ - dep/adflib/src/adf_link.c \ - dep/adflib/src/adf_raw.c \ - dep/adflib/src/adf_salv.c \ - dep/adflib/src/adf_util.c \ - -ADFLIB_OBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(ADFLIB_SRCS)) -$(ADFLIB_OBJS): CFLAGS += -Idep/adflib/src -Idep/adflib -ADFLIB_LIB = $(OBJDIR)/libadflib.a -$(ADFLIB_LIB): $(ADFLIB_OBJS) -ADFLIB_CFLAGS = -Idep/adflib/src -ADFLIB_LDFLAGS = -OBJS += $(ADFLIB_OBJS) - diff --git a/dep/adflib/build.py b/dep/adflib/build.py new file mode 100644 index 00000000..9b93510e --- /dev/null +++ b/dep/adflib/build.py @@ -0,0 +1,47 @@ +from build.c import clibrary + +clibrary( + name="adflib", + srcs=[ + "./src/adf_bitm.c", + "./src/adf_bitm.h", + "./src/adf_cache.c", + "./src/adf_cache.h", + "./src/adf_dir.c", + "./src/adf_dir.h", + "./src/adf_disk.c", + "./src/adf_disk.h", + "./src/adf_dump.c", + "./src/adf_dump.h", + "./src/adf_env.c", + "./src/adf_env.h", + "./src/adf_file.c", + "./src/adf_file.h", + "./src/adf_hd.c", + "./src/adf_hd.h", + "./src/adf_link.c", + "./src/adf_link.h", + "./src/adf_raw.c", + "./src/adf_raw.h", + "./src/adf_salv.c", + "./src/adf_salv.h", + "./src/adf_str.h", + "./src/adf_util.c", + "./src/adf_util.h", + "./src/defendian.h", + "./src/hd_blk.h", + "./src/prefix.h", + "./adf_nativ.h", + "./config.h", + "./src/adflib.h", + ], + cflags=["-Idep/adflib", "-Idep/adflib/src"], + hdrs={ + "adf_blk.h": "./src/adf_blk.h", + "adf_defs.h": "./src/adf_defs.h", + "adf_err.h": "./src/adf_err.h", + "adf_nativ.h": "./adf_nativ.h", + "adf_str.h": "./src/adf_str.h", + "adflib.h": "./src/adflib.h", + }, +) diff --git a/dep/agg/build.mk b/dep/agg/build.mk deleted file mode 100644 index 82b004a3..00000000 --- a/dep/agg/build.mk +++ /dev/null @@ -1,38 +0,0 @@ -AGG_SRCS = \ - dep/agg/src/agg_arrowhead.cpp \ - dep/agg/src/agg_line_aa_basics.cpp \ - dep/agg/src/agg_vcgen_bspline.cpp \ - dep/agg/src/agg_vpgen_segmentator.cpp \ - dep/agg/src/agg_color_rgba.cpp \ - dep/agg/src/agg_sqrt_tables.cpp \ - dep/agg/src/agg_bspline.cpp \ - dep/agg/src/agg_curves.cpp \ - dep/agg/src/agg_rounded_rect.cpp \ - dep/agg/src/agg_vcgen_markers_term.cpp \ - dep/agg/src/agg_vcgen_dash.cpp \ - dep/agg/src/agg2d.cpp \ - dep/agg/src/agg_trans_affine.cpp \ - dep/agg/src/agg_gsv_text.cpp \ - dep/agg/src/agg_vcgen_smooth_poly1.cpp \ - dep/agg/src/agg_trans_single_path.cpp \ - dep/agg/src/agg_vpgen_clip_polygon.cpp \ - dep/agg/src/agg_embedded_raster_fonts.cpp \ - dep/agg/src/agg_trans_double_path.cpp \ - dep/agg/src/agg_vcgen_stroke.cpp \ - dep/agg/src/agg_arc.cpp \ - dep/agg/src/agg_image_filters.cpp \ - dep/agg/src/agg_trans_warp_magnifier.cpp \ - dep/agg/src/agg_vpgen_clip_polyline.cpp \ - dep/agg/src/agg_bezier_arc.cpp \ - dep/agg/src/agg_line_profile_aa.cpp \ - dep/agg/src/agg_vcgen_contour.cpp \ - -AGG_OBJS = $(patsubst %.cpp, $(OBJDIR)/%.o, $(AGG_SRCS)) -AGG_LIB = $(OBJDIR)/libagg.a -$(AGG_LIB): $(AGG_OBJS) -AGG_LDFLAGS = $(AGG_LIB) -AGG_CFLAGS = -Idep/agg/include -OBJS += $(AGG_OBJS) - -$(AGG_OBJS): CFLAGS += $(AGG_CFLAGS) - diff --git a/dep/agg/build.py b/dep/agg/build.py new file mode 100644 index 00000000..67387558 --- /dev/null +++ b/dep/agg/build.py @@ -0,0 +1,164 @@ +from build.c import cxxlibrary + +cxxlibrary( + name="agg", + srcs=[ + "./src/agg_arrowhead.cpp", + "./src/agg_line_aa_basics.cpp", + "./src/agg_vcgen_bspline.cpp", + "./src/agg_vpgen_segmentator.cpp", + "./src/agg_color_rgba.cpp", + "./src/agg_sqrt_tables.cpp", + "./src/agg_bspline.cpp", + "./src/agg_curves.cpp", + "./src/agg_rounded_rect.cpp", + "./src/agg_vcgen_markers_term.cpp", + "./src/agg_vcgen_dash.cpp", + "./src/agg2d.cpp", + "./src/agg_trans_affine.cpp", + "./src/agg_gsv_text.cpp", + "./src/agg_vcgen_smooth_poly1.cpp", + "./src/agg_trans_single_path.cpp", + "./src/agg_vpgen_clip_polygon.cpp", + "./src/agg_embedded_raster_fonts.cpp", + "./src/agg_trans_double_path.cpp", + "./src/agg_vcgen_stroke.cpp", + "./src/agg_arc.cpp", + "./src/agg_image_filters.cpp", + "./src/agg_trans_warp_magnifier.cpp", + "./src/agg_vpgen_clip_polyline.cpp", + "./src/agg_bezier_arc.cpp", + "./src/agg_line_profile_aa.cpp", + "./src/agg_vcgen_contour.cpp", + ], + hdrs={ + "agg2d.h": "./include/agg2d.h", + "agg_alpha_mask_u8.h": "./include/agg_alpha_mask_u8.h", + "agg_arc.h": "./include/agg_arc.h", + "agg_array.h": "./include/agg_array.h", + "agg_arrowhead.h": "./include/agg_arrowhead.h", + "agg_basics.h": "./include/agg_basics.h", + "agg_bezier_arc.h": "./include/agg_bezier_arc.h", + "agg_bitset_iterator.h": "./include/agg_bitset_iterator.h", + "agg_blur.h": "./include/agg_blur.h", + "agg_bounding_rect.h": "./include/agg_bounding_rect.h", + "agg_bspline.h": "./include/agg_bspline.h", + "agg_clip_liang_barsky.h": "./include/agg_clip_liang_barsky.h", + "agg_color_gray.h": "./include/agg_color_gray.h", + "agg_color_rgba.h": "./include/agg_color_rgba.h", + "agg_config.h": "./include/agg_config.h", + "agg_conv_adaptor_vcgen.h": "./include/agg_conv_adaptor_vcgen.h", + "agg_conv_adaptor_vpgen.h": "./include/agg_conv_adaptor_vpgen.h", + "agg_conv_bspline.h": "./include/agg_conv_bspline.h", + "agg_conv_clip_polygon.h": "./include/agg_conv_clip_polygon.h", + "agg_conv_clip_polyline.h": "./include/agg_conv_clip_polyline.h", + "agg_conv_close_polygon.h": "./include/agg_conv_close_polygon.h", + "agg_conv_concat.h": "./include/agg_conv_concat.h", + "agg_conv_contour.h": "./include/agg_conv_contour.h", + "agg_conv_curve.h": "./include/agg_conv_curve.h", + "agg_conv_dash.h": "./include/agg_conv_dash.h", + "agg_conv_gpc.h": "./include/agg_conv_gpc.h", + "agg_conv_marker_adaptor.h": "./include/agg_conv_marker_adaptor.h", + "agg_conv_marker.h": "./include/agg_conv_marker.h", + "agg_conv_segmentator.h": "./include/agg_conv_segmentator.h", + "agg_conv_shorten_path.h": "./include/agg_conv_shorten_path.h", + "agg_conv_smooth_poly1.h": "./include/agg_conv_smooth_poly1.h", + "agg_conv_stroke.h": "./include/agg_conv_stroke.h", + "agg_conv_transform.h": "./include/agg_conv_transform.h", + "agg_conv_unclose_polygon.h": "./include/agg_conv_unclose_polygon.h", + "agg_curves.h": "./include/agg_curves.h", + "agg_dda_line.h": "./include/agg_dda_line.h", + "agg_ellipse_bresenham.h": "./include/agg_ellipse_bresenham.h", + "agg_ellipse.h": "./include/agg_ellipse.h", + "agg_embedded_raster_fonts.h": "./include/agg_embedded_raster_fonts.h", + "agg_font_cache_manager2.h": "./include/agg_font_cache_manager2.h", + "agg_font_cache_manager.h": "./include/agg_font_cache_manager.h", + "agg_gamma_functions.h": "./include/agg_gamma_functions.h", + "agg_gamma_lut.h": "./include/agg_gamma_lut.h", + "agg_glyph_raster_bin.h": "./include/agg_glyph_raster_bin.h", + "agg_gradient_lut.h": "./include/agg_gradient_lut.h", + "agg_gsv_text.h": "./include/agg_gsv_text.h", + "agg_image_accessors.h": "./include/agg_image_accessors.h", + "agg_image_filters.h": "./include/agg_image_filters.h", + "agg_line_aa_basics.h": "./include/agg_line_aa_basics.h", + "agg_math.h": "./include/agg_math.h", + "agg_math_stroke.h": "./include/agg_math_stroke.h", + "agg_path_length.h": "./include/agg_path_length.h", + "agg_path_storage.h": "./include/agg_path_storage.h", + "agg_path_storage_integer.h": "./include/agg_path_storage_integer.h", + "agg_pattern_filters_rgba.h": "./include/agg_pattern_filters_rgba.h", + "agg_pixfmt_amask_adaptor.h": "./include/agg_pixfmt_amask_adaptor.h", + "agg_pixfmt_base.h": "./include/agg_pixfmt_base.h", + "agg_pixfmt_gray.h": "./include/agg_pixfmt_gray.h", + "agg_pixfmt_rgba.h": "./include/agg_pixfmt_rgba.h", + "agg_pixfmt_rgb.h": "./include/agg_pixfmt_rgb.h", + "agg_pixfmt_rgb_packed.h": "./include/agg_pixfmt_rgb_packed.h", + "agg_pixfmt_transposer.h": "./include/agg_pixfmt_transposer.h", + "agg_rasterizer_cells_aa.h": "./include/agg_rasterizer_cells_aa.h", + "agg_rasterizer_compound_aa.h": "./include/agg_rasterizer_compound_aa.h", + "agg_rasterizer_outline_aa.h": "./include/agg_rasterizer_outline_aa.h", + "agg_rasterizer_outline.h": "./include/agg_rasterizer_outline.h", + "agg_rasterizer_scanline_aa.h": "./include/agg_rasterizer_scanline_aa.h", + "agg_rasterizer_scanline_aa_nogamma.h": "./include/agg_rasterizer_scanline_aa_nogamma.h", + "agg_rasterizer_sl_clip.h": "./include/agg_rasterizer_sl_clip.h", + "agg_renderer_base.h": "./include/agg_renderer_base.h", + "agg_renderer_markers.h": "./include/agg_renderer_markers.h", + "agg_renderer_mclip.h": "./include/agg_renderer_mclip.h", + "agg_renderer_outline_aa.h": "./include/agg_renderer_outline_aa.h", + "agg_renderer_outline_image.h": "./include/agg_renderer_outline_image.h", + "agg_renderer_primitives.h": "./include/agg_renderer_primitives.h", + "agg_renderer_raster_text.h": "./include/agg_renderer_raster_text.h", + "agg_renderer_scanline.h": "./include/agg_renderer_scanline.h", + "agg_rendering_buffer_dynarow.h": "./include/agg_rendering_buffer_dynarow.h", + "agg_rendering_buffer.h": "./include/agg_rendering_buffer.h", + "agg_rounded_rect.h": "./include/agg_rounded_rect.h", + "agg_scanline_bin.h": "./include/agg_scanline_bin.h", + "agg_scanline_boolean_algebra.h": "./include/agg_scanline_boolean_algebra.h", + "agg_scanline_p.h": "./include/agg_scanline_p.h", + "agg_scanline_storage_aa.h": "./include/agg_scanline_storage_aa.h", + "agg_scanline_storage_bin.h": "./include/agg_scanline_storage_bin.h", + "agg_scanline_u.h": "./include/agg_scanline_u.h", + "agg_shorten_path.h": "./include/agg_shorten_path.h", + "agg_simul_eq.h": "./include/agg_simul_eq.h", + "agg_span_allocator.h": "./include/agg_span_allocator.h", + "agg_span_converter.h": "./include/agg_span_converter.h", + "agg_span_gouraud_gray.h": "./include/agg_span_gouraud_gray.h", + "agg_span_gouraud.h": "./include/agg_span_gouraud.h", + "agg_span_gouraud_rgba.h": "./include/agg_span_gouraud_rgba.h", + "agg_span_gradient_alpha.h": "./include/agg_span_gradient_alpha.h", + "agg_span_gradient_contour.h": "./include/agg_span_gradient_contour.h", + "agg_span_gradient.h": "./include/agg_span_gradient.h", + "agg_span_gradient_image.h": "./include/agg_span_gradient_image.h", + "agg_span_image_filter_gray.h": "./include/agg_span_image_filter_gray.h", + "agg_span_image_filter.h": "./include/agg_span_image_filter.h", + "agg_span_image_filter_rgba.h": "./include/agg_span_image_filter_rgba.h", + "agg_span_image_filter_rgb.h": "./include/agg_span_image_filter_rgb.h", + "agg_span_interpolator_adaptor.h": "./include/agg_span_interpolator_adaptor.h", + "agg_span_interpolator_linear.h": "./include/agg_span_interpolator_linear.h", + "agg_span_interpolator_persp.h": "./include/agg_span_interpolator_persp.h", + "agg_span_interpolator_trans.h": "./include/agg_span_interpolator_trans.h", + "agg_span_pattern_gray.h": "./include/agg_span_pattern_gray.h", + "agg_span_pattern_rgba.h": "./include/agg_span_pattern_rgba.h", + "agg_span_pattern_rgb.h": "./include/agg_span_pattern_rgb.h", + "agg_span_solid.h": "./include/agg_span_solid.h", + "agg_span_subdiv_adaptor.h": "./include/agg_span_subdiv_adaptor.h", + "agg_trans_affine.h": "./include/agg_trans_affine.h", + "agg_trans_bilinear.h": "./include/agg_trans_bilinear.h", + "agg_trans_double_path.h": "./include/agg_trans_double_path.h", + "agg_trans_perspective.h": "./include/agg_trans_perspective.h", + "agg_trans_single_path.h": "./include/agg_trans_single_path.h", + "agg_trans_viewport.h": "./include/agg_trans_viewport.h", + "agg_trans_warp_magnifier.h": "./include/agg_trans_warp_magnifier.h", + "agg_vcgen_bspline.h": "./include/agg_vcgen_bspline.h", + "agg_vcgen_contour.h": "./include/agg_vcgen_contour.h", + "agg_vcgen_dash.h": "./include/agg_vcgen_dash.h", + "agg_vcgen_markers_term.h": "./include/agg_vcgen_markers_term.h", + "agg_vcgen_smooth_poly1.h": "./include/agg_vcgen_smooth_poly1.h", + "agg_vcgen_stroke.h": "./include/agg_vcgen_stroke.h", + "agg_vcgen_vertex_sequence.h": "./include/agg_vcgen_vertex_sequence.h", + "agg_vertex_sequence.h": "./include/agg_vertex_sequence.h", + "agg_vpgen_clip_polygon.h": "./include/agg_vpgen_clip_polygon.h", + "agg_vpgen_clip_polyline.h": "./include/agg_vpgen_clip_polyline.h", + "agg_vpgen_segmentator.h": "./include/agg_vpgen_segmentator.h", + }, +) diff --git a/dep/emu/build.mk b/dep/emu/build.mk deleted file mode 100644 index ba0f7edc..00000000 --- a/dep/emu/build.mk +++ /dev/null @@ -1,21 +0,0 @@ -ifeq ($(OS), Windows_NT) - -EMU_SRCS = \ - dep/emu/fnmatch.c - -EMU_OBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(EMU_SRCS)) -$(EMU_OBJS): CFLAGS += -Idep/emu -EMU_LIB = $(OBJDIR)/libemu.a -$(EMU_LIB): $(EMU_OBJS) -EMU_CFLAGS = -Idep/emu -EMU_LDFLAGS = $(EMU_LIB) -OBJS += $(EMU_OBJS) - -else - -EMU_LIB = -EMU_CFLAGS = -EMU_LDFLAGS = - -endif - diff --git a/dep/emu/build.py b/dep/emu/build.py new file mode 100644 index 00000000..a18f4db6 --- /dev/null +++ b/dep/emu/build.py @@ -0,0 +1,3 @@ +from build.c import clibrary + +clibrary(name="emu", srcs=["./fnmatch.c"], hdrs={"fnmatch.h": "./fnmatch.h"}) diff --git a/dep/fatfs/build.mk b/dep/fatfs/build.mk deleted file mode 100644 index c81a7df0..00000000 --- a/dep/fatfs/build.mk +++ /dev/null @@ -1,13 +0,0 @@ -FATFS_SRCS = \ - dep/fatfs/source/ff.c \ - dep/fatfs/source/ffsystem.c \ - dep/fatfs/source/ffunicode.c \ - -FATFS_OBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(FATFS_SRCS)) -$(FATFS_OBJS): CFLAGS += -Idep/fatfs/source -FATFS_LIB = $(OBJDIR)/libfatfs.a -$(FATFS_LIB): $(FATFS_OBJS) -FATFS_CFLAGS = -Idep/fatfs/source -FATFS_LDFLAGS = -OBJS += $(FATFS_OBJS) - diff --git a/dep/fatfs/build.py b/dep/fatfs/build.py new file mode 100644 index 00000000..31a74596 --- /dev/null +++ b/dep/fatfs/build.py @@ -0,0 +1,18 @@ +from build.c import clibrary + +clibrary( + name="fatfs", + srcs=[ + "./source/ff.c", + "./source/ffsystem.c", + "./source/ffunicode.c", + "./source/ff.h", + "./source/ffconf.h", + "./source/diskio.h", + ], + hdrs={ + "ff.h": "./source/ff.h", + "ffconf.h": "./source/ffconf.h", + "diskio.h": "./source/diskio.h", + }, +) diff --git a/dep/hfsutils/build.mk b/dep/hfsutils/build.mk deleted file mode 100644 index 2ffd727e..00000000 --- a/dep/hfsutils/build.mk +++ /dev/null @@ -1,22 +0,0 @@ -HFSUTILS_SRCS = \ - dep/hfsutils/libhfs/block.c \ - dep/hfsutils/libhfs/btree.c \ - dep/hfsutils/libhfs/data.c \ - dep/hfsutils/libhfs/file.c \ - dep/hfsutils/libhfs/hfs.c \ - dep/hfsutils/libhfs/low.c \ - dep/hfsutils/libhfs/medium.c \ - dep/hfsutils/libhfs/memcmp.c \ - dep/hfsutils/libhfs/node.c \ - dep/hfsutils/libhfs/record.c \ - dep/hfsutils/libhfs/version.c \ - dep/hfsutils/libhfs/volume.c \ - -HFSUTILS_OBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(HFSUTILS_SRCS)) -$(HFSUTILS_OBJS): CFLAGS += -Idep/hfsutils/libhfs -HFSUTILS_LIB = $(OBJDIR)/libhfsutils.a -$(HFSUTILS_LIB): $(HFSUTILS_OBJS) -HFSUTILS_CFLAGS = -Idep/hfsutils/libhfs -HFSUTILS_LDFLAGS = -OBJS += $(HFSUTILS_OBJS) - diff --git a/dep/hfsutils/build.py b/dep/hfsutils/build.py new file mode 100644 index 00000000..b040ffe1 --- /dev/null +++ b/dep/hfsutils/build.py @@ -0,0 +1,25 @@ +from build.c import clibrary + +clibrary( + name="hfsutils", + srcs=[ + "./libhfs/block.c", + "./libhfs/btree.c", + "./libhfs/data.c", + "./libhfs/file.c", + "./libhfs/hfs.c", + "./libhfs/low.c", + "./libhfs/medium.c", + "./libhfs/memcmp.c", + "./libhfs/node.c", + "./libhfs/record.c", + "./libhfs/version.c", + "./libhfs/volume.c", + ], + hdrs={ + "apple.h": "./libhfs/apple.h", + "hfs.h": "./libhfs/hfs.h", + "libhfs.h": "./libhfs/libhfs.h", + "os.h": "./libhfs/os.h", + }, +) diff --git a/dep/libusbp/build.mk b/dep/libusbp/build.mk deleted file mode 100644 index ee09b84f..00000000 --- a/dep/libusbp/build.mk +++ /dev/null @@ -1,66 +0,0 @@ -LIBUSBP_SRCS = \ - dep/libusbp/src/async_in_pipe.c \ - dep/libusbp/src/error.c \ - dep/libusbp/src/error_hresult.c \ - dep/libusbp/src/find_device.c \ - dep/libusbp/src/list.c \ - dep/libusbp/src/pipe_id.c \ - dep/libusbp/src/string.c \ - -ifeq ($(OS), Windows_NT) - -LIBUSBP_LDFLAGS += -lsetupapi -lwinusb -lole32 -luuid -LIBUSBP_SRCS += \ - dep/libusbp/src/windows/async_in_transfer_windows.c \ - dep/libusbp/src/windows/device_instance_id_windows.c \ - dep/libusbp/src/windows/device_windows.c \ - dep/libusbp/src/windows/error_windows.c \ - dep/libusbp/src/windows/generic_handle_windows.c \ - dep/libusbp/src/windows/generic_interface_windows.c \ - dep/libusbp/src/windows/interface_windows.c \ - dep/libusbp/src/windows/list_windows.c \ - dep/libusbp/src/windows/serial_port_windows.c \ - -else ifeq ($(shell uname),Darwin) - -LIBUSBP_SRCS += \ - dep/libusbp/src/mac/async_in_transfer_mac.c \ - dep/libusbp/src/mac/device_mac.c \ - dep/libusbp/src/mac/error_mac.c \ - dep/libusbp/src/mac/generic_handle_mac.c \ - dep/libusbp/src/mac/generic_interface_mac.c \ - dep/libusbp/src/mac/iokit_mac.c \ - dep/libusbp/src/mac/list_mac.c \ - dep/libusbp/src/mac/serial_port_mac.c \ - -else ifeq ($(shell uname),Linux) - -LIBUSBP_CFLAGS += $(shell pkg-config --cflags libudev) -LIBUSBP_LDFLAGS += $(shell pkg-config --libs libudev) -LIBUSBP_SRCS += \ - dep/libusbp/src/linux/async_in_transfer_linux.c \ - dep/libusbp/src/linux/device_linux.c \ - dep/libusbp/src/linux/error_linux.c \ - dep/libusbp/src/linux/generic_handle_linux.c \ - dep/libusbp/src/linux/generic_interface_linux.c \ - dep/libusbp/src/linux/list_linux.c \ - dep/libusbp/src/linux/serial_port_linux.c \ - dep/libusbp/src/linux/udev_linux.c \ - dep/libusbp/src/linux/usbfd_linux.c \ - -else - -LIBUSBP_SRCS += \ - dep/libusbp/src/dummy.c - -endif - -LIBUSBP_OBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(LIBUSBP_SRCS)) -$(LIBUSBP_OBJS): private CFLAGS += -Idep/libusbp/src -Idep/libusbp/include -LIBUSBP_LIB = $(OBJDIR)/libusbp.a -LIBUSBP_CFLAGS += -Idep/libusbp/include -LIBUSBP_LDFLAGS += -$(LIBUSBP_LIB): $(LIBUSBP_OBJS) -OBJS += $(LIBUSBP_OBJS) - - diff --git a/dep/libusbp/build.py b/dep/libusbp/build.py new file mode 100644 index 00000000..2fe67486 --- /dev/null +++ b/dep/libusbp/build.py @@ -0,0 +1,72 @@ +from build.ab import emit +from build.c import clibrary +from build.pkg import package +from config import windows, osx, unix + +srcs = [ + "./src/async_in_pipe.c", + "./src/error.c", + "./src/error_hresult.c", + "./src/find_device.c", + "./src/list.c", + "./src/pipe_id.c", + "./src/string.c", + "./src/libusbp_internal.h", + "./include/libusbp_config.h", + "./include/libusbp.h", +] +deps = [] +ldflags = [] + +if windows: + srcs += [ + "./src/windows/async_in_transfer_windows.c", + "./src/windows/device_instance_id_windows.c", + "./src/windows/device_windows.c", + "./src/windows/error_windows.c", + "./src/windows/generic_handle_windows.c", + "./src/windows/generic_interface_windows.c", + "./src/windows/interface_windows.c", + "./src/windows/list_windows.c", + "./src/windows/serial_port_windows.c", + ] + ldflags += ["-lsetupapi", "-lwinusb", "-lole32", "-luuid"] +elif osx: + srcs += [ + "./src/mac/async_in_transfer_mac.c", + "./src/mac/device_mac.c", + "./src/mac/error_mac.c", + "./src/mac/generic_handle_mac.c", + "./src/mac/generic_interface_mac.c", + "./src/mac/iokit_mac.c", + "./src/mac/list_mac.c", + "./src/mac/serial_port_mac.c", + ] +else: + package(name="udev_lib", package="libudev") + srcs += [ + "./src/linux/async_in_transfer_linux.c", + "./src/linux/device_linux.c", + "./src/linux/error_linux.c", + "./src/linux/generic_handle_linux.c", + "./src/linux/generic_interface_linux.c", + "./src/linux/list_linux.c", + "./src/linux/serial_port_linux.c", + "./src/linux/udev_linux.c", + "./src/linux/usbfd_linux.c", + ] + deps += [".+udev_lib"] + +clibrary( + name="libusbp", + srcs=srcs, + cflags=["-Idep/libusbp/include", "-Idep/libusbp/src"], + ldflags=ldflags, + deps=deps, + hdrs={ + "libusbp_internal.h": "./src/libusbp_internal.h", + "libusbp_config.h": "./include/libusbp_config.h", + "libusbp.hpp": "./include/libusbp.hpp", + "libusbp.h": "./include/libusbp.h", + }, +) diff --git a/dep/snowhouse/build.py b/dep/snowhouse/build.py new file mode 100644 index 00000000..bc36f53d --- /dev/null +++ b/dep/snowhouse/build.py @@ -0,0 +1,49 @@ +from build.c import cxxlibrary + +cxxlibrary( + name="snowhouse", + hdrs={ + "snowhouse/snowhouse.h": "./include/snowhouse/snowhouse.h", + "snowhouse/assert.h": "./include/snowhouse/assert.h", + "snowhouse/fluent/fluent.h": "./include/snowhouse/fluent/fluent.h", + "snowhouse/fluent/constraintadapter.h": "./include/snowhouse/fluent/constraintadapter.h", + "snowhouse/fluent/constraintlist.h": "./include/snowhouse/fluent/constraintlist.h", + "snowhouse/fluent/operators/andoperator.h": "./include/snowhouse/fluent/operators/andoperator.h", + "snowhouse/fluent/operators/invalidexpressionexception.h": "./include/snowhouse/fluent/operators/invalidexpressionexception.h", + "snowhouse/fluent/operators/collections/collectionoperator.h": "./include/snowhouse/fluent/operators/collections/collectionoperator.h", + "snowhouse/fluent/operators/collections/collectionconstraintevaluator.h": "./include/snowhouse/fluent/operators/collections/collectionconstraintevaluator.h", + "snowhouse/fluent/operators/collections/atleastoperator.h": "./include/snowhouse/fluent/operators/collections/atleastoperator.h", + "snowhouse/fluent/operators/collections/noneoperator.h": "./include/snowhouse/fluent/operators/collections/noneoperator.h", + "snowhouse/fluent/operators/collections/atmostoperator.h": "./include/snowhouse/fluent/operators/collections/atmostoperator.h", + "snowhouse/fluent/operators/collections/alloperator.h": "./include/snowhouse/fluent/operators/collections/alloperator.h", + "snowhouse/fluent/operators/collections/exactlyoperator.h": "./include/snowhouse/fluent/operators/collections/exactlyoperator.h", + "snowhouse/fluent/operators/notoperator.h": "./include/snowhouse/fluent/operators/notoperator.h", + "snowhouse/fluent/operators/constraintoperator.h": "./include/snowhouse/fluent/operators/constraintoperator.h", + "snowhouse/fluent/operators/oroperator.h": "./include/snowhouse/fluent/operators/oroperator.h", + "snowhouse/fluent/expressionbuilder.h": "./include/snowhouse/fluent/expressionbuilder.h", + "snowhouse/assertionexception.h": "./include/snowhouse/assertionexception.h", + "snowhouse/exceptions.h": "./include/snowhouse/exceptions.h", + "snowhouse/stringizers.h": "./include/snowhouse/stringizers.h", + "snowhouse/macros.h": "./include/snowhouse/macros.h", + "snowhouse/constraints/equalscontainerconstraint.h": "./include/snowhouse/constraints/equalscontainerconstraint.h", + "snowhouse/constraints/islessthanorequaltoconstraint.h": "./include/snowhouse/constraints/islessthanorequaltoconstraint.h", + "snowhouse/constraints/equalsconstraint.h": "./include/snowhouse/constraints/equalsconstraint.h", + "snowhouse/constraints/isgreaterthanconstraint.h": "./include/snowhouse/constraints/isgreaterthanconstraint.h", + "snowhouse/constraints/fulfillsconstraint.h": "./include/snowhouse/constraints/fulfillsconstraint.h", + "snowhouse/constraints/endswithconstraint.h": "./include/snowhouse/constraints/endswithconstraint.h", + "snowhouse/constraints/constraints.h": "./include/snowhouse/constraints/constraints.h", + "snowhouse/constraints/haslengthconstraint.h": "./include/snowhouse/constraints/haslengthconstraint.h", + "snowhouse/constraints/startswithconstraint.h": "./include/snowhouse/constraints/startswithconstraint.h", + "snowhouse/constraints/equalswithdeltaconstraint.h": "./include/snowhouse/constraints/equalswithdeltaconstraint.h", + "snowhouse/constraints/isgreaterthanorequaltoconstraint.h": "./include/snowhouse/constraints/isgreaterthanorequaltoconstraint.h", + "snowhouse/constraints/containsconstraint.h": "./include/snowhouse/constraints/containsconstraint.h", + "snowhouse/constraints/islessthanconstraint.h": "./include/snowhouse/constraints/islessthanconstraint.h", + "snowhouse/constraints/isemptyconstraint.h": "./include/snowhouse/constraints/isemptyconstraint.h", + "snowhouse/constraints/expressions/andexpression.h": "./include/snowhouse/constraints/expressions/andexpression.h", + "snowhouse/constraints/expressions/orexpression.h": "./include/snowhouse/constraints/expressions/orexpression.h", + "snowhouse/constraints/expressions/expression_fwd.h": "./include/snowhouse/constraints/expressions/expression_fwd.h", + "snowhouse/constraints/expressions/notexpression.h": "./include/snowhouse/constraints/expressions/notexpression.h", + "snowhouse/constraints/expressions/expression.h": "./include/snowhouse/constraints/expressions/expression.h", + "snowhouse/stringize.h": "./include/snowhouse/stringize.h", + }, +) diff --git a/dep/stb/build.mk b/dep/stb/build.mk deleted file mode 100644 index 1a7378ac..00000000 --- a/dep/stb/build.mk +++ /dev/null @@ -1,23 +0,0 @@ -ifeq ($(shell $(PKG_CONFIG) stb; echo $$?), 0) - -# System libstb present. - -STB_LIB = -STB_CFLAGS := $(shell $(PKG_CONFIG) --cflags stb) -STB_LDFLAGS := $(shell $(PKG_CONFIG) --libs stb) - -else - -STB_SRCS = \ - dep/stb/stb_image_write.c - -STB_OBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(STB_SRCS)) -$(STB_OBJS): CFLAGS += -Idep/stb/src -STB_LIB = $(OBJDIR)/libstb.a -$(STB_LIB): $(STB_OBJS) -STB_CFLAGS = -STB_LDFLAGS = $(STB_LIB) -OBJS += $(STB_OBJS) - -endif - diff --git a/dep/stb/build.py b/dep/stb/build.py new file mode 100644 index 00000000..9ae15fab --- /dev/null +++ b/dep/stb/build.py @@ -0,0 +1,7 @@ +from build.c import clibrary + +clibrary( + name="stb", + srcs=["./stb_image_write.c"], + hdrs={"stb_image_write.h": "./stb_image_write.h"}, +) diff --git a/doc/building.md b/doc/building.md index 1002bcb1..643776d9 100644 --- a/doc/building.md +++ b/doc/building.md @@ -204,7 +204,7 @@ install some support packages. - For Linux with Ubuntu/Debian: `libusb-1.0-0-dev`, `libsqlite3-dev`, `zlib1g-dev`, `libudev-dev`, `protobuf-compiler`, `libwxgtk3.0-gtk3-dev`, - `libfmt-dev`. + `libfmt-dev`, `python3`. - For Linux with Fedora/Red Hat: `git`, `make`, `gcc`, `gcc-c++`, `xxd`, `protobuf-compiler`, `protobuf-devel`, `fmt-devel`, `systemd-devel`, `wxGTK3-devel`, @@ -214,7 +214,7 @@ install some support packages. - For Windows with MSYS2: `make`, `mingw-w64-i686-libusb`, `mingw-w64-i686-protobuf`, `mingw-w64-i686-sqlite3`, `mingw-w64-i686-zlib`, `mingw-w64-i686-gcc`, `vim`, `diffutils`, `mingw-w64-i686-wxWidgets`, - `mingw-w64-i686-fmt`, `mingw-w64-i686-pkg-config`. + `mingw-w64-i686-fmt`, `mingw-w64-i686-pkg-config`, `mingw-w64-i686-python`. These lists are not necessarily exhaustive --- please [get in touch](https://github.com/davidgiven/fluxengine/issues/new) if I've missed @@ -222,10 +222,16 @@ anything. Windows and Linux (and other Unixes) build by just doing `make`. OSX builds by doing `gmake` (we're using a feature which the elderly default make in OSX -doesn't have). You should end up with some executables in the current -directory, one of which is called `fluxengine` or `fluxengine.exe` depending on -your platform. It has minimal dependencies and you should be able to put it -anywhere. The other binaries may also be of interest. +doesn't have). Remember to add an appropriate `-j` option for a parallel build. +You should end up with some executables in the current directory, one of which +is called `fluxengine` or `fluxengine.exe` depending on your platform. It has +minimal dependencies and you should be able to put it anywhere. The other +binaries may also be of interest. + +Potential issues: + + - Complaints about a missing `libudev` on Windows? Make sure you're using the + mingw Python rather than the msys Python. If it doesn't build, please [get in touch](https://github.com/davidgiven/fluxengine/issues/new). diff --git a/doc/disk-ms2000.md b/doc/disk-ms2000.md new file mode 100644 index 00000000..71f144e9 --- /dev/null +++ b/doc/disk-ms2000.md @@ -0,0 +1,33 @@ +ms2000 +==== +## MS2000 Microdisk Development System + + +The RCA MicroDisk Development System MS2000 is a highly obscure (i.e. I gather +that single digit numbers of original machines exist) development system for the +RCA1802 series of CPUs, as made famous by the Cosmac ELF. It was a fairly +straightforward big bag o'RAM system with a 2kB boot ROM, 62kB of RAM, twin +floppy drives and a serial terminal --- CP/M users will find it very familiar. + +Read and writing disks is currently not supported by FluxEngine, but there is +basic support for the MicroDisk operating system's file system. This should +allow files to be read from MS2000 disk images. + +The disks are normal DD 3.5" disks, using a 70-track, single sided variation of +the venerable IBM floppy disk scheme, so allowing 315kB of storage per disk. + +If you have access to flux files for MS2000 disks, please [get in +touch](https://github.com/davidgiven/cpm65/issues/new) --- I would like to add +better support for these. + +## Options + +(no options) + +## Examples + +## References + + - [The EMMA-02 emulator](https://www.emma02.hobby-site.com/ms2000.html), which + supports the MS2000 and provides information on it. + diff --git a/extras/build.py b/extras/build.py new file mode 100644 index 00000000..a0728955 --- /dev/null +++ b/extras/build.py @@ -0,0 +1,44 @@ +from build.ab import normalrule, simplerule +from build.utils import objectify +from build.c import clibrary + +icons = ["fluxfile", "hardware", "icon", "imagefile"] + +clibrary( + name="icons", + hdrs={ + f"icons/{n}.h": objectify( + name=n + "_h", src=f"./{n}.png", symbol=f"icon_{n}_png" + ) + for n in icons + }, +) + +normalrule( + name="fluxengine_iconset", + ins=["./icon.png"], + outs=["fluxengine.iconset"], + commands=[ + "mkdir -p {outs[0]}", + "sips -z 64 64 {ins[0]} --out {outs[0]}/icon_32x32@2x.png > /dev/null", + ], + label="ICONSET", +) + +normalrule( + name="fluxengine_icns", + ins=[".+fluxengine_iconset"], + outs=["fluxengine.icns"], + commands=["iconutil -c icns -o {outs[0]} {ins[0]}"], + label="ICONUTIL", +) + +normalrule( + name="fluxengine_ico", + ins=["./icon.png"], + outs=["fluxengine.ico"], + commands=[ + "convert {ins[0]} -resize 64x46 -define icon:auto-resize=64,48,32,16 {outs[0]}" + ], + label="MAKEICON", +) diff --git a/lib/bitmap.cc b/lib/bitmap.cc index 7e0a2256..4c4a9919 100644 --- a/lib/bitmap.cc +++ b/lib/bitmap.cc @@ -1,9 +1,9 @@ -#include "globals.h" -#include "flags.h" -#include "dep/agg/include/agg2d.h" -#include "dep/stb/stb_image_write.h" -#include "utils.h" -#include "bitmap.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "agg2d.h" +#include "stb_image_write.h" +#include "lib/utils.h" +#include "lib/bitmap.h" #include #include diff --git a/lib/build.mk b/lib/build.mk deleted file mode 100644 index c8fc1c5f..00000000 --- a/lib/build.mk +++ /dev/null @@ -1,108 +0,0 @@ -LIBFLUXENGINE_SRCS = \ - lib/bitmap.cc \ - lib/bytes.cc \ - lib/config.cc \ - lib/crc.cc \ - lib/csvreader.cc \ - lib/decoders/decoders.cc \ - lib/decoders/fluxdecoder.cc \ - lib/decoders/fluxmapreader.cc \ - lib/decoders/fmmfm.cc \ - lib/encoders/encoders.cc \ - lib/fl2.cc \ - lib/flags.cc \ - lib/fluxmap.cc \ - lib/fluxsink/a2rfluxsink.cc \ - lib/fluxsink/aufluxsink.cc \ - lib/fluxsink/fl2fluxsink.cc \ - lib/fluxsink/fluxsink.cc \ - lib/fluxsink/hardwarefluxsink.cc \ - lib/fluxsink/scpfluxsink.cc \ - lib/fluxsink/vcdfluxsink.cc \ - lib/fluxsource/a2rfluxsource.cc \ - lib/fluxsource/cwffluxsource.cc \ - lib/fluxsource/erasefluxsource.cc \ - lib/fluxsource/fl2fluxsource.cc \ - lib/fluxsource/fluxsource.cc \ - lib/fluxsource/flx.cc \ - lib/fluxsource/flxfluxsource.cc \ - lib/fluxsource/hardwarefluxsource.cc \ - lib/fluxsource/kryoflux.cc \ - lib/fluxsource/kryofluxfluxsource.cc \ - lib/fluxsource/memoryfluxsource.cc \ - lib/fluxsource/scpfluxsource.cc \ - lib/fluxsource/testpatternfluxsource.cc \ - lib/globals.cc \ - lib/hexdump.cc \ - lib/image.cc \ - lib/imagereader/d64imagereader.cc \ - lib/imagereader/d88imagereader.cc \ - lib/imagereader/dimimagereader.cc \ - lib/imagereader/diskcopyimagereader.cc \ - lib/imagereader/fdiimagereader.cc \ - lib/imagereader/imagereader.cc \ - lib/imagereader/imdimagereader.cc \ - lib/imagereader/imgimagereader.cc \ - lib/imagereader/jv3imagereader.cc \ - lib/imagereader/nfdimagereader.cc \ - lib/imagereader/nsiimagereader.cc \ - lib/imagereader/td0imagereader.cc \ - lib/imagewriter/d64imagewriter.cc \ - lib/imagewriter/d88imagewriter.cc \ - lib/imagewriter/diskcopyimagewriter.cc \ - lib/imagewriter/imagewriter.cc \ - lib/imagewriter/imdimagewriter.cc \ - lib/imagewriter/imgimagewriter.cc \ - lib/imagewriter/ldbsimagewriter.cc \ - lib/imagewriter/nsiimagewriter.cc \ - lib/imagewriter/rawimagewriter.cc \ - lib/layout.cc \ - lib/ldbs.cc \ - lib/logger.cc \ - lib/proto.cc \ - lib/readerwriter.cc \ - lib/sector.cc \ - lib/usb/fluxengineusb.cc \ - lib/usb/greaseweazle.cc \ - lib/usb/greaseweazleusb.cc \ - lib/usb/serial.cc \ - lib/usb/usb.cc \ - lib/usb/usbfinder.cc \ - lib/utils.cc \ - lib/vfs/acorndfs.cc \ - lib/vfs/amigaffs.cc \ - lib/vfs/appledos.cc \ - lib/vfs/applesingle.cc \ - lib/vfs/brother120fs.cc \ - lib/vfs/cbmfs.cc \ - lib/vfs/cpmfs.cc \ - lib/vfs/fatfs.cc \ - lib/vfs/fluxsectorinterface.cc \ - lib/vfs/imagesectorinterface.cc \ - lib/vfs/lif.cc \ - lib/vfs/machfs.cc \ - lib/vfs/microdos.cc \ - lib/vfs/philefs.cc \ - lib/vfs/prodos.cc \ - lib/vfs/roland.cc \ - lib/vfs/smaky6fs.cc \ - lib/vfs/vfs.cc \ - lib/vfs/zdos.cc \ - -LIBFLUXENGINE_OBJS = $(patsubst %.cc, $(OBJDIR)/%.o, $(LIBFLUXENGINE_SRCS)) -OBJS += $(LIBFLUXENGINE_OBJS) -$(LIBFLUXENGINE_SRCS): | $(PROTO_HDRS) -LIBFLUXENGINE_LIB = $(OBJDIR)/libfluxengine.a -LIBFLUXENGINE_CFLAGS = -LIBFLUXENGINE_LDFLAGS = - -$(LIBFLUXENGINE_LIB): $(LIBFLUXENGINE_OBJS) - -$(LIBFLUXENGINE_OBJS): CFLAGS += $(LIBARCH_CFLAGS) -$(LIBFLUXENGINE_OBJS): CFLAGS += $(LIBUSBP_CFLAGS) -$(LIBFLUXENGINE_OBJS): CFLAGS += $(PROTO_CFLAGS) -$(LIBFLUXENGINE_OBJS): CFLAGS += $(FATFS_CFLAGS) -$(LIBFLUXENGINE_OBJS): CFLAGS += $(ADFLIB_CFLAGS) -$(LIBFLUXENGINE_OBJS): CFLAGS += $(HFSUTILS_CFLAGS) - -$(call use-pkgconfig, $(LIBFLUXENGINE_LIB), $(LIBFLUXENGINE_OBJS), fmt) diff --git a/lib/build.py b/lib/build.py new file mode 100644 index 00000000..7602d214 --- /dev/null +++ b/lib/build.py @@ -0,0 +1,25 @@ +from build.c import cxxlibrary +from build.protobuf import proto, protocc + + +proto(name="common_proto", srcs=["./common.proto"]) + +proto( + name="config_proto", + srcs=[ + "./config.proto", + "./layout.proto", + "./drive.proto", + "./decoders/decoders.proto", + "./encoders/encoders.proto", + "./fluxsink/fluxsink.proto", + "./fluxsource/fluxsource.proto", + "./imagereader/imagereader.proto", + "./imagewriter/imagewriter.proto", + "./usb/usb.proto", + "./vfs/vfs.proto", + ], + deps=[".+common_proto", "+fl2_proto"], +) + +protocc(name="config_proto_lib", srcs=[".+config_proto", "arch+arch_proto"]) diff --git a/lib/bytes.cc b/lib/bytes.cc index addfc073..28432cd3 100644 --- a/lib/bytes.cc +++ b/lib/bytes.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/bytes.h" #include #include diff --git a/lib/config.cc b/lib/config.cc index a20102b8..3b987145 100644 --- a/lib/config.cc +++ b/lib/config.cc @@ -172,7 +172,6 @@ ConfigProto* Config::combined() /* First apply any standalone options. */ std::set options = _appliedOptions; - std::set prereqs; for (const auto& option : _baseConfig.option()) { if (options.find(option.name()) != options.end()) diff --git a/lib/config.h b/lib/config.h index 31886de8..156e9910 100644 --- a/lib/config.h +++ b/lib/config.h @@ -52,7 +52,8 @@ class InapplicableValueException : public ErrorException public: InapplicableValueException(): ErrorException("selected format cannot be used here") - {} + { + } }; struct FluxConstructor diff --git a/lib/crc.cc b/lib/crc.cc index 3cea8ecd..71719f29 100644 --- a/lib/crc.cc +++ b/lib/crc.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "bytes.h" -#include "crc.h" +#include "lib/globals.h" +#include "lib/bytes.h" +#include "lib/crc.h" template T reflect(T bin, unsigned width = sizeof(T) * 8) diff --git a/lib/csvreader.cc b/lib/csvreader.cc index 057d45cd..b87b1bc0 100644 --- a/lib/csvreader.cc +++ b/lib/csvreader.cc @@ -1,6 +1,6 @@ #include #include -#include "csvreader.h" +#include "lib/csvreader.h" std::vector CsvReader::readLine() { diff --git a/lib/decoders/decoders.cc b/lib/decoders/decoders.cc index b66766ef..446f438c 100644 --- a/lib/decoders/decoders.cc +++ b/lib/decoders/decoders.cc @@ -1,8 +1,8 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" #include "arch/agat/agat.h" #include "arch/aeslanier/aeslanier.h" #include "arch/amiga/amiga.h" @@ -21,12 +21,12 @@ #include "arch/tids990/tids990.h" #include "arch/victor9k/victor9k.h" #include "arch/zilogmcz/zilogmcz.h" -#include "decoders/fluxmapreader.h" -#include "flux.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/flux.h" #include "protocol.h" -#include "decoders/rawbits.h" -#include "sector.h" -#include "image.h" +#include "lib/decoders/rawbits.h" +#include "lib/sector.h" +#include "lib/image.h" #include "lib/decoders/decoders.pb.h" #include "lib/layout.h" #include diff --git a/lib/decoders/decoders.h b/lib/decoders/decoders.h index 2be8d76a..4b0b72f5 100644 --- a/lib/decoders/decoders.h +++ b/lib/decoders/decoders.h @@ -1,10 +1,10 @@ #ifndef DECODERS_H #define DECODERS_H -#include "bytes.h" -#include "sector.h" -#include "decoders/fluxmapreader.h" -#include "decoders/fluxdecoder.h" +#include "lib/bytes.h" +#include "lib/sector.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/decoders/fluxdecoder.h" class Sector; class Fluxmap; @@ -12,7 +12,7 @@ class FluxmapReader; class RawBits; class DecoderProto; -#include "flux.h" +#include "lib/flux.h" extern void setDecoderManualClockRate(double clockrate_us); diff --git a/lib/decoders/fluxdecoder.cc b/lib/decoders/fluxdecoder.cc index a3c1439d..bb35da58 100644 --- a/lib/decoders/fluxdecoder.cc +++ b/lib/decoders/fluxdecoder.cc @@ -1,7 +1,7 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" -#include "decoders/fluxdecoder.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/decoders/fluxdecoder.h" #include "lib/decoders/decoders.pb.h" /* This is a port of the samdisk code: diff --git a/lib/decoders/fluxmapreader.cc b/lib/decoders/fluxmapreader.cc index 49d38016..4ce8f7c8 100644 --- a/lib/decoders/fluxmapreader.cc +++ b/lib/decoders/fluxmapreader.cc @@ -1,9 +1,9 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" -#include "flags.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/flags.h" +#include "lib/proto.h" #include "protocol.h" -#include "proto.h" #include #include #include diff --git a/lib/decoders/fluxmapreader.h b/lib/decoders/fluxmapreader.h index 35036eda..e154b8f0 100644 --- a/lib/decoders/fluxmapreader.h +++ b/lib/decoders/fluxmapreader.h @@ -1,9 +1,9 @@ #ifndef FLUXMAPREADER_H #define FLUXMAPREADER_H -#include "fluxmap.h" +#include "lib/fluxmap.h" +#include "lib/flags.h" #include "protocol.h" -#include "flags.h" class FluxMatcher; class DecoderProto; diff --git a/lib/decoders/fmmfm.cc b/lib/decoders/fmmfm.cc index 3a4135b8..8ae7d955 100644 --- a/lib/decoders/fmmfm.cc +++ b/lib/decoders/fmmfm.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "decoders/decoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" Bytes decodeFmMfm( std::vector::const_iterator ii, std::vector::const_iterator end) diff --git a/lib/drive.proto b/lib/drive.proto index 2b3e310e..6bbe1766 100644 --- a/lib/drive.proto +++ b/lib/drive.proto @@ -1,8 +1,9 @@ syntax = "proto2"; import "lib/common.proto"; +import "lib/fl2.proto"; -// Next: 17 +// Next: 15 message DriveProto { optional int32 drive = 1 @@ -11,32 +12,30 @@ message DriveProto [ default = INDEXMODE_DRIVE, (help) = "index pulse source" ]; optional int32 hard_sector_count = 3 [ default = 0, (help) = "number of hard sectors on disk" ]; - optional double hard_sector_threshold_ns = 16 + optional double hard_sector_threshold_ns = 4 [ default = 0, (help) = "index pulses longer than this interval are " "considered sector markers; shorter indicates an true index marker" ]; - optional bool high_density = 4 + optional bool high_density = 5 [ default = true, (help) = "set if this is a high density disk" ]; - optional bool sync_with_index = 5 + optional bool sync_with_index = 6 [ default = false, (help) = "start reading at index mark" ]; - optional double revolutions = 6 + optional double revolutions = 7 [ default = 1.2, (help) = "number of revolutions to read" ]; - optional int32 tracks = 7 + optional int32 tracks = 8 [ default = 81, (help) = "Number of tracks supported by drive" ]; - optional int32 heads = 8 + optional int32 heads = 9 [ default = 2, (help) = "Number of heads supported by drive" ]; - optional int32 head_bias = 9 [ + optional int32 head_bias = 10 [ default = 0, (help) = "Bias to apply to the head position (in tracks)" ]; - optional int32 group_offset = 14 [ + optional int32 group_offset = 11 [ default = 0, (help) = "When writing groups, erase all tracks except this one in each group" ]; - optional int32 head_width = 10 - [ default = 1, (help) = "Width of the head (in tracks)" ]; - optional float tpi = 11 [ default = 0, (help) = "TPI of drive; 0 disables all track mapping" ]; - optional double rotational_period_ms = 12 + optional DriveType drive_type = 12 [ default = DRIVETYPE_UNKNOWN, (help) = "Type of drive" ]; + optional double rotational_period_ms = 13 [ default = 0, (help) = "Rotational period of the drive in milliseconds (0 to autodetect)"]; enum ErrorBehaviour { @@ -45,7 +44,7 @@ message DriveProto RECALIBRATE = 2; } - optional ErrorBehaviour error_behaviour = 15 + optional ErrorBehaviour error_behaviour = 14 [ default = JIGGLE, (help) = "what to do when an error occurs during reads" ]; } diff --git a/lib/encoders/encoders.cc b/lib/encoders/encoders.cc index 41c786f1..6126d663 100644 --- a/lib/encoders/encoders.cc +++ b/lib/encoders/encoders.cc @@ -1,7 +1,7 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" #include "arch/agat/agat.h" #include "arch/amiga/amiga.h" #include "arch/apple2/apple2.h" diff --git a/lib/fl2.cc b/lib/fl2.cc index abf2f57c..5f97c428 100644 --- a/lib/fl2.cc +++ b/lib/fl2.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "proto.h" -#include "fluxmap.h" +#include "lib/globals.h" +#include "lib/proto.h" +#include "lib/fluxmap.h" #include "lib/fl2.pb.h" #include diff --git a/lib/fl2.proto b/lib/fl2.proto index fa0d5f2a..899cfc4f 100644 --- a/lib/fl2.proto +++ b/lib/fl2.proto @@ -15,11 +15,28 @@ message TrackFluxProto { repeated bytes flux = 3; } +enum DriveType { + DRIVETYPE_UNKNOWN = 0; + DRIVETYPE_40TRACK = 1; + DRIVETYPE_80TRACK = 2; + DRIVETYPE_APPLE2 = 3; +} + +enum FormatType { + FORMATTYPE_UNKNOWN = 0; + FORMATTYPE_40TRACK = 1; + FORMATTYPE_80TRACK = 2; +} + +// NEXT: 8 message FluxFileProto { optional int32 magic = 1; optional FluxFileVersion version = 2; repeated TrackFluxProto track = 3; optional double rotational_period_ms = 4; - optional int32 tpi = 5; + optional DriveType drive_type = 6 [default = DRIVETYPE_UNKNOWN]; + optional FormatType format_type = 7 [default = FORMATTYPE_UNKNOWN]; + + reserved 5; } diff --git a/lib/flux.h b/lib/flux.h index f958c71e..eed9365e 100644 --- a/lib/flux.h +++ b/lib/flux.h @@ -1,7 +1,7 @@ #ifndef FLUX_H #define FLUX_H -#include "bytes.h" +#include "lib/bytes.h" class Fluxmap; class Sector; diff --git a/lib/fluxmap.cc b/lib/fluxmap.cc index 766d1f16..8c7b1463 100644 --- a/lib/fluxmap.cc +++ b/lib/fluxmap.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" #include "protocol.h" Fluxmap& Fluxmap::appendBytes(const Bytes& bytes) diff --git a/lib/fluxmap.h b/lib/fluxmap.h index 69367f77..15b6e27c 100644 --- a/lib/fluxmap.h +++ b/lib/fluxmap.h @@ -1,7 +1,7 @@ #ifndef FLUXMAP_H #define FLUXMAP_H -#include "bytes.h" +#include "lib/bytes.h" #include "protocol.h" #include "fmt/format.h" diff --git a/lib/fluxsink/a2rfluxsink.cc b/lib/fluxsink/a2rfluxsink.cc index 7953c0bb..37d1cf58 100644 --- a/lib/fluxsink/a2rfluxsink.cc +++ b/lib/fluxsink/a2rfluxsink.cc @@ -1,15 +1,15 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/bytes.h" #include "protocol.h" -#include "fluxsink/fluxsink.h" -#include "decoders/fluxmapreader.h" +#include "lib/fluxsink/fluxsink.h" +#include "lib/decoders/fluxmapreader.h" #include "lib/fluxsink/fluxsink.pb.h" #include "lib/logger.h" -#include "proto.h" -#include "fluxmap.h" -#include "a2r.h" +#include "lib/proto.h" +#include "lib/fluxmap.h" +#include "lib/a2r.h" #include #include #include diff --git a/lib/fluxsink/aufluxsink.cc b/lib/fluxsink/aufluxsink.cc index 6c970a72..996f6f2f 100644 --- a/lib/fluxsink/aufluxsink.cc +++ b/lib/fluxsink/aufluxsink.cc @@ -1,12 +1,12 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/bytes.h" #include "protocol.h" -#include "fluxsink/fluxsink.h" -#include "decoders/fluxmapreader.h" +#include "lib/fluxsink/fluxsink.h" +#include "lib/decoders/fluxmapreader.h" #include "lib/fluxsink/fluxsink.pb.h" -#include "proto.h" +#include "lib/proto.h" #include #include #include diff --git a/lib/fluxsink/fl2fluxsink.cc b/lib/fluxsink/fl2fluxsink.cc index 8a0491ec..0822ccaf 100644 --- a/lib/fluxsink/fl2fluxsink.cc +++ b/lib/fluxsink/fl2fluxsink.cc @@ -1,14 +1,14 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/bytes.h" #include "protocol.h" -#include "fluxsink/fluxsink.h" -#include "decoders/fluxmapreader.h" +#include "lib/fluxsink/fluxsink.h" +#include "lib/decoders/fluxmapreader.h" #include "lib/fluxsink/fluxsink.pb.h" -#include "proto.h" +#include "lib/proto.h" #include "lib/fl2.pb.h" -#include "fl2.h" +#include "lib/fl2.h" #include #include #include @@ -45,7 +45,8 @@ public: proto.set_rotational_period_ms( globalConfig()->drive().rotational_period_ms()); - proto.set_tpi(globalConfig()->drive().tpi()); + proto.set_drive_type(globalConfig()->drive().drive_type()); + proto.set_format_type(globalConfig()->layout().format_type()); saveFl2File(_filename, proto); } diff --git a/lib/fluxsink/fluxsink.cc b/lib/fluxsink/fluxsink.cc index 6aa47e30..69673bdf 100644 --- a/lib/fluxsink/fluxsink.cc +++ b/lib/fluxsink/fluxsink.cc @@ -1,9 +1,9 @@ -#include "globals.h" -#include "flags.h" -#include "fluxsink/fluxsink.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxsink/fluxsink.h" #include "lib/config.pb.h" -#include "proto.h" -#include "utils.h" +#include "lib/proto.h" +#include "lib/utils.h" #include std::unique_ptr FluxSink::create(const FluxSinkProto& config) diff --git a/lib/fluxsink/fluxsink.h b/lib/fluxsink/fluxsink.h index 8ffb7616..8f3b4260 100644 --- a/lib/fluxsink/fluxsink.h +++ b/lib/fluxsink/fluxsink.h @@ -1,7 +1,7 @@ #ifndef FLUXSINK_H #define FLUXSINK_H -#include "flags.h" +#include "lib/flags.h" #include class Fluxmap; diff --git a/lib/fluxsink/hardwarefluxsink.cc b/lib/fluxsink/hardwarefluxsink.cc index 54f81112..faaa23ef 100644 --- a/lib/fluxsink/hardwarefluxsink.cc +++ b/lib/fluxsink/hardwarefluxsink.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "logger.h" -#include "proto.h" -#include "usb/usb.h" -#include "fluxsink/fluxsink.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/logger.h" +#include "lib/proto.h" +#include "lib/usb/usb.h" +#include "lib/fluxsink/fluxsink.h" #include "lib/fluxsink/fluxsink.pb.h" #include "lib/readerwriter.h" diff --git a/lib/fluxsink/scpfluxsink.cc b/lib/fluxsink/scpfluxsink.cc index a08e7c56..77d0a26a 100644 --- a/lib/fluxsink/scpfluxsink.cc +++ b/lib/fluxsink/scpfluxsink.cc @@ -1,15 +1,15 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/bytes.h" #include "protocol.h" -#include "fluxsink/fluxsink.h" -#include "decoders/fluxmapreader.h" +#include "lib/fluxsink/fluxsink.h" +#include "lib/decoders/fluxmapreader.h" #include "lib/fluxsink/fluxsink.pb.h" -#include "proto.h" -#include "fluxmap.h" -#include "layout.h" -#include "scp.h" +#include "lib/proto.h" +#include "lib/fluxmap.h" +#include "lib/layout.h" +#include "lib/scp.h" #include "lib/logger.h" #include #include @@ -55,7 +55,7 @@ public: _fileheader.start_track = strackno(minTrack, minSide); _fileheader.end_track = strackno(maxTrack, maxSide); _fileheader.flags = SCP_FLAG_INDEXED; - if (globalConfig()->drive().tpi() != 48) + if (globalConfig()->drive().drive_type() != DRIVETYPE_40TRACK) _fileheader.flags |= SCP_FLAG_96TPI; _fileheader.cell_width = 0; if ((minSide == 0) && (maxSide == 0)) diff --git a/lib/fluxsink/vcdfluxsink.cc b/lib/fluxsink/vcdfluxsink.cc index 0ba83a64..a52bf987 100644 --- a/lib/fluxsink/vcdfluxsink.cc +++ b/lib/fluxsink/vcdfluxsink.cc @@ -1,12 +1,12 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/bytes.h" #include "protocol.h" -#include "fluxsink/fluxsink.h" -#include "decoders/fluxmapreader.h" +#include "lib/fluxsink/fluxsink.h" +#include "lib/decoders/fluxmapreader.h" #include "lib/fluxsink/fluxsink.pb.h" -#include "proto.h" +#include "lib/proto.h" #include #include #include diff --git a/lib/fluxsource/a2rfluxsource.cc b/lib/fluxsource/a2rfluxsource.cc index b189fd99..f2bb2f64 100644 --- a/lib/fluxsource/a2rfluxsource.cc +++ b/lib/fluxsource/a2rfluxsource.cc @@ -1,8 +1,8 @@ -#include "globals.h" -#include "fluxmap.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" #include "lib/fluxsource/fluxsource.pb.h" -#include "fluxsource/fluxsource.h" -#include "proto.h" +#include "lib/fluxsource/fluxsource.h" +#include "lib/proto.h" #include struct A2Rv2Flux @@ -80,13 +80,14 @@ public: /* 5.25" with quarter stepping. */ _extraConfig.mutable_drive()->set_tracks(160); _extraConfig.mutable_drive()->set_heads(1); - _extraConfig.mutable_drive()->set_head_width(4); - _extraConfig.mutable_drive()->set_tpi(48 * 4); + _extraConfig.mutable_drive()->set_drive_type( + DRIVETYPE_APPLE2); } else { /* 3.5". */ - _extraConfig.mutable_drive()->set_tpi(135); + _extraConfig.mutable_drive()->set_drive_type( + DRIVETYPE_80TRACK); } Bytes stream = findChunk("STRM"); diff --git a/lib/fluxsource/cwffluxsource.cc b/lib/fluxsource/cwffluxsource.cc index 12a63063..0157f93e 100644 --- a/lib/fluxsource/cwffluxsource.cc +++ b/lib/fluxsource/cwffluxsource.cc @@ -1,8 +1,8 @@ -#include "globals.h" -#include "fluxmap.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" #include "lib/fluxsource/fluxsource.pb.h" -#include "fluxsource/fluxsource.h" -#include "proto.h" +#include "lib/fluxsource/fluxsource.h" +#include "lib/proto.h" #include struct CwfHeader diff --git a/lib/fluxsource/erasefluxsource.cc b/lib/fluxsource/erasefluxsource.cc index 4ac3de59..87bd2d74 100644 --- a/lib/fluxsource/erasefluxsource.cc +++ b/lib/fluxsource/erasefluxsource.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "fluxmap.h" -#include "fluxsource/fluxsource.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/fluxsource/fluxsource.h" #include "lib/fluxsource/fluxsource.pb.h" class EraseFluxSource : public TrivialFluxSource diff --git a/lib/fluxsource/fl2fluxsource.cc b/lib/fluxsource/fl2fluxsource.cc index 2e02a71c..f4c2f5f4 100644 --- a/lib/fluxsource/fl2fluxsource.cc +++ b/lib/fluxsource/fl2fluxsource.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "fluxmap.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" #include "lib/fluxsource/fluxsource.pb.h" #include "lib/fl2.pb.h" -#include "fluxsource/fluxsource.h" -#include "proto.h" -#include "fl2.h" -#include "fluxmap.h" +#include "lib/fluxsource/fluxsource.h" +#include "lib/proto.h" +#include "lib/fl2.h" +#include "lib/fluxmap.h" #include class Fl2FluxSourceIterator : public FluxSourceIterator @@ -39,8 +39,8 @@ public: _extraConfig.mutable_drive()->set_rotational_period_ms( _proto.rotational_period_ms()); - if (_proto.has_tpi()) - _extraConfig.mutable_drive()->set_tpi(_proto.tpi()); + if (_proto.has_drive_type()) + _extraConfig.mutable_drive()->set_drive_type(_proto.drive_type()); } public: diff --git a/lib/fluxsource/fluxsource.cc b/lib/fluxsource/fluxsource.cc index e5870d32..4b0a9bc0 100644 --- a/lib/fluxsource/fluxsource.cc +++ b/lib/fluxsource/fluxsource.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "fluxsource/fluxsource.h" -#include "fluxmap.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxsource/fluxsource.h" +#include "lib/fluxmap.h" #include "lib/config.pb.h" -#include "proto.h" -#include "utils.h" +#include "lib/proto.h" +#include "lib/utils.h" std::unique_ptr FluxSource::create(const FluxSourceProto& config) { diff --git a/lib/fluxsource/fluxsource.h b/lib/fluxsource/fluxsource.h index 3bcddf77..b7c0b1c8 100644 --- a/lib/fluxsource/fluxsource.h +++ b/lib/fluxsource/fluxsource.h @@ -1,7 +1,7 @@ #ifndef FLUXSOURCE_H #define FLUXSOURCE_H -#include "flags.h" +#include "lib/flags.h" #include "lib/config.pb.h" class A2rFluxSourceProto; diff --git a/lib/fluxsource/flx.cc b/lib/fluxsource/flx.cc index d1296cf9..4022a6a3 100644 --- a/lib/fluxsource/flx.cc +++ b/lib/fluxsource/flx.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "fluxmap.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" #include "kryoflux.h" #include "protocol.h" #include "lib/fluxsource/flx.h" diff --git a/lib/fluxsource/hardwarefluxsource.cc b/lib/fluxsource/hardwarefluxsource.cc index 2e0d41a2..df0081a0 100644 --- a/lib/fluxsource/hardwarefluxsource.cc +++ b/lib/fluxsource/hardwarefluxsource.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "logger.h" -#include "proto.h" -#include "usb/usb.h" -#include "fluxsource/fluxsource.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/logger.h" +#include "lib/proto.h" +#include "lib/usb/usb.h" +#include "lib/fluxsource/fluxsource.h" #include "lib/fluxsource/fluxsource.pb.h" #include "lib/readerwriter.h" diff --git a/lib/fluxsource/kryoflux.cc b/lib/fluxsource/kryoflux.cc index 2b054d37..41a0d868 100644 --- a/lib/fluxsource/kryoflux.cc +++ b/lib/fluxsource/kryoflux.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "fluxmap.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" #include "kryoflux.h" #include "protocol.h" #include diff --git a/lib/fluxsource/kryofluxfluxsource.cc b/lib/fluxsource/kryofluxfluxsource.cc index b924846f..e483f020 100644 --- a/lib/fluxsource/kryofluxfluxsource.cc +++ b/lib/fluxsource/kryofluxfluxsource.cc @@ -1,8 +1,8 @@ -#include "globals.h" -#include "fluxmap.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" #include "kryoflux.h" #include "lib/fluxsource/fluxsource.pb.h" -#include "fluxsource/fluxsource.h" +#include "lib/fluxsource/fluxsource.h" class KryofluxFluxSource : public TrivialFluxSource { diff --git a/lib/fluxsource/scpfluxsource.cc b/lib/fluxsource/scpfluxsource.cc index cb92846b..bdab7227 100644 --- a/lib/fluxsource/scpfluxsource.cc +++ b/lib/fluxsource/scpfluxsource.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "fluxmap.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" #include "kryoflux.h" #include "lib/fluxsource/fluxsource.pb.h" #include "lib/utils.h" -#include "fluxsource/fluxsource.h" -#include "scp.h" -#include "proto.h" +#include "lib/fluxsource/fluxsource.h" +#include "lib/scp.h" +#include "lib/proto.h" #include "lib/logger.h" #include @@ -42,8 +42,9 @@ public: (_header.file_id[2] != 'P')) error("input not a SCP file"); - int tpi = (_header.flags & SCP_FLAG_96TPI) ? 96 : 48; - _extraConfig.mutable_drive()->set_tpi(tpi); + _extraConfig.mutable_drive()->set_drive_type( + (_header.flags & SCP_FLAG_96TPI) ? DRIVETYPE_80TRACK + : DRIVETYPE_40TRACK); _resolution = 25 * (_header.resolution + 1); int startSide = (_header.heads == 2) ? 1 : 0; diff --git a/lib/fluxsource/testpatternfluxsource.cc b/lib/fluxsource/testpatternfluxsource.cc index 2dc6ff13..0b3a0da1 100644 --- a/lib/fluxsource/testpatternfluxsource.cc +++ b/lib/fluxsource/testpatternfluxsource.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "fluxmap.h" -#include "fluxsource/fluxsource.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/fluxsource/fluxsource.h" #include "lib/fluxsource/fluxsource.pb.h" class TestPatternFluxSource : public TrivialFluxSource diff --git a/lib/hexdump.cc b/lib/hexdump.cc index ed6242fd..5c120d9b 100644 --- a/lib/hexdump.cc +++ b/lib/hexdump.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/bytes.h" void hexdump(std::ostream& stream, const Bytes& buffer) { diff --git a/lib/imagereader/d64imagereader.cc b/lib/imagereader/d64imagereader.cc index 20d1381e..ad3756b6 100644 --- a/lib/imagereader/d64imagereader.cc +++ b/lib/imagereader/d64imagereader.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagereader/imagereader.h" -#include "image.h" -#include "logger.h" -#include "proto.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagereader/imagereader.h" +#include "lib/image.h" +#include "lib/logger.h" +#include "lib/proto.h" #include #include #include diff --git a/lib/imagereader/d88imagereader.cc b/lib/imagereader/d88imagereader.cc index c5ce3783..3bee4018 100644 --- a/lib/imagereader/d88imagereader.cc +++ b/lib/imagereader/d88imagereader.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagereader/imagereader.h" -#include "image.h" -#include "proto.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagereader/imagereader.h" +#include "lib/image.h" +#include "lib/proto.h" +#include "lib/logger.h" #include "lib/config.pb.h" #include #include @@ -61,13 +61,13 @@ public: if (mediaFlag == 0x20) { _extraConfig.mutable_drive()->set_high_density(true); - _extraConfig.mutable_layout()->set_tpi(96); + _extraConfig.mutable_layout()->set_format_type(FORMATTYPE_80TRACK); } else { clockRate = 300; _extraConfig.mutable_drive()->set_high_density(false); - _extraConfig.mutable_layout()->set_tpi(48); + _extraConfig.mutable_layout()->set_format_type(FORMATTYPE_40TRACK); } auto layout = _extraConfig.mutable_layout(); diff --git a/lib/imagereader/dimimagereader.cc b/lib/imagereader/dimimagereader.cc index d8f5e027..8410a9b6 100644 --- a/lib/imagereader/dimimagereader.cc +++ b/lib/imagereader/dimimagereader.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagereader/imagereader.h" -#include "image.h" -#include "logger.h" -#include "proto.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagereader/imagereader.h" +#include "lib/image.h" +#include "lib/logger.h" +#include "lib/proto.h" #include "lib/config.pb.h" #include #include diff --git a/lib/imagereader/diskcopyimagereader.cc b/lib/imagereader/diskcopyimagereader.cc index 4f952ea2..d6c85a79 100644 --- a/lib/imagereader/diskcopyimagereader.cc +++ b/lib/imagereader/diskcopyimagereader.cc @@ -1,9 +1,9 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagereader/imagereader.h" -#include "image.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagereader/imagereader.h" +#include "lib/image.h" +#include "lib/logger.h" #include "lib/config.pb.h" #include #include diff --git a/lib/imagereader/fdiimagereader.cc b/lib/imagereader/fdiimagereader.cc index 8c0813cb..f7317320 100644 --- a/lib/imagereader/fdiimagereader.cc +++ b/lib/imagereader/fdiimagereader.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagereader/imagereader.h" -#include "image.h" -#include "proto.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagereader/imagereader.h" +#include "lib/image.h" +#include "lib/proto.h" +#include "lib/logger.h" #include "lib/config.pb.h" #include #include diff --git a/lib/imagereader/imagereader.cc b/lib/imagereader/imagereader.cc index b5fc7469..b5d7da28 100644 --- a/lib/imagereader/imagereader.cc +++ b/lib/imagereader/imagereader.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagereader/imagereader.h" -#include "utils.h" -#include "proto.h" -#include "image.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagereader/imagereader.h" +#include "lib/utils.h" +#include "lib/proto.h" +#include "lib/image.h" #include "lib/layout.h" #include "lib/config.pb.h" #include "lib/logger.h" diff --git a/lib/imagereader/imagereader.h b/lib/imagereader/imagereader.h index 0ae0225e..3baa8283 100644 --- a/lib/imagereader/imagereader.h +++ b/lib/imagereader/imagereader.h @@ -1,7 +1,7 @@ #ifndef IMAGEREADER_H #define IMAGEREADER_H -#include "image.h" +#include "lib/image.h" #include "lib/config.pb.h" class ImageSpec; diff --git a/lib/imagereader/imdimagereader.cc b/lib/imagereader/imdimagereader.cc index 855455b6..ab868b26 100644 --- a/lib/imagereader/imdimagereader.cc +++ b/lib/imagereader/imdimagereader.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagereader/imagereader.h" -#include "image.h" -#include "proto.h" -#include "logger.h" -#include "layout.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagereader/imagereader.h" +#include "lib/image.h" +#include "lib/proto.h" +#include "lib/logger.h" +#include "lib/layout.h" #include "lib/config.pb.h" #include #include diff --git a/lib/imagereader/imgimagereader.cc b/lib/imagereader/imgimagereader.cc index 5644a9a3..8ae3a108 100644 --- a/lib/imagereader/imgimagereader.cc +++ b/lib/imagereader/imgimagereader.cc @@ -1,9 +1,9 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagereader/imagereader.h" -#include "image.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagereader/imagereader.h" +#include "lib/image.h" +#include "lib/logger.h" #include "lib/config.pb.h" #include "lib/layout.pb.h" #include "lib/proto.h" diff --git a/lib/imagereader/jv3imagereader.cc b/lib/imagereader/jv3imagereader.cc index 5af47920..15bc5123 100644 --- a/lib/imagereader/jv3imagereader.cc +++ b/lib/imagereader/jv3imagereader.cc @@ -1,9 +1,9 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagereader/imagereader.h" -#include "image.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagereader/imagereader.h" +#include "lib/image.h" +#include "lib/logger.h" #include "lib/config.pb.h" #include #include diff --git a/lib/imagereader/nfdimagereader.cc b/lib/imagereader/nfdimagereader.cc index 489eb2e0..b626c31c 100644 --- a/lib/imagereader/nfdimagereader.cc +++ b/lib/imagereader/nfdimagereader.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagereader/imagereader.h" -#include "image.h" -#include "proto.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagereader/imagereader.h" +#include "lib/image.h" +#include "lib/proto.h" +#include "lib/logger.h" #include "lib/config.pb.h" #include #include @@ -58,7 +58,7 @@ public: log("NFD: HD 1.2MB mode"); log("NFD: forcing hign density mode"); _extraConfig.mutable_drive()->set_high_density(true); - _extraConfig.mutable_layout()->set_tpi(96); + _extraConfig.mutable_layout()->set_format_type(FORMATTYPE_80TRACK); std::unique_ptr image(new Image); for (int track = 0; track < 163; track++) diff --git a/lib/imagereader/nsiimagereader.cc b/lib/imagereader/nsiimagereader.cc index e1fc3308..0101c656 100644 --- a/lib/imagereader/nsiimagereader.cc +++ b/lib/imagereader/nsiimagereader.cc @@ -1,11 +1,11 @@ /* Image reader for Northstar floppy disk images */ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagereader/imagereader.h" -#include "image.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagereader/imagereader.h" +#include "lib/image.h" +#include "lib/logger.h" #include "lib/imagereader/imagereader.pb.h" #include #include diff --git a/lib/imagereader/td0imagereader.cc b/lib/imagereader/td0imagereader.cc index ed99b253..30ee7c70 100644 --- a/lib/imagereader/td0imagereader.cc +++ b/lib/imagereader/td0imagereader.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagereader/imagereader.h" -#include "image.h" -#include "crc.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagereader/imagereader.h" +#include "lib/image.h" +#include "lib/crc.h" +#include "lib/logger.h" #include "lib/config.pb.h" #include #include diff --git a/lib/imagewriter/d64imagewriter.cc b/lib/imagewriter/d64imagewriter.cc index 7501d787..74990a18 100644 --- a/lib/imagewriter/d64imagewriter.cc +++ b/lib/imagewriter/d64imagewriter.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagewriter/imagewriter.h" -#include "image.h" -#include "ldbs.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagewriter/imagewriter.h" +#include "lib/image.h" +#include "lib/ldbs.h" +#include "lib/logger.h" #include "lib/config.pb.h" #include #include diff --git a/lib/imagewriter/d88imagewriter.cc b/lib/imagewriter/d88imagewriter.cc index 0494f6b6..75d24e2d 100644 --- a/lib/imagewriter/d88imagewriter.cc +++ b/lib/imagewriter/d88imagewriter.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagewriter/imagewriter.h" -#include "image.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagewriter/imagewriter.h" +#include "lib/image.h" #include "lib/config.pb.h" #include "lib/layout.h" -#include "logger.h" +#include "lib/logger.h" #include #include #include diff --git a/lib/imagewriter/diskcopyimagewriter.cc b/lib/imagewriter/diskcopyimagewriter.cc index 256d7184..d98b44fe 100644 --- a/lib/imagewriter/diskcopyimagewriter.cc +++ b/lib/imagewriter/diskcopyimagewriter.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagewriter/imagewriter.h" -#include "ldbs.h" -#include "image.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagewriter/imagewriter.h" +#include "lib/ldbs.h" +#include "lib/image.h" +#include "lib/logger.h" #include "lib/config.pb.h" #include #include diff --git a/lib/imagewriter/imagewriter.cc b/lib/imagewriter/imagewriter.cc index 9b2ec35a..17b9a3a7 100644 --- a/lib/imagewriter/imagewriter.cc +++ b/lib/imagewriter/imagewriter.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagewriter/imagewriter.h" -#include "image.h" -#include "utils.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagewriter/imagewriter.h" +#include "lib/image.h" +#include "lib/utils.h" #include "lib/config.pb.h" -#include "proto.h" +#include "lib/proto.h" #include "lib/layout.h" #include "lib/logger.h" #include diff --git a/lib/imagewriter/imdimagewriter.cc b/lib/imagewriter/imdimagewriter.cc index 4d00b20f..3e1e5d78 100644 --- a/lib/imagewriter/imdimagewriter.cc +++ b/lib/imagewriter/imdimagewriter.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagewriter/imagewriter.h" -#include "image.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagewriter/imagewriter.h" +#include "lib/image.h" #include "lib/config.pb.h" #include "lib/layout.h" -#include "logger.h" +#include "lib/logger.h" #include #include #include diff --git a/lib/imagewriter/imgimagewriter.cc b/lib/imagewriter/imgimagewriter.cc index 33099776..698c1059 100644 --- a/lib/imagewriter/imgimagewriter.cc +++ b/lib/imagewriter/imgimagewriter.cc @@ -1,13 +1,13 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagewriter/imagewriter.h" -#include "image.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagewriter/imagewriter.h" +#include "lib/image.h" #include "lib/proto.h" #include "lib/config.pb.h" #include "lib/layout.h" #include "lib/layout.pb.h" -#include "logger.h" +#include "lib/logger.h" #include #include #include diff --git a/lib/imagewriter/ldbsimagewriter.cc b/lib/imagewriter/ldbsimagewriter.cc index 54e3a3a0..89f36a1f 100644 --- a/lib/imagewriter/ldbsimagewriter.cc +++ b/lib/imagewriter/ldbsimagewriter.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagewriter/imagewriter.h" -#include "ldbs.h" -#include "image.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagewriter/imagewriter.h" +#include "lib/ldbs.h" +#include "lib/image.h" +#include "lib/logger.h" #include "lib/config.pb.h" #include #include diff --git a/lib/imagewriter/nsiimagewriter.cc b/lib/imagewriter/nsiimagewriter.cc index 06d1d915..6c002af4 100644 --- a/lib/imagewriter/nsiimagewriter.cc +++ b/lib/imagewriter/nsiimagewriter.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagewriter/imagewriter.h" -#include "decoders/decoders.h" -#include "image.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagewriter/imagewriter.h" +#include "lib/decoders/decoders.h" +#include "lib/image.h" +#include "lib/logger.h" #include "arch/northstar/northstar.h" #include "lib/imagewriter/imagewriter.pb.h" #include diff --git a/lib/imagewriter/rawimagewriter.cc b/lib/imagewriter/rawimagewriter.cc index 1b01547a..ebe8c228 100644 --- a/lib/imagewriter/rawimagewriter.cc +++ b/lib/imagewriter/rawimagewriter.cc @@ -1,10 +1,10 @@ -#include "globals.h" -#include "flags.h" -#include "sector.h" -#include "imagewriter/imagewriter.h" -#include "decoders/decoders.h" -#include "image.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/sector.h" +#include "lib/imagewriter/imagewriter.h" +#include "lib/decoders/decoders.h" +#include "lib/image.h" +#include "lib/logger.h" #include "arch/northstar/northstar.h" #include "lib/imagewriter/imagewriter.pb.h" #include diff --git a/lib/layout.cc b/lib/layout.cc index f004c9c1..b23e1cea 100644 --- a/lib/layout.cc +++ b/lib/layout.cc @@ -2,34 +2,47 @@ #include "lib/layout.h" #include "lib/proto.h" #include "lib/logger.h" - -bool approximatelyEqual(float a, float b, float epsilon) -{ - return fabs(a - b) <= ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon); -} +#include "lib/fl2.h" static unsigned getTrackStep() { - if (globalConfig()->layout().tpi() == 0) - error("no layout TPI set"); - if (globalConfig()->drive().tpi() == 0) - return 1; + auto format_type = globalConfig()->layout().format_type(); + auto drive_type = globalConfig()->drive().drive_type(); - if (globalConfig()->layout().tpi() == 0.0) - error("layout TPI is zero; this shouldn't happen?"); + switch (format_type) + { + case FORMATTYPE_40TRACK: + switch (drive_type) + { + case DRIVETYPE_40TRACK: + return 1; - float trackStepFactor = - globalConfig()->drive().tpi() / globalConfig()->layout().tpi(); + case DRIVETYPE_80TRACK: + return 2; - if (!approximatelyEqual(trackStepFactor, round(trackStepFactor), 0.001)) - error( - "this drive can't handle this image, because the drive TPI doesn't " - "divide neatly into the layout TPI"); - if (trackStepFactor < 0.999) - error( - "this drive can't handle this image, because the head is too big"); + case DRIVETYPE_APPLE2: + return 4; + } - return round(trackStepFactor); + case FORMATTYPE_80TRACK: + switch (drive_type) + { + case DRIVETYPE_40TRACK: + error( + "you can't write an 80 track image to a 40 track " + "drive"); + + case DRIVETYPE_80TRACK: + return 1; + + case DRIVETYPE_APPLE2: + error( + "you can't write an 80 track image to an Apple II " + "drive"); + } + } + + return 1; } unsigned Layout::remapTrackPhysicalToLogical(unsigned ptrack) @@ -237,3 +250,15 @@ std::shared_ptr Layout::getLayoutOfTrackPhysical( return getLayoutOfTrack(remapTrackPhysicalToLogical(physicalTrack), remapSidePhysicalToLogical(physicalSide)); } + +int Layout::getHeadWidth() +{ + switch (globalConfig()->drive().drive_type()) + { + case DRIVETYPE_APPLE2: + return 4; + + default: + return 1; + } +} diff --git a/lib/layout.h b/lib/layout.h index 24d2bf4c..f886150c 100644 --- a/lib/layout.h +++ b/lib/layout.h @@ -52,6 +52,9 @@ public: /* Expand a SectorList into the actual sector IDs. */ static std::vector expandSectorList( const SectorListProto& sectorsProto); + + /* Return the head width of the current drive. */ + static int getHeadWidth(); }; class TrackInfo diff --git a/lib/layout.proto b/lib/layout.proto index d4b50f22..edd33cca 100644 --- a/lib/layout.proto +++ b/lib/layout.proto @@ -1,6 +1,7 @@ syntax = "proto2"; import "lib/common.proto"; +import "lib/fl2.proto"; message SectorListProto { @@ -57,5 +58,6 @@ message LayoutProto [ default = CHS, (help) = "the order of sectors in the filesystem" ]; optional bool swap_sides = 5 [ default = false, (help) = "the sides are inverted on this disk" ]; - optional float tpi = 6 [ (help) = "TPI of image; if 0, use TPI of drive" ]; + optional FormatType format_type = 6 + [ default = FORMATTYPE_UNKNOWN, (help) = "Format type of image" ]; } diff --git a/lib/ldbs.cc b/lib/ldbs.cc index f7ae8ee0..dacde544 100644 --- a/lib/ldbs.cc +++ b/lib/ldbs.cc @@ -1,7 +1,7 @@ -#include "globals.h" +#include "lib/globals.h" #include -#include "bytes.h" -#include "ldbs.h" +#include "lib/bytes.h" +#include "lib/ldbs.h" LDBS::LDBS() {} diff --git a/lib/logger.cc b/lib/logger.cc index c12d4d47..6a23cd82 100644 --- a/lib/logger.cc +++ b/lib/logger.cc @@ -1,9 +1,9 @@ -#include "globals.h" -#include "bytes.h" -#include "fluxmap.h" -#include "sector.h" -#include "flux.h" -#include "logger.h" +#include "lib/globals.h" +#include "lib/bytes.h" +#include "lib/fluxmap.h" +#include "lib/sector.h" +#include "lib/flux.h" +#include "lib/logger.h" static bool indented = false; diff --git a/lib/proto.cc b/lib/proto.cc index 61e39a2c..fa3f8e20 100644 --- a/lib/proto.cc +++ b/lib/proto.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "proto.h" +#include "lib/globals.h" +#include "lib/proto.h" #include "lib/common.pb.h" #include @@ -288,8 +288,7 @@ std::string getProtoFieldValue(ProtoField& protoField) case google::protobuf::FieldDescriptor::TYPE_ENUM: { const auto* enumvalue = reflection->GetEnum(*message, field); - const auto* enumfield = field->enum_type(); - return enumfield->name(); + return enumvalue->name(); } case google::protobuf::FieldDescriptor::TYPE_MESSAGE: diff --git a/lib/readerwriter.cc b/lib/readerwriter.cc index 2f8b0a65..e1c25ccd 100644 --- a/lib/readerwriter.cc +++ b/lib/readerwriter.cc @@ -1,22 +1,22 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "readerwriter.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/readerwriter.h" #include "protocol.h" -#include "usb/usb.h" -#include "encoders/encoders.h" -#include "decoders/decoders.h" -#include "fluxsource/fluxsource.h" -#include "fluxsink/fluxsink.h" -#include "imagereader/imagereader.h" -#include "imagewriter/imagewriter.h" -#include "sector.h" -#include "image.h" -#include "logger.h" -#include "layout.h" -#include "utils.h" +#include "lib/usb/usb.h" +#include "lib/encoders/encoders.h" +#include "lib/decoders/decoders.h" +#include "lib/fluxsource/fluxsource.h" +#include "lib/fluxsink/fluxsink.h" +#include "lib/imagereader/imagereader.h" +#include "lib/imagewriter/imagewriter.h" +#include "lib/sector.h" +#include "lib/image.h" +#include "lib/logger.h" +#include "lib/layout.h" +#include "lib/utils.h" #include "lib/config.pb.h" -#include "proto.h" +#include "lib/proto.h" #include enum ReadResult @@ -218,7 +218,7 @@ ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder, ReadResult result = BAD_AND_CAN_NOT_RETRY; for (unsigned offset = 0; offset < trackInfo->groupSize; - offset += globalConfig()->drive().head_width()) + offset += Layout::getHeadWidth()) { auto& fluxSourceIterator = fluxSourceIteratorHolder.getIterator( trackInfo->physicalTrack + offset, trackInfo->physicalSide); @@ -274,7 +274,7 @@ void writeTracks(FluxSink& fluxSink, for (;;) { for (int offset = 0; offset < trackInfo->groupSize; - offset += globalConfig()->drive().head_width()) + offset += Layout::getHeadWidth()) { unsigned physicalTrack = trackInfo->physicalTrack + offset; diff --git a/lib/sector.cc b/lib/sector.cc index 4053fb3c..40f024a7 100644 --- a/lib/sector.cc +++ b/lib/sector.cc @@ -1,7 +1,7 @@ -#include "globals.h" -#include "flux.h" -#include "sector.h" -#include "layout.h" +#include "lib/globals.h" +#include "lib/flux.h" +#include "lib/sector.h" +#include "lib/layout.h" Sector::Sector(const LogicalLocation& location): LogicalLocation(location), diff --git a/lib/sector.h b/lib/sector.h index c50d5cc1..a9c34ee2 100644 --- a/lib/sector.h +++ b/lib/sector.h @@ -1,8 +1,8 @@ #ifndef SECTOR_H #define SECTOR_H -#include "bytes.h" -#include "fluxmap.h" +#include "lib/bytes.h" +#include "lib/fluxmap.h" class Record; class TrackInfo; @@ -93,7 +93,7 @@ struct Sector : public LogicalLocation template <> struct fmt::formatter : formatter { - auto format(Sector::Status status, format_context& ctx) const + auto format(Sector::Status status, format_context& ctx) { return formatter::format( Sector::statusToString(status), ctx); diff --git a/lib/usb/fluxengineusb.cc b/lib/usb/fluxengineusb.cc index 3c856f9e..8a2bf015 100644 --- a/lib/usb/fluxengineusb.cc +++ b/lib/usb/fluxengineusb.cc @@ -1,8 +1,8 @@ -#include "globals.h" +#include "lib/globals.h" #include "usb.h" #include "protocol.h" -#include "fluxmap.h" -#include "bytes.h" +#include "lib/fluxmap.h" +#include "lib/bytes.h" #include "libusbp_config.h" #include "libusbp.hpp" @@ -76,7 +76,7 @@ public: "your FluxEngine firmware is at version {} but the client is " "for version {}; please upgrade", version, - (int) FLUXENGINE_PROTOCOL_VERSION); + (int)FLUXENGINE_PROTOCOL_VERSION); } private: diff --git a/lib/usb/greaseweazle.cc b/lib/usb/greaseweazle.cc index d96d8743..8b418e4f 100644 --- a/lib/usb/greaseweazle.cc +++ b/lib/usb/greaseweazle.cc @@ -1,7 +1,7 @@ -#include "globals.h" +#include "lib/globals.h" #include "usb.h" #include "protocol.h" -#include "bytes.h" +#include "lib/bytes.h" #include "greaseweazle.h" Bytes fluxEngineToGreaseweazle(const Bytes& fldata, nanoseconds_t clock) diff --git a/lib/usb/serial.cc b/lib/usb/serial.cc index 2e22b0f0..047bbe35 100644 --- a/lib/usb/serial.cc +++ b/lib/usb/serial.cc @@ -1,8 +1,8 @@ -#include "globals.h" +#include "lib/globals.h" #include "usb.h" #include "protocol.h" -#include "fluxmap.h" -#include "bytes.h" +#include "lib/fluxmap.h" +#include "lib/bytes.h" #include "serial.h" #include #include diff --git a/lib/usb/usb.cc b/lib/usb/usb.cc index a93aa036..a6654796 100644 --- a/lib/usb/usb.cc +++ b/lib/usb/usb.cc @@ -1,14 +1,14 @@ -#include "globals.h" -#include "flags.h" +#include "lib/globals.h" +#include "lib/flags.h" #include "usb.h" #include "libusbp_config.h" #include "libusbp.hpp" #include "protocol.h" -#include "fluxmap.h" -#include "bytes.h" -#include "proto.h" +#include "lib/fluxmap.h" +#include "lib/bytes.h" +#include "lib/proto.h" #include "usbfinder.h" -#include "logger.h" +#include "lib/logger.h" #include "greaseweazle.h" static USB* usb = NULL; diff --git a/lib/usb/usb.h b/lib/usb/usb.h index c77b2636..7686ad07 100644 --- a/lib/usb/usb.h +++ b/lib/usb/usb.h @@ -1,8 +1,8 @@ #ifndef USB_H #define USB_H -#include "bytes.h" -#include "flags.h" +#include "lib/bytes.h" +#include "lib/flags.h" class Fluxmap; class GreaseweazleProto; diff --git a/lib/usb/usbfinder.cc b/lib/usb/usbfinder.cc index a1a6d1aa..d3a87003 100644 --- a/lib/usb/usbfinder.cc +++ b/lib/usb/usbfinder.cc @@ -1,7 +1,7 @@ -#include "globals.h" -#include "flags.h" +#include "lib/globals.h" +#include "lib/flags.h" #include "usb.h" -#include "bytes.h" +#include "lib/bytes.h" #include "usbfinder.h" #include "greaseweazle.h" #include "protocol.h" diff --git a/lib/utils.cc b/lib/utils.cc index 29d1f8a8..09b4ba7b 100644 --- a/lib/utils.cc +++ b/lib/utils.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "utils.h" +#include "lib/globals.h" +#include "lib/utils.h" #include "lib/bytes.h" #include #include diff --git a/lib/vfs/amigaffs.cc b/lib/vfs/amigaffs.cc index ef18f203..d2e22791 100644 --- a/lib/vfs/amigaffs.cc +++ b/lib/vfs/amigaffs.cc @@ -7,7 +7,7 @@ #include "adflib.h" #include "adf_blk.h" -#include "dep/adflib/adf_nativ.h" +#include "adf_nativ.h" #undef min #include diff --git a/lib/vfs/lif.cc b/lib/vfs/lif.cc index 68e96f2a..0dbe5c04 100644 --- a/lib/vfs/lif.cc +++ b/lib/vfs/lif.cc @@ -214,7 +214,7 @@ private: _directoryBlock = rbr.read_be32(); rbr.skip(4); _directorySize = rbr.read_be32(); - rbr.skip(4); + rbr.skip(4); unsigned tracks = rbr.read_be32(); unsigned heads = rbr.read_be32(); unsigned sectors = rbr.read_be32(); diff --git a/lib/vfs/roland.cc b/lib/vfs/roland.cc index c5b61ac0..d642a083 100644 --- a/lib/vfs/roland.cc +++ b/lib/vfs/roland.cc @@ -69,10 +69,10 @@ private: void putBlock(RolandFsFilesystem* fs, uint8_t offset, uint8_t block) { if (blocks.size() <= offset) - blocks.resize(offset+1); + blocks.resize(offset + 1); blocks[offset] = block; - length = (offset+1) * fs->_blockSectors * fs->_sectorSize; + length = (offset + 1) * fs->_blockSectors * fs->_sectorSize; attributes[Filesystem::LENGTH] = std::to_string(length); } @@ -84,7 +84,7 @@ private: if (!blocknumber) break; - putBlock(fs, offset+i, blocknumber); + putBlock(fs, offset + i, blocknumber); } } @@ -336,7 +336,7 @@ private: else de = it->second; - de->putBlocks(this, extent*16, direntBytes); + de->putBlocks(this, extent * 16, direntBytes); } } diff --git a/lib/vfs/sectorinterface.h b/lib/vfs/sectorinterface.h index 7984e470..2d875217 100644 --- a/lib/vfs/sectorinterface.h +++ b/lib/vfs/sectorinterface.h @@ -12,7 +12,7 @@ class Encoder; class SectorInterface { public: - virtual ~SectorInterface() {} + virtual ~SectorInterface() {} public: virtual std::shared_ptr get( diff --git a/lib/vfs/vfs.cc b/lib/vfs/vfs.cc index 0de71064..051272d2 100644 --- a/lib/vfs/vfs.cc +++ b/lib/vfs/vfs.cc @@ -1,4 +1,4 @@ -#include "globals.h" +#include "lib/globals.h" #include "vfs.h" #include "lib/proto.h" #include "lib/layout.pb.h" @@ -281,9 +281,10 @@ Bytes Filesystem::getSector(unsigned track, unsigned side, unsigned sector) Bytes Filesystem::getLogicalSector(uint32_t number, uint32_t count) { if ((number + count) > _locations.size()) - throw BadFilesystemException( - fmt::format("invalid filesystem: sector {} is out of bounds ({} maximum)", - number + count - 1, _locations.size())); + throw BadFilesystemException(fmt::format( + "invalid filesystem: sector {} is out of bounds ({} maximum)", + number + count - 1, + _locations.size())); Bytes data; ByteWriter bw(data); diff --git a/scripts/analysedriveresponse.py b/scripts/analysedriveresponse.py index ed4383e4..69d3cd8b 100644 --- a/scripts/analysedriveresponse.py +++ b/scripts/analysedriveresponse.py @@ -12,6 +12,7 @@ data = numpy.loadtxt(open("driveresponse.csv", "rb"), delimiter=",", skiprows=1) labels = data[:, 0] frequencies = data[:, 1:] + # Scale the frequencies. def scaled(row): m = row.mean() @@ -20,13 +21,21 @@ def scaled(row): else: return row + scaledfreq = numpy.array([scaled(row) for row in frequencies]) # Create new Figure with black background -fig = plt.figure(figsize=(8, 8), facecolor='#aaa') +fig = plt.figure(figsize=(8, 8), facecolor="#aaa") -plt.imshow(scaledfreq, extent=[0, 512/TICKS_PER_US, labels[0], labels[-1]], cmap='jet', - vmin=0, vmax=1, origin='lower', aspect='auto') +plt.imshow( + scaledfreq, + extent=[0, 512 / TICKS_PER_US, labels[0], labels[-1]], + cmap="jet", + vmin=0, + vmax=1, + origin="lower", + aspect="auto", +) plt.colorbar() plt.ylabel("Interval period (us)") plt.xlabel("Response (us)") diff --git a/scripts/build.mk b/scripts/build.mk deleted file mode 100644 index 45505f95..00000000 --- a/scripts/build.mk +++ /dev/null @@ -1,11 +0,0 @@ -$(OBJDIR)/protoencode_ConfigProto.exe: $(OBJDIR)/scripts/protoencode_ConfigProto.o -$(OBJDIR)/protoencode_TestProto.exe: $(OBJDIR)/scripts/protoencode_TestProto.o - -$(OBJDIR)/scripts/protoencode_%.o: scripts/protoencode.cc - @mkdir -p $(dir $@) - @echo CXX $< $* - @$(CXX) $(CFLAGS) -DPROTO=$* $(CXXFLAGS) -MMD -MP -MF $(@:.o=.d) -c -o $@ $< - -$(call use-library, $(OBJDIR)/protoencode_ConfigProto.exe, $(OBJDIR)/scripts/protoencode_ConfigProto.o, PROTO) -$(call use-library, $(OBJDIR)/protoencode_TestProto.exe, $(OBJDIR)/scripts/protoencode_TestProto.o, PROTO) - diff --git a/scripts/build.py b/scripts/build.py new file mode 100644 index 00000000..ec053834 --- /dev/null +++ b/scripts/build.py @@ -0,0 +1,46 @@ +from build.ab import Rule, normalrule, Targets +from build.c import cxxprogram + +encoders = {} + + +@Rule +def protoencode(self, name, srcs: Targets, proto, symbol): + if proto not in encoders: + r = cxxprogram( + name="protoencode_" + proto, + srcs=["scripts/protoencode.cc"], + cflags=["-DPROTO=" + proto], + deps=[ + "lib+config_proto_lib", + "tests+test_proto_lib", + "+protobuf_lib", + "+fmt_lib", + ], + ) + encoders[proto] = r + else: + r = encoders[proto] + r.materialise() + + normalrule( + replaces=self, + ins=srcs, + outs=[f"{name}.cc"], + deps=[r], + commands=["{deps[0]} {ins} {outs} " + symbol], + label="PROTOENCODE", + ) + + +cxxprogram( + name="mkdoc", + srcs=["./mkdoc.cc"], + deps=["src/formats", "lib+config_proto_lib", "+lib"], +) + +cxxprogram( + name="mkdocindex", + srcs=["./mkdocindex.cc"], + deps=["src/formats", "lib+config_proto_lib", "+lib"], +) diff --git a/scripts/encodedecodetest.sh b/scripts/encodedecodetest.sh index c43e6392..8bb152c2 100755 --- a/scripts/encodedecodetest.sh +++ b/scripts/encodedecodetest.sh @@ -1,22 +1,21 @@ #!/bin/sh set -e -format=$1 -tmp=/tmp/$$-$format -srcfile=$tmp.src.img -fluxfile=$tmp.$2 -destfile=$tmp.dest.img -fluxengine=$3 -shift -shift -shift +format="$1" +ext="$2" +fluxengine="$3" +script="$4" +flags="$5" +dir="$6" -trap "rm -f $srcfile $fluxfile $destfile" EXIT +srcfile=$dir.$format.src.img +fluxfile=$dir.$format.$ext +destfile=$dir.$format.dest.img dd if=/dev/urandom of=$srcfile bs=1048576 count=2 2>&1 -$fluxengine write $format -i $srcfile -d $fluxfile --drive.rotational_period_ms=200 "$@" -$fluxengine read $format -s $fluxfile -o $destfile --drive.rotational_period_ms=200 "$@" +$fluxengine write $format -i $srcfile -d $fluxfile --drive.rotational_period_ms=200 $flags +$fluxengine read $format -s $fluxfile -o $destfile --drive.rotational_period_ms=200 $flags if [ ! -s $destfile ]; then echo "Zero length output file!" >&2 exit 1 diff --git a/src/build.mk b/src/build.mk deleted file mode 100644 index 0d3dadd0..00000000 --- a/src/build.mk +++ /dev/null @@ -1,52 +0,0 @@ -include src/formats/build.mk - -FLUXENGINE_SRCS = \ - src/fe-analysedriveresponse.cc \ - src/fe-analyselayout.cc \ - src/fe-format.cc \ - src/fe-getdiskinfo.cc \ - src/fe-getfile.cc \ - src/fe-getfileinfo.cc \ - src/fe-inspect.cc \ - src/fe-ls.cc \ - src/fe-merge.cc \ - src/fe-mkdir.cc \ - src/fe-mv.cc \ - src/fe-rm.cc \ - src/fe-putfile.cc \ - src/fe-rawread.cc \ - src/fe-rawwrite.cc \ - src/fe-read.cc \ - src/fe-rpm.cc \ - src/fe-seek.cc \ - src/fe-testbandwidth.cc \ - src/fe-testvoltages.cc \ - src/fe-write.cc \ - src/fileutils.cc \ - src/fluxengine.cc \ - -FLUXENGINE_OBJS = $(patsubst %.cc, $(OBJDIR)/%.o, $(FLUXENGINE_SRCS)) -OBJS += $(FLUXENGINE_OBJS) -$(FLUXENGINE_SRCS): | $(PROTO_HDRS) -FLUXENGINE_BIN = $(OBJDIR)/fluxengine.exe -$(FLUXENGINE_BIN): $(FLUXENGINE_OBJS) - -$(call use-pkgconfig, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), fmt) -$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), AGG) -$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), LIBARCH) -$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), LIBFLUXENGINE) -$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), LIBFORMATS) -$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), LIBUSBP) -$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), PROTO) -$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), STB) -$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), FATFS) -$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), ADFLIB) -$(call use-library, $(FLUXENGINE_BIN), $(FLUXENGINE_OBJS), HFSUTILS) - -binaries: fluxengine$(EXT) - -fluxengine$(EXT): $(FLUXENGINE_BIN) - @echo CP $@ - @cp $< $@ - - diff --git a/src/build.py b/src/build.py new file mode 100644 index 00000000..ae33ae74 --- /dev/null +++ b/src/build.py @@ -0,0 +1,47 @@ +from build.c import cxxprogram + +cxxprogram( + name="fluxengine", + srcs=[ + "./fluxengine.cc", + "./fe-analysedriveresponse.cc", + "./fe-analyselayout.cc", + "./fe-format.cc", + "./fe-getdiskinfo.cc", + "./fe-getfile.cc", + "./fe-getfileinfo.cc", + "./fe-inspect.cc", + "./fe-ls.cc", + "./fe-merge.cc", + "./fe-mkdir.cc", + "./fe-mv.cc", + "./fe-putfile.cc", + "./fe-rawread.cc", + "./fe-rawwrite.cc", + "./fe-read.cc", + "./fe-rm.cc", + "./fe-rpm.cc", + "./fe-seek.cc", + "./fe-testbandwidth.cc", + "./fe-testvoltages.cc", + "./fe-write.cc", + "./fileutils.cc", + ], + cflags=["-I."], + deps=[ + "+fl2_proto_lib", + "+fmt_lib", + "+protobuf_lib", + "+protocol", + "+z_lib", + "dep/adflib", + "dep/agg", + "dep/fatfs", + "dep/hfsutils", + "dep/libusbp", + "dep/stb", + "+lib", + "lib+config_proto_lib", + "src/formats", + ], +) diff --git a/src/fe-analysedriveresponse.cc b/src/fe-analysedriveresponse.cc index a5ca645a..3841fba2 100644 --- a/src/fe-analysedriveresponse.cc +++ b/src/fe-analysedriveresponse.cc @@ -1,15 +1,15 @@ -#include "globals.h" -#include "flags.h" -#include "usb/usb.h" -#include "bitmap.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" -#include "readerwriter.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/usb/usb.h" +#include "lib/bitmap.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/readerwriter.h" #include "protocol.h" -#include "proto.h" -#include "fluxsink/fluxsink.h" -#include "dep/agg/include/agg2d.h" -#include "dep/stb/stb_image_write.h" +#include "lib/proto.h" +#include "lib/fluxsink/fluxsink.h" +#include "agg2d.h" +#include "stb_image_write.h" #include static FlagGroup flags; @@ -246,8 +246,7 @@ static void draw_x_graticules(Agg2D& painter, int mainAnalyseDriveResponse(int argc, const char* argv[]) { - globalConfig().overrides()->mutable_flux_source()->set_type( - FLUXTYPE_DRIVE); + globalConfig().overrides()->mutable_flux_source()->set_type(FLUXTYPE_DRIVE); flags.parseFlagsWithConfigFiles(argc, argv, {}); if (globalConfig()->flux_sink().type() != FLUXTYPE_DRIVE) diff --git a/src/fe-analyselayout.cc b/src/fe-analyselayout.cc index c36d2fca..f7a95a5f 100644 --- a/src/fe-analyselayout.cc +++ b/src/fe-analyselayout.cc @@ -1,14 +1,14 @@ #define _USE_MATH_DEFINES -#include "globals.h" -#include "flags.h" -#include "bitmap.h" -#include "fluxmap.h" -#include "sector.h" -#include "csvreader.h" -#include "image.h" -#include "decoders/fluxmapreader.h" -#include "dep/agg/include/agg2d.h" -#include "dep/stb/stb_image_write.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/bitmap.h" +#include "lib/fluxmap.h" +#include "lib/sector.h" +#include "lib/csvreader.h" +#include "lib/image.h" +#include "lib/decoders/fluxmapreader.h" +#include "agg2d.h" +#include "stb_image_write.h" #include #include diff --git a/src/fe-format.cc b/src/fe-format.cc index 0c744b5a..076f64b3 100644 --- a/src/fe-format.cc +++ b/src/fe-format.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "sector.h" -#include "proto.h" -#include "readerwriter.h" -#include "imagereader/imagereader.h" -#include "imagewriter/imagewriter.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/sector.h" +#include "lib/proto.h" +#include "lib/readerwriter.h" +#include "lib/imagereader/imagereader.h" +#include "lib/imagewriter/imagewriter.h" #include "lib/fluxsource/fluxsource.h" #include "lib/decoders/decoders.h" #include "fluxengine.h" diff --git a/src/fe-getdiskinfo.cc b/src/fe-getdiskinfo.cc index eba202f7..09f9ea6a 100644 --- a/src/fe-getdiskinfo.cc +++ b/src/fe-getdiskinfo.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "sector.h" -#include "proto.h" -#include "readerwriter.h" -#include "imagereader/imagereader.h" -#include "imagewriter/imagewriter.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/sector.h" +#include "lib/proto.h" +#include "lib/readerwriter.h" +#include "lib/imagereader/imagereader.h" +#include "lib/imagewriter/imagewriter.h" #include "lib/fluxsource/fluxsource.h" #include "lib/decoders/decoders.h" #include "fluxengine.h" diff --git a/src/fe-getfile.cc b/src/fe-getfile.cc index 8e480a81..9627f4ee 100644 --- a/src/fe-getfile.cc +++ b/src/fe-getfile.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "sector.h" -#include "proto.h" -#include "readerwriter.h" -#include "imagereader/imagereader.h" -#include "imagewriter/imagewriter.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/sector.h" +#include "lib/proto.h" +#include "lib/readerwriter.h" +#include "lib/imagereader/imagereader.h" +#include "lib/imagewriter/imagewriter.h" #include "lib/fluxsource/fluxsource.h" #include "lib/decoders/decoders.h" #include "fluxengine.h" diff --git a/src/fe-getfileinfo.cc b/src/fe-getfileinfo.cc index b5cb02ad..3dabbc7b 100644 --- a/src/fe-getfileinfo.cc +++ b/src/fe-getfileinfo.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "sector.h" -#include "proto.h" -#include "readerwriter.h" -#include "imagereader/imagereader.h" -#include "imagewriter/imagewriter.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/sector.h" +#include "lib/proto.h" +#include "lib/readerwriter.h" +#include "lib/imagereader/imagereader.h" +#include "lib/imagewriter/imagewriter.h" #include "lib/fluxsource/fluxsource.h" #include "lib/decoders/decoders.h" #include "fluxengine.h" diff --git a/src/fe-inspect.cc b/src/fe-inspect.cc index d9847719..7514e8bf 100644 --- a/src/fe-inspect.cc +++ b/src/fe-inspect.cc @@ -1,15 +1,15 @@ -#include "globals.h" -#include "flags.h" -#include "readerwriter.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" -#include "decoders/fluxdecoder.h" -#include "decoders/decoders.h" -#include "fluxsource/fluxsource.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/readerwriter.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" +#include "lib/decoders/fluxdecoder.h" +#include "lib/decoders/decoders.h" +#include "lib/fluxsource/fluxsource.h" #include "protocol.h" -#include "decoders/rawbits.h" -#include "sector.h" -#include "proto.h" +#include "lib/decoders/rawbits.h" +#include "lib/sector.h" +#include "lib/proto.h" static FlagGroup flags; @@ -131,8 +131,7 @@ static nanoseconds_t guessClock(const Fluxmap& fluxmap) int mainInspect(int argc, const char* argv[]) { - globalConfig().overrides()->mutable_flux_source()->set_type( - FLUXTYPE_DRIVE); + globalConfig().overrides()->mutable_flux_source()->set_type(FLUXTYPE_DRIVE); flags.parseFlagsWithConfigFiles(argc, argv, {}); auto& fluxSource = globalConfig().getFluxSource(); diff --git a/src/fe-ls.cc b/src/fe-ls.cc index d6d9a2cf..4a2869b2 100644 --- a/src/fe-ls.cc +++ b/src/fe-ls.cc @@ -1,9 +1,9 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "sector.h" -#include "proto.h" -#include "readerwriter.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/sector.h" +#include "lib/proto.h" +#include "lib/readerwriter.h" #include "lib/decoders/decoders.h" #include "lib/fluxsource/fluxsource.h" #include "lib/imagereader/imagereader.h" @@ -57,8 +57,8 @@ int mainLs(int argc, const char* argv[]) quote(dirent->filename), maxlen + 2, dirent->length, - dirent->mode, - dirent->attributes[Filesystem::CTIME]); + dirent->mode, + dirent->attributes[Filesystem::CTIME]); total += dirent->length; } fmt::print("({} files, {} bytes)\n", files.size(), total); diff --git a/src/fe-merge.cc b/src/fe-merge.cc index 2430f879..4afc1bff 100644 --- a/src/fe-merge.cc +++ b/src/fe-merge.cc @@ -1,12 +1,12 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "sector.h" -#include "proto.h" -#include "flux.h" -#include "fl2.h" -#include "fl2.pb.h" -#include "fluxengine.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/sector.h" +#include "lib/proto.h" +#include "lib/flux.h" +#include "lib/fl2.h" +#include "lib/fl2.pb.h" +#include "src/fluxengine.h" #include static FlagGroup flags; diff --git a/src/fe-mkdir.cc b/src/fe-mkdir.cc index 1db49266..bb2f08ee 100644 --- a/src/fe-mkdir.cc +++ b/src/fe-mkdir.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "flags.h" -#include "proto.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/proto.h" #include "fluxengine.h" #include "lib/vfs/vfs.h" #include "lib/utils.h" diff --git a/src/fe-mv.cc b/src/fe-mv.cc index 8f13efa8..e61658f1 100644 --- a/src/fe-mv.cc +++ b/src/fe-mv.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "flags.h" -#include "proto.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/proto.h" #include "fluxengine.h" #include "lib/vfs/vfs.h" #include "lib/utils.h" diff --git a/src/fe-putfile.cc b/src/fe-putfile.cc index 0712bdcf..0f161e37 100644 --- a/src/fe-putfile.cc +++ b/src/fe-putfile.cc @@ -1,11 +1,11 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "sector.h" -#include "proto.h" -#include "readerwriter.h" -#include "imagereader/imagereader.h" -#include "imagewriter/imagewriter.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/sector.h" +#include "lib/proto.h" +#include "lib/readerwriter.h" +#include "lib/imagereader/imagereader.h" +#include "lib/imagewriter/imagewriter.h" #include "lib/fluxsource/fluxsource.h" #include "lib/decoders/decoders.h" #include "fluxengine.h" diff --git a/src/fe-rawread.cc b/src/fe-rawread.cc index 618425c9..3374e8b5 100644 --- a/src/fe-rawread.cc +++ b/src/fe-rawread.cc @@ -1,16 +1,13 @@ -#include "globals.h" -#include "flags.h" -#include "readerwriter.h" -#include "fluxmap.h" -#include "decoders/decoders.h" -#include "macintosh/macintosh.h" -#include "sector.h" -#include "proto.h" -#include "fluxsink/fluxsink.h" -#include "fluxsource/fluxsource.h" -#include "arch/brother/brother.h" -#include "arch/ibm/ibm.h" -#include "imagewriter/imagewriter.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/readerwriter.h" +#include "lib/fluxmap.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" +#include "lib/proto.h" +#include "lib/fluxsink/fluxsink.h" +#include "lib/fluxsource/fluxsource.h" +#include "lib/imagewriter/imagewriter.h" #include "fluxengine.h" #include #include @@ -56,8 +53,7 @@ int mainRawRead(int argc, const char* argv[]) if (argc == 1) showProfiles("rawread", formats); - globalConfig().overrides()->mutable_flux_source()->set_type( - FLUXTYPE_DRIVE); + globalConfig().overrides()->mutable_flux_source()->set_type(FLUXTYPE_DRIVE); flags.parseFlagsWithConfigFiles(argc, argv, formats); if (globalConfig()->flux_sink().type() == FLUXTYPE_DRIVE) diff --git a/src/fe-rawwrite.cc b/src/fe-rawwrite.cc index 4731d756..4fbe53f8 100644 --- a/src/fe-rawwrite.cc +++ b/src/fe-rawwrite.cc @@ -1,9 +1,9 @@ -#include "globals.h" -#include "flags.h" -#include "readerwriter.h" -#include "fluxmap.h" -#include "sector.h" -#include "proto.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/readerwriter.h" +#include "lib/fluxmap.h" +#include "lib/sector.h" +#include "lib/proto.h" #include "lib/fluxsource/fluxsource.h" #include "lib/fluxsink/fluxsink.h" #include "fluxengine.h" @@ -59,8 +59,7 @@ int mainRawWrite(int argc, const char* argv[]) if (argc == 1) showProfiles("rawwrite", formats); - globalConfig().overrides()->mutable_flux_sink()->set_type( - FLUXTYPE_DRIVE); + globalConfig().overrides()->mutable_flux_sink()->set_type(FLUXTYPE_DRIVE); flags.parseFlagsWithConfigFiles(argc, argv, formats); if (globalConfig()->flux_source().type() == FLUXTYPE_DRIVE) diff --git a/src/fe-read.cc b/src/fe-read.cc index d0024ad6..15651387 100644 --- a/src/fe-read.cc +++ b/src/fe-read.cc @@ -1,16 +1,13 @@ -#include "globals.h" -#include "flags.h" -#include "readerwriter.h" -#include "fluxmap.h" -#include "decoders/decoders.h" -#include "macintosh/macintosh.h" -#include "sector.h" -#include "proto.h" -#include "fluxsource/fluxsource.h" -#include "fluxsink/fluxsink.h" -#include "arch/brother/brother.h" -#include "arch/ibm/ibm.h" -#include "imagewriter/imagewriter.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/readerwriter.h" +#include "lib/fluxmap.h" +#include "lib/decoders/decoders.h" +#include "lib/sector.h" +#include "lib/proto.h" +#include "lib/fluxsource/fluxsource.h" +#include "lib/fluxsink/fluxsink.h" +#include "lib/imagewriter/imagewriter.h" #include "fluxengine.h" #include #include diff --git a/src/fe-rm.cc b/src/fe-rm.cc index cb63e495..e02322a4 100644 --- a/src/fe-rm.cc +++ b/src/fe-rm.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "flags.h" -#include "proto.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/proto.h" #include "fluxengine.h" #include "lib/vfs/vfs.h" #include "lib/utils.h" diff --git a/src/fe-rpm.cc b/src/fe-rpm.cc index eac151e4..7e430457 100644 --- a/src/fe-rpm.cc +++ b/src/fe-rpm.cc @@ -1,9 +1,9 @@ -#include "globals.h" -#include "flags.h" -#include "usb/usb.h" -#include "fluxsource/fluxsource.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/usb/usb.h" +#include "lib/fluxsource/fluxsource.h" #include "protocol.h" -#include "proto.h" +#include "lib/proto.h" static FlagGroup flags; diff --git a/src/fe-seek.cc b/src/fe-seek.cc index 2f6b2df0..aebad132 100644 --- a/src/fe-seek.cc +++ b/src/fe-seek.cc @@ -1,8 +1,8 @@ -#include "globals.h" -#include "flags.h" -#include "usb/usb.h" -#include "fluxsource/fluxsource.h" -#include "proto.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/usb/usb.h" +#include "lib/fluxsource/fluxsource.h" +#include "lib/proto.h" #include "protocol.h" static FlagGroup flags; diff --git a/src/fe-testbandwidth.cc b/src/fe-testbandwidth.cc index 3059f381..0f723b73 100644 --- a/src/fe-testbandwidth.cc +++ b/src/fe-testbandwidth.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "flags.h" -#include "usb/usb.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/usb/usb.h" static FlagGroup flags; diff --git a/src/fe-testvoltages.cc b/src/fe-testvoltages.cc index 6a7d56fb..9f7c3857 100644 --- a/src/fe-testvoltages.cc +++ b/src/fe-testvoltages.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "flags.h" -#include "usb/usb.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/usb/usb.h" #include "protocol.h" static FlagGroup flags; diff --git a/src/fe-write.cc b/src/fe-write.cc index cf199c85..3221c42b 100644 --- a/src/fe-write.cc +++ b/src/fe-write.cc @@ -1,16 +1,16 @@ -#include "globals.h" -#include "flags.h" -#include "readerwriter.h" -#include "fluxmap.h" -#include "decoders/decoders.h" -#include "encoders/encoders.h" -#include "sector.h" -#include "proto.h" -#include "fluxsink/fluxsink.h" -#include "fluxsource/fluxsource.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/readerwriter.h" +#include "lib/fluxmap.h" +#include "lib/decoders/decoders.h" +#include "lib/encoders/encoders.h" +#include "lib/sector.h" +#include "lib/proto.h" +#include "lib/fluxsink/fluxsink.h" +#include "lib/fluxsource/fluxsource.h" #include "arch/brother/brother.h" #include "arch/ibm/ibm.h" -#include "imagereader/imagereader.h" +#include "lib/imagereader/imagereader.h" #include "fluxengine.h" #include #include diff --git a/src/fileutils.cc b/src/fileutils.cc index 79c12f6f..1ca1640a 100644 --- a/src/fileutils.cc +++ b/src/fileutils.cc @@ -1,9 +1,9 @@ -#include "globals.h" -#include "flags.h" -#include "fluxmap.h" -#include "sector.h" -#include "proto.h" -#include "readerwriter.h" +#include "lib/globals.h" +#include "lib/flags.h" +#include "lib/fluxmap.h" +#include "lib/sector.h" +#include "lib/proto.h" +#include "lib/readerwriter.h" #include "lib/fluxsource/fluxsource.h" #include "lib/fluxsink/fluxsink.h" #include "lib/imagereader/imagereader.h" diff --git a/src/fluxengine.cc b/src/fluxengine.cc index 4cce1a77..392dea5f 100644 --- a/src/fluxengine.cc +++ b/src/fluxengine.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "proto.h" +#include "lib/globals.h" +#include "lib/proto.h" #include typedef int command_cb(int agrc, const char* argv[]); diff --git a/src/formats/40track_drive.textpb b/src/formats/40track_drive.textpb index b4647bda..736b709d 100644 --- a/src/formats/40track_drive.textpb +++ b/src/formats/40track_drive.textpb @@ -16,8 +16,7 @@ fluxengine read ibm --180 40track_drive drive { tracks: 40 - head_width: 1 - tpi: 48 + drive_type: DRIVETYPE_40TRACK } diff --git a/src/formats/acornadfs.textpb b/src/formats/acornadfs.textpb index 1d96b9b2..de3932e0 100644 --- a/src/formats/acornadfs.textpb +++ b/src/formats/acornadfs.textpb @@ -42,7 +42,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 1 layoutdata { @@ -62,7 +62,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 1 layoutdata { @@ -82,7 +82,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { @@ -102,7 +102,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { @@ -123,7 +123,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { diff --git a/src/formats/acorndfs.textpb b/src/formats/acorndfs.textpb index 37623a70..e87e562b 100644 --- a/src/formats/acorndfs.textpb +++ b/src/formats/acorndfs.textpb @@ -78,7 +78,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 } } @@ -91,7 +91,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 } } diff --git a/src/formats/aeslanier.textpb b/src/formats/aeslanier.textpb index 1e741932..70c60e13 100644 --- a/src/formats/aeslanier.textpb +++ b/src/formats/aeslanier.textpb @@ -51,7 +51,7 @@ decoder { } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 77 sides: 1 layoutdata { diff --git a/src/formats/agat.textpb b/src/formats/agat.textpb index f7f0164c..6585ff9d 100644 --- a/src/formats/agat.textpb +++ b/src/formats/agat.textpb @@ -32,7 +32,7 @@ image_writer { } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { diff --git a/src/formats/amiga.textpb b/src/formats/amiga.textpb index dc9f717f..e23a23cc 100644 --- a/src/formats/amiga.textpb +++ b/src/formats/amiga.textpb @@ -40,7 +40,7 @@ image_writer { } layout { - tpi: 135 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { diff --git a/src/formats/ampro.textpb b/src/formats/ampro.textpb index 010f38db..1a912317 100644 --- a/src/formats/ampro.textpb +++ b/src/formats/ampro.textpb @@ -82,7 +82,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 } } @@ -94,7 +94,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 } } diff --git a/src/formats/apple2.textpb b/src/formats/apple2.textpb index 24f90891..7461b464 100644 --- a/src/formats/apple2.textpb +++ b/src/formats/apple2.textpb @@ -73,7 +73,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 35 sides: 1 layoutdata { @@ -93,7 +93,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 order: HCS diff --git a/src/formats/apple2_drive.textpb b/src/formats/apple2_drive.textpb index 0cf4b923..0527daf4 100644 --- a/src/formats/apple2_drive.textpb +++ b/src/formats/apple2_drive.textpb @@ -24,8 +24,7 @@ usb { drive { tracks: 160 heads: 1 - head_width: 4 - tpi: 192 + drive_type: DRIVETYPE_APPLE2 } diff --git a/src/formats/atarist.textpb b/src/formats/atarist.textpb index a0431b25..260ea6b9 100644 --- a/src/formats/atarist.textpb +++ b/src/formats/atarist.textpb @@ -51,7 +51,7 @@ decoder { } layout { - tpi: 135 + format_type: FORMATTYPE_80TRACK } option_group { diff --git a/src/formats/bk.textpb b/src/formats/bk.textpb index bf13827e..0db6ff16 100644 --- a/src/formats/bk.textpb +++ b/src/formats/bk.textpb @@ -28,7 +28,7 @@ image_writer { } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { diff --git a/src/formats/brother.textpb b/src/formats/brother.textpb index f5469047..08c9f915 100644 --- a/src/formats/brother.textpb +++ b/src/formats/brother.textpb @@ -141,7 +141,7 @@ option_group { config { layout { - tpi: 67.5 + format_type: FORMATTYPE_40TRACK tracks: 39 sides: 1 layoutdata { @@ -162,7 +162,7 @@ option_group { drive { head_bias: 0 - group_offset: 1 + group_offset: 0 } filesystem { @@ -178,7 +178,7 @@ option_group { config { layout { - tpi: 135 + format_type: FORMATTYPE_80TRACK tracks: 78 sides: 1 layoutdata { diff --git a/src/formats/build.mk b/src/formats/build.mk deleted file mode 100644 index c9455dd3..00000000 --- a/src/formats/build.mk +++ /dev/null @@ -1,103 +0,0 @@ -FORMATS = \ - 40track_drive \ - acornadfs \ - acorndfs \ - aeslanier \ - agat \ - amiga \ - ampro \ - apple2_drive \ - apple2 \ - atarist \ - bk \ - brother \ - commodore \ - eco1 \ - epsonpf10 \ - f85 \ - fb100 \ - hplif \ - ibm \ - icl30 \ - mac \ - micropolis \ - ms2000 \ - mx \ - n88basic \ - northstar \ - psos \ - rolandd20 \ - rx50 \ - shugart_drive \ - smaky6 \ - tids990 \ - tiki \ - victor9k \ - zilogmcz \ - -$(OBJDIR)/src/formats/format_%.o: $(OBJDIR)/src/formats/format_%.cc -$(OBJDIR)/src/formats/format_%.cc: $(OBJDIR)/protoencode_ConfigProto.exe src/formats/%.textpb - @mkdir -p $(dir $@) - @echo PROTOENCODE $* - @$^ $@ formats_$*_pb - -OBJS += $(patsubst %, $(OBJDIR)/src/formats/format_%.o, $(FORMATS)) - -$(OBJDIR)/src/formats/table.cc: scripts/mktable.sh src/formats/build.mk - @mkdir -p $(dir $@) - @echo MKTABLE $@ - @scripts/mktable.sh formats $(FORMATS) > $@ - -LIBFORMATS_SRCS = \ - $(patsubst %, $(OBJDIR)/src/formats/format_%.cc, $(FORMATS)) \ - $(OBJDIR)/src/formats/table.cc -LIBFORMATS_OBJS = $(patsubst %.cc, %.o, $(LIBFORMATS_SRCS)) -.PRECIOUS: $(LIBFORMATS_SRCS) - -LIBFORMATS_LIB = $(OBJDIR)/libformats.a -LIBFORMATS_LDFLAGS = -$(LIBFORMATS_LIB): $(LIBFORMATS_OBJS) - - -$(OBJDIR)/mkdoc.exe: $(OBJDIR)/scripts/mkdoc.o - -$(OBJDIR)/scripts/mkdoc.o: scripts/mkdoc.cc - @mkdir -p $(dir $@) - @echo CXX $< $* - @$(CXX) $(CFLAGS) -DPROTO=$* $(CXXFLAGS) -MMD -MP -MF $(@:.o=.d) -c -o $@ $< - -$(call use-library, $(OBJDIR)/mkdoc.exe, $(OBJDIR)/scripts/mkdoc.o, PROTO) -$(call use-library, $(OBJDIR)/mkdoc.exe, $(OBJDIR)/scripts/mkdoc.o, LIBFORMATS) -$(call use-library, $(OBJDIR)/mkdoc.exe, $(OBJDIR)/scripts/mkdoc.o, LIBFLUXENGINE) - - -docs: $(patsubst %, doc/disk-%.md, $(FORMATS)) - -doc/disk-%.md: src/formats/%.textpb $(OBJDIR)/mkdoc.exe - @echo MKDOC $@ - @mkdir -p $(dir $@) - @$(OBJDIR)/mkdoc.exe $* > $@ - - -$(OBJDIR)/mkdocindex.exe: $(OBJDIR)/scripts/mkdocindex.o - -$(OBJDIR)/scripts/mkdocindex.o: scripts/mkdocindex.cc - -$(call use-library, $(OBJDIR)/mkdocindex.exe, $(OBJDIR)/scripts/mkdocindex.o, PROTO) -$(call use-library, $(OBJDIR)/mkdocindex.exe, $(OBJDIR)/scripts/mkdocindex.o, LIBFORMATS) -$(call use-library, $(OBJDIR)/mkdocindex.exe, $(OBJDIR)/scripts/mkdocindex.o, LIBFLUXENGINE) - - -docs: $(patsubst %, doc/disk-%.md, $(FORMATS)) - -doc/disk-%.md: src/formats/%.textpb $(OBJDIR)/mkdoc.exe - @echo MKDOC $@ - @mkdir -p $(dir $@) - @$(OBJDIR)/mkdoc.exe $* > $@ - -docs: README.md -README.md: $(OBJDIR)/mkdocindex.exe - @echo MKDOCINDEX $@ - @csplit -s -f$(OBJDIR)/README. README.md '//' '%%' - @(cat $(OBJDIR)/README.00 && $(OBJDIR)/mkdocindex.exe && cat $(OBJDIR)/README.01) > README.md - diff --git a/src/formats/build.py b/src/formats/build.py new file mode 100644 index 00000000..7331080c --- /dev/null +++ b/src/formats/build.py @@ -0,0 +1,82 @@ +from build.ab import normalrule, export +from build.c import cxxlibrary +from scripts.build import protoencode + +formats = [ + "40track_drive", + "acornadfs", + "acorndfs", + "aeslanier", + "agat", + "amiga", + "ampro", + "apple2_drive", + "apple2", + "atarist", + "bk", + "brother", + "commodore", + "eco1", + "epsonpf10", + "f85", + "fb100", + "hplif", + "ibm", + "icl30", + "mac", + "micropolis", + "ms2000", + "mx", + "n88basic", + "northstar", + "psos", + "rolandd20", + "rx50", + "shugart_drive", + "smaky6", + "tids990", + "tiki", + "victor9k", + "zilogmcz", +] + +normalrule( + name="table_cc", + ins=[f"./{name}.textpb" for name in formats], + deps=["scripts/mktable.sh"], + outs=["table.cc"], + commands=[ + "sh scripts/mktable.sh formats " + (" ".join(formats)) + " > {outs}" + ], + label="MKTABLE", +) + +encoded = [ + protoencode( + name=f"{name}_cc", + srcs=[f"./{name}.textpb"], + proto="ConfigProto", + symbol=f"formats_{name}_pb", + ) + for name in formats +] + +cxxlibrary( + name="formats", + srcs=[".+table_cc"] + encoded, + deps=["+lib", "lib+config_proto_lib"], +) + +export( + name="docs", + items={ + f"doc/disk-{f}.md": normalrule( + name=f"{f}_doc", + ins=["scripts+mkdoc"], + outs=[f"disk-{f}.md"], + commands=["{ins[0]} " + f + " | tr -d '\\r' > {outs[0]}"], + label="MKDOC", + ) + for f in formats + }, +) diff --git a/src/formats/commodore.textpb b/src/formats/commodore.textpb index 081ed1bc..3748e016 100644 --- a/src/formats/commodore.textpb +++ b/src/formats/commodore.textpb @@ -76,7 +76,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 35 sides: 1 layoutdata { @@ -132,7 +132,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 1 layoutdata { @@ -188,7 +188,7 @@ option_group { config { layout { - tpi: 135 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 swap_sides: true @@ -230,7 +230,7 @@ option_group { config { layout { - tpi: 100 + format_type: FORMATTYPE_80TRACK sides: 2 tracks: 77 layoutdata { @@ -282,7 +282,7 @@ option_group { config { layout { - tpi: 135 + format_type: FORMATTYPE_80TRACK tracks: 81 sides: 2 swap_sides: true diff --git a/src/formats/eco1.textpb b/src/formats/eco1.textpb index 20e565f1..311aae32 100644 --- a/src/formats/eco1.textpb +++ b/src/formats/eco1.textpb @@ -41,7 +41,7 @@ image_writer { } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 77 sides: 2 layoutdata { diff --git a/src/formats/epsonpf10.textpb b/src/formats/epsonpf10.textpb index ce660a4a..915e3ba3 100644 --- a/src/formats/epsonpf10.textpb +++ b/src/formats/epsonpf10.textpb @@ -15,7 +15,7 @@ image_writer { } layout { - tpi: 67.5 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 2 layoutdata { diff --git a/src/formats/f85.textpb b/src/formats/f85.textpb index d73feb1b..8dc81aae 100644 --- a/src/formats/f85.textpb +++ b/src/formats/f85.textpb @@ -50,7 +50,7 @@ decoder { } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 77 sides: 1 layoutdata { diff --git a/src/formats/fb100.textpb b/src/formats/fb100.textpb index c848d201..6940f7e5 100644 --- a/src/formats/fb100.textpb +++ b/src/formats/fb100.textpb @@ -51,7 +51,7 @@ decoder { } layout { - tpi: 67.5 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 1 layoutdata { diff --git a/src/formats/hplif.textpb b/src/formats/hplif.textpb index 88dc2faa..aadfb61d 100644 --- a/src/formats/hplif.textpb +++ b/src/formats/hplif.textpb @@ -46,7 +46,7 @@ filesystem { } layout { - tpi: 135 + format_type: FORMATTYPE_80TRACK } option_group { diff --git a/src/formats/ibm.textpb b/src/formats/ibm.textpb index 90c60138..a6a976d6 100644 --- a/src/formats/ibm.textpb +++ b/src/formats/ibm.textpb @@ -110,7 +110,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK } } } @@ -121,7 +121,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 1 layoutdata { @@ -150,7 +150,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 1 layoutdata { @@ -179,7 +179,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 2 layoutdata { @@ -208,7 +208,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 2 layoutdata { @@ -237,7 +237,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { @@ -266,7 +266,7 @@ option_group { config { layout { - tpi: 135 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { @@ -295,7 +295,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { @@ -324,7 +324,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 77 sides: 2 layoutdata { @@ -353,7 +353,7 @@ option_group { config { layout { - tpi: 135 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { @@ -382,7 +382,7 @@ option_group { config { layout { - tpi: 135 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { diff --git a/src/formats/icl30.textpb b/src/formats/icl30.textpb index 99726e26..d1692ac3 100644 --- a/src/formats/icl30.textpb +++ b/src/formats/icl30.textpb @@ -15,7 +15,7 @@ image_writer { } layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 35 sides: 2 layoutdata { diff --git a/src/formats/mac.textpb b/src/formats/mac.textpb index 0384e24c..6f8872fd 100644 --- a/src/formats/mac.textpb +++ b/src/formats/mac.textpb @@ -70,7 +70,7 @@ image_writer { } layout { - tpi: 135 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { diff --git a/src/formats/micropolis.textpb b/src/formats/micropolis.textpb index 3c95443c..dd445c62 100644 --- a/src/formats/micropolis.textpb +++ b/src/formats/micropolis.textpb @@ -142,7 +142,7 @@ option_group { config { layout { - tpi: 50 + format_type: FORMATTYPE_40TRACK tracks: 35 sides: 1 } @@ -156,7 +156,7 @@ option_group { config { layout { - tpi: 50 + format_type: FORMATTYPE_40TRACK tracks: 35 sides: 2 } @@ -169,7 +169,7 @@ option_group { config { layout { - tpi: 100 + format_type: FORMATTYPE_80TRACK tracks: 77 sides: 1 } @@ -182,7 +182,7 @@ option_group { config { layout { - tpi: 100 + format_type: FORMATTYPE_80TRACK tracks: 77 sides: 2 } diff --git a/src/formats/ms2000.textpb b/src/formats/ms2000.textpb index 0e85b60d..f677f415 100644 --- a/src/formats/ms2000.textpb +++ b/src/formats/ms2000.textpb @@ -41,7 +41,7 @@ image_writer { layout { tracks: 70 sides: 1 - tpi: 135 + format_type: FORMATTYPE_80TRACK layoutdata { sector_size: 512 physical { diff --git a/src/formats/mx.textpb b/src/formats/mx.textpb index 6cbcca2e..6620f6f4 100644 --- a/src/formats/mx.textpb +++ b/src/formats/mx.textpb @@ -83,7 +83,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 1 } @@ -96,7 +96,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 2 } @@ -109,7 +109,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 1 } @@ -123,7 +123,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 } diff --git a/src/formats/n88basic.textpb b/src/formats/n88basic.textpb index 053c34fb..1a21f79c 100644 --- a/src/formats/n88basic.textpb +++ b/src/formats/n88basic.textpb @@ -28,7 +28,7 @@ image_writer { } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 77 sides: 2 layoutdata { diff --git a/src/formats/northstar.textpb b/src/formats/northstar.textpb index 0516f6a4..fca37c42 100644 --- a/src/formats/northstar.textpb +++ b/src/formats/northstar.textpb @@ -44,7 +44,7 @@ image_writer { } layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK layoutdata { physical { start_sector: 0 diff --git a/src/formats/psos.textpb b/src/formats/psos.textpb index ba4b75c9..4bf9afaa 100644 --- a/src/formats/psos.textpb +++ b/src/formats/psos.textpb @@ -35,7 +35,7 @@ image_writer { } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 order: HCS diff --git a/src/formats/rolandd20.textpb b/src/formats/rolandd20.textpb index 19c670a1..e1d5367d 100644 --- a/src/formats/rolandd20.textpb +++ b/src/formats/rolandd20.textpb @@ -46,7 +46,7 @@ image_writer { } layout { - tpi: 135 + format_type: FORMATTYPE_80TRACK tracks: 78 sides: 1 layoutdata { diff --git a/src/formats/rx50.textpb b/src/formats/rx50.textpb index 93457074..ea049a5e 100644 --- a/src/formats/rx50.textpb +++ b/src/formats/rx50.textpb @@ -25,7 +25,7 @@ image_writer { } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 1 layoutdata { diff --git a/src/formats/smaky6.textpb b/src/formats/smaky6.textpb index 0df3d3bb..cc076a76 100644 --- a/src/formats/smaky6.textpb +++ b/src/formats/smaky6.textpb @@ -33,7 +33,7 @@ image_writer { } layout { - tpi: 100 + format_type: FORMATTYPE_80TRACK tracks: 77 sides: 1 layoutdata { diff --git a/src/formats/tids990.textpb b/src/formats/tids990.textpb index acb739db..f59ab874 100644 --- a/src/formats/tids990.textpb +++ b/src/formats/tids990.textpb @@ -40,7 +40,7 @@ image_writer { } layout { - tpi: 48 + format_type: FORMATTYPE_80TRACK tracks: 77 sides: 2 layoutdata { diff --git a/src/formats/tiki.textpb b/src/formats/tiki.textpb index 838749ad..34c30a47 100644 --- a/src/formats/tiki.textpb +++ b/src/formats/tiki.textpb @@ -27,7 +27,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 1 layoutdata { @@ -59,7 +59,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 1 layoutdata { @@ -91,7 +91,7 @@ option_group { config { layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 40 sides: 2 layoutdata { @@ -124,7 +124,7 @@ option_group { config { layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { diff --git a/src/formats/victor9k.textpb b/src/formats/victor9k.textpb index 1f2f9bef..c839e502 100644 --- a/src/formats/victor9k.textpb +++ b/src/formats/victor9k.textpb @@ -59,7 +59,7 @@ image_writer { } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 80 sides: 2 layoutdata { diff --git a/src/formats/zilogmcz.textpb b/src/formats/zilogmcz.textpb index c6cae4f9..29525d00 100644 --- a/src/formats/zilogmcz.textpb +++ b/src/formats/zilogmcz.textpb @@ -45,7 +45,7 @@ decoder { } layout { - tpi: 48 + format_type: FORMATTYPE_40TRACK tracks: 77 sides: 1 layoutdata { diff --git a/src/gui/browserpanel.cc b/src/gui/browserpanel.cc index 8e8e9821..69b7030e 100644 --- a/src/gui/browserpanel.cc +++ b/src/gui/browserpanel.cc @@ -1,9 +1,9 @@ -#include "globals.h" +#include "lib/globals.h" #include "lib/fluxmap.h" #include "lib/vfs/vfs.h" #include "lib/utils.h" #include "gui.h" -#include "layout.h" +#include "lib/layout.h" #include "filesystemmodel.h" #include "fileviewerwindow.h" #include "textviewerwindow.h" @@ -244,12 +244,12 @@ private: uint32_t usedBlocks = std::stoul( metadata.at(Filesystem::USED_BLOCKS)); - if (!totalBlocks) - throw std::out_of_range("no disk usage data"); + if (!totalBlocks) + throw std::out_of_range("no disk usage data"); - diskSpaceGauge->Enable(); - diskSpaceGauge->SetRange(totalBlocks); - diskSpaceGauge->SetValue(usedBlocks); + diskSpaceGauge->Enable(); + diskSpaceGauge->SetRange(totalBlocks); + diskSpaceGauge->SetValue(usedBlocks); } catch (const std::out_of_range& e) { diff --git a/src/gui/build.mk b/src/gui/build.mk deleted file mode 100644 index f2f96376..00000000 --- a/src/gui/build.mk +++ /dev/null @@ -1,103 +0,0 @@ -ifneq ($(shell $(WX_CONFIG) --version),) - -include src/gui/drivetypes/build.mk - -FLUXENGINE_GUI_SRCS = \ - src/gui/browserpanel.cc \ - src/gui/customstatusbar.cc \ - src/gui/explorerpanel.cc \ - src/gui/filesystemmodel.cc \ - src/gui/fileviewerwindow.cc \ - src/gui/fluxviewercontrol.cc \ - src/gui/fluxviewerwindow.cc \ - src/gui/histogramviewer.cc \ - src/gui/iconbutton.cc \ - src/gui/idlepanel.cc \ - src/gui/imagerpanel.cc \ - src/gui/jobqueue.cc \ - src/gui/layout.cpp \ - src/gui/main.cc \ - src/gui/mainwindow.cc \ - src/gui/texteditorwindow.cc \ - src/gui/textviewerwindow.cc \ - src/gui/visualisationcontrol.cc \ - -src/gui/idlepanel.cc: \ - $(OBJDIR)/extras/hardware.h \ - $(OBJDIR)/extras/fluxfile.h \ - $(OBJDIR)/extras/imagefile.h - -FLUXENGINE_GUI_OBJS = \ - $(patsubst %.cpp, $(OBJDIR)/%.o, \ - $(patsubst %.cc, $(OBJDIR)/%.o, $(FLUXENGINE_GUI_SRCS)) \ - ) -OBJS += $(FLUXENGINE_GUI_OBJS) -$(FLUXENGINE_GUI_SRCS): | $(PROTO_HDRS) -$(FLUXENGINE_GUI_OBJS): CFLAGS += $(shell $(WX_CONFIG) --cxxflags core base adv aui richtext) -FLUXENGINE_GUI_BIN = $(OBJDIR)/fluxengine-gui.exe -$(FLUXENGINE_GUI_BIN): LDFLAGS += $(shell $(WX_CONFIG) --libs core base adv aui richtext) -$(FLUXENGINE_GUI_BIN): $(FLUXENGINE_GUI_OBJS) - -$(call use-pkgconfig, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), fmt) -$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBARCH) -$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBFLUXENGINE) -$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBFORMATS) -$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBDRIVETYPES) -$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBUSBP) -$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), PROTO) -$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), FATFS) -$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), ADFLIB) -$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), HFSUTILS) - -binaries: fluxengine-gui$(EXT) - -fluxengine-gui$(EXT): $(FLUXENGINE_GUI_BIN) - @echo CP $@ - @cp $< $@ - -$(OBJDIR)/%.h: %.png - @echo ENCODE $@ - @mkdir -p $(dir $@) - @xxd -i $^ > $@ - -ifeq ($(PLATFORM),OSX) - -binaries: FluxEngine.pkg - -FluxEngine.pkg: FluxEngine.app - @echo PKGBUILD $@ - @pkgbuild --quiet --install-location /Applications --component $< $@ - -FluxEngine.app: fluxengine-gui$(EXT) $(OBJDIR)/fluxengine.icns src/gui/build.mk - @echo MAKEAPP $@ - rm -rf $@ - cp -a extras/FluxEngine.app.template $@ - touch $@ - cp fluxengine-gui$(EXT) $@/Contents/MacOS/fluxengine-gui - mkdir -p $@/Contents/Resources - cp $(OBJDIR)/fluxengine.icns $@/Contents/Resources/FluxEngine.icns - dylibbundler -of -x $@/Contents/MacOS/fluxengine-gui -b -d $@/Contents/libs -cd > /dev/null - cp $$(brew --prefix wxwidgets)/README.md $@/Contents/libs/wxWidgets.md - cp $$(brew --prefix protobuf)/LICENSE $@/Contents/libs/protobuf.txt - cp $$(brew --prefix fmt)/LICENSE.rst $@/Contents/libs/fmt.rst - cp $$(brew --prefix libpng)/LICENSE $@/Contents/libs/libpng.txt - cp $$(brew --prefix libjpeg)/README $@/Contents/libs/libjpeg.txt - -$(OBJDIR)/fluxengine.icns: $(OBJDIR)/fluxengine.iconset - @echo ICONUTIL $@ - @iconutil -c icns -o $@ $< - -$(OBJDIR)/fluxengine.iconset: extras/icon.png - @echo ICONSET $@ - @rm -rf $@ - @mkdir -p $@ - @sips -z 64 64 $< --out $@/icon_32x32@2x.png > /dev/null - -endif - -else - -$(warning wx-config missing, not building GUI) - -endif - diff --git a/src/gui/build.py b/src/gui/build.py new file mode 100644 index 00000000..a7118161 --- /dev/null +++ b/src/gui/build.py @@ -0,0 +1,110 @@ +from build.ab import emit, normalrule +from build.c import cxxprogram +import config + +emit( + """ +WX_CONFIG ?= wx-config +ifneq ($(strip $(shell command -v $(WX_CONFIG) >/dev/null 2>&1; echo $$?)),0) +$(error Required binary 'wx-config' not found.) +endif + +WX_CFLAGS := $(shell $(WX_CONFIG) --cxxflags core base adv aui richtext) +WX_LDFLAGS := $(shell $(WX_CONFIG) --libs core base adv aui richtext) +""" +) + +extrasrcs = [] +if config.windows: + extrasrcs += [ + normalrule( + name="rc", + ins=["./windres.rc"], + outs=["rc.o"], + deps=["./manifest.xml", "extras+fluxengine_ico"], + commands=["$(WINDRES) {ins[0]} {outs[0]}"], + label="WINDRES" + ) + ] + +cxxprogram( + name="gui", + srcs=[ + "./browserpanel.cc", + "./customstatusbar.cc", + "./explorerpanel.cc", + "./filesystemmodel.cc", + "./fileviewerwindow.cc", + "./fluxviewercontrol.cc", + "./fluxviewerwindow.cc", + "./histogramviewer.cc", + "./iconbutton.cc", + "./idlepanel.cc", + "./imagerpanel.cc", + "./jobqueue.cc", + "./main.cc", + "./mainwindow.cc", + "./texteditorwindow.cc", + "./textviewerwindow.cc", + "./visualisationcontrol.cc", + "./layout.cpp", + ] + + extrasrcs, + cflags=["$(WX_CFLAGS)"], + ldflags=["$(WX_LDFLAGS)"], + deps=[ + "+fl2_proto_lib", + "+protocol", + "dep/adflib", + "dep/fatfs", + "dep/hfsutils", + "dep/libusbp", + "extras+icons", + "+lib", + "lib+config_proto_lib", + "src/formats", + "src/gui/drivetypes", + "+z_lib", + "+fmt_lib", + "+protobuf_lib", + ], +) + +if config.osx: + normalrule( + name="fluxengine_pkg", + ins=[".+fluxengine_app"], + outs=["FluxEngine.pkg"], + commands=[ + "pkgbuild --quiet --install-location /Applications --component {ins[0]} {outs[0]}" + ], + label="PKGBUILD", + ) + + normalrule( + name="fluxengine_app", + ins=[ + ".+gui", + "extras+fluxengine_icns", + "extras/FluxEngine.app.template/", + ], + outs=["FluxEngine.app"], + commands=[ + "rm -rf {outs[0]}", + "cp -a {ins[2]} {outs[0]}", + "touch {outs[0]}", + "cp {ins[0]} {outs[0]}/Contents/MacOS/fluxengine-gui", + "mkdir -p {outs[0]}/Contents/Resources", + "cp {ins[1]} {outs[0]}/Contents/Resources/FluxEngine.icns", + "dylibbundler -of -x {outs[0]}/Contents/MacOS/fluxengine-gui -b -d {outs[0]}/Contents/libs -cd > /dev/null", + "cp $$(brew --prefix wxwidgets)/README.md $@/Contents/libs/wxWidgets.md", + "cp $$(brew --prefix protobuf)/LICENSE $@/Contents/libs/protobuf.txt", + "cp $$(brew --prefix fmt)/LICENSE.rst $@/Contents/libs/fmt.rst", + "cp $$(brew --prefix libpng)/LICENSE $@/Contents/libs/libpng.txt", + "cp $$(brew --prefix libjpeg)/README $@/Contents/libs/libjpeg.txt", + "cp $$(brew --prefix abseil)/LICENSE $@/Contents/libs/abseil.txt", + "cp $$(brew --prefix libtiff)/LICENSE.md $@/Contents/libs/libtiff.txt", + "cp $$(brew --prefix zstd)/LICENSE $@/Contents/libs/zstd.txt", + ], + label="MKAPP", + ) diff --git a/src/gui/drivetypes/35_40.textpb b/src/gui/drivetypes/35_40.textpb deleted file mode 100644 index a0e9bc39..00000000 --- a/src/gui/drivetypes/35_40.textpb +++ /dev/null @@ -1,6 +0,0 @@ -comment: '3.5" 40 track 67.5tpi' - -drive { - tpi: 67.5 -} - diff --git a/src/gui/drivetypes/35_80.textpb b/src/gui/drivetypes/35_80.textpb deleted file mode 100644 index 852ed2cb..00000000 --- a/src/gui/drivetypes/35_80.textpb +++ /dev/null @@ -1,6 +0,0 @@ -comment: '3.5" 80 track 135tpi' - -drive { - tpi: 135 -} - diff --git a/src/gui/drivetypes/40track.textpb b/src/gui/drivetypes/40track.textpb new file mode 100644 index 00000000..98280421 --- /dev/null +++ b/src/gui/drivetypes/40track.textpb @@ -0,0 +1,6 @@ +comment: '8", 5.25" or 3.5" 40 track' + +drive { + drive_type: DRIVETYPE_40TRACK +} + diff --git a/src/gui/drivetypes/525_40.textpb b/src/gui/drivetypes/525_40.textpb deleted file mode 100644 index ae0ea006..00000000 --- a/src/gui/drivetypes/525_40.textpb +++ /dev/null @@ -1,6 +0,0 @@ -comment: '5.25" 40 track 48tpi' - -drive { - tpi: 48 -} - diff --git a/src/gui/drivetypes/525_40M.textpb b/src/gui/drivetypes/525_40M.textpb deleted file mode 100644 index c34bd46c..00000000 --- a/src/gui/drivetypes/525_40M.textpb +++ /dev/null @@ -1,6 +0,0 @@ -comment: '5.25" 40 track 50tpi (Micropolis Mod-I)' - -drive { - tpi: 50 -} - diff --git a/src/gui/drivetypes/525_80.textpb b/src/gui/drivetypes/525_80.textpb deleted file mode 100644 index 4c01a16c..00000000 --- a/src/gui/drivetypes/525_80.textpb +++ /dev/null @@ -1,6 +0,0 @@ -comment: '5.25" 80 track 96tpi' - -drive { - tpi: 96 -} - diff --git a/src/gui/drivetypes/525_80M.textpb b/src/gui/drivetypes/525_80M.textpb deleted file mode 100644 index c5fec8c8..00000000 --- a/src/gui/drivetypes/525_80M.textpb +++ /dev/null @@ -1,6 +0,0 @@ -comment: '5.25" 80 track 100tpi (Micropolis Mod-II)' - -drive { - tpi: 100 -} - diff --git a/src/gui/drivetypes/80track.textpb b/src/gui/drivetypes/80track.textpb new file mode 100644 index 00000000..9c777ce0 --- /dev/null +++ b/src/gui/drivetypes/80track.textpb @@ -0,0 +1,5 @@ +comment: '8", 5.25" or 3.5" 80 track' + +drive { + drive_type: DRIVETYPE_80TRACK +} diff --git a/src/gui/drivetypes/8_38.textpb b/src/gui/drivetypes/8_38.textpb deleted file mode 100644 index bccffe4c..00000000 --- a/src/gui/drivetypes/8_38.textpb +++ /dev/null @@ -1,6 +0,0 @@ -comment: '8" 38 track 32tpi' - -drive { - tpi: 32 -} - diff --git a/src/gui/drivetypes/8_77.textpb b/src/gui/drivetypes/8_77.textpb deleted file mode 100644 index dd3a2d51..00000000 --- a/src/gui/drivetypes/8_77.textpb +++ /dev/null @@ -1,6 +0,0 @@ -comment: '8" 77 track 48tpi' - -drive { - tpi: 48 -} - diff --git a/src/gui/drivetypes/apple2.textpb b/src/gui/drivetypes/apple2.textpb index 1967af6c..e8d933ce 100644 --- a/src/gui/drivetypes/apple2.textpb +++ b/src/gui/drivetypes/apple2.textpb @@ -9,7 +9,6 @@ usb { drive { tracks: 160 heads: 1 - head_width: 4 - tpi: 192 + drive_type: DRIVETYPE_APPLE2 } diff --git a/src/gui/drivetypes/build.mk b/src/gui/drivetypes/build.mk deleted file mode 100644 index c65ea14f..00000000 --- a/src/gui/drivetypes/build.mk +++ /dev/null @@ -1,33 +0,0 @@ -DRIVETYPES = \ - 35_40 \ - 35_80 \ - 525_40 \ - 525_40M \ - 525_80 \ - 525_80M \ - 8_38 \ - 8_77 \ - apple2 \ - -$(OBJDIR)/src/gui/drivetypes/drivetype_%.o: $(OBJDIR)/src/gui/drivetypes/drivetype_%.cc -$(OBJDIR)/src/gui/drivetypes/drivetype_%.cc: $(OBJDIR)/protoencode_ConfigProto.exe src/gui/drivetypes/%.textpb - @mkdir -p $(dir $@) - @echo PROTOENCODE $* - @$^ $@ drivetypes_$*_pb - -$(OBJDIR)/src/gui/drivetypes/table.cc: scripts/mktable.sh src/gui/drivetypes/build.mk \ - $(patsubst %,src/gui/drivetypes/%.textpb,$(DRIVETYPES)) - @mkdir -p $(dir $@) - @echo MKTABLE $@ - @scripts/mktable.sh drivetypes $(DRIVETYPES) > $@ - -LIBDRIVETYPES_SRCS = \ - $(patsubst %, $(OBJDIR)/src/gui/drivetypes/drivetype_%.cc, $(DRIVETYPES)) \ - $(OBJDIR)/src/gui/drivetypes/table.cc -LIBDRIVETYPES_OBJS = $(patsubst %.cc, %.o, $(LIBDRIVETYPES_SRCS)) -.PRECIOUS: $(LIBDRIVETYPES_SRCS) - -LIBDRIVETYPES_LIB = $(OBJDIR)/libgui/drivetypes.a -LIBDRIVETYPES_LDFLAGS = $(LIBDRIVETYPES_LIB) -$(LIBDRIVETYPES_LIB): $(LIBDRIVETYPES_OBJS) - diff --git a/src/gui/drivetypes/build.py b/src/gui/drivetypes/build.py new file mode 100644 index 00000000..0e950c9a --- /dev/null +++ b/src/gui/drivetypes/build.py @@ -0,0 +1,34 @@ +from build.ab import normalrule +from build.c import cxxlibrary +from scripts.build import protoencode + +drivetypes = [ + "40track", + "80track", + "apple2", +] + +normalrule( + name="drivetypes_cc", + ins=[f"./{name}.textpb" for name in drivetypes], + deps=["scripts/mktable.sh"], + outs=["table.cc"], + commands=[ + "sh scripts/mktable.sh drivetypes " + + (" ".join(drivetypes)) + + " > {outs}" + ], + label="MKTABLE", +) + +encoded = [ + protoencode( + name=f"{name}_cc", + srcs=[f"./{name}.textpb"], + proto="ConfigProto", + symbol=f"drivetypes_{name}_pb", + ) + for name in drivetypes +] + +cxxlibrary(name="drivetypes", srcs=[".+drivetypes_cc"] + encoded) diff --git a/src/gui/fileviewerwindow.cc b/src/gui/fileviewerwindow.cc index 59694401..e0d2b687 100644 --- a/src/gui/fileviewerwindow.cc +++ b/src/gui/fileviewerwindow.cc @@ -2,7 +2,7 @@ #include "lib/utils.h" #include "lib/bytes.h" #include "gui.h" -#include "layout.h" +#include "lib/layout.h" #include "fileviewerwindow.h" FileViewerWindow::FileViewerWindow( diff --git a/src/gui/fluxviewercontrol.cc b/src/gui/fluxviewercontrol.cc index 77fb28c9..cd548add 100644 --- a/src/gui/fluxviewercontrol.cc +++ b/src/gui/fluxviewercontrol.cc @@ -1,4 +1,4 @@ -#include "globals.h" +#include "lib/globals.h" #include "gui.h" #include "fluxviewercontrol.h" #include "textviewerwindow.h" diff --git a/src/gui/fluxviewerwindow.cc b/src/gui/fluxviewerwindow.cc index 7b113581..1fcdbee2 100644 --- a/src/gui/fluxviewerwindow.cc +++ b/src/gui/fluxviewerwindow.cc @@ -1,6 +1,6 @@ -#include "globals.h" +#include "lib/globals.h" #include "gui.h" -#include "layout.h" +#include "lib/layout.h" #include "fluxviewerwindow.h" #include "fluxviewercontrol.h" #include "lib/flux.h" diff --git a/src/gui/icon.png.h b/src/gui/icon.png.h index 4d76b49a..83326b5c 100644 --- a/src/gui/icon.png.h +++ b/src/gui/icon.png.h @@ -5,113 +5,968 @@ #include #include -static const unsigned char icon_png[] = -{ - 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, - 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x40, - 0x00, 0x00, 0x00, 0x40, 0x08, 0x06, 0x00, 0x00, 0x00, 0xAA, - 0x69, 0x71, 0xDE, 0x00, 0x00, 0x03, 0x80, 0x49, 0x44, 0x41, - 0x54, 0x78, 0x9C, 0xD5, 0x9B, 0x5B, 0x9A, 0xA3, 0x20, 0x10, - 0x85, 0x0F, 0xF3, 0xCD, 0x6A, 0xDC, 0x4F, 0xBB, 0x9D, 0x90, - 0xED, 0x98, 0xFD, 0x64, 0x3B, 0xCC, 0x43, 0x02, 0x2D, 0x25, - 0x97, 0x2A, 0x28, 0xC0, 0x39, 0x2F, 0x1D, 0x6D, 0x29, 0xF8, - 0x8F, 0x65, 0x81, 0xC6, 0x00, 0x6B, 0xE5, 0x16, 0xF7, 0x8F, - 0x3F, 0x0B, 0xFB, 0x76, 0xD6, 0x5A, 0x60, 0xB1, 0x09, 0x66, - 0x51, 0xBF, 0x1E, 0x1E, 0x00, 0xF0, 0xFD, 0xBC, 0x64, 0x2C, - 0x2B, 0x3A, 0x8D, 0xE0, 0xBD, 0x56, 0x99, 0x30, 0xBB, 0xC3, - 0x24, 0xBC, 0xD7, 0x0A, 0x13, 0x66, 0xD6, 0x80, 0x22, 0xFC, - 0xE7, 0x08, 0x07, 0x4C, 0xAE, 0x09, 0xB3, 0xDC, 0xAE, 0xC2, - 0xDB, 0xC7, 0xE3, 0x77, 0xC3, 0x18, 0x60, 0xD2, 0xD8, 0x66, - 0x74, 0x22, 0x83, 0xF7, 0x9A, 0x64, 0xC2, 0xE8, 0x0E, 0xDA, - 0xE0, 0xBD, 0x26, 0x98, 0x30, 0x32, 0x78, 0x1F, 0xBC, 0xD7, - 0x60, 0x13, 0x46, 0x05, 0xD6, 0x81, 0xF7, 0x1A, 0x68, 0xC2, - 0x88, 0x59, 0xA0, 0x09, 0xDE, 0x9A, 0x67, 0x21, 0xE2, 0xB8, - 0xD9, 0x41, 0xDB, 0x80, 0x66, 0x78, 0xEB, 0x1E, 0x97, 0x7D, - 0x71, 0xE4, 0x31, 0x26, 0xFC, 0x55, 0x8C, 0xA5, 0x72, 0xE6, - 0xFD, 0x36, 0x35, 0xE4, 0xD3, 0x83, 0x03, 0x8C, 0x71, 0x50, - 0xBC, 0x1C, 0xB4, 0x02, 0xA9, 0xA6, 0x7D, 0x12, 0xFE, 0x2C, - 0xC5, 0x9A, 0xA0, 0x11, 0x64, 0x2E, 0xBC, 0x97, 0x92, 0x09, - 0xBD, 0x01, 0xD6, 0xC0, 0x7B, 0x29, 0x98, 0xD0, 0x53, 0x04, - 0xF5, 0xAB, 0xBD, 0x78, 0x04, 0xFD, 0x85, 0xB1, 0xD5, 0x3D, - 0x75, 0xF8, 0xDC, 0xD9, 0x2F, 0x16, 0x45, 0xAF, 0x8E, 0x4C, - 0x68, 0x69, 0x34, 0xF4, 0xCC, 0x5B, 0xF7, 0x08, 0xD3, 0x22, - 0x0B, 0xDE, 0xAB, 0xD1, 0x04, 0x69, 0x83, 0x25, 0x69, 0x3F, - 0xB2, 0x30, 0x4A, 0x6A, 0x40, 0xD7, 0x22, 0x27, 0x05, 0xC1, - 0x01, 0x4B, 0xB6, 0xCB, 0x19, 0xDA, 0x50, 0x13, 0xB8, 0x0B, - 0xA1, 0xE6, 0xB5, 0x7D, 0x2B, 0x78, 0xB6, 0x6D, 0x62, 0xD5, - 0x18, 0x49, 0xB8, 0x58, 0xE2, 0x64, 0x40, 0xFD, 0x49, 0x0E, - 0x00, 0xFB, 0x2C, 0xA7, 0x79, 0xEE, 0x7A, 0x2E, 0xC1, 0x84, - 0x36, 0xE4, 0x6F, 0xED, 0x78, 0x49, 0x26, 0xD4, 0x5C, 0x62, - 0xC1, 0x47, 0x83, 0xC8, 0x65, 0x42, 0xE6, 0xCC, 0xB5, 0xD6, - 0x87, 0xD4, 0xBD, 0xC3, 0x25, 0x3E, 0xA3, 0x26, 0x94, 0x32, - 0xA0, 0x0A, 0xBF, 0x6D, 0x1B, 0xB6, 0x6D, 0x8B, 0x07, 0x92, - 0xC8, 0x84, 0x52, 0xDA, 0x4A, 0x32, 0x22, 0xDB, 0x26, 0x17, - 0x9F, 0x91, 0x09, 0x39, 0x77, 0x58, 0xF0, 0x67, 0xBD, 0xDF, - 0xEF, 0x78, 0x50, 0xCC, 0xFB, 0xFD, 0x73, 0x06, 0x9C, 0x21, - 0xB8, 0xAB, 0xC5, 0x6A, 0x4D, 0x00, 0x8A, 0x99, 0x90, 0xCA, - 0x00, 0x31, 0x3C, 0x10, 0x1E, 0x69, 0xFF, 0x6E, 0x57, 0x6A, - 0x02, 0xD0, 0x0E, 0x7F, 0xAE, 0x09, 0xAC, 0x82, 0x5A, 0xC8, - 0x04, 0xEA, 0x4A, 0x13, 0xFC, 0xBE, 0xEF, 0x70, 0xCE, 0xC1, - 0x18, 0x73, 0x35, 0xA2, 0x90, 0x09, 0xC5, 0x4B, 0x83, 0x51, - 0x1B, 0xC4, 0xB3, 0x44, 0x22, 0x13, 0xCE, 0x19, 0xD0, 0x05, - 0x0F, 0x00, 0xCE, 0x39, 0x51, 0x26, 0xF4, 0xC2, 0xA7, 0x66, - 0x89, 0x6C, 0xCC, 0xE7, 0xD3, 0x8F, 0x2D, 0xCA, 0x84, 0xB3, - 0x1B, 0x45, 0x03, 0x6A, 0xF0, 0x51, 0x50, 0x61, 0x26, 0x44, - 0xC7, 0xD1, 0x07, 0x24, 0x27, 0xD0, 0x6A, 0xDB, 0x02, 0x7C, - 0xB4, 0x7D, 0xFA, 0x06, 0x8A, 0xB5, 0x12, 0x94, 0xC0, 0x03, - 0xF2, 0x4C, 0x08, 0xC7, 0x90, 0x55, 0xA3, 0xE4, 0xF6, 0x98, - 0x0B, 0x0F, 0x20, 0xCA, 0x84, 0xAA, 0x01, 0x12, 0xF8, 0xD7, - 0xEB, 0x15, 0x3E, 0xB7, 0x98, 0x10, 0x15, 0x42, 0x52, 0xF0, - 0xB8, 0xED, 0x72, 0xFD, 0x59, 0x6B, 0xA3, 0x6B, 0xDF, 0x9B, - 0x50, 0x34, 0xA0, 0x05, 0xBE, 0xD7, 0x04, 0xAA, 0x5A, 0x36, - 0x48, 0xE0, 0xCF, 0x26, 0xF8, 0xCB, 0x20, 0x3B, 0x0B, 0xB4, - 0x9E, 0x79, 0xAF, 0x9F, 0x9F, 0x9F, 0xF0, 0xB9, 0xB7, 0x26, - 0xE4, 0xEA, 0x80, 0x30, 0xED, 0x8D, 0xB5, 0xD6, 0x7D, 0x3F, - 0x03, 0xDF, 0x1A, 0x90, 0x5A, 0x1C, 0xB8, 0xE3, 0x38, 0x2E, - 0x3B, 0x25, 0xF0, 0x5E, 0xBD, 0x26, 0xD0, 0xAA, 0x9E, 0x5B, - 0x37, 0x44, 0x6D, 0x6A, 0x97, 0x19, 0xF9, 0x0A, 0x3E, 0x75, - 0x09, 0x98, 0x7D, 0xDF, 0xA3, 0x1D, 0x2D, 0xF0, 0x54, 0xE2, - 0x29, 0x72, 0x02, 0xFC, 0x65, 0x83, 0xC8, 0x1D, 0xC7, 0xD1, - 0x0C, 0x7F, 0x3E, 0xFB, 0x51, 0x87, 0x8C, 0x4C, 0x28, 0xDD, - 0x38, 0x69, 0xC2, 0x27, 0x77, 0x10, 0x39, 0x4D, 0xF8, 0xD0, - 0x69, 0xC1, 0x84, 0x99, 0xF0, 0xD9, 0x9D, 0x44, 0x91, 0x09, - 0xBD, 0xF0, 0xA1, 0x63, 0x41, 0x4D, 0x18, 0x05, 0x5F, 0xFC, - 0x07, 0x51, 0x30, 0x81, 0x5B, 0xF4, 0x38, 0xEA, 0x99, 0x1D, - 0x80, 0x7E, 0xF8, 0xEA, 0x3F, 0x89, 0x8A, 0x26, 0x48, 0xE1, - 0xC3, 0x00, 0x1A, 0x4D, 0xD0, 0x80, 0x67, 0x1D, 0x40, 0x94, - 0x34, 0xA1, 0x15, 0x3E, 0x0C, 0x42, 0x7A, 0x17, 0xA9, 0x04, - 0xCF, 0x3E, 0x88, 0x28, 0x32, 0xA1, 0x17, 0x3E, 0x0C, 0x84, - 0x69, 0x82, 0x26, 0xBC, 0xE8, 0x40, 0xA2, 0xE4, 0xEC, 0x00, - 0x7C, 0x40, 0x72, 0xFF, 0xAB, 0x0E, 0xA6, 0x62, 0x82, 0x36, - 0xBC, 0xF8, 0x60, 0xA2, 0xA9, 0x26, 0x8C, 0x80, 0x6F, 0x6A, - 0x40, 0x14, 0x4C, 0xA0, 0xD0, 0xAD, 0x26, 0x18, 0x63, 0x70, - 0x1C, 0xC7, 0xE5, 0x19, 0x63, 0x49, 0x3D, 0x6F, 0x98, 0xAA, - 0xBC, 0x1F, 0xA0, 0x65, 0x82, 0x87, 0xF7, 0xE2, 0x98, 0xD0, - 0xFB, 0x7A, 0xAD, 0xDA, 0x1B, 0x22, 0xBD, 0x26, 0x50, 0x78, - 0xAF, 0x92, 0x09, 0x1A, 0xEF, 0x16, 0x6B, 0xBE, 0x7A, 0xD6, - 0x6C, 0xC2, 0x2A, 0x78, 0x95, 0x00, 0x44, 0x62, 0x13, 0x56, - 0xC2, 0xAB, 0x05, 0x21, 0xCA, 0x9A, 0x70, 0xE9, 0x7C, 0x31, - 0xBC, 0x6A, 0x20, 0xA2, 0xAA, 0x09, 0x77, 0x80, 0x57, 0x0F, - 0x46, 0x54, 0x5C, 0x27, 0xDC, 0x01, 0x7E, 0x48, 0x40, 0xA2, - 0x8B, 0x09, 0x77, 0x82, 0x1F, 0x16, 0x94, 0x28, 0xBA, 0x1C, - 0xEE, 0x04, 0x3F, 0x34, 0x30, 0x91, 0x03, 0x70, 0x3B, 0x78, - 0x60, 0xDE, 0x6F, 0x86, 0x92, 0x10, 0xAB, 0xE1, 0xA7, 0x74, - 0x40, 0x14, 0x1E, 0xB9, 0xDF, 0x01, 0x1E, 0x98, 0xFF, 0xCB, - 0x51, 0x03, 0xDC, 0x07, 0x7E, 0x6A, 0x47, 0x44, 0xB7, 0xF9, - 0xF1, 0xE4, 0x2A, 0x03, 0x80, 0x1B, 0xFD, 0x7C, 0x76, 0xA5, - 0xDC, 0xF7, 0xFB, 0xBA, 0xAE, 0x17, 0x9E, 0xFF, 0x77, 0x2D, - 0x85, 0xFF, 0x07, 0xE6, 0x6F, 0xFC, 0xB7, 0xE2, 0xFB, 0x3A, - 0x0B, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, - 0x42, 0x60, 0x82, +static const unsigned char icon_png[] = { + 0x89, + 0x50, + 0x4E, + 0x47, + 0x0D, + 0x0A, + 0x1A, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x0D, + 0x49, + 0x48, + 0x44, + 0x52, + 0x00, + 0x00, + 0x00, + 0x40, + 0x00, + 0x00, + 0x00, + 0x40, + 0x08, + 0x06, + 0x00, + 0x00, + 0x00, + 0xAA, + 0x69, + 0x71, + 0xDE, + 0x00, + 0x00, + 0x03, + 0x80, + 0x49, + 0x44, + 0x41, + 0x54, + 0x78, + 0x9C, + 0xD5, + 0x9B, + 0x5B, + 0x9A, + 0xA3, + 0x20, + 0x10, + 0x85, + 0x0F, + 0xF3, + 0xCD, + 0x6A, + 0xDC, + 0x4F, + 0xBB, + 0x9D, + 0x90, + 0xED, + 0x98, + 0xFD, + 0x64, + 0x3B, + 0xCC, + 0x43, + 0x02, + 0x2D, + 0x25, + 0x97, + 0x2A, + 0x28, + 0xC0, + 0x39, + 0x2F, + 0x1D, + 0x6D, + 0x29, + 0xF8, + 0x8F, + 0x65, + 0x81, + 0xC6, + 0x00, + 0x6B, + 0xE5, + 0x16, + 0xF7, + 0x8F, + 0x3F, + 0x0B, + 0xFB, + 0x76, + 0xD6, + 0x5A, + 0x60, + 0xB1, + 0x09, + 0x66, + 0x51, + 0xBF, + 0x1E, + 0x1E, + 0x00, + 0xF0, + 0xFD, + 0xBC, + 0x64, + 0x2C, + 0x2B, + 0x3A, + 0x8D, + 0xE0, + 0xBD, + 0x56, + 0x99, + 0x30, + 0xBB, + 0xC3, + 0x24, + 0xBC, + 0xD7, + 0x0A, + 0x13, + 0x66, + 0xD6, + 0x80, + 0x22, + 0xFC, + 0xE7, + 0x08, + 0x07, + 0x4C, + 0xAE, + 0x09, + 0xB3, + 0xDC, + 0xAE, + 0xC2, + 0xDB, + 0xC7, + 0xE3, + 0x77, + 0xC3, + 0x18, + 0x60, + 0xD2, + 0xD8, + 0x66, + 0x74, + 0x22, + 0x83, + 0xF7, + 0x9A, + 0x64, + 0xC2, + 0xE8, + 0x0E, + 0xDA, + 0xE0, + 0xBD, + 0x26, + 0x98, + 0x30, + 0x32, + 0x78, + 0x1F, + 0xBC, + 0xD7, + 0x60, + 0x13, + 0x46, + 0x05, + 0xD6, + 0x81, + 0xF7, + 0x1A, + 0x68, + 0xC2, + 0x88, + 0x59, + 0xA0, + 0x09, + 0xDE, + 0x9A, + 0x67, + 0x21, + 0xE2, + 0xB8, + 0xD9, + 0x41, + 0xDB, + 0x80, + 0x66, + 0x78, + 0xEB, + 0x1E, + 0x97, + 0x7D, + 0x71, + 0xE4, + 0x31, + 0x26, + 0xFC, + 0x55, + 0x8C, + 0xA5, + 0x72, + 0xE6, + 0xFD, + 0x36, + 0x35, + 0xE4, + 0xD3, + 0x83, + 0x03, + 0x8C, + 0x71, + 0x50, + 0xBC, + 0x1C, + 0xB4, + 0x02, + 0xA9, + 0xA6, + 0x7D, + 0x12, + 0xFE, + 0x2C, + 0xC5, + 0x9A, + 0xA0, + 0x11, + 0x64, + 0x2E, + 0xBC, + 0x97, + 0x92, + 0x09, + 0xBD, + 0x01, + 0xD6, + 0xC0, + 0x7B, + 0x29, + 0x98, + 0xD0, + 0x53, + 0x04, + 0xF5, + 0xAB, + 0xBD, + 0x78, + 0x04, + 0xFD, + 0x85, + 0xB1, + 0xD5, + 0x3D, + 0x75, + 0xF8, + 0xDC, + 0xD9, + 0x2F, + 0x16, + 0x45, + 0xAF, + 0x8E, + 0x4C, + 0x68, + 0x69, + 0x34, + 0xF4, + 0xCC, + 0x5B, + 0xF7, + 0x08, + 0xD3, + 0x22, + 0x0B, + 0xDE, + 0xAB, + 0xD1, + 0x04, + 0x69, + 0x83, + 0x25, + 0x69, + 0x3F, + 0xB2, + 0x30, + 0x4A, + 0x6A, + 0x40, + 0xD7, + 0x22, + 0x27, + 0x05, + 0xC1, + 0x01, + 0x4B, + 0xB6, + 0xCB, + 0x19, + 0xDA, + 0x50, + 0x13, + 0xB8, + 0x0B, + 0xA1, + 0xE6, + 0xB5, + 0x7D, + 0x2B, + 0x78, + 0xB6, + 0x6D, + 0x62, + 0xD5, + 0x18, + 0x49, + 0xB8, + 0x58, + 0xE2, + 0x64, + 0x40, + 0xFD, + 0x49, + 0x0E, + 0x00, + 0xFB, + 0x2C, + 0xA7, + 0x79, + 0xEE, + 0x7A, + 0x2E, + 0xC1, + 0x84, + 0x36, + 0xE4, + 0x6F, + 0xED, + 0x78, + 0x49, + 0x26, + 0xD4, + 0x5C, + 0x62, + 0xC1, + 0x47, + 0x83, + 0xC8, + 0x65, + 0x42, + 0xE6, + 0xCC, + 0xB5, + 0xD6, + 0x87, + 0xD4, + 0xBD, + 0xC3, + 0x25, + 0x3E, + 0xA3, + 0x26, + 0x94, + 0x32, + 0xA0, + 0x0A, + 0xBF, + 0x6D, + 0x1B, + 0xB6, + 0x6D, + 0x8B, + 0x07, + 0x92, + 0xC8, + 0x84, + 0x52, + 0xDA, + 0x4A, + 0x32, + 0x22, + 0xDB, + 0x26, + 0x17, + 0x9F, + 0x91, + 0x09, + 0x39, + 0x77, + 0x58, + 0xF0, + 0x67, + 0xBD, + 0xDF, + 0xEF, + 0x78, + 0x50, + 0xCC, + 0xFB, + 0xFD, + 0x73, + 0x06, + 0x9C, + 0x21, + 0xB8, + 0xAB, + 0xC5, + 0x6A, + 0x4D, + 0x00, + 0x8A, + 0x99, + 0x90, + 0xCA, + 0x00, + 0x31, + 0x3C, + 0x10, + 0x1E, + 0x69, + 0xFF, + 0x6E, + 0x57, + 0x6A, + 0x02, + 0xD0, + 0x0E, + 0x7F, + 0xAE, + 0x09, + 0xAC, + 0x82, + 0x5A, + 0xC8, + 0x04, + 0xEA, + 0x4A, + 0x13, + 0xFC, + 0xBE, + 0xEF, + 0x70, + 0xCE, + 0xC1, + 0x18, + 0x73, + 0x35, + 0xA2, + 0x90, + 0x09, + 0xC5, + 0x4B, + 0x83, + 0x51, + 0x1B, + 0xC4, + 0xB3, + 0x44, + 0x22, + 0x13, + 0xCE, + 0x19, + 0xD0, + 0x05, + 0x0F, + 0x00, + 0xCE, + 0x39, + 0x51, + 0x26, + 0xF4, + 0xC2, + 0xA7, + 0x66, + 0x89, + 0x6C, + 0xCC, + 0xE7, + 0xD3, + 0x8F, + 0x2D, + 0xCA, + 0x84, + 0xB3, + 0x1B, + 0x45, + 0x03, + 0x6A, + 0xF0, + 0x51, + 0x50, + 0x61, + 0x26, + 0x44, + 0xC7, + 0xD1, + 0x07, + 0x24, + 0x27, + 0xD0, + 0x6A, + 0xDB, + 0x02, + 0x7C, + 0xB4, + 0x7D, + 0xFA, + 0x06, + 0x8A, + 0xB5, + 0x12, + 0x94, + 0xC0, + 0x03, + 0xF2, + 0x4C, + 0x08, + 0xC7, + 0x90, + 0x55, + 0xA3, + 0xE4, + 0xF6, + 0x98, + 0x0B, + 0x0F, + 0x20, + 0xCA, + 0x84, + 0xAA, + 0x01, + 0x12, + 0xF8, + 0xD7, + 0xEB, + 0x15, + 0x3E, + 0xB7, + 0x98, + 0x10, + 0x15, + 0x42, + 0x52, + 0xF0, + 0xB8, + 0xED, + 0x72, + 0xFD, + 0x59, + 0x6B, + 0xA3, + 0x6B, + 0xDF, + 0x9B, + 0x50, + 0x34, + 0xA0, + 0x05, + 0xBE, + 0xD7, + 0x04, + 0xAA, + 0x5A, + 0x36, + 0x48, + 0xE0, + 0xCF, + 0x26, + 0xF8, + 0xCB, + 0x20, + 0x3B, + 0x0B, + 0xB4, + 0x9E, + 0x79, + 0xAF, + 0x9F, + 0x9F, + 0x9F, + 0xF0, + 0xB9, + 0xB7, + 0x26, + 0xE4, + 0xEA, + 0x80, + 0x30, + 0xED, + 0x8D, + 0xB5, + 0xD6, + 0x7D, + 0x3F, + 0x03, + 0xDF, + 0x1A, + 0x90, + 0x5A, + 0x1C, + 0xB8, + 0xE3, + 0x38, + 0x2E, + 0x3B, + 0x25, + 0xF0, + 0x5E, + 0xBD, + 0x26, + 0xD0, + 0xAA, + 0x9E, + 0x5B, + 0x37, + 0x44, + 0x6D, + 0x6A, + 0x97, + 0x19, + 0xF9, + 0x0A, + 0x3E, + 0x75, + 0x09, + 0x98, + 0x7D, + 0xDF, + 0xA3, + 0x1D, + 0x2D, + 0xF0, + 0x54, + 0xE2, + 0x29, + 0x72, + 0x02, + 0xFC, + 0x65, + 0x83, + 0xC8, + 0x1D, + 0xC7, + 0xD1, + 0x0C, + 0x7F, + 0x3E, + 0xFB, + 0x51, + 0x87, + 0x8C, + 0x4C, + 0x28, + 0xDD, + 0x38, + 0x69, + 0xC2, + 0x27, + 0x77, + 0x10, + 0x39, + 0x4D, + 0xF8, + 0xD0, + 0x69, + 0xC1, + 0x84, + 0x99, + 0xF0, + 0xD9, + 0x9D, + 0x44, + 0x91, + 0x09, + 0xBD, + 0xF0, + 0xA1, + 0x63, + 0x41, + 0x4D, + 0x18, + 0x05, + 0x5F, + 0xFC, + 0x07, + 0x51, + 0x30, + 0x81, + 0x5B, + 0xF4, + 0x38, + 0xEA, + 0x99, + 0x1D, + 0x80, + 0x7E, + 0xF8, + 0xEA, + 0x3F, + 0x89, + 0x8A, + 0x26, + 0x48, + 0xE1, + 0xC3, + 0x00, + 0x1A, + 0x4D, + 0xD0, + 0x80, + 0x67, + 0x1D, + 0x40, + 0x94, + 0x34, + 0xA1, + 0x15, + 0x3E, + 0x0C, + 0x42, + 0x7A, + 0x17, + 0xA9, + 0x04, + 0xCF, + 0x3E, + 0x88, + 0x28, + 0x32, + 0xA1, + 0x17, + 0x3E, + 0x0C, + 0x84, + 0x69, + 0x82, + 0x26, + 0xBC, + 0xE8, + 0x40, + 0xA2, + 0xE4, + 0xEC, + 0x00, + 0x7C, + 0x40, + 0x72, + 0xFF, + 0xAB, + 0x0E, + 0xA6, + 0x62, + 0x82, + 0x36, + 0xBC, + 0xF8, + 0x60, + 0xA2, + 0xA9, + 0x26, + 0x8C, + 0x80, + 0x6F, + 0x6A, + 0x40, + 0x14, + 0x4C, + 0xA0, + 0xD0, + 0xAD, + 0x26, + 0x18, + 0x63, + 0x70, + 0x1C, + 0xC7, + 0xE5, + 0x19, + 0x63, + 0x49, + 0x3D, + 0x6F, + 0x98, + 0xAA, + 0xBC, + 0x1F, + 0xA0, + 0x65, + 0x82, + 0x87, + 0xF7, + 0xE2, + 0x98, + 0xD0, + 0xFB, + 0x7A, + 0xAD, + 0xDA, + 0x1B, + 0x22, + 0xBD, + 0x26, + 0x50, + 0x78, + 0xAF, + 0x92, + 0x09, + 0x1A, + 0xEF, + 0x16, + 0x6B, + 0xBE, + 0x7A, + 0xD6, + 0x6C, + 0xC2, + 0x2A, + 0x78, + 0x95, + 0x00, + 0x44, + 0x62, + 0x13, + 0x56, + 0xC2, + 0xAB, + 0x05, + 0x21, + 0xCA, + 0x9A, + 0x70, + 0xE9, + 0x7C, + 0x31, + 0xBC, + 0x6A, + 0x20, + 0xA2, + 0xAA, + 0x09, + 0x77, + 0x80, + 0x57, + 0x0F, + 0x46, + 0x54, + 0x5C, + 0x27, + 0xDC, + 0x01, + 0x7E, + 0x48, + 0x40, + 0xA2, + 0x8B, + 0x09, + 0x77, + 0x82, + 0x1F, + 0x16, + 0x94, + 0x28, + 0xBA, + 0x1C, + 0xEE, + 0x04, + 0x3F, + 0x34, + 0x30, + 0x91, + 0x03, + 0x70, + 0x3B, + 0x78, + 0x60, + 0xDE, + 0x6F, + 0x86, + 0x92, + 0x10, + 0xAB, + 0xE1, + 0xA7, + 0x74, + 0x40, + 0x14, + 0x1E, + 0xB9, + 0xDF, + 0x01, + 0x1E, + 0x98, + 0xFF, + 0xCB, + 0x51, + 0x03, + 0xDC, + 0x07, + 0x7E, + 0x6A, + 0x47, + 0x44, + 0xB7, + 0xF9, + 0xF1, + 0xE4, + 0x2A, + 0x03, + 0x80, + 0x1B, + 0xFD, + 0x7C, + 0x76, + 0xA5, + 0xDC, + 0xF7, + 0xFB, + 0xBA, + 0xAE, + 0x17, + 0x9E, + 0xFF, + 0x77, + 0x2D, + 0x85, + 0xFF, + 0x07, + 0xE6, + 0x6F, + 0xFC, + 0xB7, + 0xE2, + 0xFB, + 0x3A, + 0x0B, + 0x00, + 0x00, + 0x00, + 0x00, + 0x49, + 0x45, + 0x4E, + 0x44, + 0xAE, + 0x42, + 0x60, + 0x82, }; wxBitmap& icon_png_to_wx_bitmap() { - static wxMemoryInputStream memIStream( icon_png, sizeof( icon_png ) ); - static wxImage image( memIStream, wxBITMAP_TYPE_PNG ); - static wxBitmap bmp( image ); - return bmp; + static wxMemoryInputStream memIStream(icon_png, sizeof(icon_png)); + static wxImage image(memIStream, wxBITMAP_TYPE_PNG); + static wxBitmap bmp(image); + return bmp; } - -#endif //ICON_PNG_H +#endif // ICON_PNG_H diff --git a/src/gui/idlepanel.cc b/src/gui/idlepanel.cc index 0161fb13..9e213b7d 100644 --- a/src/gui/idlepanel.cc +++ b/src/gui/idlepanel.cc @@ -9,16 +9,16 @@ #include "lib/fluxsink/fluxsink.h" #include "lib/imagereader/imagereader.h" #include "lib/imagewriter/imagewriter.h" -#include "layout.h" +#include "lib/layout.h" #include "texteditorwindow.h" #include "iconbutton.h" #include #include #include #include -#include ".obj/extras/hardware.h" -#include ".obj/extras/fluxfile.h" -#include ".obj/extras/imagefile.h" +#include "icons/hardware.h" +#include "icons/fluxfile.h" +#include "icons/imagefile.h" #define CONFIG_SELECTEDSOURCE "SelectedSource" #define CONFIG_DEVICE "Device" @@ -103,11 +103,11 @@ public: parent->AddPage(this, "idle"); _imageList.Add( - createBitmap(extras_hardware_png, sizeof(extras_hardware_png))); + createBitmap(icon_hardware_png, sizeof(icon_hardware_png))); _imageList.Add( - createBitmap(extras_fluxfile_png, sizeof(extras_fluxfile_png))); + createBitmap(icon_fluxfile_png, sizeof(icon_fluxfile_png))); _imageList.Add( - createBitmap(extras_imagefile_png, sizeof(extras_imagefile_png))); + createBitmap(icon_imagefile_png, sizeof(icon_imagefile_png))); UpdateSources(); } @@ -239,12 +239,12 @@ public: { if (_selectedFluxFormat) { - if (_selectedFluxFormat->sink) - _selectedFluxFormat->sink(_selectedFluxFilename, - globalConfig().overrides()->mutable_flux_sink()); - if (_selectedFluxFormat->source) - _selectedFluxFormat->source(_selectedFluxFilename, - globalConfig().overrides()->mutable_flux_source()); + if (_selectedFluxFormat->sink) + _selectedFluxFormat->sink(_selectedFluxFilename, + globalConfig().overrides()->mutable_flux_sink()); + if (_selectedFluxFormat->source) + _selectedFluxFormat->source(_selectedFluxFilename, + globalConfig().overrides()->mutable_flux_source()); } break; } @@ -695,8 +695,11 @@ private: for (auto& group : globalConfig()->option_group()) { + std::string groupName = group.comment(); + if (groupName == "$formats") + groupName = "Formats"; sizer->Add(new wxStaticText( - formatOptionsContainer, wxID_ANY, group.comment() + ":")); + formatOptionsContainer, wxID_ANY, groupName + ":")); bool first = true; bool valueSet = false; diff --git a/src/gui/imagerpanel.cc b/src/gui/imagerpanel.cc index dd3cc5b1..79e7c452 100644 --- a/src/gui/imagerpanel.cc +++ b/src/gui/imagerpanel.cc @@ -9,7 +9,7 @@ #include "lib/proto.h" #include "lib/readerwriter.h" #include "gui.h" -#include "layout.h" +#include "lib/layout.h" #include "fluxviewerwindow.h" #include "jobqueue.h" diff --git a/src/gui/layout.cpp b/src/gui/layout.cpp index e8d495d9..93ea55f9 100644 --- a/src/gui/layout.cpp +++ b/src/gui/layout.cpp @@ -1081,7 +1081,7 @@ FluxfileSourcePanelGen::FluxfileSourcePanelGen( wxWindow* parent, wxWindowID id, m_staticText27->Wrap( -1 ); bSizer8->Add( m_staticText27, 0, wxALL, 5 ); - fluxImagePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.*"), wxDefaultPosition, wxDefaultSize, wxFLP_FILE_MUST_EXIST|wxFLP_OPEN ); + fluxImagePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.*"), wxDefaultPosition, wxDefaultSize, wxFLP_OPEN|wxFLP_USE_TEXTCTRL ); fluxImagePicker->SetToolTip( wxT("Path to a .flux, .scp or other flux file.") ); bSizer8->Add( fluxImagePicker, 0, wxALL|wxEXPAND, 5 ); @@ -1118,7 +1118,7 @@ ImagefileSourcePanelGen::ImagefileSourcePanelGen( wxWindow* parent, wxWindowID i m_staticText28->Wrap( -1 ); bSizer9->Add( m_staticText28, 0, wxALL, 5 ); - diskImagePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.*"), wxDefaultPosition, wxDefaultSize, wxFLP_FILE_MUST_EXIST|wxFLP_OPEN ); + diskImagePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.*"), wxDefaultPosition, wxDefaultSize, wxFLP_OPEN|wxFLP_USE_TEXTCTRL ); diskImagePicker->SetToolTip( wxT("The path to the disk image.") ); bSizer9->Add( diskImagePicker, 0, wxALL|wxEXPAND, 5 ); diff --git a/src/gui/layout.fbp b/src/gui/layout.fbp index a176a7d0..6836a7eb 100644 --- a/src/gui/layout.fbp +++ b/src/gui/layout.fbp @@ -6592,7 +6592,7 @@ 0 1 - 1 + 0 0 0 @@ -6615,7 +6615,7 @@ Resizable 1 - wxFLP_FILE_MUST_EXIST|wxFLP_OPEN + wxFLP_OPEN|wxFLP_USE_TEXTCTRL ; ; forward_declare 0 Path to a .flux, .scp or other flux file. @@ -6963,7 +6963,7 @@ Resizable 1 - wxFLP_FILE_MUST_EXIST|wxFLP_OPEN + wxFLP_OPEN|wxFLP_USE_TEXTCTRL ; ; forward_declare 0 The path to the disk image. diff --git a/src/gui/layout.h b/src/gui/layout.h index a7f189fe..e6e44682 100644 --- a/src/gui/layout.h +++ b/src/gui/layout.h @@ -51,28 +51,45 @@ /////////////////////////////////////////////////////////////////////////////// class MainWindowGen : public wxFrame { - private: +private: +protected: + wxMenuBar* menuBar; + wxMenu* m_menu1; + wxMenu* m_menu2; + wxSimplebook* dataNotebook; - protected: - wxMenuBar* menuBar; - wxMenu* m_menu1; - wxMenu* m_menu2; - wxSimplebook* dataNotebook; + // Virtual event handlers, override them in your derived class + virtual void OnClose(wxCloseEvent& event) + { + event.Skip(); + } + virtual void OnAboutMenuItem(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnExit(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnShowLogWindow(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnShowConfigWindow(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } - virtual void OnAboutMenuItem( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExit( wxCommandEvent& event ) { event.Skip(); } - virtual void OnShowLogWindow( wxCommandEvent& event ) { event.Skip(); } - virtual void OnShowConfigWindow( wxCommandEvent& event ) { event.Skip(); } - - - public: - - MainWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("FluxEngine"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 616,607 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL ); - - ~MainWindowGen(); +public: + MainWindowGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("FluxEngine"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(616, 607), + long style = wxDEFAULT_FRAME_STYLE | wxRESIZE_BORDER | + wxFULL_REPAINT_ON_RESIZE | wxTAB_TRAVERSAL); + ~MainWindowGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -80,24 +97,32 @@ class MainWindowGen : public wxFrame /////////////////////////////////////////////////////////////////////////////// class TextViewerWindowGen : public wxDialog { - private: +private: +protected: + wxTextCtrl* textControl; + wxStdDialogButtonSizer* m_sdbSizer2; + wxButton* m_sdbSizer2OK; - protected: - wxTextCtrl* textControl; - wxStdDialogButtonSizer* m_sdbSizer2; - wxButton* m_sdbSizer2OK; + // Virtual event handlers, override them in your derived class + virtual void OnClose(wxCloseEvent& event) + { + event.Skip(); + } + virtual void OnClose(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } - virtual void OnClose( wxCommandEvent& event ) { event.Skip(); } - - - public: - - TextViewerWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 208,143 ), long style = wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER ); - - ~TextViewerWindowGen(); +public: + TextViewerWindowGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(208, 143), + long style = wxCLOSE_BOX | wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | + wxMINIMIZE_BOX | wxRESIZE_BORDER); + ~TextViewerWindowGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -105,25 +130,33 @@ class TextViewerWindowGen : public wxDialog /////////////////////////////////////////////////////////////////////////////// class FluxViewerWindowGen : public wxDialog { - private: +private: +protected: + FluxViewerControl* fluxviewer; + wxScrollBar* scrollbar; + wxStdDialogButtonSizer* m_sdbSizer2; + wxButton* m_sdbSizer2OK; - protected: - FluxViewerControl* fluxviewer; - wxScrollBar* scrollbar; - wxStdDialogButtonSizer* m_sdbSizer2; - wxButton* m_sdbSizer2OK; + // Virtual event handlers, override them in your derived class + virtual void OnClose(wxCloseEvent& event) + { + event.Skip(); + } + virtual void OnClose(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } - virtual void OnClose( wxCommandEvent& event ) { event.Skip(); } - - - public: - - FluxViewerWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 400,200 ), long style = wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER ); - - ~FluxViewerWindowGen(); +public: + FluxViewerWindowGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(400, 200), + long style = wxCLOSE_BOX | wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | + wxMINIMIZE_BOX | wxRESIZE_BORDER); + ~FluxViewerWindowGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -131,26 +164,37 @@ class FluxViewerWindowGen : public wxDialog /////////////////////////////////////////////////////////////////////////////// class TextEditorWindowGen : public wxDialog { - private: +private: +protected: + wxTextCtrl* textControl; + wxStdDialogButtonSizer* m_sdbSizer2; + wxButton* m_sdbSizer2Save; + wxButton* m_sdbSizer2Cancel; - protected: - wxTextCtrl* textControl; - wxStdDialogButtonSizer* m_sdbSizer2; - wxButton* m_sdbSizer2Save; - wxButton* m_sdbSizer2Cancel; + // Virtual event handlers, override them in your derived class + virtual void OnClose(wxCloseEvent& event) + { + event.Skip(); + } + virtual void OnCancel(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnSave(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } - virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); } - virtual void OnSave( wxCommandEvent& event ) { event.Skip(); } - - - public: - - TextEditorWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER ); - - ~TextEditorWindowGen(); +public: + TextEditorWindowGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxCLOSE_BOX | wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | + wxMINIMIZE_BOX | wxRESIZE_BORDER); + ~TextEditorWindowGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -158,27 +202,32 @@ class TextEditorWindowGen : public wxDialog /////////////////////////////////////////////////////////////////////////////// class FileViewerWindowGen : public wxDialog { - private: +private: +protected: + wxNotebook* m_notebook1; + wxPanel* m_panel8; + wxTextCtrl* textControl; + wxPanel* m_panel7; + wxTextCtrl* hexControl; + wxStdDialogButtonSizer* m_sdbSizer2; + wxButton* m_sdbSizer2OK; - protected: - wxNotebook* m_notebook1; - wxPanel* m_panel8; - wxTextCtrl* textControl; - wxPanel* m_panel7; - wxTextCtrl* hexControl; - wxStdDialogButtonSizer* m_sdbSizer2; - wxButton* m_sdbSizer2OK; + // Virtual event handlers, override them in your derived class + virtual void OnClose(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnClose( wxCommandEvent& event ) { event.Skip(); } - - - public: - - FileViewerWindowGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 408,269 ), long style = wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER ); - - ~FileViewerWindowGen(); +public: + FileViewerWindowGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(408, 269), + long style = wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | wxMINIMIZE_BOX | + wxRESIZE_BORDER); + ~FileViewerWindowGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -186,23 +235,26 @@ class FileViewerWindowGen : public wxDialog /////////////////////////////////////////////////////////////////////////////// class GetfileDialog : public wxDialog { - private: +private: +protected: + wxStaticText* m_staticText7; + wxStaticText* m_staticText9; - protected: - wxStaticText* m_staticText7; - wxStaticText* m_staticText9; +public: + wxTextCtrl* filenameText; + wxFilePickerCtrl* targetFilePicker; + wxStdDialogButtonSizer* buttons_; + wxButton* buttons_OK; + wxButton* buttons_Cancel; - public: - wxTextCtrl* filenameText; - wxFilePickerCtrl* targetFilePicker; - wxStdDialogButtonSizer* buttons_; - wxButton* buttons_OK; - wxButton* buttons_Cancel; - - GetfileDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Copy file off disk"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); - - ~GetfileDialog(); + GetfileDialog(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("Copy file off disk"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE); + ~GetfileDialog(); }; /////////////////////////////////////////////////////////////////////////////// @@ -210,24 +262,27 @@ class GetfileDialog : public wxDialog /////////////////////////////////////////////////////////////////////////////// class FileConflictDialog : public wxDialog { - private: +private: +protected: + wxStaticText* m_staticText91; + wxStaticText* m_staticText7; + wxStaticText* m_staticText9; - protected: - wxStaticText* m_staticText91; - wxStaticText* m_staticText7; - wxStaticText* m_staticText9; +public: + wxTextCtrl* newNameText; + wxTextCtrl* oldNameText; + wxStdDialogButtonSizer* buttons_; + wxButton* buttons_OK; + wxButton* buttons_Cancel; - public: - wxTextCtrl* newNameText; - wxTextCtrl* oldNameText; - wxStdDialogButtonSizer* buttons_; - wxButton* buttons_OK; - wxButton* buttons_Cancel; - - FileConflictDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Filename conflict"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); - - ~FileConflictDialog(); + FileConflictDialog(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("Filename conflict"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE); + ~FileConflictDialog(); }; /////////////////////////////////////////////////////////////////////////////// @@ -235,24 +290,27 @@ class FileConflictDialog : public wxDialog /////////////////////////////////////////////////////////////////////////////// class FileRenameDialog : public wxDialog { - private: +private: +protected: + wxStaticText* m_staticText91; + wxStaticText* m_staticText7; + wxStaticText* m_staticText9; - protected: - wxStaticText* m_staticText91; - wxStaticText* m_staticText7; - wxStaticText* m_staticText9; +public: + wxTextCtrl* newNameText; + wxTextCtrl* oldNameText; + wxStdDialogButtonSizer* buttons_; + wxButton* buttons_OK; + wxButton* buttons_Cancel; - public: - wxTextCtrl* newNameText; - wxTextCtrl* oldNameText; - wxStdDialogButtonSizer* buttons_; - wxButton* buttons_OK; - wxButton* buttons_Cancel; - - FileRenameDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Rename or move file"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); - - ~FileRenameDialog(); + FileRenameDialog(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("Rename or move file"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE); + ~FileRenameDialog(); }; /////////////////////////////////////////////////////////////////////////////// @@ -260,22 +318,25 @@ class FileRenameDialog : public wxDialog /////////////////////////////////////////////////////////////////////////////// class CreateDirectoryDialog : public wxDialog { - private: +private: +protected: + wxStaticText* m_staticText91; + wxStaticText* m_staticText9; - protected: - wxStaticText* m_staticText91; - wxStaticText* m_staticText9; +public: + wxTextCtrl* newNameText; + wxStdDialogButtonSizer* buttons_; + wxButton* buttons_OK; + wxButton* buttons_Cancel; - public: - wxTextCtrl* newNameText; - wxStdDialogButtonSizer* buttons_; - wxButton* buttons_OK; - wxButton* buttons_Cancel; - - CreateDirectoryDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Create new directory"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); - - ~CreateDirectoryDialog(); + CreateDirectoryDialog(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("Create new directory"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE); + ~CreateDirectoryDialog(); }; /////////////////////////////////////////////////////////////////////////////// @@ -283,23 +344,26 @@ class CreateDirectoryDialog : public wxDialog /////////////////////////////////////////////////////////////////////////////// class FormatDialog : public wxDialog { - private: +private: +protected: + wxStaticText* m_staticText91; + wxStaticText* m_staticText7; - protected: - wxStaticText* m_staticText91; - wxStaticText* m_staticText7; +public: + wxTextCtrl* volumeNameText; + wxCheckBox* quickFormatCheckBox; + wxStdDialogButtonSizer* buttons_; + wxButton* buttons_OK; + wxButton* buttons_Cancel; - public: - wxTextCtrl* volumeNameText; - wxCheckBox* quickFormatCheckBox; - wxStdDialogButtonSizer* buttons_; - wxButton* buttons_OK; - wxButton* buttons_Cancel; - - FormatDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Format disk"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); - - ~FormatDialog(); + FormatDialog(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("Format disk"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE); + ~FormatDialog(); }; /////////////////////////////////////////////////////////////////////////////// @@ -307,37 +371,59 @@ class FormatDialog : public wxDialog /////////////////////////////////////////////////////////////////////////////// class IdlePanelGen : public wxPanel { - private: +private: +protected: + wxStaticBitmap* applicationBitmap; + wxPanel* sourceIconPanel; + wxSimplebook* sourceBook; + wxChoice* formatChoice; + wxButton* customConfigurationButton; + wxPanel* formatOptionsContainer; + wxButton* readButton; + wxButton* writeButton; + wxButton* browseButton; + wxButton* formatButton; + wxButton* exploreButton; - protected: - wxStaticBitmap* applicationBitmap; - wxPanel* sourceIconPanel; - wxSimplebook* sourceBook; - wxChoice* formatChoice; - wxButton* customConfigurationButton; - wxPanel* formatOptionsContainer; - wxButton* readButton; - wxButton* writeButton; - wxButton* browseButton; - wxButton* formatButton; - wxButton* exploreButton; + // Virtual event handlers, override them in your derived class + virtual void OnControlsChanged(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnCustomConfigurationButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnReadButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnWriteButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowseButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnFormatButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnExploreButton(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnControlsChanged( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCustomConfigurationButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnReadButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnWriteButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowseButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnFormatButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExploreButton( wxCommandEvent& event ) { event.Skip(); } - - - public: - - IdlePanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - - ~IdlePanelGen(); +public: + IdlePanelGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(-1, -1), + long style = wxTAB_TRAVERSAL, + const wxString& name = wxEmptyString); + ~IdlePanelGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -345,30 +431,43 @@ class IdlePanelGen : public wxPanel /////////////////////////////////////////////////////////////////////////////// class ImagerPanelGen : public wxPanel { - private: +private: +protected: + wxAuiToolBar* imagerToolbar; + wxAuiToolBarItem* imagerBackTool; + VisualisationControl* visualiser; + wxButton* imagerSaveImageButton; + wxButton* imagerSaveFluxButton; + HistogramViewer* histogram; + wxButton* imagerGoAgainButton; - protected: - wxAuiToolBar* imagerToolbar; - wxAuiToolBarItem* imagerBackTool; - VisualisationControl* visualiser; - wxButton* imagerSaveImageButton; - wxButton* imagerSaveFluxButton; - HistogramViewer* histogram; - wxButton* imagerGoAgainButton; + // Virtual event handlers, override them in your derived class + virtual void OnBackButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnSaveImageButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnSaveFluxButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnImagerGoAgainButton(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnBackButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnSaveImageButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnSaveFluxButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnImagerGoAgainButton( wxCommandEvent& event ) { event.Skip(); } - - - public: - - ImagerPanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - - ~ImagerPanelGen(); +public: + ImagerPanelGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(500, 300), + long style = wxTAB_TRAVERSAL, + const wxString& name = wxEmptyString); + ~ImagerPanelGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -376,69 +475,121 @@ class ImagerPanelGen : public wxPanel /////////////////////////////////////////////////////////////////////////////// class BrowserPanelGen : public wxPanel { - private: +private: +protected: + wxAuiToolBar* browserToolbar; + wxAuiToolBarItem* browserBackTool; + wxAuiToolBarItem* browserInfoTool; + wxAuiToolBarItem* browserViewTool; + wxAuiToolBarItem* browserSaveTool; + wxAuiToolBarItem* browserMoreMenuButton; + wxMenu* browserMoreMenu; + wxMenuItem* browserAddMenuItem; + wxMenuItem* browserNewDirectoryMenuItem; + wxMenuItem* browserRenameMenuItem; + wxMenuItem* browserDeleteMenuItem; + wxAuiToolBarItem* browserFormatTool; + wxDataViewCtrl* browserTree; + wxDataViewColumn* m_dataViewColumn1; + wxDataViewColumn* m_dataViewColumn2; + wxDataViewColumn* m_dataViewColumn3; + wxGauge* diskSpaceGauge; + wxButton* browserDiscardButton; + wxButton* browserCommitButton; + wxStaticText* m_staticText12; - protected: - wxAuiToolBar* browserToolbar; - wxAuiToolBarItem* browserBackTool; - wxAuiToolBarItem* browserInfoTool; - wxAuiToolBarItem* browserViewTool; - wxAuiToolBarItem* browserSaveTool; - wxAuiToolBarItem* browserMoreMenuButton; - wxMenu* browserMoreMenu; - wxMenuItem* browserAddMenuItem; - wxMenuItem* browserNewDirectoryMenuItem; - wxMenuItem* browserRenameMenuItem; - wxMenuItem* browserDeleteMenuItem; - wxAuiToolBarItem* browserFormatTool; - wxDataViewCtrl* browserTree; - wxDataViewColumn* m_dataViewColumn1; - wxDataViewColumn* m_dataViewColumn2; - wxDataViewColumn* m_dataViewColumn3; - wxGauge* diskSpaceGauge; - wxButton* browserDiscardButton; - wxButton* browserCommitButton; - wxStaticText* m_staticText12; + // Virtual event handlers, override them in your derived class + virtual void OnBackButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserInfoButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserViewButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserSaveButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserAddMenuItem(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserNewDirectoryMenuItem(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserRenameMenuItem(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserDeleteMenuItem(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserFormatButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserBeginDrag(wxDataViewEvent& event) + { + event.Skip(); + } + virtual void OnBrowserDrop(wxDataViewEvent& event) + { + event.Skip(); + } + virtual void OnBrowserDropPossible(wxDataViewEvent& event) + { + event.Skip(); + } + virtual void OnBrowserDirectoryExpanding(wxDataViewEvent& event) + { + event.Skip(); + } + virtual void OnBrowserFilenameChanged(wxDataViewEvent& event) + { + event.Skip(); + } + virtual void OnBrowserSelectionChanged(wxDataViewEvent& event) + { + event.Skip(); + } + virtual void OnBrowserDiscardButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnBrowserCommitButton(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnBackButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserInfoButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserViewButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserSaveButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserAddMenuItem( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserNewDirectoryMenuItem( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserRenameMenuItem( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserDeleteMenuItem( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserFormatButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserBeginDrag( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnBrowserDrop( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnBrowserDropPossible( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnBrowserDirectoryExpanding( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnBrowserFilenameChanged( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnBrowserSelectionChanged( wxDataViewEvent& event ) { event.Skip(); } - virtual void OnBrowserDiscardButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnBrowserCommitButton( wxCommandEvent& event ) { event.Skip(); } +public: + BrowserPanelGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(500, 300), + long style = wxTAB_TRAVERSAL, + const wxString& name = wxEmptyString); + ~BrowserPanelGen(); - public: - - BrowserPanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - - ~BrowserPanelGen(); - - void browserMoreMenuButtonOnDropDownMenu( wxAuiToolBarEvent &event ) - { - if ( event.IsDropDownClicked() ) - { - browserToolbar->SetToolSticky( event.GetId(), true ); - wxRect rect = browserToolbar->GetToolRect( event.GetId() ); - wxPoint pt = browserToolbar->ClientToScreen( rect.GetBottomLeft() ); - pt = ScreenToClient( pt ); - browserToolbar->PopupMenu( browserMoreMenu, pt ); - browserToolbar->SetToolSticky( event.GetId(), false ); - } - } - + void browserMoreMenuButtonOnDropDownMenu(wxAuiToolBarEvent& event) + { + if (event.IsDropDownClicked()) + { + browserToolbar->SetToolSticky(event.GetId(), true); + wxRect rect = browserToolbar->GetToolRect(event.GetId()); + wxPoint pt = browserToolbar->ClientToScreen(rect.GetBottomLeft()); + pt = ScreenToClient(pt); + browserToolbar->PopupMenu(browserMoreMenu, pt); + browserToolbar->SetToolSticky(event.GetId(), false); + } + } }; /////////////////////////////////////////////////////////////////////////////// @@ -446,45 +597,64 @@ class BrowserPanelGen : public wxPanel /////////////////////////////////////////////////////////////////////////////// class ExplorerPanelGen : public wxPanel { - private: +private: +protected: + wxAuiToolBar* explorerToolbar; + wxAuiToolBarItem* explorerBackTool; + wxAuiToolBarItem* explorerRefreshTool; + wxStaticText* m_staticText22; + wxSpinCtrl* explorerTrackSpinCtrl; + wxStaticText* m_staticText26; + wxSpinCtrl* explorerSideSpinCtrl; + wxStaticText* m_staticText231; + wxSpinCtrlDouble* explorerStartTimeSpinCtrl; + wxStaticText* m_staticText24; + wxButton* guessButton; + wxSpinCtrlDouble* explorerClockSpinCtrl; + wxStaticText* m_staticText25; + wxSpinCtrl* explorerBitOffsetSpinCtrl; + wxStaticText* m_staticText27; + wxChoice* explorerDecodeChoice; + wxStaticText* m_staticText241; + wxCheckBox* explorerReverseCheckBox; + HistogramViewer* histogram; + wxTextCtrl* explorerText; - protected: - wxAuiToolBar* explorerToolbar; - wxAuiToolBarItem* explorerBackTool; - wxAuiToolBarItem* explorerRefreshTool; - wxStaticText* m_staticText22; - wxSpinCtrl* explorerTrackSpinCtrl; - wxStaticText* m_staticText26; - wxSpinCtrl* explorerSideSpinCtrl; - wxStaticText* m_staticText231; - wxSpinCtrlDouble* explorerStartTimeSpinCtrl; - wxStaticText* m_staticText24; - wxButton* guessButton; - wxSpinCtrlDouble* explorerClockSpinCtrl; - wxStaticText* m_staticText25; - wxSpinCtrl* explorerBitOffsetSpinCtrl; - wxStaticText* m_staticText27; - wxChoice* explorerDecodeChoice; - wxStaticText* m_staticText241; - wxCheckBox* explorerReverseCheckBox; - HistogramViewer* histogram; - wxTextCtrl* explorerText; + // Virtual event handlers, override them in your derived class + virtual void OnBackButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnExplorerRefreshButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnExplorerSettingChange(wxSpinEvent& event) + { + event.Skip(); + } + virtual void OnExplorerSettingChange(wxSpinDoubleEvent& event) + { + event.Skip(); + } + virtual void OnGuessClockButton(wxCommandEvent& event) + { + event.Skip(); + } + virtual void OnExplorerSettingChange(wxCommandEvent& event) + { + event.Skip(); + } - // Virtual event handlers, override them in your derived class - virtual void OnBackButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExplorerRefreshButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExplorerSettingChange( wxSpinEvent& event ) { event.Skip(); } - virtual void OnExplorerSettingChange( wxSpinDoubleEvent& event ) { event.Skip(); } - virtual void OnGuessClockButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExplorerSettingChange( wxCommandEvent& event ) { event.Skip(); } - - - public: - - ExplorerPanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 620,426 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - - ~ExplorerPanelGen(); +public: + ExplorerPanelGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(620, 426), + long style = wxTAB_TRAVERSAL, + const wxString& name = wxEmptyString); + ~ExplorerPanelGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -492,21 +662,24 @@ class ExplorerPanelGen : public wxPanel /////////////////////////////////////////////////////////////////////////////// class HardwareSourcePanelGen : public wxPanel { - private: +private: +protected: + wxStaticText* m_staticText30; + wxStaticText* m_staticText29; - protected: - wxStaticText* m_staticText30; - wxStaticText* m_staticText29; +public: + wxStaticText* label; + wxCheckBox* highDensityToggle; + wxChoice* driveTypeChoice; - public: - wxStaticText* label; - wxCheckBox* highDensityToggle; - wxChoice* driveTypeChoice; - - HardwareSourcePanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - - ~HardwareSourcePanelGen(); + HardwareSourcePanelGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(-1, -1), + long style = wxTAB_TRAVERSAL, + const wxString& name = wxEmptyString); + ~HardwareSourcePanelGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -514,21 +687,24 @@ class HardwareSourcePanelGen : public wxPanel /////////////////////////////////////////////////////////////////////////////// class FluxfileSourcePanelGen : public wxPanel { - private: +private: +protected: + wxStaticText* m_staticText28; + wxStaticText* m_staticText27; + wxStaticText* m_staticText281; - protected: - wxStaticText* m_staticText28; - wxStaticText* m_staticText27; - wxStaticText* m_staticText281; +public: + wxFilePickerCtrl* fluxImagePicker; + wxChoice* fluxImageFormat; - public: - wxFilePickerCtrl* fluxImagePicker; - wxChoice* fluxImageFormat; - - FluxfileSourcePanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - - ~FluxfileSourcePanelGen(); + FluxfileSourcePanelGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(-1, -1), + long style = wxTAB_TRAVERSAL, + const wxString& name = wxEmptyString); + ~FluxfileSourcePanelGen(); }; /////////////////////////////////////////////////////////////////////////////// @@ -536,18 +712,20 @@ class FluxfileSourcePanelGen : public wxPanel /////////////////////////////////////////////////////////////////////////////// class ImagefileSourcePanelGen : public wxPanel { - private: +private: +protected: + wxStaticText* m_staticText29; + wxStaticText* m_staticText28; - protected: - wxStaticText* m_staticText29; - wxStaticText* m_staticText28; +public: + wxFilePickerCtrl* diskImagePicker; - public: - wxFilePickerCtrl* diskImagePicker; - - ImagefileSourcePanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - - ~ImagefileSourcePanelGen(); + ImagefileSourcePanelGen(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(-1, -1), + long style = wxTAB_TRAVERSAL, + const wxString& name = wxEmptyString); + ~ImagefileSourcePanelGen(); }; - diff --git a/src/gui/main.cc b/src/gui/main.cc index f4817631..f9ba7525 100644 --- a/src/gui/main.cc +++ b/src/gui/main.cc @@ -1,7 +1,7 @@ #include "lib/globals.h" #include "lib/logger.h" #include "gui.h" -#include "utils.h" +#include "lib/utils.h" class FluxEngineApp; class ExecEvent; @@ -53,19 +53,19 @@ private: bool FluxEngineApp::OnInit() { - try - { - wxImage::AddHandler(new wxPNGHandler()); - Bind(EXEC_EVENT_TYPE, &FluxEngineApp::OnExec, this); - _mainWindow = CreateMainWindow(); - _mainWindow->Show(true); - return true; - } - catch (const ErrorException* e) - { - fmt::print(stderr, "Exception on startup: {}\n", e->message); - exit(1); - } + try + { + wxImage::AddHandler(new wxPNGHandler()); + Bind(EXEC_EVENT_TYPE, &FluxEngineApp::OnExec, this); + _mainWindow = CreateMainWindow(); + _mainWindow->Show(true); + return true; + } + catch (const ErrorException* e) + { + fmt::print(stderr, "Exception on startup: {}\n", e->message); + exit(1); + } } wxThread::ExitCode FluxEngineApp::Entry() diff --git a/src/gui/mainwindow.cc b/src/gui/mainwindow.cc index 0865358e..ef2464be 100644 --- a/src/gui/mainwindow.cc +++ b/src/gui/mainwindow.cc @@ -1,15 +1,15 @@ -#include "globals.h" -#include "proto.h" +#include "lib/globals.h" +#include "lib/proto.h" #include "gui.h" -#include "logger.h" -#include "readerwriter.h" -#include "fluxsource/fluxsource.h" -#include "fluxsink/fluxsink.h" -#include "imagereader/imagereader.h" -#include "imagewriter/imagewriter.h" -#include "encoders/encoders.h" -#include "decoders/decoders.h" -#include "utils.h" +#include "lib/logger.h" +#include "lib/readerwriter.h" +#include "lib/fluxsource/fluxsource.h" +#include "lib/fluxsink/fluxsink.h" +#include "lib/imagereader/imagereader.h" +#include "lib/imagewriter/imagewriter.h" +#include "lib/encoders/encoders.h" +#include "lib/decoders/decoders.h" +#include "lib/utils.h" #include "fluxviewerwindow.h" #include "textviewerwindow.h" #include "fileviewerwindow.h" diff --git a/src/gui/manifest.xml b/src/gui/manifest.xml new file mode 100644 index 00000000..2ca99465 --- /dev/null +++ b/src/gui/manifest.xml @@ -0,0 +1,13 @@ + + + FluxEngine + + + + + + + + diff --git a/src/gui/texteditorwindow.cc b/src/gui/texteditorwindow.cc index 92e7ef51..082a0b7f 100644 --- a/src/gui/texteditorwindow.cc +++ b/src/gui/texteditorwindow.cc @@ -1,6 +1,6 @@ -#include "globals.h" +#include "lib/globals.h" #include "gui.h" -#include "layout.h" +#include "lib/layout.h" #include "texteditorwindow.h" wxDEFINE_EVENT(EDITOR_SAVE_EVENT, EditorSaveEvent); diff --git a/src/gui/textviewerwindow.cc b/src/gui/textviewerwindow.cc index 98187eba..e0a0da2a 100644 --- a/src/gui/textviewerwindow.cc +++ b/src/gui/textviewerwindow.cc @@ -1,6 +1,6 @@ -#include "globals.h" +#include "lib/globals.h" #include "gui.h" -#include "layout.h" +#include "lib/layout.h" #include "textviewerwindow.h" TextViewerWindow::TextViewerWindow(wxWindow* parent, diff --git a/src/gui/visualisationcontrol.cc b/src/gui/visualisationcontrol.cc index 1aa7a24f..24e2e795 100644 --- a/src/gui/visualisationcontrol.cc +++ b/src/gui/visualisationcontrol.cc @@ -1,10 +1,10 @@ -#include "globals.h" +#include "lib/globals.h" #include "gui.h" #include "visualisationcontrol.h" -#include "fluxmap.h" -#include "flux.h" -#include "sector.h" -#include "image.h" +#include "lib/fluxmap.h" +#include "lib/flux.h" +#include "lib/sector.h" +#include "lib/image.h" #include "lib/layout.h" #define BORDER 20 diff --git a/src/gui/windres.rc b/src/gui/windres.rc new file mode 100644 index 00000000..9d2a5059 --- /dev/null +++ b/src/gui/windres.rc @@ -0,0 +1,9 @@ +/* © 2023 David Given. + * FluxEngine is licensed under the MIT open source license. See the COPYING + * file in this distribution for the full text. + */ + +#include "winuser.h" + +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "src/gui/manifest.xml" +101 ICON DISCARDABLE ".obj/extras+fluxengine_ico/fluxengine.ico" diff --git a/src/readibm.h b/src/readibm.h index 0d42ef8e..9bdfb33f 100644 --- a/src/readibm.h +++ b/src/readibm.h @@ -1,7 +1,7 @@ #ifndef READIBM_H #define READIBM_H -#include "flags.h" +#include "lib/flags.h" #include "dataspec.h" extern IntFlag sectorIdBase; diff --git a/tests/agg.cc b/tests/agg.cc index f6b78041..442bf4a0 100644 --- a/tests/agg.cc +++ b/tests/agg.cc @@ -1,7 +1,7 @@ -#include "globals.h" -#include "bytes.h" -#include "dep/agg/include/agg2d.h" -#include "dep/stb/stb_image_write.h" +#include "lib/globals.h" +#include "lib/bytes.h" +#include "agg2d.h" +#include "stb_image_write.h" #include static void test_agg(void) diff --git a/tests/amiga.cc b/tests/amiga.cc index 163a9ffe..4fa0c88f 100644 --- a/tests/amiga.cc +++ b/tests/amiga.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "bytes.h" -#include "decoders/decoders.h" +#include "lib/globals.h" +#include "lib/bytes.h" +#include "lib/decoders/decoders.h" #include "arch/amiga/amiga.h" #include diff --git a/tests/bitaccumulator.cc b/tests/bitaccumulator.cc index 83788ac2..0321155a 100644 --- a/tests/bitaccumulator.cc +++ b/tests/bitaccumulator.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/bytes.h" #include int main(int argc, const char* argv[]) diff --git a/tests/build.mk b/tests/build.mk deleted file mode 100644 index 08d617c6..00000000 --- a/tests/build.mk +++ /dev/null @@ -1,56 +0,0 @@ - -$(OBJDIR)/tests/%.log: $(OBJDIR)/tests/%.exe - @mkdir -p $(dir $@) - @echo TEST $* - @$< && touch $@ - -declare-test = $(eval $(declare-test-impl)) -define declare-test-impl - -tests: $(OBJDIR)/tests/$1.log -$(OBJDIR)/tests/$1.exe: $(OBJDIR)/tests/$1.o -$(OBJDIR)/tests/$1.o: private CFLAGS += -Idep/snowhouse/include -OBJS += $(OBJDIR)/tests/$1.o -$(call use-library, $(OBJDIR)/tests/$1.exe, $(OBJDIR)/tests/$1.o, LIBARCH) -$(call use-library, $(OBJDIR)/tests/$1.exe, $(OBJDIR)/tests/$1.o, LIBFLUXENGINE) -$(call use-library, $(OBJDIR)/tests/$1.exe, $(OBJDIR)/tests/$1.o, LIBFORMATS) -$(call use-library, $(OBJDIR)/tests/$1.exe, $(OBJDIR)/tests/$1.o, LIBUSBP) -$(call use-library, $(OBJDIR)/tests/$1.exe, $(OBJDIR)/tests/$1.o, PROTO) -$(call use-library, $(OBJDIR)/tests/$1.exe, $(OBJDIR)/tests/$1.o, FATFS) -$(call use-library, $(OBJDIR)/tests/$1.exe, $(OBJDIR)/tests/$1.o, ADFLIB) -$(call use-library, $(OBJDIR)/tests/$1.exe, $(OBJDIR)/tests/$1.o, HFSUTILS) - -endef - -$(call declare-test,agg) -$(call declare-test,amiga) -$(call declare-test,applesingle) -$(call declare-test,bitaccumulator) -$(call declare-test,bytes) -$(call declare-test,compression) -$(call declare-test,configs) -$(call declare-test,cpmfs) -$(call declare-test,csvreader) -$(call declare-test,flags) -$(call declare-test,fluxmapreader) -$(call declare-test,fluxpattern) -$(call declare-test,flx) -$(call declare-test,fmmfm) -$(call declare-test,greaseweazle) -$(call declare-test,kryoflux) -$(call declare-test,layout) -$(call declare-test,ldbs) -$(call declare-test,options) -$(call declare-test,proto) -$(call declare-test,utils) -$(call declare-test,vfs) - -$(call use-library, $(OBJDIR)/tests/agg.exe, $(OBJDIR)/tests/agg.o, AGG) -$(call use-library, $(OBJDIR)/tests/agg.exe, $(OBJDIR)/tests/agg.o, STB) - -$(OBJDIR)/tests/proto.exe: $(OBJDIR)/tests/testproto.o -$(OBJDIR)/tests/testproto.cc: $(OBJDIR)/protoencode_TestProto.exe tests/testproto.textpb - @mkdir -p $(dir $@) - @echo PROTOENCODE $@ - @$^ $@ testproto_pb - diff --git a/tests/build.py b/tests/build.py new file mode 100644 index 00000000..ef3f9625 --- /dev/null +++ b/tests/build.py @@ -0,0 +1,104 @@ +from build.ab import export +from build.c import cxxprogram +from build.protobuf import proto, protocc +from build.utils import test +from scripts.build import protoencode + + +proto( + name="test_proto", + srcs=[ + "./testproto.proto", + ], +) + +protocc( + name="test_proto_lib", + srcs=[".+test_proto"], + deps=["lib+config_proto", "arch+arch_proto"], +) + +tests = [ + "agg", + "amiga", + "applesingle", + "bitaccumulator", + "bytes", + "compression", + "configs", + "cpmfs", + "csvreader", + "flags", + "fluxmapreader", + "fluxpattern", + "flx", + "fmmfm", + "greaseweazle", + "kryoflux", + "layout", + "ldbs", + "options", + "utils", + "vfs", +] + +export( + name="tests", + deps=[ + test( + name="proto_test", + command=cxxprogram( + name="proto_test_exe", + srcs=[ + "./proto.cc", + protoencode( + name="testproto_cc", + srcs=["./testproto.textpb"], + proto="TestProto", + symbol="testproto_pb", + ), + ], + deps=[ + "+fl2_proto_lib", + "+protocol", + "+z_lib", + ".+test_proto_lib", + "dep/adflib", + "dep/agg", + "dep/fatfs", + "dep/hfsutils", + "dep/libusbp", + "dep/snowhouse", + "dep/stb", + "+lib", + "lib+config_proto_lib", + "src/formats", + ], + ), + ), + ] + + [ + test( + name=f"{n}_test", + command=cxxprogram( + name=f"{n}_test_exe", + srcs=[f"./{n}.cc"], + deps=[ + "+fl2_proto_lib", + "+protocol", + "dep/adflib", + "dep/agg", + "dep/fatfs", + "dep/hfsutils", + "dep/libusbp", + "dep/snowhouse", + "dep/stb", + "+lib", + "lib+config_proto_lib", + "src/formats", + ], + ), + ) + for n in tests + ], +) diff --git a/tests/bytes.cc b/tests/bytes.cc index b572792e..539e5b46 100644 --- a/tests/bytes.cc +++ b/tests/bytes.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/bytes.h" #include "snowhouse/snowhouse.h" using namespace snowhouse; diff --git a/tests/compression.cc b/tests/compression.cc index ba1d1f56..102788a3 100644 --- a/tests/compression.cc +++ b/tests/compression.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/bytes.h" static void test_roundtrip() { diff --git a/tests/configs.cc b/tests/configs.cc index 361de8b1..a5d4c658 100644 --- a/tests/configs.cc +++ b/tests/configs.cc @@ -83,8 +83,8 @@ static void validateConfigWithOptions(std::string baseConfigName, { /* All configs must have a tpi. */ - if (!config.layout().has_tpi()) - configError("{}{}: no layout.tpi set", baseConfigName, options); + if (!config.layout().has_format_type()) + configError("{}{}: no layout.format_type set", baseConfigName, options); } static void validateToplevelConfig(std::string name) diff --git a/tests/cpmfs.cc b/tests/cpmfs.cc index dfe53dc9..48ad5928 100644 --- a/tests/cpmfs.cc +++ b/tests/cpmfs.cc @@ -1,4 +1,4 @@ -#include "globals.h" +#include "lib/globals.h" #include "lib/vfs/vfs.h" #include "lib/vfs/sectorinterface.h" #include "lib/vfs/vfs.pb.h" @@ -119,11 +119,11 @@ int main(void) { const std::string text = R"M( drive { - tpi: 96 + drive_type: DRIVETYPE_80TRACK } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 10 sides: 1 layoutdata { diff --git a/tests/csvreader.cc b/tests/csvreader.cc index 3ed7ff3c..57bc365d 100644 --- a/tests/csvreader.cc +++ b/tests/csvreader.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "csvreader.h" +#include "lib/globals.h" +#include "lib/csvreader.h" #include typedef std::vector strings; diff --git a/tests/flags.cc b/tests/flags.cc index 79e19735..89ed0989 100644 --- a/tests/flags.cc +++ b/tests/flags.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "flags.h" +#include "lib/globals.h" +#include "lib/flags.h" #include static void testDefaultIntValue() diff --git a/tests/fluxmapreader.cc b/tests/fluxmapreader.cc index be090e7c..996ab85b 100644 --- a/tests/fluxmapreader.cc +++ b/tests/fluxmapreader.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" #include "protocol.h" #include "fmt/format.h" #include "tests.h" diff --git a/tests/fluxpattern.cc b/tests/fluxpattern.cc index 013ede65..3dcdcb13 100644 --- a/tests/fluxpattern.cc +++ b/tests/fluxpattern.cc @@ -1,6 +1,6 @@ -#include "globals.h" -#include "fluxmap.h" -#include "decoders/fluxmapreader.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/decoders/fluxmapreader.h" #include typedef std::vector ivector; diff --git a/tests/flx.cc b/tests/flx.cc index 85b0f045..bc26e65d 100644 --- a/tests/flx.cc +++ b/tests/flx.cc @@ -1,7 +1,7 @@ #include #include #include -#include "globals.h" +#include "lib/globals.h" #include "lib/fluxmap.h" #include "lib/fluxsource/flx.h" diff --git a/tests/fmmfm.cc b/tests/fmmfm.cc index ed105e03..f5a4c29a 100644 --- a/tests/fmmfm.cc +++ b/tests/fmmfm.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "decoders/decoders.h" +#include "lib/globals.h" +#include "lib/decoders/decoders.h" #include static void testDecode(void) diff --git a/tests/greaseweazle.cc b/tests/greaseweazle.cc index 9a57832d..8ddbc8dd 100644 --- a/tests/greaseweazle.cc +++ b/tests/greaseweazle.cc @@ -1,8 +1,8 @@ #include #include #include -#include "globals.h" -#include "fluxmap.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" #include "lib/usb/greaseweazle.h" #define E28(val) \ diff --git a/tests/kryoflux.cc b/tests/kryoflux.cc index 8361a82d..175a5411 100644 --- a/tests/kryoflux.cc +++ b/tests/kryoflux.cc @@ -1,9 +1,9 @@ #include #include #include -#include "globals.h" -#include "fluxmap.h" -#include "fluxsource/kryoflux.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/fluxsource/kryoflux.h" static void test_convert(const Bytes& kryofluxbytes, const Bytes& fluxmapbytes) { diff --git a/tests/layout.cc b/tests/layout.cc index 086a2c03..eef179ba 100644 --- a/tests/layout.cc +++ b/tests/layout.cc @@ -22,11 +22,11 @@ static void test_physical_sectors() globalConfig().clear(); globalConfig().readBaseConfig(R"M( drive { - tpi: 96 + drive_type: DRIVETYPE_80TRACK } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 78 sides: 2 layoutdata { @@ -55,11 +55,11 @@ static void test_logical_sectors() globalConfig().clear(); globalConfig().readBaseConfig(R"M( drive { - tpi: 96 + drive_type: DRIVETYPE_80TRACK } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 78 sides: 2 layoutdata { @@ -94,11 +94,11 @@ static void test_both_sectors() globalConfig().clear(); globalConfig().readBaseConfig(R"M( drive { - tpi: 96 + drive_type: DRIVETYPE_80TRACK } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 78 sides: 2 layoutdata { @@ -133,11 +133,11 @@ static void test_skew() globalConfig().clear(); globalConfig().readBaseConfig(R"M( drive { - tpi: 96 + drive_type: DRIVETYPE_80TRACK } layout { - tpi: 96 + format_type: FORMATTYPE_80TRACK tracks: 78 sides: 2 layoutdata { diff --git a/tests/ldbs.cc b/tests/ldbs.cc index 9c295702..af97933b 100644 --- a/tests/ldbs.cc +++ b/tests/ldbs.cc @@ -1,9 +1,9 @@ #include #include #include -#include "globals.h" -#include "bytes.h" -#include "ldbs.h" +#include "lib/globals.h" +#include "lib/bytes.h" +#include "lib/ldbs.h" static Bytes testdata{ // clang-format off diff --git a/tests/options.cc b/tests/options.cc index 4d712326..dd8eb13c 100644 --- a/tests/options.cc +++ b/tests/options.cc @@ -1,8 +1,8 @@ -#include "globals.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/bytes.h" #include "tests/testproto.pb.h" #include "lib/config.pb.h" -#include "proto.h" +#include "lib/proto.h" #include "snowhouse/snowhouse.h" #include #include @@ -23,15 +23,15 @@ static void test_option_validity() globalConfig().clear(); globalConfig().readBaseConfig(R"M( drive { - tpi: 96 + drive_type: DRIVETYPE_80TRACK } option { name: "option1" prerequisite: { - key: "drive.tpi" - value: "96" + key: "drive.drive_type" + value: "DRIVETYPE_80TRACK" } } @@ -39,8 +39,8 @@ static void test_option_validity() name: "option2" prerequisite: { - key: "drive.tpi" - value: "95" + key: "drive.drive_type" + value: "DRIVETYPE_40TRACK" } } @@ -48,8 +48,8 @@ static void test_option_validity() name: "option3" prerequisite: { - key: "drive.tpi" - value: ["0", "96"] + key: "drive.drive_type" + value: ["DRIVETYPE_UNKNOWN", "DRIVETYPE_80TRACK"] } } )M"); diff --git a/tests/proto.cc b/tests/proto.cc index 04850bc7..1386f689 100644 --- a/tests/proto.cc +++ b/tests/proto.cc @@ -1,8 +1,8 @@ -#include "globals.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/bytes.h" #include "tests/testproto.pb.h" #include "lib/config.pb.h" -#include "proto.h" +#include "lib/proto.h" #include "snowhouse/snowhouse.h" #include #include diff --git a/tests/utils.cc b/tests/utils.cc index 5ff64b03..b98901de 100644 --- a/tests/utils.cc +++ b/tests/utils.cc @@ -1,5 +1,5 @@ -#include "globals.h" -#include "utils.h" +#include "lib/globals.h" +#include "lib/utils.h" #include "snowhouse/snowhouse.h" using namespace snowhouse; diff --git a/tests/vfs.cc b/tests/vfs.cc index 158c9524..523355ce 100644 --- a/tests/vfs.cc +++ b/tests/vfs.cc @@ -1,4 +1,4 @@ -#include "globals.h" +#include "lib/globals.h" #include "lib/vfs/vfs.h" #include "snowhouse/snowhouse.h" diff --git a/tools/brother120tool.cc b/tools/brother120tool.cc index a124842b..ccec94f2 100644 --- a/tools/brother120tool.cc +++ b/tools/brother120tool.cc @@ -1,7 +1,7 @@ -#include "globals.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/bytes.h" #include "fmt/format.h" -#include "utils.h" +#include "lib/utils.h" #include #include "fnmatch.h" diff --git a/tools/brother240tool.cc b/tools/brother240tool.cc index 18195683..9cfbcac6 100644 --- a/tools/brother240tool.cc +++ b/tools/brother240tool.cc @@ -1,4 +1,4 @@ -#include "globals.h" +#include "lib/globals.h" #include "fmt/format.h" #include diff --git a/tools/build.mk b/tools/build.mk deleted file mode 100644 index 1586c7f1..00000000 --- a/tools/build.mk +++ /dev/null @@ -1,43 +0,0 @@ -$(OBJDIR)/brother120tool.exe: $(OBJDIR)/tools/brother120tool.o -$(OBJDIR)/brother240tool.exe: $(OBJDIR)/tools/brother240tool.o -$(OBJDIR)/upgrade-flux-file.exe: $(OBJDIR)/tools/upgrade-flux-file.o - -OBJS += \ - $(OBJDIR)/tools/brother120tool.o \ - $(OBJDIR)/tools/brother240tool.o \ - $(OBJDIR)/tools/upgrade-flux-file.o \ - -$(call use-library, $(OBJDIR)/brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, PROTO) -$(call use-library, $(OBJDIR)/brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, LIBFLUXENGINE) -$(call use-library, $(OBJDIR)/brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, LIBFORMATS) -$(call use-library, $(OBJDIR)/brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, LIBUSBP) -$(call use-library, $(OBJDIR)/brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, PROTO) -$(call use-library, $(OBJDIR)/brother120tool.exe, $(OBJDIR)/tools/brother120tool.o, EMU) - -$(call use-library, $(OBJDIR)/brother240tool.exe, $(OBJDIR)/tools/brother240tool.o, PROTO) -$(call use-library, $(OBJDIR)/brother240tool.exe, $(OBJDIR)/tools/brother240tool.o, LIBFLUXENGINE) -$(call use-library, $(OBJDIR)/brother240tool.exe, $(OBJDIR)/tools/brother240tool.o, LIBFORMATS) -$(call use-library, $(OBJDIR)/brother240tool.exe, $(OBJDIR)/tools/brother240tool.o, LIBUSBP) -$(call use-library, $(OBJDIR)/brother240tool.exe, $(OBJDIR)/tools/brother240tool.o, EMU) - -$(call use-pkgconfig, $(OBJDIR)/upgrade-flux-file.exe, $(OBJDIR)/tools/upgrade-flux-file.o, sqlite3) -$(call use-library, $(OBJDIR)/upgrade-flux-file.exe, $(OBJDIR)/tools/upgrade-flux-file.o, LIBARCH) -$(call use-library, $(OBJDIR)/upgrade-flux-file.exe, $(OBJDIR)/tools/upgrade-flux-file.o, LIBFLUXENGINE) -$(call use-library, $(OBJDIR)/upgrade-flux-file.exe, $(OBJDIR)/tools/upgrade-flux-file.o, LIBFORMATS) -$(call use-library, $(OBJDIR)/upgrade-flux-file.exe, $(OBJDIR)/tools/upgrade-flux-file.o, PROTO) -$(call use-library, $(OBJDIR)/upgrade-flux-file.exe, $(OBJDIR)/tools/upgrade-flux-file.o, LIBUSBP) - -brother120tool$(EXT): $(OBJDIR)/brother120tool.exe - @echo CP $@ - @cp $< $@ - -brother240tool$(EXT): $(OBJDIR)/brother240tool.exe - @echo CP $@ - @cp $< $@ - -upgrade-flux-file$(EXT): $(OBJDIR)/upgrade-flux-file.exe - @echo CP $@ - @cp $< $@ - -binaries: brother120tool$(EXT) brother240tool$(EXT) upgrade-flux-file$(EXT) - diff --git a/tools/build.py b/tools/build.py new file mode 100644 index 00000000..5d2895f5 --- /dev/null +++ b/tools/build.py @@ -0,0 +1,32 @@ +from build.c import cxxprogram +import config + +emu = [] +if config.windows: + emu = ["dep/emu"] + +cxxprogram( + name="brother120tool", + srcs=["./brother120tool.cc"], + deps=["+lib", "lib+config_proto_lib"] + emu, +) + +cxxprogram( + name="brother240tool", + srcs=["./brother240tool.cc"], + deps=["+lib", "lib+config_proto_lib"] + emu, +) + +cxxprogram( + name="upgrade-flux-file", + srcs=["./upgrade-flux-file.cc"], + deps=[ + "+lib", + "src/formats", + "lib+config_proto_lib", + "+protocol", + "+fl2_proto_lib", + "+sqlite3_lib", + "dep/libusbp", + ], +) diff --git a/tools/upgrade-flux-file.cc b/tools/upgrade-flux-file.cc index 6c49eaff..9aaa8589 100644 --- a/tools/upgrade-flux-file.cc +++ b/tools/upgrade-flux-file.cc @@ -1,7 +1,7 @@ -#include "globals.h" -#include "fluxmap.h" -#include "fluxsink/fluxsink.h" -#include "bytes.h" +#include "lib/globals.h" +#include "lib/fluxmap.h" +#include "lib/fluxsink/fluxsink.h" +#include "lib/bytes.h" #include "fmt/format.h" #include #include