Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Common - Event MGR.inl
    »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
    »Version«   4.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/*   -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, Andrew Aye.  All Rights Reserved.
    This software is free for non-commercial use.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
      following conditions are met:
        Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
        Redistribution in binary form must reproduce this copyright notice, this list of conditions and the following disclaimers in the documentation and other materials
          provided with the distribution.
    The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
    The intellectual property rights of the algorithms used reside with Andrew Aye.
    You may not use this software, in whole or in part, in support of any commercial product without the express written consent of the author.
    There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
#if !defined(TGS_COMMON_EVENT_MGR_INL)
#define TGS_COMMON_EVENT_MGR_INL
#pragma once


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Inline Functions */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgEM_TB_Set_Paused ---------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgVOID tgEM_TB_Set_Paused( PCU_STg2_EM_TB psTB, C_TgBOOL bFlag )
{
    tgBF_Set_Flag_U32( &psTB->m_bfFlags, 0, bFlag );
}


/* ---- tgEM_TB_Set_Active ---------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgVOID tgEM_TB_Set_Active( PCU_STg2_EM_TB psTB, C_TgBOOL bFlag )
{
    tgBF_Set_Flag_U32( &psTB->m_bfFlags, 1, bFlag );
}


/* ---- tgEM_TB_Is_Paused ----------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgBOOL tgEM_TB_Is_Paused( CPCU_STg2_EM_TB psTB )
{
    return (tgBF_Query_Flag_U32( &psTB->m_bfFlags, 0 ) ? TgTRUE : TgFALSE );
}


/* ---- tgEM_TB_Is_Paused ----------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgBOOL tgEM_TB_Is_Active( CPCU_STg2_EM_TB psTB )
{
    return (tgBF_Query_Flag_U32( &psTB->m_bfFlags, 1 ) ? TgTRUE : TgFALSE );
}


/* ---- tgEM_TE_FRM_Lock ------------------------------------------------------------------------------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgRESULT tgEM_TE_FRM_Lock( C_TgEM_TE_FRM_ID tiTE, C_TgUINT32 uiPool, C_TgUINT32 uiIndex )
{
    TgPARAM_CHECK(uiIndex < KTgEM_NUM_TE_IN_POOL);
    TgPARAM_CHECK(uiPool < KTgEM_MAX_TE_FRM_POOL);

    tgCM_UTM_SN_Lock_Spin( &g_asEM_TE_FRM_Data_Lock[uiPool].m_sLock );

    /* Time lines are only valid for the period for which they have a valid id */
    if ((nullptr == g_apsEM_TE_FRM[uiPool]) || (g_apsEM_TE_FRM[uiPool]->m_aiKI[uiIndex] != tiTE.m_iKI))
    {
        tgCM_UTM_SN_Signal( &g_asEM_TE_FRM_Data_Lock[uiPool].m_sLock );
        return (KTgE_FAIL);
    };

    return (KTgS_OK);
}


/* ---- tgEM_TE_SEC_Lock ------------------------------------------------------------------------------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgRESULT tgEM_TE_SEC_Lock( C_TgEM_TE_SEC_ID tiTE, C_TgUINT32 uiPool, C_TgUINT32 uiIndex )
{
    TgPARAM_CHECK(uiIndex < KTgEM_NUM_TE_IN_POOL);
    TgPARAM_CHECK(uiPool < KTgEM_MAX_TE_SEC_POOL);

    tgCM_UTM_SN_Lock_Spin( &g_asEM_TE_SEC_Data_Lock[uiPool].m_sLock );

    /* Time lines are only valid for the period for which they have a valid id */
    if ((nullptr == g_apsEM_TE_SEC[uiPool]) || (g_apsEM_TE_SEC[uiPool]->m_aiKI[uiIndex] != tiTE.m_iKI))
    {
        tgCM_UTM_SN_Signal( &g_asEM_TE_SEC_Data_Lock[uiPool].m_sLock );
        return (KTgE_FAIL);
    };

    return (KTgS_OK);
}


/* ====================================================================================================================================================================== */
#endif