lib-bmg.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. /***************************************************************************
  2. * *
  3. * _____ ____ *
  4. * | __ \ / __ \ _ _ _____ *
  5. * | | \ \ / / \_\ | | | | _ \ *
  6. * | | \ \| | | | | | |_| | *
  7. * | | | || | | | | | ___/ *
  8. * | | / /| | __ | | | | _ \ *
  9. * | |__/ / \ \__/ / | |___| | |_| | *
  10. * |_____/ \____/ |_____|_|_____/ *
  11. * *
  12. * Wiimms source code library *
  13. * *
  14. ***************************************************************************
  15. * *
  16. * Copyright (c) 2012-2022 by Dirk Clemens <wiimm@wiimm.de> *
  17. * *
  18. ***************************************************************************
  19. * *
  20. * This library is free software; you can redistribute it and/or modify *
  21. * it under the terms of the GNU General Public License as published by *
  22. * the Free Software Foundation; either version 2 of the License, or *
  23. * (at your option) any later version. *
  24. * *
  25. * This library is distributed in the hope that it will be useful, *
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  28. * GNU General Public License for more details. *
  29. * *
  30. * See file gpl-2.0.txt or http://www.gnu.org/licenses/gpl-2.0.txt *
  31. * *
  32. ***************************************************************************/
  33. #ifndef DC_LIB_BMG_H
  34. #define DC_LIB_BMG_H 1
  35. #define _GNU_SOURCE 1
  36. #include "dclib-basics.h"
  37. #include "dclib-file.h"
  38. //
  39. ///////////////////////////////////////////////////////////////////////////////
  40. /////////////// basic consts ///////////////
  41. ///////////////////////////////////////////////////////////////////////////////
  42. #define BMG_ATTRIB_SIZE 40 // attrib size in bytes
  43. #define BMG_ATTRIB_BUF_SIZE (10+4*BMG_ATTRIB_SIZE) // good buf size for attrib string
  44. #define BMG_INF_MAX_SIZE (4+BMG_ATTRIB_SIZE) // max supported inf size
  45. #define BMG_INF_LIMIT 1000 // max allowed inf size
  46. #define BMG_LEGACY_BLOCK_SIZE 32 // block size for legacy files
  47. #define BMG_MAX_SECTIONS 100 // max supported sections (sanity check)
  48. // [[xbuf]]
  49. #define BMG_MSG_BUF_SIZE 20050 // good buf size for messages
  50. ///////////////////////////////////////////////////////////////////////////////
  51. #define BMG_MAGIC "MESGbmg1"
  52. #define BMG_MAGIC8_NUM 0x4d455347626d6731ull
  53. #define BMG_TEXT_MAGIC "#BMG"
  54. #define BMG_TEXT_MAGIC_NUM 0x23424d47
  55. #define BMG_UTF8_MAX 0xfffd
  56. #define BMG_UTF8_MAX_DIFF 0x058f // behind: from-right-to-left letters
  57. #define BMG_NO_PREDEF_SLOT 0xffff // only slots <this can be predefined
  58. typedef u16 bmg_slot_t; // type of slot
  59. typedef struct bmg_t bmg_t;
  60. //
  61. ///////////////////////////////////////////////////////////////////////////////
  62. /////////////// MKW specific consts ///////////////
  63. ///////////////////////////////////////////////////////////////////////////////
  64. enum
  65. {
  66. BMG_N_CHAT = 96,
  67. BMG_N_RCUP = 8,
  68. BMG_N_BCUP = 2,
  69. BMG_N_TRACK = 32,
  70. BMG_N_ARENA = 10,
  71. MID_RCUP_BEG = 0x23f0,
  72. MID_RCUP_END = MID_RCUP_BEG + BMG_N_RCUP,
  73. MID_BCUP_BEG = 0x2489,
  74. MID_BCUP_END = MID_BCUP_BEG + BMG_N_BCUP,
  75. BMG_RCUP_TRACKS = 4,
  76. BMG_BCUP_TRACKS = 5,
  77. MID_ENGINE_BEG = 0x0589,
  78. MID_ENGINE_END = MID_ENGINE_BEG + 4,
  79. MID_CHAT_BEG = 0x1194,
  80. MID_CHAT_END = MID_CHAT_BEG + BMG_N_CHAT,
  81. //-- parameters
  82. MID_PARAM_IDENTIFY = 0x3def,
  83. MID_PARAM_BEG = 0x3ff0,
  84. MID_VERSUS_POINTS = MID_PARAM_BEG,
  85. MID_PARAM_END = 0x4000,
  86. //-- extended messages for CT/LE
  87. MID_X_MESSAGE_BEG = 0x6000,
  88. MID_X_MESSAGE_END = 0x6200,
  89. //-- CT-CODE
  90. BMG_N_CT_RCUP = 0x3e,
  91. BMG_N_CT_BCUP = 2,
  92. BMG_N_CT_TRACK = 0x1fe,
  93. BMG_N_CT_ARENA = BMG_N_ARENA,
  94. MID_CT_TRACK_BEG = 0x4000,
  95. MID_CT_TRACK_END = MID_CT_TRACK_BEG + BMG_N_CT_TRACK,
  96. MID_CT_ARENA_BEG = MID_CT_TRACK_BEG + BMG_N_TRACK,
  97. MID_CT_ARENA_END = MID_CT_ARENA_BEG + BMG_N_CT_ARENA,
  98. MID_CT_RANDOM = MID_CT_TRACK_BEG + 0xff,
  99. MID_CT_CUP_BEG = 0x4200,
  100. MID_CT_RCUP_BEG = MID_CT_CUP_BEG,
  101. MID_CT_RCUP_END = MID_CT_RCUP_BEG + BMG_N_CT_RCUP,
  102. MID_CT_BCUP_BEG = MID_CT_RCUP_END,
  103. MID_CT_BCUP_END = MID_CT_BCUP_BEG + BMG_N_CT_BCUP,
  104. MID_CT_CUP_END = MID_CT_BCUP_END,
  105. MID_CT_CUP_REF_BEG = 0x4300,
  106. MID_CT_CUP_REF_END = MID_CT_CUP_REF_BEG + BMG_N_CT_TRACK,
  107. MID_CT_BEG = MID_CT_TRACK_BEG,
  108. MID_CT_END = MID_CT_CUP_REF_END,
  109. //-- LE-CODE
  110. BMG_N_LE_RCUP = 0x400,
  111. BMG_N_LE_BCUP = 2,
  112. BMG_N_LE_TRACK = 0x1000,
  113. BMG_N_LE_ARENA = BMG_N_ARENA,
  114. BMG_LE_FIRST_CTRACK = 0x44,
  115. MID_LE_CUP_BEG = 0x6800,
  116. MID_LE_RCUP_BEG = MID_LE_CUP_BEG,
  117. MID_LE_RCUP_END = MID_LE_RCUP_BEG + BMG_N_LE_RCUP,
  118. MID_LE_BCUP_BEG = MID_LE_RCUP_END,
  119. MID_LE_BCUP_END = MID_LE_BCUP_BEG + BMG_N_LE_BCUP,
  120. MID_LE_CUP_END = MID_LE_BCUP_END,
  121. MID_LE_TRACK_BEG = 0x7000,
  122. MID_LE_TRACK_END = MID_LE_TRACK_BEG + BMG_N_LE_TRACK,
  123. MID_LE_ARENA_BEG = MID_LE_TRACK_BEG + BMG_N_TRACK,
  124. MID_LE_ARENA_END = MID_LE_ARENA_BEG + BMG_N_LE_ARENA,
  125. MID_LE_CUP_REF_BEG = 0x8000,
  126. MID_LE_CUP_REF_END = MID_LE_CUP_REF_BEG + BMG_N_LE_TRACK,
  127. MID_LE_BEG = MID_LE_CUP_BEG,
  128. MID_LE_END = MID_LE_CUP_REF_END,
  129. //-- max(CT,LE)
  130. BMG_MAX_RCUP = 0x3fe,
  131. BMG_MAX_BCUP = 2,
  132. BMG_MAX_TRACK = 0x1000,
  133. BMG_MAX_ARENA = BMG_N_ARENA,
  134. //-- tracks
  135. MID_TRACK1_BEG = 0x2454,
  136. MID_TRACK1_END = MID_TRACK1_BEG + BMG_N_TRACK,
  137. MID_TRACK2_BEG = 0x2490,
  138. MID_TRACK2_END = MID_TRACK2_BEG + BMG_N_TRACK,
  139. MID_ARENA1_BEG = 0x24b8,
  140. MID_ARENA1_END = MID_ARENA1_BEG + BMG_N_ARENA,
  141. MID_ARENA2_BEG = 0x24cc,
  142. MID_ARENA2_END = MID_ARENA2_BEG + BMG_N_ARENA,
  143. MID_RANDOM = 0x1101,
  144. //--- misc
  145. MID_GENERIC_BEG = 0xfff0,
  146. MID_G_SMALL = MID_GENERIC_BEG,
  147. MID_G_MEDIUM,
  148. MID_G_LARGE,
  149. MID_GENERIC_END,
  150. BMG_N_GENERIC = MID_GENERIC_END - MID_GENERIC_BEG,
  151. //MID_VEHICLE = 0xd66,
  152. MID_KARTS = 0xd67,
  153. MID_BIKES = 0xd68,
  154. MID__VIP_BEG = MID_CHAT_BEG,
  155. MID__VIP_END = MID_LE_END,
  156. BMG__VIP_N = MID__VIP_END - MID__VIP_BEG
  157. };
  158. //
  159. ///////////////////////////////////////////////////////////////////////////////
  160. /////////////// global bmg options ///////////////
  161. ///////////////////////////////////////////////////////////////////////////////
  162. typedef enum ColNameLevelBMG // color names as escapes
  163. {
  164. BMG_CNL_NONE, // disable color names
  165. BMG_CNL_BASICS, // use only old standard color names
  166. BMG_CNL_YOR, // + use YOR* names
  167. BMG_CNL_ALL = BMG_CNL_YOR // default
  168. }
  169. ColNameLevelBMG;
  170. extern uint opt_bmg_force_count; // >0: force some operations
  171. extern uint opt_bmg_align; // alignment of raw-bg sections
  172. extern bool opt_bmg_export; // true: optimize for exports
  173. extern bool opt_bmg_no_attrib; // true: suppress attributes
  174. extern bool opt_bmg_x_escapes; // true: use x-scapes insetad of z-escapes
  175. extern bool opt_bmg_old_escapes; // true: use only old escapes
  176. extern int opt_bmg_single_line; // >0: single line, >1: suppress atrributes
  177. extern bool opt_bmg_inline_attrib; // true: print attrinbutes inline
  178. extern bool opt_bmg_support_mkw; // true: support MKW specific extensions
  179. extern bool opt_bmg_support_ctcode; // true: support MKW/CT-CODE specific extensions
  180. extern bool opt_bmg_support_lecode; // true: support MKW/LE-CODE specific extensions
  181. extern uint opt_bmg_rcup_fill_limit;// >0: limit racing cups to reduce BMG size
  182. extern uint opt_bmg_track_fill_limit;// >0: limit tracks to reduce BMG size
  183. extern int opt_bmg_colors; // use c-escapes: 0:off, 1:auto, 2:on
  184. extern ColNameLevelBMG opt_bmg_color_name;
  185. extern uint opt_bmg_max_recurse; // max recurse depth
  186. extern bool opt_bmg_allow_print; // true: allow '$' to print a log message
  187. extern bool opt_bmg_use_slots; // true: use predifined slots
  188. extern bool opt_bmg_use_raw_sections;// true: use raw sections
  189. //-----------------------------------------------------------------------------
  190. extern int opt_bmg_endian;
  191. extern int opt_bmg_encoding;
  192. extern uint opt_bmg_inf_size;
  193. extern OffOn_t opt_bmg_mid;
  194. extern bool opt_bmg_force_attrib;
  195. extern bool opt_bmg_def_attrib;
  196. extern u8 bmg_force_attrib[BMG_ATTRIB_SIZE];
  197. extern u8 bmg_def_attrib[BMG_ATTRIB_SIZE];
  198. // 'PatchKeysBMG->opt'
  199. // 0: no param
  200. // 1: file param
  201. // 2: string param
  202. extern const KeywordTab_t PatchKeysBMG[];
  203. extern const sizeof_info_t sizeof_info_bmg[];
  204. //
  205. ///////////////////////////////////////////////////////////////////////////////
  206. /////////////// CT/LE support ///////////////
  207. ///////////////////////////////////////////////////////////////////////////////
  208. // [[ct_mode_t]]
  209. typedef enum ct_mode_t
  210. {
  211. CTM_NO_INIT, // don't initialize, don't change value
  212. CTM_NINTENDO, // original Nintendo mdoe with 32 tracks
  213. CTM_AUTO, // use fallback
  214. CTM_OPTIONS, // use options opt_bmg_support_{le,ct}code
  215. CTM_CTCODE_BASE = 0x10, // base for all CT-CODEs
  216. CTM_CTCODE, // CT-CODE (v1)
  217. CTM_LECODE_BASE = 0x20, // base for all LE-CODEs
  218. CTM_LECODE1, // LE-CODE phase 1 [[not longer used]]
  219. CTM_LECODE2, // LE-CODE phase 2
  220. CTM_LECODE_MIN = CTM_LECODE2, // minimal LE-PHASE
  221. CTM_LECODE_DEF = CTM_LECODE2, // default LE-PHASE
  222. CTM_LECODE_MAX = CTM_LECODE2, // maximal LE-PHASE
  223. }
  224. ct_mode_t;
  225. ct_mode_t NormalizeCtModeBMG ( ct_mode_t mode, ct_mode_t fallback );
  226. ct_mode_t SetupCtModeBMG ( ct_mode_t mode );
  227. ccp GetCtModeNameBMG ( ct_mode_t mode, bool full );
  228. ///////////////////////////////////////////////////////////////////////////////
  229. // [[bmg_range_t]]
  230. typedef struct bmg_range_t
  231. {
  232. u32 beg; // id of first MID
  233. u32 end; // id of last MID+1
  234. u32 n; // number of MIDs := end-beg
  235. }
  236. bmg_range_t;
  237. ///////////////////////////////////////////////////////////////////////////////
  238. // [[ct_bmg_t]]
  239. typedef struct ct_bmg_t
  240. {
  241. ct_mode_t ct_mode; // normalized CT mode
  242. int version; // a version number
  243. uint is_ct_code; // 0:off, 1:CT-CODE, 2:CT+LE-CODE
  244. uint le_phase; // >0: LE-CODE enabled in phase #
  245. u32 identify; // MID if ifentification
  246. bmg_range_t param; // MID range of parameters
  247. bmg_range_t range; // MID range of this section (min,max)
  248. bmg_range_t rcup_name; // MID range of racing cup names
  249. bmg_range_t bcup_name; // MID range of battle cup names (maybe part of rcup_name)
  250. bmg_range_t track_name1; // MID range of track names, first set
  251. bmg_range_t track_name2; // 0 or MID range of track names, second set
  252. bmg_range_t arena_name1; // MID range of arena names, first set
  253. bmg_range_t arena_name2; // 0 or MID range of arena names, second set
  254. bmg_range_t cup_ref; // MID range of battle track_to_cup references
  255. bmg_range_t random; // MID for RANDOM
  256. }
  257. ct_bmg_t;
  258. ct_mode_t SetupCtBMG ( ct_bmg_t *ctb, ct_mode_t mode, ct_mode_t fallback );
  259. static inline void ResetCtBMG ( ct_bmg_t *ctb ) {}
  260. ccp GetCtBMGIdentification ( ct_bmg_t *ctb, bool full ); // message for MID_PARAM_IDENTIFY
  261. void DumpCtBMG ( FILE *f, int indent, ct_bmg_t *ctb );
  262. //
  263. ///////////////////////////////////////////////////////////////////////////////
  264. /////////////// global string functions ///////////////
  265. ///////////////////////////////////////////////////////////////////////////////
  266. // returns 1..N
  267. uint GetWordLength16BMG ( const u16 *source );
  268. uint GetLength16BMG
  269. (
  270. const u16 * sourse, // source
  271. uint max_len // max possible length
  272. );
  273. //-----------------------------------------------------------------------------
  274. uint PrintString16BMG
  275. (
  276. char *buf, // destination buffer
  277. uint buf_size, // size of 'buf'
  278. const u16 *src, // source
  279. int src_len, // length of source in u16 words, -1:NULL term
  280. u16 utf8_max, // max code printed as UTF-8
  281. uint quote, // 0:no quotes, 1:escape ", 2: print in quotes
  282. int use_color // >0: use \c{...}
  283. );
  284. // [[xbuf]] [[2do]] not implemented yet
  285. uint PrintFastBuf16BMG
  286. (
  287. FastBuf_t *fb, // destination buffer (data appended)
  288. const u16 *src, // source
  289. int src_len, // length of source in u16 words, -1:NULL term
  290. u16 utf8_max, // max code printed as UTF-8
  291. uint quote, // 0:no quotes, 1:escape ", 2: print in quotes
  292. int use_color // >0: use \c{...}
  293. );
  294. //-----------------------------------------------------------------------------
  295. uint ScanString16BMG
  296. (
  297. u16 *buf, // destination buffer
  298. uint buf_size, // size of 'buf' in u16 words
  299. ccp src, // UTF-8 source
  300. int src_len, // length of source, -1: determine with strlen()
  301. const bmg_t *bmg // NULL or support for \m{...}
  302. );
  303. // [[xbuf]] [[2do]] not implemented yet
  304. uint ScanFastBuf16BMG
  305. (
  306. FastBuf_t *fb, // destination buffer (data appended)
  307. ccp src, // UTF-8 source
  308. int src_len, // length of source, -1: determine with strlen()
  309. const bmg_t *bmg // NULL or support for \m{...}
  310. );
  311. //
  312. ///////////////////////////////////////////////////////////////////////////////
  313. /////////////// struct bmg_header_t ///////////////
  314. ///////////////////////////////////////////////////////////////////////////////
  315. // [[bmg_section_t]]
  316. typedef struct bmg_section_t
  317. {
  318. /*00*/ char magic[4]; // a magic to identity the section
  319. /*04*/ be32_t size; // total size of the section
  320. /*08*/ u8 data[0]; // section data
  321. }
  322. __attribute__ ((packed)) bmg_section_t;
  323. //-----------------------------------------------------------------------------
  324. // [[bmg_endian_t]]
  325. typedef enum bmg_endian_t
  326. {
  327. BMG_AUTO_ENDIAN,
  328. BMG_BIG_ENDIAN, // used in MKWii
  329. BMG_LITTLE_ENDIAN,
  330. BMG_DEFAULT_ENDIAN = BMG_BIG_ENDIAN,
  331. }
  332. __attribute__ ((packed)) bmg_endian_t;
  333. extern const KeywordTab_t TabEndianBMG[];
  334. ccp GetEndianNameBMG ( int endian, ccp return_if_invalid );
  335. //-----------------------------------------------------------------------------
  336. // [[bmg_encoding_t]]
  337. typedef enum bmg_encoding_t
  338. {
  339. BMG_ENC_CP1252 = 1,
  340. BMG_ENC_UTF16BE = 2, // used in MKWii and AC
  341. BMG_ENC_SHIFT_JIS = 3,
  342. BMG_ENC_UTF8 = 4,
  343. BMG_ENC__MIN = BMG_ENC_CP1252,
  344. BMG_ENC__DEFAULT = BMG_ENC_UTF16BE,
  345. BMG_ENC__MAX = BMG_ENC_UTF8,
  346. BMG_ENC__UNDEFINED = -1, // only for option --bmg-encoding
  347. }
  348. __attribute__ ((packed)) bmg_encoding_t;
  349. extern const KeywordTab_t TabEncodingBMG[];
  350. ccp GetEncodingNameBMG ( int encoding, ccp return_if_invalid );
  351. int CheckEncodingBMG ( int encoding, int return_if_invalid );
  352. //-----------------------------------------------------------------------------
  353. // [[bmg_header_t]]
  354. typedef struct bmg_header_t
  355. {
  356. /*00*/ char magic[8]; // = BMG_MAGIC
  357. /*08*/ be32_t size; // total size of file
  358. /*0c*/ be32_t n_sections; // number of sections
  359. /*10*/ bmg_encoding_t encoding; // text encoding
  360. /*11*/ u8 unknown[15]; // unknown data
  361. /*20*/ //bmg_section_t section[0]; // first section header
  362. // -> disabled because MVC
  363. }
  364. __attribute__ ((packed)) bmg_header_t;
  365. //
  366. ///////////////////////////////////////////////////////////////////////////////
  367. /////////////// struct bmg_inf_t ///////////////
  368. ///////////////////////////////////////////////////////////////////////////////
  369. #define BMG_INF_MAGIC "INF1"
  370. #define BMG_INF_STD_ATTRIB 0x01000000
  371. #define BMG_INF_STD_SIZE 8
  372. #define BMG_INF_DEFAULT_0C 0
  373. //-----------------------------------------------------------------------------
  374. // [[bmg_inf_item_t]]
  375. typedef struct bmg_inf_item_t
  376. {
  377. /*00*/ u32 offset; // offset into text pool
  378. /*04*/ u8 attrib[0]; // attribute bytes
  379. // NKWii: MSByte used for font selection.
  380. }
  381. __attribute__ ((packed)) bmg_inf_item_t;
  382. //-----------------------------------------------------------------------------
  383. // [[bmg_inf_t]]
  384. typedef struct bmg_inf_t
  385. {
  386. /*00*/ char magic[4]; // = BMG_INF_MAGIC
  387. /*04*/ be32_t size; // total size of the section
  388. /*08*/ be16_t n_msg; // number of messages
  389. /*0a*/ be16_t inf_size; // size of inf items
  390. /*0c*/ be32_t unknown_0c; // = BMG_INF_DEFAULT_0C = 0 for MKW
  391. /*10*/ bmg_inf_item_t list[0]; // message list with (offset,attribute)
  392. }
  393. __attribute__ ((packed)) bmg_inf_t;
  394. //
  395. ///////////////////////////////////////////////////////////////////////////////
  396. /////////////// struct bmg_dat_t + bmg_str_t ///////////////
  397. ///////////////////////////////////////////////////////////////////////////////
  398. #define BMG_DAT_MAGIC "DAT1"
  399. #define BMG_STR_MAGIC "STR1"
  400. //-----------------------------------------------------------------------------
  401. // [[bmg_dat_t]]
  402. typedef struct bmg_dat_t
  403. {
  404. /*00*/ char magic[4]; // = BMG_DAT_MAGIC
  405. /*04*/ be32_t size; // total size of the section
  406. /*08*/ u8 text_pool[];
  407. }
  408. __attribute__ ((packed)) bmg_dat_t;
  409. //-----------------------------------------------------------------------------
  410. // [[bmg_str_t]]
  411. typedef bmg_dat_t bmg_str_t;
  412. //
  413. ///////////////////////////////////////////////////////////////////////////////
  414. /////////////// struct bmg_mid_t ///////////////
  415. ///////////////////////////////////////////////////////////////////////////////
  416. #define BMG_MID_MAGIC "MID1"
  417. #define BMG_MID_DEFAULT_0A 0x1000
  418. #define BMG_MID_DEFAULT_0C 0
  419. //-----------------------------------------------------------------------------
  420. // [[bmg_mid_t]]
  421. typedef struct bmg_mid_t
  422. {
  423. /*00*/ char magic[4]; // = BMG_MID_MAGIC
  424. /*04*/ be32_t size; // total size of the section
  425. /*08*/ be16_t n_msg; // number of messages
  426. /*0a*/ be16_t unknown_0a; // = BMG_MID_DEFAULT_0A = 0x1000 for MKW
  427. /*0c*/ be32_t unknown_0c; // = BMG_MID_DEFAULT_0C = 0 for MKW
  428. /*10*/ u32 mid[0]; // message id table
  429. }
  430. __attribute__ ((packed)) bmg_mid_t;
  431. //
  432. ///////////////////////////////////////////////////////////////////////////////
  433. /////////////// struct bmg_flw_t ///////////////
  434. ///////////////////////////////////////////////////////////////////////////////
  435. #define BMG_FLW_MAGIC "FLW1"
  436. //-----------------------------------------------------------------------------
  437. // [[bmg_flw_t]]
  438. typedef struct bmg_flw_t
  439. {
  440. /*00*/ char magic[4]; // = BMG_FLW_MAGIC
  441. /*04*/ be32_t size; // total size of the section
  442. /*08*/ u8 unknown[]; // ??? [[2do]]
  443. }
  444. __attribute__ ((packed)) bmg_flw_t;
  445. //
  446. ///////////////////////////////////////////////////////////////////////////////
  447. /////////////// struct bmg_fli_t ///////////////
  448. ///////////////////////////////////////////////////////////////////////////////
  449. #define BMG_FLI_MAGIC "FLI1"
  450. //-----------------------------------------------------------------------------
  451. // [[bmg_fli_t]]
  452. typedef struct bmg_fli_t
  453. {
  454. /*00*/ char magic[4]; // = BMG_FLI_MAGIC
  455. /*04*/ be32_t size; // total size of the section
  456. /*08*/ u8 unknown[]; // ??? [[2do]]
  457. }
  458. __attribute__ ((packed)) bmg_fli_t;
  459. //
  460. ///////////////////////////////////////////////////////////////////////////////
  461. /////////////// bmg_sect_info_t & bmg_sect_list_t ///////////////
  462. ///////////////////////////////////////////////////////////////////////////////
  463. // [[bmg_sect_info_t]]
  464. typedef struct bmg_sect_info_t
  465. {
  466. uint offset; // offset from beginning of file
  467. uint sect_size; // section size by section header
  468. uint real_size; // real section size
  469. uint head_size; // size of section header
  470. uint elem_size; // =0: unknown, >0: element size
  471. uint n_elem_head; // elem_size>0: number of elements by header
  472. uint n_elem; // 0: number of real elements
  473. bmg_section_t *sect; // pointer to raw source data
  474. // if NULL: list terminator
  475. bool known; // true: section known
  476. bool supported; // true: section fully supported
  477. bool is_empty; // true: complete data is NULL
  478. // bool use_str1; // true: SINF1 uses 2x 16-bit offsets to STR1
  479. ccp info; // short description
  480. }
  481. bmg_sect_info_t;
  482. //-----------------------------------------------------------------------------
  483. // [[bmg_sect_list_t]]
  484. typedef struct bmg_sect_list_t
  485. {
  486. uint source_size; // valid source size
  487. uint this_size; // total size of this including info[]
  488. const endian_func_t *endian; // endian functions, never NULL
  489. // all following pointers point into raw source data
  490. bmg_header_t *header; // NULL or pointer to BMG file header
  491. bmg_inf_t *pinf; // NULL or pointer to INF1 header
  492. bmg_dat_t *pdat; // NULL or pointer to DAT1 header
  493. bmg_str_t *pstr; // NULL or pointer to STR1 header
  494. bmg_mid_t *pmid; // NULL or pointer to MID1 header
  495. bmg_flw_t *pflw; // NULL or pointer to FLW1 header
  496. bmg_fli_t *pfli; // NULL or pointer to FLI1 header
  497. uint n_sections; // number if secton, get by bmg header
  498. uint n_info; // number of info records excluding terimination
  499. bmg_sect_info_t info[]; // list of sections,
  500. // terminated by a record with sect==NULL
  501. }
  502. bmg_sect_list_t;
  503. //-----------------------------------------------------------------------------
  504. // result is alloced => FREE(result)
  505. bmg_sect_list_t * ScanSectionsBMG
  506. ( cvp data, uint size, const endian_func_t *endian ); // endian==0: auto detect
  507. const bmg_sect_info_t * SearchSectionBMG
  508. (
  509. const bmg_sect_list_t *sl, // valid, created by ScanSectionsBMG()
  510. cvp search, // magic to search
  511. bool abbrev, // if not found: allow abbreviations
  512. bool icase // if not found: ignore case and try again
  513. );
  514. //
  515. ///////////////////////////////////////////////////////////////////////////////
  516. /////////////// struct bmg_raw_section_t ///////////////
  517. ///////////////////////////////////////////////////////////////////////////////
  518. // [[bmg_raw_section_t]]
  519. typedef struct bmg_raw_section_t
  520. {
  521. char magic[4]; // section magic
  522. FastBuf_t data; // data buffer
  523. uint total_size; // total size of section
  524. // if 0: calculate it
  525. struct
  526. bmg_raw_section_t *next; // pointer to next element
  527. }
  528. bmg_raw_section_t;
  529. //-----------------------------------------------------------------------------
  530. bmg_raw_section_t * GetRawSectionBMG ( bmg_t *bmg, cvp magic );
  531. bmg_raw_section_t * CreateRawSectionBMG ( bmg_t *bmg, cvp magic );
  532. //
  533. ///////////////////////////////////////////////////////////////////////////////
  534. /////////////// struct bmg_item_t ///////////////
  535. ///////////////////////////////////////////////////////////////////////////////
  536. // [[bmg_item_t]]
  537. typedef struct bmg_item_t
  538. {
  539. u32 mid; // message ID
  540. u32 cond; // >0: message 'cond' must be defined
  541. bmg_slot_t slot; // BMG_NO_PREDEF_SLOT or predifined slot
  542. u16 attrib_used; // used size of 'attrib'
  543. u8 attrib[BMG_ATTRIB_SIZE];// attribute buffer, copy from 'inf'
  544. // always padded with NULL
  545. u16 *text; // pointer to text
  546. u16 len; // length in u16 words of 'text'
  547. u16 alloced_size; // alloced size in u16 words of 'text'
  548. // if 0: pointer to an other area
  549. // ==> do not free or modify
  550. }
  551. __attribute__ ((packed)) bmg_item_t;
  552. //-----------------------------------------------------------------------------
  553. // special value for bmg_item_t::text
  554. extern u16 bmg_null_entry[]; // = {0}
  555. static inline bool isSpecialEntryBMG ( const u16 *text )
  556. {
  557. return text == bmg_null_entry;
  558. }
  559. //-----------------------------------------------------------------------------
  560. void FreeItemBMG( bmg_item_t * bi );
  561. void AssignItemTextBMG
  562. (
  563. bmg_item_t * bi, // valid item
  564. ccp utf8, // UTF-8 text to store
  565. int len // length of 'utf8'.
  566. // if -1: detect length with strlen()
  567. );
  568. void AssignItemScanTextBMG
  569. (
  570. bmg_item_t * bi, // valid item
  571. ccp utf8, // UTF-8 text to scan
  572. int len // length of 'utf8'.
  573. // if -1: detect length with strlen()
  574. );
  575. void AssignItemText16BMG
  576. (
  577. bmg_item_t * bi, // valid item
  578. const u16 * text16, // text to store
  579. int len // length of 'text16'.
  580. // if -1: detect length by finding
  581. // first NULL value.
  582. );
  583. bool IsItemEqualBMG
  584. (
  585. const bmg_item_t * bi1, // NULL or valid item
  586. const bmg_item_t * bi2 // NULL or valid item
  587. );
  588. u16 * ModifiyItem
  589. (
  590. // return a fixed 'ptr'
  591. bmg_item_t * bi, // valid item, prepare text modification
  592. const u16 * ptr // NULL or a pointer within 'bi->text'
  593. );
  594. //
  595. ///////////////////////////////////////////////////////////////////////////////
  596. /////////////// struct bmg_t ///////////////
  597. ///////////////////////////////////////////////////////////////////////////////
  598. // [[bmg_t]]
  599. struct szs_file_t;
  600. typedef struct bmg_t
  601. {
  602. //--- base info
  603. ccp fname; // alloced filename of loaded file
  604. FileAttrib_t fatt; // file attribute
  605. bool is_text_src; // true: source was text
  606. const endian_func_t * endian; // endian functions, never NULL
  607. //--- container, used by SZS tools
  608. struct szs_file_t *szs; // NULL or pointer to containing SZS
  609. //--- multiple load support
  610. bool src_is_arch; // true: source is an archive
  611. uint src_count; // number of scanned sources
  612. enumError max_err; // max error
  613. uint recurse_depth; // current recurse depth
  614. //--- raw data
  615. u8 * data; // raw data
  616. uint data_size; // size of 'data'
  617. bool data_alloced; // true: 'data' must be freed
  618. bmg_inf_t * inf; // pointer to 'INF1' data
  619. bmg_dat_t * dat; // pointer to 'DAT1' data
  620. bmg_mid_t * mid; // pointer to 'MID1' data
  621. //--- raw sections
  622. bmg_raw_section_t *first_raw; // NULL or pointer to chain of raw sections
  623. bmg_raw_section_t *current_raw; // NULL or pointer to current raw sections
  624. //--- section header data
  625. u32 unknown_inf_0c; // section INF1 offset 0x0c
  626. u16 unknown_mid_0a; // section MID1 offset 0x0a
  627. u32 unknown_mid_0c; // section MID1 offset 0x0c
  628. //--- text map
  629. bmg_item_t * item; // item list
  630. uint item_used; // number of used items
  631. uint item_size; // number of alloced items
  632. //--- attributes and other parameters
  633. bmg_encoding_t encoding; // type of encoding
  634. uint inf_size; // size of each 'inf' element
  635. bool have_mid; // TRUE: enable MID1 creation
  636. bool legacy; // TRUE: legacy (GameCube) mode enabled
  637. u8 attrib[BMG_ATTRIB_SIZE];// attribute buffer for defaults
  638. u16 attrib_used; // used size of 'attrib', ALIGN(4)
  639. u8 use_color_names; // 0:off, 1:auto, 2:on
  640. u8 use_mkw_messages; // 0:off, 1:auto, 2:on
  641. bool param_defined; // true: params above finally defined
  642. bool have_predef_slots; // temporary, set by HavePredifinedSlots()
  643. bool use_slots; // init by opt_bmg_use_slots
  644. bool use_raw_sections; // init by opt_bmg_use_raw_sections
  645. u32 active_cond; // active condition (for text output)
  646. //--- raw data, created by CreateRawBMG()
  647. u8 * raw_data; // NULL or data
  648. uint raw_data_size; // size of 'raw_data'
  649. } bmg_t;
  650. //-----------------------------------------------------------------------------
  651. extern bmg_t *bmg_macros;
  652. //-----------------------------------------------------------------------------
  653. bmg_item_t * FindItemBMG ( const bmg_t *bmg, u32 mid );
  654. bmg_item_t * FindAnyItemBMG ( const bmg_t *bmg, u32 mid );
  655. bmg_item_t * InsertItemBMG ( bmg_t *bmg, u32 mid,
  656. u8 *attrib, uint attrib_used, bool *old_item );
  657. bool DeleteItemBMG ( bmg_t *bmg, u32 mid );
  658. void ResetAttribBMG
  659. (
  660. const bmg_t * bmg, // pointer to bmg
  661. bmg_item_t * item // dest item
  662. );
  663. void CopyAttribBMG
  664. (
  665. const bmg_t * dest, // pointer to destination bmg
  666. bmg_item_t * dptr, // dest item
  667. const bmg_item_t * sptr // source item
  668. );
  669. bool HavePredifinedSlots ( bmg_t *bmg );
  670. //-----------------------------------------------------------------------------
  671. void InitializeBMG ( bmg_t * bmg );
  672. void ResetBMG ( bmg_t * bmg );
  673. void AssignEncodingBMG ( bmg_t * bmg, int encoding );
  674. void AssignInfSizeBMG ( bmg_t * bmg, uint inf_size );
  675. //-----------------------------------------------------------------------------
  676. enumError ScanBMG
  677. (
  678. bmg_t * bmg, // pointer to valid bmg
  679. bool initialize, // true: initialize 'bmg'
  680. ccp fname, // NULL or filename for error messages
  681. const u8 * data, // data / if NULL: use internal data
  682. size_t data_data // size of 'data' if data not NULL
  683. );
  684. enumError ScanRawBMG ( bmg_t * bmg );
  685. enumError ScanTextBMG ( bmg_t * bmg );
  686. enumError LoadBMG
  687. (
  688. bmg_t * bmg, // pointer to valid bmg
  689. bool initialize, // true: initialize 'bmg'
  690. ccp parent_fname, // NULL or filename of parent for dir-extract
  691. ccp fname, // filename of source
  692. FileMode_t file_mode // open modes
  693. );
  694. //-----------------------------------------------------------------------------
  695. char * PrintAttribBMG
  696. (
  697. char *buf, // destination buffer
  698. uint buf_size, // size of 'buf', BMG_ATTRIB_BUF_SIZE is good
  699. const u8 *attrib, // NULL or attrib to print
  700. uint attrib_used, // used length of attrib
  701. const u8 *def_attrib, // NULL or default attrib
  702. bool force // true: always print '[]'
  703. );
  704. //-----------------------------------------------------------------------------
  705. enumError CreateRawBMG
  706. (
  707. bmg_t * bmg // pointer to valid BMG
  708. );
  709. enumError SaveRawBMG
  710. (
  711. bmg_t * bmg, // pointer to valid bmg
  712. ccp fname, // filename of destination
  713. FileMode_t fmode, // create-file mode
  714. bool set_time // true: set time stamps
  715. );
  716. enumError SaveRawFileBMG
  717. (
  718. bmg_t * bmg, // pointer to valid bmg
  719. FILE * f, // valid output file
  720. ccp fname // NULL or filename for error messages
  721. );
  722. enumError SaveTextBMG
  723. (
  724. bmg_t * bmg, // pointer to valid bmg
  725. ccp fname, // filename of destination
  726. FileMode_t fmode, // create-file mode
  727. bool set_time, // true: set time stamps
  728. bool force_numeric, // true: force numeric MIDs
  729. uint brief_count // >0: suppress syntax info
  730. // >1: suppress all comments
  731. // >2: suppress '#BMG' magic
  732. );
  733. enumError SaveTextFileBMG
  734. (
  735. bmg_t * bmg, // pointer to valid bmg
  736. FILE * f, // valid output file
  737. ccp fname, // NULL or filename for error messages
  738. bool force_numeric, // true: force numeric MIDs
  739. uint brief_count // >0: suppress syntax info
  740. // >1: suppress all comments
  741. // >2: suppress '#BMG' magic
  742. );
  743. //
  744. ///////////////////////////////////////////////////////////////////////////////
  745. /////////////// struct bmg_create_t ///////////////
  746. ///////////////////////////////////////////////////////////////////////////////
  747. // [[bmg_create_t]]
  748. typedef struct bmg_create_t
  749. {
  750. bmg_t *bmg; // current bmg
  751. const endian_func_t // endian functions, never NULL
  752. *endian; // init by bmg->endian, overridden by opt_bmg_endian
  753. FastBuf_t inf; // INF1 data
  754. FastBuf_t dat; // DAT1 data
  755. FastBuf_t mid; // MID1 data
  756. bool have_mid; // true: have MID1 section
  757. uint n_msg; // number of inserted messages
  758. //--- iterator -> GetFirstBI() + GetNextBI()
  759. int slot; // slot number
  760. bmg_item_t *bi; // next bi
  761. bmg_item_t *bi_end; // last bi
  762. bmg_item_t **bi_list; // list for predifined slots
  763. uint bi_used; // number of used elements in 'bi_list'
  764. uint bi_size; // number of alloced elements in 'bi_list'
  765. }
  766. bmg_create_t;
  767. //-----------------------------------------------------------------------------
  768. void InitializeCreateBMG( bmg_create_t *bc, bmg_t *bmg );
  769. void ResetCreateBMG ( bmg_create_t *bc );
  770. bmg_item_t * GetFirstBI ( bmg_create_t *bc );
  771. bmg_item_t * GetNextBI ( bmg_create_t *bc );
  772. //
  773. ///////////////////////////////////////////////////////////////////////////////
  774. /////////////// struct bmg_scan_mid_t ///////////////
  775. ///////////////////////////////////////////////////////////////////////////////
  776. // [[bmg_scan_mid_t]]
  777. typedef struct bmg_scan_mid_t
  778. {
  779. int status; // -1 for invalid, or 'n_mid'
  780. int n_mid; // number of valid members in mid (0..3)
  781. u32 mid[3]; // list of message IDs
  782. // mid[0]: standard MID
  783. // mid[1]: twin (track or arena)
  784. // mid[2]: MID for LE_CODE or CT_CODE
  785. char *scan_end; // NULL or end of scanned 'source'
  786. }
  787. bmg_scan_mid_t;
  788. //-----------------------------------------------------------------------------
  789. int ScanBMGMID
  790. (
  791. // returns 'scan->status'
  792. bmg_scan_mid_t *scan, // result, never NULL
  793. bmg_t *bmg, // NULL or bmg to update parameters
  794. ccp src, // source pointer
  795. ccp src_end // NULL or end of source
  796. );
  797. //-----------------------------------------------------------------------------
  798. // [[obsolete]] wrapper for ScanBMGMID();
  799. int ScanMidBMG
  800. (
  801. // returns:
  802. // -1: invalid MID
  803. // 0: empty line
  804. // 1: single mid found
  805. // 2: double mid found (track or arena)
  806. // 3: triple mid found (track or arena, CTCODE)
  807. bmg_t *bmg, // NULL or bmg to update parameters
  808. u32 *ret_mid1, // return value: pointer to first MID
  809. u32 *ret_mid2, // return value: pointer to second MID
  810. u32 *ret_mid3, // return value: pointer to third MID
  811. ccp src, // source pointer
  812. ccp src_end, // NULL or end of source
  813. char **scan_end // return value: NULL or end of scanned 'source'
  814. );
  815. //
  816. ///////////////////////////////////////////////////////////////////////////////
  817. /////////////// MKW hooks ///////////////
  818. ///////////////////////////////////////////////////////////////////////////////
  819. extern int (*GetTrackIndexBMG) ( uint idx, int result_if_not_found );
  820. extern int (*GetArenaIndexBMG) ( uint idx, int result_if_not_found );
  821. extern ccp (*GetContainerNameBMG) ( const bmg_t * bmg );
  822. extern int (*AtHookBMG) ( bmg_t * bmg, ccp line, ccp line_end );
  823. // On return status:
  824. // -1: continue with scanning line
  825. // -2: continue with next line
  826. // >=0: close file and return status as error code
  827. //
  828. ///////////////////////////////////////////////////////////////////////////////
  829. /////////////// patch BMG ///////////////
  830. ///////////////////////////////////////////////////////////////////////////////
  831. // [[PatchModeBMG_t]]
  832. typedef enum PatchModeBMG_t
  833. {
  834. // this mode descibes the operation:
  835. // source := source x patch
  836. //--------------------------------------//
  837. // only only source source //
  838. // in in != == //
  839. // source patch patch patch //
  840. //--------------------------------------//
  841. BMG_PM_PRINT, // source - print print //
  842. BMG_PM_FORMAT, // ________use_parameter________ //
  843. BMG_PM_REGEX, // ________use_parameter________ //
  844. BMG_PM_RM_REGEX, // ________use_parameter________ //
  845. BMG_PM_ID, // prefix n.a. n.a. n.a. //
  846. BMG_PM_ID_ALL, // prefix n.a. n.a. n.a. //
  847. BMG_PM_UNICODE, // ___no_patch_file_available___ //
  848. BMG_PM_RM_ESCAPES, // ___no_patch_file_available___ //
  849. //--------------------------------------//
  850. BMG_PM_REPLACE, // source - patch both //
  851. BMG_PM_INSERT, // source patch source both //
  852. BMG_PM_OVERWRITE, // source patch patch both //
  853. BMG_PM_DELETE, // source - - - //
  854. BMG_PM_MASK, // - - source both //
  855. BMG_PM_EQUAL, // - - - both //
  856. BMG_PM_NOT_EQUAL, // - - source - //
  857. //--------------------------------------//
  858. BMG_PM_GENERIC, // ___no_patch_file_available___ //
  859. BMG_PM_RM_CUPS, // ___no_patch_file_available___ //
  860. BMG_PM_CT_COPY, // ___no_patch_file_available___ //
  861. BMG_PM_CT_FORCE_COPY, // ___no_patch_file_available___ //
  862. BMG_PM_CT_FILL, // ___no_patch_file_available___ //
  863. BMG_PM_LE_COPY, // ___no_patch_file_available___ //
  864. BMG_PM_LE_FORCE_COPY, // ___no_patch_file_available___ //
  865. BMG_PM_LE_FILL, // ___no_patch_file_available___ //
  866. BMG_PM_X_COPY, // ___no_patch_file_available___ //
  867. BMG_PM_X_FORCE_COPY, // ___no_patch_file_available___ //
  868. BMG_PM_X_FILL, // ___no_patch_file_available___ //
  869. BMG_PM_RM_FILLED, // ___no_patch_file_available___ //
  870. //--------------------------------------//
  871. //--- helpers
  872. BMG_PM__MASK_CMD = 0xff, // relevant bits of the command
  873. BMG_PM__SHIFT_OPT = 8 // shift the parameter option by 8 bits
  874. } PatchModeBMG_t;
  875. ///////////////////////////////////////////////////////////////////////////////
  876. enumError PatchBMG
  877. (
  878. bmg_t *dest, // pointer to destination bmg
  879. const bmg_t *src, // pointer to source bmg
  880. PatchModeBMG_t patch_mode, // patch mode
  881. ccp format, // NULL or format parameter
  882. bool dup_strings // true: alloc mem for copied strings (OVERWRITE)
  883. );
  884. //-----------------------------------------------------------------------------
  885. bool PatchFormatBMG
  886. (
  887. bmg_t *dest, // pointer to destination bmg
  888. const bmg_t *src, // pointer to source bmg
  889. ccp format // format parameter
  890. );
  891. bool PatchOverwriteBMG
  892. (
  893. bmg_t * dest, // pointer to destination bmg
  894. const bmg_t * src, // pointer to source bmg
  895. bool dup_strings // true: allocate mem for copied strings
  896. );
  897. bool PatchPrintBMG ( bmg_t * dest, const bmg_t * src );
  898. bool PatchReplaceBMG ( bmg_t * dest, const bmg_t * src );
  899. bool PatchInsertBMG ( bmg_t * dest, const bmg_t * src );
  900. bool PatchDeleteBMG ( bmg_t * dest, const bmg_t * src );
  901. bool PatchMaskBMG ( bmg_t * dest, const bmg_t * src );
  902. bool PatchEqualBMG ( bmg_t * dest, const bmg_t * src );
  903. bool PatchNotEqualBMG ( bmg_t * dest, const bmg_t * src );
  904. bool PatchGenericBMG ( bmg_t * dest, const bmg_t * src );
  905. bool PatchRmCupsBMG ( bmg_t * bmg );
  906. bool PatchCTCopyBMG ( bmg_t * bmg );
  907. bool PatchLECopyBMG ( bmg_t * bmg );
  908. bool PatchXCopyBMG ( bmg_t * bmg );
  909. bool PatchCTForceCopyBMG( bmg_t * bmg );
  910. bool PatchLEForceCopyBMG( bmg_t * bmg );
  911. bool PatchXForceCopyBMG ( bmg_t * bmg );
  912. bool PatchFillBMG
  913. ( bmg_t *bmg, ct_mode_t ct_mode, uint rcup_limit, uint track_limit );
  914. bool PatchXFillBMG ( bmg_t *bmg, uint rcup_limit, uint track_limit );
  915. static inline bool PatchCTFillBMG ( bmg_t *bmg, uint rcup_limit, uint track_limit )
  916. { return PatchFillBMG(bmg,CTM_CTCODE,rcup_limit,track_limit); }
  917. static inline bool PatchLEFillBMG ( bmg_t *bmg, uint rcup_limit, uint track_limit )
  918. { return PatchFillBMG(bmg,CTM_LECODE2,rcup_limit,track_limit); }
  919. bool PatchIdBMG
  920. (
  921. bmg_t * bmg, // pointer to destination bmg
  922. bool prefix_all // true: prefix all messages
  923. );
  924. bool PatchRmEscapesBMG
  925. (
  926. bmg_t * bmg, // pointer to destination bmg
  927. bool unicode, // replace '\u{16bit}' by unicode chars
  928. bool rm_escapes // remove 1A escapes
  929. );
  930. // remove between mid1 and mid2-1
  931. bool PatchRemoveBMG ( bmg_t * bmg, int mid1, int mid2 );
  932. //bool PatchRemoveTracksBMG ( bmg_t * bmg, int track_limit );
  933. bool PatchIdentificationBMG ( bmg_t *bmg, ct_bmg_t *ctb );
  934. //-----------------------------------------------------------------------------
  935. ccp GetNameBMG ( const bmg_t *bmg, uint *name_len );
  936. //
  937. ///////////////////////////////////////////////////////////////////////////////
  938. /////////////// E N D ///////////////
  939. ///////////////////////////////////////////////////////////////////////////////
  940. #endif // DC_LIB_BMG_H 1