From e115acc717d9ca8302175e7bc4b2d3d1044f3fa3 Mon Sep 17 00:00:00 2001 From: koolsmoky <> Date: Thu, 26 Jun 2003 19:23:59 +0000 Subject: [PATCH] moved OS and CPU flags from bInfo to _GlideRoot --- glide3x/h5/glide3/src/fxglide.h | 82 +++--------- glide3x/h5/glide3/src/gpci.c | 156 ++--------------------- glide3x/h5/glide3/src/gsfc.c | 6 +- glide3x/h5/glide3/src/gsst.c | 19 ++- glide3x/h5/glide3/src/gthread.c | 11 +- glide3x/h5/minihwc/minihwc.c | 218 ++++++++++++++++++-------------- glide3x/h5/minihwc/minihwc.h | 16 ++- glide3x/h5/minihwc/win_mode.c | 49 +++---- 8 files changed, 202 insertions(+), 355 deletions(-) diff --git a/glide3x/h5/glide3/src/fxglide.h b/glide3x/h5/glide3/src/fxglide.h index f211fa4..2725e3d 100644 --- a/glide3x/h5/glide3/src/fxglide.h +++ b/glide3x/h5/glide3/src/fxglide.h @@ -2020,19 +2020,14 @@ typedef struct GrGC_s ** stuff near the top is accessed a lot */ struct _GlideRoot_s { - int p6Fencer; /* xchg to here to keep this in cache!!! */ - FxU32 - tlsIndex, - tlsOffset; + int p6Fencer; /* xchg to here to keep this in cache!!! */ + FxU32 tlsIndex; + FxU32 tlsOffset; - int current_sst; - _p_info - CPUType; /* Colourless's CPUID */ - FxBool - OSWin95; - FxI32 - windowsInit; /* Is the fullscreen part of glide initialized? */ + int current_sst; + FxI32 windowsInit; /* Is the fullscreen part of glide initialized? */ + _p_info CPUType; /* CPUID */ #if !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP FxU32 paramCount; @@ -2041,9 +2036,9 @@ struct _GlideRoot_s { #endif /* !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP */ #if GLIDE_MULTIPLATFORM - GrGCFuncs - curGCFuncs; /* Current dd Function pointer table */ + GrGCFuncs curGCFuncs; /* Current dd Function pointer table */ #endif + int initialized; struct { /* constant pool (minimizes cache misses) */ @@ -2160,6 +2155,16 @@ struct _GlideRoot_s { GrTexDownloadProcVector* nullTexProcs; } deviceArchProcs; +#if (GLIDE_PLATFORM & GLIDE_OS_WIN32) +#define OS_WIN32_95 0 +#define OS_WIN32_98 1 +#define OS_WIN32_ME 2 +#define OS_WIN32_NT4 3 +#define OS_WIN32_2K 4 +#define OS_WIN32_XP 5 + FxI32 OS; +#endif + }; extern struct _GlideRoot_s GR_CDECL _GlideRoot; @@ -3182,57 +3187,6 @@ _grErrorCallback(const char* const procName, va_list args); #endif -#if 0 /* we now use Colourless's CPUID */ -/* Returns 16:16 pair indicating the cpu's manufacturer and its - * capabilities. Non-Intel processors should have a vendor id w/ the - * high bit set so that it appears to be a negative #. The value of - * the capability field is assumed to be a monotonically increasing - * inclusive set. - * - * Unknown: - * 0xFFFF:0xFFFF - * - * Intel: 0x0000 - * 4: 486 and lower - * 5: Pentium - * 6: P6 Core or better - * 7: p6 Core w/ katmai (instructions/write buffers) - * - * AMD: 0x8001 - * 1: MMX - * 2: 3DNow!(tm) - * 4: K6-type MTRRs - * 8: P2-type MTRRs - * - * Cyrix: 0x8002 - * 1: MMX - * 2: 3DNow!(tm) - * - * IDT: 0x8003 - * 1: MMX - * 2: 3DNow!(tm) - * - */ - -enum { - kCPUVendorIntel = 0x0000, - kCPUVendorAMD = 0x8001, - kCPUVendorCyrix = 0x8002, - kCPUVendorIDT = 0x8003, - kCPUVendorTransmeta = 0x8004, - kCPUVendorUnknown = 0xFFFF -}; - -extern FxI32 GR_CDECL -_cpu_detect_asm(void); - -extern void GR_CDECL -single_precision_asm(void); - -extern void GR_CDECL -double_precision_asm(void); -#endif /* we now use Colourless's CPUID */ - /* The translation macros convert from the reasonable log2 formats to * the somewhat whacked (For those of us coming back to sst1 things * from sst2 w/ its saner lms notation) sst1 lod format. The api and diff --git a/glide3x/h5/glide3/src/gpci.c b/glide3x/h5/glide3/src/gpci.c index 7659acd..60b2597 100644 --- a/glide3x/h5/glide3/src/gpci.c +++ b/glide3x/h5/glide3/src/gpci.c @@ -1318,17 +1318,13 @@ void _GlideInitEnvironment(int which) { #define FN_NAME "_GlideInitEnvironment" - /* int i; */ + int i; FxU32 ditherMode; const char* envStr; FxU32 ctx = which; double pi = 3.1415926535; const char* envStr2; -#if (GLIDE_PLATFORM & GLIDE_OS_WIN32) - OSVERSIONINFO ovi; -#endif - if (_GlideRoot.initialized) /* only execute once */ return; @@ -1338,15 +1334,7 @@ _GlideInitEnvironment(int which) #if (GLIDE_PLATFORM & GLIDE_OS_WIN32) - - ovi.dwOSVersionInfoSize = sizeof ( ovi ); - GetVersionEx ( &ovi ); - if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT) - _GlideRoot.OSWin95 = 0; - else - _GlideRoot.OSWin95 = 1; - GDBG_INFO(80, "%s: OS = %s\n", FN_NAME, _GlideRoot.OSWin95 ? "W9X" : "WNT"); - + _GlideRoot.OS = hwcGetOS(); #if defined(FX_DLL_ENABLE) && (GLIDE_PLATFORM & GLIDE_OS_WIN32) { /* GMT: display the DLL pathname for sanity checking */ char buf[132] = "failed"; @@ -1908,130 +1896,15 @@ _GlideInitEnvironment(int which) _GlideRoot.environment.useAppGamma = GLIDE_GETENV("FX_GLIDE_USE_APP_GAMMA", GC.bInfo->RegPath, 1L); -#if 0 /* use Colourless's CPUID */ - _GlideRoot.CPUType = GLIDE_GETENV("FX_CPU", GC.bInfo->RegPath, _cpu_detect_asm() ); - /* The FP part of SSE introduces a new architectural state and therefore - requires support from the operating system. So even if CPUID indicates - support for SSE FP, the application might not be able to use it. If - CPUID indicates support for SSE FP, check here whether it is also - supported by the OS, and turn off the SSE FP feature bit if there - is no OS support for SSE FP. - - Operating systems that do not support SSE FP return an illegal - instruction exception if execution of an SSE FP instruction is performed. - Here, a sample SSE FP instruction is executed, and is checked for an - exception using the (non-standard) __try/__except mechanism - of Microsoft Visual C. - Although CR0 can be called from ring3, CR4 must be called from ring0 - which prevents us from using the CR0.EM and the CR4.OSFXSR bits. The - main reason for this indirect method. - */ - if((_GlideRoot.CPUType & 0x10L) == 0x10UL) { - __try { - __asm _emit 0x0f - __asm _emit 0x56 - __asm _emit 0xC0 ;; orps xmm0, xmm0 - } - __except(EXCEPTION_EXECUTE_HANDLER) { - GDBG_INFO(0,"SSE is not supported by OS\n"); - _GlideRoot.CPUType &= ~0x10UL; - } - } - if((_GlideRoot.CPUType & 0x40L) == 0x40UL) { - __try { - __asm _emit 0x66 - __asm _emit 0x0f - __asm _emit 0x57 - __asm _emit 0xc0 ;; xorpd xmm0, xmm0 - } - __except(EXCEPTION_EXECUTE_HANDLER) { - GDBG_INFO(0,"SSE2 is not supported by OS\n"); - _GlideRoot.CPUType &= ~0x40UL; - } - } - GDBG_INFO(0," cpu: 0x%x\n",_GlideRoot.CPUType); - - /* Setup the basic proc tables based on the cpu type. */ - { - /* Default case - rasterization routines */ - _GlideRoot.deviceArchProcs.curTriProcs = _triSetupProcs + 0; - _GlideRoot.deviceArchProcs.curDrawTrisProc = _grDrawTriangles_Default; - _GlideRoot.deviceArchProcs.curVertexListProcs = _vertexListProcs[0]; - - /* Default case - texture download procs */ - _GlideRoot.deviceArchProcs.curTexProcs = _texDownloadProcs + 0; - - /* null proc case */ -#define ARRAY_LAST(__array) ((sizeof(__array) / sizeof((__array)[0])) - 1) - _GlideRoot.deviceArchProcs.nullTriProcs = _triSetupProcs + ARRAY_LAST(_triSetupProcs); - _GlideRoot.deviceArchProcs.nullDrawTrisProc = _grDrawTriangles_null; - _GlideRoot.deviceArchProcs.nullVertexListProcs = _vertexListProcs[ARRAY_LAST(_vertexListProcs)]; - _GlideRoot.deviceArchProcs.nullTexProcs = _texDownloadProcs + ARRAY_LAST(_texDownloadProcs); -#undef ARRAY_LAST - - /* Check for vendor specific optimization cases */ - switch((_GlideRoot.CPUType & 0xFFFF0000UL) >> 16UL) { - case kCPUVendorIntel: - GDBG_INFO(0,"Intel detected\n"); - break; - case kCPUVendorAMD: - GDBG_INFO(0,"AMD detected\n"); - break; - case kCPUVendorCyrix: - GDBG_INFO(0,"Cyrix detected\n"); - break; - case kCPUVendorIDT: - GDBG_INFO(0,"IDT detected\n"); - break; - case kCPUVendorTransmeta: - GDBG_INFO(0,"Transmeta detected\n"); - break; - case kCPUVendorUnknown: - default: - GDBG_INFO(0,"unknown CPU\n"); - break; - } - - if(((_GlideRoot.CPUType & 0xFFFF0000UL) >> 16UL) != kCPUVendorUnknown) { -#if GL_MMX - if ((_GlideRoot.CPUType & 0x1L) == 0x1UL) { /* check for MMX feature */ - GDBG_INFO(0,"using MMX\n"); - _GlideRoot.deviceArchProcs.curTexProcs = _texDownloadProcs + 2; - } -#endif /* GL_MMX */ -#if GL_SSE - if ((_GlideRoot.CPUType & 0x10L) == 0x10UL) { /* check for SSE FP feature */ - GDBG_INFO(0,"using SSE\n"); - _GlideRoot.deviceArchProcs.curTriProcs = _triSetupProcs + 2; - _GlideRoot.deviceArchProcs.curDrawTrisProc = _grDrawTriangles_SSE; - _GlideRoot.deviceArchProcs.curVertexListProcs = _vertexListProcs[2]; - } -#endif /* GL_SSE */ -#if GL_AMD3D - if ((_GlideRoot.CPUType & 0x2L) == 0x2UL) { /* check for 3DNow! feature */ - GDBG_INFO(0,"using 3DNow!\n"); - _GlideRoot.deviceArchProcs.curTriProcs = _triSetupProcs + 1; - _GlideRoot.deviceArchProcs.curDrawTrisProc = _grDrawTriangles_3DNow; - _GlideRoot.deviceArchProcs.curVertexListProcs = _vertexListProcs[1]; - _GlideRoot.deviceArchProcs.curTexProcs = _texDownloadProcs + 1; - } -#endif /* GL_AMD3D */ -#if GL_SSE2 - if ((_GlideRoot.CPUType & 0x40L) == 0x40UL) { /* check for SSE2 feature */ - GDBG_INFO(0,"using SSE2\n"); - _GlideRoot.deviceArchProcs.curTexProcs = _texDownloadProcs + 3; - } -#endif /* GL_SSE2*/ - } - - } - -#else - - /* Get CPU type */ + /* Get CPU Info */ _cpuid (&_GlideRoot.CPUType); +#ifndef __linux__ + /* Pass retrieved CPU Info into minihwc */ + hwcSetCPUInfo(&_GlideRoot.CPUType); +#endif + /* Setup the basic proc tables based on the cpu type. */ { //int mmx_3dnow; @@ -2053,7 +1926,7 @@ _GlideInitEnvironment(int which) /* Check for vendor specific optimization cases */ GDBG_INFO( 0," CPU Vendor: %s\n", _GlideRoot.CPUType.v_name); - GDBG_INFO( 0," CPU Model: %s\n", _GlideRoot.CPUType.model_name); + GDBG_INFO( 0," CPU Model : %s\n", _GlideRoot.CPUType.model_name); GDBG_INFO(80," MMX Support: %c\n", _GlideRoot.CPUType.os_support&_CPU_FEATURE_MMX ? 'Y' : 'N'); GDBG_INFO(80," SSE Support: %c\n", _GlideRoot.CPUType.os_support&_CPU_FEATURE_SSE ? 'Y' : 'N'); GDBG_INFO(80," SSE2 Support: %c\n", _GlideRoot.CPUType.os_support&_CPU_FEATURE_SSE2 ? 'Y' : 'N'); @@ -2070,7 +1943,7 @@ _GlideInitEnvironment(int which) #if GL_MMX if (_GlideRoot.CPUType.os_support & _CPU_FEATURE_MMX) { /* check for MMX feature */ - GDBG_INFO(80,"Using MMX Texture Download Functions\n"); + GDBG_INFO(0,"Using MMX Texture Download Functions\n"); _GlideRoot.deviceArchProcs.curTexProcs = _texDownloadProcs + 2; } #endif /* GL_MMX */ @@ -2084,7 +1957,7 @@ _GlideInitEnvironment(int which) #endif /* GL_SSE */ #if GL_AMD3D if (_GlideRoot.CPUType.os_support & _CPU_FEATURE_3DNOW) { /* check for 3DNow! feature */ - GDBG_INFO(80,"Using 3DNow! Texture Download Functions\n"); + GDBG_INFO(0,"Using 3DNow! Texture Download Functions\n"); _GlideRoot.deviceArchProcs.curTexProcs = _texDownloadProcs + 1; GDBG_INFO(0,"Using 3DNow! Geometry Functions\n"); @@ -2100,8 +1973,6 @@ _GlideInitEnvironment(int which) } #endif /* GL_SSE2*/ } - -#endif /* use Colourless's CPUID */ #if __POWERPC__ && PCI_BUMP_N_GRIND @@ -2164,13 +2035,10 @@ _GlideInitEnvironment(int which) #endif } */ - - /* KoolSmoky - just get the info for the requested sst + /* display info for all sst devices */ for (i = 0; i < _GlideRoot.hwConfig.num_sst; i++) { displayBoardInfo(i, &_GlideRoot.hwConfig); } - */ - displayBoardInfo(ctx, &_GlideRoot.hwConfig); _GlideRoot.initialized = FXTRUE; /* save this for the end */ } /* _GlideInitEnvironment */ diff --git a/glide3x/h5/glide3/src/gsfc.c b/glide3x/h5/glide3/src/gsfc.c index 02c1be2..a82f725 100644 --- a/glide3x/h5/glide3/src/gsfc.c +++ b/glide3x/h5/glide3/src/gsfc.c @@ -418,8 +418,10 @@ GR_EXT_ENTRY(grSurfaceReleaseContext, void , (GrContext_t ctx) ) * context by yanking out the hardware mapping! %%KCD */ #if (GLIDE_OS & GLIDE_OS_WIN32) - if ( !gc->bInfo->osNT ) - hwcUnmapMemory9x ( gc->bInfo ); + if ((_GlideRoot.OS == OS_WIN32_95) || + (_GlideRoot.OS == OS_WIN32_98) || + (_GlideRoot.OS == OS_WIN32_ME)) + hwcUnmapMemory9x ( gc->bInfo ); #endif /* Free any windowed fifo associated w/ the context */ diff --git a/glide3x/h5/glide3/src/gsst.c b/glide3x/h5/glide3/src/gsst.c index f97ae55..8de7f00 100644 --- a/glide3x/h5/glide3/src/gsst.c +++ b/glide3x/h5/glide3/src/gsst.c @@ -3097,15 +3097,9 @@ GR_ENTRY(grSstWinClose, FxBool, (GrContext_t context)) ** OpenGL fullscreen apps can run. If not, we will cause a lot ** of problems. */ -#if 0 if (_GlideRoot.environment.is_opengl == FXTRUE) { - /* KoolSmoky- don't release Exclusive mode if we're running - * in NT5.1. This may cause probems. but, ohwell. - * Fix me! */ - if( !gc->bInfo->osNT51 ) - hwcRestoreVideo(gc->bInfo); + hwcRestoreVideo(gc->bInfo); } -#endif #ifndef __linux__ if (gc->lostContext) { @@ -3222,10 +3216,13 @@ GR_ENTRY(grSstWinClose, FxBool, (GrContext_t context)) #if (GLIDE_OS & GLIDE_OS_WIN32) if (_GlideRoot.environment.is_opengl != FXTRUE) { - if ( gc->bInfo->osNT ) - hwcUnmapMemory(); - else - hwcUnmapMemory9x ( gc->bInfo ); + if ((_GlideRoot.OS == OS_WIN32_95) || + (_GlideRoot.OS == OS_WIN32_98) || + (_GlideRoot.OS == OS_WIN32_ME)) { + hwcUnmapMemory9x ( gc->bInfo ); + } else { + hwcUnmapMemory(); + } } #endif diff --git a/glide3x/h5/glide3/src/gthread.c b/glide3x/h5/glide3/src/gthread.c index 85fec35..efea0e5 100644 --- a/glide3x/h5/glide3/src/gthread.c +++ b/glide3x/h5/glide3/src/gthread.c @@ -57,11 +57,14 @@ initThreadStorage( void ) threadInit = 1; _GlideRoot.tlsIndex = TlsAlloc(); } - if (_GlideRoot.OSWin95) - _GlideRoot.tlsOffset = W95_TLS_INDEX_TO_OFFSET(_GlideRoot.tlsIndex); - else - _GlideRoot.tlsOffset = WNT_TLS_INDEX_TO_OFFSET(_GlideRoot.tlsIndex); + if ((_GlideRoot.OS == OS_WIN32_95) || + (_GlideRoot.OS == OS_WIN32_98) || + (_GlideRoot.OS == OS_WIN32_ME)) { + _GlideRoot.tlsOffset = W95_TLS_INDEX_TO_OFFSET(_GlideRoot.tlsIndex); + } else { + _GlideRoot.tlsOffset = WNT_TLS_INDEX_TO_OFFSET(_GlideRoot.tlsIndex); + } } /* initThreadStorage */ void setThreadValue( FxU32 value ) { diff --git a/glide3x/h5/minihwc/minihwc.c b/glide3x/h5/minihwc/minihwc.c index 0123b9b..75ca202 100644 --- a/glide3x/h5/minihwc/minihwc.c +++ b/glide3x/h5/minihwc/minihwc.c @@ -1026,6 +1026,7 @@ static __inline int min (int x, int y) #define HWC_RAW_LFB_STRIDE SST_RAW_LFB_ADDR_STRIDE_8K hwcInfo hInfo; +_p_info *CPUInfo = NULL; #define MAX_ERROR_SIZE 1024 static char errorString[MAX_ERROR_SIZE]; @@ -1190,15 +1191,6 @@ static hwcBoardInfo *curBI = NULL; #ifdef HWC_EXT_INIT -#if 0 -#if !defined(HMONITOR_DECLARED) // AJB- Make def compatible w/ vc6 headers - -typedef void *HMONITOR; -//DECLARE_HANDLE(HMONITOR); - -#define HMONITOR_DECLARED -#endif -#endif typedef BOOL (CALLBACK* MONITORENUMPROC)(HMONITOR, HDC, LPRECT, LPARAM); typedef WINUSERAPI BOOL WINAPI EnumDisplayMonitors_func( HDC hdc, @@ -1219,11 +1211,12 @@ static char * getRegPathEx() { char *retVal = NULL; - OSVERSIONINFO ovi; - - ovi.dwOSVersionInfoSize = sizeof ( ovi ); - GetVersionEx ( &ovi ); - if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT) { + FxI32 OS = hwcGetOS(); + + if ((OS == OS_WIN32_NT4) || + (OS == OS_WIN32_2K) || + (OS == OS_WIN32_XP)) + { HKEY hKey; DWORD type ; static char strval[255]; @@ -1328,10 +1321,6 @@ monitorEnum( HMONITOR handle, HDC dc, LPRECT rect, LPARAM param ) drvName = "DISPLAY", devName = NULL; - OSVERSIONINFO ovi; - ovi.dwOSVersionInfoSize = sizeof ( ovi ); - GetVersionEx ( &ovi ); - /* If we're on a multi-mon capable system then we may have * different display type devices so we have to get the device * name explicitly for the CreateDC call. @@ -1471,11 +1460,7 @@ hwcInit(FxU32 vID, FxU32 dID) DevEnumRec data[HWC_MAX_BOARDS*2]; int monitor; - _p_info CPUInfo; - OSVERSIONINFO ovi; - - ovi.dwOSVersionInfoSize = sizeof ( ovi ); - GetVersionEx ( &ovi ); + FxI32 OS = hwcGetOS(); GDBG_INFO(80, "%s\n", FN_NAME); errorString[0] = '\0'; @@ -1642,25 +1627,16 @@ hwcInit(FxU32 vID, FxU32 dID) data[num_monitor].dc = hdc; strcpy(data[num_monitor].DeviceName, DispDev.DeviceName); - switch(ovi.dwPlatformId) { - case VER_PLATFORM_WIN32_NT: - { - // win2k/xp + if (OS == OS_WIN32_95) { + strcpy(data[num_monitor].RegPath, getRegPathEx()); + } else if ( (OS == OS_WIN32_98) || (OS == OS_WIN32_ME) ) { + strcpy(data[num_monitor].RegPath, DispDev.DeviceKey); + } else { char *pdest; pdest = strstr(DispDev.DeviceKey, "\\Service"); strcpy(data[num_monitor].RegPath, "SYSTEM\\CurrentControlSet"); strcat(data[num_monitor].RegPath, pdest); - } - break; - case VER_PLATFORM_WIN32_WINDOWS: - { - if(ovi.dwMinorVersion < 10) - strcpy(data[num_monitor].RegPath, getRegPathEx()); // win95 - else - strcpy(data[num_monitor].RegPath, DispDev.DeviceKey); // win98/me - } - break; - } + } GDBG_INFO(80, "DeviceKey: %s\n", data[num_monitor].RegPath); @@ -1772,16 +1748,6 @@ hwcInit(FxU32 vID, FxU32 dID) } } } - - /* Colourless - Get CPUInfo */ - _cpuid (&CPUInfo); - { - /* No CPU Extensions Allowed */ - for (monitor = 0; monitor < num_monitor; monitor++) { - const char *no_cpu_ext = GETENV("FX_GLIDE_NO_CPU_EXTENSIONS", data[monitor].RegPath); - if (no_cpu_ext && atoi(no_cpu_ext)) CPUInfo.feature = CPUInfo.os_support = 0; - } - } hInfo.nBoards = 0; for (monitor = 0; monitor < num_monitor; monitor++) { @@ -1810,21 +1776,6 @@ hwcInit(FxU32 vID, FxU32 dID) GDBG_INFO(80,"hInfo : [%d] DeviceName: %s\n", monitor, hInfo.boardInfo[monitor].DeviceName); /* hInfo.boardInfo[monitor].extContextID = ctxRes.Ext.optData.allocContextRes.contextID; */ - if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT) { - hInfo.boardInfo[monitor].osNT = FXTRUE; - if ( ovi.dwMajorVersion >= 5 && ovi.dwMinorVersion >= 1) { - hInfo.boardInfo[monitor].osNT51 = FXTRUE; - GDBG_INFO(80, FN_NAME ": OS: NT5.1\n"); - } else { - hInfo.boardInfo[monitor].osNT51 = FXFALSE; - GDBG_INFO(80, FN_NAME ": OS: NT\n"); - } - } else { - hInfo.boardInfo[monitor].osNT = FXFALSE; - hInfo.boardInfo[monitor].osNT51 = FXFALSE; - GDBG_INFO(80, FN_NAME ": OS: 9X\n"); - } - ctxReq.which = HWCEXT_GETDEVICECONFIG; ctxReq.optData.deviceConfigReq.dc = hdc; ctxReq.optData.deviceConfigReq.devNo = boardNum; @@ -1870,19 +1821,14 @@ hwcInit(FxU32 vID, FxU32 dID) ctxRes.optData.deviceConfigRes.isMaster; hInfo.boardInfo[monitor].pciInfo.numChips = ctxRes.optData.deviceConfigRes.numChips; - if /*(*/(hInfo.boardInfo[monitor].pciInfo.numChips > 4)/* || - (hInfo.boardInfo[monitor].pciInfo.numChips < 0))*//* KoolSmoky */ { + if ((hInfo.boardInfo[monitor].pciInfo.numChips > 4) || + (hInfo.boardInfo[monitor].pciInfo.numChips < 0)) hInfo.boardInfo[monitor].pciInfo.numChips = 0; - } //else { - /* KoolSmoky - Napalm framebuffer is unified, where the framebuffer + /* Napalm framebuffer is unified, where the framebuffer ** bound to each chip is effectively divided by SLI mode. ** (framebuffer of one chip) = (total framebuffer / SLI mode) - ** 2 chip device can have 1-way-SLI or 2-way-SLI ** h3Mem is the amount of video ram dedicated for one chip. - hInfo.boardInfo[monitor].h3Mem = - (ctxRes.optData.deviceConfigRes.fbRam >> 20); */ - //} } #endif /* FX_GLIDE_NAPALM */ @@ -1936,9 +1882,6 @@ hwcInit(FxU32 vID, FxU32 dID) (FxU32) sizeof(resolutionSupported[0][0]) / sizeof(FxBool), (void *) hInfo.boardInfo[monitor].hMon); #endif - - /* Colourless - CPUInfo */ - hInfo.boardInfo[monitor].CPUInfo = CPUInfo; } } #elif defined(HWC_GDX_INIT) @@ -2153,6 +2096,7 @@ hwcInit(FxU32 vID, FxU32 dID) } #endif /* HWC_EXT_INIT */ + if (hInfo.nBoards) return &hInfo; else @@ -4503,6 +4447,7 @@ hwcInitVideo(hwcBoardInfo *bInfo, FxBool tiled, FxVideoTimingInfo *vidTiming, #ifdef HWC_EXT_INIT hwcExtRequest_t ctxReq; hwcExtResult_t ctxRes; + FxI32 OS = hwcGetOS(); #endif { @@ -5045,7 +4990,9 @@ hwcInitVideo(hwcBoardInfo *bInfo, FxBool tiled, FxVideoTimingInfo *vidTiming, GDBG_INFO(80, FN_NAME ": HWC_MINIVDD_HACK\n"); - if (bInfo->osNT) + if ((OS == OS_WIN32_NT4) || + (OS == OS_WIN32_2K) || + (OS == OS_WIN32_XP)) { FxU32 retVal = FXTRUE; ctxReq.which = HWCEXT_SLI_AA_REQUEST ; @@ -5703,6 +5650,11 @@ FxBool hwcRestoreVideo(hwcBoardInfo *bInfo) { #define FN_NAME "hwcRestoreVideo" + +#ifdef HWC_EXT_INIT + FxI32 OS = hwcGetOS(); +#endif + #if 1 hwcIdleHardwareWithTimeout(bInfo); @@ -5727,7 +5679,9 @@ hwcRestoreVideo(hwcBoardInfo *bInfo) GDBG_INFO(80, FN_NAME ": HWC_MINIVDD_HACK\n"); - if (bInfo->osNT) + if ((OS == OS_WIN32_NT4) || + (OS == OS_WIN32_2K) || + (OS == OS_WIN32_XP)) { hwcExtRequest_t ctxReq ; hwcExtResult_t ctxRes ; @@ -6542,7 +6496,7 @@ static void hwcReadRegion565(hwcBoardInfo *bInfo, FxU32 src, FxU32 src_x, FxU32 stride_diff = strideInBytes - (src_width*2); - if (bInfo->CPUInfo.os_support & _CPU_FEATURE_MMX) + if (CPUInfo && (CPUInfo->os_support & _CPU_FEATURE_MMX)) { /* MMX Optimized Loop */ #ifdef __DJGPP__ @@ -6698,7 +6652,7 @@ static void hwcReadRegion1555(hwcBoardInfo *bInfo, FxU32 src, FxU32 src_x, FxU32 stride_diff = strideInBytes - (src_width*2); - if (bInfo->CPUInfo.os_support & _CPU_FEATURE_MMX) + if (CPUInfo && (CPUInfo->os_support & _CPU_FEATURE_MMX)) { /* MMX Optimized Loop */ #ifdef __DJGPP__ @@ -6854,7 +6808,7 @@ static void hwcReadRegion8888(hwcBoardInfo *bInfo, FxU32 src, FxU32 src_x, FxU32 stride_diff = strideInBytes - (src_width*4); - if (bInfo->CPUInfo.os_support & _CPU_FEATURE_MMX) + if (CPUInfo && (CPUInfo->os_support & _CPU_FEATURE_MMX)) { /* MMX Optimized Loop */ #ifdef __DJGPP__ @@ -7188,7 +7142,7 @@ static void hwcCopyBuffer8888Flipped(hwcBoardInfo *bInfo, FxU16 *source, int w, FxU8 *endline = dst+w*4; w*= 4; - if (bInfo->CPUInfo.os_support & _CPU_FEATURE_MMX) + if (CPUInfo && (CPUInfo->os_support & _CPU_FEATURE_MMX)) { /* MMX Optimized Loop */ #ifdef __DJGPP__ @@ -7323,7 +7277,7 @@ static void hwcCopyBuffer8888FlippedShifted(hwcBoardInfo *bInfo, FxU16 *source, FxU8 *endline = dst+w*4; w *= 4; - if (bInfo->CPUInfo.os_support & _CPU_FEATURE_MMX) + if (CPUInfo && (CPUInfo->os_support & _CPU_FEATURE_MMX)) { /* MMX Optimized Loop */ #ifdef __DJGPP__ @@ -7471,9 +7425,9 @@ static void hwcCopyBuffer8888FlippedDithered(hwcBoardInfo *bInfo, FxU16 *source, val_max = (0xFF << aaShift); dither_mask = ~((~0) << aaShift); - if (bInfo->CPUInfo.os_support & _CPU_FEATURE_MMX) + if (CPUInfo && (CPUInfo->os_support & _CPU_FEATURE_MMX)) { - FxU32 sse_mmxplus = bInfo->CPUInfo.os_support & (_CPU_FEATURE_MMXPLUS|_CPU_FEATURE_SSE); + FxU32 sse_mmxplus = CPUInfo->os_support & (_CPU_FEATURE_MMXPLUS|_CPU_FEATURE_SSE); /* MMX Optimized Loop */ #ifdef __DJGPP__ @@ -8074,7 +8028,7 @@ static void hwcCopyBuffer565Shifted(hwcBoardInfo *bInfo, FxU16 *src, int w, int rshift = 8 - aaShift; - if (bInfo->CPUInfo.os_support & _CPU_FEATURE_MMX) + if (CPUInfo && (CPUInfo->os_support & _CPU_FEATURE_MMX)) { /* MMX Optimized Loop */ #ifdef __DJGPP__ @@ -8989,11 +8943,12 @@ static char * getRegPath() { char *retVal = NULL; - OSVERSIONINFO ovi; + FxI32 OS = hwcGetOS(); - ovi.dwOSVersionInfoSize = sizeof ( ovi ); - GetVersionEx ( &ovi ); - if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT) { + if ((OS == OS_WIN32_NT4) || + (OS == OS_WIN32_2K) || + (OS == OS_WIN32_XP)) + { HKEY hKey; DWORD type ; static char strval[255]; @@ -9324,6 +9279,7 @@ hwcShareContextData(hwcBoardInfo *bInfo, FxU32 **data) #if HWC_EXT_INIT hwcExtRequest_t ctxReq; hwcExtResult_t ctxRes; + FxI32 OS = hwcGetOS(); GDBG_INFO(80, FN_NAME "\n"); @@ -9331,7 +9287,10 @@ hwcShareContextData(hwcBoardInfo *bInfo, FxU32 **data) if( HWCEXT_PROTOCOL( bInfo->boardNum ) ) { - if (bInfo->osNT) { + if ((OS == OS_WIN32_NT4) || + (OS == OS_WIN32_2K) || + (OS == OS_WIN32_XP)) + { hwcExtRequest_t ctxReq; hwcExtResult_t @@ -9394,7 +9353,9 @@ hwcShareContextData(hwcBoardInfo *bInfo, FxU32 **data) * check the retVal and the pointer. This also screws with ALT-TAB. */ GDBG_INFO(80, FN_NAME ": ExtEscape retVal=%d, dwordOffset=%d, contextDWORD=%d\n", retVal, ctxRes.optData.contextDwordNTRes.dwordOffset, ctxRes.optData.shareContextDWORDRes.contextDWORD); - if( (retVal <= 0) || (ctxRes.optData.contextDwordNTRes.dwordOffset == 0) || (bInfo->osNT51)) { /* make exceptions for winxp escapecalls */ + if( (retVal <= 0) || + (ctxRes.optData.contextDwordNTRes.dwordOffset == 0) || + (OS == OS_WIN32_XP)) { /* make exceptions for winxp escapecalls */ #if (WINXP_ALT_TAB_FIX || WINXP_FASTER_ALT_TAB_FIX) cLostPointer = #endif @@ -9494,9 +9455,13 @@ hwcUnmapMemory() FxU32 i; hwcExtRequest_t ctxReq; hwcExtResult_t ctxRes; + FxI32 OS = hwcGetOS(); if ( curBI ) { - if ( curBI->osNT ) { + if ((OS == OS_WIN32_NT4) || + (OS == OS_WIN32_2K) || + (OS == OS_WIN32_XP)) + { hwcExtRequest_t ctxReq; hwcExtResult_t @@ -9508,7 +9473,7 @@ hwcUnmapMemory() */ ctxReq.optData.unmapMemoryReq.procHandle = (ULONG)GetCurrentProcessId(); - ExtEscape((HDC)curBI->hdc, HWCEXT_ESCAPE(curBI->boardNum), + ExtEscape((HDC)curBI->hdc, HWCEXT_ESCAPE(curBI->boardNum), sizeof(ctxReq), (LPSTR) &ctxReq, sizeof(ctxRes), (LPSTR) &ctxRes); curBI->isMapped = FXFALSE; @@ -10016,3 +9981,72 @@ static FxI32 valarray[SST_SIPROCESS_OSC_CNTR + 1]; // is this how you do an HWC_IO_STORE(bInfo->regInfo, pllCtrl1, pllCtrl1_save); } + +void +hwcSetCPUInfo(_p_info *CPUInfo_) +{ + CPUInfo = CPUInfo_; +} /* hwcSetCPUInfo */ + +#ifdef __WIN32__ +FxI32 +hwcGetOS() +{ + static FxI32 OS = -1; + OSVERSIONINFO ovi; + + if ( OS != -1 ) return OS; + + ovi.dwOSVersionInfoSize = sizeof ( ovi ); + GetVersionEx ( &ovi ); + + if (ovi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { + if(ovi.dwMajorVersion == 4) { + if (ovi.dwMinorVersion >= 90) { + OS = OS_WIN32_ME; + } else if (ovi.dwMinorVersion >= 10) { + OS = OS_WIN32_98; + } else { + OS = OS_WIN32_95; + } + } + } else if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT) { + if(ovi.dwMajorVersion == 4) { + OS = OS_WIN32_NT4; + } else if(ovi.dwMajorVersion >= 5) { + if (ovi.dwMinorVersion >= 1) { + OS = OS_WIN32_XP; + } else { + OS = OS_WIN32_2K; + } + } + } + + switch(OS) { + case OS_WIN32_95: + GDBG_INFO(0, "hwcGetOS: OS = win95\n"); + break; + case OS_WIN32_98: + GDBG_INFO(0, "hwcGetOS: OS = win98\n"); + break; + case OS_WIN32_ME: + GDBG_INFO(0, "hwcGetOS: OS = winme\n"); + break; + case OS_WIN32_NT4: + GDBG_INFO(0, "hwcGetOS: OS = winnt4.0\n"); + break; + case OS_WIN32_2K: + GDBG_INFO(0, "hwcGetOS: OS = win2k\n"); + break; + case OS_WIN32_XP: + GDBG_INFO(0, "hwcGetOS: OS = winxp\n"); + break; + default: + GDBG_INFO(0, "hwcGetOS: OS = unknown\n"); + break; + } + + return OS; +#undef FN_NAME +} /* hwcGetOS */ +#endif /* __WIN32__ */ \ No newline at end of file diff --git a/glide3x/h5/minihwc/minihwc.h b/glide3x/h5/minihwc/minihwc.h index 7b13b14..a994797 100644 --- a/glide3x/h5/minihwc/minihwc.h +++ b/glide3x/h5/minihwc/minihwc.h @@ -501,8 +501,6 @@ typedef struct hwcBoardInfo_s { agpInfo; FxU32 lostContextDWORD; - FxBool - osNT; FxBool isMapped; FxU32 @@ -512,10 +510,8 @@ typedef struct hwcBoardInfo_s { FxI32 hwcProtocol; FxU32 devNode ; /* AJB- DevNode from display driver for minivdd ioctls */ FxI16/*FxI32*/ hwcEscape ; /* AJB- sucky: H5 TOT uses a diff't escape code than H3 */ /* KoolSmoky - new escape code for winxp *//* revert back to previous for now */ - FxBool osNT51; /* KoolSmoky- WinXP flag */ char RegPath[255]; /* KoolSmoky - Device registry path */ char DeviceName[32]; /* KoolSmoky - Device Name */ - _p_info CPUInfo; /* Colourless - CPU info */ } hwcBoardInfo; @@ -625,6 +621,15 @@ hwcCheckMemSize(hwcBoardInfo *bInfo, FxU32 xres, FxU32 yres, FxU32 nColBuffers, #ifdef __WIN32__ +#define OS_WIN32_95 0 +#define OS_WIN32_98 1 +#define OS_WIN32_ME 2 +#define OS_WIN32_NT4 3 +#define OS_WIN32_2K 4 +#define OS_WIN32_XP 5 +FxI32 +hwcGetOS(); + FxU32 hwcAllocWinContext(hwcBoardInfo* bInfo); @@ -769,3 +774,6 @@ extern void hwcAAReadRegion(hwcBoardInfo *bInfo, FxU32 colBufNum, void hwcCalcSipValue(hwcBoardInfo *bInfo, FxU32 chipNum, FxU32 *nandChain, FxU32 *norChain); #endif /* MINIHWC_H not defined */ + +void +hwcSetCPUInfo(_p_info *CPUInfo_); diff --git a/glide3x/h5/minihwc/win_mode.c b/glide3x/h5/minihwc/win_mode.c index 3c3ad3e..b150880 100644 --- a/glide3x/h5/minihwc/win_mode.c +++ b/glide3x/h5/minihwc/win_mode.c @@ -56,6 +56,7 @@ #include #include "qmodes.h" #include "setmode.h" +#include "minihwc.h" #define IS_32 #define Not_VxD #include @@ -238,23 +239,17 @@ static char * getModesRegPath() { char *retVal = NULL; - OSVERSIONINFO ovi; + FxU32 OS = hwcGetOS(); - ovi.dwOSVersionInfoSize = sizeof ( ovi ); - GetVersionEx ( &ovi ); - if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT) { + if ((OS == OS_WIN32_NT4) || + (OS == OS_WIN32_2K) || + (OS == OS_WIN32_XP)) + { HKEY hKey; DWORD type ; static char strval[255]; DWORD szData = sizeof(strval) ; -/* GDBG_INFO(80, "OS == WNT\n"); */ - if ( ovi.dwMajorVersion >= 5 && ovi.dwMinorVersion >= 1) { - GDBG_INFO(80, "REGPATH: OS == NT5.1\n"); - } else { - GDBG_INFO(80, "REGPATH: OS == NT4\n"); - } - /* Go fishing for the registry path on Win2K */ if (RegOpenKey(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\VIDEO", &hKey) == ERROR_SUCCESS) { @@ -327,7 +322,7 @@ setVideoMode( HWND hwnd, int xRes, int yRes, int h3pixelSize, int refresh, void //HRESULT ddRVal; //DWORD style; #ifdef IS_ALT_TAB - OSVERSIONINFO ovi; + FxU32 OS = hwcGetOS(); /* reset fullscreen flag */ is_fullscreen = FXFALSE; @@ -445,12 +440,6 @@ setVideoMode( HWND hwnd, int xRes, int yRes, int h3pixelSize, int refresh, void // checkSpecialList(); - -#ifdef IS_ALT_TAB - /* get os version */ - ovi.dwOSVersionInfoSize = sizeof ( ovi ); - GetVersionEx ( &ovi ); -#endif if (lpDD == NULL) { /* only create directdraw object once */ @@ -542,8 +531,8 @@ setVideoMode( HWND hwnd, int xRes, int yRes, int h3pixelSize, int refresh, void devMode.dmBitsPerPel = bpp; devMode.dmDisplayFrequency = refresh; - if(((ovi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && (ovi.dwMinorVersion < 10)) || - ((ovi.dwPlatformId == VER_PLATFORM_WIN32_NT) && (ovi.dwMajorVersion < 5))) + if ((OS == OS_WIN32_95) || + (OS == OS_WIN32_NT4)) { // win95,nt4 if(ChangeDisplaySettings(&devMode, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL) @@ -800,7 +789,7 @@ resetVideo( void ) #define FN_NAME "resetVideo" #ifdef IS_ALT_TAB - OSVERSIONINFO ovi; + FxU32 OS = hwcGetOS(); #endif GDBG_INFO(80, "%s: called!\n", FN_NAME); @@ -840,13 +829,9 @@ resetVideo( void ) #endif #ifdef IS_ALT_TAB - /* get os version */ - ovi.dwOSVersionInfoSize = sizeof ( ovi ); - GetVersionEx ( &ovi ); - //ChangeDisplaySettings(NULL, 0); - if(((ovi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && (ovi.dwMinorVersion < 10)) || - ((ovi.dwPlatformId == VER_PLATFORM_WIN32_NT) && (ovi.dwMajorVersion < 5))) + if ((OS == OS_WIN32_95) || + (OS == OS_WIN32_NT4)) { // win95,nt4 /* KoolSmoky - ripped from quake3 */ @@ -952,14 +937,10 @@ checkResolutions( FxBool *supportedByResolution, FxU32 stride, void *hmon, int h #define FN_NAME "checkResolution" DEVMODE chkDevMode; DWORD chkRes, chkRefresh; - OSVERSIONINFO ovi; + FxU32 OS = hwcGetOS(); GDBG_INFO(80, "%s: called!\n", FN_NAME); - /* get os version */ - ovi.dwOSVersionInfoSize = sizeof ( ovi ); - GetVersionEx ( &ovi ); - chkDevMode.dmSize = sizeof(DEVMODE); chkDevMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; @@ -980,8 +961,8 @@ checkResolutions( FxBool *supportedByResolution, FxU32 stride, void *hmon, int h chkDevMode.dmDisplayFrequency = refresh[chkRefresh]; //ChangeDisplaySettings(NULL, 0); - if(((ovi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && (ovi.dwMinorVersion < 10)) || - ((ovi.dwPlatformId == VER_PLATFORM_WIN32_NT) && (ovi.dwMajorVersion < 5))) + if ((OS == OS_WIN32_95) || + (OS == OS_WIN32_NT4)) { // win95,nt4 if(ChangeDisplaySettings(&chkDevMode, CDS_TEST) == DISP_CHANGE_SUCCESSFUL)