From ab065a51113b86d45a5bacc543dc61b5e78fbae0 Mon Sep 17 00:00:00 2001 From: dgis Date: Wed, 21 Nov 2018 22:21:27 +0000 Subject: [PATCH] --- app/CMakeLists.txt | 14 +- app/src/main/cpp/android-layer.c | 9 + app/src/main/cpp/win32-layer.c | 348 ++++++++++++++++++++----------- app/src/main/cpp/win32-layer.h | 239 +++++++++++++++++---- 4 files changed, 438 insertions(+), 172 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 2ad7e25..c21fb8e 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -28,17 +28,17 @@ add_library( # Sets the name of the library. # src/main/cpp/debugger.c # src/main/cpp/disasm.c src/main/cpp/dismem.c - src/main/cpp/display.c #-> To rewrite +# src/main/cpp/display.c #-> To rewrite src/main/cpp/disrpl.c # src/main/cpp/Emu48.c #-> To rewrite src/main/cpp/engine.c src/main/cpp/external.c src/main/cpp/fetch.c - src/main/cpp/files.c #TODO +# src/main/cpp/files.c #TODO src/main/cpp/i28f160.c src/main/cpp/keyboard.c # src/main/cpp/keymacro.c - src/main/cpp/kml.c #TODO +# src/main/cpp/kml.c #-> To rewrite or TODO src/main/cpp/lodepng.c src/main/cpp/lowbat.c src/main/cpp/mops.c @@ -48,13 +48,13 @@ add_library( # Sets the name of the library. # src/main/cpp/redeye.c src/main/cpp/rpl.c # src/main/cpp/serial.c - src/main/cpp/settings.c #TODO + src/main/cpp/settings.c # src/main/cpp/sndenum.c # src/main/cpp/sound.c src/main/cpp/stack.c - src/main/cpp/symbfile.c #TODO - src/main/cpp/timer.c #TODO - src/main/cpp/udp.c #TODO + src/main/cpp/symbfile.c + src/main/cpp/timer.c +# src/main/cpp/udp.c src/main/cpp/emu48-jni.c diff --git a/app/src/main/cpp/android-layer.c b/app/src/main/cpp/android-layer.c index 7b690b2..e7a0d19 100644 --- a/app/src/main/cpp/android-layer.c +++ b/app/src/main/cpp/android-layer.c @@ -86,3 +86,12 @@ HRGN hRgn = NULL; //BOOL bClientWinMove = FALSE; // emulator window can be moved over client area //BOOL bSingleInstance = FALSE; // multiple emulator instances allowed +// udp.c + +VOID ResetUdp(VOID) { + return; +} + +BOOL SendByteUdp(BYTE byData) { + return FALSE; +} \ No newline at end of file diff --git a/app/src/main/cpp/win32-layer.c b/app/src/main/cpp/win32-layer.c index c62bc9f..bb35b97 100644 --- a/app/src/main/cpp/win32-layer.c +++ b/app/src/main/cpp/win32-layer.c @@ -1,18 +1,19 @@ #include "pch.h" -#include +//#include #include +#include HANDLE hWnd; LPTSTR szTitle; -static NSMutableDictionary *gEventLockDict; +//static NSMutableDictionary *gEventLockDict; static HANDLE gEventId; BOOL SetCurrentDirectory(LPCTSTR path) { - if(nil==path) - return NO; + if(path == NULL) + return FALSE; return chdir(path); } @@ -38,29 +39,60 @@ int CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPV } fd = open(lpFileName, flags, perm); - if (-1 != fd && 0 != dwShareMode) - { - // Not specifiying shared write means non-shared (exclusive) write - if (0 == (dwShareMode & FILE_SHARE_WRITE)) - lock.l_type = F_WRLCK; - else if (0 != (dwShareMode & FILE_SHARE_READ)) - lock.l_type = F_RDLCK; - - // Lock entire file - lock.l_len = lock.l_start = 0; - lock.l_whence = SEEK_SET; - - if (-1 == fcntl(fd, F_SETLK, &lock) && - (EACCES == errno || EAGAIN == errno)) - { - close(fd); - return -1; - } - } +// if (-1 != fd && 0 != dwShareMode) +// { +// // Not specifiying shared write means non-shared (exclusive) write +// if (0 == (dwShareMode & FILE_SHARE_WRITE)) +// lock.l_type = F_WRLCK; +// else if (0 != (dwShareMode & FILE_SHARE_READ)) +// lock.l_type = F_RDLCK; +// +// // Lock entire file +// lock.l_len = lock.l_start = 0; +// lock.l_whence = SEEK_SET; +// +// if (-1 == fcntl(fd, F_SETLK, &lock) && (EACCES == errno || EAGAIN == errno)) +// { +// close(fd); +// return -1; +// } +// } return fd; } +BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped) { + return FALSE; +} + +DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod) { + return 0; +} + +DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) { + return 0; +} + +BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped) { + return FALSE; +} + +HANDLE CreateFileMapping(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCSTR lpName) { + return NULL; +} + +LPVOID MapViewOfFile(HANDLE hFileMappingObject,DWORD dwDesiredAccess, DWORD dwFileOffsetHigh,DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap) { + return NULL; +} + +BOOL UnmapViewOfFile(LPCVOID lpBaseAddress) { + return NULL; +} + +BOOL SetEndOfFile(HANDLE hFile) { + return FALSE; +} + /* OSErr ReadFile(FSPtr &file, void *buf, SInt64 size, void *, void *) { @@ -245,66 +277,86 @@ void SetTimer(void *, TimerType id, int msec, void *) } */ +BOOL GetOpenFileName(LPOPENFILENAME openFilename) { + //TODO + return FALSE; +} +BOOL GetSaveFileName(LPOPENFILENAME openFilename) { + //TODO + return FALSE; +} + +HANDLE LoadImage(HINSTANCE hInst, LPCSTR name, UINT type, int cx, int cy, UINT fuLoad) { + //TODO + return NULL; +} + +LRESULT SendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { + //TODO + return NULL; +} + + int MessageBox(HANDLE h, LPCTSTR szMessage, LPCTSTR title, int flags) { int result = IDOK; -#if !TARGET_OS_IPHONE - NSAlert *alert = [[NSAlert alloc] init]; - [alert setMessageText: NSLocalizedString([NSString stringWithUTF8String: szMessage],@"")]; - if (0 != (flags & MB_OK)) - { - [alert addButtonWithTitle: NSLocalizedString(@"OK",@"")]; - } - else if (0 != (flags & MB_YESNO)) - { - [alert addButtonWithTitle: NSLocalizedString(@"Yes",@"")]; - [alert addButtonWithTitle: NSLocalizedString(@"No",@"")]; - } - else if (0 != (flags & MB_YESNOCANCEL)) - { - [alert addButtonWithTitle: NSLocalizedString(@"Yes",@"")]; - [alert addButtonWithTitle: NSLocalizedString(@"Cancel",@"")]; - [alert addButtonWithTitle: NSLocalizedString(@"No",@"")]; - } - - if (0 != (flags & MB_ICONSTOP)) - [alert setAlertStyle: NSAlertStyleCritical]; - else if (0 != (flags & MB_ICONINFORMATION)) - [alert setAlertStyle: NSAlertStyleInformational]; - - result = (int)[alert runModal]; - [alert release]; - - if (0 != (flags & MB_OK)) - result = IDOK; - else if (0 != (flags & MB_YESNO)) - result = NSAlertFirstButtonReturn ? IDYES : IDNO; - else if (0 != (flags & MB_YESNOCANCEL)) - result = NSAlertFirstButtonReturn ? IDYES : - NSAlertSecondButtonReturn ? IDCANCEL : IDNO; -#endif +//#if !TARGET_OS_IPHONE +// NSAlert *alert = [[NSAlert alloc] init]; +// [alert setMessageText: NSLocalizedString([NSString stringWithUTF8String: szMessage],@"")]; +// if (0 != (flags & MB_OK)) +// { +// [alert addButtonWithTitle: NSLocalizedString(@"OK",@"")]; +// } +// else if (0 != (flags & MB_YESNO)) +// { +// [alert addButtonWithTitle: NSLocalizedString(@"Yes",@"")]; +// [alert addButtonWithTitle: NSLocalizedString(@"No",@"")]; +// } +// else if (0 != (flags & MB_YESNOCANCEL)) +// { +// [alert addButtonWithTitle: NSLocalizedString(@"Yes",@"")]; +// [alert addButtonWithTitle: NSLocalizedString(@"Cancel",@"")]; +// [alert addButtonWithTitle: NSLocalizedString(@"No",@"")]; +// } +// +// if (0 != (flags & MB_ICONSTOP)) +// [alert setAlertStyle: NSAlertStyleCritical]; +// else if (0 != (flags & MB_ICONINFORMATION)) +// [alert setAlertStyle: NSAlertStyleInformational]; +// +// result = (int)[alert runModal]; +// [alert release]; +// +// if (0 != (flags & MB_OK)) +// result = IDOK; +// else if (0 != (flags & MB_YESNO)) +// result = NSAlertFirstButtonReturn ? IDYES : IDNO; +// else if (0 != (flags & MB_YESNOCANCEL)) +// result = NSAlertFirstButtonReturn ? IDYES : +// NSAlertSecondButtonReturn ? IDCANCEL : IDNO; +//#endif return result; } BOOL QueryPerformanceFrequency(PLARGE_INTEGER l) { - static struct mach_timebase_info timebase = { 0, 0 }; - if (0 == timebase.denom) - mach_timebase_info(&timebase); -// l->LowPart = 1e9 * timebase.denom / timebase.numer; - l->QuadPart=1000000; +// static struct mach_timebase_info timebase = { 0, 0 }; +// if (0 == timebase.denom) +// mach_timebase_info(&timebase); +//// l->LowPart = 1e9 * timebase.denom / timebase.numer; +// l->QuadPart=1000000; return TRUE; } BOOL QueryPerformanceCounter(PLARGE_INTEGER l) { - l->QuadPart = mach_absolute_time() / 1000; +// l->QuadPart = mach_absolute_time() / 1000; return TRUE; } DWORD timeGetTime(void) { - time_t t = time(nil); + time_t t = time(NULL); return (DWORD)(t * 1000); } @@ -322,90 +374,90 @@ void LeaveCriticalSection(CRITICAL_SECTION *lock) // https://github.com/NeoSmart/PEvents HANDLE CreateEvent(WORD attr, BOOL is_manual_reset, BOOL is_signaled, WORD name) { - if (nil == gEventLockDict) - { - gEventLockDict = [[NSMutableDictionary alloc] init]; - } - ++gEventId; - NSNumber *key = [[NSNumber alloc] initWithInt: gEventId]; - NSConditionLock *lock = [[NSConditionLock alloc] initWithCondition: 0]; - [gEventLockDict setObject:lock forKey:key]; - [lock release]; - [key release]; -// if (NULL == gEventLock) +// if (nil == gEventLockDict) // { -// gEventLock = [[NSConditionLock alloc] initWithCondition: 0]; +// gEventLockDict = [[NSMutableDictionary alloc] init]; // } +// ++gEventId; +// NSNumber *key = [[NSNumber alloc] initWithInt: gEventId]; +// NSConditionLock *lock = [[NSConditionLock alloc] initWithCondition: 0]; +// [gEventLockDict setObject:lock forKey:key]; +// [lock release]; +// [key release]; +//// if (NULL == gEventLock) +//// { +//// gEventLock = [[NSConditionLock alloc] initWithCondition: 0]; +//// } return gEventId; } void SetEvent(HANDLE eventId) { - NSNumber *key = [[NSNumber alloc] initWithInt: eventId]; - NSConditionLock *lock = [gEventLockDict objectForKey: key]; - [key release]; - if (lock) - { - [lock lock]; - [lock unlockWithCondition: eventId]; - } +// NSNumber *key = [[NSNumber alloc] initWithInt: eventId]; +// NSConditionLock *lock = [gEventLockDict objectForKey: key]; +// [key release]; +// if (lock) +// { +// [lock lock]; +// [lock unlockWithCondition: eventId]; +// } } BOOL ResetEvent(HANDLE eventId) { - NSNumber *key = [[NSNumber alloc] initWithInt: eventId]; - NSConditionLock *lock = [gEventLockDict objectForKey: key]; - [key release]; - if (lock) - { - [lock lock]; - [lock unlockWithCondition: 0]; - return YES; - } - return NO; +// NSNumber *key = [[NSNumber alloc] initWithInt: eventId]; +// NSConditionLock *lock = [gEventLockDict objectForKey: key]; +// [key release]; +// if (lock) +// { +// [lock lock]; +// [lock unlockWithCondition: 0]; +// return TRUE; +// } + return FALSE; } void DestroyEvent(HANDLE eventId) { - NSNumber *key = [[NSNumber alloc] initWithInt: eventId]; - NSConditionLock *lock = [gEventLockDict objectForKey: key]; - if (lock) - { - [gEventLockDict removeObjectForKey: key]; - } - [key release]; +// NSNumber *key = [[NSNumber alloc] initWithInt: eventId]; +// NSConditionLock *lock = [gEventLockDict objectForKey: key]; +// if (lock) +// { +// [gEventLockDict removeObjectForKey: key]; +// } +// [key release]; } DWORD WaitForSingleObject(HANDLE eventId, int timeout) { DWORD result = WAIT_OBJECT_0; - NSNumber *key = [[NSNumber alloc] initWithInt: eventId]; - NSConditionLock *lock = [gEventLockDict objectForKey: key]; - [key release]; - - if (nil == lock) - return WAIT_FAILED; - - if (timeout > 0) - { - NSDate *timeoutDate = [[NSDate alloc] initWithTimeIntervalSinceNow: (timeout/1000.0)]; - if (![lock lockWhenCondition:eventId beforeDate:timeoutDate]) - result = WAIT_TIMEOUT; - [timeoutDate release]; - } - else - { - [lock lockWhenCondition: eventId]; - [lock unlockWithCondition: 0]; - } +// NSNumber *key = [[NSNumber alloc] initWithInt: eventId]; +// NSConditionLock *lock = [gEventLockDict objectForKey: key]; +// [key release]; +// +// if (nil == lock) +// return WAIT_FAILED; +// +// if (timeout > 0) +// { +// NSDate *timeoutDate = [[NSDate alloc] initWithTimeIntervalSinceNow: (timeout/1000.0)]; +// if (![lock lockWhenCondition:eventId beforeDate:timeoutDate]) +// result = WAIT_TIMEOUT; +// [timeoutDate release]; +// } +// else +// { +// [lock lockWhenCondition: eventId]; +// [lock unlockWithCondition: 0]; +// } return result; } void Sleep(int ms) { - [[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: (ms / 1000.0)]]; -// [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: (ms / 1000.0)]]; +// [[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: (ms / 1000.0)]]; +//// [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: (ms / 1000.0)]]; } @@ -483,6 +535,49 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hMem) { return NULL; } +DWORD GetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName) { + //TODO +#ifdef UNICODE + wcsncpy(lpReturnedString, lpDefault, nSize); +#else + strncpy(lpReturnedString, lpDefault, nSize); +#endif + return 0; +} +UINT GetPrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nDefault, LPCTSTR lpFileName) { + //TODO + return nDefault; +} +BOOL WritePrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString, LPCTSTR lpFileName) { + //TODO + return 0; +} + +MMRESULT timeSetEvent(UINT uDelay, UINT uResolution, LPTIMECALLBACK fptc, DWORD_PTR dwUser, UINT fuEvent) { + //TODO + return 0; //No error +} +MMRESULT timeKillEvent(UINT uTimerID) { + //TODO + return 0; //No error +} +MMRESULT timeGetDevCaps(LPTIMECAPS ptc, UINT cbtc) { + //TODO + return 0; //No error +} +MMRESULT timeBeginPeriod(UINT uPeriod) { + //TODO + return 0; //No error +} +MMRESULT timeEndPeriod(UINT uPeriod) { + //TODO + return 0; //No error +} +VOID GetLocalTime(LPSYSTEMTIME lpSystemTime) { + //TODO + return; +} + #ifdef UNICODE @@ -502,7 +597,9 @@ void __cdecl _wsplitpath(wchar_t const* _FullPath, wchar_t* _Drive, wchar_t* _Di int WINAPI lstrcmp(LPCWSTR lpString1, LPCWSTR lpString2) { return wcscmp(lpString1, lpString2); } - +int lstrcmpi(LPCWSTR lpString1, LPCWSTR lpString2) { + return wcscasecmp(lpString1, lpString2); +} #else int WINAPI wvsprintf(LPSTR arg1, LPCSTR arg2, va_list arglist) { @@ -519,6 +616,9 @@ void __cdecl _splitpath(char const* _FullPath, char* _Drive, char* _Dir, char* _ int WINAPI lstrcmp(LPCSTR lpString1, LPCSTR lpString2) { return strcmp(lpString1, lpString2); } +int lstrcmpi(LPCSTR lpString1, LPCSTR lpString2) { + return strcasecmp(lpString1, lpString2); +} diff --git a/app/src/main/cpp/win32-layer.h b/app/src/main/cpp/win32-layer.h index 6e15ce8..4d33e53 100644 --- a/app/src/main/cpp/win32-layer.h +++ b/app/src/main/cpp/win32-layer.h @@ -1,6 +1,8 @@ #include #include #include +#include +#include #ifndef __OBJC__ typedef signed char BOOL; // deliberately same type as defined in objc @@ -9,6 +11,8 @@ typedef signed char BOOL; // deliberately same type as defined in objc #define FALSE 0 #define MAX_PATH PATH_MAX #define INFINITE 0 +#define FAR +#define NEAR typedef unsigned long ULONG; typedef unsigned long ulong; // ushort is already in types.h @@ -29,7 +33,13 @@ typedef char CHAR; typedef void VOID; typedef void *LPVOID; typedef long LONG; +typedef LONG *PLONG; +typedef unsigned int UINT_PTR, *PUINT_PTR; +typedef long LONG_PTR, *PLONG_PTR; typedef size_t SIZE_T; +typedef /*_W64*/ unsigned long ULONG_PTR, *PULONG_PTR; +typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR; + #define CONST const @@ -43,7 +53,10 @@ typedef void *TIMECALLBACK ; #define CALLBACK typedef void(*LPTIMECALLBACK)(UINT uEventId, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2) ; //typedef TIMECALLBACK *LPTIMECALLBACK; -typedef long LRESULT; +//typedef long LRESULT; +typedef UINT_PTR WPARAM; +typedef LONG_PTR LPARAM; +typedef LONG_PTR LRESULT; typedef struct _RECT { short left; short right; @@ -170,10 +183,6 @@ typedef struct _SYSTEM_POWER_STATUS #define WINAPI - -#include -#include - enum { GENERIC_READ = 1, @@ -312,8 +321,39 @@ extern void EnableWindow(ControlRef, bool enable); typedef FMFontFamilyCallbackFilterProcPtr FONTENUMPROC; extern void EnumFontFamilies(void *, void *, FONTENUMPROC, void *userdata); */ +typedef struct _OVERLAPPED { +/* + ULONG_PTR Internal; + ULONG_PTR InternalHigh; + union { + struct { + DWORD Offset; + DWORD OffsetHigh; + } DUMMYSTRUCTNAME; + PVOID Pointer; + } DUMMYUNIONNAME; +*/ + + HANDLE hEvent; +} OVERLAPPED, *LPOVERLAPPED; + + extern BOOL SetCurrentDirectory(LPCTSTR); // returns NO if fails extern int CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPVOID lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, LPVOID hTemplateFile); +extern BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped); +extern DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod); +extern DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh); +extern BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped); +typedef struct _SECURITY_ATTRIBUTES { + DWORD nLength; + LPVOID lpSecurityDescriptor; + BOOL bInheritHandle; +} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; +extern HANDLE CreateFileMapping(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCSTR lpName); +extern LPVOID MapViewOfFile(HANDLE hFileMappingObject,DWORD dwDesiredAccess, DWORD dwFileOffsetHigh,DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap); +extern BOOL UnmapViewOfFile(LPCVOID lpBaseAddress); +extern BOOL SetEndOfFile(HANDLE hFile); + /* extern int ReadFile(int fd, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPVOID lpOverlapped); // WriteFile() writes to a temp file, then swaps that with the real file @@ -325,6 +365,62 @@ extern long SetFilePointer(FSPtr &, long offset, void *, FilePointerType startpo extern void SetTimer(void *, TimerType, int msec, void *); */ + +typedef UINT_PTR (CALLBACK *LPOFNHOOKPROC) (HWND, UINT, WPARAM, LPARAM); +typedef struct tagOFNA { + DWORD lStructSize; + HWND hwndOwner; + HINSTANCE hInstance; + LPCSTR lpstrFilter; + LPSTR lpstrCustomFilter; + DWORD nMaxCustFilter; + DWORD nFilterIndex; + LPSTR lpstrFile; + DWORD nMaxFile; + LPSTR lpstrFileTitle; + DWORD nMaxFileTitle; + LPCSTR lpstrInitialDir; + LPCSTR lpstrTitle; + DWORD Flags; + WORD nFileOffset; + WORD nFileExtension; + LPCSTR lpstrDefExt; + LPARAM lCustData; + LPOFNHOOKPROC lpfnHook; + LPCSTR lpTemplateName; +#ifdef _MAC + LPEDITMENU lpEditInfo; + LPCSTR lpstrPrompt; +#endif +#if (_WIN32_WINNT >= 0x0500) + void * pvReserved; + DWORD dwReserved; + DWORD FlagsEx; +#endif // (_WIN32_WINNT >= 0x0500) +} OPENFILENAMEA, *LPOPENFILENAMEA; +typedef OPENFILENAMEA OPENFILENAME; +typedef LPOPENFILENAMEA LPOPENFILENAME; +#define OFN_READONLY 0x00000001 +#define OFN_OVERWRITEPROMPT 0x00000002 +#define OFN_HIDEREADONLY 0x00000004 +#define OFN_PATHMUSTEXIST 0x00000800 +#define OFN_FILEMUSTEXIST 0x00001000 +#define OFN_CREATEPROMPT 0x00002000 +#define OFN_EXPLORER 0x00080000 // new look commdlg +extern BOOL GetOpenFileName(LPOPENFILENAME); +extern BOOL GetSaveFileName(LPOPENFILENAME); +#define IMAGE_BITMAP 0 +#define IMAGE_ICON 1 +#define LR_LOADFROMFILE 0x00000010 +#define LR_DEFAULTSIZE 0x00000040 +#define LR_SHARED 0x00008000 +extern HANDLE LoadImage(HINSTANCE hInst, LPCSTR name, UINT type, int cx, int cy, UINT fuLoad); + +#define WM_SETICON 0x0080 +#define ICON_SMALL 0 +#define ICON_BIG 1 +extern LRESULT SendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); + extern int MessageBox(HANDLE, LPCTSTR szMessage, LPCTSTR szTitle, int flags); extern BOOL QueryPerformanceFrequency(PLARGE_INTEGER l); extern BOOL QueryPerformanceCounter(PLARGE_INTEGER l); @@ -335,7 +431,7 @@ extern HANDLE CreateEvent(WORD, BOOL, BOOL, WORD); extern void SetEvent(HANDLE); extern void DestroyEvent(HANDLE); extern BOOL ResetEvent(HANDLE); -#define CloseEvent(h); +//#define CloseEvent(h); #define WAIT_OBJECT_0 0 #define WAIT_TIMEOUT 0x00000102 @@ -347,23 +443,40 @@ extern void Sleep(int); extern BOOL GetSystemPowerStatus(LPSYSTEM_POWER_STATUS l); -typedef struct _SECURITY_ATTRIBUTES { - DWORD nLength; - LPVOID lpSecurityDescriptor; - BOOL bInheritHandle; -} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; -typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)( +typedef DWORD (*PTHREAD_START_ROUTINE)( LPVOID lpThreadParameter ); typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE; -extern HANDLE WINAPI CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId); -extern BOOL WINAPI CloseHandle(HANDLE hObject); - - - +extern HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId); +extern BOOL CloseHandle(HANDLE hObject); +typedef struct tagBITMAPINFOHEADER{ + DWORD biSize; + LONG biWidth; + LONG biHeight; + WORD biPlanes; + WORD biBitCount; + DWORD biCompression; + DWORD biSizeImage; + LONG biXPelsPerMeter; + LONG biYPelsPerMeter; + DWORD biClrUsed; + DWORD biClrImportant; +} BITMAPINFOHEADER, FAR *LPBITMAPINFOHEADER, *PBITMAPINFOHEADER; +typedef struct tagPALETTEENTRY { + BYTE peRed; + BYTE peGreen; + BYTE peBlue; + BYTE peFlags; +} PALETTEENTRY, *PPALETTEENTRY, FAR *LPPALETTEENTRY; +typedef struct tagLOGPALETTE { + WORD palVersion; + WORD palNumEntries; + PALETTEENTRY palPalEntry[1]; +} LOGPALETTE, *PLOGPALETTE, NEAR *NPLOGPALETTE, FAR *LPLOGPALETTE; +HPALETTE CreatePalette(CONST LOGPALETTE * plpal); struct HRGN__ { int unused; }; @@ -410,8 +523,8 @@ typedef struct tagWINDOWPLACEMENT { } WINDOWPLACEMENT; typedef WINDOWPLACEMENT *PWINDOWPLACEMENT, *LPWINDOWPLACEMENT; -extern BOOL WINAPI GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT *lpwndpl); -extern BOOL WINAPI SetWindowPlacement(HWND hWnd, CONST WINDOWPLACEMENT *lpwndpl); +extern BOOL GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT *lpwndpl); +extern BOOL SetWindowPlacement(HWND hWnd, CONST WINDOWPLACEMENT *lpwndpl); #define _MAX_PATH 260 // max. length of full pathname #define _MAX_DRIVE 3 // max. length of drive component @@ -422,57 +535,101 @@ extern BOOL WINAPI SetWindowPlacement(HWND hWnd, CONST WINDOWPLACEMENT *lpwndpl) typedef wchar_t WCHAR; // wc, 16-bit UNICODE character typedef CONST WCHAR *LPCWSTR, *PCWSTR; typedef WCHAR *NWPSTR, *LPWSTR, *PWSTR; -extern BOOL WINAPI GetClientRect(HWND hWnd, LPRECT lpRect); +extern BOOL GetClientRect(HWND hWnd, LPRECT lpRect); typedef char *PSZ; typedef DWORD COLORREF; -extern BOOL WINAPI MessageBeep(UINT uType); +extern BOOL MessageBeep(UINT uType); typedef HANDLE HGLOBAL; #define GMEM_MOVEABLE 0x0002 -extern HGLOBAL WINAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes); -extern LPVOID WINAPI GlobalLock (HGLOBAL hMem); -extern BOOL WINAPI GlobalUnlock(HGLOBAL hMem); +extern HGLOBAL GlobalAlloc(UINT uFlags, SIZE_T dwBytes); +extern LPVOID GlobalLock (HGLOBAL hMem); +extern BOOL GlobalUnlock(HGLOBAL hMem); #define CF_TEXT 1 -extern BOOL WINAPI OpenClipboard(HWND hWndNewOwner); -extern BOOL WINAPI CloseClipboard(VOID); -extern BOOL WINAPI EmptyClipboard(VOID); -extern HANDLE WINAPI SetClipboardData(UINT uFormat,HANDLE hMem); -extern HGLOBAL WINAPI GlobalFree(HGLOBAL hMem); -extern BOOL WINAPI IsClipboardFormatAvailable(UINT format); -extern HANDLE WINAPI GetClipboardData(UINT uFormat); +extern BOOL OpenClipboard(HWND hWndNewOwner); +extern BOOL CloseClipboard(VOID); +extern BOOL EmptyClipboard(VOID); +extern HANDLE SetClipboardData(UINT uFormat,HANDLE hMem); +extern HGLOBAL GlobalFree(HGLOBAL hMem); +extern BOOL IsClipboardFormatAvailable(UINT format); +extern HANDLE GetClipboardData(UINT uFormat); + + +extern DWORD GetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName); +extern UINT GetPrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nDefault, LPCTSTR lpFileName); +extern BOOL WritePrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString, LPCTSTR lpFileName); + +/* flags for fuEvent parameter of timeSetEvent() function */ +#define TIME_ONESHOT 0x0000 /* program timer for single event */ +#define TIME_PERIODIC 0x0001 /* program for continuous periodic event */ +typedef UINT MMRESULT; /* error return code, 0 means no error */ +extern MMRESULT timeSetEvent(UINT uDelay, UINT uResolution, LPTIMECALLBACK fptc, DWORD_PTR dwUser, UINT fuEvent); +extern MMRESULT timeKillEvent(UINT uTimerID); +typedef struct _SYSTEMTIME { + WORD wYear; + WORD wMonth; + WORD wDayOfWeek; + WORD wDay; + WORD wHour; + WORD wMinute; + WORD wSecond; + WORD wMilliseconds; +} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME; +/* timer device capabilities data structure */ +typedef struct timecaps_tag { + UINT wPeriodMin; /* minimum period supported */ + UINT wPeriodMax; /* maximum period supported */ +} TIMECAPS, *PTIMECAPS, *NPTIMECAPS, *LPTIMECAPS; +extern MMRESULT timeGetDevCaps(LPTIMECAPS ptc, UINT cbtc); +/* timer error return values */ +#define TIMERR_NOERROR (0) /* no error */ +#define TIMERR_NOCANDO (TIMERR_BASE+1) /* request not completed */ +#define TIMERR_STRUCT (TIMERR_BASE+33) /* time struct size */ +extern MMRESULT timeBeginPeriod(UINT uPeriod); +extern MMRESULT timeEndPeriod(UINT uPeriod); +extern VOID GetLocalTime(LPSYSTEMTIME lpSystemTime); #ifdef UNICODE -extern int WINAPI wvsprintf(LPWSTR, LPCWSTR, va_list arglist); -extern DWORD WINAPI GetFullPathName(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart); -extern LPWSTR WINAPI lstrcpyn(LPWSTR lpString1, LPCWSTR lpString2,int iMaxLength); -extern LPWSTR WINAPI lstrcat(LPWSTR lpString1, LPCWSTR lpString2); +extern int wvsprintf(LPWSTR, LPCWSTR, va_list arglist); +extern DWORD GetFullPathName(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart); +extern LPWSTR lstrcpyn(LPWSTR lpString1, LPCWSTR lpString2,int iMaxLength); +extern LPWSTR lstrcat(LPWSTR lpString1, LPCWSTR lpString2); extern void __cdecl _wsplitpath(wchar_t const* _FullPath, wchar_t* _Drive, wchar_t* _Dir, wchar_t* _Filename, wchar_t* _Ext); #define _tsplitpath _wsplitpath #define _tcschr wcschr extern void _wmakepath(wchar_t _Buffer, wchar_t const* _Drive, wchar_t const* _Dir, wchar_t const* _Filename, wchar_t const* _Ext); #define _tmakepath _wmakepath -extern int WINAPI lstrcmp(LPCWSTR lpString1, LPCWSTR lpString2); +extern int lstrcmp(LPCWSTR lpString1, LPCWSTR lpString2); #define _tcsncmp wcsncmp +extern int lstrcmpi(LPCWSTR lpString1, LPCWSTR lpString2); + #else -extern int WINAPI wvsprintf(LPSTR, LPCSTR, va_list arglist); -extern DWORD WINAPI GetFullPathName(LPCSTR lpFileName, DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart); -extern LPSTR WINAPI lstrcpyn(LPSTR lpString1, LPCSTR lpString2,int iMaxLength); -extern LPSTR WINAPI lstrcat(LPSTR lpString1, LPCSTR lpString2); +extern int wvsprintf(LPSTR, LPCSTR, va_list arglist); +extern DWORD GetFullPathName(LPCSTR lpFileName, DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart); +extern LPSTR lstrcpyn(LPSTR lpString1, LPCSTR lpString2,int iMaxLength); +extern LPSTR lstrcat(LPSTR lpString1, LPCSTR lpString2); extern void __cdecl _splitpath(char const* _FullPath, char* _Drive, char* _Dir, char* _Filename, char* _Ext); #define _tsplitpath _splitpath #define _tcschr strchr extern void _makepath(char _Buffer, char const* _Drive, char const* _Dir, char const* _Filename, char const* _Ext); #define _tmakepath _makepath -extern int WINAPI lstrcmp(LPCSTR lpString1, LPCSTR lpString2); +extern int lstrcmp(LPCSTR lpString1, LPCSTR lpString2); #define _tcsncmp strncmp +extern int lstrcmpi(LPCSTR lpString1, LPCSTR lpString2); #endif // !UNICODE + + + +#define __max(a,b) (((a) > (b)) ? (a) : (b)) +#define __min(a,b) (((a) < (b)) ? (a) : (b)) +