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)
30 // check environemnt/language
33 // Microsoft Visual C++
35 // variable scope of 'for' loop for Microsoft Visual C++ 6.0
36 #define for if(0);else for
39 // Microsoft Visual C++ 6.0 or later
40 #define SUPPORT_TCHAR_TYPE
43 // Microsoft Visual C++ 8.0 (2005) or later
44 #define SUPPORT_SECURE_FUNCTIONS
45 #pragma warning( disable : 4819 )
46 //#pragma warning( disable : 4995 )
47 #pragma warning( disable : 4996 )
50 // Microsoft Visual C++ 12.0 (2013) or later
51 #define SUPPORT_CPLUSPLUS_11
53 #define CSP_OS_WINDOWS
55 // Win32, but not Microsoft Visual C++
56 #define SUPPORT_TCHAR_TYPE
57 // #define SUPPORT_SECURE_FUNCTIONS
61 #if defined(Q_OS_CYGWIN)
62 #define CSP_OS_GCC_CYGWIN
63 #define CSP_OS_WINDOWS
64 #elif defined(Q_OS_WIN) || defined(__WIN32) || defined(__WIN64)
65 #define CSP_OS_GCC_WINDOWS
66 #define CSP_OS_WINDOWS
68 #define DLL_PREFIX __declspec(dllexport)
69 #define DLL_PREFIX_I __declspec(dllimport)
72 #define CSP_OS_GCC_GENERIC
73 #define CSP_OS_GENERIC
77 #if defined(__clang__)
78 #define __CSP_COMPILER_CLANG
80 #define __CSP_COMPILER_GCC
82 #define SUPPORT_CPLUSPLUS_11
88 #ifndef SUPPORT_CPLUSPLUS_11
89 #if defined(__cplusplus) && (__cplusplus > 199711L)
90 #define SUPPORT_CPLUSPLUS_11
93 #ifndef SUPPORT_TCHAR_TYPE
94 // secure functions need tchar type
95 #undef SUPPORT_SECURE_FUNCTIONS
104 // include common header files
105 #ifdef SUPPORT_TCHAR_TYPE
108 #ifdef SUPPORT_CPLUSPLUS_11
115 #include <typeinfo.h>
122 // include environment/language dependent header files
125 #include <windowsx.h>
127 #include <mmsystem.h>
138 #if defined(__MINGW32__) || (__MINGW64__)
143 #include <QtCore/QString>
144 #include <QtCore/QFile>
146 #include <sys/param.h>
149 #define _MAX_PATH 2048
153 #if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
154 #if defined(__BYTE_ORDER) && (defined(__LITTLE_ENDIAN) || defined(__BIG_ENDIAN))
155 #if __BYTE_ORDER == __LITTLE_ENDIAN
156 #define __LITTLE_ENDIAN__
157 #elif __BYTE_ORDER == __BIG_ENDIAN
158 #define __BIG_ENDIAN__
160 #elif defined(SDL_BYTEORDER) && (defined(SDL_LIL_ENDIAN) || defined(SDL_BIG_ENDIAN))
161 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
162 #define __LITTLE_ENDIAN__
163 #elif SDL_BYTEORDER == SDL_BIG_ENDIAN
164 #define __BIG_ENDIAN__
166 #elif defined(WORDS_LITTLEENDIAN)
167 #define __LITTLE_ENDIAN__
168 #elif defined(WORDS_BIGENDIAN)
169 #define __BIG_ENDIAN__
172 #if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
173 // may be Microsoft Visual C++
174 #define __LITTLE_ENDIAN__
178 #ifndef SUPPORT_TCHAR_TYPE
184 #ifndef SUPPORT_CPLUSPLUS_11
186 typedef signed char int8_t;
189 typedef signed short int16_t;
192 typedef signed int int32_t;
195 typedef signed long long int64_t;
198 typedef unsigned char uint8_t;
201 typedef unsigned short uint16_t;
204 typedef unsigned int uint32_t;
207 typedef unsigned long long uint64_t;
213 typedef _TCHAR* LPTSTR;
216 typedef const _TCHAR* LPCTSTR;
228 typedef uint8_t BYTE;
231 typedef uint16_t WORD;
234 typedef uint32_t DWORD;
237 typedef uint64_t QWORD;
243 typedef int16_t INT16;
246 typedef int32_t INT32;
249 typedef int64_t INT64;
252 typedef uint8_t UINT8;
255 typedef uint16_t UINT16;
258 typedef uint32_t UINT32;
261 typedef uint64_t UINT64;
267 typedef unsigned int UINT;
273 #ifdef __BIG_ENDIAN__
280 #ifdef __BIG_ENDIAN__
289 inline void read_2bytes_le_from(uint8_t *t)
291 b.l = t[0]; b.h = t[1];
293 inline void write_2bytes_le_to(uint8_t *t)
295 t[0] = b.l; t[1] = b.h;
297 inline void read_2bytes_be_from(uint8_t *t)
299 b.h = t[0]; b.l = t[1];
301 inline void write_2bytes_be_to(uint8_t *t)
303 t[0] = b.h; t[1] = b.l;
306 inline void set_2bytes_be_from(uint16_t n)
315 b.l = bigv.b.l; b.h = bigv.b.h;
317 inline void set_2bytes_le_from(uint16_t n)
326 b.l = littlev.b.l; b.h = littlev.b.h;
328 inline uint16_t get_2bytes_be_to()
336 bigv.b.l = b.l; bigv.b.h = b.h;
339 inline uint16_t get_2bytes_le_to()
347 littlev.b.l = b.l; littlev.b.h = b.h;
355 #ifdef __BIG_ENDIAN__
356 uint8_t h3, h2, h, l;
358 uint8_t l, h, h2, h3;
362 #ifdef __BIG_ENDIAN__
369 #ifdef __BIG_ENDIAN__
376 #ifdef __BIG_ENDIAN__
383 #ifdef __BIG_ENDIAN__
391 inline void read_2bytes_le_from(uint8_t *t)
393 b.l = t[0]; b.h = t[1]; b.h2 = b.h3 = 0;
395 inline void write_2bytes_le_to(uint8_t *t)
397 t[0] = b.l; t[1] = b.h;
399 inline void read_2bytes_be_from(uint8_t *t)
401 b.h3 = b.h2 = 0; b.h = t[0]; b.l = t[1];
403 inline void write_2bytes_be_to(uint8_t *t)
405 t[0] = b.h; t[1] = b.l;
407 inline void read_4bytes_le_from(uint8_t *t)
409 b.l = t[0]; b.h = t[1]; b.h2 = t[2]; b.h3 = t[3];
411 inline void write_4bytes_le_to(uint8_t *t)
413 t[0] = b.l; t[1] = b.h; t[2] = b.h2; t[3] = b.h3;
415 inline void read_4bytes_be_from(uint8_t *t)
417 b.h3 = t[0]; b.h2 = t[1]; b.h = t[2]; b.l = t[3];
419 inline void write_4bytes_be_to(uint8_t *t)
421 t[0] = b.h3; t[1] = b.h2; t[2] = b.h; t[3] = b.l;
424 inline void set_2bytes_be_from(uint16_t n)
433 b.l = bigv.b.l; b.h = bigv.b.h;
436 inline void set_2bytes_le_from(uint16_t n)
445 b.l = littlev.b.l; b.h = littlev.b.h;
448 inline uint16_t get_2bytes_be_to()
456 bigv.b.l = b.l; bigv.b.h = b.h;
459 inline uint16_t get_2bytes_le_to()
467 littlev.b.l = b.l; littlev.b.h = b.h;
471 inline void set_4bytes_be_from(uint32_t n)
476 uint8_t h3, h2, h, l;
480 b.l = bigv.b.l; b.h = bigv.b.h; b.h2 = bigv.b.h2; b.h3 = bigv.b.h3;
482 inline void set_4bytes_le_from(uint32_t n)
487 uint8_t l, h, h2, h3;
491 b.l = littlev.b.l; b.h = littlev.b.h; b.h2 = littlev.b.h2; b.h3 = littlev.b.h3;
493 inline uint32_t get_4bytes_be_to()
498 uint8_t h3, h2, h, l;
501 bigv.b.l = b.l; bigv.b.h = b.h; bigv.b.h2 = b.h2; bigv.b.h3 = b.h3;
504 inline uint32_t get_4bytes_le_to()
509 uint8_t l, h, h2, h3;
512 littlev.b.l = b.l; littlev.b.h = b.h; littlev.b.h2 = b.h2; littlev.b.h3 = b.h3;
520 #ifdef __BIG_ENDIAN__
521 uint8_t h7, h6, h5, h4, h3, h2, h, l;
523 uint8_t l, h, h2, h3, h4, h5, h6, h7;
527 #ifdef __BIG_ENDIAN__
528 int8_t h7, h6, h5, h4, h3, h2, h, l;
530 int8_t l, h, h2, h3, h4, h5, h6, h7;
534 #ifdef __BIG_ENDIAN__
535 uint16_t h3, h2, h, l;
537 uint16_t l, h, h2, h3;
541 #ifdef __BIG_ENDIAN__
542 int16_t h3, h2, h, l;
544 int16_t l, h, h2, h3;
548 #ifdef __BIG_ENDIAN__
549 pair16_t h3, h2, h, l;
551 pair16_t l, h, h2, h3;
555 #ifdef __BIG_ENDIAN__
562 #ifdef __BIG_ENDIAN__
569 #ifdef __BIG_ENDIAN__
578 inline void read_2bytes_le_from(uint8_t *t)
580 b.l = t[0]; b.h = t[1]; b.h2 = b.h3 = 0;
581 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
583 inline void write_2bytes_le_to(uint8_t *t)
585 t[0] = b.l; t[1] = b.h;
587 inline void read_2bytes_be_from(uint8_t *t)
589 b.h3 = b.h2 = 0; b.h = t[0]; b.l = t[1];
590 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
592 inline void write_2bytes_be_to(uint8_t *t)
594 t[0] = b.h; t[1] = b.l;
596 inline void read_4bytes_le_from(uint8_t *t)
598 b.l = t[0]; b.h = t[1]; b.h2 = t[2]; b.h3 = t[3];
599 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
601 inline void write_4bytes_le_to(uint8_t *t)
603 t[0] = b.l; t[1] = b.h; t[2] = b.h2; t[3] = b.h3;
605 inline void read_4bytes_be_from(uint8_t *t)
607 b.h3 = t[0]; b.h2 = t[1]; b.h = t[2]; b.l = t[3];
608 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
610 inline void write_4bytes_be_to(uint8_t *t)
612 t[0] = b.h3; t[1] = b.h2; t[2] = b.h; t[3] = b.l;
615 inline void read_8bytes_le_from(uint8_t *t)
617 b.l = t[0]; b.h = t[1]; b.h2 = t[2]; b.h3 = t[3];
618 b.h4 = t[4]; b.h5 = t[5]; b.h6 = t[6]; b.h7 = t[7];
620 inline void write_8bytes_le_to(uint8_t *t)
622 t[0] = b.l; t[1] = b.h; t[2] = b.h2; t[3] = b.h3;
623 t[4] = b.h4; t[5] = b.h5; t[6] = b.h6; t[7] = b.h7;
625 inline void read_8bytes_be_from(uint8_t *t)
627 b.h7 = t[0]; b.h6 = t[1]; b.h5 = t[2]; b.h4 = t[3];
628 b.h3 = t[4]; b.h2 = t[5]; b.h = t[6]; b.l = t[7];
630 inline void write_8bytes_be_to(uint8_t *t)
632 t[0] = b.h7; t[1] = b.h6; t[2] = b.h5; t[3] = b.h4;
633 t[4] = b.h3; t[5] = b.h2; t[6] = b.h; t[7] = b.l;
636 inline void set_2bytes_be_from(uint16_t n)
645 b.l = bigv.b.l; b.h = bigv.b.h;
647 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
649 inline void set_2bytes_le_from(uint16_t n)
658 b.l = littlev.b.l; b.h = littlev.b.h;
660 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
662 inline uint16_t get_2bytes_be_to()
670 bigv.b.l = b.l; bigv.b.h = b.h;
673 inline uint16_t get_2bytes_le_to()
681 littlev.b.l = b.l; littlev.b.h = b.h;
685 inline void set_4bytes_be_from(uint32_t n)
690 uint8_t h3, h2, h, l;
694 b.l = bigv.b.l; b.h = bigv.b.h; b.h2 = bigv.b.h2; b.h3 = bigv.b.h3;
695 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
697 inline void set_4bytes_le_from(uint32_t n)
702 uint8_t l, h, h2, h3;
706 b.l = littlev.b.l; b.h = littlev.b.h; b.h2 = littlev.b.h2; b.h3 = littlev.b.h3;
707 b.h4 = 0; b.h5 = 0; b.h6 = 0; b.h7 = 0;
709 inline uint32_t get_4bytes_be_to()
714 uint8_t h3, h2, h, l;
717 bigv.b.l = b.l; bigv.b.h = b.h; bigv.b.h2 = b.h2; bigv.b.h3 = b.h3;
720 inline uint32_t get_4bytes_le_to()
725 uint8_t l, h, h2, h3;
728 littlev.b.l = b.l; littlev.b.h = b.h; littlev.b.h2 = b.h2; littlev.b.h3 = b.h3;
732 inline void set_8bytes_be_from(uint64_t n)
737 uint8_t h7, h6, h5, h4, h3, h2, h, l;
741 b.l = bigv.b.l; b.h = bigv.b.h; b.h2 = bigv.b.h2; b.h3 = bigv.b.h3;
742 b.h4 = bigv.b.h4; b.h5 = bigv.b.h5; b.h6 = bigv.b.h6; b.h7 = bigv.b.h7;
744 inline void set_8bytes_le_from(uint64_t n)
749 uint8_t l, h, h2, h3, h4, h5, h6, h7;
753 b.l = littlev.b.l; b.h = littlev.b.h; b.h2 = littlev.b.h2; b.h3 = littlev.b.h3;
754 b.h4 = littlev.b.h4; b.h5 = littlev.b.h5; b.h6 = littlev.b.h6; b.h7 = littlev.b.h7;
756 inline uint64_t get_8bytes_be_to()
761 uint8_t h7, h6, h5, h4, h3, h2, h, l;
764 bigv.b.l = b.l; bigv.b.h = b.h; bigv.b.h2 = b.h2; bigv.b.h3 = b.h3;
765 bigv.b.h4 = b.h4; bigv.b.h5 = b.h5; bigv.b.h6 = b.h6; bigv.b.h7 = b.h7;
768 inline uint64_t get_8bytes_le_to()
773 uint8_t l, h, h2, h3, h4, h5, h6, h7;
776 littlev.b.l = b.l; littlev.b.h = b.h; littlev.b.h2 = b.h2; littlev.b.h3 = b.h3;
777 littlev.b.h4 = b.h4; littlev.b.h5 = b.h5; littlev.b.h6 = b.h6; littlev.b.h7 = b.h7;
783 uint32_t DLL_PREFIX EndianToLittle_DWORD(uint32_t x);
784 uint16_t DLL_PREFIX EndianToLittle_WORD(uint16_t x);
790 int DLL_PREFIX max(int a, int b);
791 unsigned int DLL_PREFIX max(unsigned int a, unsigned int b);
792 int DLL_PREFIX min(int a, int b);
793 unsigned int DLL_PREFIX min(unsigned int a, unsigned int b);
797 #if defined(__GNUC__) || defined(__CYGWIN__) || defined(Q_OS_CYGWIN)
798 #define stricmp(a,b) strcasecmp(a,b)
799 #define strnicmp(a,b,n) strncasecmp(a,b,n)
802 #ifndef SUPPORT_TCHAR_TYPE
804 #define _fgetts fgets
807 #define _ftprintf printf
810 #define _tfopen fopen
813 #define _tcscmp strcmp
816 #define _tcscpy strcpy
819 #define _tcsicmp stricmp
822 #define _tcslen strlen
825 #define _tcscat strcat
828 #define _tcsncat strncat
831 #define _tcsncpy strncpy
834 #define _tcsncicmp strnicmp
837 #define _tcschr strchr
840 #define _tcsrchr strrchr
843 #define _tcsstr strstr
846 #define _tcstok strtok
852 #define _tcstol strtol
855 #define _tcstoul strtoul
858 #define _stprintf sprintf
861 #define _vstprintf vsprintf
864 #define _taccess access
867 #define _tremove remove
870 #define _trename rename
874 #define _TEXT(x) __T(x)
877 #ifndef SUPPORT_SECURE_FUNCTIONS
881 // errno_t DLL_PREFIX my_tfopen_s(FILE** pFile, const _TCHAR *filename, const _TCHAR *mode);
882 errno_t DLL_PREFIX my_tcscat_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHAR *strSource);
883 errno_t DLL_PREFIX my_strcpy_s(char *strDestination, size_t numberOfElements, const char *strSource);
884 errno_t DLL_PREFIX my_tcscpy_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHAR *strSource);
885 errno_t DLL_PREFIX my_strncpy_s(char *strDestination, size_t numberOfElements, const char *strSource, size_t count);
886 errno_t DLL_PREFIX my_tcsncpy_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHAR *strSource, size_t count);
887 char * DLL_PREFIX my_strtok_s(char *strToken, const char *strDelimit, char **context);
888 _TCHAR *DLL_PREFIX my_tcstok_s(_TCHAR *strToken, const char *strDelimit, _TCHAR **context);
889 #define my_fprintf_s fprintf
890 #define my_ftprintf_s fprintf
891 int DLL_PREFIX my_sprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, ...);
892 int DLL_PREFIX my_swprintf_s(wchar_t *buffer, size_t sizeOfBuffer, const wchar_t *format, ...);
893 int DLL_PREFIX my_stprintf_s(_TCHAR *buffer, size_t sizeOfBuffer, const _TCHAR *format, ...);
894 int DLL_PREFIX my_vsprintf_s(char *buffer, size_t numberOfElements, const char *format, va_list argptr);
895 int DLL_PREFIX my_vstprintf_s(_TCHAR *buffer, size_t numberOfElements, const _TCHAR *format, va_list argptr);
897 // #define my_tfopen_s _tfopen_s
898 #define my_tcscat_s _tcscat_s
899 #define my_strcpy_s strcpy_s
900 #define my_tcscpy_s _tcscpy_s
901 #define my_strncpy_s strncpy_s
902 #define my_tcsncpy_s _tcsncpy_s
903 #define my_strtok_s strtok_s
904 #define my_tcstok_s _tcstok_s
905 #define my_fprintf_s fprintf_s
906 #define my_ftprintf_s _ftprintf_s
907 #define my_sprintf_s sprintf_s
908 #define my_swprintf_s swprintf_s
909 #define my_stprintf_s _stprintf_s
910 #define my_vsprintf_s vsprintf_s
911 #define my_vstprintf_s _vstprintf_s
916 void *DLL_PREFIX my_memcpy(void *dst, void *src, size_t len);
918 #define my_memcpy memcpy
922 #if defined(__clang__)
923 #define __DECL_VECTORIZED_LOOP _Pragma("clang loop vectorize(enable) interleave(enable)")
924 #elif defined(__GNUC__)
925 #define __DECL_VECTORIZED_LOOP _Pragma("GCC ivdep")
927 #define __DECL_VECTORIZED_LOOP
930 // C99 math functions
932 #define my_isfinite _finite
933 #define my_log2(v) (log((double)(v)) / log(2.0))
936 #define my_isfinite std::isfinite
942 BOOL MyWritePrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString, LPCTSTR lpFileName);
943 DWORD MyGetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName);
944 UINT MyGetPrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nDefault, LPCTSTR lpFileName);
945 // used only in winmain and win32 osd class
946 // #define ZeroMemory(p,s) memset(p,0x00,s)
947 // #define CopyMemory(t,f,s) memcpy(t,f,s)
949 #define MyWritePrivateProfileString WritePrivateProfileString
950 #define MyGetPrivateProfileString GetPrivateProfileString
951 #define MyGetPrivateProfileInt GetPrivateProfileInt
955 #if !defined(_RGB555) && !defined(_RGB565) && !defined(_RGB888)
959 #if defined(_RGB555) || defined(_RGB565)
960 typedef uint16_t scrntype_t;
961 scrntype_t DLL_PREFIX RGB_COLOR(uint32_t r, uint32_t g, uint32_t b);
962 scrntype_t DLL_PREFIX RGBA_COLOR(uint32_t r, uint32_t g, uint32_t b, uint32_t a);
963 uint8_t DLL_PREFIX R_OF_COLOR(scrntype_t c);
964 uint8_t DLL_PREFIX G_OF_COLOR(scrntype_t c);
965 uint8_t DLL_PREFIX B_OF_COLOR(scrntype_t c);
966 uint8_t DLL_PREFIX A_OF_COLOR(scrntype_t c);
967 #elif defined(_RGB888)
968 typedef uint32_t scrntype_t;
969 #define RGB_COLOR(r, g, b) (((uint32_t)(r) << 16) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 0))
970 #define RGBA_COLOR(r, g, b, a) (((uint32_t)(r) << 16) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 0) | ((uint32_t)(a) << 24))
971 #define R_OF_COLOR(c) (((c) >> 16) & 0xff)
972 #define G_OF_COLOR(c) (((c) >> 8) & 0xff)
973 #define B_OF_COLOR(c) (((c) ) & 0xff)
974 #define A_OF_COLOR(c) (((c) >> 24) & 0xff)
977 inline uint64_t ExchangeEndianU64(uint64_t __in)
992 inline int64_t ExchangeEndianS64(uint64_t __in)
1000 __o.b.h3 = __i.b.h4;
1001 __o.b.h2 = __i.b.h5;
1006 inline uint32_t ExchangeEndianU32(uint32_t __in)
1017 inline int32_t ExchangeEndianS32(uint32_t __in)
1028 inline uint16_t ExchangeEndianU16(uint16_t __in)
1037 inline int16_t ExchangeEndianS16(uint16_t __in)
1056 wav_chunk_t riff_chunk;
1058 wav_chunk_t fmt_chunk;
1061 uint32_t sample_rate;
1062 uint32_t data_speed;
1063 uint16_t block_size;
1064 uint16_t sample_bits;
1069 const _TCHAR *DLL_PREFIX get_application_path();
1070 const _TCHAR *DLL_PREFIX create_local_path(const _TCHAR *format, ...);
1071 void DLL_PREFIX create_local_path(_TCHAR *file_path, int length, const _TCHAR *format, ...);
1072 const _TCHAR *DLL_PREFIX create_date_file_path(const _TCHAR *extension);
1073 bool DLL_PREFIX is_absolute_path(const _TCHAR *file_path);
1074 const _TCHAR *DLL_PREFIX create_absolute_path(const _TCHAR *file_name);
1075 void DLL_PREFIX create_absolute_path(_TCHAR *file_path, int length, const _TCHAR *file_name);
1076 void DLL_PREFIX create_date_file_path(_TCHAR *file_path, int length, const _TCHAR *extension);
1077 bool DLL_PREFIX check_file_extension(const _TCHAR *file_path, const _TCHAR *ext);
1078 const _TCHAR *DLL_PREFIX get_file_path_without_extensiton(const _TCHAR *file_path);
1079 void DLL_PREFIX get_long_full_path_name(const _TCHAR* src, _TCHAR* dst, size_t dst_len);
1080 const _TCHAR* DLL_PREFIX get_parent_dir(const _TCHAR* file);
1083 const _TCHAR *DLL_PREFIX create_string(const _TCHAR* format, ...);
1084 const wchar_t *DLL_PREFIX char_to_wchar(const char *cs);
1085 const char *DLL_PREFIX wchar_to_char(const wchar_t *ws);
1086 const _TCHAR *DLL_PREFIX char_to_tchar(const char *cs);
1087 const char *DLL_PREFIX tchar_to_char(const _TCHAR *ts);
1088 const _TCHAR *DLL_PREFIX wchar_to_tchar(const wchar_t *ws);
1089 const wchar_t *DLL_PREFIX tchar_to_wchar(const _TCHAR *ts);
1093 int32_t DLL_PREFIX muldiv_s32(int32_t nNumber, int32_t nNumerator, int32_t nDenominator);
1094 uint32_t DLL_PREFIX muldiv_u32(uint32_t nNumber, uint32_t nNumerator, uint32_t nDenominator);
1096 uint32_t DLL_PREFIX get_crc32(uint8_t data[], int size);
1097 uint32_t DLL_PREFIX calc_crc32(uint32_t seed, uint8_t data[], int size);
1098 uint16_t DLL_PREFIX jis_to_sjis(uint16_t jis);
1100 int DLL_PREFIX decibel_to_volume(int decibel);
1101 int32_t DLL_PREFIX apply_volume(int32_t sample, int volume);
1103 #define array_length(array) (sizeof(array) / sizeof(array[0]))
1105 #define FROM_BCD(v) (((v) & 0x0f) + (((v) >> 4) & 0x0f) * 10)
1106 #define TO_BCD(v) ((int)(((v) % 100) / 10) << 4) | ((v) % 10)
1107 #define TO_BCD_LO(v) ((v) % 10)
1108 #define TO_BCD_HI(v) (int)(((v) % 100) / 10)
1111 #define LEAP_YEAR(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
1113 #define dll_cur_time_t DLL_PREFIX_I struct cur_time_s
1115 typedef DLL_PREFIX struct cur_time_s {
1116 int year, month, day, day_of_week, hour, minute, second;
1120 initialized = false;
1124 void update_day_of_week();
1125 void save_state(void *f);
1126 bool load_state(void *f);
1127 void save_state_helper(void *f, uint32_t *sumseed, bool *__stat);
1128 bool load_state_helper(void *f, uint32_t *sumseed, bool *__stat);
1131 void DLL_PREFIX get_host_time(cur_time_t* cur_time);
1134 typedef struct symbol_s {
1137 struct symbol_s *next_symbol;
1140 const _TCHAR* DLL_PREFIX get_symbol(symbol_t *first_symbol, uint32_t addr);
1141 const _TCHAR* DLL_PREFIX get_value_or_symbol(symbol_t *first_symbol, const _TCHAR *format, uint32_t addr);
1142 const _TCHAR* DLL_PREFIX get_value_and_symbol(symbol_t *first_symbol, const _TCHAR *format, uint32_t addr);