source: trunk/src/ddraw/OS2UTIL.CPP@ 2638

Last change on this file since 2638 was 2638, checked in by hugh, 26 years ago

Bugfixes at many places

File size: 2.2 KB
Line 
1/* $Id: OS2UTIL.CPP,v 1.9 2000-02-04 19:31:25 hugh Exp $ */
2
3/*
4 * OS/2 Utility functions
5 *
6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11#define INCL_DOSMEMMGR
12#define INCL_DOSDEVICES
13#include <os2wrap.h>
14#include <misc.h>
15#include "os2util.h"
16#include "cio2.h"
17
18//******************************************************************************
19//******************************************************************************
20char *OS2AllocMem(ULONG size)
21{
22 PVOID lpMem;
23 APIRET rc;
24
25 rc = DosAllocMem(&lpMem, size, PAG_READ|PAG_WRITE|PAG_COMMIT);
26 if(rc) {
27 dprintf(("DDRAW: DosAllocMem returned %d", rc));
28 return(NULL);
29 }
30 return((char *)lpMem);
31}
32//******************************************************************************
33//******************************************************************************
34void OS2FreeMem(char *lpMem)
35{
36 APIRET rc;
37
38 rc = DosFreeMem(lpMem);
39 if(rc) {
40 dprintf(("DDRAW: DosFreeMem returned %d", rc));
41 }
42}//******************************************************************************
43//******************************************************************************
44void OS2MaximizeWindow(HWND hwndClient)
45{
46 WinSetWindowPos(hwndClient, HWND_TOP, 0, 0, 0, 0, SWP_MAXIMIZE);
47}
48//******************************************************************************
49//******************************************************************************
50
51HWND WIN32API WindowFromDC(HDC hdc);
52HWND Win32ToOS2Handle(HWND hwnd);
53BOOL APIENTRY _GpiEnableYInversion (HPS hps, LONG lHeight);
54
55void InverseDC(HDC hdc, LONG lHeight)
56{
57 USHORT sel = RestoreOS2FS();
58
59 _GpiEnableYInversion( WinGetPS( Win32ToOS2Handle( WindowFromDC(hdc) ) ), lHeight);
60 SetFS(sel);
61
62}
63
64int InitIO()
65{
66 WORD gdt;
67 HRESULT rc;
68 HFILE device;
69 ULONG ulAction;
70
71 rc = DosOpen( "\\dev\\fastio$",
72 &device,
73 &ulAction,
74 0,0,1,
75 OPEN_ACCESS_READWRITE|OPEN_SHARE_DENYNONE,
76 0);
77 if(rc)
78 return rc;
79
80 rc = DosDevIOCtl( device, 118, 100, 0,0,0,&gdt,2,&ulAction);
81
82 DosClose(device);
83
84 if(rc)
85 {
86 return rc;
87 }
88
89 io_init2(gdt);
90
91 return 0;
92}
93
Note: See TracBrowser for help on using the repository browser.