Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Common - Base - API - Platform.h
    »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_BASE_API_PLATFORM_H)
#define TGS_COMMON_BASE_API_PLATFORM_H
#pragma once


/* == Common ============================================================================================================================================================ */

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Functions                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

TgINLINE TgVOID                             tgPM_Break( TgVOID );
TgINLINE TgVOID                             tgPM_Abort( TgVOID );

TgINLINE TgSINT32                           tgPM_BSR_U08( C_TgUINT08 );
TgINLINE TgSINT32                           tgPM_BSR_U16( C_TgUINT16 );
TgINLINE TgSINT32                           tgPM_BSR_U32( C_TgUINT32 );
TgINLINE TgSINT32                           tgPM_BSR_U64( C_TgUINT64 );
TgINLINE TgSINT32                           tgPM_BSR_UXX( C_TgUINTXX );

TgINLINE TgSINT08                           tgPM_ABS_S08( C_TgSINT08 );
TgINLINE TgSINT16                           tgPM_ABS_S16( C_TgSINT16 );
TgINLINE TgSINT32                           tgPM_ABS_S32( C_TgSINT32 );
TgINLINE TgSINT64                           tgPM_ABS_S64( C_TgSINT64 );

TgINLINE TgSINT32                           tgPM_RAND_S_S32( TgVOID );
TgINLINE TgUINT32                           tgPM_RAND_S_U32( TgVOID );

TgINLINE TgBOOL                             tgPM_NAN_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_CEIL_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_FLOOR_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_SIN_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_COS_F32( C_TgFLOAT32 );
TgINLINE TgVOID                             tgPM_SINCOS_F32( PCU_TgFLOAT32, PCU_TgFLOAT32, C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_TAN_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_ASIN_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_ACOS_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_ATAN_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_ATAN2_F32( C_TgFLOAT32, C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_ABS_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_POW_F32( C_TgFLOAT32, C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_SQRT_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_EXP_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_LN_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_LOG_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_SQR_F32( C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_FMOD_F32( C_TgFLOAT32, C_TgFLOAT32 );
TgINLINE TgFLOAT32                          tgPM_FSEL_F32( C_TgFLOAT32, C_TgFLOAT32, C_TgFLOAT32 ); /*« _F32(A >= 0.0) ? B : C */
TgINLINE TgFLOAT32                          tgPM_COPY_SIGN_F32( C_TgFLOAT32, C_TgFLOAT32 );

TgINLINE TgBOOL                             tgPM_NAN_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_CEIL_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_FLOOR_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_SIN_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_COS_F64( C_TgFLOAT64 );
TgINLINE TgVOID                             tgPM_SINCOS_F64( PCU_TgFLOAT64, PCU_TgFLOAT64, C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_TAN_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_ASIN_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_ACOS_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_ATAN_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_ATAN2_F64( C_TgFLOAT64, C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_ABS_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_POW_F64( C_TgFLOAT64, C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_SQRT_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_EXP_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_LN_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_LOG_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_SQR_F64( C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_FMOD_F64( C_TgFLOAT64, C_TgFLOAT64 );
TgINLINE TgFLOAT64                          tgPM_FSEL_F64( C_TgFLOAT64, C_TgFLOAT64, C_TgFLOAT64 ); /*« _F64(A >= 0.0) ? B : C */
TgINLINE TgFLOAT64                          tgPM_COPY_SIGN_F64( C_TgFLOAT64, C_TgFLOAT64 );


/* ---- Thread ------------------------------------------------------------------------------------------------------------------------------------------------------------ */

#if TgCOMPILE_THREAD
TgEXTN TgTHREAD_ID                          tgTR_Register_Main_Thread( CPC_TgCHAR );

                                            /* Thread_Create - Platform agnostic method to create a new thread */
                                            /* 1: Platform specific thread function */
                                            /* 2: Thread function parameter */
                                            /* 3: Stack Size */
                                            /* 4: Thread priority.  By default this should be normal */
                                            /* 5: Thread name - used for debugging purposes. */
TgEXTN TgTHREAD_ID                          tgTR_Create( TgPLATFORM_THREAD_FCN, C_TgUINTPTR, C_TgUINT32, C_ETgTHREAD_PRIORITY, CPC_TgCHAR );

TgEXTN TgTHREAD_ID                          tgTR_Query_Id( TgVOID );

TgEXTN TgVOID                               tgTR_Close( C_TgTHREAD_ID );
TgEXTN ETgTHREAD_STATUS                     tgTR_Status( C_TgTHREAD_ID );

TgEXTN TgUINT32                             tgTR_Stack_Size( TgVOID );

/*# TgCOMPILE_THREAD */
#endif

TgINLINE TgVOID                             tgTR_Yield( TgVOID );
TgINLINE TgVOID                             tgTR_Pause( TgVOID );
TgINLINE TgVOID                             tgTR_Sleep( C_TgUINT32 ); /*« 1: Sleep time in ms */


/* ---- Time -------------------------------------------------------------------------------------------------------------------------------------------------------------- */

                                            /* NOTE: These functions are inaccurate when CPU dynamic clock adjustments are active */
TgEXTN TgVOID                               tgTM_Init( TgVOID );
TgEXTN TgSINT64                             tgTM_Query_Counter_Tick( TgVOID );
TgEXTN TgFLOAT32                            tgTM_Counter_Tick_To_MSec( C_TgSINT64 );
TgEXTN TgFLOAT32                            tgTM_Query_Time( TgVOID );

TgEXTN TgFLOAT32                            tgTM_Channel_Query_Time( C_ETgTIMER_CHANNEL );
TgEXTN TgFLOAT32                            tgTM_Channel_Elapsed_Time( C_ETgTIMER_CHANNEL );
TgEXTN TgVOID                               tgTM_Channel_Reset( C_ETgTIMER_CHANNEL );
TgEXTN TgVOID                               tgTM_Channel_Start( C_ETgTIMER_CHANNEL );
TgEXTN TgVOID                               tgTM_Channel_Stop( C_ETgTIMER_CHANNEL );
TgEXTN TgVOID                               tgTM_Channel_Update( C_ETgTIMER_CHANNEL );
TgEXTN TgVOID                               tgTM_Channel_Step( C_ETgTIMER_CHANNEL, C_TgFLOAT32 );


/* ---- IO ---------------------------------------------------------------------------------------------------------------------------------------------------------------- */

                                            /* File_Open -  */
                                            /* 1: Return result - handle to file */
                                            /* 2: Full path */
                                            /* 3: FILE_IO_ACCESS Mask */
TgEXTN TgRESULT                             tgIO_File_Open( P_TgSINTPTR, CPC_TgCHAR, C_TgSINT32 );

                                            /* File_Read -  */
                                            /* 1: File Handle */
                                            /* 2: Buffer */
                                            /* 3: Buffer Size */
TgEXTN TgSIZE                               tgIO_File_Read( C_TgSINTPTR, P_TgVOID, TgSIZE );
TgEXTN TgSIZE                               tgIO_File_Read_Async( C_TgSINTPTR, P_TgVOID, TgSIZE );

                                            /* File_Write -  */
                                            /* 1: File Handle */
                                            /* 2: Buffer */
                                            /* 3: Buffer Size */
TgEXTN TgSIZE                               tgIO_File_Write( C_TgSINTPTR, CP_TgVOID, TgSIZE );

                                            /* File_Flush -  */
                                            /* 1: File Handle */
TgEXTN TgRESULT                             tgIO_File_Flush( C_TgSINTPTR );

                                            /* File_Close -  */
                                            /* 1: File Handle */
TgEXTN TgRESULT                             tgIO_File_Close( C_TgSINTPTR );

                                            /* File_Valid -  */
                                            /* 1: File Handle */
TgEXTN TgBOOL                               tgIO_File_Valid( C_TgSINTPTR );

                                            /* File_Seek -  */
                                            /* 1: File Handle */
                                            /* 2: Seek Mode */
                                            /* 3: Seek Position */
                                            /* R: New Position */
TgEXTN TgRESULT                             tgIO_File_Seek( C_TgSINTPTR, C_ETgIO_SEEK, C_TgSINT64 );

                                            /* File_Size -  */
                                            /* 1: File Handle */
TgEXTN TgSIZE                               tgIO_File_Size( C_TgSINTPTR );

                                            /* Directory_Make -  */
                                            /* 1: Full path */
TgEXTN TgRESULT                             tgIO_Directory_Make( CPC_TgCHAR );

                                            /* Directory_Remove -  */
                                            /* 1: Full path */
TgEXTN TgRESULT                             tgIO_Directory_Remove( CPC_TgCHAR );

                                            /* Directory_Exists -  */
                                            /* 1: Full path */
TgEXTN TgBOOL                               tgIO_Directory_Exists( CPC_TgCHAR );

                                            /* Directory_Find_First - */
                                            /* 1: Output Buffer for Directory Name */
                                            /* 2: Length of Output Buffer */
                                            /* 3: Output handle for enumerator */
                                            /* 4: Input path */
TgEXTN TgRESULT                             tgIO_Directory_Find_First( P_TgCHAR, C_TgSIZE, PP_TgVOID, CPC_TgCHAR );

                                            /* Directory_Find_Next - */
                                            /* 1: Output Buffer for Directory Name */
                                            /* 2: Length of Output Buffer */
                                            /* 3: Input handle for enumerator */
TgEXTN TgBOOL                               tgIO_Directory_Find_Next( P_TgCHAR, C_TgSIZE, P_TgVOID );

                                            /* Directory_Find_Close - */
                                            /* 1: Output handle for enumerator */
TgEXTN TgVOID                               tgIO_Directory_Find_Close( P_TgVOID );

                                            /* File_Delete -  */
                                            /* 1: Full path */
TgEXTN TgRESULT                             tgIO_File_Delete( CPC_TgCHAR );

                                            /* File_Move -  */
                                            /* 1: Full path, Source */
                                            /* 2: Full path, Destination */
TgEXTN TgRESULT                             tgIO_File_Copy( CPC_TgCHAR, CPC_TgCHAR );

                                            /* File_Move -  */
                                            /* 1: Full path, Source */
                                            /* 2: Full path, Destination */
TgEXTN TgRESULT                             tgIO_File_Move( CPC_TgCHAR, CPC_TgCHAR );

                                            /* File_Exists -  */
                                            /* 1: Full path */
TgEXTN TgBOOL                               tgIO_File_Exists( CPC_TgCHAR );

                                            /* File_Find_First - */
                                            /* 1: Output Buffer for File Name */
                                            /* 2: Length of Output Buffer */
                                            /* 3: Output handle for enumerator */
                                            /* 4: Input path */
TgEXTN TgRESULT                             tgIO_File_Find_First( P_TgCHAR, C_TgSIZE, PP_TgVOID, CPC_TgCHAR );

                                            /* File_Find_Next - */
                                            /* 1: Output Buffer for File Name */
                                            /* 2: Length of Output Buffer */
                                            /* 3: Input handle for enumerator */
TgEXTN TgBOOL                               tgIO_File_Find_Next( P_TgCHAR, C_TgSIZE, P_TgVOID );

                                            /* File_Find_Close - */
                                            /* 1: Output handle for enumerator */
TgEXTN TgVOID                               tgIO_File_Find_Close( P_TgVOID );


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