imhex.txt 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. #pragma endian little
  2. #pragma pattern_limit 512000
  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. (1): u32 value; // ??
  46. (_): {
  47. std::warning(std::format("Unknown length tag: {} at 0x{:02X}", length, $));
  48. u8 value[length];
  49. }
  50. }
  51. } [[sealed, format("format_field")]];
  52. fn format_field(Field f) {
  53. return f.value;
  54. };
  55. // Variable length field of a fixed type.
  56. struct String {
  57. u32 length;
  58. char16 value[length / sizeof(char16)];
  59. } [[sealed, format("format_string")]];
  60. fn format_string(String s) {
  61. return s.value;
  62. };
  63. struct Header {
  64. char16 magic[0x8];
  65. u8 unknown[0x338];
  66. };
  67. struct Pen {
  68. u32 num_fields; // Number of fields in this struct (236)
  69. Field color;
  70. String name;
  71. Field disabled;
  72. Field use_default_param;
  73. Field loop_count;
  74. Field speed; // Changes with wobble relative speed
  75. Field power;
  76. Field frequency;
  77. Field unknown_1[1];
  78. Field start_tc;
  79. Field end_tc;
  80. Field polygon_tc;
  81. Field jump_speed;
  82. Field unknown_2[10];
  83. Field laser_off_tc;
  84. Field wave; // Only available if continue_mode is false
  85. Field unknown_3[1];
  86. Field wobble_enable;
  87. Field wobble_diameter;
  88. Field wobble_distance;
  89. Field unknown_4[8];
  90. Field min_jump_tc;
  91. Field max_jump_tc;
  92. Field jump_limit;
  93. Field unknown_5[2];
  94. Field frequency2;
  95. Field unknown_6[152];
  96. FieldOf<WobbleType> wobble_type;
  97. Field continue_mode;
  98. Field unknown_7[12];
  99. Field wobble_diameter2; // Only with wobble type ellipse
  100. Field unknown_8[26];
  101. Field unknown_9[134];
  102. };
  103. bitfield ObjectFlags {
  104. disabled : 1;
  105. aspect_ratio_unlocked : 1; // ??
  106. padding : 14;
  107. };
  108. enum ObjectType: u32 {
  109. Curve = 1,
  110. Point = 2,
  111. Rectangle = 3,
  112. Circle = 4,
  113. Ellipse = 5,
  114. Polygon = 6,
  115. Hatch = 32,
  116. };
  117. struct ObjCommon {
  118. u32 num_fields; // Number of fields in this struct (17)
  119. Field pen;
  120. Field type; // Seems to always be same value as object type
  121. FieldOf<ObjectFlags>;
  122. String name;
  123. Field count;
  124. Field unknown_2[1];
  125. Field io_control_enable_mask;
  126. Field io_control_disable_mask;
  127. Field unknown_3[5];
  128. FieldOf<Point> origin;
  129. Field z;
  130. Field a;
  131. Field unknown_4[1];
  132. };
  133. enum LineType : u16 {
  134. Point = 0x0001,
  135. Line = 0x0100,
  136. Bezier = 0x0300,
  137. };
  138. struct LineEntry {
  139. LineType type;
  140. u32; // Zeros
  141. match (type) {
  142. (LineType::Point): Point;
  143. (LineType::Line): {
  144. u32 count;
  145. Point points[count];
  146. }
  147. (LineType::Bezier): {
  148. u32 count;
  149. Point points[count];
  150. }
  151. (_): std::error(std::format("Unknown line type: 0x{:02X} at 0x{:02X}", u32(type), $));
  152. }
  153. };
  154. struct LineSet : ObjCommon {
  155. u32 count;
  156. u32; // Zeros
  157. LineEntry entries[count];
  158. };
  159. struct ClosedSet : ObjCommon {
  160. u32 count;
  161. Field entries[count];
  162. };
  163. struct Rectangle : ObjCommon {
  164. u32 num_fields; // Number of fields in this struct (8)
  165. FieldOf<Point> corner_a;
  166. FieldOf<Point> corner_b;
  167. Field round_bottom_left;
  168. Field round_bottom_right;
  169. Field round_top_right;
  170. Field round_top_left;
  171. Field unknown[2];
  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; // 47
  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[4];
  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[count_6 - 4];
  273. //Field unknown_6[count_6];
  274. u32 num_lines;
  275. HatchLine lines[num_lines];
  276. };
  277. struct Object {
  278. ObjectType type;
  279. match (type) {
  280. (ObjectType::Curve): LineSet;
  281. (ObjectType::Point): LineSet;
  282. (ObjectType::Rectangle): Rectangle;
  283. (ObjectType::Circle): Circle;
  284. (ObjectType::Ellipse): Ellipse;
  285. (ObjectType::Polygon): Polygon;
  286. (ObjectType::Hatch): Hatch;
  287. (_): std::error(std::format("Unknown object type: 0x{:02X} at 0x{:02X}", u32(type), $));
  288. }
  289. };
  290. struct Layer {
  291. u32 num_fields_1; // Number of fields before object list (17)
  292. Field unknown_1[3];
  293. String name;
  294. Field count;
  295. Field unknown_2[1];
  296. Field input_signal_wait_enable_mask;
  297. Field input_signal_wait_disable_mask;
  298. Field unknown_3[9];
  299. u32 object_count;
  300. Object objects[object_count];
  301. u32 num_fields_2; // Number of fields to footer (151)
  302. Field unknown_4[54];
  303. Field output_signal_start_enable_mask;
  304. Field output_signal_start_disable_mask;
  305. Field output_signal_end_enable_mask;
  306. Field output_signal_end_disable_mask;
  307. Field unknown_5[9];
  308. Field fixture_offset;
  309. Field unknown_6[64];
  310. Field output_signal_start_delay;
  311. Field output_signal_end_delay;
  312. Field input_signal_wait_enable;
  313. Field unknown_7[2];
  314. Field output_signal_start_pulse;
  315. Field output_signal_end_pulse;
  316. Field unknown_8[12];
  317. u32 footer;
  318. };
  319. struct Layers {
  320. u32 count;
  321. Layer layer[count];
  322. };
  323. struct File {
  324. Header header;
  325. RGBA8 thumbnail[40000]; // 200x200?
  326. padding[16];
  327. Pen pens[256];
  328. Layers;
  329. };
  330. File file @ 0x0;