File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,6 +22,12 @@ option(BUILD_WITH_RES "Build with the resource file (Windows Compiler Only)" ON)
2222
2323set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MD" )
2424
25+ include (TestBigEndian )
26+ TEST_BIG_ENDIAN (BIG_ENDIAN )
27+ if (BIG_ENDIAN)
28+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBIG_ENDIAN" )
29+ endif ()
30+
2531if (
2632 NOT IMPL STREQUAL "DJGPP"
2733 AND
Original file line number Diff line number Diff line change @@ -59,6 +59,11 @@ unsigned int hssImpl_get() {
5959}
6060
6161void hssImpl_set (const unsigned int highScore ) {
62+ #ifdef BIG_ENDIAN
63+ unsigned char i ;
64+ unsigned char hsByte [4 ];
65+ #endif
66+
6267 if (fileStatus == FILE_BROKEN ) {
6368 fprintf (stderr , HSSIMPL_STRING_FILE_NOTVALID );
6469 return ;
@@ -73,12 +78,24 @@ void hssImpl_set(const unsigned int highScore) {
7378 return ;
7479 }
7580 fprintf (file , HSSIMPL_SIGNATURE );
81+ #ifdef BIG_ENDIAN
82+ for (i = 0 ; i < 4 ; i ++ ) {
83+ hsByte [i ] = highScore >> i * 8 ;
84+ fwrite (
85+ & hsByte [i ],
86+ 1 ,
87+ sizeof (unsigned char ),
88+ file
89+ );
90+ }
91+ #else
7692 fwrite (
7793 & highScore ,
7894 1 ,
7995 sizeof (unsigned int ),
8096 file
8197 );
98+ #endif
8299 fflush (file );
83100 }
84101 return ;
You can’t perform that action at this time.
0 commit comments