Kevin Lee 4 months ago
commit
86b86d25ec
10 changed files with 1210 additions and 0 deletions
  1. 2 0
      .gitignore
  2. 529 0
      Cargo.lock
  3. 13 0
      Cargo.toml
  4. BIN
      Rectangle.mlp
  5. 131 0
      Shapes.txt
  6. 370 0
      imhex.txt
  7. 49 0
      src/ezcad/basic_field.rs
  8. 75 0
      src/ezcad/field_of.rs
  9. 2 0
      src/ezcad/mod.rs
  10. 39 0
      src/main.rs

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+/target
+.vscode/

+ 529 - 0
Cargo.lock

@@ -0,0 +1,529 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "aho-corasick"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "anstream"
+version = "0.6.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
+
+[[package]]
+name = "anstyle-parse"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
+dependencies = [
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
+dependencies = [
+ "anstyle",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "array-init"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc"
+
+[[package]]
+name = "binrw"
+version = "0.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "173901312e9850391d4d7c1318c4e099fdc037d61870fca427429830efdb4e5f"
+dependencies = [
+ "array-init",
+ "binrw_derive",
+ "bytemuck",
+]
+
+[[package]]
+name = "binrw_derive"
+version = "0.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb515fdd6f8d3a357c8e19b8ec59ef53880807864329b1cb1cba5c53bf76557e"
+dependencies = [
+ "either",
+ "owo-colors",
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "bitflags"
+version = "2.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
+
+[[package]]
+name = "bytemuck"
+version = "1.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
+
+[[package]]
+name = "clap"
+version = "4.4.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2"
+dependencies = [
+ "clap_builder",
+ "clap_derive",
+]
+
+[[package]]
+name = "clap-verbosity-flag"
+version = "2.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c90e95e5bd4e8ac34fa6f37c774b0c6f8ed06ea90c79931fd448fcf941a9767"
+dependencies = [
+ "clap",
+ "log",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.4.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "clap_lex",
+ "strsim",
+]
+
+[[package]]
+name = "clap_derive"
+version = "4.4.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.42",
+]
+
+[[package]]
+name = "clap_lex"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
+
+[[package]]
+name = "colorchoice"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
+
+[[package]]
+name = "either"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
+
+[[package]]
+name = "env_logger"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece"
+dependencies = [
+ "humantime",
+ "is-terminal",
+ "log",
+ "regex",
+ "termcolor",
+]
+
+[[package]]
+name = "errno"
+version = "0.3.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
+dependencies = [
+ "libc",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "ezcad_patcher"
+version = "0.1.0"
+dependencies = [
+ "binrw",
+ "clap",
+ "clap-verbosity-flag",
+ "env_logger",
+ "log",
+]
+
+[[package]]
+name = "heck"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
+
+[[package]]
+name = "hermit-abi"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
+
+[[package]]
+name = "humantime"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
+
+[[package]]
+name = "is-terminal"
+version = "0.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
+dependencies = [
+ "hermit-abi",
+ "rustix",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.151"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.4.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
+
+[[package]]
+name = "log"
+version = "0.4.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
+
+[[package]]
+name = "memchr"
+version = "2.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
+
+[[package]]
+name = "owo-colors"
+version = "3.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.71"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.33"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "regex"
+version = "1.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
+
+[[package]]
+name = "rustix"
+version = "0.38.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316"
+dependencies = [
+ "bitflags",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "strsim"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
+
+[[package]]
+name = "syn"
+version = "1.0.109"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.42"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "termcolor"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
+
+[[package]]
+name = "utf8parse"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-util"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "windows-sys"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
+dependencies = [
+ "windows-targets 0.48.5",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
+dependencies = [
+ "windows-targets 0.52.0",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
+dependencies = [
+ "windows_aarch64_gnullvm 0.48.5",
+ "windows_aarch64_msvc 0.48.5",
+ "windows_i686_gnu 0.48.5",
+ "windows_i686_msvc 0.48.5",
+ "windows_x86_64_gnu 0.48.5",
+ "windows_x86_64_gnullvm 0.48.5",
+ "windows_x86_64_msvc 0.48.5",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
+dependencies = [
+ "windows_aarch64_gnullvm 0.52.0",
+ "windows_aarch64_msvc 0.52.0",
+ "windows_i686_gnu 0.52.0",
+ "windows_i686_msvc 0.52.0",
+ "windows_x86_64_gnu 0.52.0",
+ "windows_x86_64_gnullvm 0.52.0",
+ "windows_x86_64_msvc 0.52.0",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"

+ 13 - 0
Cargo.toml

@@ -0,0 +1,13 @@
+[package]
+name = "ezcad_patcher"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+binrw = "0.13.3"
+clap = { version = "4.4.11", features = ["derive"] }
+clap-verbosity-flag = "2.1.1"
+env_logger = "0.10.1"
+log = "0.4.20"

BIN
Rectangle.mlp


+ 131 - 0
Shapes.txt

@@ -0,0 +1,131 @@
+Point 		01 00 00 00
+				00 00 00 00
+			01 00 00 00 00 00
+				A8 42 B4 E1 F3 47 2E C0 80 97 3C 18 70 C6 05 40
+
+Line 		01 00 00 00
+				00 00 00 00
+			00 01 00 00 00 00
+				02 00 00 00
+					58 BD 4B 1E 0C 38 3B C0 14 A2 0D 9F 3F E6 2B 40
+					F8 63 8E D2 ED AB 20 C0 78 97 3C 18 70 C6 15 40
+
+ Multiline	01 00 00 00
+ 				00 00 00 00
+ 			00 01 00 00 00 00
+ 				04 00 00 00
+					36 7C FE 98 A3 74 36 C0 2C 12 D4 54 88 B6 22 40
+					30 7C FE 98 A3 74 16 C0 40 BD 4B 1E 0C 38 EB 3F
+					40 50 53 21 DA F0 1D C0 70 2D 12 D4 54 08 22 C0
+					48 50 53 21 DA F0 2D C0 A0 A6 42 B4 E1 33 32 C0
+
+Curve 		01 00 00 00
+				00 00 00 00
+			00 03 00 00 00 00
+				04 00 00 00
+					AE 45 82 9A 0A D1 37 C0 FC CA EA 5D F2 E0 2A 40
+					BA E4 C1 80 33 6E 3D C0 E0 F3 C7 1C A5 DB 19 40
+					28 0F 06 9C 71 2D 39 C0 30 79 30 E0 8C EB 2C C0
+					28 0F 06 9C 71 2D 29 C0 A0 A6 42 B4 E1 33 32 C0
+Multicurve	02 00 00 00
+				00 00 00 00
+			00 03 00 00 00 00
+				04 00 00 00
+					EC 2B AB 77 C9 43 35 C0 5C BD 4B 1E 0C 38 2B 40
+					9C D8 89 9D D8 89 3A C0 9C 71 2D 12 D4 54 20 40
+					AC 45 82 9A 0A D1 37 C0 4C 50 53 21 DA F0 2D C0
+					78 97 3C 18 70 C6 25 C0 58 56 EF 92 07 03 31 C0
+			00 03 00 00 00 00
+				04 00 00 00
+					78 97 3C 18 70 C6 25 C0 58 56 EF 92 07 03 31 C0
+					A0 71 2D 12 D4 54 00 40 8A 04 35 15 A2 0D 33 C0
+					C0 B2 7A 97 3C 18 25 40 88 6B 91 A0 A6 42 2D C0
+					58 BD 4B 1E 0C 38 2B 40 88 6B 91 A0 A6 42 1D C0
+Multicurve2 03 00 00 00
+				00 00 00 00
+			00 03 00 00 00 00
+				04 00 00 00
+					10 6D F8 FC 31 07 3A C0 E4 F3 C7 1C A5 DB 29 40
+					B2 7A 97 3C 18 B0 39 C0 60 BD 4B 1E 0C 38 0B 40
+					3C E6 28 DD BE 32 3A C0 B4 48 50 53 21 5A 31 C0
+					88 6B 91 A0 A6 42 2D C0 12 3B B1 13 3B B1 31 C0
+			00 03 00 00 00 00
+				04 00 00 00
+					88 6B 91 A0 A6 42 2D C0 12 3B B1 13 3B B1 31 C0
+					60 2A 44 1B 3E 7F 08 C0 70 2D 12 D4 54 08 32 C0
+					FC 63 8E D2 ED AB 30 40 F4 95 D5 BB E4 01 39 C0
+					8C 04 35 15 A2 0D 33 40 2C 79 30 E0 8C EB 2C C0
+			00 03 00 00 00 00
+				04 00 00 00
+					8C 04 35 15 A2 0D 33 40 2C 79 30 E0 8C EB 2C C0
+					1C A5 DB 57 56 6F 35 40 C0 19 D7 22 41 4D 0F C0
+					A0 A6 42 B4 E1 33 32 40 78 6B 91 A0 A6 42 1D 40
+					F0 60 C0 19 D7 22 27 40 9A 71 2D 12 D4 54 30 40
+Rectangle	08 00 00 00
+				10 00 00 00
+					B2 7A 97 3C 18 B0 39 C0 2C 12 D4 54 88 B6 22 40
+				10 00 00 00
+					40 50 53 21 DA F0 FD 3F F8 63 8E D2 ED AB 20 C0
+				08 00 00 00
+					00 00 00 00 00 00 00 00
+				08 00 00 00
+					00 00 00 00 00 00 00 00
+				08 00 00 00
+					00 00 00 00 00 00 00 00
+				08 00 00 00
+					00 00 00 00 00 00 00 00
+				04 00 00 00
+					00 00 00 00
+				48 00 00 00
+					70 00 00 00 00 00 F0 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F0 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F0 3F
+Circle		06 00 00 00
+				10 00 00 00
+					00 35 15 A2 0D 9F 1E C0 80 04 35 15 A2 0D F3 3F
+				08 00 00 00
+					7F 43 DA 09 B8 95 31 40
+				08 00 00 00
+					E0 86 44 54 FB 21 F9 3F
+				04 00 00 00
+					01 00 00 00
+				04 00 00 00
+					00 00 00 00
+				48 00 00 00
+					00 00 00 00 00 00 F0 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F0 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F0 3F
+Ellipse		08 00 00 00
+				04 00 00 00
+					00 00 00 00
+				10 00 00 00
+					00 CE B8 16 09 6A 24 C0 F0 60 C0 19 D7 22 17 C0
+				10 00 00 00
+					5C 8B 04 35 15 E2 32 40 7C 97 3C 18 70 C6 25 40
+				08 00 00 00
+					00 00 00 00 00 00 00 00
+				08 00 00 00
+					EA 2E 44 54 FB 21 19 40
+				04 00 00 00
+					00 00 00 00
+				48 00 00 00
+					00 00 00 00 00 00 F0 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F0 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F0 3F
+				04 00 00 00
+					00 00 00 00
+Polygon		0A 00 00 00
+				04 00 00 00
+					00 00 00 00
+				10 00 00 00
+					60 C0 19 D7 22 C1 34 C0 94 6E 5F 59 BD CB 26 C0
+				10 00 00 00
+					00 CE B8 16 09 6A 04 40 EE 92 07 03 CE 78 3F C0
+				08 00 00 00
+					00 00 00 00 00 00 00 00
+				08 00 00 00
+					00 00 00 00 00 00 00 00
+				08 00 00 00
+					00 00 00 00 00 00 00 00
+				08 00 00 00
+					00 00 00 00 00 00 00 00
+				04 00 00 00
+					06 00 00 00
+				04 00 00 00
+					FF 00 00 00
+				48 00 00 00
+					00 00 00 00 00 00 F0 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F0 3F 00 00 00 00 00 00 00 00 88 F9 95 D5 BB 64 13 C0 1C A5 DB 57 56 6F 25 40 00 00 00 00 00 00 F0 3F

+ 370 - 0
imhex.txt

@@ -0,0 +1,370 @@
+#pragma endian little
+#pragma pattern_limit 256000
+
+#include <std/sys.pat>
+#include <std/mem.pat>
+#include <std/io.pat>
+#include <std/core.pat>
+
+struct RGBA8 {
+  u8 red;
+  u8 green;
+  u8 blue;
+  u8 alpha;
+} [[static, color(std::format("{:02X}{:02X}{:02X}", red, green, blue))]];
+
+struct Point {
+    double x;
+    double y;
+};
+
+struct MultiLine {
+    u32 points;
+    Point point[points];
+};
+
+enum WobbleType : u32 {
+    Spiral = 0,
+    Sinusoidal = 1,
+    Ellipse = 2,
+    Vert_8 = 3,
+    Hoti_8 = 4,
+};
+
+// Field of a custom defined type
+struct FieldOf<T> {
+    u32 length;
+    T value;
+    
+    std::assert(length == sizeof(value), "Size mismatch");
+} [[sealed, format("format_field_of")]];
+
+fn format_field_of(FieldOf<u8> f) {
+    return f.value;
+};
+
+// Field of generic types
+struct Field {
+    u32 length;
+    
+    match (length) {
+        (4): u32 value;
+        (8): double value;
+        (2): u16 value; // ??
+        (16): Point value; // ??
+        (1): u32 value; // ??
+        (_): {
+            std::warning(std::format("Unknown length tag: {} at 0x{:02X}", length, $));
+            u8 value[length];
+        }
+    }
+} [[sealed, format("format_field")]];
+
+fn format_field(Field f) {
+    return f.value;
+};
+
+// Variable length field of a fixed type.
+struct String {
+    u32 length;
+    char16 value[length / sizeof(char16)];
+} [[sealed, format("format_string")]];
+
+fn format_string(String s) {
+    return s.value;
+};
+
+struct Header {
+    char16 magic[0x8];
+    u8 unknown[0x338];
+};
+
+struct Pen {
+    u32 num_fields; // Number of fields in this struct (236)
+    Field color;
+    String name;
+    Field disabled;
+    Field use_default_param;
+    Field loop_count;
+    Field speed; // Changes with wobble relative speed
+    Field power;
+    Field frequency;
+    Field unknown_1[1];
+    Field start_tc;
+    Field end_tc;
+    Field polygon_tc;
+    Field jump_speed;
+    Field unknown_2[10];
+    Field laser_off_tc;
+    Field wave; // Only available if continue_mode is false
+    Field unknown_3[1];
+    Field wobble_enable;
+    Field wobble_diameter;
+    Field wobble_distance;
+    Field unknown_4[8];
+    Field min_jump_tc;
+    Field max_jump_tc;
+    Field jump_limit;
+    Field unknown_5[2];
+    Field frequency2;
+    Field unknown_6[152];
+    FieldOf<WobbleType> wobble_type;
+    Field continue_mode;
+    Field unknown_7[12];
+    Field wobble_diameter2; // Only with wobble type ellipse
+    Field unknown_8[26];
+};
+
+bitfield ObjectFlags {
+    disabled : 1;
+    aspect_ratio_unlocked : 1; // ??
+    padding : 14;
+};
+
+enum ObjectType: u32 {
+    Curve = 1,
+    Point = 2,
+    Rectangle = 3,
+    Circle = 4,
+    Ellipse = 5,
+    Polygon = 6,
+    Hatch = 32,
+};
+
+struct ObjCommon {
+    u32 num_fields; // Number of fields in this struct (17)
+    Field pen;
+    Field type; // Seems to always be same value as object type
+    FieldOf<ObjectFlags>;
+    String name;
+    Field count;
+    Field unknown_2[1];
+    Field io_control_enable_mask;
+    Field io_control_disable_mask;
+    Field unknown_3[5];
+    FieldOf<Point> origin;
+    Field z;
+    Field a;
+    Field unknown_4[1];
+};
+
+enum LineType : u16 {
+    Point = 0x0001,
+    Line = 0x0100,
+    Bezier = 0x0300,
+};
+
+struct LineEntry {
+    LineType type;
+    u32; // Zeros
+    
+    match (type) {
+        (LineType::Point): Point;
+        (LineType::Line): {
+            u32 count;
+            Point points[count];
+        }
+        (LineType::Bezier): {
+            u32 count;
+            Point points[count];
+        }
+        (_): std::error(std::format("Unknown line type: 0x{:02X} at 0x{:02X}", u32(type), $));
+    }
+};
+
+struct LineSet : ObjCommon {
+    u32 count;
+    u32; // Zeros
+    
+    LineEntry entries[count];
+};
+
+struct ClosedSet : ObjCommon {
+    u32 count;
+    Field entries[count];
+};
+
+struct Rectangle : ObjCommon {
+    u32 num_fields; // Number of fields in this struct (8)
+    FieldOf<Point> corner_a;
+    FieldOf<Point> corner_b;
+    Field round_bottom_left;
+    Field round_bottom_right;
+    Field round_top_right;
+    Field round_top_left;
+    Field unknown[2];
+};
+
+struct Circle : ObjCommon {
+    u32 num_fields; // Number of fields in this struct (6)
+    FieldOf<Point> origin;
+    Field radius;
+    Field start_angle; // Radians
+    Field clockwise;
+    Field unknown[2];
+};
+
+struct Ellipse : ObjCommon {
+    u32 num_fields; // Number of fields in this struct (8)
+    Field clockwise;
+    FieldOf<Point> corner_a;
+    FieldOf<Point> corner_b;
+    Field start_angle; // Radians
+    Field end_angle; // Radians
+    Field unknown[2];
+    Field open_curve;
+};
+
+struct Polygon : ObjCommon {
+    u32 num_fields; // Number of fields in this struct (10)
+    Field invert_shape;
+    FieldOf<Point> corner_a;
+    FieldOf<Point> corner_b;
+    Field offset_cx; // Moves (intial) sharper corner
+    Field offset_cy; // Moves (initial)sharper corner
+    Field offset_dx;
+    Field offset_dy;
+    Field edges;
+    Field unknown_3[2];
+};
+
+struct HatchLine {
+    u32 num_lines;
+    LineSet line[num_lines];
+};
+
+using Object;
+
+bitfield HatchFlags {
+    padding : 1;
+    follow_edge_once : 1;
+    padding : 4;
+    auto_rotate_hatch_angle : 1;
+    average_distribut_line : 1;
+    padding : 2;
+    cross_hatch : 1;
+    padding : 21;
+};
+
+struct HatchSettings {
+    u32 num_fields; // 46
+    Field flags; // 1 = mark contour
+    Field unknown_1[1];
+    Field pen;
+    FieldOf<HatchFlags> flags_2;
+    Field edge_offset;
+    Field line_spacing;
+    Field start_offset;
+    Field end_offset;
+    Field angle;
+    Field unknown_4[9];
+    Field auto_rotate_angle;
+    Field unknown_7[10];
+    Field line_reduction;
+    Field unknown_3[2];
+    Field num_loops;
+    Field unknown_5[2];
+    Field loop_distance;
+    Field unknown_6[5];
+    Field contour_first;
+    Field count;
+    Field unknown_2[3];
+};
+
+struct HatchSettings2 {
+    u32 num_fields; // 15
+    Field count;
+    Field unknown_1[1];
+    Field pen;
+    FieldOf<HatchFlags> flags_2; // Same as HatchSettings.flags_2
+    Field edge_offset;
+    Field line_spacing;
+    Field start_offset;
+    Field end_offset;
+    Field angle;
+    Field auto_rotate_angle;
+    Field line_reduction;
+    Field loop_distance;
+    Field num_loops;
+    Field unknown_5[2];
+};
+
+struct Hatch : ObjCommon {
+    u32; // 1
+    Object outline;
+    HatchSettings settings;
+    HatchSettings2 settings_2;
+    u32 count_5; //17
+    Field unknown_5[count_5];
+    u32; // 1
+    u32; // 16
+    u32 count_6; // 17
+    Field pen;
+    Field unknown_6[2];
+    String hatch_name;
+    Field unknown_7[count_6 - 4];
+    //Field unknown_6[count_6];
+    
+    u32 num_lines;
+    HatchLine lines[num_lines];    
+};
+
+struct Object {
+    ObjectType type;
+    
+    match (type) {
+        (ObjectType::Curve): LineSet;
+        (ObjectType::Point): LineSet;
+        (ObjectType::Rectangle): Rectangle;
+        (ObjectType::Circle): Circle;
+        (ObjectType::Ellipse): Ellipse;
+        (ObjectType::Polygon): Polygon;
+        (ObjectType::Hatch): Hatch;
+        (_): std::error(std::format("Unknown object type: 0x{:02X} at 0x{:02X}", u32(type), $));
+    }
+};
+
+struct Layer {
+    u32 num_fields_1; // Number of fields before object list (17)
+    Field unknown_1[3];
+    String name;
+    Field count;
+    Field unknown_2[1];
+    Field input_signal_wait_enable_mask;
+    Field input_signal_wait_disable_mask;
+    Field unknown_3[9];
+    u32 object_count;
+    Object objects[object_count];
+    u32 num_fields_2; // Number of fields to footer (151)
+    Field unknown_4[54];
+    Field output_signal_start_enable_mask;
+    Field output_signal_start_disable_mask;
+    Field output_signal_end_enable_mask;
+    Field output_signal_end_disable_mask;
+    Field unknown_5[9];
+    Field fixture_offset;
+    Field unknown_6[64];
+    Field output_signal_start_delay;
+    Field output_signal_end_delay;
+    Field input_signal_wait_enable;
+    Field unknown_7[2];
+    Field output_signal_start_pulse;
+    Field output_signal_end_pulse;
+    Field unknown_8[12];
+    u32 footer;
+};
+
+struct Layers {
+    u32 count;
+    Layer layer[count];
+};
+
+struct File {
+    Header header;
+    RGBA8 thumbnail[40000]; // 200x200?
+    padding[16];
+    Pen pens[256];
+    Layers;
+};
+
+File file @ 0x0;

+ 49 - 0
src/ezcad/basic_field.rs

@@ -0,0 +1,49 @@
+use binrw::{BinRead, BinWrite};
+
+#[derive(BinRead, BinWrite, PartialEq, Debug)]
+enum BasicField {
+    #[brw(magic(2u32))]
+    U16(u16),
+    #[brw(magic(4u32))]
+    U32(u32),
+    #[brw(magic(8u32))]
+    Double(f64),
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use std::io::Cursor;
+
+    #[test]
+    fn field_u32_be() {
+        let encoded: Vec<u8> = vec![0x00, 0x00, 0x00, 0x04, 0x0A, 0x0B, 0x0C, 0x0D];
+        let decoded: u32 = 0x0A0B0C0D;
+
+        let mut stream: Cursor<Vec<u8>> = Cursor::new(encoded.clone());
+        assert_eq!(
+            BasicField::read_be(&mut stream).unwrap(),
+            BasicField::U32(decoded)
+        );
+
+        let mut buffer: Cursor<Vec<u8>> = Cursor::new(vec![]);
+        BasicField::U32(decoded).write_be(&mut buffer).unwrap();
+        assert_eq!(buffer.into_inner(), encoded);
+    }
+
+    #[test]
+    fn field_u32_le() {
+        let encoded: Vec<u8> = vec![0x04, 0x00, 0x00, 0x00, 0x0D, 0x0C, 0x0B, 0x0A];
+        let decoded: u32 = 0x0A0B0C0D;
+
+        let mut stream: Cursor<Vec<u8>> = Cursor::new(encoded.clone());
+        assert_eq!(
+            BasicField::read_le(&mut stream).unwrap(),
+            BasicField::U32(decoded)
+        );
+
+        let mut buffer: Cursor<Vec<u8>> = Cursor::new(vec![]);
+        BasicField::U32(decoded).write_le(&mut buffer).unwrap();
+        assert_eq!(buffer.into_inner(), encoded);
+    }
+}

+ 75 - 0
src/ezcad/field_of.rs

@@ -0,0 +1,75 @@
+use binrw::{binread, binwrite, BinRead, BinWrite};
+use std::mem::size_of;
+
+#[binwrite]
+#[binread]
+#[derive(Debug, PartialEq)]
+struct FieldOf<T>
+where
+    T: for<'a> BinRead<Args<'a> = ()> + Default,
+    T: for<'a> BinWrite<Args<'a> = ()> + Default,
+{
+    #[br(temp, assert(size == size_of::<T>().try_into().unwrap()))]
+    #[bw(try_calc(u32::try_from(size_of::<T>())))]
+    size: u32,
+    pub value: T,
+}
+
+#[cfg(test)]
+mod tests {
+    use std::io::Cursor;
+
+    use super::*;
+
+    #[test]
+    fn field_of_be() {
+        #[derive(BinRead, BinWrite, Debug, PartialEq, Default)]
+        struct Test {
+            a: u32,
+            b: u32,
+        }
+
+        let decoded: FieldOf<Test> = FieldOf {
+            value: Test {
+                a: 0x0A0B0C0D,
+                b: 0x01020304,
+            },
+        };
+        let encoded: Vec<u8> = vec![
+            0x00, 0x00, 0x00, 0x08, 0x0A, 0x0B, 0x0C, 0x0D, 0x01, 0x02, 0x03, 0x04,
+        ];
+
+        let mut stream: Cursor<Vec<u8>> = Cursor::new(encoded.clone());
+        assert_eq!(FieldOf::<Test>::read_be(&mut stream).unwrap(), decoded);
+
+        let mut buffer: Cursor<Vec<u8>> = Cursor::new(vec![]);
+        decoded.write_be(&mut buffer).unwrap();
+        assert_eq!(buffer.into_inner(), encoded);
+    }
+
+    #[test]
+    fn field_of_le() {
+        #[derive(BinRead, BinWrite, Debug, PartialEq, Default)]
+        struct Test {
+            a: u32,
+            b: u32,
+        }
+
+        let decoded: FieldOf<Test> = FieldOf {
+            value: Test {
+                a: 0x0A0B0C0D,
+                b: 0x01020304,
+            },
+        };
+        let encoded: Vec<u8> = vec![
+            0x08, 0x00, 0x00, 0x00, 0x0D, 0x0C, 0x0B, 0x0A, 0x04, 0x03, 0x02, 0x01,
+        ];
+
+        let mut stream: Cursor<Vec<u8>> = Cursor::new(encoded.clone());
+        assert_eq!(FieldOf::<Test>::read_le(&mut stream).unwrap(), decoded);
+
+        let mut buffer: Cursor<Vec<u8>> = Cursor::new(vec![]);
+        decoded.write_le(&mut buffer).unwrap();
+        assert_eq!(buffer.into_inner(), encoded);
+    }
+}

+ 2 - 0
src/ezcad/mod.rs

@@ -0,0 +1,2 @@
+pub mod basic_field;
+pub mod field_of;

+ 39 - 0
src/main.rs

@@ -0,0 +1,39 @@
+use std::{path::PathBuf, fs::read};
+
+use clap::Parser;
+
+mod ezcad;
+
+#[derive(Debug, Parser)]
+struct Cli {
+    /// Input file to parse
+    #[arg(short, long)]
+    input: PathBuf,
+
+    /// Output file to write to
+    #[arg(short, long)]
+    output: PathBuf,
+
+    /// Configuration file
+    #[arg(short, long)]
+    config: PathBuf,
+
+    #[command(flatten)]
+    verbose: clap_verbosity_flag::Verbosity,
+}
+
+fn main() {
+    env_logger::builder()
+    .format_timestamp(None)
+    .filter_level(log::LevelFilter::Info)
+    .init();
+
+    let args: Cli = Cli::parse();
+
+    let _input = read(args.input).unwrap();
+    let _confing = read(args.config).unwrap();
+
+
+    println!("Hello, world!");
+    
+}