imhex.txt 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. #pragma endian little
  2. #pragma pattern_limit 256000
  3. #include <std/sys.pat>
  4. #include <std/mem.pat>
  5. #include <std/io.pat>
  6. #include <std/core.pat>
  7. struct RGBA8 {
  8. u8 red;
  9. u8 green;
  10. u8 blue;
  11. u8 alpha;
  12. } [[static, color(std::format("{:02X}{:02X}{:02X}", red, green, blue))]];
  13. struct Point {
  14. double x;
  15. double y;
  16. };
  17. struct MultiLine {
  18. u32 points;
  19. Point point[points];
  20. };
  21. enum WobbleType : u32 {
  22. Spiral = 0,
  23. Sinusoidal = 1,
  24. Ellipse = 2,
  25. Vert_8 = 3,
  26. Hoti_8 = 4,
  27. };
  28. // Field of a custom defined type
  29. struct FieldOf<T> {
  30. u32 length;
  31. T value;
  32. std::assert(length == sizeof(value), "Size mismatch");
  33. } [[sealed, format("format_field_of")]];
  34. fn format_field_of(FieldOf<u8> f) {
  35. return f.value;
  36. };
  37. // Field of generic types
  38. struct Field {
  39. u32 length;
  40. match (length) {
  41. (4): u32 value;
  42. (8): double value;
  43. (2): u16 value; // ??
  44. (16): Point value; // ??
  45. (_): {
  46. std::warning(std::format("Unknown length tag: {} at 0x{:02X}", length, $));
  47. u8 value[length];
  48. }
  49. }
  50. } [[sealed, format("format_field")]];
  51. fn format_field(Field f) {
  52. return f.value;
  53. };
  54. // Variable length field of a fixed type.
  55. struct String {
  56. u32 length;
  57. char16 value[length / sizeof(char16)];
  58. } [[sealed, format("format_string")]];
  59. fn format_string(String s) {
  60. return s.value;
  61. };
  62. struct Header {
  63. char16 magic[0x8];
  64. u8 unknown[0x338];
  65. };
  66. struct Pen {
  67. u32 num_fields; // Number of fields in this struct (236)
  68. Field color;
  69. String name;
  70. Field disabled;
  71. Field use_default_param;
  72. Field loop_count;
  73. Field speed; // Changes with wobble relative speed
  74. Field power;
  75. Field frequency;
  76. Field unknown_1[1];
  77. Field start_tc;
  78. Field end_tc;
  79. Field polygon_tc;
  80. Field jump_speed;
  81. Field unknown_2[10];
  82. Field laser_off_tc;
  83. Field wave; // Only available if continue_mode is false
  84. Field unknown_3[1];
  85. Field wobble_enable;
  86. Field wobble_diameter;
  87. Field wobble_distance;
  88. Field unknown_4[8];
  89. Field min_jump_tc;
  90. Field max_jump_tc;
  91. Field jump_limit;
  92. Field unknown_5[2];
  93. Field frequency2;
  94. Field unknown_6[152];
  95. FieldOf<WobbleType> wobble_type;
  96. Field continue_mode;
  97. Field unknown_7[12];
  98. Field wobble_diameter2; // Only with wobble type ellipse
  99. Field unknown_8[26];
  100. };
  101. bitfield ObjectFlags {
  102. disabled : 1;
  103. aspect_ratio_unlocked : 1; // ??
  104. padding : 14;
  105. };
  106. enum ObjectType: u32 {
  107. Curve = 1,
  108. Point = 2,
  109. Rectangle = 3,
  110. Circle = 4,
  111. Ellipse = 5,
  112. Polygon = 6,
  113. Hatch = 32,
  114. };
  115. struct ObjCommon {
  116. u32 num_fields; // Number of fields in this struct (17)
  117. Field pen;
  118. Field type; // Seems to always be same value as object type
  119. FieldOf<ObjectFlags>;
  120. String name;
  121. Field count;
  122. Field unknown_2[1];
  123. Field io_control_enable_mask;
  124. Field io_control_disable_mask;
  125. Field unknown_3[5];
  126. FieldOf<Point> origin;
  127. Field z;
  128. Field a;
  129. Field unknown_4[1];
  130. };
  131. enum LineType : u16 {
  132. Point = 0x0001,
  133. Line = 0x0100,
  134. Bezier = 0x0300,
  135. };
  136. struct LineEntry {
  137. LineType type;
  138. u32; // Zeros
  139. match (type) {
  140. (LineType::Point): Point;
  141. (LineType::Line): {
  142. u32 count;
  143. Point points[count];
  144. }
  145. (LineType::Bezier): {
  146. u32 count;
  147. Point points[count];
  148. }
  149. (_): std::error(std::format("Unknown line type: 0x{:02X} at 0x{:02X}", u32(type), $));
  150. }
  151. };
  152. struct LineSet : ObjCommon {
  153. u32 count;
  154. u32; // Zeros
  155. LineEntry entries[count];
  156. };
  157. struct ClosedSet : ObjCommon {
  158. u32 count;
  159. Field entries[count];
  160. };
  161. struct Rectangle : ObjCommon {
  162. u32 num_fields; // Number of fields in this struct (8)
  163. FieldOf<Point> corner_a;
  164. FieldOf<Point> corner_b;
  165. Field round_bottom_left;
  166. Field round_bottom_right;
  167. Field round_top_right;
  168. Field round_top_left;
  169. Field unknown;
  170. u32 length;
  171. u8 bytes[length];
  172. };
  173. struct Circle : ObjCommon {
  174. u32 num_fields; // Number of fields in this struct (6)
  175. FieldOf<Point> origin;
  176. Field radius;
  177. Field start_angle; // Radians
  178. Field clockwise;
  179. Field unknown[2];
  180. };
  181. struct Ellipse : ObjCommon {
  182. u32 num_fields; // Number of fields in this struct (8)
  183. Field clockwise;
  184. FieldOf<Point> corner_a;
  185. FieldOf<Point> corner_b;
  186. Field start_angle; // Radians
  187. Field end_angle; // Radians
  188. Field unknown[2];
  189. Field open_curve;
  190. };
  191. struct Polygon : ObjCommon {
  192. u32 num_fields; // Number of fields in this struct (10)
  193. Field invert_shape;
  194. FieldOf<Point> corner_a;
  195. FieldOf<Point> corner_b;
  196. Field offset_cx; // Moves (intial) sharper corner
  197. Field offset_cy; // Moves (initial)sharper corner
  198. Field offset_dx;
  199. Field offset_dy;
  200. Field edges;
  201. Field unknown_3[2];
  202. };
  203. struct HatchLine {
  204. u32 num_lines;
  205. LineSet line[num_lines];
  206. };
  207. using Object;
  208. bitfield HatchFlags {
  209. padding : 1;
  210. follow_edge_once : 1;
  211. padding : 4;
  212. auto_rotate_hatch_angle : 1;
  213. average_distribut_line : 1;
  214. padding : 2;
  215. cross_hatch : 1;
  216. padding : 21;
  217. };
  218. struct HatchSettings {
  219. u32 num_fields; // 46
  220. Field flags; // 1 = mark contour
  221. Field unknown_1[1];
  222. Field pen;
  223. FieldOf<HatchFlags> flags_2;
  224. Field edge_offset;
  225. Field line_spacing;
  226. Field start_offset;
  227. Field end_offset;
  228. Field angle;
  229. Field unknown_4[9];
  230. Field auto_rotate_angle;
  231. Field unknown_7[10];
  232. Field line_reduction;
  233. Field unknown_3[2];
  234. Field num_loops;
  235. Field unknown_5[2];
  236. Field loop_distance;
  237. Field unknown_6[5];
  238. Field contour_first;
  239. Field count;
  240. Field unknown_2[3];
  241. };
  242. struct HatchSettings2 {
  243. u32 num_fields; // 15
  244. Field count;
  245. Field unknown_1[1];
  246. Field pen;
  247. FieldOf<HatchFlags> flags_2; // Same as HatchSettings.flags_2
  248. Field edge_offset;
  249. Field line_spacing;
  250. Field start_offset;
  251. Field end_offset;
  252. Field angle;
  253. Field auto_rotate_angle;
  254. Field line_reduction;
  255. Field loop_distance;
  256. Field num_loops;
  257. Field unknown_5[2];
  258. };
  259. struct Hatch : ObjCommon {
  260. u32; // 1
  261. Object outline;
  262. HatchSettings settings;
  263. HatchSettings2 settings_2;
  264. u32 count_5; //17
  265. Field unknown_5[count_5];
  266. u32; // 1
  267. u32; // 16
  268. u32 count_6; // 17
  269. Field pen;
  270. Field unknown_6[2];
  271. String hatch_name;
  272. Field unknown_7[13];
  273. u32 num_lines;
  274. HatchLine lines[num_lines];
  275. };
  276. struct Object {
  277. ObjectType type;
  278. match (type) {
  279. (ObjectType::Curve): LineSet;
  280. (ObjectType::Point): LineSet;
  281. (ObjectType::Rectangle): Rectangle;
  282. (ObjectType::Circle): Circle;
  283. (ObjectType::Ellipse): Ellipse;
  284. (ObjectType::Polygon): Polygon;
  285. (ObjectType::Hatch): Hatch;
  286. (_): std::error(std::format("Unknown object type: 0x{:02X} at 0x{:02X}", u32(type), $));
  287. }
  288. };
  289. struct Layer {
  290. u32 num_fields_1; // Number of fields before object list (17)
  291. Field unknown_1[3];
  292. String name;
  293. Field count;
  294. Field unknown_2[1];
  295. Field input_signal_wait_enable_mask;
  296. Field input_signal_wait_disable_mask;
  297. Field unknown_3[9];
  298. u32 object_count;
  299. Object objects[object_count];
  300. u32 num_fields_2; // Number of fields to footer (151)
  301. Field unknown_4[54];
  302. Field output_signal_start_enable_mask;
  303. Field output_signal_start_disable_mask;
  304. Field output_signal_end_enable_mask;
  305. Field output_signal_end_disable_mask;
  306. Field unknown_5[9];
  307. Field fixture_offset;
  308. Field unknown_6[64];
  309. Field output_signal_start_delay;
  310. Field output_signal_end_delay;
  311. Field input_signal_wait_enable;
  312. Field unknown_7[2];
  313. Field output_signal_start_pulse;
  314. Field output_signal_end_pulse;
  315. Field unknown_8[12];
  316. u32 footer;
  317. };
  318. struct Layers {
  319. u32 count;
  320. Layer layer[count];
  321. };
  322. struct File {
  323. Header header;
  324. RGBA8 thumbnail[40000]; // 200x200?
  325. padding[16];
  326. Pen pens[256];
  327. Layers;
  328. };
  329. File file @ 0x0;