/* ** Blacksmith object constructor - not a single use object, but just use this class. */ t_adv_blacksmith::t_adv_blacksmith( std::string const& source ) : t_single_use_object( source ) { std::fill( &m_available_potions[0], &m_available_potions[ ELEMENTS_OF( m_available_potions ) ], k_artifact_none); std::fill( &m_available_items[0], &m_available_items[ ELEMENTS_OF( m_available_items ) ], k_artifact_none); std::fill( &m_available_long_items[0], &m_available_long_items[ ELEMENTS_OF( m_available_long_items ) ], k_artifact_none); }
int _bsp_get_edma_error_vectors(uint32_t dev_num, const uint32_t **vectors_ptr) { if (dev_num < ELEMENTS_OF(edma_error_vectors)) { *vectors_ptr = edma_error_vectors[dev_num]; return ELEMENTS_OF(edma_error_vectors[0]); } return 0; }
uint_32 _bsp_get_dspi_vectors(uint_32 dev_num, const uint_32 _PTR_ _PTR_ vectors_ptr) { if (dev_num < ELEMENTS_OF(dspi_vectors)) { *vectors_ptr = dspi_vectors[dev_num]; return ELEMENTS_OF(dspi_vectors[0]); } return 0; }
uint32_t _bsp_get_dspi_vectors(uint32_t dev_num, const uint32_t **vectors_ptr) { if (dev_num < ELEMENTS_OF(dspi_vectors)) { *vectors_ptr = dspi_vectors[dev_num]; return ELEMENTS_OF(dspi_vectors[0]); } else { return 0; } }
uint_32 _bsp_get_linflexd_vectors(uint_32 device, const uint_32 _PTR_ _PTR_ vectors_ptr) { if (device < ELEMENTS_OF(linflexd_vectors)) { *vectors_ptr = linflexd_vectors[device]; return ELEMENTS_OF(linflexd_vectors[0]); } else { return 0; } }
pointer _bsp_get_dspi_base_address(uint_8 dev_num) { if (dev_num < ELEMENTS_OF(dspi_address)) { return dspi_address[dev_num]; } return NULL; }
void *_bsp_get_dspi_base_address(uint8_t dev_num) { if (dev_num < ELEMENTS_OF(dspi_address)) { return (void *)dspi_address[dev_num]; } return NULL; }
uint_32 _bsp_get_adc_channel_mask(uint_32 device) { if (device < ELEMENTS_OF(adc_channel_mask)) { return adc_channel_mask[device]; } return 0; }
VPXADC_REG_STRUCT_PTR _bsp_get_adc_base_address(uint_32 device) { if (device < ELEMENTS_OF(adc_address)) { return ((VPXADC_REG_STRUCT_PTR) (adc_address[device])); } return NULL; }
SEMA4_MemMapPtr _bsp_get_sema4_base_address(uint_32 device) { if (device < ELEMENTS_OF(sema4_address)) { return (SEMA4_MemMapPtr) sema4_address[device]; } return NULL; }
pointer _bsp_get_flexcan_base_address(uint_8 channel) { if (channel < ELEMENTS_OF(flexcan_address)) { return flexcan_address[channel]; } return NULL; }
VLINFLEXD_REG_STRUCT_PTR _bsp_get_linflexd_base_address(uint_32 channel) { if (channel < ELEMENTS_OF(linflexd_address)) { return (VLINFLEXD_REG_STRUCT_PTR)linflexd_address[channel]; } return NULL; }
uint_32 _bsp_get_sema4_vector(uint_32 device) { if (device < ELEMENTS_OF(sema4_vector)) { return sema4_vector[device]; } return 0; }
/*FUNCTION********************************************************************** * * Function Name : _bsp_get_adc_base_address * Returned Value : pointer to base of ADC registers * Comments : * This function returns base address of ADC related register space. * *END***************************************************************************/ pointer _bsp_get_adc_base_address(uint_32 device_number) { /* Check if device number is correct */ if (device_number < ELEMENTS_OF(adc_address)) { return (pointer)adc_address[device_number]; } return NULL; }
void *_bsp_get_adc_base_address(uint8_t device_number) { /* Check if device number is correct */ if (device_number < ELEMENTS_OF(adc_address)) { return (void *)adc_address[device_number]; } return NULL; }
boolean _bsp_flexcan_enable_access(uint_32 device) { if (device < ELEMENTS_OF(flexcan_address)) { if (_psp_core_peripheral_enabled(flexcan_config[device])) { return _qpbridge_enable_access(flexcan_pbridge_id[device]); } } return FALSE; }
static void monitor_all_inputs(void) { LWADC_STRUCT_PTR lwadc_inputs; LWADC_VALUE_PTR last; LWADC_VALUE i,scaled, raw, delta, max_delta = 160; printf("Monitoring all inputs\n"); lwadc_inputs = (LWADC_STRUCT_PTR) _mem_alloc_zero(ELEMENTS_OF(adc_inputs)*sizeof(LWADC_STRUCT)); last = (LWADC_VALUE_PTR) _mem_alloc_zero(ELEMENTS_OF(adc_inputs)*sizeof(LWADC_VALUE)); if ((lwadc_inputs == NULL) || (last==NULL)) { printf("Error, Insufficient memory to run full test\n."); _task_block(); } for (i=0;i<ELEMENTS_OF(adc_inputs);i++) { /* Set last value to a value out of range of the ADC. */ last[i] = MAX_UINT_32; if ( !_lwadc_init_input(&lwadc_inputs[i],adc_inputs[i].input) ) { /* Failed to initialize this input. We will end up failing the reads below as well. */ printf("Failed to initialize ADC input %s\n",adc_inputs[i].name); } } printf("Monitoring ADC Inputs\n"); while (1) { for (i=0;i<ELEMENTS_OF(adc_inputs);i++) { /* This waits until a new conversion is read on the channel */ if (_lwadc_wait_next(&lwadc_inputs[i])) { if (_lwadc_read(&lwadc_inputs[i], &scaled) && _lwadc_read_raw(&lwadc_inputs[i], &raw)) { /* Obtained data, is the change significant enough to display? */ delta = (raw>last[i])?raw-last[i]:last[i]-raw; if (delta > max_delta) { printf("%-30s = %04x (%d mv)\n",adc_inputs[i].name, raw,scaled); last[i]=raw; } } } } } }
// ------------------------------------------------------------------------- // read a file id // ------------------------------------------------------------------------- static t_artifact_file read_file_id( std::string string ) { t_artifact_file result; for (result = t_artifact_file(0); result < ELEMENTS_OF( k_file_keywords ); enum_incr(result)) { if (stricmp( k_file_keywords[result], string.c_str() ) == 0) return result; } return k_artifact_file_none; }
// Return the colors needed for a given terrain type t_combat_grid_colors const & get_combat_grid_colors( t_terrain_type main_terrain_type, bool on_bridge ) { if ( !g_initialized ) initialize(); if ( on_bridge ) return k_bridge_colors; t_terrain_type basic_terrain = get_basic_terrain( main_terrain_type ); assert( basic_terrain >= 0 && basic_terrain < ELEMENTS_OF( k_terrain_colors ) ); if ( basic_terrain >= 0 && basic_terrain < ELEMENTS_OF( k_terrain_colors ) ) { return k_terrain_colors[ basic_terrain ]; } else { return k_terrain_colors[ 0 ]; } }
/*! * \cond DOXYGEN_PRIVATE * * \brief This function get base address. * * \param dev_num[in] LPT module. * * \return base address of LPT module. * */ void *lpt_get_base_address ( /* [IN] LPT index */ uint8_t dev_num ) { if (dev_num < ELEMENTS_OF(lpt_address)) { return (void *)lpt_address[dev_num]; } return NULL; }
/*! * \cond DOXYGEN_PRIVATE * * \brief This function performs BSP-specific initialization related to LPT * * \param dev_num[in] Number of LPT module. * * \return MQX_OK Success. */ _mqx_int lpt_io_init ( uint32_t dev_num ) { if (dev_num < ELEMENTS_OF(lpt_address)) { SIM_SCGC5 |= SIM_SCGC5_LPTIMER_MASK; return MQX_OK; } return MQX_INVALID_DEVICE; }
pointer _bsp_get_lpt_base_address ( /* [IN] LPT index */ uint_8 dev_num ) { if (dev_num < ELEMENTS_OF(lpt_address)) { return lpt_address[dev_num]; } return NULL; }
uint_32 _bsp_enable_lpt_clock ( /* [IN] LPT index */ uint_8 dev_num ) { if (dev_num < ELEMENTS_OF(lpt_address)) { SIM_SCGC5 |= SIM_SCGC5_LPTIMER_MASK; return MQX_OK; } return MQX_INVALID_DEVICE; }
// ------------------------------------------------------- // random tome // ------------------------------------------------------- void t_random_tome::place( t_adventure_map & map, t_adv_map_point const& point ) { static t_artifact_type const k_tomes[] = { k_artifact_tome_of_life, k_artifact_tome_of_order, k_artifact_tome_of_death, k_artifact_tome_of_chaos, k_artifact_tome_of_nature }; t_artifact_type type; t_counted_ptr<t_adv_artifact> artifact; type = map.get_random_artifact( k_tomes, ELEMENTS_OF( k_tomes )); artifact = new t_adv_artifact( type ); artifact->place( map, point ); };
uint_32 _bsp_get_lpt_vector ( /* [IN] LPT index */ uint_8 dev_num ) { if (dev_num < ELEMENTS_OF(lpt_vectors)) { return lpt_vectors[dev_num]; } else { return 0; } }
/*! * \cond DOXYGEN_PRIVATE * * \brief This function get Interrupt Number. * * \param dev_num[in] LPT module. * * \return Interrupt Number for LPT module. * */ uint32_t lpt_get_vector ( /* [IN] LPT index */ uint8_t dev_num ) { if (dev_num < ELEMENTS_OF(lpt_vectors)) { return lpt_vectors[dev_num]; } else { return 0; } }
// ------------------------------------------------------- // random staff // ------------------------------------------------------- void t_random_staff::place( t_adventure_map & map, t_adv_map_point const& point ) { static t_artifact_type const k_staves[] = { k_artifact_caduceus, k_artifact_staff_of_enchantment, k_artifact_staff_of_death, k_artifact_staff_of_the_witch_king, k_artifact_staff_of_summoning }; t_artifact_type type; t_counted_ptr<t_adv_artifact> artifact; type = map.get_random_artifact( k_staves, ELEMENTS_OF( k_staves )); artifact = new t_adv_artifact( type ); artifact->place( map, point ); };
t_spell get_potion_effect( t_artifact_type artifact ) { assert( !is_cut( artifact ) ); static t_spell effect[k_artifact_type_count]; static bool initialized = false; if (!initialized) { int const k_effects[][2] = { { k_artifact_vial_of_acid, k_spell_effect_potion_of_acid }, { k_artifact_binding_liquid, k_spell_effect_potion_of_binding }, { k_artifact_potion_of_cold, k_spell_effect_potion_of_cold }, { k_artifact_cloud_of_despair, k_spell_effect_potion_of_despair }, { k_artifact_potion_of_endurance, k_spell_effect_potion_of_endurance }, { k_artifact_kreegan_fire, k_spell_effect_potion_of_fire }, { k_artifact_potion_of_fire_resistance, k_spell_effect_potion_of_fire_resistance }, { k_artifact_vial_of_choking_gas, k_spell_effect_potion_of_gas }, { k_artifact_potion_of_healing, k_spell_effect_potion_of_healing }, { k_artifact_potion_of_health, k_spell_effect_potion_of_health }, { k_artifact_holy_water, k_spell_effect_potion_of_holy_water }, { k_artifact_potion_of_luck, k_spell_effect_potion_of_luck }, { k_artifact_potion_of_mana, k_spell_effect_potion_of_mana }, { k_artifact_potion_of_mirth, k_spell_effect_potion_of_mirth }, { k_artifact_vial_of_poison, k_spell_effect_potion_of_poison }, { k_artifact_potion_of_quickness, k_spell_effect_potion_of_quickness }, { k_artifact_potion_of_resistance, k_spell_effect_potion_of_resistance }, { k_artifact_potion_of_restoration, k_spell_effect_potion_of_restoration }, { k_artifact_vial_of_blinding_smoke, k_spell_effect_potion_of_smoke }, { k_artifact_potion_of_speed, k_spell_effect_potion_of_speed }, { k_artifact_potion_of_strength, k_spell_effect_potion_of_strength } }; int i; initialized = true; for (i = 0; i < k_artifact_type_count; i++) effect[i] = k_spell_effect_potion_of_acid; for (i = 0; i < ELEMENTS_OF( k_effects ); i++) effect[k_effects[i][0]] = t_spell(k_effects[i][1]); } return effect[artifact]; }
/*! * \cond DOXYGEN_PRIVATE * * \brief This function check validation of input LPT module * * \param dev_num[in] Number of LPT module. * \param isr_prior[in] ISR priority. * * \return MQX_OK Valid. */ _mqx_int lpt_validate_module ( uint32_t dev_num, uint32_t isr_prior ) { if (dev_num >= ELEMENTS_OF(lpt_address)) { return MQX_INVALID_DEVICE; } /* Check ISR priority */ if (0 == CORTEX_PRIOR(isr_prior)) { return MQX_INVALID_PARAMETER; } return MQX_OK; }
// -------------------------------------------------------------------------- // -------------------------------------------------------------------------- bool available( t_script_numeric_expression_type expression_type, t_script_context context ) { assert( expression_type >= 0 && expression_type < k_script_numeric_expression_type_count ); switch ( expression_type ) { case k_script_numeric_creatures_in_army: case k_script_numeric_hero_experience_level: case k_script_numeric_hero_skill_mastery: case k_script_numeric_total_creatures_in_army: case k_script_numeric_total_heroes_in_army: { static t_script_context const k_contexts[] = { k_script_context_hero, k_script_context_hero_in_combat, k_script_context_town, k_script_context_town_in_combat, k_script_context_town_with_visitor, k_script_context_placed_event, k_script_context_seers_hut, k_script_context_quest_guard, k_script_context_quest_gate, k_script_context_army, k_script_context_army_in_combat, k_script_context_garrison, k_script_context_garrison_in_combat, k_script_context_garrison_with_visitor, }; static t_script_context_mask const k_context_mask = build_script_context_mask( k_contexts, ELEMENTS_OF( k_contexts ) ); return k_context_mask[ context ]; } } return true; }