aboutsummaryrefslogtreecommitdiff
path: root/project/src/lib-lecode.h
diff options
context:
space:
mode:
authorWiimm <wiimm@wiimm.de>2021-02-03 16:42:38 +0100
committerWiimm <wiimm@wiimm.de>2021-02-03 16:42:38 +0100
commit69894f75254cd630e2e4fe1422044c6b7d6adb5f (patch)
tree139b93491a16987905c53c4e10bc8b44034de278 /project/src/lib-lecode.h
parenta3d605bc52ba3e53720d0dee29a470661b35a1c2 (diff)
SZS 2.23a
Diffstat (limited to '')
-rw-r--r--project/src/lib-lecode.h354
1 files changed, 1 insertions, 353 deletions
diff --git a/project/src/lib-lecode.h b/project/src/lib-lecode.h
index b480166..edb1630 100644
--- a/project/src/lib-lecode.h
+++ b/project/src/lib-lecode.h
@@ -17,7 +17,7 @@
* This file is part of the SZS project. *
* Visit https://szs.wiimm.de/ for project details and sources. *
* *
- * Copyright (c) 2011-2020 by Dirk Clemens <wiimm@wiimm.de> *
+ * Copyright (c) 2011-2021 by Dirk Clemens <wiimm@wiimm.de> *
* *
***************************************************************************
* *
@@ -543,358 +543,6 @@ void PatchLPAR ( le_lpar_t * lp );
//
///////////////////////////////////////////////////////////////////////////////
-/////////////// lecode extension LEX ///////////////
-///////////////////////////////////////////////////////////////////////////////
-
-#define LEX_MAJOR_VERSION 1
-#define LEX_MINOR_VERSION 0
-
-#define LEX_BIN_MAGIC "LE-X"
-#define LEX_BIN_MAGIC_NUM 0x4c452d58
-#define LEX_TEXT_MAGIC "#LEX"
-#define LEX_TEXT_MAGIC_NUM 0x234c4558
-
-///////////////////////////////////////////////////////////////////////////////
-// [[have_lex_t]]
-// order is important, compare have_lex_info[] and ct.wiimm.de
-
-typedef enum have_lex_t
-{
- HAVELEX_SET1,
- HAVELEX_CANN,
- HAVELEX_TEST,
- HAVELEX_HIPT,
- //--- add new elements here (order is important)
- HAVELEX__N
-}
-have_lex_t;
-
-//-----------------------------------------------------------------------------
-// [[lex_stream_id]]
-
-typedef enum lex_stream_id
-{
- LEXS_TERMINATE = 0, // terminate stream
- LEXS_IGNORE = 0x2d2d2d2d, // "----" ignore and remove
-
- LEXS_SET1 = 0x53455431, // "SET1" primary settings
- LEXS_CANN = 0x43414e4e, // "CANN" cannon settings
- LEXS_HIPT = 0x48495054, // "HIPT" hide position tracker
- LEXS_TEST = 0x54455354, // "TEST" settings for tests
-}
-lex_stream_id;
-
-//-----------------------------------------------------------------------------
-// [[have_lex_info_t]]
-
-typedef struct have_lex_info_t
-{
- lex_stream_id magic; // section magic
- ccp name; // info name
- uint min_size; // minimal size for 'is available'
-}
-have_lex_info_t;
-
-extern const have_lex_info_t have_lex_info[HAVELEX__N];
-
-//-----------------------------------------------------------------------------
-// [[lex_header_t]]
-
-typedef struct lex_header_t
-{
- char magic[4]; // always LEX_BIN_MAGIC
- u16 major_version; // usually LEX_MAJOR_VERSION
- u16 minor_version; // usually LEX_MINOR_VERSION
- u32 size; // size of this file (header+streams)
- u32 element_off; // offset of first lex_element_t, 32-bit aligned
-}
-__attribute__ ((packed)) lex_header_t;
-
-//-----------------------------------------------------------------------------
-// [[lex_element_t]]
-
-typedef struct lex_element_t
-{
- u32 magic; // identification of section
- u32 size; // size of 'data' (this header excluded)
- u8 data[]; // section data, 32-bit aligned
-}
-__attribute__ ((packed)) lex_element_t;
-
-//-----------------------------------------------------------------------------
-// [[lex_set1_t]]
-
-typedef struct lex_set1_t
-{
- float3 item_factor; // factor for item positions, always >=1.0
- u8 test[4]; // 4 test values (TEST1..TEST4)
-}
-__attribute__ ((packed,aligned(4))) lex_set1_t;
-
-//-----------------------------------------------------------------------------
-// [[lex_hipt_rule_t]]
-
-typedef struct lex_hipt_rule_t
-{
- u8 cond; // condition bits: 1:offline, 2:online
- s8 lap; // compare lap index with this. 99=all laps
- u8 from; // compare CHKT >= from
- u8 to; // && CHKT <= to
- u8 mode; // result: 0=hide, 1:show
-}
-__attribute__ ((packed)) lex_hipt_rule_t;
-
-//-----------------------------------------------------------------------------
-// [[lex_test_t]]
-
-typedef struct lex_test_t
-{
- u8 offline_online; // 1: assume offline / 2: assume online
- u8 n_offline; // >0: assume # offline humans at Wii
- u8 n_online; // >0: assume # players total if playing online
- s8 cond_bit; // >=0: use bit # for CONDITIONS
- u8 game_mode; // one of LEX_GMODE_*
- u8 random; // 1..6: force random scenario
- u8 engine; // >=0: force engine := kmp_engine_t+1
- u8 padding;
-}
-__attribute__ ((packed,aligned(4))) lex_test_t;
-
-///////////////////////////////////////////////////////////////////////////////
-
-typedef enumError (*lex_stream_func)
- ( u32 magic, const u8 *data, uint size, cvp user_ptr, int user_int );
-
-enumError ScanLexFile
- ( cvp data, uint data_size, lex_stream_func func, cvp user_ptr, int user_int );
-enumError ScanLexElements
- ( cvp data, uint data_size, lex_stream_func func, cvp user_ptr, int user_int );
-
-lex_element_t * FindLexElement ( lex_header_t *head, uint data_size, u32 magic );
-
-//
-///////////////////////////////////////////////////////////////////////////////
-/////////////// lex_t ///////////////
-///////////////////////////////////////////////////////////////////////////////
-// [[lex_item_t]]
-
-typedef struct lex_item_t
-{
- uint sort_order; // sort priority, lesser comes first
- uint insert_order; // second sort priority
-
- // always last element because of various size!!
- lex_element_t elem; // raw element data, big endian
-}
-lex_item_t;
-
-///////////////////////////////////////////////////////////////////////////////
-// [[lex_t]]
-
-typedef struct lex_t
-{
- //--- base info
-
- ccp fname; // alloced filename of loaded file
- FileAttrib_t fatt; // file attribute
- file_format_t fform; // FF_LEX | FF_LEX_TXT
- bool develop; // true: enable developer mode
- bool modified; // true: modified after loading
-
-
- //--- sections
-
- uint item_used; // number of used items
- uint item_size; // number of alloced items
- lex_item_t **item; // NULL or item list (alloced)
- uint have_lex; // status vector about found sections
-
-
- //--- parser helpers
-
- int revision; // tool revision
- bool is_pass2; // true: LEX compiler runs pass2
-
-
- //--- raw data, created by CreateRawLEX()
-
- u8 * raw_data; // NULL or data
- uint raw_data_size; // size of 'raw_data'
-}
-lex_t;
-
-//
-///////////////////////////////////////////////////////////////////////////////
-/////////////// LEX interface ///////////////
-///////////////////////////////////////////////////////////////////////////////
-
-void InitializeLEX ( lex_t * lex );
-void ResetLEX ( lex_t * lex );
-void UpdateLEX ( lex_t * lex, bool add_missing, bool add_test );
-
-lex_item_t * AppendSet1LEX ( lex_t * lex, bool overwrite );
-lex_item_t * AppendCannLEX ( lex_t * lex, bool overwrite );
-lex_item_t * AppendHiptLEX ( lex_t * lex, bool overwrite );
-lex_item_t * AppendTestLEX ( lex_t * lex, bool overwrite );
-
-const VarMap_t * SetupVarsLEX();
-
-void DumpElementsLEX ( FILE *f, lex_t *lex, bool hexdump );
-
-ccp CreateSectionInfoLEX
- ( have_lex_t special, bool add_value, ccp return_if_empty );
-
-static inline bool IsLexFF ( file_format_t fform )
- { return fform == FF_LEX || fform == FF_LEX_TXT; }
-
-///////////////////////////////////////////////////////////////////////////////
-
-enumError ScanRawLEX
-(
- lex_t * lex, // LEX data structure
- bool init_lex, // true: initialize 'lex' first
- const void * data, // data to scan
- uint data_size, // size of 'data'
- uint dump_mode // 0: add element to lex->sect
- // 1: dump scanned elements
- // >=0x10: add hexdump of max # bytes
-);
-
-//-----------------------------------------------------------------------------
-
-enumError ScanTextLEX
-(
- lex_t * lex, // LEX data structure
- bool init_lex, // true: initialize 'lex' first
- const void * data, // data to scan
- uint data_size // size of 'data'
-);
-
-//-----------------------------------------------------------------------------
-
-enumError ScanLEX
-(
- lex_t * lex, // LEX data structure
- bool init_lex, // true: initialize 'lex' first
- const void * data, // data to scan
- uint data_size // size of 'data'
-);
-
-//-----------------------------------------------------------------------------
-
-enumError ScanRawDataLEX
-(
- lex_t * lex, // LEX data structure
- bool init_lex, // true: initialize 'lex' first
- struct raw_data_t * raw // valid raw data
-);
-
-///////////////////////////////////////////////////////////////////////////////
-
-enumError LoadLEX
-(
- lex_t * lex, // LEX data structure
- bool init_lex, // true: initialize 'lex' first
- ccp fname, // valid pointer to filenname
- bool ignore_no_file // ignore if file does not exists
- // and return warning ERR_NOT_EXISTS
-);
-
-//-----------------------------------------------------------------------------
-
-enumError CreateRawLEX
-(
- lex_t * lex // pointer to valid LEX
-);
-
-//-----------------------------------------------------------------------------
-
-enumError SaveRawLEX
-(
- lex_t * lex, // pointer to valid LEX
- ccp fname, // filename of destination
- bool set_time // true: set time stamps
-);
-
-//-----------------------------------------------------------------------------
-
-enumError SaveTextLEX
-(
- const lex_t * lex, // pointer to valid LEX
- ccp fname, // filename of destination
- bool set_time // true: set time stamps
-);
-
-//
-///////////////////////////////////////////////////////////////////////////////
-/////////////// lex_info_t ///////////////
-///////////////////////////////////////////////////////////////////////////////
-// [[lex_info_t]]
-
-typedef struct lex_info_t
-{
- bool lex_found; // true: LEX file found
-
- bool set1_found; // true: section SET1 found
- lex_set1_t set1; // data of section SET1
-
- bool test_found; // true: section TEST found
- lex_set1_t test; // data of section TEST
-}
-lex_info_t;
-
-///////////////////////////////////////////////////////////////////////////////
-
-static inline void InitializeLexInfo ( lex_info_t *info )
- { DASSERT(info); memset(info,0,sizeof(*info)); }
-
-static inline void ResetLexInfo ( lex_info_t *info )
- { if (info) memset(info,0,sizeof(*info)); }
-
-void SetupLexInfo ( lex_info_t *info, const lex_t *lex );
-enumError SetupLexInfoByData ( lex_info_t *info, cvp data, uint data_size );
-
-//
-///////////////////////////////////////////////////////////////////////////////
-/////////////// LEX patching ///////////////
-///////////////////////////////////////////////////////////////////////////////
-
-extern bool opt_lex_purge;
-extern bool force_lex_test;
-extern bool opt_lt_clear;
-extern int opt_lt_online;
-extern int opt_lt_n_offline;
-extern int opt_lt_n_online;
-extern int opt_lt_itemrain;
-
-int ScanOptLtOnline ( ccp arg );
-int ScanOptLtNPlayers ( ccp arg );
-int ScanOptLtCondBit ( ccp arg );
-int ScanOptLtGameMode ( ccp arg );
-int ScanOptLtEngine ( ccp arg );
-int ScanOptLtRandom ( ccp arg );
-
-// return TRUE if any option set
-bool HavePatchTestLEX();
-bool HaveActivePatchTestLEX();
-static inline bool HavePatchLEX()
- { return opt_lex_purge || HavePatchTestLEX(); }
-static inline bool HaveActivePatchLEX()
- { return opt_lex_purge || HaveActivePatchTestLEX(); }
-
-// return TRUE if modified / set optional 'empty' to true, if test section is empty
-bool PatchTestLEX ( lex_test_t *lt, bool *empty );
-bool PatchLEX ( lex_t *lex );
-bool PurgeLEX ( lex_t *lex );
-
-struct szs_norm_t;
-void AddTestLEX ( struct szs_file_t *szs, struct szs_norm_t *norm );
-
-bool LEX_ACTION_LOG ( bool is_patch, const char * format, ... )
- __attribute__ ((__format__(__printf__,2,3)));
-
-//
-///////////////////////////////////////////////////////////////////////////////
/////////////// misc ///////////////
///////////////////////////////////////////////////////////////////////////////