📄 i_dive.c
字号:
WinPostMsg( pwinData->hwndFrame, WM_VRNENABLED, 0L, 0L );
// set palette
if (pwinData->ulColorBits==8)
DiveSetDestinationPalette( pwinData->hDive, 0, pwinData->ulNumColors, 0);
// init full screen access
DosQuerySysInfo( QSV_VERSION_MAJOR, QSV_VERSION_MINOR, aulVersion, 8);
// on warp3
if (aulVersion[0] == 20 && aulVersion[1] <= 30 ) {
// GameSrvr ----------------------------------------------------begin---
if (DosLoadModule( (PSZ) szErrorBuf, 256, "GAMESRVR", &hmodGameSrvr)==0) {
ULONG pvmi;
ULONG ul;
if (DosQueryProcAddr( hmodGameSrvr, 1, 0, &pfnInitGameFrameProc)==0)
(pfnInitGameFrameProc)( pwinData->hwndFrame, 0 );
WinSendMsg( pwinData->hwndFrame, WM_GetVideoModeTable, (MPARAM)&pvmi, (MPARAM)&ul);
pwinData->fFSBase = TRUE;
} else {
WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
(PSZ)"usage: FSDIVE failed to load GAMESRVR.DLL.",
(PSZ)"Error!", 0, MB_OK | MB_MOVEABLE );
}
// GameSrvr ----------------------------------------------------end-----
} else { // Warp4 Merlin
DosLoadModule( (PSZ) szErrorBuf, 256, "PMMERGE", &hmodGameSrvr);
if (DosQueryProcAddr( hmodGameSrvr, 6099, 0, &pfnInitGameFrameProc)==0) {
ULONG pvmi;
ULONG ul;
(pfnInitGameFrameProc)( pwinData->hwndFrame, 0 );
//WinSendMsg( pwinData->hwndFrame, WM_GetVideoModeTable, (MPARAM)&pvmi, (MPARAM)&ul);
pwinData->fFSBase = TRUE;
} else {
WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
(PSZ)"usage: FSDIVE failed to access FS functions.",
(PSZ)"Error!", 0, MB_OK | MB_MOVEABLE );
}
}
pvmi = 0;
ul = 0;
if (pwinData->fFSBase) {
WinSendMsg( pwinData->hwndFrame, WM_GetVideoModeTable, (MPARAM)&pvmi, (MPARAM)&ul);
printf( "FullScreen available -> QueryFullScreen modes: %d,%d\n", pvmi, ul);
}
pwinData->ulWindowStyle = WS_DesktopDive; // current window style
printf( "InitDIVE buffer=%p done!\n", pwinData->pbBuffer);
return 0; // init ok
}
//
// init dive buffer
//
int InitDIVEBuffer( PWINDATA pwinData)
{
ULONG ulScanLineBytes; /* Size of scan line for current window */
ULONG ulScanLines; /* Number of scan lines in window */
printf( "InitDIVEBuffer: hwnd=%x DONE\n", (int) pwinData->hwndFrame);
if (pwinData->pbBuffer) {
DiveEndImageBufferAccess( pwinData->hDive, pwinData->ulImage);
DiveFreeImageBuffer( pwinData->hDive, pwinData->ulImage);
pwinData->pbBuffer = NULL;
}
if (pwinData->pbBuffer2) {
DiveEndImageBufferAccess( pwinData->hDive, pwinData->ulImage2);
DiveFreeImageBuffer( pwinData->hDive, pwinData->ulImage2);
pwinData->pbBuffer2 = NULL;
}
// Allocate DIVE image buffer
if (DiveAllocImageBuffer( pwinData->hDive,
&(pwinData->ulImage),
pwinData->fccColorFormat,
pwinData->ulWidth,
pwinData->ulHeight * (NUMSCREENS+1),
0, 0) ) {
pwinData->hDive = 0;
return 1;
}
if (DiveAllocImageBuffer( pwinData->hDive,
&(pwinData->ulImage2),
pwinData->fccColorFormat,
pwinData->ulWidth,
pwinData->ulHeight,
0, 0) ) {
pwinData->hDive = 0;
return 1;
}
// begin access
ulScanLineBytes = 0; // leave 0, so dive will set to
ulScanLines = 0; // best value
DiveBeginImageBufferAccess( pwinData->hDive,
pwinData->ulImage,
(PPBYTE)&pwinData->pbBuffer,
&ulScanLineBytes,
&ulScanLines);
ulScanLineBytes = 0; // leave 0, so dive will set to
ulScanLines = 0; // best value
DiveBeginImageBufferAccess( pwinData->hDive,
pwinData->ulImage2,
(PPBYTE)&pwinData->pbBuffer2,
&ulScanLineBytes,
&ulScanLines);
printf( "InitDIVEBuffer: image#0 %ld, buffer=%p DONE\n", pwinData->ulImage, pwinData->pbBuffer);
printf( "InitDIVEBuffer: image#1 %ld, buffer=%p DONE\n", pwinData->ulImage2, pwinData->pbBuffer2);
return 0; // init ok
}
//
// close dive access
//
void ShutdownDIVE( PWINDATA pwinData)
{
DiveEndImageBufferAccess( pwinData->hDive, pwinData->ulImage);
DiveEndImageBufferAccess( pwinData->hDive, pwinData->ulImage2);
DiveFreeImageBuffer( pwinData->hDive, pwinData->ulImage);
DiveFreeImageBuffer( pwinData->hDive, pwinData->ulImage2);
// Make sure that we are in desk top mode
WinPostMsg( pwinData->hwndFrame, WM_SetVideoMode, (MPARAM)WS_DesktopDive, 0);
DiveClose( pwinData->hDive);
pwinData->hDive = 0;
printf( "ShutdownDIVE done!\n");
}
/**********************************************************
* PALETTE MANAGER *
**********************************************************/
/*
* This function must be called on every REALIZE PALETTE
* window message, so that DIVE gets to know the new
* palette.
*/
void RealizePalette(WINDATA *this)
{
if (!this->hDive)
return;
#ifdef USE_PALETTE_MGR
if (this->ulPalMode) {
ULONG foo;
WinRealizePalette(this->hwndClient, this->hps, &foo);
}
#endif
DiveSetDestinationPalette(this->hDive, 0, 0, 0);
} /* RealizePalette */
#ifdef USE_PALETTE_MGR
void CreatePalette(WINDATA *this)
{
HAB hab = WinQueryAnchorBlock(this->hwndClient);
ULONG aux[this->ulNumColors];
ULONG count;
SIZEL sizl;
LONG alCaps[CAPS_PHYS_COLORS];
LONG lCount = CAPS_PHYS_COLORS;
LONG lStart = CAPS_FAMILY;
BOOL fPaletteCaps;
if (!this->ulPalMode)
return;
printf( "Entering CreatePalette...\n");
/* We obtain a Device Context for our window. We next query whether this
device allows palette changes. If true, we create an empty
Presentation Space with an empty palette that we will update every
time Doom's palette changes
*/
sizl.cx =0;
sizl.cy =0;
this->hdc = WinOpenWindowDC(this->hwndClient);
if ( this->hdc == NULLHANDLE )
{
printf( "WinOpenWindowDC Error 0x%04x\n", WinGetLastError(hab));
}
DevQueryCaps( this->hdc, lStart, lCount, alCaps );
fPaletteCaps = alCaps[CAPS_ADDITIONAL_GRAPHICS] & CAPS_PALETTE_MANAGER;
if ( fPaletteCaps == FALSE ) {
this->ulPalMode = 0;
}
this->hps = GpiCreatePS(hab, this->hdc, &sizl,
PU_PELS | GPIF_DEFAULT
| GPIT_MICRO | GPIA_ASSOC);
if ( this->hps == NULLHANDLE)
{
printf( "GpiCreatePS Error 0x%04x\n", WinGetLastError(hab));
}
/* We clear all entries, up to complete the whole Doom palette
*/
for (count = 0; count < this->ulNumColors; count++) {
aux[count] = PC_RESERVED * 16777216L;
}
/* We create a palette for this PS, and set it with these initial colors
*/
this->hpal= GpiCreatePalette(hab, LCOL_PURECOLOR
| LCOL_OVERRIDE_DEFAULT_COLORS,
LCOLF_CONSECRGB,
this->ulNumColors,
aux);
if( this->hpal == NULLHANDLE || this->hpal == GPI_ERROR)
{
printf( "GpiCreatePalette Error 0x%04x\n", WinGetLastError(hab));
}
if (GpiSelectPalette(this->hps, this->hpal) == PAL_ERROR)
{
printf( "GpiSelectPalette Error 0x%04x\n", WinGetLastError(hab));
}
if( WinRealizePalette(this->hwndClient, this->hps, &count) == PAL_ERROR)
{
printf( "WinRealizePalette Error 0x%04x\n", WinGetLastError(hab));
}
printf( "Exiting CreatePalette...\n");
} /* CreatePalette */
void DestroyPalette(WINDATA *this)
{
if ( this->ulPalMode )
{
ULONG foo;
GpiSelectPalette(this->hps,0);
GpiDeletePalette(this->hpal);
WinRealizePalette(this->hwndClient, this->hps, &foo);
GpiDestroyPS(this->hps);
}
} /* DestroyPalette */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -