cc_structures.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. /*
  2. XCC Utilities and Library
  3. Copyright (C) 2000 Olaf van der Spek <[email protected]>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #pragma once
  16. #include "palet.h"
  17. enum t_game
  18. {
  19. game_td,
  20. game_ra,
  21. game_ts,
  22. game_dune2,
  23. game_dune2000,
  24. game_ra2,
  25. game_ra2_yr,
  26. game_rg,
  27. game_gr,
  28. game_gr_zh,
  29. game_ebfd,
  30. game_nox,
  31. game_bfme,
  32. game_bfme2,
  33. game_tw,
  34. game_ts_fs,
  35. game_unknown
  36. };
  37. const char* game_name[];
  38. inline __int32 reverse(__int32 v)
  39. {
  40. _asm
  41. {
  42. mov eax, v
  43. xchg al, ah
  44. rol eax, 16
  45. xchg al, ah
  46. mov v, eax
  47. }
  48. return v;
  49. }
  50. #pragma pack(push, 1)
  51. struct t_aud_header
  52. {
  53. unsigned __int16 samplerate;
  54. unsigned __int32 size_in;
  55. unsigned __int32 size_out;
  56. __int8 flags;
  57. __int8 compression;
  58. };
  59. struct t_aud_chunk_header
  60. {
  61. unsigned __int16 size_in;
  62. unsigned __int16 size_out;
  63. __int32 id;
  64. };
  65. const __int32 aud_chunk_id = 0x0000deaf;
  66. struct t_audio_idx_header
  67. {
  68. __int32 id;
  69. __int32 two;
  70. __int32 c_sounds;
  71. };
  72. struct t_audio_idx_entry
  73. {
  74. char fname[16];
  75. __int32 offset;
  76. __int32 size;
  77. __int32 samplerate;
  78. __int32 flags;
  79. __int32 chunk_size;
  80. };
  81. const __int32 audio_idx_id = *(__int32*)"GABA";
  82. struct t_big_header
  83. {
  84. __int32 id;
  85. __int32 size;
  86. __int32 mc_files;
  87. __int32 mcb_header;
  88. int c_files() const
  89. {
  90. return reverse(mc_files);
  91. }
  92. int cb_header() const
  93. {
  94. return reverse(mcb_header);
  95. }
  96. };
  97. struct t_big_index_entry
  98. {
  99. __int32 offset;
  100. __int32 size;
  101. };
  102. const int big_id = 'FGIB';
  103. const int big4_id = '4GIB';
  104. struct t_cps_header
  105. {
  106. unsigned __int16 size;
  107. __int16 unknown;
  108. unsigned __int16 image_size;
  109. __int16 zero;
  110. __int16 palet_size;
  111. };
  112. struct t_csf_header
  113. {
  114. __int32 id;
  115. __int32 flags1;
  116. __int32 count1;
  117. __int32 count2;
  118. __int32 zero;
  119. __int32 flags2;
  120. };
  121. const __int32 csf_file_id = 'CSF ';
  122. const __int32 csf_label_id = 'LBL ';
  123. const __int32 csf_string_id = 'STR ';
  124. const __int32 csf_string_w_id = 'STRW';
  125. struct t_fnt_header
  126. {
  127. unsigned __int16 size;
  128. __int16 id1;
  129. __int16 id2;
  130. __int16 id3;
  131. unsigned __int16 cx_ofs;
  132. unsigned __int16 image_ofs;
  133. unsigned __int16 cy_ofs;
  134. __int16 id4;
  135. __int8 zero;
  136. unsigned __int8 c_chars;
  137. __int8 cy;
  138. __int8 cmax_x;
  139. };
  140. struct t_hva_header
  141. {
  142. char id[16];
  143. __int32 c_frames;
  144. __int32 c_sections;
  145. };
  146. using t_hva_transform_matrix = float[3][4];
  147. struct t_jpeg_header
  148. {
  149. __int8 unknown[6];
  150. __int8 id[4];
  151. };
  152. const char jpeg_id[] = "JFIF";
  153. union t_mix_header
  154. {
  155. struct
  156. {
  157. __int16 c_files;
  158. __int32 size;
  159. };
  160. __int32 flags;
  161. };
  162. const int mix_checksum = 0x00010000;
  163. const int mix_encrypted = 0x00020000;
  164. const int cb_mix_key = 56;
  165. const int cb_mix_key_source = 80;
  166. const int cb_mix_checksum = 20;
  167. struct t_mix_index_entry
  168. {
  169. t_mix_index_entry() = default;
  170. t_mix_index_entry(unsigned int id_, int offset_, int size_)
  171. {
  172. id = id_;
  173. offset = offset_;
  174. size = size_;
  175. }
  176. unsigned __int32 id;
  177. __int32 offset;
  178. __int32 size;
  179. };
  180. struct t_mix_rg_header
  181. {
  182. __int32 id;
  183. __int32 index_offset;
  184. __int32 tailer_offset;
  185. __int32 zero;
  186. };
  187. struct t_mix_rg_index_entry
  188. {
  189. __int32 id;
  190. __int32 offset;
  191. __int32 size;
  192. };
  193. const int mix_rg_id = '1XIM';
  194. struct t_iso_map_pack_entry
  195. {
  196. unsigned __int16 x;
  197. unsigned __int16 y;
  198. __int16 tile;
  199. unsigned __int8 zero1;
  200. unsigned __int8 zero2;
  201. unsigned __int8 sub_tile;
  202. unsigned __int8 z;
  203. unsigned __int8 zero3;
  204. };
  205. struct t_ogg_header
  206. {
  207. __int8 id[4];
  208. };
  209. const char ogg_id[] = "OggS";
  210. struct t_pack_section_header
  211. {
  212. unsigned __int16 size_in;
  213. unsigned __int16 size_out;
  214. };
  215. struct t_pcx_header
  216. {
  217. __int8 manufacturer;
  218. __int8 version;
  219. __int8 encoding;
  220. __int8 cbits_pixel;
  221. __int16 xmin;
  222. __int16 ymin;
  223. __int16 xmax;
  224. __int16 ymax;
  225. __int16 cx_inch;
  226. __int16 cy_inch;
  227. __int8 colorpap[16][3];
  228. __int8 reserved;
  229. __int8 c_planes;
  230. __int16 cb_line;
  231. __int8 filler[60];
  232. };
  233. struct t_png_header
  234. {
  235. __int8 id[8];
  236. };
  237. const char png_id[] = "\x89PNG\r\n\x1A\n";
  238. struct t_shp_dune2_header
  239. {
  240. __int16 c_images;
  241. };
  242. struct t_shp_dune2_image_header
  243. {
  244. __int16 compression;
  245. unsigned __int8 cy;
  246. unsigned __int16 cx;
  247. unsigned __int8 cy2;
  248. unsigned __int16 size_in;
  249. unsigned __int16 size_out;
  250. };
  251. struct t_shp_header
  252. {
  253. __int16 c_images;
  254. __int16 unknown1;
  255. __int16 unknown2;
  256. __int16 cx;
  257. __int16 cy;
  258. __int32 unknown3;
  259. };
  260. struct t_shp_ts_header
  261. {
  262. __int16 zero;
  263. __int16 cx;
  264. __int16 cy;
  265. __int16 c_images;
  266. };
  267. struct t_shp_ts_image_header
  268. {
  269. __int16 x;
  270. __int16 y;
  271. __int16 cx;
  272. __int16 cy;
  273. __int32 compression;
  274. __int32 unknown;
  275. __int32 zero;
  276. __int32 offset;
  277. };
  278. struct t_tga_header
  279. {
  280. byte id_size;
  281. byte map_t;
  282. byte image_t;
  283. unsigned __int16 map_first;
  284. unsigned __int16 map_size;
  285. byte map_entry_size;
  286. unsigned __int16 x;
  287. unsigned __int16 y;
  288. unsigned __int16 cx;
  289. unsigned __int16 cy;
  290. byte cb_pixel;
  291. byte alpha:4;
  292. byte horizontal:1;
  293. byte vertical:1;
  294. };
  295. struct t_tmp_header
  296. {
  297. __int16 cx;
  298. __int16 cy;
  299. __int16 c_tiles;
  300. __int16 zero1;
  301. __int32 size;
  302. __int32 image_offset;
  303. __int32 zero2;
  304. __int32 id;
  305. __int32 index2;
  306. __int32 index1;
  307. };
  308. struct t_tmp_ra_header
  309. {
  310. __int16 cx;
  311. __int16 cy;
  312. __int16 c_tiles;
  313. __int16 zero1;
  314. __int16 cblocks_x;
  315. __int16 cblocks_y;
  316. __int32 size;
  317. __int32 image_offset;
  318. __int32 zero2;
  319. __int32 unknown1;
  320. __int32 index2;
  321. __int32 unknown2;
  322. __int32 index1;
  323. };
  324. struct t_tmp_ts_header
  325. {
  326. __int32 cblocks_x;
  327. __int32 cblocks_y;
  328. __int32 cx;
  329. __int32 cy;
  330. };
  331. struct t_tmp_image_header
  332. {
  333. __int32 x;
  334. __int32 y;
  335. __int32 extra_ofs;
  336. __int32 z_ofs;
  337. __int32 extra_z_ofs;
  338. __int32 x_extra;
  339. __int32 y_extra;
  340. __int32 cx_extra;
  341. __int32 cy_extra;
  342. unsigned int has_extra_data: 1;
  343. unsigned int has_z_data: 1;
  344. unsigned int has_damaged_data: 1;
  345. __int8 height;
  346. __int8 terrain_type;
  347. __int8 ramp_type;
  348. unsigned __int8 radar_red_left;
  349. unsigned __int8 radar_green_left;
  350. unsigned __int8 radar_blue_left;
  351. unsigned __int8 radar_red_right;
  352. unsigned __int8 radar_green_right;
  353. unsigned __int8 radar_blue_right;
  354. __int8 pad[3];
  355. };
  356. struct t_voc_header
  357. {
  358. char id[20];
  359. __int16 offset;
  360. __int32 version;
  361. };
  362. struct t_voc_sound_data_header
  363. {
  364. unsigned __int8 samplerate;
  365. __int8 compression;
  366. };
  367. const char voc_id[] = "Creative Voice File\x1a";
  368. struct t_vqa_chunk_header
  369. {
  370. __int32 id;
  371. __int32 size;
  372. };
  373. struct t_vqa_header
  374. {
  375. t_vqa_chunk_header file_header;
  376. // 'FORM'
  377. __int64 id;
  378. // 'WVQAVQHD'
  379. __int32 startpos;
  380. __int16 version;
  381. __int16 video_flags;
  382. __int16 c_frames;
  383. __int16 cx;
  384. __int16 cy;
  385. __int8 cx_block;
  386. __int8 cy_block;
  387. __int16 unknown3;
  388. __int16 c_colors;
  389. __int16 cb_max_cbp_chunk;
  390. __int32 unknown4;
  391. __int16 unknown5;
  392. unsigned __int16 samplerate;
  393. __int8 c_channels;
  394. __int8 cbits_sample;
  395. __int8 unknown6[14];
  396. };
  397. const __int32 vqa_c_mask = 0xff000000;
  398. const __int32 vqa_t_mask = 0x00ffffff;
  399. const __int32 vqa_file_id = *(__int32*)"FORM";
  400. const __int64 vqa_form_id = {*(__int64*)"WVQAVQHD"};
  401. const __int32 vqa_cbf_id = *(__int32*)"CBF\0";
  402. const __int32 vqa_cbp_id = *(__int32*)"CBP\0";
  403. const __int32 vqa_cpl_id = *(__int32*)"CPL\0";
  404. const __int32 vqa_finf_id = *(__int32*)"FINF";
  405. const __int32 vqa_sn2j_id = *(__int32*)"SN2J";
  406. const __int32 vqa_snd_id = *(__int32*)"SND\0";
  407. const __int32 vqa_vpt_id = *(__int32*)"VPT\0";
  408. const __int32 vqa_vpr_id = *(__int32*)"VPR\0";
  409. const __int32 vqa_vqfl_id = *(__int32*)"VQFL";
  410. const __int32 vqa_vqfr_id = *(__int32*)"VQFR";
  411. struct t_vqp_header
  412. {
  413. unsigned __int32 c_tables;
  414. };
  415. struct t_vxl_header
  416. {
  417. char id[16];
  418. __int32 one;
  419. unsigned __int32 c_section_headers;
  420. unsigned __int32 c_section_tailers;
  421. unsigned __int32 size;
  422. __int16 unknown;
  423. t_palet palet;
  424. };
  425. struct t_vxl_section_header
  426. {
  427. char id[16];
  428. __int32 section_i;
  429. __int32 one;
  430. __int32 zero;
  431. };
  432. struct t_vxl_section_tailer
  433. {
  434. __int32 span_start_ofs;
  435. __int32 span_end_ofs;
  436. __int32 span_data_ofs;
  437. float scale;
  438. float transform[3][4];
  439. float x_min_scale;
  440. float y_min_scale;
  441. float z_min_scale;
  442. float x_max_scale;
  443. float y_max_scale;
  444. float z_max_scale;
  445. unsigned __int8 cx;
  446. unsigned __int8 cy;
  447. unsigned __int8 cz;
  448. __int8 unknown;
  449. };
  450. const char vxl_id[] = "Voxel Animation";
  451. struct t_w3d_header
  452. {
  453. __int32 id;
  454. __int32 m_size;
  455. bool container() const
  456. {
  457. return m_size & 0x80000000;
  458. }
  459. int size() const
  460. {
  461. return m_size & ~0x80000000;
  462. }
  463. };
  464. struct t_wsa_dune2_header
  465. {
  466. __int16 c_frames;
  467. __int16 cx;
  468. __int16 cy;
  469. __int16 delta;
  470. };
  471. struct t_wsa_header
  472. {
  473. __int16 c_frames;
  474. __int16 x;
  475. __int16 y;
  476. __int16 cx;
  477. __int16 cy;
  478. __int32 delta;
  479. };
  480. struct t_xcc_header
  481. {
  482. char id[32];
  483. __int32 size;
  484. __int32 type;
  485. __int32 version;
  486. };
  487. const char xcc_id[] = "XCC by Olaf van der Spek\x1a\x04\x17\x27\x10\x19\x80";
  488. struct t_xcc_lmd_header
  489. {
  490. __int32 game;
  491. __int32 c_fnames;
  492. };
  493. #pragma pack(pop)