[21875] | 1 | /* $Id: initterm.cpp,v 1.20 2003-01-21 11:20:35 sandervl Exp $
|
---|
[9698] | 2 | *
|
---|
[21875] | 3 | * DDRAW DLL entry point
|
---|
[9698] | 4 | *
|
---|
| 5 | * Copyright 1998 Sander van Leeuwen
|
---|
| 6 | * Copyright 1998 Peter Fitzsimmons
|
---|
| 7 | *
|
---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #define INCL_DOSMODULEMGR
|
---|
| 12 | #define INCL_DOSPROCESS
|
---|
| 13 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
| 14 | #include <stdlib.h>
|
---|
| 15 | #include <stdio.h>
|
---|
| 16 | #include <string.h>
|
---|
| 17 | #include <odin.h>
|
---|
| 18 | #include <win32type.h>
|
---|
| 19 | #include <winconst.h>
|
---|
| 20 | #include <odinlx.h>
|
---|
| 21 | #include <dbglog.h>
|
---|
[21875] | 22 | #include <exitlist.h>
|
---|
| 23 | #include <misc.h> /*PLF Wed 98-03-18 23:18:15*/
|
---|
| 24 | #include <initdll.h>
|
---|
| 25 |
|
---|
| 26 | #ifdef FULLSCREEN_DDRAW
|
---|
| 27 | #include "os2fsdd.h" // For RestorePM()
|
---|
| 28 | #endif
|
---|
[9698] | 29 | #include "divewrap.h"
|
---|
| 30 |
|
---|
[21875] | 31 | // Win32 resource table (produced by wrc)
|
---|
| 32 | extern DWORD ddraw_PEResTab;
|
---|
[9698] | 33 |
|
---|
| 34 | char ddrawPath[CCHMAXPATH] = "";
|
---|
| 35 | static HMODULE dllHandle = 0;
|
---|
| 36 |
|
---|
[21875] | 37 | #if 0 // not currently needed
|
---|
| 38 | BOOL WINAPI LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
|
---|
| 39 | {
|
---|
| 40 | switch (fdwReason)
|
---|
| 41 | {
|
---|
| 42 | case DLL_PROCESS_ATTACH:
|
---|
| 43 | return TRUE;
|
---|
[9698] | 44 |
|
---|
[21875] | 45 | case DLL_THREAD_ATTACH:
|
---|
| 46 | case DLL_THREAD_DETACH:
|
---|
| 47 | return TRUE;
|
---|
| 48 |
|
---|
| 49 | case DLL_PROCESS_DETACH:
|
---|
| 50 | return TRUE;
|
---|
| 51 | }
|
---|
| 52 | return FALSE;
|
---|
| 53 | }
|
---|
| 54 | #endif
|
---|
| 55 |
|
---|
| 56 | ULONG SYSTEM DLL_InitDDraw(ULONG hModule)
|
---|
[9698] | 57 | {
|
---|
[21875] | 58 | APIRET rc;
|
---|
[9698] | 59 |
|
---|
[21875] | 60 | DosQueryModuleName(hModule, CCHMAXPATH, ddrawPath);
|
---|
| 61 | char *endofpath = strrchr(ddrawPath, '\\');
|
---|
| 62 | if (endofpath)
|
---|
| 63 | *(endofpath+1) = '\0';
|
---|
[9698] | 64 |
|
---|
[21875] | 65 | CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
|
---|
[9698] | 66 |
|
---|
[21875] | 67 | dllHandle = RegisterLxDll(hModule, NULL, (PVOID)&ddraw_PEResTab,
|
---|
| 68 | DDRAW_MAJORIMAGE_VERSION, DDRAW_MINORIMAGE_VERSION,
|
---|
| 69 | IMAGE_SUBSYSTEM_WINDOWS_GUI);
|
---|
| 70 | if (dllHandle == 0)
|
---|
| 71 | return -1;
|
---|
[9698] | 72 |
|
---|
[21875] | 73 | DiveLoad();
|
---|
[9698] | 74 |
|
---|
[21875] | 75 | #ifdef FULLSCREEN_DDRAW
|
---|
| 76 | return EXITLIST_NONCOREDLL;
|
---|
| 77 | #else
|
---|
| 78 | return 0;
|
---|
| 79 | #endif
|
---|
| 80 | }
|
---|
[9698] | 81 |
|
---|
[21875] | 82 | void SYSTEM DLL_TermDDraw(ULONG hModule)
|
---|
| 83 | {
|
---|
| 84 | #ifdef FULLSCREEN_DDRAW
|
---|
| 85 | dprintf(("DDRAW processing exitlist"));
|
---|
| 86 | RestorePM();
|
---|
| 87 | dprintf(("DDRAW exitlist done"));
|
---|
| 88 | #endif
|
---|
| 89 |
|
---|
| 90 | DiveUnload();
|
---|
| 91 |
|
---|
| 92 | if (dllHandle)
|
---|
| 93 | UnregisterLxDll(dllHandle);
|
---|
[9698] | 94 | }
|
---|
[21875] | 95 |
|
---|
| 96 | ULONG SYSTEM DLL_Init(ULONG hModule)
|
---|
| 97 | {
|
---|
| 98 | if (DLL_InitDefault(hModule) == -1)
|
---|
| 99 | return -1;
|
---|
| 100 | return DLL_InitDDraw(hModule);
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | void SYSTEM DLL_Term(ULONG hModule)
|
---|
| 104 | {
|
---|
| 105 | DLL_TermDDraw(hModule);
|
---|
| 106 | DLL_TermDefault(hModule);
|
---|
| 107 | }
|
---|