This commit is contained in:
dgis 2018-11-29 22:33:50 +00:00
parent 81b3024034
commit cf1ba8a3a8
4 changed files with 226 additions and 128 deletions

View file

@ -2070,8 +2070,9 @@ BOOL emu48Start()
ReadSettings(); ReadSettings();
_tcscpy(szCurrentDirectory, ""); _tcscpy(szCurrentDirectory, "");
_tcscpy(szEmuDirectory, "assets/calculators/");
_tcscpy(szRomDirectory, "assets/calculators/"); _tcscpy(szRomDirectory, "assets/calculators/");
_tcscpy(szPort2Filename, "");
// running an instance of me? // running an instance of me?
// if (bSingleInstance && (hWnd = FindWindow(MAKEINTATOM(classAtom),NULL)) != NULL) // if (bSingleInstance && (hWnd = FindWindow(MAKEINTATOM(classAtom),NULL)) != NULL)
@ -2149,6 +2150,8 @@ BOOL emu48Start()
// //
// VERIFY(hAccel = LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_MENU))); // VERIFY(hAccel = LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_MENU)));
hWindowDC = CreateCompatibleDC(NULL);
// initialization // initialization
QueryPerformanceFrequency(&lFreq); // init high resolution counter QueryPerformanceFrequency(&lFreq); // init high resolution counter
QueryPerformanceCounter(&lAppStart); QueryPerformanceCounter(&lAppStart);

View file

@ -2,6 +2,8 @@
// PCH.H // PCH.H
// //
#define DEBUG_DISPLAY 1
#define _WIN32_IE 0x0200 #define _WIN32_IE 0x0200
#define _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE
#define _CRTDBG_MAP_ALLOC #define _CRTDBG_MAP_ALLOC

View file

@ -13,6 +13,9 @@ const TCHAR * assetsPrefix = _T("assets/"),
assetsPrefixLength = 7; assetsPrefixLength = 7;
AAssetManager * assetManager; AAssetManager * assetManager;
VOID OutputDebugString(LPCSTR lpOutputString) {
LOGD("%s", lpOutputString);
}
DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer) { DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer) {
if(getcwd(lpBuffer, nBufferLength)) { if(getcwd(lpBuffer, nBufferLength)) {
@ -51,15 +54,6 @@ HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
HANDLE handle = malloc(sizeof(_HANDLE)); HANDLE handle = malloc(sizeof(_HANDLE));
handle->handleType = HANDLE_TYPE_FILE_ASSET; handle->handleType = HANDLE_TYPE_FILE_ASSET;
handle->fileAsset = asset; handle->fileAsset = asset;
// char buf[BUFSIZ];
// int nb_read = 0;
// nb_read = AAsset_read(asset, buf, BUFSIZ);
// AAsset_close(asset);
// }
// AAssetDir* assetDir = AAssetManager_openDir(assetManager, "");
// const char* filename = (const char*)NULL;
// while ((filename = AAssetDir_getNextFileName(assetDir)) != NULL) {
// AAssetDir_close(assetDir);
return handle; return handle;
} }
} else { } else {
@ -105,7 +99,7 @@ HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
return handle; return handle;
} }
} }
return NULL; return INVALID_HANDLE_VALUE;
} }
BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped) { BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped) {
@ -407,15 +401,24 @@ BOOL WINAPI CloseHandle(HANDLE hObject) {
case HANDLE_TYPE_FILE: { case HANDLE_TYPE_FILE: {
int closeResult = close(hObject->fileDescriptor); int closeResult = close(hObject->fileDescriptor);
if(closeResult >= 0) { if(closeResult >= 0) {
hObject->handleType = HANDLE_TYPE_INVALID;
hObject->fileDescriptor = 0; hObject->fileDescriptor = 0;
free(hObject); free(hObject);
return TRUE; return TRUE;
} }
break; break;
} }
case HANDLE_TYPE_FILE_ASSET: {
AAsset_close(hObject->fileAsset);
hObject->handleType = HANDLE_TYPE_INVALID;
hObject->fileAsset = NULL;
free(hObject);
return TRUE;
}
case HANDLE_TYPE_FILE_MAPPING: { case HANDLE_TYPE_FILE_MAPPING: {
int closeResult = UnmapViewOfFile(hObject->fileMappingAddress); int closeResult = UnmapViewOfFile(hObject->fileMappingAddress);
if(closeResult == TRUE) { if(closeResult == TRUE) {
hObject->handleType = HANDLE_TYPE_INVALID;
hObject->fileDescriptor = 0; hObject->fileDescriptor = 0;
hObject->fileMappingSize = 0; hObject->fileMappingSize = 0;
hObject->fileMappingAddress = NULL; hObject->fileMappingAddress = NULL;
@ -424,7 +427,16 @@ BOOL WINAPI CloseHandle(HANDLE hObject) {
} }
break; break;
} }
case HANDLE_TYPE_FILE_MAPPING_ASSET: {
hObject->handleType = HANDLE_TYPE_INVALID;
hObject->fileAsset = NULL;
hObject->fileMappingSize = 0;
hObject->fileMappingAddress = NULL;
free(hObject);
return TRUE;
}
case HANDLE_TYPE_EVENT: { case HANDLE_TYPE_EVENT: {
hObject->handleType = HANDLE_TYPE_INVALID;
int result = 0; int result = 0;
result = pthread_cond_destroy(&hObject->eventCVariable); result = pthread_cond_destroy(&hObject->eventCVariable);
_ASSERT(result == 0); _ASSERT(result == 0);
@ -436,6 +448,7 @@ BOOL WINAPI CloseHandle(HANDLE hObject) {
return TRUE; return TRUE;
} }
case HANDLE_TYPE_THREAD: case HANDLE_TYPE_THREAD:
hObject->handleType = HANDLE_TYPE_INVALID;
hObject->threadId = 0; hObject->threadId = 0;
free(hObject); free(hObject);
return TRUE; return TRUE;
@ -626,6 +639,26 @@ BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy,
BOOL IsRectEmpty(CONST RECT *lprc) { return 0; } BOOL IsRectEmpty(CONST RECT *lprc) { return 0; }
BOOL WINAPI SetWindowOrgEx(HDC hdc, int x, int y, LPPOINT lppt) { return 0; } BOOL WINAPI SetWindowOrgEx(HDC hdc, int x, int y, LPPOINT lppt) { return 0; }
// GDI
HGDIOBJ SelectObject(HDC hdc, HGDIOBJ h) {
switch (h->handleType) {
case HGDIOBJ_TYPE_PEN:
break;
case HGDIOBJ_TYPE_BRUSH:
break;
case HGDIOBJ_TYPE_FONT:
break;
case HGDIOBJ_TYPE_BITMAP:
hdc->selectedBitmap = h;
break;
case HGDIOBJ_TYPE_REGION:
break;
case HGDIOBJ_TYPE_PALETTE:
hdc->selectedPalette = h;
break;
}
return NULL;
}
int GetObject(HANDLE h, int c, LPVOID pv) { int GetObject(HANDLE h, int c, LPVOID pv) {
//TODO //TODO
return 0; return 0;
@ -634,41 +667,55 @@ HGDIOBJ GetCurrentObject(HDC hdc, UINT type) {
//TODO //TODO
return NULL; return NULL;
} }
int SetStretchBltMode(HDC hdc, int mode) { BOOL DeleteObject(HGDIOBJ ho) {
//TODO switch(ho->handleType) {
return 0; case HGDIOBJ_TYPE_PALETTE: {
} ho->handleType = 0;
BOOL StretchBlt(HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, DWORD rop) { ho->paletteLog = NULL;
//TODO free(ho);
return 0; return TRUE;
} }
HPALETTE CreatePalette(CONST LOGPALETTE * plpal) { case HGDIOBJ_TYPE_BITMAP: {
//TODO ho->handleType = 0;
return NULL; ho->bitmapInfoHeader = NULL;
} ho->bitmapBits = NULL;
HPALETTE SelectPalette(HDC hdc, HPALETTE hPal, BOOL bForceBkgd) { ho->bitmapInfo = NULL;
//TODO free(ho);
return NULL; return TRUE;
} }
UINT RealizePalette(HDC hdc) { }
//TODO return FALSE;
return 0;
}
HDC CreateCompatibleDC(HDC hdc) {
//TODO
return NULL;
}
BOOL DeleteDC(HDC hdc) {
//TODO
return 0;
} }
HGDIOBJ GetStockObject(int i) { HGDIOBJ GetStockObject(int i) {
//TODO //TODO
return NULL; return NULL;
} }
HGDIOBJ SelectObject(HDC hdc, HGDIOBJ h) { HPALETTE CreatePalette(CONST LOGPALETTE * plpal) {
HGDIOBJ newHDC = (HGDIOBJ)malloc(sizeof(_HGDIOBJ));
newHDC->handleType = HGDIOBJ_TYPE_PALETTE;
newHDC->paletteLog = (PLOGPALETTE)plpal; // Can be free -> we have to make a copy
return newHDC;
}
HPALETTE SelectPalette(HDC hdc, HPALETTE hPal, BOOL bForceBkgd) {
hdc->selectedPalette = hPal;
return hPal;
}
UINT RealizePalette(HDC hdc) {
//TODO //TODO
return NULL; return 0;
}
// DC
HDC CreateCompatibleDC(HDC hdc) {
HDC newHDC = (HDC)malloc(sizeof(struct _HDC));
newHDC->handleType = HDC_TYPE_DC;
newHDC->hdcCompatible = hdc;
return newHDC;
}
BOOL DeleteDC(HDC hdc) {
//TODO
return 0;
} }
BOOL MoveToEx(HDC hdc, int x, int y, LPPOINT lppt) { BOOL MoveToEx(HDC hdc, int x, int y, LPPOINT lppt) {
//TODO //TODO
@ -686,6 +733,14 @@ BOOL BitBlt(HDC hdc, int x, int y, int cx, int cy, HDC hdcSrc, int x1, int y1, D
//TODO //TODO
return 0; return 0;
} }
int SetStretchBltMode(HDC hdc, int mode) {
//TODO
return 0;
}
BOOL StretchBlt(HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, DWORD rop) {
//TODO
return 0;
}
UINT SetDIBColorTable(HDC hdc, UINT iStart, UINT cEntries, CONST RGBQUAD *prgbq) { UINT SetDIBColorTable(HDC hdc, UINT iStart, UINT cEntries, CONST RGBQUAD *prgbq) {
//TODO //TODO
return 0; return 0;
@ -696,21 +751,28 @@ UINT SetDIBColorTable(HDC hdc, UINT iStart, UINT cEntries, CONST RGBQUAD *prgbq
#define DIB_RGB_COLORS 0 /* color table in RGBs */ #define DIB_RGB_COLORS 0 /* color table in RGBs */
#define DIB_PAL_COLORS 1 /* color table in palette indices */ #define DIB_PAL_COLORS 1 /* color table in palette indices */
HBITMAP CreateDIBitmap( HDC hdc, CONST BITMAPINFOHEADER *pbmih, DWORD flInit, CONST VOID *pjBits, CONST BITMAPINFO *pbmi, UINT iUsage) { HBITMAP CreateDIBitmap( HDC hdc, CONST BITMAPINFOHEADER *pbmih, DWORD flInit, CONST VOID *pjBits, CONST BITMAPINFO *pbmi, UINT iUsage) {
//TODO HGDIOBJ newHDC = (HGDIOBJ)malloc(sizeof(_HGDIOBJ));
return NULL; newHDC->handleType = HGDIOBJ_TYPE_BITMAP;
newHDC->bitmapInfo = pbmi;
newHDC->bitmapInfoHeader = pbmih;
newHDC->bitmapBits = pjBits;
return newHDC;
} }
HBITMAP CreateDIBSection(HDC hdc, CONST BITMAPINFO *pbmi, UINT usage, VOID **ppvBits, HANDLE hSection, DWORD offset) { HBITMAP CreateDIBSection(HDC hdc, CONST BITMAPINFO *pbmi, UINT usage, VOID **ppvBits, HANDLE hSection, DWORD offset) {
//TODO HGDIOBJ newHDC = (HGDIOBJ)malloc(sizeof(_HGDIOBJ));
return NULL; newHDC->handleType = HGDIOBJ_TYPE_BITMAP;
newHDC->bitmapInfo = pbmi;
newHDC->bitmapInfoHeader = pbmi;
// For DIB_RGB_COLORS only
int size = pbmi->bmiHeader.biWidth * abs(pbmi->bmiHeader.biHeight) * 4; //(pbmi->bmiHeader.biBitCount >> 3);
newHDC->bitmapBits = malloc(size); //pbmi->bmiHeader.biSizeImage);
*ppvBits = newHDC->bitmapBits;
return newHDC;
} }
HBITMAP CreateCompatibleBitmap( HDC hdc, int cx, int cy) { HBITMAP CreateCompatibleBitmap( HDC hdc, int cx, int cy) {
//TODO //TODO
return NULL; return NULL;
} }
BOOL DeleteObject(HGDIOBJ ho) {
//TODO
return 0;
}
int GetDIBits(HDC hdc, HBITMAP hbm, UINT start, UINT cLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT usage) { int GetDIBits(HDC hdc, HBITMAP hbm, UINT start, UINT cLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT usage) {
//TODO //TODO
return 0; return 0;
@ -787,7 +849,21 @@ MMRESULT timeEndPeriod(UINT uPeriod) {
return 0; //No error return 0; //No error
} }
VOID GetLocalTime(LPSYSTEMTIME lpSystemTime) { VOID GetLocalTime(LPSYSTEMTIME lpSystemTime) {
//TODO if(lpSystemTime) {
struct timespec ts = {0, 0};
struct tm tm = {};
clock_gettime(CLOCK_REALTIME, &ts);
time_t tim = ts.tv_sec;
localtime_r(&tim, &tm);
lpSystemTime->wYear = 1900 + tm.tm_year;
lpSystemTime->wMonth = 1 + tm.tm_mon;
lpSystemTime->wDayOfWeek = tm.tm_wday;
lpSystemTime->wDay = tm.tm_mday;
lpSystemTime->wHour = tm.tm_hour;
lpSystemTime->wMinute = tm.tm_min;
lpSystemTime->wSecond = tm.tm_sec;
lpSystemTime->wMilliseconds = ts.tv_nsec / 1e6;
}
return; return;
} }
@ -855,7 +931,7 @@ extern TCHAR szCurrentKml[MAX_PATH];
INT_PTR DialogBoxParamA(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam) { INT_PTR DialogBoxParamA(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam) {
//TODO //TODO
if(lpTemplateName == MAKEINTRESOURCE(IDD_CHOOSEKML)) { if(lpTemplateName == MAKEINTRESOURCE(IDD_CHOOSEKML)) {
lstrcpy(szCurrentKml, "assets/calculators/real48sx.kml"); lstrcpy(szCurrentKml, "real48sx.kml");
} else if(lpTemplateName == MAKEINTRESOURCE(IDD_KMLLOG)) { } else if(lpTemplateName == MAKEINTRESOURCE(IDD_KMLLOG)) {
//LOGD(szLog); //LOGD(szLog);
lpDialogFunc(NULL, WM_INITDIALOG, 0, 0); lpDialogFunc(NULL, WM_INITDIALOG, 0, 0);

View file

@ -51,8 +51,18 @@ typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
#define CONST const #define CONST const
#define _ASSERT(expr)
//#define _ASSERT(expr) \
// (void)( \
// (!!(expr)) || \
// (1 != _CrtDbgReportW(_CRT_ASSERT, _CRT_WIDE(__FILE__), __LINE__, NULL, L"%ls", NULL)) || \
// (_CrtDbgBreak(), 0) \
// )
enum HANDLE_TYPE { enum HANDLE_TYPE {
HANDLE_TYPE_FILE = 1, HANDLE_TYPE_INVALID = 0,
HANDLE_TYPE_FILE,
HANDLE_TYPE_FILE_ASSET, HANDLE_TYPE_FILE_ASSET,
HANDLE_TYPE_FILE_MAPPING, HANDLE_TYPE_FILE_MAPPING,
HANDLE_TYPE_FILE_MAPPING_ASSET, HANDLE_TYPE_FILE_MAPPING_ASSET,
@ -60,7 +70,7 @@ enum HANDLE_TYPE {
HANDLE_TYPE_THREAD, HANDLE_TYPE_THREAD,
}; };
typedef struct { typedef struct {
int handleType; enum HANDLE_TYPE handleType;
int fileDescriptor; int fileDescriptor;
@ -77,11 +87,8 @@ typedef struct {
BOOL eventState; BOOL eventState;
} _HANDLE; } _HANDLE;
typedef _HANDLE * HANDLE; typedef _HANDLE * HANDLE;
typedef HANDLE HPALETTE;
typedef HANDLE HBITMAP;
typedef HANDLE HMENU; typedef HANDLE HMENU;
typedef HANDLE HFONT;
typedef void * HGDIOBJ;
#define MK_LBUTTON 0x0001 #define MK_LBUTTON 0x0001
@ -139,7 +146,7 @@ typedef pthread_mutex_t CRITICAL_SECTION;
typedef HANDLE HINSTANCE; typedef HANDLE HINSTANCE;
typedef HANDLE HWND; typedef HANDLE HWND;
typedef void WNDCLASS; typedef void WNDCLASS;
typedef HANDLE HDC;
typedef HANDLE HCURSOR; typedef HANDLE HCURSOR;
struct FILETIME { struct FILETIME {
@ -231,11 +238,9 @@ enum
FILE_FLAG_OVERLAPPED = 2, FILE_FLAG_OVERLAPPED = 2,
FILE_FLAG_SEQUENTIAL_SCAN = 4, FILE_FLAG_SEQUENTIAL_SCAN = 4,
PAGE_READONLY, PAGE_READONLY,
FILE_MAP_READ,
CREATE_ALWAYS, CREATE_ALWAYS,
PAGE_READWRITE, PAGE_READWRITE,
PAGE_WRITECOPY, PAGE_WRITECOPY,
FILE_MAP_WRITE,
FILE_MAP_COPY, FILE_MAP_COPY,
//errors //errors
@ -243,6 +248,8 @@ enum
ERROR_ALREADY_EXISTS = 1 ERROR_ALREADY_EXISTS = 1
}; };
#define FILE_MAP_WRITE 0x0002
#define FILE_MAP_READ 0x0004
enum MsgBoxFlagType { enum MsgBoxFlagType {
IDOK = 0, IDOK = 0,
@ -332,33 +339,7 @@ enum {
#define ZeroMemory(p,s) memset(p,0,s) #define ZeroMemory(p,s) memset(p,0,s)
#define FillMemory(p,n,v) memset(p,v,n*sizeof(*(p))) #define FillMemory(p,n,v) memset(p,v,n*sizeof(*(p)))
#define CopyMemory(d,src,s) memcpy(d,src,s) #define CopyMemory(d,src,s) memcpy(d,src,s)
//inline unsigned char HIBYTE(int i) { return i>>8; }
//inline unsigned char LOBYTE(int i) { return i; }
//inline BOOL _istdigit(unichar c) { return (c>='0' && c<='9'); }
/*
extern RGBColor RGB(int r, int g, int b);
inline ControlRef GetDlgItem(WindowRef window, SInt32 control_code)
{
ControlRef control;
ControlID control_id = { app_signature, control_code };
FailOSErr(GetControlByID(window, &control_id, &control));
return control;
}
// For radio groups, 1=first choice, 2=second, etc
extern void CheckDlgButton(WindowRef, SInt32 control_code, SInt32 value);
extern void SetDlgItemInt(WindowRef, SInt32 control_code, int value, bool);
extern void SetDlgItemText(WindowRef, SInt32 control_code, CFStringRef);
// Use this to fiddle with dropdown menus (pass a CB_ constant for msg)
// Indexes are zero-based. Also handles WMU_SETWINDOWVALUE
extern int SendDlgItemMessage(WindowRef, SInt32 control_code, int msg, int p1, void *p2);
// For checkboxes, result will be zero or one (can cast directly to bool)
extern SInt32 IsDlgButtonChecked(WindowRef, SInt32 control_code);
// Despite its name, this dims/undims controls
extern void EnableWindow(ControlRef, bool enable);
// Used to fill in font dropdown menus
typedef FMFontFamilyCallbackFilterProcPtr FONTENUMPROC;
extern void EnumFontFamilies(void *, void *, FONTENUMPROC, void *userdata);
*/
typedef struct _OVERLAPPED { typedef struct _OVERLAPPED {
/* /*
ULONG_PTR Internal; ULONG_PTR Internal;
@ -376,6 +357,8 @@ typedef struct _OVERLAPPED {
} OVERLAPPED, *LPOVERLAPPED; } OVERLAPPED, *LPOVERLAPPED;
extern VOID OutputDebugString(LPCSTR lpOutputString);
extern DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer); extern DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer);
extern BOOL SetCurrentDirectory(LPCTSTR); // returns NO if fails extern BOOL SetCurrentDirectory(LPCTSTR); // returns NO if fails
extern HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPVOID lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, LPVOID hTemplateFile); extern HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPVOID lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, LPVOID hTemplateFile);
@ -393,18 +376,6 @@ extern LPVOID MapViewOfFile(HANDLE hFileMappingObject,DWORD dwDesiredAccess, DWO
extern BOOL UnmapViewOfFile(LPCVOID lpBaseAddress); extern BOOL UnmapViewOfFile(LPCVOID lpBaseAddress);
extern BOOL SetEndOfFile(HANDLE hFile); 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
extern OSErr WriteFile(FSPtr &, void *buf, SInt64 size, void *, void *);
extern UInt64 GetFileSize(FSPtr &, void *);
// Do a strcmp-like comparison between 64-bit times
extern int CompareFileTime(FILETIME *, FILETIME *);
extern long SetFilePointer(FSPtr &, long offset, void *, FilePointerType startpoint);
extern void SetTimer(void *, TimerType, int msec, void *);
*/
typedef UINT_PTR (CALLBACK *LPOFNHOOKPROC) (HWND, UINT, WPARAM, LPARAM); typedef UINT_PTR (CALLBACK *LPOFNHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef struct tagOFNA { typedef struct tagOFNA {
DWORD lStructSize; DWORD lStructSize;
@ -474,11 +445,6 @@ extern int MessageBox(HANDLE, LPCTSTR szMessage, LPCTSTR szTitle, int flags);
extern BOOL QueryPerformanceFrequency(PLARGE_INTEGER l); extern BOOL QueryPerformanceFrequency(PLARGE_INTEGER l);
extern BOOL QueryPerformanceCounter(PLARGE_INTEGER l); extern BOOL QueryPerformanceCounter(PLARGE_INTEGER l);
extern DWORD timeGetTime(void); extern DWORD timeGetTime(void);
extern void EnterCriticalSection(CRITICAL_SECTION *);
extern void LeaveCriticalSection(CRITICAL_SECTION *);
extern HANDLE CreateEvent(LPVOID lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCTSTR name);
extern BOOL SetEvent(HANDLE hEvent);
extern BOOL ResetEvent(HANDLE hEvent);
#define WAIT_OBJECT_0 0 #define WAIT_OBJECT_0 0
#define WAIT_TIMEOUT 0x00000102 #define WAIT_TIMEOUT 0x00000102
@ -490,6 +456,13 @@ extern void Sleep(int);
extern BOOL GetSystemPowerStatus(LPSYSTEM_POWER_STATUS l); extern BOOL GetSystemPowerStatus(LPSYSTEM_POWER_STATUS l);
// Event
extern HANDLE CreateEvent(LPVOID lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCTSTR name);
extern BOOL SetEvent(HANDLE hEvent);
extern BOOL ResetEvent(HANDLE hEvent);
// Thread
typedef DWORD (*PTHREAD_START_ROUTINE)( typedef DWORD (*PTHREAD_START_ROUTINE)(
LPVOID lpThreadParameter LPVOID lpThreadParameter
@ -499,14 +472,12 @@ typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
extern HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId); extern HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId);
extern DWORD ResumeThread(HANDLE hThread); extern DWORD ResumeThread(HANDLE hThread);
extern BOOL CloseHandle(HANDLE hObject); extern BOOL CloseHandle(HANDLE hObject);
#define OBJ_BITMAP 7
extern int GetObject(HANDLE h, int c, LPVOID pv);
extern HGDIOBJ GetCurrentObject(HDC hdc, UINT type);
#define HALFTONE 4
extern int SetStretchBltMode(HDC hdc, int mode);
extern BOOL StretchBlt(HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, DWORD rop);
typedef struct tagBITMAP extern void EnterCriticalSection(CRITICAL_SECTION *);
extern void LeaveCriticalSection(CRITICAL_SECTION *);
// GDI
typedef struct __attribute__((packed)) tagBITMAP
{ {
LONG bmType; LONG bmType;
LONG bmWidth; LONG bmWidth;
@ -523,14 +494,14 @@ typedef struct tagBITMAP
#define BI_BITFIELDS 3L #define BI_BITFIELDS 3L
#define BI_JPEG 4L #define BI_JPEG 4L
#define BI_PNG 5L #define BI_PNG 5L
typedef struct tagBITMAPFILEHEADER { typedef struct __attribute__((packed)) tagBITMAPFILEHEADER {
WORD bfType; WORD bfType;
DWORD bfSize; DWORD bfSize;
WORD bfReserved1; WORD bfReserved1;
WORD bfReserved2; WORD bfReserved2;
DWORD bfOffBits; DWORD bfOffBits;
} BITMAPFILEHEADER, FAR *LPBITMAPFILEHEADER, *PBITMAPFILEHEADER; } BITMAPFILEHEADER, FAR *LPBITMAPFILEHEADER, *PBITMAPFILEHEADER;
typedef struct tagBITMAPINFOHEADER{ typedef struct __attribute__((packed)) tagBITMAPINFOHEADER{
DWORD biSize; DWORD biSize;
LONG biWidth; LONG biWidth;
LONG biHeight; LONG biHeight;
@ -543,27 +514,77 @@ typedef struct tagBITMAPINFOHEADER{
DWORD biClrUsed; DWORD biClrUsed;
DWORD biClrImportant; DWORD biClrImportant;
} BITMAPINFOHEADER, FAR *LPBITMAPINFOHEADER, *PBITMAPINFOHEADER; } BITMAPINFOHEADER, FAR *LPBITMAPINFOHEADER, *PBITMAPINFOHEADER;
typedef struct tagBITMAPINFO { typedef struct __attribute__((packed)) tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader; BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1]; RGBQUAD bmiColors[1];
} BITMAPINFO, FAR *LPBITMAPINFO, *PBITMAPINFO; } BITMAPINFO, FAR *LPBITMAPINFO, *PBITMAPINFO;
typedef struct tagPALETTEENTRY { typedef struct __attribute__((packed)) tagPALETTEENTRY {
BYTE peRed; BYTE peRed;
BYTE peGreen; BYTE peGreen;
BYTE peBlue; BYTE peBlue;
BYTE peFlags; BYTE peFlags;
} PALETTEENTRY, *PPALETTEENTRY, FAR *LPPALETTEENTRY; } PALETTEENTRY, *PPALETTEENTRY, FAR *LPPALETTEENTRY;
typedef struct tagLOGPALETTE { typedef struct __attribute__((packed)) tagLOGPALETTE {
WORD palVersion; WORD palVersion;
WORD palNumEntries; WORD palNumEntries;
PALETTEENTRY palPalEntry[1]; PALETTEENTRY palPalEntry[1];
} LOGPALETTE, *PLOGPALETTE, NEAR *NPLOGPALETTE, FAR *LPLOGPALETTE; } LOGPALETTE, *PLOGPALETTE, NEAR *NPLOGPALETTE, FAR *LPLOGPALETTE;
enum HGDIOBJ_TYPE {
HGDIOBJ_TYPE_INVALID = 0,
HGDIOBJ_TYPE_PEN,
HGDIOBJ_TYPE_BRUSH,
HGDIOBJ_TYPE_FONT,
HGDIOBJ_TYPE_BITMAP,
HGDIOBJ_TYPE_REGION,
HGDIOBJ_TYPE_PALETTE
};
typedef struct {
enum HGDIOBJ_TYPE handleType;
// HGDIOBJ_TYPE_PALETTE
PLOGPALETTE paletteLog;
// HGDIOBJ_TYPE_BITMAP
CONST BITMAPINFO *bitmapInfo;
CONST BITMAPINFOHEADER * bitmapInfoHeader;
CONST VOID *bitmapBits;
} _HGDIOBJ;
typedef _HGDIOBJ * HGDIOBJ;
//typedef void * HGDIOBJ;
typedef HGDIOBJ HPALETTE;
typedef HGDIOBJ HBITMAP;
typedef HGDIOBJ HFONT;
extern int GetObject(HANDLE h, int c, LPVOID pv);
extern BOOL DeleteObject(HGDIOBJ ho);
#define OBJ_BITMAP 7
#define WHITE_PEN 6
#define BLACK_PEN 7
extern HGDIOBJ GetStockObject(int i);
extern HPALETTE CreatePalette(CONST LOGPALETTE * plpal); extern HPALETTE CreatePalette(CONST LOGPALETTE * plpal);
extern HPALETTE SelectPalette(HDC hdc, HPALETTE hPal, BOOL bForceBkgd);
extern UINT RealizePalette(HDC hdc); // DC
enum HDC_TYPE {
HDC_TYPE_DC = 1,
HDC_TYPE_FILE_ASSET
};
struct _HDC;
typedef struct _HDC * HDC;
struct _HDC{
enum HDC_TYPE handleType;
HDC hdcCompatible;
HBITMAP selectedBitmap;
HPALETTE selectedPalette;
};
//typedef HANDLE HDC;
extern HDC CreateCompatibleDC(HDC hdc); extern HDC CreateCompatibleDC(HDC hdc);
extern BOOL DeleteDC(HDC hdc); extern BOOL DeleteDC(HDC hdc);
extern HGDIOBJ SelectObject(HDC hdc, HGDIOBJ h); extern HGDIOBJ SelectObject(HDC hdc, HGDIOBJ h);
extern HGDIOBJ GetCurrentObject(HDC hdc, UINT type);
typedef struct tagPOINT typedef struct tagPOINT
{ {
LONG x; LONG x;
@ -571,14 +592,14 @@ typedef struct tagPOINT
} POINT, *PPOINT, NEAR *NPPOINT, FAR *LPPOINT; } POINT, *PPOINT, NEAR *NPPOINT, FAR *LPPOINT;
extern BOOL MoveToEx(HDC hdc, int x, int y, LPPOINT lppt); extern BOOL MoveToEx(HDC hdc, int x, int y, LPPOINT lppt);
extern BOOL LineTo(HDC hdc, int x, int y); extern BOOL LineTo(HDC hdc, int x, int y);
#define WHITE_PEN 6
#define BLACK_PEN 7
extern HGDIOBJ GetStockObject(int i);
#define SRCCOPY (DWORD)0x00CC0020 /* dest = source */ #define SRCCOPY (DWORD)0x00CC0020 /* dest = source */
#define DSTINVERT (DWORD)0x00550009 /* dest = (NOT dest) */ #define DSTINVERT (DWORD)0x00550009 /* dest = (NOT dest) */
#define BLACKNESS (DWORD)0x00000042 /* dest = BLACK */ #define BLACKNESS (DWORD)0x00000042 /* dest = BLACK */
extern BOOL PatBlt(HDC hdc, int x, int y, int w, int h, DWORD rop); extern BOOL PatBlt(HDC hdc, int x, int y, int w, int h, DWORD rop);
extern BOOL BitBlt(HDC hdc, int x, int y, int cx, int cy, HDC hdcSrc, int x1, int y1, DWORD rop); extern BOOL BitBlt(HDC hdc, int x, int y, int cx, int cy, HDC hdcSrc, int x1, int y1, DWORD rop);
#define HALFTONE 4
extern int SetStretchBltMode(HDC hdc, int mode);
extern BOOL StretchBlt(HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, DWORD rop);
extern UINT SetDIBColorTable(HDC hdc, UINT iStart, UINT cEntries, CONST RGBQUAD *prgbq); extern UINT SetDIBColorTable(HDC hdc, UINT iStart, UINT cEntries, CONST RGBQUAD *prgbq);
/* constants for CreateDIBitmap */ /* constants for CreateDIBitmap */
#define CBM_INIT 0x04L /* initialize bitmap */ #define CBM_INIT 0x04L /* initialize bitmap */
@ -588,7 +609,6 @@ extern UINT SetDIBColorTable(HDC hdc, UINT iStart, UINT cEntries, CONST RGBQUAD
extern HBITMAP CreateDIBitmap( HDC hdc, CONST BITMAPINFOHEADER *pbmih, DWORD flInit, CONST VOID *pjBits, CONST BITMAPINFO *pbmi, UINT iUsage); extern HBITMAP CreateDIBitmap( HDC hdc, CONST BITMAPINFOHEADER *pbmih, DWORD flInit, CONST VOID *pjBits, CONST BITMAPINFO *pbmi, UINT iUsage);
extern HBITMAP CreateDIBSection(HDC hdc, CONST BITMAPINFO *pbmi, UINT usage, VOID **ppvBits, HANDLE hSection, DWORD offset); extern HBITMAP CreateDIBSection(HDC hdc, CONST BITMAPINFO *pbmi, UINT usage, VOID **ppvBits, HANDLE hSection, DWORD offset);
extern HBITMAP CreateCompatibleBitmap( HDC hdc, int cx, int cy); extern HBITMAP CreateCompatibleBitmap( HDC hdc, int cx, int cy);
extern BOOL DeleteObject(HGDIOBJ ho);
typedef struct _RGNDATAHEADER { typedef struct _RGNDATAHEADER {
DWORD dwSize; DWORD dwSize;
DWORD iType; DWORD iType;
@ -602,6 +622,8 @@ typedef struct _RGNDATA {
char Buffer[1]; char Buffer[1];
} RGNDATA, *PRGNDATA, NEAR *NPRGNDATA, FAR *LPRGNDATA; } RGNDATA, *PRGNDATA, NEAR *NPRGNDATA, FAR *LPRGNDATA;
extern int GetDIBits(HDC hdc, HBITMAP hbm, UINT start, UINT cLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT usage); extern int GetDIBits(HDC hdc, HBITMAP hbm, UINT start, UINT cLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT usage);
extern HPALETTE SelectPalette(HDC hdc, HPALETTE hPal, BOOL bForceBkgd);
extern UINT RealizePalette(HDC hdc);
/* GetRegionData/ExtCreateRegion */ /* GetRegionData/ExtCreateRegion */
#define RDH_RECTANGLES 1 #define RDH_RECTANGLES 1
extern BOOL SetRect(LPRECT lprc, int xLeft, int yTop, int xRight, int yBottom); extern BOOL SetRect(LPRECT lprc, int xLeft, int yTop, int xRight, int yBottom);
@ -621,13 +643,8 @@ extern int SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw);
extern HRGN ExtCreateRegion(CONST XFORM * lpx, DWORD nCount, CONST RGNDATA * lpData); extern HRGN ExtCreateRegion(CONST XFORM * lpx, DWORD nCount, CONST RGNDATA * lpData);
extern BOOL GdiFlush(void); extern BOOL GdiFlush(void);
#define _ASSERT(expr) // Window
//#define _ASSERT(expr) \
// (void)( \
// (!!(expr)) || \
// (1 != _CrtDbgReportW(_CRT_ASSERT, _CRT_WIDE(__FILE__), __LINE__, NULL, L"%ls", NULL)) || \
// (_CrtDbgBreak(), 0) \
// )
// disrpl.c // disrpl.c