| 1 | /* $Id: OS2UTIL.CPP,v 1.11 2001-03-20 23:18:55 mike 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 | extern "C" {
|
|---|
| 52 | BOOL APIENTRY _GpiEnableYInversion (HPS hps, LONG lHeight);
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | void InverseDC(HDC hdc, LONG lHeight)
|
|---|
| 56 | {
|
|---|
| 57 | USHORT sel = RestoreOS2FS();
|
|---|
| 58 |
|
|---|
| 59 | // _GpiEnableYInversion( WinGetPS( Win32ToOS2Handle( WindowFromDC(hdc) ) ), lHeight);
|
|---|
| 60 | _GpiEnableYInversion( hdc, lHeight);
|
|---|
| 61 | SetFS(sel);
|
|---|
| 62 |
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | int InitIO()
|
|---|
| 66 | {
|
|---|
| 67 | WORD gdt;
|
|---|
| 68 | HRESULT rc;
|
|---|
| 69 | HFILE device;
|
|---|
| 70 | ULONG ulAction;
|
|---|
| 71 |
|
|---|
| 72 | rc = DosOpen( "\\dev\\fastio$",
|
|---|
| 73 | &device,
|
|---|
| 74 | &ulAction,
|
|---|
| 75 | 0,0,1,
|
|---|
| 76 | OPEN_ACCESS_READWRITE|OPEN_SHARE_DENYNONE,
|
|---|
| 77 | 0);
|
|---|
| 78 | if(rc)
|
|---|
| 79 | return rc;
|
|---|
| 80 |
|
|---|
| 81 | rc = DosDevIOCtl( device, 118, 100, 0,0,0,&gdt,2,&ulAction);
|
|---|
| 82 |
|
|---|
| 83 | DosClose(device);
|
|---|
| 84 |
|
|---|
| 85 | if(rc)
|
|---|
| 86 | {
|
|---|
| 87 | return rc;
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | io_init2(gdt);
|
|---|
| 91 |
|
|---|
| 92 | return 0;
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|