/* PERIODIC_FUNCTIONS.C symbols in this file: 000F9D90 0070: _periodic_functions_dispose (0000) 000F9E00 0130: _periodic_function_evaluate (0000) 000F9F30 0120: _transition_function_evaluate (0000) 000FA050 0100: _code_000fa050 (0000) 000FA150 0130: _code_000fa150 (0000) 000FA280 02b0: _code_000fa280 (0000) 000FA530 00c0: _periodic_functions_initialize (0000) 0027AC7C 000a: ??_C@_09PFNFPFNK@very?5late?$AA@ (0000) 0027AC88 0005: ??_C@_04KNPHFNKG@late?$AA@ (0000) 0027AC90 000b: ??_C@_0L@JFLLBJBL@very?5early?$AA@ (0000) 0027AC9C 0006: ??_C@_05MMFAAGKE@early?$AA@ (0000) 0027ACA4 0006: ??_C@_05GILPFPMI@spark?$AA@ (0000) 0027ACAC 0007: ??_C@_06EJKHKJBM@wander?$AA@ (0000) 0027ACB4 0007: ??_C@_06NJLEAOMD@jitter?$AA@ (0000) 0027ACBC 0018: ??_C@_0BI@LODCFJBP@slide?5?$CIvariable?5period?$CJ?$AA@ (0000) 0027ACD4 0006: ??_C@_05IODDPPOI@slide?$AA@ (0000) 0027ACDC 0020: ??_C@_0CA@POBCGHPD@diagonal?5wave?5?$CIvariable?5period?$CJ?$AA@ (0000) 0027ACFC 000e: ??_C@_0O@JLGDFEJA@diagonal?5wave?$AA@ (0000) 0027AD0C 0019: ??_C@_0BJ@LIPGHGNF@cosine?5?$CIvariable?5period?$CJ?$AA@ (0000) 0027AD28 0007: ??_C@_06IDPAJACI@cosine?$AA@ (0000) 0027AD30 0005: ??_C@_04DDFHDMOL@zero?$AA@ (0000) 0027AD38 0004: ??_C@_03OHDNLOHO@one?$AA@ (0000) 0027AD3C 0029: ??_C@_0CJ@OKNGCK@c?3?2halo?2SOURCE?2math?2periodic_fun@ (0000) 0027AD68 0004: __real@41cccccd (0000) 0027AD6C 003f: ??_C@_0DP@JEKDFHEF@function_type?$DO?$DN0?5?$CG?$CG?5function_typ@ (0000) 0027ADAC 0004: __real@447fc000 (0000) 0027ADB0 0041: ??_C@_0EB@CENGDIOD@function_type?$DO?$DN0?5?$CG?$CG?5function_typ@ (0000) 0027ADF4 0004: __real@3cce16a7 (0000) 0027ADF8 0004: __real@3d002d4f (0000) 0027ADFC 0004: __real@3d377812 (0000) 0027AE00 0008: __real@4000000000000000 (0000) 0027AE08 0008: __real@3fd0000000000000 (0000) 0027AE10 0004: __real@3a802008 (0000) 0027AE14 0004: __real@422fede0 (0000) 0027AE18 0004: __real@41c90fdb (0000) 0027AE1C 0004: __real@3f65c8fa (0000) 0027AE20 0004: __real@41e00000 (0000) 0027AE24 0004: __real@3cdfffff (0000) 0027AE28 001d: ??_C@_0BN@IGAJMLPO@?$CBfunction_tables_initialized?$AA@ (0000) 0030791C 0060: _data_0030791c (0000) _global_periodic_functions_enum (0030) _global_transition_functions_enum (0054) 004561BC 004c: _bss_004561bc (0000) */ /* ---------- headers */ #include "cseries.h" #include "periodic_functions.h" /* ---------- constants */ enum { _periodic_function_one = 0, _periodic_function_zero, _periodic_function_cosine, _periodic_function_cosine_variable_period, _periodic_function_diagonal_wave, _periodic_function_diagonal_wave_variable_period, _periodic_function_slide, _periodic_function_slide_variable_period, _periodic_function_noise, _periodic_function_jitter, _periodic_function_wander, _periodic_function_spark, NUMBER_OF_PERIODIC_FUNCTIONS, }; enum { PERIODIC_FUNCTION_TABLE_SIZE = 1024, PERIODIC_FUNCTION_TABLE_MASK = PERIODIC_FUNCTION_TABLE_SIZE-1, }; /* ---------- macros */ /* ---------- structures */ struct tag_enum_definition { long count; char **names; void *unused; }; struct periodic_functions_globals { boolean function_tables_initialized; byte pad[3]; byte *transition_function_tables[NUMBER_OF_TRANSITION_FUNCTIONS]; byte *periodic_function_tables[NUMBER_OF_PERIODIC_FUNCTIONS]; }; /* ---------- prototypes */ static void code_000fa050(real *values); static void code_000fa150(byte *table, short function_type); void code_000fa280(short function_type, byte *table); /* ---------- globals */ char *data_0030791c[NUMBER_OF_PERIODIC_FUNCTIONS] = { "one", "zero", "cosine", "cosine (variable period)", "diagonal wave", "diagonal wave (variable period)", "slide", "slide (variable period)", "noise", "jitter", "wander", "spark", }; struct tag_enum_definition global_periodic_functions_enum = { NUMBER_OF_PERIODIC_FUNCTIONS, data_0030791c, NULL, }; static char *transition_function_names[NUMBER_OF_TRANSITION_FUNCTIONS] = { "linear", "early", "very early", "late", "very late", "cosine", }; struct tag_enum_definition global_transition_functions_enum = { NUMBER_OF_TRANSITION_FUNCTIONS, transition_function_names, NULL, }; struct periodic_functions_globals bss_004561bc = { 0 }; /* ---------- public code */ void periodic_functions_dispose( void) { short function_index; if (bss_004561bc.function_tables_initialized) { for (function_index = 0; function_index < NUMBER_OF_PERIODIC_FUNCTIONS; function_index++) { match_free( "c:\\halo\\SOURCE\\math\\periodic_functions.c", 122, bss_004561bc.periodic_function_tables[function_index]); } for (function_index = 0; function_index < NUMBER_OF_TRANSITION_FUNCTIONS; function_index++) { match_free( "c:\\halo\\SOURCE\\math\\periodic_functions.c", 132, bss_004561bc.transition_function_tables[function_index]); } bss_004561bc.function_tables_initialized = FALSE; } return; } real periodic_function_evaluate( short function_type, real time) { long index; real fraction; real first_value; real second_value; real result; if (function_type == _periodic_function_one) return 1.0f; match_assert( "c:\\halo\\SOURCE\\math\\periodic_functions.c", 157, function_type>=0 && function_type 0.75f && second_value < 0.25f) { second_value += 1.0f; } result = first_value*(1.0f-fraction) + second_value*fraction; if (result > 1.0f) result -= 1.0f; return result; } real transition_function_evaluate( short function_type, real value) { short index; real fraction; real first_value; real second_value; if (value < 0.0f) value = 0.0f; else if (value > 1.0f) value = 1.0f; if (function_type == _transition_function_linear) return value; match_assert( "c:\\halo\\SOURCE\\math\\periodic_functions.c", 216, function_type>=0 && function_type