2 Skelton for retropc emulator
4 Author : Takeda.Toshiya
13 // move shared codes to DLL???
15 // #define USE_SHARED_DLL
18 // use zlib to decompress gzip file???
20 #if defined(_MSC_VER) && (_MSC_VER >= 1500)
26 // check environemnt/language
29 // Microsoft Visual C++
31 // variable scope of 'for' loop for Microsoft Visual C++ 6.0
32 #define for if(0);else for
35 // Microsoft Visual C++ 6.0 or later
36 #define SUPPORT_TCHAR_TYPE
39 // Microsoft Visual C++ 8.0 (2005) or later
40 #define SUPPORT_SECURE_FUNCTIONS
41 #pragma warning( disable : 4819 )
42 //#pragma warning( disable : 4995 )
43 #pragma warning( disable : 4996 )
46 // Microsoft Visual C++ 12.0 (2013) or later
47 #define SUPPORT_CPLUSPLUS_11
49 #define CSP_OS_WINDOWS
51 // Win32, but not Microsoft Visual C++
52 #define SUPPORT_TCHAR_TYPE
53 // #define SUPPORT_SECURE_FUNCTIONS
57 #if defined(Q_OS_CYGWIN)
58 #define CSP_OS_GCC_CYGWIN
59 #define CSP_OS_WINDOWS
60 #elif defined(Q_OS_WIN) || defined(__WIN32) || defined(__WIN64)
61 #define CSP_OS_GCC_WINDOWS
62 #define CSP_OS_WINDOWS
64 #define DLL_PREFIX __declspec(dllexport)
65 #define DLL_PREFIX_I __declspec(dllimport)
68 #define CSP_OS_GCC_GENERIC
69 #define CSP_OS_GENERIC
73 #if defined(__clang__)
74 #define __CSP_COMPILER_CLANG
76 #define __CSP_COMPILER_GCC
78 #define SUPPORT_CPLUSPLUS_11
84 #ifndef SUPPORT_CPLUSPLUS_11
85 #if defined(__cplusplus) && (__cplusplus > 199711L)
86 #define SUPPORT_CPLUSPLUS_11
89 #ifndef SUPPORT_TCHAR_TYPE
90 // secure functions need tchar type
91 #undef SUPPORT_SECURE_FUNCTIONS
100 // include common header files
101 #ifdef SUPPORT_TCHAR_TYPE
104 #ifdef SUPPORT_CPLUSPLUS_11
111 #include <typeinfo.h>
118 // include environment/language dependent header files
121 #include <windowsx.h>
123 #include <mmsystem.h>
134 #if defined(__MINGW32__) || (__MINGW64__)
139 #include <QtCore/QString>
140 #include <QtCore/QFile>
142 #include <sys/param.h>
145 #define _MAX_PATH 2048
149 #if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
150 #if defined(__BYTE_ORDER) && (defined(__LITTLE_ENDIAN) || defined(__BIG_ENDIAN))
151 #if __BYTE_ORDER == __LITTLE_ENDIAN
152 #define __LITTLE_ENDIAN__
153 #elif __BYTE_ORDER == __BIG_ENDIAN
154 #define __BIG_ENDIAN__
156 #elif defined(SDL_BYTEORDER) && (defined(SDL_LIL_ENDIAN) || defined(SDL_BIG_ENDIAN))
157 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
158 #define __LITTLE_ENDIAN__
159 #elif SDL_BYTEORDER == SDL_BIG_ENDIAN
160 #define __BIG_ENDIAN__
162 #elif defined(WORDS_LITTLEENDIAN)
163 #define __LITTLE_ENDIAN__
164 #elif defined(WORDS_BIGENDIAN)
165 #define __BIG_ENDIAN__
168 #if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
169 // may be Microsoft Visual C++
170 #define __LITTLE_ENDIAN__
174 #ifndef SUPPORT_TCHAR_TYPE
180 #ifndef SUPPORT_CPLUSPLUS_11
182 typedef signed char int8_t;
185 typedef signed short int16_t;
188 typedef signed int int32_t;
191 typedef signed long long int64_t;
194 typedef unsigned char uint8_t;
197 typedef unsigned short uint16_t;
200 typedef unsigned int uint32_t;
203 typedef unsigned long long uint64_t;
209 typedef _TCHAR* LPTSTR;
212 typedef const _TCHAR* LPCTSTR;
224 typedef uint8_t BYTE;
227 typedef uint16_t WORD;
230 typedef uint32_t DWORD;
233 typedef uint64_t QWORD;
239 typedef int16_t INT16;
242 typedef int32_t INT32;
245 typedef int64_t INT64;
248 typedef uint8_t UINT8;
251 typedef uint16_t UINT16;
254 typedef uint32_t UINT32;
257 typedef uint64_t UINT64;
263 typedef unsigned int UINT;
269 #ifdef __BIG_ENDIAN__
276 #ifdef __BIG_ENDIAN__
285 inline void read_2bytes_le_from(uint8_t *t)
287 b.l = t[0]; b.h = t[1];
289 inline void write_2bytes_le_to(uint8_t *t)
291 t[0] = b.l; t[1] = b.h;
293 inline void read_2bytes_be_from(uint8_t *t)
295 b.h = t[0]; b.l = t[1];
297 inline void write_2bytes_be_to(uint8_t *t)
299 t[0] = b.h; t[1] = b.l;
302 inline void set_2bytes_be_from(uint16_t n)
311 b.l = bigv.b.l; b.h = bigv.b.h;
313 inline void set_2bytes_le_from(uint16_t n)
322 b.l = littlev.b.l; b.h = littlev.b.h;
324 inline uint16_t get_2bytes_be_to()
332 bigv.b.l = b.l; bigv.b.h = b.h;
335 inline uint16_t get_2bytes_le_to()
343 littlev.b.l = b.l; littlev.b.h = b.h;
351 #ifdef __BIG_ENDIAN__
352 uint8_t h3, h2, h, l;
354 uint8_t l, h, h2, h3;
358 #ifdef __BIG_ENDIAN__
365 #ifdef __BIG_ENDIAN__
372 #ifdef __BIG_ENDIAN__
379 #ifdef __BIG_ENDIAN__
387 inline void read_2bytes_le_from(uint8_t *t)
389 b.l = t[0]; b.h = t[1]; b.h2 = b.h3 = 0;
391 inline void write_2bytes_le_to(uint8_t *t)
393 t[0] = b.l; t[1] = b.h;
395 inline void read_2bytes_be_from(uint8_t *t)
397 b.h3 = b.h2 = 0; b.h = t[0]; b.l = t[1];
399 inline void write_2bytes_be_to(uint8_t *t)
401 t[0] = b.h; t[1] = b.l;
403 inline void read_4bytes_le_from(uint8_t *t)
405 b.l = t[0]; b.h = t[1]; b.h2 = t[2]; b.h3 = t[3];
407 inline void write_4bytes_le_to(uint8_t *t)
409 t[0] = b.l; t[1] = b.h; t[2] = b.h2; t[3] = b.h3;
411 inline void read_4bytes_be_from(uint8_t *t)
413 b.h3 = t[0]; b.h2 = t[1]; b.h = t[2]; b.l = t[3];
415 inline void write_4bytes_be_to(uint8_t *t)
417 t[0] = b.h3; t[1] = b.h2; t[2] = b.h; t[3] = b.l;
420 inline void set_2bytes_be_from(uint16_t n)
429 b.l = bigv.b.l; b.h = bigv.b.h;
432 inline void set_2bytes_le_from(uint16_t n)
441 b.l = littlev.b.l; b.h = littlev.b.h;
444 inline uint16_t get_2bytes_be_to()
452 bigv.b.l = b.l; bigv.b.h = b.h;
455 inline uint16_t get_2bytes_le_to()
463 littlev.b.l = b.l; littlev.b.h = b.h;
467 inline void set_4bytes_be_from(uint32_t n)
472 uint8_t h3, h2, h, l;
476 b.l = bigv.b.l; b.h = bigv.b.h; b.h2 = bigv.b.h2; b.h3 = bigv.b.h3;
478 inline void set_4bytes_le_from(uint32_t n)
483 uint8_t l, h, h2, h3;
487 b.l = littlev.b.l; b.h = littlev.b.h; b.h2 = littlev.b.h2; b.h3 = littlev.b.h3;
489 inline uint32_t get_4bytes_be_to()
494 uint8_t h3, h2, h, l;
497 bigv.b.l = b.l; bigv.b.h = b.h; bigv.b.h2 = b.h2; bigv.b.h3 = b.h3;
500 inline uint32_t get_4bytes_le_to()
505 uint8_t l, h, h2, h3;
508 littlev.b.l = b.l; littlev.b.h = b.h; littlev.b.h2 = b.h2; littlev.b.h3 = b.h3;
516 #ifdef __BIG_ENDIAN__
517 uint8_t h7, h6, h5, h4, h3, h2, h, l;
519 uint8_t l, h, h2, h3, h4, h5, h6, h7;
523 #ifdef __BIG_ENDIAN__
524 int8_t h7, h6, h5, h4, h3, h2, h, l;
526 int8_t l, h, h2, h3, h4, h5, h6, h7;
530 #ifdef __BIG_ENDIAN__
531 uint16_t h3, h2, h, l;
533 uint16_t l, h, h2, h3;
537 #ifdef __BIG_ENDIAN__
538 int16_t h3, h2, h, l;
540 int16_t l, h, h2, h3;
544 #ifdef __BIG_ENDIAN__
545 pair16_t h3, h2, h, l;
547 pair16_t l, h, h2, h3;
551 #ifdef __BIG_ENDIAN__
558 #ifdef __BIG_ENDIAN__
565 #ifdef __BIG_ENDIAN__
574 inline void read_2bytes_le_from(uint8_t *t)
576 b.l = t[0]; b.h = t[1]; b.h2 = b.h3 = 0;
577 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
579 inline void write_2bytes_le_to(uint8_t *t)
581 t[0] = b.l; t[1] = b.h;
583 inline void read_2bytes_be_from(uint8_t *t)
585 b.h3 = b.h2 = 0; b.h = t[0]; b.l = t[1];
586 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
588 inline void write_2bytes_be_to(uint8_t *t)
590 t[0] = b.h; t[1] = b.l;
592 inline void read_4bytes_le_from(uint8_t *t)
594 b.l = t[0]; b.h = t[1]; b.h2 = t[2]; b.h3 = t[3];
595 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
597 inline void write_4bytes_le_to(uint8_t *t)
599 t[0] = b.l; t[1] = b.h; t[2] = b.h2; t[3] = b.h3;
601 inline void read_4bytes_be_from(uint8_t *t)
603 b.h3 = t[0]; b.h2 = t[1]; b.h = t[2]; b.l = t[3];
604 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
606 inline void write_4bytes_be_to(uint8_t *t)
608 t[0] = b.h3; t[1] = b.h2; t[2] = b.h; t[3] = b.l;
611 inline void read_8bytes_le_from(uint8_t *t)
613 b.l = t[0]; b.h = t[1]; b.h2 = t[2]; b.h3 = t[3];
614 b.h4 = t[4]; b.h5 = t[5]; b.h6 = t[6]; b.h7 = t[7];
616 inline void write_8bytes_le_to(uint8_t *t)
618 t[0] = b.l; t[1] = b.h; t[2] = b.h2; t[3] = b.h3;
619 t[4] = b.h4; t[5] = b.h5; t[6] = b.h6; t[7] = b.h7;
621 inline void read_8bytes_be_from(uint8_t *t)
623 b.h7 = t[0]; b.h6 = t[1]; b.h5 = t[2]; b.h4 = t[3];
624 b.h3 = t[4]; b.h2 = t[5]; b.h = t[6]; b.l = t[7];
626 inline void write_8bytes_be_to(uint8_t *t)
628 t[0] = b.h7; t[1] = b.h6; t[2] = b.h5; t[3] = b.h4;
629 t[4] = b.h3; t[5] = b.h2; t[6] = b.h; t[7] = b.l;
632 inline void set_2bytes_be_from(uint16_t n)
641 b.l = bigv.b.l; b.h = bigv.b.h;
643 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
645 inline void set_2bytes_le_from(uint16_t n)
654 b.l = littlev.b.l; b.h = littlev.b.h;
656 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
658 inline uint16_t get_2bytes_be_to()
666 bigv.b.l = b.l; bigv.b.h = b.h;
669 inline uint16_t get_2bytes_le_to()
677 littlev.b.l = b.l; littlev.b.h = b.h;
681 inline void set_4bytes_be_from(uint32_t n)
686 uint8_t h3, h2, h, l;
690 b.l = bigv.b.l; b.h = bigv.b.h; b.h2 = bigv.b.h2; b.h3 = bigv.b.h3;
691 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
693 inline void set_4bytes_le_from(uint32_t n)
698 uint8_t l, h, h2, h3;
702 b.l = littlev.b.l; b.h = littlev.b.h; b.h2 = littlev.b.h2; b.h3 = littlev.b.h3;
703 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
705 inline uint32_t get_4bytes_be_to()
710 uint8_t h3, h2, h, l;
713 bigv.b.l = b.l; bigv.b.h = b.h; bigv.b.h2 = b.h2; bigv.b.h3 = b.h3;
716 inline uint32_t get_4bytes_le_to()
721 uint8_t l, h, h2, h3;
724 littlev.b.l = b.l; littlev.b.h = b.h; littlev.b.h2 = b.h2; littlev.b.h3 = b.h3;
728 inline void set_8bytes_be_from(uint64_t n)
733 uint8_t h7, h6, h5, h4, h3, h2, h, l;
737 b.l = bigv.b.l; b.h = bigv.b.h; b.h2 = bigv.b.h2; b.h3 = bigv.b.h3;
738 b.h4 = bigv.b.h4; b.h5 = bigv.b.h5; b.h6 = bigv.b.h6; b.h7 = bigv.b.h7;
740 inline void set_8bytes_le_from(uint64_t n)
745 uint8_t l, h, h2, h3, h4, h5, h6, h7;
749 b.l = littlev.b.l; b.h = littlev.b.h; b.h2 = littlev.b.h2; b.h3 = littlev.b.h3;
750 b.h4 = littlev.b.h4; b.h5 = littlev.b.h5; b.h6 = littlev.b.h6; b.h7 = littlev.b.h7;
752 inline uint64_t get_8bytes_be_to()
757 uint8_t h7, h6, h5, h4, h3, h2, h, l;
760 bigv.b.l = b.l; bigv.b.h = b.h; bigv.b.h2 = b.h2; bigv.b.h3 = b.h3;
761 bigv.b.h4 = b.h4; bigv.b.h5 = b.h5; bigv.b.h6 = b.h6; bigv.b.h7 = b.h7;
764 inline uint64_t get_8bytes_le_to()
769 uint8_t l, h, h2, h3, h4, h5, h6, h7;
772 littlev.b.l = b.l; littlev.b.h = b.h; littlev.b.h2 = b.h2; littlev.b.h3 = b.h3;
773 littlev.b.h4 = b.h4; littlev.b.h5 = b.h5; littlev.b.h6 = b.h6; littlev.b.h7 = b.h7;
779 uint32_t DLL_PREFIX EndianToLittle_DWORD(uint32_t x);
780 uint16_t DLL_PREFIX EndianToLittle_WORD(uint16_t x);
781 uint32_t DLL_PREFIX EndianFromLittle_DWORD(uint32_t x);
782 uint16_t DLL_PREFIX EndianFromLittle_WORD(uint16_t x);
784 uint32_t DLL_PREFIX EndianToBig_DWORD(uint32_t x);
785 uint16_t DLL_PREFIX EndianToBig_WORD(uint16_t x);
786 uint32_t DLL_PREFIX EndianFromBig_DWORD(uint32_t x);
787 uint16_t DLL_PREFIX EndianFromBig_WORD(uint16_t x);
792 int DLL_PREFIX max(int a, int b);
793 unsigned int DLL_PREFIX max(int a, unsigned int b);
794 unsigned int DLL_PREFIX max(unsigned int a, int b);
795 unsigned int DLL_PREFIX max(unsigned int a, unsigned int b);
796 int DLL_PREFIX min(int a, int b);
797 int DLL_PREFIX min(unsigned int a, int b);
798 int DLL_PREFIX min(int a, unsigned int b);
799 unsigned int DLL_PREFIX min(unsigned int a, unsigned int b);
803 #if defined(__GNUC__) || defined(__CYGWIN__) || defined(Q_OS_CYGWIN)
804 #define stricmp(a,b) strcasecmp(a,b)
805 #define strnicmp(a,b,n) strncasecmp(a,b,n)
808 #ifndef SUPPORT_TCHAR_TYPE
810 #define _fgetts fgets
813 #define _ftprintf printf
816 #define _tfopen fopen
819 #define _tcscmp strcmp
822 #define _tcscpy strcpy
825 #define _tcsicmp stricmp
828 #define _tcslen strlen
831 #define _tcscat strcat
834 #define _tcsncat strncat
837 #define _tcsncpy strncpy
840 #define _tcsncicmp strnicmp
843 #define _tcschr strchr
846 #define _tcsrchr strrchr
849 #define _tcsstr strstr
852 #define _tcstok strtok
858 #define _tcstol strtol
861 #define _tcstoul strtoul
864 #define _stprintf sprintf
867 #define _vstprintf vsprintf
870 #define _taccess access
873 #define _tremove remove
876 #define _trename rename
880 #define _TEXT(x) __T(x)
883 #ifndef SUPPORT_SECURE_FUNCTIONS
887 // errno_t DLL_PREFIX my_tfopen_s(FILE** pFile, const _TCHAR *filename, const _TCHAR *mode);
888 errno_t DLL_PREFIX my_tcscat_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHAR *strSource);
889 errno_t DLL_PREFIX my_strcpy_s(char *strDestination, size_t numberOfElements, const char *strSource);
890 errno_t DLL_PREFIX my_tcscpy_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHAR *strSource);
891 errno_t DLL_PREFIX my_strncpy_s(char *strDestination, size_t numberOfElements, const char *strSource, size_t count);
892 errno_t DLL_PREFIX my_tcsncpy_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHAR *strSource, size_t count);
893 char * DLL_PREFIX my_strtok_s(char *strToken, const char *strDelimit, char **context);
894 _TCHAR *DLL_PREFIX my_tcstok_s(_TCHAR *strToken, const char *strDelimit, _TCHAR **context);
895 #define my_fprintf_s fprintf
896 #define my_ftprintf_s fprintf
897 int DLL_PREFIX my_sprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, ...);
898 int DLL_PREFIX my_swprintf_s(wchar_t *buffer, size_t sizeOfBuffer, const wchar_t *format, ...);
899 int DLL_PREFIX my_stprintf_s(_TCHAR *buffer, size_t sizeOfBuffer, const _TCHAR *format, ...);
900 int DLL_PREFIX my_vsprintf_s(char *buffer, size_t numberOfElements, const char *format, va_list argptr);
901 int DLL_PREFIX my_vstprintf_s(_TCHAR *buffer, size_t numberOfElements, const _TCHAR *format, va_list argptr);
903 // #define my_tfopen_s _tfopen_s
904 #define my_tcscat_s _tcscat_s
905 #define my_strcpy_s strcpy_s
906 #define my_tcscpy_s _tcscpy_s
907 #define my_strncpy_s strncpy_s
908 #define my_tcsncpy_s _tcsncpy_s
909 #define my_strtok_s strtok_s
910 #define my_tcstok_s _tcstok_s
911 #define my_fprintf_s fprintf_s
912 #define my_ftprintf_s _ftprintf_s
913 #define my_sprintf_s sprintf_s
914 #define my_swprintf_s swprintf_s
915 #define my_stprintf_s _stprintf_s
916 #define my_vsprintf_s vsprintf_s
917 #define my_vstprintf_s _vstprintf_s
922 void *DLL_PREFIX my_memcpy(void *dst, void *src, size_t len);
924 #define my_memcpy memcpy
928 #if defined(__clang__)
929 #define __DECL_VECTORIZED_LOOP _Pragma("clang loop vectorize(enable) interleave(enable)")
930 #elif defined(__GNUC__)
931 #define __DECL_VECTORIZED_LOOP _Pragma("GCC ivdep")
933 #define __DECL_VECTORIZED_LOOP
936 // C99 math functions
938 #define my_isfinite _finite
939 #define my_log2(v) (log((double)(v)) / log(2.0))
942 #define my_isfinite std::isfinite
948 BOOL MyWritePrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString, LPCTSTR lpFileName);
949 DWORD MyGetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName);
950 UINT MyGetPrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nDefault, LPCTSTR lpFileName);
951 // used only in winmain and win32 osd class
952 // #define ZeroMemory(p,s) memset(p,0x00,s)
953 // #define CopyMemory(t,f,s) memcpy(t,f,s)
955 #define MyWritePrivateProfileString WritePrivateProfileString
956 #define MyGetPrivateProfileString GetPrivateProfileString
957 #define MyGetPrivateProfileInt GetPrivateProfileInt
961 #if !defined(_RGB555) && !defined(_RGB565) && !defined(_RGB888)
965 #if defined(_RGB555) || defined(_RGB565)
966 typedef uint16_t scrntype_t;
967 scrntype_t DLL_PREFIX RGB_COLOR(uint32_t r, uint32_t g, uint32_t b);
968 scrntype_t DLL_PREFIX RGBA_COLOR(uint32_t r, uint32_t g, uint32_t b, uint32_t a);
969 uint8_t DLL_PREFIX R_OF_COLOR(scrntype_t c);
970 uint8_t DLL_PREFIX G_OF_COLOR(scrntype_t c);
971 uint8_t DLL_PREFIX B_OF_COLOR(scrntype_t c);
972 uint8_t DLL_PREFIX A_OF_COLOR(scrntype_t c);
973 #elif defined(_RGB888)
974 typedef uint32_t scrntype_t;
975 #if defined(__LITTLE_ENDIAN__)
976 #define RGB_COLOR(r, g, b) (((uint32_t)(b) << 16) | ((uint32_t)(g) << 8) | ((uint32_t)(r) << 0) | (0xff << 24))
977 #define RGBA_COLOR(r, g, b, a) (((uint32_t)(b) << 16) | ((uint32_t)(g) << 8) | ((uint32_t)(r) << 0) | ((uint32_t)(a) << 24))
978 #define R_OF_COLOR(c) (((c) ) & 0xff)
979 #define G_OF_COLOR(c) (((c) >> 8) & 0xff)
980 #define B_OF_COLOR(c) (((c) >> 16) & 0xff)
981 #define A_OF_COLOR(c) (((c) >> 24) & 0xff)
983 #define RGB_COLOR(r, g, b) (((uint32_t)(r) << 16) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 0) | (0xff << 24))
984 #define RGBA_COLOR(r, g, b, a) (((uint32_t)(r) << 16) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 0) | ((uint32_t)(a) << 24))
985 #define R_OF_COLOR(c) (((c) >> 16) & 0xff)
986 #define G_OF_COLOR(c) (((c) >> 8) & 0xff)
987 #define B_OF_COLOR(c) (((c) ) & 0xff)
988 #define A_OF_COLOR(c) (((c) >> 24) & 0xff)
992 inline uint64_t ExchangeEndianU64(uint64_t __in)
1000 __o.b.h3 = __i.b.h4;
1001 __o.b.h2 = __i.b.h5;
1007 inline int64_t ExchangeEndianS64(uint64_t __in)
1013 __o.b.h5 = __i.b.h2;
1014 __o.b.h4 = __i.b.h3;
1015 __o.b.h3 = __i.b.h4;
1016 __o.b.h2 = __i.b.h5;
1021 inline uint32_t ExchangeEndianU32(uint32_t __in)
1032 inline int32_t ExchangeEndianS32(uint32_t __in)
1043 inline uint16_t ExchangeEndianU16(uint16_t __in)
1052 inline int16_t ExchangeEndianS16(uint16_t __in)
1071 wav_chunk_t riff_chunk;
1073 wav_chunk_t fmt_chunk;
1076 uint32_t sample_rate;
1077 uint32_t data_speed;
1078 uint16_t block_size;
1079 uint16_t sample_bits;
1083 // See http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html.
1086 wav_chunk_t riff_chunk;
1088 wav_chunk_t fmt_chunk;
1091 uint32_t sample_rate;
1092 uint32_t data_speed;
1093 uint16_t block_size;
1094 uint16_t sample_bits;
1095 uint16_t cbsize; // Extension size.Normaly set to 0.
1096 wav_chunk_t fact_chunk; // "fact", 4.
1097 } wav_header_float_t;
1100 // Use this before writing wav_data.
1101 bool DLL_PREFIX write_dummy_wav_header(void *__fio);
1102 // Use this after writng wav_data.
1103 bool DLL_PREFIX set_wav_header(wav_header_t *header, wav_chunk_t *first_chunk, uint16_t channels, uint32_t rate,
1104 uint16_t bits, size_t file_length);
1105 bool DLL_PREFIX load_wav_to_stereo(void *__fio, int16_t **left_buf, int16_t **right_buf, uint32_t *rate, int *got_samples);
1106 bool DLL_PREFIX load_wav_to_monoral(void *__fio, int16_t **buffer, uint32_t *rate, int *got_samples);
1109 const _TCHAR *DLL_PREFIX get_application_path();
1110 const _TCHAR *DLL_PREFIX create_local_path(const _TCHAR *format, ...);
1111 void DLL_PREFIX create_local_path(_TCHAR *file_path, int length, const _TCHAR *format, ...);
1112 const _TCHAR *DLL_PREFIX create_date_file_path(const _TCHAR *extension);
1113 bool DLL_PREFIX is_absolute_path(const _TCHAR *file_path);
1114 const _TCHAR *DLL_PREFIX create_absolute_path(const _TCHAR *file_name);
1115 void DLL_PREFIX create_absolute_path(_TCHAR *file_path, int length, const _TCHAR *file_name);
1116 void DLL_PREFIX create_date_file_path(_TCHAR *file_path, int length, const _TCHAR *extension);
1117 bool DLL_PREFIX check_file_extension(const _TCHAR *file_path, const _TCHAR *ext);
1118 const _TCHAR *DLL_PREFIX get_file_path_without_extensiton(const _TCHAR *file_path);
1119 void DLL_PREFIX get_long_full_path_name(const _TCHAR* src, _TCHAR* dst, size_t dst_len);
1120 const _TCHAR* DLL_PREFIX get_parent_dir(const _TCHAR* file);
1123 const _TCHAR *DLL_PREFIX create_string(const _TCHAR* format, ...);
1124 const wchar_t *DLL_PREFIX char_to_wchar(const char *cs);
1125 const char *DLL_PREFIX wchar_to_char(const wchar_t *ws);
1126 const _TCHAR *DLL_PREFIX char_to_tchar(const char *cs);
1127 const char *DLL_PREFIX tchar_to_char(const _TCHAR *ts);
1128 const _TCHAR *DLL_PREFIX wchar_to_tchar(const wchar_t *ws);
1129 const wchar_t *DLL_PREFIX tchar_to_wchar(const _TCHAR *ts);
1133 int32_t DLL_PREFIX muldiv_s32(int32_t nNumber, int32_t nNumerator, int32_t nDenominator);
1134 uint32_t DLL_PREFIX muldiv_u32(uint32_t nNumber, uint32_t nNumerator, uint32_t nDenominator);
1136 uint32_t DLL_PREFIX get_crc32(uint8_t data[], int size);
1137 uint32_t DLL_PREFIX calc_crc32(uint32_t seed, uint8_t data[], int size);
1138 uint16_t DLL_PREFIX jis_to_sjis(uint16_t jis);
1140 int DLL_PREFIX decibel_to_volume(int decibel);
1141 int32_t DLL_PREFIX apply_volume(int32_t sample, int volume);
1143 #define array_length(array) (sizeof(array) / sizeof(array[0]))
1145 #define FROM_BCD(v) (((v) & 0x0f) + (((v) >> 4) & 0x0f) * 10)
1146 #define TO_BCD(v) ((int)(((v) % 100) / 10) << 4) | ((v) % 10)
1147 #define TO_BCD_LO(v) ((v) % 10)
1148 #define TO_BCD_HI(v) (int)(((v) % 100) / 10)
1151 #define LEAP_YEAR(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
1153 #define dll_cur_time_t DLL_PREFIX_I struct cur_time_s
1155 typedef DLL_PREFIX struct cur_time_s {
1156 int year, month, day, day_of_week, hour, minute, second;
1160 initialized = false;
1164 void update_day_of_week();
1165 void save_state(void *f);
1166 bool load_state(void *f);
1167 void save_state_helper(void *f, uint32_t *sumseed, bool *__stat);
1168 bool load_state_helper(void *f, uint32_t *sumseed, bool *__stat);
1171 void DLL_PREFIX get_host_time(cur_time_t* cur_time);
1172 const _TCHAR DLL_PREFIX *get_lib_common_version();
1175 typedef struct symbol_s {
1178 struct symbol_s *next_symbol;
1181 const _TCHAR* DLL_PREFIX get_symbol(symbol_t *first_symbol, uint32_t addr);
1182 const _TCHAR* DLL_PREFIX get_value_or_symbol(symbol_t *first_symbol, const _TCHAR *format, uint32_t addr);
1183 const _TCHAR* DLL_PREFIX get_value_and_symbol(symbol_t *first_symbol, const _TCHAR *format, uint32_t addr);