| 1 | /* $Id: OS2UTIL.CPP,v 1.10 2001-01-02 18:21:39 sandervl 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 | //****************************************************************************** | 
|---|
| 20 | char *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 | //****************************************************************************** | 
|---|
| 34 | void 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 | //****************************************************************************** | 
|---|
| 44 | void OS2MaximizeWindow(HWND hwndClient) | 
|---|
| 45 | { | 
|---|
| 46 | WinSetWindowPos(hwndClient, HWND_TOP, 0, 0, 0, 0, SWP_MAXIMIZE); | 
|---|
| 47 | } | 
|---|
| 48 | //****************************************************************************** | 
|---|
| 49 | //****************************************************************************** | 
|---|
| 50 |  | 
|---|
| 51 | BOOL    APIENTRY _GpiEnableYInversion (HPS hps, LONG lHeight); | 
|---|
| 52 |  | 
|---|
| 53 | void InverseDC(HDC hdc, LONG lHeight) | 
|---|
| 54 | { | 
|---|
| 55 | USHORT sel = RestoreOS2FS(); | 
|---|
| 56 |  | 
|---|
| 57 | // _GpiEnableYInversion( WinGetPS( Win32ToOS2Handle( WindowFromDC(hdc) ) ), lHeight); | 
|---|
| 58 | _GpiEnableYInversion( hdc, lHeight); | 
|---|
| 59 | SetFS(sel); | 
|---|
| 60 |  | 
|---|
| 61 | } | 
|---|
| 62 |  | 
|---|
| 63 | int InitIO() | 
|---|
| 64 | { | 
|---|
| 65 | WORD  gdt; | 
|---|
| 66 | HRESULT rc; | 
|---|
| 67 | HFILE  device; | 
|---|
| 68 | ULONG  ulAction; | 
|---|
| 69 |  | 
|---|
| 70 | rc = DosOpen( "\\dev\\fastio$", | 
|---|
| 71 | &device, | 
|---|
| 72 | &ulAction, | 
|---|
| 73 | 0,0,1, | 
|---|
| 74 | OPEN_ACCESS_READWRITE|OPEN_SHARE_DENYNONE, | 
|---|
| 75 | 0); | 
|---|
| 76 | if(rc) | 
|---|
| 77 | return rc; | 
|---|
| 78 |  | 
|---|
| 79 | rc = DosDevIOCtl( device, 118, 100, 0,0,0,&gdt,2,&ulAction); | 
|---|
| 80 |  | 
|---|
| 81 | DosClose(device); | 
|---|
| 82 |  | 
|---|
| 83 | if(rc) | 
|---|
| 84 | { | 
|---|
| 85 | return rc; | 
|---|
| 86 | } | 
|---|
| 87 |  | 
|---|
| 88 | io_init2(gdt); | 
|---|
| 89 |  | 
|---|
| 90 | return 0; | 
|---|
| 91 | } | 
|---|
| 92 |  | 
|---|