00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <Windows.h>
00023
00024 #include "DCommon.h"
00025 #include "GlideDrv.h"
00026 #include "GMain.h"
00027 #include "Glide.h"
00028 #include "GTHandle.h"
00029 #include "Render.h"
00030
00031 int32 LastError;
00032 char LastErrorStr[255];
00033
00034 static geFloat CurrentGamma;
00035
00036 DRV_EngineSettings EngineSettings;
00037 #define ENABLE_WIREFRAME
00038
00039
00040
00041 geBoolean DRIVERCC DrvInit(DRV_DriverHook *Hook)
00042 {
00043 #ifdef ENABLE_WIREFRAME
00044 {
00045
00046 uint32 KeyState1, KeyState2;
00047 #pragma message("Glide : WireFrame enabled!")
00048 KeyState1 = GetAsyncKeyState(VK_CONTROL);
00049 KeyState2 = GetAsyncKeyState(VK_F8);
00050 }
00051 #endif
00052
00053 return GMain_Startup(Hook);
00054 }
00055
00056
00057
00058 geBoolean DRIVERCC DrvShutdown(void)
00059 {
00060 GMain_Shutdown();
00061
00062 return TRUE;
00063 }
00064
00065
00066
00067 geBoolean DRIVERCC DrvResetAll(void)
00068 {
00069 return GMain_ResetAll();
00070 }
00071
00072
00073
00074 geBoolean DRIVERCC SetGamma(geFloat Gamma)
00075 {
00076 CurrentGamma = Gamma;
00077
00078
00079 return TRUE;
00080 }
00081
00082
00083
00084 geBoolean DRIVERCC GetGamma(geFloat *Gamma)
00085 {
00086
00087 *Gamma = 1.0f;
00088
00089 return TRUE;
00090 }
00091
00092
00093
00094 geBoolean DRIVERCC EnumModes(int32 Driver, char *DriverName, DRV_ENUM_MODES_CB *Cb, void *Context)
00095 {
00096
00097
00098
00099 if (g_BoardInfo.MainRam == 0)
00100 return GE_TRUE;
00101
00102 if (g_BoardInfo.MainRam >= 1)
00103 {
00104 if (!Cb(0, "512x384", 512, 384, Context))
00105 return GE_TRUE;
00106 }
00107
00108 if (g_BoardInfo.MainRam >= 2)
00109 {
00110 if (!Cb(1, "640x480", 640, 480, Context))
00111 return GE_TRUE;
00112 }
00113
00114 if (g_BoardInfo.MainRam >= 4)
00115 {
00116 if (!Cb(2, "800x600", 800, 600, Context))
00117 return GE_TRUE;
00118 }
00119
00120 if (g_BoardInfo.MainRam > 4)
00121 {
00122 if (!Cb(3, "1024x768", 1024, 768, Context))
00123 return GE_TRUE;
00124 }
00125
00126 return GE_TRUE;
00127 }
00128
00129
00130
00131 geBoolean DRIVERCC EnumSubDrivers(DRV_ENUM_DRV_CB *Cb, void *Context)
00132 {
00133
00134 grGlideInit();
00135
00136
00137 if (!GMain_GetBoardInfo(&g_BoardInfo))
00138 return GE_TRUE;
00139
00140 if (g_BoardInfo.MainRam == 0)
00141 return GE_TRUE;
00142
00143 if (!Cb(0, "Glide Driver v"DRV_VMAJS"."DRV_VMINS".", Context))
00144 return GE_TRUE;
00145
00146
00147 grGlideShutdown();
00148
00149 return GE_TRUE;
00150 }
00151
00152 geRDriver_PixelFormat PixelFormats[] =
00153 {
00154 {GE_PIXELFORMAT_8BIT , RDRIVER_PF_3D | RDRIVER_PF_COMBINE_LIGHTMAP},
00155 {GE_PIXELFORMAT_16BIT_4444_ARGB , RDRIVER_PF_3D | RDRIVER_PF_COMBINE_LIGHTMAP},
00156 {GE_PIXELFORMAT_16BIT_565_RGB , RDRIVER_PF_3D | RDRIVER_PF_COMBINE_LIGHTMAP},
00157 {GE_PIXELFORMAT_8BIT , RDRIVER_PF_3D},
00158 {GE_PIXELFORMAT_16BIT_565_RGB , RDRIVER_PF_2D | RDRIVER_PF_CAN_DO_COLORKEY},
00159 {GE_PIXELFORMAT_16BIT_565_RGB , RDRIVER_PF_LIGHTMAP},
00160 {THANDLE_PALETTE_FORMAT , RDRIVER_PF_PALETTE},
00161 {GE_PIXELFORMAT_16BIT_1555_ARGB , RDRIVER_PF_3D | RDRIVER_PF_COMBINE_LIGHTMAP},
00162 };
00163
00164 #define NUM_PIXEL_FORMATS (sizeof(PixelFormats)/sizeof(geRDriver_PixelFormat))
00165
00166
00167
00168 geBoolean DRIVERCC EnumPixelFormats(DRV_ENUM_PFORMAT_CB *Cb, void *Context)
00169 {
00170 int32 i;
00171
00172
00173 for (i=0; i<NUM_PIXEL_FORMATS; i++)
00174 {
00175 if (!Cb(&PixelFormats[i], Context))
00176 return GE_TRUE;
00177 }
00178
00179 return GE_TRUE;
00180 }
00181
00182 geBoolean DRIVERCC DrvUpdateWindow(void)
00183 {
00184 return GE_TRUE;
00185 }
00186 geBoolean DRIVERCC DrvSetActive(geBoolean Active)
00187 {
00188 return GE_TRUE;
00189 }
00190
00191
00192
00193 DRV_Driver GLIDEDRV =
00194 {
00195 "Glide driver. v"DRV_VMAJS"."DRV_VMINS". Copyright 1999, WildTangent Inc.; All Rights Reserved.",
00196 DRV_VERSION_MAJOR,
00197 DRV_VERSION_MINOR,
00198
00199 DRV_ERROR_NONE,
00200 NULL,
00201
00202 EnumSubDrivers,
00203 EnumModes,
00204
00205 EnumPixelFormats,
00206
00207 DrvInit,
00208 DrvShutdown,
00209 DrvResetAll,
00210 DrvUpdateWindow,
00211 DrvSetActive,
00212
00213 GTHandle_Create,
00214 GTHandle_Destroy,
00215
00216 GTHandle_Lock,
00217 GTHandle_UnLock,
00218
00219 GThandle_SetPal,
00220 GThandle_GetPal,
00221
00222 NULL,
00223 NULL,
00224
00225 GTHandle_GetInfo,
00226
00227 BeginScene,
00228 EndScene,
00229 BeginWorld,
00230 EndWorld,
00231 BeginMeshes,
00232 EndMeshes,
00233 BeginModels,
00234 EndModels,
00235
00236 Render_GouraudPoly,
00237 Render_WorldPoly,
00238 Render_MiscTexturePoly,
00239
00240 Render_DrawDecal,
00241
00242 0,0,0,
00243
00244 &CacheInfo,
00245
00246 GMain_ScreenShot,
00247
00248 SetGamma,
00249 GetGamma,
00250
00251 GMain_SetFogEnable,
00252
00253 NULL,
00254 NULL,
00255 NULL
00256 };
00257
00258
00259
00260
00261 DllExport geBoolean DriverHook(DRV_Driver **Driver)
00262 {
00263 GrHwConfiguration g;
00264 FxBool b;
00265
00266 EngineSettings.CanSupportFlags = (DRV_SUPPORT_ALPHA | DRV_SUPPORT_COLORKEY);
00267 EngineSettings.PreferenceFlags = 0;
00268
00269 GLIDEDRV.EngineSettings = &EngineSettings;
00270
00271 *Driver = &GLIDEDRV;
00272
00273
00274 GLIDEDRV.LastErrorStr = LastErrorStr;
00275
00276 SetLastDrvError(DRV_ERROR_NONE, "GLIDE_DRV: No error.");
00277
00278
00279 b=grSstQueryBoards(&g);
00280
00281 return (b && g.num_sst)?TRUE:FALSE;
00282 }
00283
00284
00285
00286 void SetLastDrvError(int32 Error, char *ErrorStr)
00287 {
00288 LastError = Error;
00289
00290 if (ErrorStr)
00291 {
00292 strcpy(LastErrorStr, ErrorStr);
00293 }
00294 else
00295 LastErrorStr[0] = 0;
00296
00297 GLIDEDRV.LastErrorStr = LastErrorStr;
00298 GLIDEDRV.LastError = LastError;
00299 }