Skip to content

Commit

Permalink
Fixed build for raspberry pi.
Browse files Browse the repository at this point in the history
  • Loading branch information
tx00100xt committed Jun 2, 2022
1 parent f0f520d commit c8b8907
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 12 deletions.
5 changes: 5 additions & 0 deletions SamTFE/Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ if (PYRA)
add_definitions(-DPLATFORM_PYRA=1)
endif()

option(RPI4 "Raspberry PI 4" FALSE)
if(RPI4)
add_definitions(-DPLATFORM_RPI4=1)
endif()

option(USE_TREMOR "Use Tremor instead of Vorbis" FALSE)
if (USE_TREMOR)
add_definitions(-DUSE_TREMOR=1)
Expand Down
10 changes: 8 additions & 2 deletions SamTFE/Sources/Engine/Base/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ static inline __int64 ReadTSC(void)
struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &tp);
return( (((__int64) tp.tv_sec) * 1000000000LL) + ((__int64) tp.tv_nsec));
#elif (defined PLATFORM_RPI4)
struct timeval tv;
gettimeofday(&tv, NULL);
return( (((__int64) tv.tv_sec) * 1000000) + ((__int64) tv.tv_usec) );
#elif (defined __MSVC_INLINE__)
__int64 mmRet;
__asm {
Expand Down Expand Up @@ -117,6 +121,7 @@ void sys_precise_clock(uint64_t *result)
(uint64_t) tv.tv_usec;
}

#if !defined(PLATFORM_PANDORA) && !defined(PLATFORM_PYRA) && !defined(PLATFORM_RPI4)
// cpu_rdtsc
void cpu_rdtsc(uint64_t* result)
{
Expand Down Expand Up @@ -239,7 +244,7 @@ int cpu_clock_measure(int millis, int quad_check)
//
// END libcpuid functions
//

#endif // not PANDORA PYRA RPI4

// link with Win-MultiMedia
#ifdef _MSC_VER
Expand Down Expand Up @@ -484,7 +489,8 @@ CTimer::CTimer(BOOL bInterrupt /*=TRUE*/)
#if defined(PLATFORM_PANDORA) || defined(PLATFORM_PYRA)
// just use gettimeofday.
tm_llCPUSpeedHZ = tm_llPerformanceCounterFrequency = 1000000000LL;

#elif PLATFORM_RPI4
tm_llCPUSpeedHZ = tm_llPerformanceCounterFrequency = 1000000;
#elif PLATFORM_WIN32
{ // this part of code must be executed as precisely as possible
CSetPriority sp(REALTIME_PRIORITY_CLASS, THREAD_PRIORITY_TIME_CRITICAL);
Expand Down
2 changes: 1 addition & 1 deletion SamTFE/Sources/build-linux32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cp -vfr ../Entities/PlayerWeapons_old.es ../Entities/PlayerWeapons.es

# Right now we force x86, though...
#cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DUSE_I386_NASM_ASM=TRUE .. $1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS=-mmmx -DCMAKE_CXX_FLAGS=-mmmx -DUSE_I386_NASM_ASM=TRUE .. $1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS=-mmmx -DCMAKE_CXX_FLAGS=-mmmx -DUSE_I386_NASM_ASM=TRUE .. $1 $2
echo "ECC first"
make ecc
echo "Then the rest..."
Expand Down
2 changes: 1 addition & 1 deletion SamTFE/Sources/build-linux32xplus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cp -vfr ../Entities/PlayerWeaponsHD.es ../Entities/PlayerWeapons.es

# Right now we force x86, though...
#cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DUSE_I386_NASM_ASM=TRUE .. $1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS=-mmmx -DCMAKE_CXX_FLAGS=-mmmx -DUSE_I386_NASM_ASM=TRUE .. $1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS=-mmmx -DCMAKE_CXX_FLAGS=-mmmx -DUSE_I386_NASM_ASM=TRUE .. $1 $2
echo "ECC first"
make ecc
echo "Then the rest..."
Expand Down
2 changes: 1 addition & 1 deletion SamTFE/Sources/build-linux64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cp -vfr ../Entities/PlayerWeapons_old.es ../Entities/PlayerWeapons.es
#ninja

# This is the eventual path for amd64.
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. $1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. $1 $2

# Right now we force x86, though...
#cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 ..
Expand Down
2 changes: 1 addition & 1 deletion SamTFE/Sources/build-linux64xplus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cp -vfr ../Entities/PlayerWeaponsHD.es ../Entities/PlayerWeapons.es
#ninja

# This is the eventual path for amd64.
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. $1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. $1 $2

# Right now we force x86, though...
#cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 ..
Expand Down
5 changes: 5 additions & 0 deletions SamTSE/Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ if (PYRA)
add_definitions(-DPLATFORM_PYRA=1)
endif()

option(RPI4 "Raspberry PI 4" FALSE)
if(RPI4)
add_definitions(-DPLATFORM_RPI4=1)
endif()

option(USE_TREMOR "Use Tremor instead of Vorbis" FALSE)
if (USE_TREMOR)
add_definitions(-DUSE_TREMOR=1)
Expand Down
10 changes: 8 additions & 2 deletions SamTSE/Sources/Engine/Base/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ static inline __int64 ReadTSC(void)
struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &tp);
return( (((__int64) tp.tv_sec) * 1000000000LL) + ((__int64) tp.tv_nsec));
#elif (defined PLATFORM_RPI4)
struct timeval tv;
gettimeofday(&tv, NULL);
return( (((__int64) tv.tv_sec) * 1000000) + ((__int64) tv.tv_usec) );
#elif (defined __MSVC_INLINE__)
__int64 mmRet;
__asm {
Expand Down Expand Up @@ -117,6 +121,7 @@ void sys_precise_clock(uint64_t *result)
(uint64_t) tv.tv_usec;
}

#if !defined(PLATFORM_PANDORA) && !defined(PLATFORM_PYRA) && !defined(PLATFORM_RPI4)
// cpu_rdtsc
void cpu_rdtsc(uint64_t* result)
{
Expand Down Expand Up @@ -239,7 +244,7 @@ int cpu_clock_measure(int millis, int quad_check)
//
// END libcpuid functions
//

#endif // not PANDORA PYRA RPI4

// link with Win-MultiMedia
#ifdef _MSC_VER
Expand Down Expand Up @@ -484,7 +489,8 @@ CTimer::CTimer(BOOL bInterrupt /*=TRUE*/)
#if defined(PLATFORM_PANDORA) || defined(PLATFORM_PYRA)
// just use gettimeofday.
tm_llCPUSpeedHZ = tm_llPerformanceCounterFrequency = 1000000000LL;

#elif PLATFORM_RPI4
tm_llCPUSpeedHZ = tm_llPerformanceCounterFrequency = 1000000;
#elif PLATFORM_WIN32
{ // this part of code must be executed as precisely as possible
CSetPriority sp(REALTIME_PRIORITY_CLASS, THREAD_PRIORITY_TIME_CRITICAL);
Expand Down
2 changes: 1 addition & 1 deletion SamTSE/Sources/build-linux32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cp -vfr ../EntitiesMP/PlayerWeapons_old.es ../EntitiesMP/PlayerWeapons.es

# Right now we force x86, though...
#cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DUSE_I386_NASM_ASM=TRUE .. $1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS=-mmmx -DCMAKE_CXX_FLAGS=-mmmx -DUSE_I386_NASM_ASM=TRUE .. $1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS=-mmmx -DCMAKE_CXX_FLAGS=-mmmx -DUSE_I386_NASM_ASM=TRUE .. $1 $2
echo "ECC first"
make ecc
echo "Then the rest..."
Expand Down
2 changes: 1 addition & 1 deletion SamTSE/Sources/build-linux32xplus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cp -vfr ../EntitiesMP/PlayerWeaponsHD.es ../EntitiesMP/PlayerWeapons.es

# Right now we force x86, though...
#cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DUSE_I386_NASM_ASM=TRUE .. $1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS=-mmmx -DCMAKE_CXX_FLAGS=-mmmx -DUSE_I386_NASM_ASM=TRUE .. $1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS=-mmmx -DCMAKE_CXX_FLAGS=-mmmx -DUSE_I386_NASM_ASM=TRUE .. $1 $2
echo "ECC first"
make ecc
echo "Then the rest..."
Expand Down
2 changes: 1 addition & 1 deletion SamTSE/Sources/build-linux64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cp -vfr ../EntitiesMP/PlayerWeapons_old.es ../EntitiesMP/PlayerWeapons.es
#ninja

# This is the eventual path for amd64.
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. $1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. $1 $2

# Right now we force x86, though...
#cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 ..
Expand Down
2 changes: 1 addition & 1 deletion SamTSE/Sources/build-linux64xplus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cp -vfr ../EntitiesMP/PlayerWeaponsHD.es ../EntitiesMP/PlayerWeapons.es
#ninja

# This is the eventual path for amd64.
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. $1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. $1 $2

# Right now we force x86, though...
#cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 ..
Expand Down

0 comments on commit c8b8907

Please sign in to comment.