1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
|
/*
** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
**
** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
** THE UNITED STATES.
**
** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
**
** $Header: /cvsroot/glide/glide2x/h3/minihwc/exttest.c,v 1.1.1.1 1999/12/07 21:49:43 joseph Exp $
** $Log: exttest.c,v $
** Revision 1.1.1.1 1999/12/07 21:49:43 joseph
** Initial checkin into SourceForge.
**
**
** 2 3/16/99 1:20a Dow
** Sync to various workarounds.
**
** 1 3/10/99 10:48a Peter
** mmmm.... yawmnw
**
** 1 3/10/99 10:46a Peter
** mmmm.... yawmnw
**
** 1 5/01/98 9:16a Dow
**
*/
#include <windows.h>
#include <3dfx.h>
#include "..\hwcext.h"
/* This segment simulates main() for Windows, creates a window, etc. */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
/* Forward declarations */
HWND hWndMain;
/*
* MainWndproc
*
* Callback for all Windows messages
*/
static int qhead = 0;
static int qtail = 0;
static int queue[256] = {0};
long FAR PASCAL
MainWndproc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
PAINTSTRUCT ps;
HDC hdc;
switch( message )
{
case WM_SETCURSOR:
SetCursor(NULL);
break;
case WM_CREATE:
break;
case WM_PAINT:
hdc = BeginPaint( hWnd, &ps );
EndPaint( hWnd, &ps );
return 1;
case WM_CLOSE:
queue[qhead++] = 'q'; qhead &= 255;
break;
case WM_DESTROY:
break;
case WM_MOVE:
break;
case WM_DISPLAYCHANGE:
case WM_SIZE:
break;
case WM_CHAR:
break;
default:
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
} /* MainWndproc */
void
main(int argc, char **argv)
{
HWND hWndMain;
HANDLE hInstance = GetModuleHandle(NULL);
HDC dc;
int extRes;
hwcExtRequest_t req;
hwcExtResult_t res;
WNDCLASS wc;
BOOL rc;
FxU32 contextID;
wc.style = CS_DBLCLKS;
wc.lpfnWndProc = MainWndproc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION); /* generic icon */
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = GetStockObject( BLACK_BRUSH );
wc.lpszMenuName = NULL;
wc.lpszClassName = "ExtTestClass";
rc = RegisterClass( &wc );
if( !rc ) {
printf("Failed to register class!\n");
exit(1);
}
hWndMain =
CreateWindowEx(
#if 0
WS_EX_APPWINDOW gives you regular borders?
WS_EX_TOPMOST Works as advertised.
#endif
WS_EX_APPWINDOW,
"ExtTestClass",
"ExtEscape Test",
WS_OVERLAPPED |
WS_CAPTION |
WS_THICKFRAME |
WS_MAXIMIZEBOX |
WS_MINIMIZEBOX |
WS_POPUP | /* non-app window */
WS_SYSMENU, /* so we get an icon in the tray */
CW_USEDEFAULT,
CW_USEDEFAULT,
0x110, /* GetSystemMetrics(SM_CXSCREEN), */
0x120, /* GetSystemMetrics(SM_CYSCREEN), */
NULL,
NULL,
hInstance,
NULL
);
if( !hWndMain ) {
printf("Failed to create window\n");
exit(2);
}
/* HWCEXT_GETDRIVERVERSION */
req.which = HWCEXT_GETDRIVERVERSION;
dc = GetDC(hWndMain);
extRes = ExtEscape(dc, EXT_HWC, sizeof(req), (LPCSTR) &req,
sizeof(res), (LPCSTR) &res);
if (extRes == 0) {
printf("No escape!\n");
exit(3);
}
printf("HWCEXT_GETDRIVERVERSION:\n\tMajor:\t0x%x\n\tMinor:\t0x%x\n",
res.optData.driverVersionRes.major,
res.optData.driverVersionRes.minor);
/* HWCEXT_ALLOCCONTEXT */
req.which = HWCEXT_ALLOCCONTEXT;
req.optData.allocContextReq.protocolRev = HWCEXT_PROTOCOLREV;
req.optData.allocContextReq.appType = HWCEXT_ABAPPTYPE_FSEM;
extRes = ExtEscape(dc, EXT_HWC, sizeof(req), (LPCSTR) &req,
sizeof(res), (LPCSTR) &res);
printf("HWCEXT_ALLOCCONTEXT:\n\tStatus:\t0x%x\n\tContext ID:\t0x%x\n",
res.resStatus, res.optData.allocContextRes.contextID);
contextID = res.optData.allocContextRes.contextID;
/* HWCEXT_GETDEVICECONFIG */
req.which = HWCEXT_GETDEVICECONFIG;
extRes = ExtEscape(dc, EXT_HWC, sizeof(req), (LPCSTR) &req,
sizeof(res), (LPCSTR) &res);
printf("HWCEXT_GETDEVICECONFIG:\
\n\tStatus:\t0x%x\
\n\tdevNum:\t0x%x\
\n\tvendorDI:\t0x%x\
\n\tfbRam:\t0x%x\
\n\tchipRev:\t0x%x\n",
res.resStatus, res.optData.deviceConfigRes.devNum,
res.optData.deviceConfigRes.vendorID,
res.optData.deviceConfigRes.fbRam,
res.optData.deviceConfigRes.chipRev);
/* HWCEXT_GETLINEARADDR */
req.which = HWCEXT_GETLINEARADDR;
req.optData.linearAddrReq.devNum = 0;
extRes = ExtEscape(dc, EXT_HWC, sizeof(req), (LPCSTR) &req,
sizeof(res), (LPCSTR) &res);
printf("HWCEXT_LINEARADDRESS:\
\n\tStatus:\t0x%x\
\n\tnumBaseAddrs: %d\
\n\tbaseAddresses[0]: 0x%x\
\n\tbaseAddresses[1]: 0x%x\
\n\tbaseAddresses[2]: 0x%x\n",
res.resStatus, res.optData.linearAddressRes.numBaseAddrs,
res.optData.linearAddressRes.baseAddresses[0],
res.optData.linearAddressRes.baseAddresses[1],
res.optData.linearAddressRes.baseAddresses[2]
);
/* HWCEXT_RELEASECONTEXT */
req.which = HWCEXT_RELEASECONTEXT;
req.optData.releaseContextReq.contextID = contextID;
extRes = ExtEscape(dc, EXT_HWC, sizeof(req), (LPCSTR) &req,
sizeof(res), (LPCSTR) &res);
printf("HWCEXT_RELEASECONTEXT:\n\tStatus:\t0x%x\n", res.resStatus);
} /* main */
|