DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/libs/zmbv/drvproc.cpp
00001 /*
00002  *  Copyright (C) 2002-2013  The DOSBox Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 //
00019 // Zipped Motion Block Video
00020 //
00021 // Based on Huffyuv by Ben Rudiak-Gould.
00022 // which was based on MSYUV sample code, which is:
00023 // Copyright (c) 1993 Microsoft Corporation.
00024 // All Rights Reserved.
00025 //
00026 
00027 #include "zmbv_vfw.h"
00028 
00029 /***************************************************************************
00030  * DriverProc  -  The entry point for an installable driver.
00031  *
00032  * PARAMETERS
00033  * dwDriverId:  For most messages, <dwDriverId> is the DWORD
00034  *     value that the driver returns in response to a <DRV_OPEN> message.
00035  *     Each time that the driver is opened, through the <DrvOpen> API,
00036  *     the driver receives a <DRV_OPEN> message and can return an
00037  *     arbitrary, non-zero value. The installable driver interface
00038  *     saves this value and returns a unique driver handle to the
00039  *     application. Whenever the application sends a message to the
00040  *     driver using the driver handle, the interface routes the message
00041  *     to this entry point and passes the corresponding <dwDriverId>.
00042  *     This mechanism allows the driver to use the same or different
00043  *     identifiers for multiple opens but ensures that driver handles
00044  *     are unique at the application interface layer.
00045  *
00046  *     The following messages are not related to a particular open
00047  *     instance of the driver. For these messages, the dwDriverId
00048  *     will always be zero.
00049  *
00050  *         DRV_LOAD, DRV_FREE, DRV_ENABLE, DRV_DISABLE, DRV_OPEN
00051  *
00052  * hDriver: This is the handle returned to the application by the
00053  *    driver interface.
00054  *
00055  * uiMessage: The requested action to be performed. Message
00056  *     values below <DRV_RESERVED> are used for globally defined messages.
00057  *     Message values from <DRV_RESERVED> to <DRV_USER> are used for
00058  *     defined driver protocols. Messages above <DRV_USER> are used
00059  *     for driver specific messages.
00060  *
00061  * lParam1: Data for this message.  Defined separately for
00062  *     each message
00063  *
00064  * lParam2: Data for this message.  Defined separately for
00065  *     each message
00066  *
00067  * RETURNS
00068  *   Defined separately for each message.
00069  *
00070  ***************************************************************************/
00071 LRESULT PASCAL DriverProc(DWORD dwDriverID, HDRVR hDriver, UINT uiMessage, LPARAM lParam1, LPARAM lParam2) {
00072   CodecInst* pi = (CodecInst*)dwDriverID;
00073 
00074   switch (uiMessage) {
00075     case DRV_LOAD:
00076       return (LRESULT)1L;
00077 
00078     case DRV_FREE:
00079       return (LRESULT)1L;
00080 
00081     case DRV_OPEN:
00082       // GAAH! This used to return a pointer to 0xFFFF0000 when lParam==0!
00083       return (LRESULT)(DWORD)(UINT) Open((ICOPEN*) lParam2);
00084 
00085     case DRV_CLOSE:
00086       if (pi) Close(pi);
00087       return (LRESULT)1L;
00088 
00089     /*********************************************************************
00090 
00091       state messages
00092 
00093     *********************************************************************/
00094 
00095     // cwk
00096     case DRV_QUERYCONFIGURE:    // configuration from drivers applet
00097       return (LRESULT)1L;
00098 
00099     case DRV_CONFIGURE:
00100       pi->Configure((HWND)lParam1);
00101       return DRV_OK;
00102 
00103     case ICM_CONFIGURE:
00104       //
00105       //  return ICERR_OK if you will do a configure box, error otherwise
00106       //
00107       if (lParam1 == -1)
00108         return pi->QueryConfigure() ? ICERR_OK : ICERR_UNSUPPORTED;
00109       else
00110         return pi->Configure((HWND)lParam1);
00111 
00112     case ICM_ABOUT:
00113       //
00114       //  return ICERR_OK if you will do a about box, error otherwise
00115       //
00116       if (lParam1 == -1)
00117         return pi->QueryAbout() ? ICERR_OK : ICERR_UNSUPPORTED;
00118       else
00119         return pi->About((HWND)lParam1);
00120 
00121     case ICM_GETSTATE:
00122       return pi->GetState((LPVOID)lParam1, (DWORD)lParam2);
00123 
00124     case ICM_SETSTATE:
00125       return pi->SetState((LPVOID)lParam1, (DWORD)lParam2);
00126 
00127     case ICM_GETINFO:
00128       return pi->GetInfo((ICINFO*)lParam1, (DWORD)lParam2);
00129 
00130     case ICM_GETDEFAULTQUALITY:
00131       if (lParam1) {
00132         *((LPDWORD)lParam1) = 10000;
00133         return ICERR_OK;
00134       }
00135       break;
00136 
00137     /*********************************************************************
00138 
00139       compression messages
00140 
00141     *********************************************************************/
00142 
00143     case ICM_COMPRESS_QUERY:
00144       return pi->CompressQuery((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
00145 
00146     case ICM_COMPRESS_BEGIN:
00147       return pi->CompressBegin((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
00148 
00149     case ICM_COMPRESS_GET_FORMAT:
00150       return pi->CompressGetFormat((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
00151 
00152     case ICM_COMPRESS_GET_SIZE:
00153       return pi->CompressGetSize((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
00154 
00155     case ICM_COMPRESS:
00156       return pi->Compress((ICCOMPRESS*)lParam1, (DWORD)lParam2);
00157 
00158     case ICM_COMPRESS_END:
00159       return pi->CompressEnd();
00160 
00161     /*********************************************************************
00162 
00163       decompress messages
00164 
00165     *********************************************************************/
00166 
00167     case ICM_DECOMPRESS_QUERY:
00168       return pi->DecompressQuery((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
00169 
00170     case ICM_DECOMPRESS_BEGIN:
00171       return pi->DecompressBegin((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
00172 
00173     case ICM_DECOMPRESS_GET_FORMAT:
00174       return pi->DecompressGetFormat((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
00175 
00176     case ICM_DECOMPRESS_GET_PALETTE:
00177       return pi->DecompressGetPalette((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
00178 
00179     case ICM_DECOMPRESS:
00180       return pi->Decompress((ICDECOMPRESS*)lParam1, (DWORD)lParam2);
00181 
00182     case ICM_DECOMPRESS_END:
00183       return pi->DecompressEnd();
00184 
00185     /*********************************************************************
00186 
00187       standard driver messages
00188 
00189     *********************************************************************/
00190 
00191     case DRV_DISABLE:
00192     case DRV_ENABLE:
00193       return (LRESULT)1L;
00194 
00195     case DRV_INSTALL:
00196     case DRV_REMOVE:
00197       return (LRESULT)DRV_OK;
00198   }
00199 
00200   if (uiMessage < DRV_USER)
00201     return DefDriverProc(dwDriverID, hDriver, uiMessage, lParam1, lParam2);
00202   else
00203     return ICERR_UNSUPPORTED;
00204 }
00205 
00206 
00207 HMODULE hmoduleCodec=0;
00208 
00209 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) {
00210   hmoduleCodec = (HMODULE) hinstDLL;
00211   return TRUE;
00212 }