diff options
Diffstat (limited to 'project/src')
| -rw-r--r-- | project/src/lib-analyze.c | 22 | ||||
| -rw-r--r-- | project/src/lib-file.c | 7 | ||||
| -rw-r--r-- | project/src/lib-kmp-text.c | 2 | ||||
| -rw-r--r-- | project/src/lib-kmp.h | 4 | ||||
| -rw-r--r-- | project/src/lib-lecode.c | 81 | ||||
| -rw-r--r-- | project/src/lib-lecode.h | 72 | ||||
| -rw-r--r-- | project/src/lib-lex.c | 345 | ||||
| -rw-r--r-- | project/src/lib-lex.h | 54 | ||||
| -rw-r--r-- | project/src/lib-mdl.c | 2 | ||||
| -rw-r--r-- | project/src/lib-numeric.c | 36 | ||||
| -rw-r--r-- | project/src/lib-parser-func.c | 4 | ||||
| -rw-r--r-- | project/src/lib-pat.c | 2 | ||||
| -rw-r--r-- | project/src/lib-std.h | 2 | ||||
| -rw-r--r-- | project/src/lib-szs.h | 1 | ||||
| -rw-r--r-- | project/src/prefix.inc | 187 | ||||
| -rw-r--r-- | project/src/ui/tab-wlect.inc | 2 | ||||
| -rw-r--r-- | project/src/ui/tab-wszst.inc | 2 | ||||
| -rw-r--r-- | project/src/ui/ui-wlect.c | 6 | ||||
| -rw-r--r-- | project/src/ui/ui-wszst.c | 4 | ||||
| -rw-r--r-- | project/src/ui/ui.def | 10 | ||||
| -rw-r--r-- | project/src/wlect.c | 13 | ||||
| -rw-r--r-- | project/src/wszst.c | 2 | ||||
| -rw-r--r-- | project/src/wtest.c | 165 |
23 files changed, 812 insertions, 213 deletions
diff --git a/project/src/lib-analyze.c b/project/src/lib-analyze.c index 3f2049e..322a2bd 100644 --- a/project/src/lib-analyze.c +++ b/project/src/lib-analyze.c @@ -202,8 +202,9 @@ void AnalyzeSZS InitializeLEX(&lex); lex.check_only = true; ScanLEX(&lex,false,szs->course_lex_data,szs->course_lex_size); - szs->have.lex_sect = lex.have_sect; - szs->have.lex_feat = lex.have_feat; + szs->have.lex_sect = lex.have_sect; + szs->have.lex_feat = lex.have_feat; + szs->have.lex_apply_otl = lex.apply_otl; SetupLexInfo(&as->lexinfo,&lex); ResetLEX(&lex); } @@ -445,7 +446,24 @@ void AnalyzeSZS //--- finalize ct_attrib by "lex" and "warn" if (szs->course_lex_data) + { ct_dest = StringCopyE(ct_dest,ct_end,",lex"); + if ( szs->have.lex_apply_otl ) + { + if ( szs->have.lex_apply_otl < 100 ) + ct_dest = snprintfE(ct_dest,ct_end,",otl=%us",szs->have.lex_apply_otl); + else + { + uint sec = szs->have.lex_apply_otl % 60; + if (sec) + ct_dest = snprintfE(ct_dest,ct_end,",otl=%um%02u", + szs->have.lex_apply_otl / 60, sec ); + else + ct_dest = snprintfE(ct_dest,ct_end,",otl=%um", + szs->have.lex_apply_otl / 60 ); + } + } + } if (szs->warn_bits) ct_dest = StringCat2E(ct_dest,ct_end,",warn=",GetWarnSZSNames(szs->warn_bits,'+')); diff --git a/project/src/lib-file.c b/project/src/lib-file.c index 0bd1daa..5e4f7c4 100644 --- a/project/src/lib-file.c +++ b/project/src/lib-file.c @@ -4254,10 +4254,10 @@ enumError SavePrefixTable ( FILE *f, const mkw_prefix_t * tab ) fprintf(f, "#-------------------\r\n" "# %u prefixes total\r\n" - "# Max prefix len:%2u\r\n" - "# Max info len:%4u\r\n" + "# Max prefix len:%3u\r\n" + "# Max info len:%5u\r\n" ,count - ,fw_prefix + ,fw_prefix ,fw_info ); @@ -4653,6 +4653,7 @@ void ScanSha1Ref ( struct ScanText_t *st ) uint good_size = 0; + st->ignore_values = false; while ( NextLineScanText(st) ) { mem_t srcline = { .ptr = st->line, .len = st->eol - st->line }; diff --git a/project/src/lib-kmp-text.c b/project/src/lib-kmp-text.c index 161765e..036a311 100644 --- a/project/src/lib-kmp-text.c +++ b/project/src/lib-kmp-text.c @@ -6418,7 +6418,7 @@ enumError SaveTextKMP fprintf(F.f, "%s[SETUP]\r\n\r\n" "TOOL = %s\r\n" - "SYSTEM2 = %s\r\n" + "SYSTEM = %s\r\n" "VERSION = %s\r\n" "REVISION = %u\r\n" "DATE = %s\r\n" diff --git a/project/src/lib-kmp.h b/project/src/lib-kmp.h index c1c42cb..8de8ea1 100644 --- a/project/src/lib-kmp.h +++ b/project/src/lib-kmp.h @@ -494,7 +494,7 @@ __attribute__ ((packed)) kmp_poti_group_t; // [[kmp_poti_point_t]] typedef struct kmp_poti_point_t -{ +{ // Routes /*0x00*/ float32 position[3]; @@ -581,7 +581,7 @@ typedef struct kmp_stgi_entry_t { // Stage Information - /*0x00*/ u8 lap_count; // XML suggest but ignored + /*0x00*/ u8 lap_count; // XML suggest, used by lap_modifier /*0x01*/ u8 pole_pos; // 0:left, 1:right /*0x02*/ u8 narrow_start; // 0:normal, 1:closer together /*0x03*/ u8 enable_lens_flare; // 0:off, 1:enabled diff --git a/project/src/lib-lecode.c b/project/src/lib-lecode.c index 672aca5..5a859f4 100644 --- a/project/src/lib-lecode.c +++ b/project/src/lib-lecode.c @@ -1081,6 +1081,19 @@ bool LimitToLparMode ( le_lpar_t * lp, lpar_mode_t lpmode ) { lp->enable_perfmon = 1; modified = true; } } + #if 0 + // [[time-limit]] + if ( lpmode <= LPM_TESTING ) + { + if ( lp->default_online_sec > LE_MAX_ONLINE_SEC ) + { lp->default_online_sec = LE_MAX_ONLINE_SEC; modified = true; } + if ( lp->min_online_sec > LE_MAX_ONLINE_SEC ) + { lp->min_online_sec = LE_MAX_ONLINE_SEC; modified = true; } + if ( lp->max_online_sec > LE_MAX_ONLINE_SEC ) + { lp->max_online_sec = LE_MAX_ONLINE_SEC; modified = true; } + } + #endif + // [[new-lpar]] return modified; @@ -1266,6 +1279,10 @@ void InitializeLPAR ( le_lpar_t *lpar, bool load_lpar ) lpar->drag_blue_shell = 1; lpar->thcloud_frames = 300; lpar->block_textures = 1; +// [[time-limit]] + lpar->default_online_sec = LE_DEF_ONLINE_SEC; + lpar->min_online_sec = LE_DEF_ONLINE_SEC; + lpar->max_online_sec = LE_MAX_WD_ONLINE_SEC; // [[new-lpar]] @@ -1325,6 +1342,16 @@ static void NormalizeLPAR ( le_lpar_t * lp, int build ) lp->vs_worldwide &= 1; } +// [[time-limit]] + lp->default_online_sec = MINMAX( lp->default_online_sec, LE_MIN_ONLINE_SEC, LE_MAX_ONLINE_SEC ); + if ( !lp->min_online_sec || lp->min_online_sec > lp->max_online_sec ) + lp->min_online_sec = lp->max_online_sec = 0; + else + { + lp->min_online_sec = MINMAX( lp->min_online_sec, LE_MIN_ONLINE_SEC, LE_MAX_ONLINE_SEC ); + lp->max_online_sec = MINMAX( lp->max_online_sec, lp->min_online_sec, LE_MAX_ONLINE_SEC ); + } + // [[new-lpar]] #if 0 @@ -1418,6 +1445,14 @@ static void CopyLPAR2Data ( le_analyze_t * ana ) if ( offsetof(le_binpar_v1_t,staticr_points) < ana->param_size ) h->staticr_points = lp->staticr_points; +// [[time-limit]] + if ( offsetof(le_binpar_v1_t,default_online_sec) < ana->param_size ) + h->default_online_sec = htons(lp->default_online_sec); + if ( offsetof(le_binpar_v1_t,min_online_sec) < ana->param_size ) + h->min_online_sec = htons(lp->min_online_sec); + if ( offsetof(le_binpar_v1_t,max_online_sec) < ana->param_size ) + h->max_online_sec = htons(lp->max_online_sec); + // [[new-lpar]] } @@ -1574,6 +1609,13 @@ enumError WriteSectionLPAR ,lpar_std_flags( lpar->vs_textures & LE_M_TEXTURE ) ,lpar->block_textures ,lpar->staticr_points +// [[time-limit]] + ,LE_MIN_ONLINE_SEC ,PrintHMS(0,0,LE_MIN_ONLINE_SEC,LE_VIEW_ONLINE_HMS," (",")") + ,LE_MAX_ONLINE_SEC ,PrintHMS(0,0,LE_MAX_ONLINE_SEC,LE_VIEW_ONLINE_HMS," (",")") + ,LE_MAX_WD_ONLINE_SEC ,PrintHMS(0,0,LE_MAX_WD_ONLINE_SEC,LE_VIEW_ONLINE_HMS," (",")") + ,lpar->default_online_sec ,PrintHMS(0,0,lpar->default_online_sec,LE_VIEW_ONLINE_HMS," # ",0) + ,lpar->min_online_sec ,PrintHMS(0,0,lpar->min_online_sec,LE_VIEW_ONLINE_HMS," # ",0) + ,lpar->max_online_sec ,PrintHMS(0,0,lpar->max_online_sec,LE_VIEW_ONLINE_HMS," # ",0) ); } else @@ -1600,6 +1642,9 @@ enumError WriteSectionLPAR "VS-TEXTURES = %s\r\n" "BLOCK-TEXTURES = %u\r\n" "STATICR-POINTS = %u\r\n" + "DEF-ONLINE-SEC = %3u%s\r\n" + "MIN-ONLINE-SEC = %3u%s\r\n" + "MAX-ONLINE-SEC = %3u%s\r\n" ,GetLparModeName(CalcCurrentLparMode(lpar,true),export_count>0) ,lpar->cheat_mode ,lpar->engine[0],lpar->engine[1],lpar->engine[2] @@ -1619,6 +1664,10 @@ enumError WriteSectionLPAR ,lpar_std_flags( lpar->vs_textures & LE_M_TEXTURE ) ,lpar->block_textures ,lpar->staticr_points +// [[time-limit]] + ,lpar->default_online_sec ,PrintHMS(0,0,lpar->default_online_sec,LE_VIEW_ONLINE_HMS," # ",0) + ,lpar->min_online_sec ,PrintHMS(0,0,lpar->min_online_sec,LE_VIEW_ONLINE_HMS," # ",0) + ,lpar->max_online_sec ,PrintHMS(0,0,lpar->max_online_sec,LE_VIEW_ONLINE_HMS," # ",0) ); } @@ -2090,6 +2139,15 @@ enumError AnalyzeLEBinary ana->lpar.staticr_points = p->staticr_points; } + if ( param_size >= sizeof(le_binpar_v1_270_t) ) + { +// [[time-limit]] + le_binpar_v1_270_t *p = (le_binpar_v1_270_t*)(data+off_param); + ana->lpar.default_online_sec = ntohs(p->default_online_sec); + ana->lpar.min_online_sec = ntohs(p->min_online_sec); + ana->lpar.max_online_sec = ntohs(p->max_online_sec); + } + // [[new-lpar]] break; @@ -2547,11 +2605,11 @@ static ccp GetSlotInfo return flags & G_LEFL_ALIAS ? PrintCircBuf("[%s->%4x %s,%s] ", col->differ, TrackByAliasLE(prop,music), - col->reset, PrintLEFL(ana->flags_bits,flags,true) ) + col->reset, PrintLEFLcol(ana->flags_bits,flags,true,col) ) : PrintCircBuf("[%s%s%s,%s%s%s,%s]%c", prop1, propx, prop0, music1, musicx, music0, - PrintLEFL(ana->flags_bits,flags,true), warn_list[warn] ); + PrintLEFLcol(ana->flags_bits,flags,true,col), warn_list[warn] ); } if (col) @@ -3250,6 +3308,21 @@ void DumpLEAnalyse ( FILE *f, uint indent, const le_analyze_t *ana ) ); } + if ( ana->param_size >= sizeof(le_binpar_v1_270_t) ) + { +// [[time-limit]] + const uint def = ntohs(h->default_online_sec); + const uint min = ntohs(h->min_online_sec); + const uint max = ntohs(h->max_online_sec); + fprintf(f, + "%*s" "Online time limit: %us%s / Range for LEX: %us%s .. %us%s\n" + ,indent,"" + ,def, PrintHMS(0,0,def,LE_VIEW_ONLINE_HMS," (",")") + ,min, PrintHMS(0,0,min,LE_VIEW_ONLINE_HMS," (",")") + ,max, PrintHMS(0,0,max,LE_VIEW_ONLINE_HMS," (",")") + ); + } + // [[new-lpar]] #if 0 // for later use @@ -3959,6 +4032,10 @@ static enumError ScanTextLPAR_PARAM { "VS-TEXTURES", SPM_U8, &lpar->vs_textures }, { "BLOCK-TEXTURES", SPM_U8, &lpar->block_textures }, { "STATICR-POINTS", SPM_U8, &lpar->staticr_points }, +// [[time-limit]] + { "DEF-ONLINE-SEC", SPM_U16, &lpar->default_online_sec }, + { "MIN-ONLINE-SEC", SPM_U16, &lpar->min_online_sec }, + { "MAX-ONLINE-SEC", SPM_U16, &lpar->max_online_sec }, // [[new-lpar]] {0} diff --git a/project/src/lib-lecode.h b/project/src/lib-lecode.h index 0793d6c..c2b6a81 100644 --- a/project/src/lib-lecode.h +++ b/project/src/lib-lecode.h @@ -62,6 +62,13 @@ #define LE_RESERVED_SLOTS (LE_FIRST_CT_SLOT - 32) #define LE_MAX_BLOCK_TRACK 50 +// [[time-limit]] +#define LE_DEF_ONLINE_SEC 340 // 5:40 : default online time limit +#define LE_MIN_ONLINE_SEC 30 // 0:30 : min accepted online time limit +#define LE_MAX_WD_ONLINE_SEC 525 // 8:45 : max online time limit for enabled watchdog +#define LE_MAX_ONLINE_SEC 0xffff // 18:12:15 : max possible online time limit +#define LE_VIEW_ONLINE_HMS 61 // 1:01 : min value when time is printed as additonal HMS + //----------------------------------------------------------------------------- // [[le_valid_t]] @@ -284,7 +291,6 @@ ccp PatchNameLEREG ( char *buf, uint bufsize, ccp name, le_region_t lereg ); const mem_t GetLecodeLEREG ( le_region_t reg ); - //----------------------------------------------------------------------------- // some more global functions, used as helpers for *LEREG functions @@ -313,6 +319,10 @@ typedef struct le_lpar_t lpar_mode_t limit_mode; // limit of other params u16 thcloud_frames; // number of frames a player is small after thundercloud hit +// [[time-limit]] + u16 default_online_sec; // default time limit in seconds + u16 min_online_sec; // minimal time limit in seconds, that can be set by LEX:SET1 + u16 max_online_sec; // maximal time limit in seconds, that can be set by LEX:SET1 u8 cheat_mode; // 0:off, 1:debug only, 2:allow all u8 engine[3]; // 100cc, 150cc, mirror (sum always 100) @@ -933,12 +943,68 @@ typedef struct le_binpar_v1_26a_t } __attribute__ ((packed)) le_binpar_v1_26a_t; -_Static_assert(sizeof(le_binpar_v1_26a_t)==0x26a,"le_binpar_v1_26a_t"); +//----------------------------------------------------------------------------- +// [[le_binpar_v1_270_t]] + +typedef struct le_binpar_v1_270_t +{ + /*000*/ char magic[8]; // LE_PARAM_MAGIC + /*008*/ u32 version; // always 1 for v1 + /*00c*/ u32 size; // size (and minor version) + /*010*/ u32 off_eod; // offset of end-of-data + + /*014*/ u32 off_cup_par; // offset to cup param + /*018*/ u32 off_cup_track; // offset of cup-track list + /*01c*/ u32 off_cup_arena; // offset of cup-arena list + /*020*/ u32 off_course_par; // offset of course param + /*024*/ u32 off_property; // offset of property list + /*028*/ u32 off_music; // offset of music list + /*02c*/ u32 off_flags; // offset of flags + + /*030*/ u8 engine[3]; // 100cc, 150cc, mirror (sum always 100) + /*033*/ u8 enable_200cc; // TRUE: 200C enabled => 150cc, 200cc, mirror + /*034*/ u8 enable_perfmon; // >0: performance monitor enabled; >1: for dolphin too + /*035*/ u8 enable_custom_tt; // TRUE: time trial for cusotm tracks enabled + /*036*/ u8 enable_xpflags; // TRUE: extended presence flags enabled + /*037*/ u8 block_track; // block used track for 0.. tracks + /*038*/ u16 chat_mode_1[BMG_N_CHAT]; // mode for each chat message + /*0f8*/ u16 chat_mode_2[BMG_N_CHAT]; // mode for each chat message + /*1b8*/ u8 enable_speedo; // speedometer selection (0..2), see SPEEDO_* + /*1b9*/ u8 no_speedo_if_debug; // if bit is set: suppress speedometer + /*1ba*/ u8 debug_mode; // debug mode (0..), see DEBUGMD_* + /*1bb*/ u8 item_cheat; // 0:disabled, 1:enabled + + /*1bc*/ u8 debug_predef[LEDEB__N_CONFIG]; + // information about used predefined mode + /*1c0*/ u32 debug[LEDEB__N_CONFIG][LEDEB__N_LINE]; + // debug line settings, see LEDEB_* + + /*260*/ u8 cheat_mode; // 0:off, 1:debug only, 2:allow all + /*261*/ u8 drag_blue_shell; // >0: allow dragging of blue shell + /*262*/ u16 thcloud_frames; // number of frames a player is small after thundercloud hit + + /*264*/ u8 bt_worldwide; // >0: enable worldwide battles + /*265*/ u8 vs_worldwide; // >0: enable worldwide versus races + /*266*/ u8 bt_textures; // &1: enable texture hacks for battles, &2:alternable + /*267*/ u8 vs_textures; // &1: enable texture hacks for versus, &2:alternable + /*268*/ u8 block_textures; // >0: enable blocking of recent texture hacks + /*269*/ u8 staticr_points; // >0: use points definied by StaticR.rel + +// [[time-limit]] + /*26a*/ u16 default_online_sec; // default time limit in seconds + /*26c*/ u16 min_online_sec; // minimal time limit in seconds, that can be set by LEX:SET1 + /*26e*/ u16 max_online_sec; // maximal time limit in seconds, that can be set by LEX:SET1 + + /*270*/ +} +__attribute__ ((packed)) le_binpar_v1_270_t; + +_Static_assert(sizeof(le_binpar_v1_270_t)==0x270,"le_binpar_v1_270_t"); //----------------------------------------------------------------------------- // [[le_binpar_v1_t]] [[new-lpar]] -typedef struct le_binpar_v1_26a_t le_binpar_v1_t; +typedef struct le_binpar_v1_270_t le_binpar_v1_t; // /////////////////////////////////////////////////////////////////////////////// diff --git a/project/src/lib-lex.c b/project/src/lib-lex.c index 0a37bfe..a786477 100644 --- a/project/src/lib-lex.c +++ b/project/src/lib-lex.c @@ -161,7 +161,9 @@ static const feature_var_t lex_section_list[] = DEF_VAR( 0,HAVELEXS_SET1, lex_sect_set1, "LEX section SET1" ), DEF_VAR( 0,HAVELEXS_CANN, lex_sect_cann, "LEX section CANN" ), DEF_VAR( 0,HAVELEXS_HIPT, lex_sect_hipt, "LEX section HIPT" ), + DEF_VAR( 0,HAVELEXS_RITP, lex_sect_ritp, "LEX section RITP" ), + // [[new-lex-sect]] {0,0,0,0,0} }; @@ -174,6 +176,10 @@ static const feature_var_t lex_feature_list[] = DEF_VAR( 0,HAVELEXF_CANNON, lex_cannon, "LEX: Alternative cannon settings" ), DEF_VAR( 0,HAVELEXF_HIDE_POS, lex_hide_pos, "LEX: Hide position tracker conditionally" ), DEF_VAR( 0,HAVELEXF_START_ITEM, lex_start_item, "LEX: Player can get item before start of race." ), + DEF_VAR( 0,HAVELEXF_APPLY_OTL, lex_apply_otl, "LEX: Track applies alternative online time limit." ), + DEF_VAR( 0,HAVELEXF_RND_ITPH, lex_rnd_itph, "LEX: Random next links @KMP:ITPH." ), + + // [[new-lex-sect]] {0,0,0,0,0} }; @@ -566,12 +572,17 @@ const features_szs_t * GetFeaturesModes() m.lex_sect_set1 = FZM_GAMEPLAY | FZM_M_TYPE | FZM_ONLINE | FZM_SECTION; m.lex_sect_cann = FZM_GAMEPLAY | FZM_M_TYPE | FZM_M_WHERE | FZM_SECTION; m.lex_sect_hipt = FZM_VISUAL | FZM_M_TYPE | no_timetrial | FZM_SECTION; + m.lex_sect_ritp = FZM_GAMEPLAY | FZM_M_TYPE | no_timetrial | FZM_SECTION; + + // [[new-lex-sect]] m.lex_test_active = FZM_VISUAL | FZM_GAMEPLAY | FZM_M_TYPE | no_timetrial; m.lex_item_range = FZM_GAMEPLAY | FZM_M_TYPE | FZM_ONLINE; m.lex_cannon = FZM_GAMEPLAY | FZM_M_TYPE | FZM_M_WHERE; m.lex_hide_pos = FZM_VISUAL | FZM_M_TYPE | no_timetrial; m.lex_start_item = FZM_GAMEPLAY | FZM_M_TYPE | FZM_ONLINE; + m.lex_apply_otl = FZM_GAMEPLAY | FZM_M_TYPE | FZM_ONLINE; + m.lex_rnd_itph = FZM_GAMEPLAY | FZM_M_TYPE | no_timetrial; #if CHECK_FEATURES uint err_count = 0; @@ -797,6 +808,7 @@ lex_element_t * FindLexElement ( lex_header_t *head, uint data_size, u32 magic ) typedef void (*FixElementFunc) ( lex_t * lex, lex_item_t * item ); /////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// static void FixLEXElement_SET1 ( lex_set1_t *set1 ) { @@ -811,6 +823,12 @@ static void FixLEXElement_SET1 ( lex_set1_t *set1 ) } set1->start_item = set1->start_item > 0; + +// [[time-limit]] + set1->apply_online_sec = htons(MINMAX0( ntohs(set1->apply_online_sec), + LE_MIN_ONLINE_SEC, LE_MAX_ONLINE_SEC )); + + // [[new-lex-set1]] } //----------------------------------------------------------------------------- @@ -830,7 +848,6 @@ static void FixLEXItem_SET1 } //----------------------------------------------------------------------------- -// [[+]] static void ClearLEXElement_SET1 ( lex_set1_t *set1 ) { @@ -840,7 +857,6 @@ static void ClearLEXElement_SET1 ( lex_set1_t *set1 ) } //----------------------------------------------------------------------------- -// [[+]] static bool IsActiveLEXElement_SET1 ( const lex_set1_t *set1 ) { @@ -853,7 +869,11 @@ static bool IsActiveLEXElement_SET1 ( const lex_set1_t *set1 ) /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -// [[+]] + +// [[new-lex-sect]] upto 4 functions, see SET1 above + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// static void FixLEXElement_TEST ( lex_test_t *lt ) { @@ -884,7 +904,6 @@ static void FixLEXElement_TEST ( lex_test_t *lt ) } //----------------------------------------------------------------------------- -// [[+]] static void FixLEXItem_TEST ( @@ -901,7 +920,6 @@ static void FixLEXItem_TEST } //----------------------------------------------------------------------------- -// [[+]] static void ClearLEXElement_TEST ( lex_test_t *lt ) { @@ -910,7 +928,6 @@ static void ClearLEXElement_TEST ( lex_test_t *lt ) } //----------------------------------------------------------------------------- -// [[+]] static bool IsActiveLEXElement_TEST ( const lex_test_t *lt ) { @@ -951,6 +968,7 @@ static uint GetLexSortOrder ( u32 magic ) case LEXS_FEAT: return 1; case LEXS_SET1: return 2; case LEXS_TEST: return 9; + // [[new-lex-sect]] default: return 5; } } @@ -975,7 +993,7 @@ static void UpdateHaveLex ( lex_t *lex ) && size >= have_lex_sect_info[j].min_size ) { have_sect |= 1 << j; - have_feat |= GetLexFeatures(&(*ss)->elem); + have_feat |= GetLexFeatures(&(*ss)->elem,lex); break; } } @@ -1050,6 +1068,8 @@ static lex_item_t * AppendElementLEX size4 = ALIGN32(sizeof(lex_set1_t),4); break; + // [[new-lex-sect]] + case LEXS_TEST: if ( size4 < sizeof(lex_test_t) ) size4 = ALIGN32(sizeof(lex_test_t),4); @@ -1155,8 +1175,10 @@ static void SortItemsLEX /////////////// LEX features /////////////// /////////////////////////////////////////////////////////////////////////////// -static uint GetLexFeaturesSET1 ( const lex_element_t *elem ) +static uint GetLexFeaturesSET1 ( const lex_element_t *elem, lex_t *lex ) { + // if 'lex' not NULL: store additional data + uint have_feat = 0; const uint size = ntohl(elem->size); const lex_set1_t *set1 = (lex_set1_t*)elem->data; @@ -1175,6 +1197,20 @@ static uint GetLexFeaturesSET1 ( const lex_element_t *elem ) if ( size > offsetof(lex_set1_t,start_item) && set1->start_item ) have_feat |= 1 << HAVELEXF_START_ITEM; +// [[time-limit]] + if ( size > offsetof(lex_set1_t,apply_online_sec) ) + { + const uint apply_otl = ntohs(set1->apply_online_sec); + if (apply_otl) + { + have_feat |= 1 << HAVELEXF_APPLY_OTL; + if (lex) + lex->apply_otl = apply_otl; + } + } + + // [[new-lex-set1]] + return have_feat; } @@ -1197,6 +1233,14 @@ static uint GetLexFeaturesHIPT ( const lex_element_t *elem ) //----------------------------------------------------------------------------- +static uint GetLexFeaturesRITP ( const lex_element_t *elem ) +{ + return ntohl(elem->size) >= sizeof(lex_ritp_rule_t) + ? 1 << HAVELEXF_RND_ITPH : 0; +} + +//----------------------------------------------------------------------------- + static uint GetLexFeaturesTEST ( const lex_element_t *elem ) { DASSERT(elem); @@ -1206,14 +1250,18 @@ static uint GetLexFeaturesTEST ( const lex_element_t *elem ) //----------------------------------------------------------------------------- -uint GetLexFeatures ( const lex_element_t *elem ) +uint GetLexFeatures ( const lex_element_t *elem, lex_t *lex ) { + // if 'lex' not NULL: store additional data + switch(ntohl(elem->magic)) { - case LEXS_SET1: return GetLexFeaturesSET1(elem); + case LEXS_SET1: return GetLexFeaturesSET1(elem,lex); case LEXS_CANN: return GetLexFeaturesCANN(elem); case LEXS_HIPT: return GetLexFeaturesHIPT(elem); + case LEXS_RITP: return GetLexFeaturesRITP(elem); case LEXS_TEST: return GetLexFeaturesTEST(elem); + // [[new-lex-sect]] } return 0; } @@ -1227,7 +1275,9 @@ const have_lex_info_t have_lex_feat_info[HAVELEXF__N] = { HAVELEXF_CANNON, "cannon", 0 }, { HAVELEXF_HIDE_POS, "hipt", 0 }, { HAVELEXF_START_ITEM, "startitem", 0 }, - //--- add new sections here (order is important) + { HAVELEXF_APPLY_OTL, "apply-otl", 0 }, + { HAVELEXF_RND_ITPH, "rnd-itph", 0 }, + //--- add new elements here (order is important) }; /////////////////////////////////////////////////////////////////////////////// @@ -1266,7 +1316,9 @@ const have_lex_info_t have_lex_sect_info[HAVELEXS__N] = { LEXS_TEST, "test", 1 }, // HAVELEXS_TEST { LEXS_HIPT, "hidepos", sizeof(lex_hipt_rule_t) }, // HAVELEXS_HIPT { LEXS_FEAT, "features", 2 }, // HAVELEXS_FEAT + { LEXS_RITP, "rnditph", sizeof(lex_ritp_rule_t) }, // HAVELEXS_RITP //--- add new sections here (order is important) + // [[new-lex-sect]] }; /////////////////////////////////////////////////////////////////////////////// @@ -1349,6 +1401,9 @@ void UpdateLEX ( lex_t * lex, bool add_missing, bool add_test ) //--- HIPT AppendHiptLEX(lex,false); + + //--- RITP + AppendRitpLEX(lex,false); } if (add_test) //--- TEST @@ -1387,14 +1442,21 @@ lex_item_t * AppendSet1LEX ( lex_t * lex, bool overwrite ) lex_item_t * AppendCannLEX ( lex_t * lex, bool overwrite ) { return AppendElementLEX( lex, LEXS_CANN, CannonDataLEX, - sizeof(CannonDataLEX), overwrite); + sizeof(CannonDataLEX), overwrite ); } //----------------------------------------------------------------------------- lex_item_t * AppendHiptLEX ( lex_t * lex, bool overwrite ) { - return AppendElementLEX( lex, LEXS_HIPT, 0, 0, overwrite); + return AppendElementLEX( lex, LEXS_HIPT, 0, 0, overwrite ); +} + +//----------------------------------------------------------------------------- + +lex_item_t * AppendRitpLEX ( lex_t * lex, bool overwrite ) +{ + return AppendElementLEX( lex, LEXS_RITP, 0, 0, overwrite ); } //----------------------------------------------------------------------------- @@ -1402,9 +1464,11 @@ lex_item_t * AppendHiptLEX ( lex_t * lex, bool overwrite ) lex_item_t * AppendTestLEX ( lex_t * lex, bool overwrite ) { return AppendElementLEX( lex, LEXS_TEST, TestDataLEX, - sizeof(TestDataLEX), overwrite); + sizeof(TestDataLEX), overwrite ); } +// [[new-lex-sect]] + /////////////////////////////////////////////////////////////////////////////// void DumpElementsLEX ( FILE *f, lex_t *lex, bool hexdump ) @@ -1604,7 +1668,10 @@ typedef enum lex_section_id LID_SETTINGS1, LID_CANNON, LID_HIDE_PT, + LID_RND_ITPH, LID_TEST, + + // [[new-lex-sect]] } lex_section_id; @@ -1623,8 +1690,10 @@ static const KeywordTab_t lex_section_name[] = { LID_SETTINGS1, "SET1", "Basic settings", 0 }, { LID_CANNON, "CANN", "Cannon settings", 0 }, { LID_HIDE_PT, "HIPT", "Hide position tracker", 0 }, + { LID_RND_ITPH, "RITP", "Random next-links @KMP:ITPH", 0 }, { LID_TEST, "TEST", "Test case", 0 }, + // [[new-lex-sect]] { 0,0,0,0 } }; @@ -1743,15 +1812,10 @@ static enumError ScanLEXElement_SET1 { { "ITEM-POS-FACTOR", SPM_FLOAT3_BE, &set1.item_factor }, { "START-ITEM", SPM_U8, &set1.start_item }, - - // renamed at 2021-05-12 - { "TEST1", SPM_U8, &set1.start_item }, // [[obsolete]] 2022 - { "TEST2", SPM_U8, &set1.test_0d }, // [[obsolete]] 2022 - { "TEST_0D", SPM_U8, &set1.test_0d }, - { "TEST3", SPM_U8, &set1.test_0e }, // [[obsolete]] 2022 - { "TEST_0E", SPM_U8, &set1.test_0e }, - { "TEST4", SPM_U8, &set1.test_0f }, // [[obsolete]] 2022 - { "TEST_0F", SPM_U8, &set1.test_0f }, + { "PADDING-0D", SPM_U8, &set1.padding_0d }, +// [[time-limit]] + { "APPLY-ONLINE-SEC", SPM_U16_BE, &set1.apply_online_sec }, + // [[new-lex-set1]] {0} }; @@ -1903,6 +1967,60 @@ static enumError ScanLEXElement_HIPT /////////////////////////////////////////////////////////////////////////////// +static enumError ScanLEXElement_RITP +( + lex_t * lex, // KMP data structure + ScanInfo_t * si // valid data +) +{ + DASSERT(lex); + DASSERT(si); + TRACE("ScanLEXElement_HIPT()\n"); + + + //--- setup data + + ScanParam_t ptab[] = + { + {0} + }; + + char fb_buf[1000]; + FastBuf_t *fb = InitializeFastBuf(fb_buf,sizeof(fb_buf)); + + + //--- main loop + + for(;;) + { + char ch = NextCharSI(si,true); + if ( !ch || ch == '[' ) + break; + + if ( ch == '@' ) + { + ScanParamSI(si,ptab); + continue; + } + + u8 num[sizeof(lex_ritp_rule_t)] = {0}; + ScanU8SI(si,num,sizeof(num)-1,false); + if (NextCharSI(si,false)) + ScanU8SI(si,num+sizeof(num)-1,1,false); + AppendFastBuf(fb,num,sizeof(num)); + CheckEolSI(si); + } + + AppendElementLEX(lex,LEXS_RITP,fb->buf,fb->ptr-fb->buf,true); + ResetFastBuf(fb); + + return ERR_OK; +} + +/////////////////////////////////////////////////////////////////////////////// +// [[new-lex-sect]] +/////////////////////////////////////////////////////////////////////////////// + static enumError ScanLEXElement_TEST ( lex_t * lex, // KMP data structure @@ -2045,11 +2163,17 @@ enumError ScanTextLEX err = ScanLEXElement_HIPT(lex,&si); break; + case LID_RND_ITPH: + err = ScanLEXElement_RITP(lex,&si); + break; + + // [[new-lex-sect]] + case LID_TEST: err = ScanLEXElement_TEST(lex,&si); break; - default: + default: err = ERROR0(ERR_WARNING,"Unknown section (ignored): %s\n",sect_name); break; } @@ -2273,7 +2397,7 @@ static enumError SaveTextLEX_FEAT DASSERT(item); const uint size = ntohl(item->elem.size); - noPRINT("SaveTextLEX_SET1(), size=%u\n",size); + noPRINT("SaveTextLEX_FEAT(), size=%u\n",size); DASSERT( size >= sizeof(lex_set1_t) ); if ( size < sizeof(features_szs_t)) return ERR_OK; @@ -2288,7 +2412,7 @@ static enumError SaveTextLEX_FEAT ps.force_case = LOUP_UPPER; int comments = -1; - if (!brief_count) + if ( !brief_count && !export_count ) { comments = 1; ps.ena_empty = true; @@ -2308,7 +2432,7 @@ static enumError SaveTextLEX_FEAT u8 *ptr = item->elem.data + sizeof(features_szs_t); if ( size >= 4 || !IsMemConst(ptr,size,0) ) { - fputs("\n# Hex dump for unknown settings:\n",f); + fputs("\r\n# Hex dump for unknown settings:\r\n",f); HexDump(f,0,sizeof(features_szs_t),5,16,ptr,size); } } @@ -2338,23 +2462,44 @@ static enumError SaveTextLEX_SET1 const u8 *data = item->elem.data; const lex_set1_t *set1 = (lex_set1_t*)data; - fprintf(f,text_lex_elem_set1_cr +// [[time-limit]] + const unsigned apply_online_sec = ntohs(set1->apply_online_sec); + if ( brief_count || export_count ) + fprintf(f, + "%s[SET1]\r\n\r\n" + "@ITEM-POS-FACTOR = v( %5.3f, %5.3f, %5.3f )\r\n" + "@START-ITEM = %u\r\n" + "@APPLY-ONLINE-SEC = %u%s\r\n" + "\r\n" + ,section_sep + ,bef4(&set1->item_factor.x) + ,bef4(&set1->item_factor.y) + ,bef4(&set1->item_factor.z) + ,set1->start_item + ,apply_online_sec ,PrintHMS(0,0,apply_online_sec,LE_VIEW_ONLINE_HMS," # ",0) + // [[new-lex-set1]] + ); + else + fprintf(f,text_lex_elem_set1_cr ,item->sort_order ,bef4(&set1->item_factor.x) ,bef4(&set1->item_factor.y) ,bef4(&set1->item_factor.z) ,set1->start_item + ,LE_MIN_ONLINE_SEC ,PrintHMS(0,0,LE_MIN_ONLINE_SEC,LE_VIEW_ONLINE_HMS," (",")") + ,LE_MAX_ONLINE_SEC ,PrintHMS(0,0,LE_MAX_ONLINE_SEC,LE_VIEW_ONLINE_HMS," (",")") + ,apply_online_sec ,PrintHMS(0,0,apply_online_sec,LE_VIEW_ONLINE_HMS," # ",0) + // [[new-lex-set1]] ); - if ( set1->test_0d || set1->test_0e || set1->test_0f ) + if ( set1->padding_0d ) fprintf(f,text_lex_elem_set1_develop_cr - ,set1->test_0d - ,set1->test_0e - ,set1->test_0f + ,set1->padding_0d ); + if ( size > sizeof(lex_set1_t) ) { - fputs("\n# Hex dump for unknown settings:\n",f); + fputs("\r\n# Hex dump for unknown settings:\r\n",f); HexDump(f,0,sizeof(lex_set1_t),5,16, item->elem.data + sizeof(lex_set1_t), size - sizeof(lex_set1_t) ); @@ -2415,8 +2560,8 @@ static enumError SaveTextLEX_HIPT const lex_hipt_rule_t *rule = (lex_hipt_rule_t*)item->elem.data; int n = ntohl(item->elem.size) / sizeof(*rule) ; - int i, last_lap = 1000; - for ( i = 0; i < n; i++, rule++ ) + int last_lap = 1000; + for ( int i = 0; i < n; i++, rule++ ) { if ( last_lap != rule->lap ) { @@ -2424,7 +2569,7 @@ static enumError SaveTextLEX_HIPT fputs("\r\n",f); } - fprintf(f,"%5u %4d %4u %4u %4u\r\n", + fprintf(f,"%6u %5d %4u %4u %4u\r\n", rule->cond, rule->lap, rule->from, rule->to, rule->mode ); } @@ -2433,6 +2578,73 @@ static enumError SaveTextLEX_HIPT /////////////////////////////////////////////////////////////////////////////// +static enumError SaveTextLEX_RITP +( + FILE * f, // file to write + const lex_t * lex, // pointer to valid LEX + lex_item_t * item // item to save +) +{ + DASSERT(f); + DASSERT(lex); + DASSERT(item); + + if ( brief_count || export_count ) + fprintf(f,"%s[RITP]\r\n\r\n",section_sep); + else + fprintf(f,text_lex_elem_ritp_cr,item->sort_order); + + const lex_ritp_rule_t *rule = (lex_ritp_rule_t*)item->elem.data; + int n = ntohl(item->elem.size) / sizeof(*rule) ; + if ( n <= 0 ) + return ERR_OK; + + fputs(text_lex_elem_ritp_tabhead_cr,f); + + + struct mode_t + { + u8 print_param; // 0:never, 1:if not null, 2:always + char name[7]; + }; + + static const struct mode_t mode_tab[] = + { + { 1, "OFF" }, + { 0, "START" }, + // [[new-ritp-mode]] + }; + _Static_assert( sizeof(mode_tab)/sizeof(*mode_tab) == RITP_MODE__N, "RITP_MODE__N" ); + + for ( int i = 0; i < n; i++, rule++ ) + { + bool print_param; + char name[20]; + if ( rule->mode < RITP_MODE__N ) + { + const struct mode_t *md = mode_tab + rule->mode; + print_param = md->print_param; + snprintf(name,sizeof(name),"RITP$%s",md->name); + } + else + { + print_param = 2; + snprintf(name,sizeof(name),"%4u",rule->mode); + } + + if ( print_param >= 2 || print_param == 1 && rule->param ) + fprintf(f,"%6u %3u %-9s %6u\r\n", + rule->index, rule->n_next, name, rule->param ); + else + fprintf(f,"%6u %3u %s\r\n", + rule->index, rule->n_next, name ); + } + + return ERR_OK; +} + +/////////////////////////////////////////////////////////////////////////////// + static enumError SaveTextLEX_TEST ( FILE * f, // file to write @@ -2481,7 +2693,7 @@ static enumError SaveTextLEX_TEST if ( size > sizeof(lex_test_t) ) { - fputs("\n# Hex dump for unknown settings:\n",f); + fputs("\r\n# Hex dump for unknown settings:\r\n",f); HexDump(f,0,sizeof(lex_test_t),5,16, item->elem.data + sizeof(lex_test_t), size - sizeof(lex_test_t) ); @@ -2492,6 +2704,33 @@ static enumError SaveTextLEX_TEST /////////////////////////////////////////////////////////////////////////////// +static enumError SaveTextLEX_HEXDUMP +( + FILE * f, // file to write + const lex_t * lex, // pointer to valid LEX + lex_item_t * item // item to save +) +{ + DASSERT(f); + DASSERT(lex); + DASSERT(item); + + const bool brief = brief_count || export_count; + const u32 magic = ntohl(item->elem.magic); + if (brief) + fprintf(f,"%s[HEXDUMP]\r\n@MAGIC = 0x%08x\r\n\r\n",section_sep,magic); + else + fprintf(f,text_lex_hexdump_cr, + item->sort_order, magic, PrintID(&item->elem.magic,4,0) ); + + HexDumpCRLF(f,0,0,5,16,item->elem.data,ntohl(item->elem.size)); + if (!brief) + fputs(text_lex_hexdump_sep_cr,f); + return ERR_OK; +} + +/////////////////////////////////////////////////////////////////////////////// + enumError SaveTextLEX ( const lex_t * lex, // pointer to valid LEX @@ -2533,7 +2772,7 @@ enumError SaveTextLEX fprintf(F.f, "%s[SETUP]\r\n\r\n" "TOOL = %s\r\n" - "SYSTEM2 = %s\r\n" + "SYSTEM = %s\r\n" "VERSION = %s\r\n" "REVISION = %u\r\n" "DATE = %s\r\n" @@ -2550,7 +2789,7 @@ enumError SaveTextLEX for ( i = 0; i < lex->item_used; i++ ) { lex_item_t *s = lex->item[i]; - const uint size = ntohl(s->elem.size); + const uint size = ntohl(s->elem.size) + 8; fprintf(F.f,"# %-4.4s %08x, 0x%04x bytes\r\n", PrintID(&s->elem.magic,4,0), s->elem.magic, size ); } @@ -2562,7 +2801,6 @@ enumError SaveTextLEX for ( i = 0; i < lex->item_used; i++ ) { lex_item_t *s = lex->item[i]; - const uint size = ntohl(s->elem.size); const u32 magic = ntohl(s->elem.magic); enumError err = ERR_OK; switch(magic) @@ -2571,14 +2809,11 @@ enumError SaveTextLEX case LEXS_SET1: err = SaveTextLEX_SET1(F.f,lex,s); break; case LEXS_CANN: err = SaveTextLEX_CANN(F.f,lex,s); break; case LEXS_HIPT: err = SaveTextLEX_HIPT(F.f,lex,s); break; + case LEXS_RITP: err = SaveTextLEX_RITP(F.f,lex,s); break; case LEXS_TEST: err = SaveTextLEX_TEST(F.f,lex,s); break; + // [[new-lex-sect]] - default: - hexdump_eol = "\r\n"; - fprintf(F.f,text_lex_hexdump_cr, - s->sort_order, magic, PrintID(&s->elem.magic,4,0) ); - HexDump(F.f,0,0,5,16,s->elem.data,size); - break; + default: err = SaveTextLEX_HEXDUMP(F.f,lex,s); break; } if ( max_err < err ) @@ -2765,7 +3000,7 @@ void SetupLexInfo ( lex_info_t *info, const lex_t *lex ) if (lex) { - info->lex_found = true; + info->lex_found = true; info->have_sect = lex->have_sect; info->have_feat = lex->have_feat; @@ -2774,9 +3009,10 @@ void SetupLexInfo ( lex_info_t *info, const lex_t *lex ) if (item) { info->set1_found = true; - memcpy(&info->set1,item->elem.data,sizeof(info->set1)); - bef4n(info->set1.item_factor.v,info->set1.item_factor.v,3); - memcpy(&info->item_factor,&info->set1.item_factor,sizeof(info->item_factor)); + memcpy( &info->set1, item->elem.data, sizeof(info->set1) ); + // copy from info to info is correct, because of memcpy() above + bef4n( info->set1.item_factor.v, info->set1.item_factor.v, 3 ); + memcpy( &info->item_factor, &info->set1.item_factor, sizeof(info->item_factor) ); } item = FindElementLEX(lex,LEXS_TEST); @@ -2785,6 +3021,8 @@ void SetupLexInfo ( lex_info_t *info, const lex_t *lex ) info->test_found = true; memcpy(&info->test,item->elem.data,sizeof(info->test)); } + + // [[new-lex-sect]] } } @@ -2966,6 +3204,7 @@ bool PatchLEX ( lex_t * lex, const szs_have_t *have ) } + // [[new-lex-sect]] //--- section FEAT @@ -3029,6 +3268,12 @@ bool PurgeLEX ( lex_t * lex ) remove = size < sizeof(lex_hipt_rule_t); break; + case LEXS_RITP: + remove = size < sizeof(lex_ritp_rule_t); + break; + + // [[new-lex-sect]] + case LEXS_TEST: remove = !IsActiveLEXElement_TEST((lex_test_t*)data); break; diff --git a/project/src/lib-lex.h b/project/src/lib-lex.h index bd25b1e..17b5a92 100644 --- a/project/src/lib-lex.h +++ b/project/src/lib-lex.h @@ -109,6 +109,14 @@ typedef struct features_szs_t u8 lex_hide_pos; // HAVELEXF_HIDE_POS u8 lex_start_item; // HAVELEXF_START_ITEM + //--- since v2.35a + + u8 lex_apply_otl; // HAVELEXF_APPLY_OTL + u8 lex_sect_ritp; // HAVELEXS_RIPT + u8 lex_rnd_itph; // HAVELEXF_RND_ITPH + + // [[new-lex-sect]] + //--- new files and features will be appended here } __attribute__ ((packed)) features_szs_t; @@ -241,6 +249,8 @@ typedef enum have_lex_sect_t HAVELEXS_TEST, HAVELEXS_HIPT, HAVELEXS_FEAT, + HAVELEXS_RITP, + // [[new-lex-sect]] //--- add new elements here (order is important) HAVELEXS__N } @@ -257,6 +267,9 @@ typedef enum have_lex_feat_t HAVELEXF_CANNON, HAVELEXF_HIDE_POS, HAVELEXF_START_ITEM, + HAVELEXF_APPLY_OTL, + HAVELEXF_RND_ITPH, + // [[new-lex-sect]] //--- add new elements here (order is important) HAVELEXF__N } @@ -274,7 +287,10 @@ typedef enum lex_stream_id LEXS_SET1 = 0x53455431, // "SET1" primary settings LEXS_CANN = 0x43414e4e, // "CANN" cannon settings LEXS_HIPT = 0x48495054, // "HIPT" hide position tracker + LEXS_RITP = 0x52495450, // "RITP" random next links @KMP:ITPH LEXS_TEST = 0x54455354, // "TEST" settings for tests + + // [[new-lex-sect]] } lex_stream_id; @@ -323,9 +339,9 @@ typedef struct lex_set1_t { /*00*/ float3 item_factor; // factor for item positions, always >=1.0 /*0c*/ u8 start_item; // 1: player can get an item before start (hint only) - /*0d*/ u8 test_0d; // reserved - /*0e*/ u8 test_0e; // reserved - /*0f*/ u8 test_0f; // reserved + /*0d*/ u8 padding_0d; // padding_0d + /*0e*/ u16 apply_online_sec; // >0: wanted time limit if playing online + // [[new-lex-set1]] } __attribute__ ((packed,aligned(4))) lex_set1_t; @@ -343,6 +359,31 @@ typedef struct lex_hipt_rule_t __attribute__ ((packed)) lex_hipt_rule_t; //----------------------------------------------------------------------------- +// [[lex_hipt_rule_t]] + +typedef enum lex_ritp_mode_t +{ + RITP_MODE_OFF, // ignore this element + RITP_MODE_START, // shuffle once after reading KMP + // [[new-ritp-mode]] >>> keep order! + RITP_MODE__N +} +__attribute__((packed)) lex_ritp_mode_t; + +//--------------- + +typedef struct lex_ritp_rule_t +{ + u8 index; // index into section KMP/ITPH + u8 n_next; // number of next elements to shuffle (2..6) + lex_ritp_mode_t mode; // shuffle mode + u8 param; // additional parameter for some modes +} +__attribute__((packed)) lex_ritp_rule_t; + +//----------------------------------------------------------------------------- +// [[new-lex-sect]] +//----------------------------------------------------------------------------- // [[lex_test_t]] typedef struct lex_test_t @@ -408,6 +449,7 @@ typedef struct lex_t lex_item_t **item; // NULL or item list (alloced) uint have_sect; // bit field for found lex sections uint have_feat; // bit field for found lex features + uint apply_otl; // >0: applied online time limit //--- parser helpers @@ -436,6 +478,7 @@ lex_item_t * AppendFeatLEX ( lex_t * lex, bool overwrite, const features_szs_t * 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 * AppendRitpLEX ( lex_t * lex, bool overwrite ); lex_item_t * AppendTestLEX ( lex_t * lex, bool overwrite ); const VarMap_t * SetupVarsLEX(); @@ -447,7 +490,8 @@ ccp CreateSectionInfoLEX ccp CreateFeatureInfoLEX ( have_lex_feat_t special, bool add_value, ccp return_if_empty ); -uint GetLexFeatures ( const lex_element_t *elem ); +// if 'lex' not NULL: store additional data +uint GetLexFeatures ( const lex_element_t *elem, lex_t *lex ); static inline bool IsLexFF ( file_format_t fform ) { return fform == FF_LEX || fform == FF_LEX_TXT; } @@ -552,6 +596,8 @@ typedef struct lex_info_t // data float3 item_factor; // 1.0 or copy of set1.item_factor + + // [[new-lex-sect]] [[new-lex-set1]] } lex_info_t; diff --git a/project/src/lib-mdl.c b/project/src/lib-mdl.c index 7056033..831e336 100644 --- a/project/src/lib-mdl.c +++ b/project/src/lib-mdl.c @@ -2505,7 +2505,7 @@ enumError SaveTextMDL fprintf(F.f, "%s[SETUP]\r\n\r\n" "TOOL = %s\r\n" - "SYSTEM2 = %s\r\n" + "SYSTEM = %s\r\n" "VERSION = %s\r\n" "REVISION = %u\r\n" "DATE = %s\r\n" diff --git a/project/src/lib-numeric.c b/project/src/lib-numeric.c index 0e4349e..2da7ed5 100644 --- a/project/src/lib-numeric.c +++ b/project/src/lib-numeric.c @@ -1806,7 +1806,6 @@ void PrintNameIL /////////////// color conversions /////////////// /////////////////////////////////////////////////////////////////////////////// - int ScanOptCmprDefault ( ccp arg ) { DASSERT( opt_cmpr_def[4] == 0xff ); @@ -2010,41 +2009,6 @@ const u8 cc86[256] = // convert 8-bit color to 6-bit color // /////////////////////////////////////////////////////////////////////////////// -/////////////// misc /////////////// -/////////////////////////////////////////////////////////////////////////////// - -ccp GetIntModeName ( IntMode_t mode ) -{ - switch(mode) - { - case IMD_UNSET: return "-"; - - case IMD_BE0: return "BE"; - case IMD_BE1: return "BE1"; - case IMD_BE2: return "BE2"; - case IMD_BE3: return "BE3"; - case IMD_BE4: return "BE4"; - case IMD_BE5: return "BE5"; - case IMD_BE6: return "BE6"; - case IMD_BE7: return "BE7"; - case IMD_BE8: return "BE8"; - - case IMD_LE0: return "LE"; - case IMD_LE1: return "LE1"; - case IMD_LE2: return "LE2"; - case IMD_LE3: return "LE3"; - case IMD_LE4: return "LE4"; - case IMD_LE5: return "LE5"; - case IMD_LE6: return "LE6"; - case IMD_LE7: return "LE7"; - case IMD_LE8: return "LE8"; - - default: return "?"; - } -} - -// -/////////////////////////////////////////////////////////////////////////////// /////////////// END /////////////// /////////////////////////////////////////////////////////////////////////////// diff --git a/project/src/lib-parser-func.c b/project/src/lib-parser-func.c index 005b93e..6d84be2 100644 --- a/project/src/lib-parser-func.c +++ b/project/src/lib-parser-func.c @@ -234,6 +234,10 @@ void DefineMkwVars ( VarMap_t * vm ) { "LEX$EN_150M", LEX_ENGINE_150M }, { "LEX$EN_200M", LEX_ENGINE_200M }, + { "RITP$OFF", RITP_MODE_OFF }, + { "RITP$START", RITP_MODE_START }, + // [[new-ritp-mode]] + { "VEH$SMALL", CHATVEH_SMALL }, { "VEH$MEDIUM", CHATVEH_MEDIUM }, { "VEH$LARGE", CHATVEH_LARGE }, diff --git a/project/src/lib-pat.c b/project/src/lib-pat.c index 9c4424d..d549254 100644 --- a/project/src/lib-pat.c +++ b/project/src/lib-pat.c @@ -1907,7 +1907,7 @@ enumError SaveTextPAT fprintf(F.f, "%s[SETUP]\r\n\r\n" "TOOL = %s\r\n" - "SYSTEM2 = %s\r\n" + "SYSTEM = %s\r\n" "VERSION = %s\r\n" "REVISION = %u\r\n" "DATE = %s\r\n" diff --git a/project/src/lib-std.h b/project/src/lib-std.h index 66eddad..dfb4919 100644 --- a/project/src/lib-std.h +++ b/project/src/lib-std.h @@ -2191,8 +2191,8 @@ __attribute__ ((packed)) mkw_prefix_flags_t; typedef struct mkw_prefix_t { - char prefix[8]; ccp info; // if NULL: list terminator + char prefix[12]; mkw_prefix_flags_t flags; u8 order; u8 color; diff --git a/project/src/lib-szs.h b/project/src/lib-szs.h index e00b64d..0f7fbdd 100644 --- a/project/src/lib-szs.h +++ b/project/src/lib-szs.h @@ -344,6 +344,7 @@ typedef struct szs_have_t kmp_special_t kmp; // u8-list: elem>0: number of special KMP objects found uint lex_sect; // bit field for found lex sections uint lex_feat; // bit field for found lex features + uint lex_apply_otl; // >0: applied online time limit have_attrib_t attrib; // bit field for special attributes } szs_have_t; diff --git a/project/src/prefix.inc b/project/src/prefix.inc index 96926a9..2c09c59 100644 --- a/project/src/prefix.inc +++ b/project/src/prefix.inc @@ -1,98 +1,105 @@ static const u8 prefix_inc_bz2[] = { - // decompressed size: 0xcb7 = 3255 bytes - 0x00,0x00,0x0c,0xb7, + // decompressed size: 0xe34 = 3636 bytes + 0x00,0x00,0x0e,0x34, // bzipped data - 0x42,0x5a,0x68,0x39, 0x31,0x41,0x59,0x26, 0x53,0x59,0x9e,0x05, 0xfa,0xfd,0x00,0x01, - 0xcc,0xdf,0x80,0x00, 0x12,0x61,0xef,0x7f, 0xf2,0x7f,0xef,0xdf, 0xf0,0xbf,0xff,0xff, - 0xf4,0x50,0x05,0x5e, 0xc6,0xf7,0x8d,0x6b, 0xb2,0x75,0xdb,0x6c, 0xdb,0xdd,0xe7,0x07, - 0x71,0xe1,0xa2,0x4d, 0x30,0x93,0x4c,0x98, 0x98,0x8c,0x9a,0x60, 0x49,0xea,0x69,0x93, - 0x50,0xf4,0xd1,0xa8, 0x7a,0x9a,0x68,0x00, 0xd3,0xd4,0x1a,0x26, 0x89,0xb4,0xd2,0x1a, - 0x4d,0xa9,0x3c,0x9a, 0x90,0xf4,0xd4,0xf5, 0x1a,0x0c,0x80,0x32, 0x34,0x00,0x69,0xb5, - 0x00,0x12,0x9a,0x11, 0x02,0x69,0x3d,0x21, 0x91,0x19,0xa8,0x1e, 0x90,0xd0,0x64,0x03, - 0x41,0x90,0xd3,0x4d, 0x0d,0x00,0x48,0x92, 0x8a,0x7e,0x99,0x4d, 0xe4,0x4a,0x3d,0x1e, - 0xa0,0xd3,0x28,0xf5, 0x34,0xc2,0x30,0x04, 0x34,0xc1,0x19,0x00, 0x69,0x84,0x8a,0x69, - 0x51,0xb6,0xa9,0x93, 0x40,0x03,0x6a,0x68, 0x00,0x03,0x20,0x03, 0x40,0x34,0x00,0x18, - 0x20,0x5f,0xc6,0x73, 0x40,0x0b,0xe3,0xab, 0x0e,0x8f,0x76,0x0b, 0x0b,0xdf,0xd6,0xac, - 0x12,0x96,0x1f,0xd8, 0x78,0xd3,0xa4,0xa2, 0x1b,0x06,0x52,0xcc, 0x95,0xe3,0xf2,0xcf, - 0x1a,0x7d,0x84,0x74, 0x8d,0x8c,0x38,0x22, 0xee,0xe9,0xe5,0xbd, 0x5d,0x89,0xa0,0x98, - 0xd5,0xd7,0x87,0xde, 0x02,0xf1,0x2b,0x75, 0xc9,0x9f,0xd9,0x29, 0xa9,0x00,0xe3,0x21, - 0x33,0x14,0x30,0xd6, 0x98,0x70,0xb5,0xa2, 0xc4,0x4e,0x31,0x53, 0x13,0x9d,0x55,0x6d, - 0xaa,0x02,0x75,0xd7, 0x75,0x61,0x4a,0x4a, 0xde,0x03,0x3b,0xd8, 0x59,0x9c,0xdd,0x80, - 0xdb,0x53,0x74,0xcc, 0xb3,0x48,0x60,0x3f, 0x10,0xc5,0x4f,0x58, 0xbf,0xb2,0xf2,0xb3, - 0x1f,0x52,0xd9,0x8e, 0x11,0x2c,0x36,0x55, 0x26,0x95,0x55,0x10, 0x85,0x43,0x6b,0xf2, - 0x5a,0x5f,0x11,0x21, 0xcb,0x9d,0x24,0x5f, 0xef,0x9b,0xc0,0x1f, 0xd0,0x9b,0x9b,0x84, - 0x22,0x3a,0xb9,0xce, 0x07,0xbc,0x06,0x0f, 0x6e,0x20,0x1f,0xb9, 0x09,0x04,0x77,0xe5, - 0x5a,0x2e,0x9e,0xe7, 0x56,0xa9,0x88,0x49, 0xf7,0x6a,0x04,0xab, 0x48,0xb1,0x59,0x67, - 0x65,0x75,0x85,0x4b, 0x97,0x90,0xb1,0x2d, 0x51,0x4d,0xb5,0xe6, 0x21,0x24,0xcc,0x86, - 0x66,0x0e,0xfc,0x19, 0xb1,0xce,0xea,0x21, 0x1c,0xd5,0x2b,0x04, 0x44,0x47,0xbd,0x04, - 0xc8,0x56,0x93,0xf0, 0x96,0x01,0x8a,0x79, 0xdd,0xac,0x42,0x00, 0x62,0xb5,0xe3,0xc7, - 0xc5,0xbe,0x6f,0x27, 0x59,0x74,0xee,0x0f, 0xa7,0x27,0x8d,0x18, 0x06,0x74,0x56,0x84, - 0x94,0xd5,0x1d,0x10, 0x39,0xf5,0xb0,0x2d, 0x35,0x89,0xda,0x6e, 0xab,0xc3,0x96,0xf4, - 0x77,0x6e,0xe9,0xb2, 0xad,0x61,0x72,0x12, 0x40,0x7f,0x9d,0x7e, 0x6a,0x12,0xac,0x66, - 0x3d,0x75,0xe4,0x43, 0x9a,0x5c,0xc9,0x49, 0x87,0x5d,0x47,0xa1, 0x90,0x80,0x8c,0x85, - 0xf3,0x06,0x08,0x86, 0x8b,0x16,0x1a,0x73, 0xa0,0xfe,0xee,0x45, 0xe1,0x19,0x49,0x86, - 0xa2,0x84,0x26,0x29, 0x4d,0xc8,0x64,0x41, 0xd5,0x02,0xc2,0x75, 0x2a,0xd8,0x47,0x6a, - 0x0e,0x0b,0x46,0x37, 0xda,0x13,0x73,0x18, 0x52,0xdd,0x68,0xcf, 0xb9,0x8c,0xa9,0x91, - 0x51,0x25,0x2f,0x96, 0x21,0x2a,0x23,0x2b, 0x30,0x4d,0x90,0xd0, 0x3c,0xd9,0xb5,0x67, - 0xc3,0x04,0x08,0x01, 0x08,0x64,0x93,0x55, 0x3a,0x65,0x79,0xa3, 0x6a,0x18,0xbe,0xbb, - 0xd0,0x00,0xb5,0x65, 0xae,0xf2,0x75,0xdc, 0x3a,0xd0,0x24,0xa5, 0x61,0x36,0xac,0xac, - 0x0e,0x05,0x73,0xe3, 0x18,0xf2,0x18,0x2f, 0x49,0x92,0xb3,0x71, 0xf9,0x30,0x69,0xf0, - 0x3e,0x00,0xc3,0x11, 0x11,0xcd,0x42,0x6e, 0xcd,0x1a,0x2f,0x99, 0x9f,0x5d,0xe1,0x9c, - 0x5b,0x8a,0x9f,0x97, 0x51,0x34,0xdc,0x5c, 0x38,0x6c,0x57,0xb1, 0x2c,0xee,0xfc,0x76, - 0x49,0x48,0x66,0x4c, 0x83,0x67,0x3c,0x40, 0x31,0x31,0x83,0x19, 0x28,0xcc,0xe4,0xdb, - 0x69,0x0d,0x9f,0x85, 0xee,0xba,0xd5,0x46, 0x5b,0x67,0x6e,0x0f, 0x1c,0x43,0x3b,0xc6, - 0x4c,0x2f,0xbc,0xc1, 0x91,0x87,0x99,0x3b, 0x8b,0x7e,0xf9,0xf4, 0x15,0xb8,0x2f,0x1b, - 0x38,0x31,0xe5,0x1e, 0xfe,0x4f,0x30,0x2b, 0xa2,0x8e,0xd1,0x92, 0x19,0x42,0x40,0x66, - 0x48,0x10,0x12,0x6a, 0xbb,0x2a,0x29,0x8e, 0xf5,0x20,0xb8,0x03, 0x6b,0xc0,0xcf,0xa4, - 0x6e,0x3e,0x73,0x6c, 0x48,0x12,0x2f,0xe2, 0x1c,0xa5,0x23,0x8c, 0x92,0x68,0xc0,0x37, - 0xbc,0xdb,0xd1,0x1e, 0xbd,0xa2,0xd5,0xcd, 0xd2,0x0a,0x4e,0x1d, 0x2f,0x44,0xea,0xe4, - 0x0f,0x5d,0xeb,0x2a, 0x88,0x88,0xaa,0xae, 0x40,0x10,0x8a,0x82, 0x71,0x50,0x50,0xac, - 0xb3,0x57,0x6f,0x51, 0x40,0xa6,0x73,0x40, 0xbf,0xd4,0x29,0x3d, 0xbe,0x22,0x92,0x5a, - 0x09,0x36,0xc0,0x07, 0xb9,0xcd,0x9a,0xa6, 0x4e,0x15,0xb6,0x08, 0x63,0x05,0x3e,0x0b, - 0x61,0x57,0x69,0x08, 0xa4,0x9c,0x52,0x51, 0x4c,0xad,0x86,0x9b, 0x34,0x63,0xcf,0x07, - 0x38,0x48,0x30,0xf1, 0x8b,0x00,0x4d,0xc9, 0xa8,0x29,0xbf,0x7d, 0x35,0xb1,0x72,0xed, - 0xcd,0xe0,0x2a,0xe2, 0xd5,0xc1,0x83,0x4c, 0x65,0xca,0x28,0x75, 0x04,0x42,0x13,0x27, - 0x3e,0xbb,0x53,0xab, 0xc3,0x41,0xeb,0x31, 0xbc,0x33,0x48,0xf3, 0x7d,0x67,0xbb,0x6d, - 0x39,0x96,0x40,0x5f, 0x19,0x49,0xf0,0xac, 0xa4,0x7b,0x2e,0xb4, 0x3f,0xbb,0x09,0x03, - 0x2d,0xc8,0x79,0x74, 0xaa,0xfb,0x24,0x28, 0x3a,0x28,0xc1,0x9c, 0x6c,0x43,0x49,0xad, - 0x22,0x2e,0x2d,0xd9, 0x93,0xb4,0x20,0xda, 0xb8,0x69,0xcc,0x6a, 0xa6,0x6c,0x35,0x2f, - 0x39,0x8a,0xe6,0xae, 0x56,0xf7,0x00,0x4a, 0x8a,0x85,0xe7,0x8d, 0xf0,0xab,0x8c,0x33, - 0x95,0xec,0xd5,0x40, 0x02,0x83,0x0a,0x59, 0x54,0x60,0x11,0x53, 0xb2,0x6d,0xb7,0x47, - 0x20,0x16,0xce,0xfc, 0xfd,0xd4,0xbc,0xcf, 0x48,0x2c,0x02,0xb6, 0xb8,0x11,0x71,0x93, - 0x89,0x44,0xc9,0xad, 0x0b,0xdd,0x71,0x3a, 0x10,0xdc,0x02,0x69, 0xe0,0x34,0x49,0xe5, - 0x6a,0x66,0x65,0x0b, 0xb9,0x13,0xd0,0x80, 0x23,0xd7,0x9b,0x02, 0xd1,0x46,0x74,0x51, - 0x19,0x40,0x38,0xe8, 0xc9,0x6f,0x3f,0x42, 0x48,0xda,0xd6,0xb4, 0x42,0x4e,0x3a,0xb3, - 0x38,0xf0,0x82,0x59, 0x29,0x76,0x07,0x66, 0x81,0x02,0xcf,0x85, 0x27,0x35,0x0a,0xbc, - 0x41,0x32,0x21,0xb5, 0x35,0x53,0x04,0x34, 0xd0,0x32,0xf7,0xe4, 0x95,0x2d,0xef,0xe5, - 0x4e,0xf9,0x49,0x69, 0x5f,0x0c,0x59,0x85, 0x76,0xb4,0xc9,0x53, 0x19,0x16,0x9d,0xe3, - 0x7e,0x0e,0x35,0x1b, 0x87,0x5a,0xc0,0x5c, 0x7b,0x6b,0xda,0x32, 0xec,0x37,0xa5,0x0b, - 0x82,0x0e,0xfe,0x46, 0x58,0x2b,0xb0,0xec, 0xcf,0x60,0x00,0x4c, 0x20,0x5d,0xf1,0x01, - 0x2c,0x03,0x68,0x5b, 0x1a,0x61,0x12,0x7b, 0x11,0x7c,0xb1,0xda, 0x4f,0x4d,0xcb,0x67, - 0x68,0xcd,0x3d,0xd1, 0xd2,0x94,0x8b,0xfe, 0x32,0xb4,0xa1,0x74, 0xea,0xdf,0x69,0x24, - 0xdd,0x67,0xa1,0xbc, 0x3b,0xc8,0x86,0xe2, 0x64,0x2c,0x2c,0x69, 0x03,0x66,0x14,0xd0, - 0x3a,0xe1,0x0b,0xb3, 0x4e,0xf3,0x8e,0xf6, 0xc2,0x2a,0x6e,0xbb, 0x71,0x70,0xde,0x34, - 0x9a,0x2e,0xbf,0x15, 0x4a,0xe9,0x7c,0xdc, 0x74,0x1f,0x5b,0xf2, 0xe3,0xab,0x59,0x50, - 0x32,0x55,0xf4,0x38, 0x14,0xbd,0xdb,0x5e, 0x89,0x04,0x6d,0xb4, 0xd9,0x7d,0x8d,0x19, - 0xad,0xb6,0xd9,0x57, 0x2a,0xc1,0x2e,0x41, 0x6c,0x8d,0x29,0x58, 0xea,0x50,0xf6,0x92, - 0xff,0xec,0x2f,0xaf, 0x27,0x2f,0x97,0x4d, 0x2b,0xe9,0xac,0x00, 0x47,0x85,0x69,0xc4, - 0x76,0xbf,0x1c,0xb7, 0x5a,0x63,0x65,0xc1, 0x4b,0x27,0x82,0x1b, 0x72,0x1d,0x7a,0xe8, - 0xc7,0x25,0x07,0xc3, 0x08,0x5d,0xbb,0x63, 0xcd,0x48,0x35,0xb2, 0xaa,0xb2,0x6e,0xb2, - 0x47,0xe9,0xf9,0xa1, 0x9b,0xfa,0xee,0x1d, 0x9d,0x4e,0x07,0x54, 0xb8,0xc7,0xed,0xdc, - 0x49,0x98,0x6e,0xb4, 0x12,0xa9,0x2e,0x91, 0x0e,0x9d,0x9d,0x24, 0xef,0xd6,0xff,0x8b, - 0x2a,0x0b,0x00,0x4e, 0xba,0x12,0x86,0xd0, 0x90,0x34,0x65,0xb4, 0x74,0x89,0x20,0xb3, - 0x0d,0x6e,0xf2,0x54, 0xaf,0x57,0x10,0x16, 0xf8,0x73,0xad,0x23, 0xc4,0xd5,0x91,0x1e, - 0x0c,0x6c,0x4f,0x86, 0x75,0xe2,0xea,0x2f, 0xdd,0x7f,0x4f,0x97, 0x95,0x34,0x53,0x05, - 0x2f,0x85,0x1d,0x76, 0x6c,0xcb,0x21,0xf5, 0x3c,0x1c,0x3f,0xe3, 0x22,0x0a,0x21,0x24, - 0x9a,0x16,0x8d,0x5b, 0xf9,0xd6,0xa0,0xbb, 0x2d,0xbd,0x68,0x46, 0x15,0x38,0x2a,0xba, - 0x29,0x17,0x6b,0x9e, 0x66,0xe8,0x4a,0xe1, 0xbd,0x54,0x66,0xbb, 0x2e,0x7e,0x08,0x4b, - 0xe2,0x8d,0x9d,0xb5, 0x01,0x56,0xb1,0xce, 0xaf,0x63,0x86,0x27, 0x30,0xc3,0x62,0x98, - 0xab,0x1d,0x6a,0xb9, 0x29,0x38,0xe3,0x8e, 0x38,0xc5,0xd8,0xcc, 0x61,0x8c,0x0a,0xb5, - 0xdd,0xbf,0x5c,0x39, 0x65,0x13,0x8e,0x23, 0x34,0xba,0x32,0x9c, 0x41,0xa3,0x2d,0x6c, - 0x44,0x37,0x9a,0xd8, 0x89,0xff,0x17,0x72, 0x45,0x38,0x50,0x90, 0x9e,0x05,0xfa,0xfd, - // 0x570 = 1392 data bytes (43%) + 0x42,0x5a,0x68,0x39, 0x31,0x41,0x59,0x26, 0x53,0x59,0xf9,0x95, 0x37,0xa2,0x00,0x01, + 0xfa,0xdf,0x80,0x00, 0x12,0x61,0xef,0x7f, 0xf2,0x7f,0xef,0xdf, 0xf0,0xbf,0xff,0xff, + 0xf4,0x50,0x05,0xde, 0xc6,0xce,0x74,0x24, 0x6e,0xee,0xdb,0x65, 0xa6,0x8d,0x0e,0xe0, + 0x34,0x42,0x9f,0xa1, 0x0a,0x6d,0x34,0xf4, 0x53,0x0d,0x31,0x06, 0x89,0xe9,0x0d,0x10, + 0xf2,0x1a,0x23,0x6a, 0x00,0x0d,0xa8,0x34, 0x20,0x1a,0x14,0xf4, 0x42,0x6d,0x22,0x7a, + 0x9f,0xa6,0xa9,0xea, 0x01,0xa0,0xd0,0x69, 0x90,0x64,0x1e,0xa1, 0xe5,0x00,0x24,0x44, + 0x40,0x8c,0x82,0x99, 0x82,0x35,0x0f,0x4d, 0x14,0xf4,0x4d,0x32, 0x03,0xd4,0x68,0x34, + 0x36,0xa6,0x9a,0x34, 0x07,0x19,0x32,0x69, 0xa6,0x13,0x23,0x20, 0x60,0x46,0x26,0x8c, + 0x11,0x84,0x1a,0x34, 0xc0,0x00,0x82,0x49, 0x35,0x28,0x7b,0x25, 0x0f,0x29,0xe9,0x34, + 0xf5,0x00,0x00,0x00, 0x32,0x64,0x61,0x01, 0xa0,0x00,0xc0,0x90, 0xbf,0x8b,0x4c,0x81, + 0x0b,0xe3,0xb7,0x25, 0x98,0xf1,0x1a,0xab, 0xdf,0xd6,0x7c,0x50, 0x86,0x4f,0xd7,0x69, + 0x4d,0x18,0x3b,0xb3, 0x09,0x88,0xd0,0x91, 0x68,0xe2,0xad,0x1b, 0x82,0x0d,0xe3,0x66, + 0xf1,0x30,0xbb,0x16, 0x0d,0x1c,0x18,0xbd, 0xfe,0xaa,0x5a,0x29, 0xa0,0x1b,0x04,0xc6, + 0x7b,0x5d,0xfa,0xfb, 0xbc,0x58,0x2d,0x79, 0x16,0x6d,0xe0,0xb4, 0x89,0x10,0x43,0x21, + 0x43,0x17,0x18,0x5a, 0x18,0x41,0x45,0x82, 0x90,0x08,0x63,0x49, 0x89,0xa4,0xf4,0xba, + 0x31,0xa6,0x96,0x02, 0x4a,0xd7,0xe1,0x75, 0xad,0x2c,0xdc,0x46, 0xbb,0x28,0x7d,0x35, + 0xd1,0x99,0xc6,0x57, 0xea,0x46,0x54,0xcb, 0x5b,0x1f,0x9c,0x7e, 0x49,0xd3,0x94,0x53, + 0x90,0x59,0xa3,0xf5, 0x29,0x35,0x70,0xde, 0xa4,0x84,0xc1,0xa5, 0x18,0xc9,0x3a,0xe3, + 0x5b,0x04,0xe9,0x4c, 0xa1,0xb2,0xea,0x92, 0x1a,0x8b,0xe2,0x20, 0x74,0x4e,0xc0,0x07, + 0xb7,0xce,0x22,0x1b, 0xd1,0x46,0xae,0xba, 0x4b,0x5b,0x38,0x2d, 0x86,0x10,0x9c,0x2e, + 0x5d,0xbf,0xca,0x10, 0xbc,0x80,0x44,0x2d, 0xaf,0x2d,0xca,0xe9, 0xe2,0xc3,0x61,0x38, + 0x81,0xbc,0x68,0x43, 0xc9,0x22,0x41,0x29, 0x77,0xc6,0x21,0x98, 0xaf,0x76,0x12,0x41, + 0x60,0xc4,0xd3,0xe5, 0xdd,0x1d,0x99,0x92, 0x61,0x02,0x39,0xcf, 0xb5,0xe3,0x96,0x88, + 0x73,0x2c,0xe8,0xb4, 0xb6,0x49,0x99,0x94, 0xaa,0x52,0x88,0x8a, 0x52,0x44,0x84,0x53, + 0xe8,0xfc,0x64,0x6c, 0x1b,0x69,0x02,0x2b, 0x5d,0xa7,0xa7,0x2e, 0xf9,0x36,0xf9,0xa2, + 0x61,0x46,0xaf,0x7f, 0x41,0x1b,0x34,0xc4, 0xea,0xce,0x1a,0x19, 0x65,0x4a,0x15,0xdb, + 0xb3,0x9d,0xd7,0xf6, 0xbc,0x30,0x43,0xea, 0x81,0x40,0x99,0x83, 0x86,0x4c,0x06,0x4c, + 0x42,0x26,0xd0,0x40, 0xe2,0xc6,0xa0,0xa7, 0x6e,0xe9,0xfd,0xa0, 0xf2,0x80,0xc1,0x8d, + 0xb0,0x7f,0x1e,0x5f, 0xb5,0x86,0xfb,0x4c, 0x9f,0x2e,0xcc,0xd1, 0x3a,0xe7,0x37,0x95, + 0x95,0xf0,0xb2,0x7f, 0x76,0x2d,0x09,0xa3, 0x76,0xd2,0xf3,0x59, 0xc3,0xb2,0xd2,0xf7, + 0xb8,0x87,0x4f,0x84, 0x94,0xc1,0x13,0xaa, 0x86,0x6d,0xa5,0x49, 0x68,0xad,0x7a,0x25, + 0x32,0x4f,0xe2,0x47, 0x7d,0x36,0xbb,0x15, 0xa4,0xf0,0x93,0x8d, 0xc0,0xb7,0xb4,0x26, + 0xf1,0x18,0x65,0xa3, 0x6c,0x72,0xef,0xce, 0x5a,0xc8,0xb4,0x95, 0x3e,0xdb,0x84,0xb2, + 0x4b,0xa1,0x94,0x58, 0xb2,0x1a,0x07,0xc7, 0x3e,0xcc,0xb3,0x66, 0x62,0x62,0x06,0x31, + 0x36,0xd5,0x8e,0x18, 0x3c,0x16,0xad,0x04, 0x89,0x5f,0x83,0x08, 0x00,0x7a,0xae,0xc5, + 0x43,0x83,0xb4,0xd4, 0x7e,0x18,0x19,0x27, 0x80,0xb7,0xea,0x70, 0x42,0x0e,0x07,0x57, + 0x31,0x61,0x91,0x18, 0x2e,0x93,0x28,0xaf, 0x34,0xfa,0x2e,0x59, 0xf1,0x3e,0x20,0xc2, + 0x80,0x01,0xd4,0x90, 0x8c,0xd7,0x6e,0xdc, 0x28,0x31,0xd6,0x6e, 0xaa,0x5a,0x39,0xb8, + 0x2a,0x44,0x54,0x9b, 0x8d,0x23,0x86,0xc0, 0xda,0xc0,0x3c,0xbb, 0x08,0xdb,0x96,0x79, + 0x52,0x33,0x5e,0xb4, 0xd9,0xe1,0x10,0x0c, 0x4c,0x62,0x63,0x26, 0x17,0x5b,0x96,0xdb, + 0x1b,0x10,0xd9,0xf1, 0x5f,0x31,0xaf,0x4f, 0x6b,0x34,0xb5,0xe6, 0xcf,0x8e,0xba,0x1b, + 0x8c,0xb7,0xb3,0x7e, 0x63,0x46,0x86,0x34, 0xd3,0x74,0x61,0xbb, 0xb3,0x0e,0x7f,0x82, + 0xcf,0xa6,0xde,0x17, 0xc1,0x83,0xdb,0x6f, 0x76,0xda,0x30,0xf2, 0x75,0x5c,0x71,0x6a, + 0x59,0xea,0x76,0x12, 0x0d,0x44,0xe3,0xa4, 0xf5,0xe7,0xd8,0x54, 0x45,0x8e,0x0a,0xb2, + 0xa7,0xd0,0x22,0x12, 0x76,0xa4,0x34,0xf0, 0x1b,0xcd,0xd2,0xd8, 0x91,0x9b,0xa2,0x22, + 0x5e,0x8f,0x20,0xba, 0x98,0x3c,0xa8,0xa0, 0x65,0xea,0x0f,0xf7, 0x9b,0xfd,0x55,0xfe, + 0xec,0x1a,0x9b,0x8f, 0xd6,0xfd,0x47,0x2d, 0x31,0x4d,0x79,0xb0, 0x02,0x2d,0x3f,0x62, + 0xa1,0x08,0x80,0x1b, 0x74,0x6a,0x04,0x42, 0x11,0x04,0x85,0x61, 0x62,0x7b,0xef,0xee, + 0xde,0x4e,0xb8,0x18, 0xa1,0xd1,0xa2,0x5f, 0xd6,0x12,0xb6,0x7c, 0xa2,0xe2,0x94,0x6e, + 0x17,0xe1,0xb8,0x0e, 0xc8,0x39,0xec,0xa5, 0x0e,0xb7,0xe4,0x43, 0x48,0xcc,0xe9,0xca, + 0xcb,0xa8,0xed,0xd0, 0xd3,0x4a,0xca,0x1d, 0xb4,0x2a,0xe9,0x47, 0xcc,0x74,0xb6,0x6e, + 0x8e,0x41,0x63,0x90, 0x60,0x31,0x11,0x80, 0xb1,0x9c,0x03,0xd2, 0x4c,0x2a,0xc2,0x3f, + 0xf1,0x92,0x97,0x37, 0x0e,0xdc,0x1c,0x08, 0xaa,0xde,0xf0,0xd1, 0x9b,0xc1,0x23,0x15, + 0xa8,0xe6,0x72,0x10, 0x2b,0x19,0x33,0x7e, 0x2c,0xf8,0xf8,0xec, 0x3a,0x4c,0x6e,0x0a, + 0xb2,0x07,0x83,0x74, 0x4f,0x2c,0x6d,0xcf, 0x19,0x01,0x9a,0x11, 0xbd,0xd2,0xbd,0x7d, + 0x18,0x60,0xf7,0xe5, 0x89,0xc2,0xbc,0xbb, 0x8b,0x73,0x8d,0x72, 0x64,0x56,0x13,0x77, + 0x47,0x6d,0x02,0xa4, 0x32,0xa2,0x35,0x0b, 0x01,0x0c,0x62,0xc3, 0x30,0x16,0x8f,0x08, + 0x1d,0x6c,0x14,0x4c, 0x30,0x26,0xbc,0x0b, 0x29,0x8b,0x2b,0xc9, 0xae,0xc6,0xd9,0x89, + 0x43,0x16,0x3d,0x13, 0x45,0xd6,0x01,0x22, 0x0c,0x35,0x3a,0x88, 0x74,0x06,0xe6,0x30, + 0xf1,0xe1,0x6b,0xab, 0xa4,0x01,0x49,0x96, 0x50,0xd7,0x10,0xb0, 0xc1,0x11,0x66,0xd9, + 0x8f,0x6d,0xb0,0x9c, 0x86,0xad,0xf8,0xef, 0xf9,0xf8,0xe1,0x77, 0xe5,0x97,0x60,0x72, + 0xbe,0x48,0xe6,0x35, 0x34,0x86,0x6d,0xa7, 0x9e,0x2d,0xf5,0x76, 0xaa,0x91,0x7f,0x72, + 0x53,0xc3,0xd0,0xd4, 0xce,0x1b,0x28,0xcc, 0x0c,0x9d,0x5c,0x99, 0xea,0x60,0x0c,0x69, + 0x47,0xcd,0x71,0x72, 0xc4,0x61,0x68,0x88, 0x49,0xc1,0x0e,0xcb, 0x06,0xd3,0xcf,0xee, + 0x62,0x99,0x48,0x84, 0x81,0x8d,0xc1,0x0c, 0xbb,0x22,0x25,0x85, 0x13,0x6a,0x90,0x0a, + 0x12,0x91,0x83,0xcb, 0x3d,0x69,0x9a,0xa5, 0x91,0x32,0x14,0x26, 0x5b,0x54,0x45,0xcc, + 0x48,0x69,0xa5,0xb1, 0x90,0x7b,0x3f,0xc8, 0x58,0x68,0xf4,0xad, 0x74,0xf5,0x98,0x47, + 0x0f,0xa4,0x2c,0xdc, 0x54,0x31,0xc7,0x30, 0x55,0x25,0x02,0x2c, 0xbd,0xc3,0x75,0xab, + 0x7a,0xbb,0x47,0x39, 0x00,0x6e,0x81,0x0e, 0xbc,0xfb,0x45,0xfd, 0x67,0x1f,0x48,0x0d, + 0x9c,0x76,0x4d,0xdd, 0x84,0xf8,0x19,0x4b, 0xb2,0xfd,0x2f,0x96, 0xce,0x42,0x0d,0xc4, + 0x01,0xe3,0x10,0x29, 0xa6,0xf1,0xc3,0x49, 0x75,0x73,0x84,0x4b, 0xa4,0x6f,0x9c,0x74, + 0x98,0xf3,0xd4,0xba, 0xf8,0x9d,0x38,0xf7, 0x8f,0x2c,0xb2,0x85, 0xbf,0xcf,0xe1,0x4d, + 0x26,0x83,0x56,0x57, 0x7a,0x5a,0x40,0x37, 0x81,0x63,0x75,0xf4, 0x22,0x1b,0x8c,0x82, + 0x15,0x58,0xd0,0x86, 0xca,0xa6,0x81,0xdf, 0x23,0x1f,0xcb,0x66, 0xe8,0x22,0x2e,0x96, + 0x58,0x0c,0xe9,0x6b, 0xbb,0xcd,0x80,0xa8, 0x67,0x92,0xd4,0xdc, 0xfd,0x49,0x4f,0x2b, + 0x82,0x64,0x9d,0x15, 0xc3,0x10,0xf0,0x42, 0xe3,0x7f,0x79,0x00, 0x0e,0x54,0x2c,0x6f, + 0x69,0x03,0x19,0xc9, 0xb0,0x52,0x2d,0x53, 0x9e,0xeb,0xae,0xa3, 0xbd,0xab,0x24,0x65, + 0x30,0x20,0xa1,0x7d, 0x45,0x56,0xee,0x87, 0x46,0x45,0xe5,0x22, 0xdf,0xf9,0x3c,0x2c, + 0xf5,0xcf,0xb3,0x8f, 0x4f,0x75,0xb5,0xfa, 0xad,0x91,0x04,0xd1, 0xf4,0xe2,0x42,0xc1, + 0x63,0xa7,0xa0,0xa3, 0x73,0xce,0xf4,0x56, 0xda,0x75,0x29,0x5e, 0x49,0x87,0xf6,0xd5, + 0x1e,0xba,0x91,0x9b, 0x34,0xbe,0x17,0x4f, 0x7d,0x64,0xe2,0x9d, 0x8e,0xda,0x5f,0x6d, + 0x08,0xf7,0xfe,0xac, 0x4b,0xc6,0x20,0x3f, 0x4f,0x18,0x4b,0xc4, 0x65,0x18,0x8f,0x94, + 0x40,0xda,0x10,0xd8, 0x36,0x82,0x7e,0x15, 0x9a,0x36,0xc6,0xe8, 0xd3,0x85,0x11,0x1f, + 0x08,0xfe,0x6d,0xb9, 0x16,0xa4,0x4d,0xad, 0x12,0x0e,0xcc,0x80, 0x43,0x22,0xb1,0x85, + 0x7c,0x40,0x88,0x50, 0x63,0x18,0xe3,0xb9, 0x15,0xd5,0xae,0xee, 0x14,0xf7,0xf1,0xce, + 0xc1,0xe2,0x69,0x22, 0xb8,0x39,0xf8,0x64, 0x1c,0xde,0xc5,0x6f, 0x52,0xad,0xed,0xb7, + 0xe5,0x3f,0x8d,0x39, 0x69,0xbf,0x4c,0x81, 0x0e,0xc8,0xf3,0xeb, 0x54,0x0f,0x99,0xda, + 0xb3,0xfe,0x3a,0x60, 0x80,0xa1,0xed,0x16, 0x47,0x51,0x56,0xee, 0x39,0xd0,0x3f,0x46, + 0x9b,0x5a,0xa5,0x6b, 0x70,0xad,0x82,0xbd, 0x50,0xa1,0x1d,0xa5, 0x9c,0x8d,0x03,0x1c, + 0x96,0xa5,0x38,0x16, 0x70,0xef,0xbe,0xb8, 0xc3,0x2d,0x0c,0xcd, 0xb3,0x6d,0x80,0x59, + 0x98,0x71,0xab,0xdc, 0xb3,0x18,0x8c,0x38, 0xdc,0x8e,0x4d,0x17, 0x9e,0x9e,0x08,0x97, + 0xae,0xba,0xeb,0xae, 0x9f,0xa9,0xf7,0x4b, 0x84,0x0a,0xab,0xd3, 0xb9,0x9f,0x09,0x8f, + 0x64,0x4e,0x37,0x40, 0x63,0x5d,0xf8,0xaf, 0x45,0x22,0x8d,0x51, 0xb8,0x4e,0x8b,0x51, + 0xb0,0xc3,0x91,0x7f, 0xf1,0x77,0x24,0x53, 0x85,0x09,0x0f,0x99, 0x53,0x7a,0x20, + // 0x5df = 1503 data bytes (41%) }; static BZ2Manager_t prefix_inc_mgr diff --git a/project/src/ui/tab-wlect.inc b/project/src/ui/tab-wlect.inc index 90cdd5d..c6b7251 100644 --- a/project/src/ui/tab-wlect.inc +++ b/project/src/ui/tab-wlect.inc @@ -422,7 +422,7 @@ { T_OPT_GP, "LT_RANDOM", "lt-random|ltrandom", "index", - "Force a random scenario, if between 1 and 8." + "Force a random scenario, if INDEX is between 1 and 8." " Value 0 enables auto selection and -1 disables this option." " If needed, LEX section TEST is created or removed if empty." }, diff --git a/project/src/ui/tab-wszst.inc b/project/src/ui/tab-wszst.inc index aa60a17..f1feaf0 100644 --- a/project/src/ui/tab-wszst.inc +++ b/project/src/ui/tab-wszst.inc @@ -1538,7 +1538,7 @@ { T_OPT_GP, "LT_RANDOM", "lt-random|ltrandom", "index", - "Force a random scenario, if between 1 and 8." + "Force a random scenario, if INDEX is between 1 and 8." " Value 0 enables auto selection and -1 disables this option." " Only track.szs files are modified." " If needed, file course.lex and section TEST" diff --git a/project/src/ui/ui-wlect.c b/project/src/ui/ui-wlect.c index a751fdd..551d201 100644 --- a/project/src/ui/ui-wlect.c +++ b/project/src/ui/ui-wlect.c @@ -604,9 +604,9 @@ static const InfoOption_t OptionInfo[OPT__N_TOTAL+1] = { OPT_LT_RANDOM, false, false, false, false, false, 0, "lt-random", "index", - "Force a random scenario, if between 1 and 8. Value 0 enables auto" - " selection and -1 disables this option. If needed, LEX section TEST" - " is created or removed if empty." + "Force a random scenario, if INDEX is between 1 and 8. Value 0 enables" + " auto selection and -1 disables this option. If needed, LEX section" + " TEST is created or removed if empty." }, { OPT_LEX_PURGE, false, false, false, false, false, 0, "lex-purge", diff --git a/project/src/ui/ui-wszst.c b/project/src/ui/ui-wszst.c index 8a813a4..da13aa2 100644 --- a/project/src/ui/ui-wszst.c +++ b/project/src/ui/ui-wszst.c @@ -1622,8 +1622,8 @@ static const InfoOption_t OptionInfo[OPT__N_TOTAL+1] = { OPT_LT_RANDOM, false, false, false, false, false, 0, "lt-random", "index", - "Force a random scenario, if between 1 and 8. Value 0 enables auto" - " selection and -1 disables this option. Only track.szs files are" + "Force a random scenario, if INDEX is between 1 and 8. Value 0 enables" + " auto selection and -1 disables this option. Only track.szs files are" " modified. If needed, file course.lex and section TEST are created or" " removed if empty." }, diff --git a/project/src/ui/ui.def b/project/src/ui/ui.def index 51bcbd5..fe9833c 100644 --- a/project/src/ui/ui.def +++ b/project/src/ui/ui.def @@ -1252,8 +1252,8 @@ #:def_opt( "LT_RANDOM", "lt-random|ltrandom", "GP", \ "index", \ - "Force a random scenario, if between 1 and 8. Value 0 enables auto" \ - " selection and -1 disables this option. Only track.szs files are" \ + "Force a random scenario, if INDEX is between 1 and 8. Value 0 enables" \ + " auto selection and -1 disables this option. Only track.szs files are" \ " modified. If needed, file course.lex and section TEST are created or" \ " removed if empty." ) @@ -20805,9 +20805,9 @@ #:def_opt( "LT_RANDOM", "lt-random|ltrandom", "GP", \ "index", \ - "Force a random scenario, if between 1 and 8. Value 0 enables auto" \ - " selection and -1 disables this option. If needed, LEX section TEST" \ - " is created or removed if empty." ) + "Force a random scenario, if INDEX is between 1 and 8. Value 0 enables" \ + " auto selection and -1 disables this option. If needed, LEX section" \ + " TEST is created or removed if empty." ) #:def_opt( "LEX_PURGE", "lex-purge|lexpurge", "G", \ "", \ diff --git a/project/src/wlect.c b/project/src/wlect.c index 832bee8..2441970 100644 --- a/project/src/wlect.c +++ b/project/src/wlect.c @@ -1004,7 +1004,7 @@ static enumError cmd_create() //--- data enum { C_HELP, - C_LEX, C_FEATURES, C_SET1, C_CANNON, C_HIDE_PT, C_TEST, + C_LEX, C_FEATURES, C_SET1, C_CANNON, C_HIDE_PT, C_RND_ITPH, C_TEST, C_LPAR, C_LEDEF, C_PREFIX, C_CATEGORY, C_LEINFO, }; @@ -1020,6 +1020,7 @@ static enumError cmd_create() { C_SET1, "SET1", 0, 0 }, { C_CANNON, "CANNONS", 0, 0 }, { C_HIDE_PT, "HIPT", 0, 0 }, + { C_RND_ITPH, "RITP ", 0, 0 }, { C_TEST, "TEST", 0, 0 }, { C_LPAR, "LPAR", 0, 0 }, @@ -1071,15 +1072,17 @@ static enumError cmd_create() case C_SET1: case C_CANNON: case C_HIDE_PT: + case C_RND_ITPH: { lex_t lex; InitializeLEX(&lex); switch (cmd->id) { - case C_FEATURES: AppendFeatLEX(&lex,false,0); break; - case C_SET1: AppendSet1LEX(&lex,false); break; - case C_CANNON: AppendCannLEX(&lex,false); break; - case C_HIDE_PT: AppendHiptLEX(&lex,false); break; + case C_FEATURES: AppendFeatLEX(&lex,false,0); break; + case C_SET1: AppendSet1LEX(&lex,false); break; + case C_CANNON: AppendCannLEX(&lex,false); break; + case C_HIDE_PT: AppendHiptLEX(&lex,false); break; + case C_RND_ITPH: AppendRitpLEX(&lex,false); break; } err = SaveTextLEX(&lex,opt_dest,false); ResetLEX(&lex); diff --git a/project/src/wszst.c b/project/src/wszst.c index 767583d..db45867 100644 --- a/project/src/wszst.c +++ b/project/src/wszst.c @@ -509,6 +509,8 @@ static const sizeof_info_t sizeof_info_szs_list[] = SIZEOF_INFO_ENTRY(lex_element_t) SIZEOF_INFO_ENTRY(lex_set1_t) SIZEOF_INFO_ENTRY(lex_hipt_rule_t) + SIZEOF_INFO_ENTRY(lex_ritp_rule_t) + // [[new-lex-sect]] SIZEOF_INFO_ENTRY(lex_test_t) SIZEOF_INFO_ENTRY(lex_item_t) SIZEOF_INFO_ENTRY(lex_t) diff --git a/project/src/wtest.c b/project/src/wtest.c index e66c89e..48a6af5 100644 --- a/project/src/wtest.c +++ b/project/src/wtest.c @@ -4298,6 +4298,137 @@ static enumError test_key_list ( int argc, char ** argv ) // /////////////////////////////////////////////////////////////////////////////// +/////////////// test_random() /////////////// +/////////////////////////////////////////////////////////////////////////////// +// test random generator for MKWFUN patcher (LE-CODE) + +unsigned sim_select_id = 0; // simulated select_id +unsigned dwc_gamedata = 1; // simulate always onlne + +/////////////////////////////////////////////////////////////////////////////// + +static unsigned GetSelectId(void) +{ + return sim_select_id; +} + +/////////////////////////////////////////////////////////////////////////////// +// Algorithm based on ideas by Donald E. Knuth + +static unsigned GetSyncRandom1 ( int max ) +{ + unsigned num; + + if (dwc_gamedata) // if online + { + // static vars + static unsigned last_select_id = 0; + static unsigned val_a = 0, val_c = 0, val_x = 0; + + const unsigned select_id = GetSelectId(); + if ( last_select_id != select_id || !val_a ) + { + // new select_id => calculate new seed + last_select_id = select_id; + + // rotate, because lower 16 may be 0 + const int n_shift = 21; + unsigned base = select_id >> n_shift | select_id << (32-n_shift); + base = base ^ ( select_id * 101 ); + + static unsigned val_a_tab[7] = + { + 0xbb40e62d, 0x3dc8f2f5, 0xdc024635, 0x7a5b6c8d, + 0x583feb95, 0x91e06dbd, 0xa7ec03f5, + }; + + val_a = val_a_tab[base%7]; + const u32 VAL_C_ADD = 2 * 197731421; // 2 * prime + val_c = ( (base & 15) + 1 ) * VAL_C_ADD + 1; // always odd + val_x = base; + } + + num = val_x = val_a * val_x + val_c; + } + else + { + // if offline => use standard random function + num = rand(); + } + + // If max>0 return a random (0..max( otherwise return a 32 bit random + return max <= 0 ? num : num % max; +} + +/////////////////////////////////////////////////////////////////////////////// + +static enumError test_random ( int argc, char ** argv ) +{ + if ( argc != 3 ) + { + fputs( "\n" + "Test random generator for MKWFUN patcher (LE-CODE)\n" + "\n" + "Syntax: 'wtest' 'random' SEED N\n" + "\n" + ,stdout); + return ERR_WARNING; + } + + sim_select_id = str2ul(argv[1],0,10); + uint n = str2ul(argv[2],0,10); + printf("\nselect_id = %u = 0x%08x\n\n",sim_select_id,sim_select_id); + + for ( uint i = 0; i < n; i++ ) + { + uint r = GetSyncRandom1(0); + printf("%6u. %11u = %08x\n",i,r,r); + } + + return ERR_OK; +} + +// +/////////////////////////////////////////////////////////////////////////////// +/////////////// test_hms() /////////////// +/////////////////////////////////////////////////////////////////////////////// + +static enumError test_hms ( int argc, char ** argv ) +{ + if ( argc < 2 ) + { + fputs( "\n" + "Test output of PrintHMS()\n" + "\n" + "Syntax: 'wtest' 'hms' [+min] value...\n" + "\n" + ,stdout); + return ERR_WARNING; + } + + int min = 30; + printf(">> min = %d%s\n",min,PrintHMS(0,0,min,60," (",")")); + + for ( int i = 1; i < argc; i++ ) + { + ccp arg = argv[i]; + if ( *arg == '+' ) + { + min = str2ul(arg,0,10); + printf(">> min = %d%s\n",min,PrintHMS(0,0,min,60," (",")")); + } + else + { + int val = str2ul(arg,0,10); + printf("val %s: %d%s\n",arg,val,PrintHMS(0,0,val,min," (",")")); + } + } + + return ERR_OK; +} + +// +/////////////////////////////////////////////////////////////////////////////// /////////////// develop() /////////////// /////////////////////////////////////////////////////////////////////////////// @@ -4604,6 +4735,8 @@ enum CMD_PF_EXPAND, // test_pf_expand(argc,argv) CMD_CODED_VERSION, // test_coded_version(argc,argv) CMD_KEY_LIST, // test_key_list(argc,argv) + CMD_RANDOM, // test_random(argc,argv) + CMD_HMS, // test_hms(argc,argv) #ifdef HAVE_WIIMM_EXT CMD_WIIMM, // test_wiimm(argc,argv) @@ -4683,6 +4816,8 @@ static const KeywordTab_t CommandTab[] = { CMD_PF_EXPAND, "PF-EXPAND", "PFE", 0 }, { CMD_CODED_VERSION, "CVERSION", "CV", 0 }, { CMD_KEY_LIST, "KEY-LIST", "KL", 0 }, + { CMD_RANDOM, "RANDOM", "RND", 0 }, + { CMD_HMS, "HMS", 0, 0 }, #ifdef HAVE_WIIMM_EXT { CMD_WIIMM, "WIIMM", "W", 0 }, @@ -4752,6 +4887,34 @@ int main ( int argc, char ** argv ) ADDRT_MIRROR_BEGIN, ADDRT_MIRROR_END, ADDRT__N, ADDRT__NN ); + if (0) // test MINMAX() and MINMAX0() + { + const int list[] = { -3, -1, 0, 5, 9 }; + const int n = sizeof(list)/sizeof(*list); + for ( int i = 0; i < n; i++ ) + { + putchar('\n'); + const int x = list[i]; + for ( int j = 0; j < n; j++ ) + { + const int y = list[j]; + for ( int k = 0; k < n; k++ ) + { + const int z = list[k]; + printf("%2d %2d %2d => %2d %2d\n",x,y,z,MINMAX(x,y,z),MINMAX0(x,y,z)); + } + } + } + + double3 d3; + double *d = d3.v; + printf("%zu/%zu=%zu\n",sizeof(d3.v),sizeof(*d),sizeof(d3.v)/sizeof(*d)); + + float3 f3; + float *f = f3.v; + printf("%zu/%zu=%zu\n",sizeof(f3.v),sizeof(*f),sizeof(f3.v)/sizeof(*f)); + } + if (0) { double3 d3; @@ -4862,6 +5025,8 @@ int main ( int argc, char ** argv ) case CMD_PF_EXPAND: test_pf_expand(argc,argv); break; case CMD_CODED_VERSION: test_coded_version(argc,argv); break; case CMD_KEY_LIST: test_key_list(argc,argv); break; + case CMD_RANDOM: test_random(argc,argv); break; + case CMD_HMS: test_hms(argc,argv); break; #ifdef HAVE_WIIMM_EXT case CMD_WIIMM: test_wiimm(argc,argv); break; |
