mirror of
https://github.com/encounter/SDL.git
synced 2025-12-11 06:27:44 +00:00
os2: a _lot_ of coding style cleanup, sot that they match the SDL style.
also renamed the 'debug' macro to debug_os2: the former was dangerously a common name. the binary (dll) output is precisely the same as before.
This commit is contained in:
@@ -32,17 +32,17 @@
|
||||
#include "SDL_os2output.h"
|
||||
|
||||
typedef struct _VODATA {
|
||||
HDIVE hDive;
|
||||
PVOID pBuffer;
|
||||
ULONG ulDIVEBufNum;
|
||||
FOURCC fccColorEncoding;
|
||||
ULONG ulWidth;
|
||||
ULONG ulHeight;
|
||||
BOOL fBlitterReady;
|
||||
HDIVE hDive;
|
||||
PVOID pBuffer;
|
||||
ULONG ulDIVEBufNum;
|
||||
FOURCC fccColorEncoding;
|
||||
ULONG ulWidth;
|
||||
ULONG ulHeight;
|
||||
BOOL fBlitterReady;
|
||||
} VODATA;
|
||||
|
||||
static BOOL voQueryInfo(PVIDEOOUTPUTINFO pInfo);
|
||||
static PVODATA voOpen();
|
||||
static BOOL voQueryInfo(VIDEOOUTPUTINFO *pInfo);
|
||||
static PVODATA voOpen(void);
|
||||
static VOID voClose(PVODATA pVOData);
|
||||
static BOOL voSetVisibleRegion(PVODATA pVOData, HWND hwnd,
|
||||
SDL_DisplayMode *pSDLDisplayMode,
|
||||
@@ -55,294 +55,275 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects,
|
||||
ULONG cSDLRects);
|
||||
|
||||
OS2VIDEOOUTPUT voDive = {
|
||||
voQueryInfo,
|
||||
voOpen,
|
||||
voClose,
|
||||
voSetVisibleRegion,
|
||||
voVideoBufAlloc,
|
||||
voVideoBufFree,
|
||||
voUpdate
|
||||
voQueryInfo,
|
||||
voOpen,
|
||||
voClose,
|
||||
voSetVisibleRegion,
|
||||
voVideoBufAlloc,
|
||||
voVideoBufFree,
|
||||
voUpdate
|
||||
};
|
||||
|
||||
|
||||
static BOOL voQueryInfo(PVIDEOOUTPUTINFO pInfo)
|
||||
static BOOL voQueryInfo(VIDEOOUTPUTINFO *pInfo)
|
||||
{
|
||||
DIVE_CAPS sDiveCaps = { 0 };
|
||||
FOURCC fccFormats[100] = { 0 };
|
||||
DIVE_CAPS sDiveCaps = { 0 };
|
||||
FOURCC fccFormats[100] = { 0 };
|
||||
|
||||
// Query information about display hardware from DIVE.
|
||||
/* Query information about display hardware from DIVE. */
|
||||
sDiveCaps.pFormatData = fccFormats;
|
||||
sDiveCaps.ulFormatLength = 100;
|
||||
sDiveCaps.ulStructLen = sizeof(DIVE_CAPS);
|
||||
|
||||
sDiveCaps.pFormatData = fccFormats;
|
||||
sDiveCaps.ulFormatLength = 100;
|
||||
sDiveCaps.ulStructLen = sizeof(DIVE_CAPS);
|
||||
if (DiveQueryCaps(&sDiveCaps, DIVE_BUFFER_SCREEN)) {
|
||||
debug_os2("DiveQueryCaps() failed.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( DiveQueryCaps( &sDiveCaps, DIVE_BUFFER_SCREEN ) )
|
||||
{
|
||||
debug( "DiveQueryCaps() failed." );
|
||||
return FALSE;
|
||||
}
|
||||
if (sDiveCaps.ulDepth < 8) {
|
||||
debug_os2("Not enough screen colors to run DIVE. "
|
||||
"Must be at least 256 colors.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( sDiveCaps.ulDepth < 8 )
|
||||
{
|
||||
debug( "Not enough screen colors to run DIVE. "
|
||||
"Must be at least 256 colors." );
|
||||
return FALSE;
|
||||
}
|
||||
pInfo->ulBPP = sDiveCaps.ulDepth;
|
||||
pInfo->fccColorEncoding = sDiveCaps.fccColorEncoding;
|
||||
pInfo->ulScanLineSize = sDiveCaps.ulScanLineBytes;
|
||||
pInfo->ulHorizResolution = sDiveCaps.ulHorizontalResolution;
|
||||
pInfo->ulVertResolution = sDiveCaps.ulVerticalResolution;
|
||||
|
||||
pInfo->ulBPP = sDiveCaps.ulDepth;
|
||||
pInfo->fccColorEncoding = sDiveCaps.fccColorEncoding;
|
||||
pInfo->ulScanLineSize = sDiveCaps.ulScanLineBytes;
|
||||
pInfo->ulHorizResolution = sDiveCaps.ulHorizontalResolution;
|
||||
pInfo->ulVertResolution = sDiveCaps.ulVerticalResolution;
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PVODATA voOpen()
|
||||
PVODATA voOpen(void)
|
||||
{
|
||||
PVODATA pVOData = SDL_calloc( 1, sizeof(VODATA) );
|
||||
PVODATA pVOData = SDL_calloc(1, sizeof(VODATA));
|
||||
|
||||
if ( pVOData == NULL )
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
if (pVOData == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( DiveOpen( &pVOData->hDive, FALSE, NULL ) != DIVE_SUCCESS )
|
||||
{
|
||||
SDL_free( pVOData );
|
||||
SDL_SetError( "DIVE: A display engine instance open failed" );
|
||||
return NULL;
|
||||
}
|
||||
if (DiveOpen(&pVOData->hDive, FALSE, NULL) != DIVE_SUCCESS) {
|
||||
SDL_free(pVOData);
|
||||
SDL_SetError("DIVE: A display engine instance open failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pVOData;
|
||||
return pVOData;
|
||||
}
|
||||
|
||||
static VOID voClose(PVODATA pVOData)
|
||||
{
|
||||
voVideoBufFree( pVOData );
|
||||
DiveClose( pVOData->hDive );
|
||||
SDL_free( pVOData );
|
||||
voVideoBufFree(pVOData);
|
||||
DiveClose(pVOData->hDive);
|
||||
SDL_free(pVOData);
|
||||
}
|
||||
|
||||
static BOOL voSetVisibleRegion(PVODATA pVOData, HWND hwnd,
|
||||
SDL_DisplayMode *pSDLDisplayMode,
|
||||
HRGN hrgnShape, BOOL fVisible)
|
||||
{
|
||||
HPS hps;
|
||||
HRGN hrgn;
|
||||
RGNRECT rgnCtl;
|
||||
PRECTL prectl = NULL;
|
||||
ULONG ulRC;
|
||||
HPS hps;
|
||||
HRGN hrgn;
|
||||
RGNRECT rgnCtl;
|
||||
PRECTL prectl = NULL;
|
||||
ULONG ulRC;
|
||||
|
||||
if ( !fVisible )
|
||||
{
|
||||
if ( pVOData->fBlitterReady )
|
||||
{
|
||||
pVOData->fBlitterReady = FALSE;
|
||||
DiveSetupBlitter( pVOData->hDive, 0 );
|
||||
debug( "DIVE blitter is tuned off" );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Query visible rectangles
|
||||
|
||||
hps = WinGetPS( hwnd );
|
||||
hrgn = GpiCreateRegion( hps, 0, NULL );
|
||||
if ( hrgn == NULLHANDLE )
|
||||
{
|
||||
WinReleasePS( hps );
|
||||
SDL_SetError( "GpiCreateRegion() failed" );
|
||||
}
|
||||
else
|
||||
{
|
||||
WinQueryVisibleRegion( hwnd, hrgn );
|
||||
if ( hrgnShape != NULLHANDLE )
|
||||
GpiCombineRegion( hps, hrgn, hrgn, hrgnShape, CRGN_AND );
|
||||
|
||||
rgnCtl.ircStart = 1;
|
||||
rgnCtl.crc = 0;
|
||||
rgnCtl.ulDirection = 1;
|
||||
GpiQueryRegionRects( hps, hrgn, NULL, &rgnCtl, NULL );
|
||||
if ( rgnCtl.crcReturned != 0 )
|
||||
{
|
||||
prectl = SDL_malloc( rgnCtl.crcReturned * sizeof(RECTL) );
|
||||
if ( prectl != NULL )
|
||||
{
|
||||
rgnCtl.ircStart = 1;
|
||||
rgnCtl.crc = rgnCtl.crcReturned;
|
||||
rgnCtl.ulDirection = 1;
|
||||
GpiQueryRegionRects( hps, hrgn, NULL, &rgnCtl, prectl );
|
||||
}
|
||||
else
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
GpiDestroyRegion( hps, hrgn );
|
||||
WinReleasePS( hps );
|
||||
|
||||
if ( prectl != NULL )
|
||||
{
|
||||
// Setup DIVE blitter.
|
||||
SETUP_BLITTER sSetupBlitter;
|
||||
SWP swp;
|
||||
POINTL pointl = { 0 };
|
||||
|
||||
WinQueryWindowPos( hwnd, &swp );
|
||||
WinMapWindowPoints( hwnd, HWND_DESKTOP, &pointl, 1 );
|
||||
|
||||
sSetupBlitter.ulStructLen = sizeof(SETUP_BLITTER);
|
||||
sSetupBlitter.fccSrcColorFormat = pVOData->fccColorEncoding;
|
||||
sSetupBlitter.fInvert = FALSE;
|
||||
sSetupBlitter.ulSrcWidth = pVOData->ulWidth;
|
||||
sSetupBlitter.ulSrcHeight = pVOData->ulHeight;
|
||||
sSetupBlitter.ulSrcPosX = 0;
|
||||
sSetupBlitter.ulSrcPosY = 0;
|
||||
sSetupBlitter.ulDitherType = 0;
|
||||
sSetupBlitter.fccDstColorFormat = FOURCC_SCRN;
|
||||
sSetupBlitter.ulDstWidth = swp.cx;
|
||||
sSetupBlitter.ulDstHeight = swp.cy;
|
||||
sSetupBlitter.lDstPosX = 0;
|
||||
sSetupBlitter.lDstPosY = 0;
|
||||
sSetupBlitter.lScreenPosX = pointl.x;
|
||||
sSetupBlitter.lScreenPosY = pointl.y;
|
||||
|
||||
sSetupBlitter.ulNumDstRects = rgnCtl.crcReturned;
|
||||
sSetupBlitter.pVisDstRects = prectl;
|
||||
|
||||
ulRC = DiveSetupBlitter( pVOData->hDive, &sSetupBlitter );
|
||||
SDL_free( prectl );
|
||||
|
||||
if ( ulRC == DIVE_SUCCESS )
|
||||
{
|
||||
pVOData->fBlitterReady = TRUE;
|
||||
WinInvalidateRect( hwnd, NULL, TRUE );
|
||||
debug( "DIVE blitter is ready now." );
|
||||
if (!fVisible) {
|
||||
if (pVOData->fBlitterReady) {
|
||||
pVOData->fBlitterReady = FALSE;
|
||||
DiveSetupBlitter(pVOData->hDive, 0);
|
||||
debug_os2("DIVE blitter is tuned off");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_SetError( "DiveSetupBlitter(), rc = 0x%X", ulRC );
|
||||
} // if ( prectl != NULL )
|
||||
} // if ( hrgn == NULLHANDLE ) else
|
||||
/* Query visible rectangles */
|
||||
hps = WinGetPS(hwnd);
|
||||
hrgn = GpiCreateRegion(hps, 0, NULL);
|
||||
if (hrgn == NULLHANDLE) {
|
||||
WinReleasePS(hps);
|
||||
SDL_SetError("GpiCreateRegion() failed");
|
||||
} else {
|
||||
WinQueryVisibleRegion(hwnd, hrgn);
|
||||
if (hrgnShape != NULLHANDLE)
|
||||
GpiCombineRegion(hps, hrgn, hrgn, hrgnShape, CRGN_AND);
|
||||
|
||||
pVOData->fBlitterReady = FALSE;
|
||||
DiveSetupBlitter( pVOData->hDive, 0 );
|
||||
return FALSE;
|
||||
rgnCtl.ircStart = 1;
|
||||
rgnCtl.crc = 0;
|
||||
rgnCtl.ulDirection = 1;
|
||||
GpiQueryRegionRects(hps, hrgn, NULL, &rgnCtl, NULL);
|
||||
if (rgnCtl.crcReturned != 0) {
|
||||
prectl = SDL_malloc(rgnCtl.crcReturned * sizeof(RECTL));
|
||||
if (prectl != NULL) {
|
||||
rgnCtl.ircStart = 1;
|
||||
rgnCtl.crc = rgnCtl.crcReturned;
|
||||
rgnCtl.ulDirection = 1;
|
||||
GpiQueryRegionRects(hps, hrgn, NULL, &rgnCtl, prectl);
|
||||
} else {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
}
|
||||
GpiDestroyRegion(hps, hrgn);
|
||||
WinReleasePS(hps);
|
||||
|
||||
if (prectl != NULL) {
|
||||
/* Setup DIVE blitter. */
|
||||
SETUP_BLITTER sSetupBlitter;
|
||||
SWP swp;
|
||||
POINTL pointl = { 0 };
|
||||
|
||||
WinQueryWindowPos(hwnd, &swp);
|
||||
WinMapWindowPoints(hwnd, HWND_DESKTOP, &pointl, 1);
|
||||
|
||||
sSetupBlitter.ulStructLen = sizeof(SETUP_BLITTER);
|
||||
sSetupBlitter.fccSrcColorFormat = pVOData->fccColorEncoding;
|
||||
sSetupBlitter.fInvert = FALSE;
|
||||
sSetupBlitter.ulSrcWidth = pVOData->ulWidth;
|
||||
sSetupBlitter.ulSrcHeight = pVOData->ulHeight;
|
||||
sSetupBlitter.ulSrcPosX = 0;
|
||||
sSetupBlitter.ulSrcPosY = 0;
|
||||
sSetupBlitter.ulDitherType = 0;
|
||||
sSetupBlitter.fccDstColorFormat = FOURCC_SCRN;
|
||||
sSetupBlitter.ulDstWidth = swp.cx;
|
||||
sSetupBlitter.ulDstHeight = swp.cy;
|
||||
sSetupBlitter.lDstPosX = 0;
|
||||
sSetupBlitter.lDstPosY = 0;
|
||||
sSetupBlitter.lScreenPosX = pointl.x;
|
||||
sSetupBlitter.lScreenPosY = pointl.y;
|
||||
|
||||
sSetupBlitter.ulNumDstRects = rgnCtl.crcReturned;
|
||||
sSetupBlitter.pVisDstRects = prectl;
|
||||
|
||||
ulRC = DiveSetupBlitter(pVOData->hDive, &sSetupBlitter);
|
||||
SDL_free(prectl);
|
||||
|
||||
if (ulRC == DIVE_SUCCESS) {
|
||||
pVOData->fBlitterReady = TRUE;
|
||||
WinInvalidateRect(hwnd, NULL, TRUE);
|
||||
debug_os2("DIVE blitter is ready now.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
SDL_SetError("DiveSetupBlitter(), rc = 0x%X", ulRC);
|
||||
} /* if (prectl != NULL) */
|
||||
} /* if (hrgn == NULLHANDLE) else */
|
||||
|
||||
pVOData->fBlitterReady = FALSE;
|
||||
DiveSetupBlitter(pVOData->hDive, 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static PVOID voVideoBufAlloc(PVODATA pVOData, ULONG ulWidth, ULONG ulHeight,
|
||||
ULONG ulBPP, FOURCC fccColorEncoding,
|
||||
PULONG pulScanLineSize)
|
||||
{
|
||||
ULONG ulRC;
|
||||
ULONG ulScanLineSize = ulWidth * (ulBPP >> 3);
|
||||
ULONG ulRC;
|
||||
ULONG ulScanLineSize = ulWidth * (ulBPP >> 3);
|
||||
|
||||
// Destroy previous buffer.
|
||||
voVideoBufFree( pVOData );
|
||||
/* Destroy previous buffer. */
|
||||
voVideoBufFree(pVOData);
|
||||
|
||||
if ( ( ulWidth == 0 ) || ( ulHeight == 0 ) || ( ulBPP == 0 ) )
|
||||
return NULL;
|
||||
if (ulWidth == 0 || ulHeight == 0 || ulBPP == 0)
|
||||
return NULL;
|
||||
|
||||
// Bytes per line.
|
||||
ulScanLineSize = ( ulScanLineSize + 3 ) & ~3; /* 4-byte aligning */
|
||||
*pulScanLineSize = ulScanLineSize;
|
||||
/* Bytes per line. */
|
||||
ulScanLineSize = (ulScanLineSize + 3) & ~3; /* 4-byte aligning */
|
||||
*pulScanLineSize = ulScanLineSize;
|
||||
|
||||
ulRC = DosAllocMem( &pVOData->pBuffer,
|
||||
(ulHeight * ulScanLineSize) + sizeof(ULONG),
|
||||
PAG_COMMIT | PAG_EXECUTE | PAG_READ | PAG_WRITE );
|
||||
if ( ulRC != NO_ERROR )
|
||||
{
|
||||
debug( "DosAllocMem(), rc = %u", ulRC );
|
||||
return NULL;
|
||||
}
|
||||
ulRC = DosAllocMem(&pVOData->pBuffer,
|
||||
(ulHeight * ulScanLineSize) + sizeof(ULONG),
|
||||
PAG_COMMIT | PAG_EXECUTE | PAG_READ | PAG_WRITE);
|
||||
if (ulRC != NO_ERROR) {
|
||||
debug_os2("DosAllocMem(), rc = %u", ulRC);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ulRC = DiveAllocImageBuffer( pVOData->hDive, &pVOData->ulDIVEBufNum,
|
||||
fccColorEncoding, ulWidth, ulHeight,
|
||||
ulScanLineSize, pVOData->pBuffer );
|
||||
if ( ulRC != DIVE_SUCCESS )
|
||||
{
|
||||
debug( "DiveAllocImageBuffer(), rc = 0x%X", ulRC );
|
||||
DosFreeMem( pVOData->pBuffer );
|
||||
pVOData->pBuffer = NULL;
|
||||
pVOData->ulDIVEBufNum = 0;
|
||||
return NULL;
|
||||
}
|
||||
ulRC = DiveAllocImageBuffer(pVOData->hDive, &pVOData->ulDIVEBufNum,
|
||||
fccColorEncoding, ulWidth, ulHeight,
|
||||
ulScanLineSize, pVOData->pBuffer);
|
||||
if (ulRC != DIVE_SUCCESS) {
|
||||
debug_os2("DiveAllocImageBuffer(), rc = 0x%X", ulRC);
|
||||
DosFreeMem(pVOData->pBuffer);
|
||||
pVOData->pBuffer = NULL;
|
||||
pVOData->ulDIVEBufNum = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pVOData->fccColorEncoding = fccColorEncoding;
|
||||
pVOData->ulWidth = ulWidth;
|
||||
pVOData->ulHeight = ulHeight;
|
||||
pVOData->fccColorEncoding = fccColorEncoding;
|
||||
pVOData->ulWidth = ulWidth;
|
||||
pVOData->ulHeight = ulHeight;
|
||||
|
||||
debug( "buffer: 0x%P, DIVE buffer number: %u",
|
||||
pVOData->pBuffer, pVOData->ulDIVEBufNum );
|
||||
debug_os2("buffer: 0x%P, DIVE buffer number: %u",
|
||||
pVOData->pBuffer, pVOData->ulDIVEBufNum);
|
||||
|
||||
return pVOData->pBuffer;
|
||||
return pVOData->pBuffer;
|
||||
}
|
||||
|
||||
static VOID voVideoBufFree(PVODATA pVOData)
|
||||
{
|
||||
ULONG ulRC;
|
||||
ULONG ulRC;
|
||||
|
||||
if ( pVOData->ulDIVEBufNum != 0 )
|
||||
{
|
||||
ulRC = DiveFreeImageBuffer( pVOData->hDive, pVOData->ulDIVEBufNum );
|
||||
if ( ulRC != DIVE_SUCCESS )
|
||||
debug( "DiveFreeImageBuffer(,%u), rc = %u", pVOData->ulDIVEBufNum, ulRC );
|
||||
else
|
||||
debug( "DIVE buffer %u destroyed", pVOData->ulDIVEBufNum );
|
||||
if (pVOData->ulDIVEBufNum != 0) {
|
||||
ulRC = DiveFreeImageBuffer(pVOData->hDive, pVOData->ulDIVEBufNum);
|
||||
if (ulRC != DIVE_SUCCESS) {
|
||||
debug_os2("DiveFreeImageBuffer(,%u), rc = %u", pVOData->ulDIVEBufNum, ulRC);
|
||||
} else {
|
||||
debug_os2("DIVE buffer %u destroyed", pVOData->ulDIVEBufNum);
|
||||
}
|
||||
pVOData->ulDIVEBufNum = 0;
|
||||
}
|
||||
|
||||
pVOData->ulDIVEBufNum = 0;
|
||||
}
|
||||
|
||||
if ( pVOData->pBuffer != NULL )
|
||||
{
|
||||
ulRC = DosFreeMem( pVOData->pBuffer );
|
||||
if ( ulRC != NO_ERROR )
|
||||
debug( "DosFreeMem(), rc = %u", ulRC );
|
||||
|
||||
pVOData->pBuffer = NULL;
|
||||
}
|
||||
if (pVOData->pBuffer != NULL) {
|
||||
ulRC = DosFreeMem(pVOData->pBuffer);
|
||||
if (ulRC != NO_ERROR) {
|
||||
debug_os2("DosFreeMem(), rc = %u", ulRC);
|
||||
}
|
||||
pVOData->pBuffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects,
|
||||
ULONG cSDLRects)
|
||||
{
|
||||
ULONG ulRC;
|
||||
ULONG ulRC;
|
||||
|
||||
if ( !pVOData->fBlitterReady || ( pVOData->ulDIVEBufNum == 0 ) )
|
||||
{
|
||||
debug( "DIVE blitter is not ready" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( pSDLRects != 0 )
|
||||
{
|
||||
PBYTE pbLineMask;
|
||||
|
||||
pbLineMask = SDL_stack_alloc( BYTE, pVOData->ulHeight );
|
||||
if ( pbLineMask == NULL )
|
||||
{
|
||||
debug( "Not enough stack size" );
|
||||
return FALSE;
|
||||
if (!pVOData->fBlitterReady || (pVOData->ulDIVEBufNum == 0)) {
|
||||
debug_os2("DIVE blitter is not ready");
|
||||
return FALSE;
|
||||
}
|
||||
memset( pbLineMask, 0, pVOData->ulHeight );
|
||||
|
||||
for( ; ((LONG)cSDLRects) > 0; cSDLRects--, pSDLRects++ )
|
||||
memset( &pbLineMask[pSDLRects->y], 1, pSDLRects->h );
|
||||
if (pSDLRects != 0) {
|
||||
PBYTE pbLineMask;
|
||||
|
||||
ulRC = DiveBlitImageLines( pVOData->hDive, pVOData->ulDIVEBufNum,
|
||||
DIVE_BUFFER_SCREEN, pbLineMask );
|
||||
SDL_stack_free( pbLineMask );
|
||||
pbLineMask = SDL_stack_alloc(BYTE, pVOData->ulHeight);
|
||||
if (pbLineMask == NULL) {
|
||||
debug_os2("Not enough stack size");
|
||||
return FALSE;
|
||||
}
|
||||
memset(pbLineMask, 0, pVOData->ulHeight);
|
||||
|
||||
if ( ulRC != DIVE_SUCCESS )
|
||||
debug( "DiveBlitImageLines(), rc = 0x%X", ulRC );
|
||||
}
|
||||
else
|
||||
{
|
||||
ulRC = DiveBlitImage( pVOData->hDive, pVOData->ulDIVEBufNum,
|
||||
DIVE_BUFFER_SCREEN );
|
||||
if ( ulRC != DIVE_SUCCESS )
|
||||
debug( "DiveBlitImage(), rc = 0x%X", ulRC );
|
||||
}
|
||||
for ( ; ((LONG)cSDLRects) > 0; cSDLRects--, pSDLRects++) {
|
||||
memset(&pbLineMask[pSDLRects->y], 1, pSDLRects->h);
|
||||
}
|
||||
|
||||
return ulRC == DIVE_SUCCESS;
|
||||
ulRC = DiveBlitImageLines(pVOData->hDive, pVOData->ulDIVEBufNum,
|
||||
DIVE_BUFFER_SCREEN, pbLineMask);
|
||||
SDL_stack_free(pbLineMask);
|
||||
|
||||
if (ulRC != DIVE_SUCCESS) {
|
||||
debug_os2("DiveBlitImageLines(), rc = 0x%X", ulRC);
|
||||
}
|
||||
} else {
|
||||
ulRC = DiveBlitImage(pVOData->hDive, pVOData->ulDIVEBufNum,
|
||||
DIVE_BUFFER_SCREEN);
|
||||
if (ulRC != DIVE_SUCCESS) {
|
||||
debug_os2("DiveBlitImage(), rc = 0x%X", ulRC);
|
||||
}
|
||||
}
|
||||
|
||||
return ulRC == DIVE_SUCCESS;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,46 +26,43 @@
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
#include "SDL_os2util.h"
|
||||
|
||||
HPOINTER hptrCursor = NULLHANDLE;
|
||||
HPOINTER hptrCursor = NULLHANDLE;
|
||||
|
||||
static SDL_Cursor* OS2_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y)
|
||||
{
|
||||
ULONG ulMaxW = WinQuerySysValue( HWND_DESKTOP, SV_CXPOINTER );
|
||||
ULONG ulMaxH = WinQuerySysValue( HWND_DESKTOP, SV_CYPOINTER );
|
||||
HPOINTER hptr;
|
||||
SDL_Cursor *pSDLCursor;
|
||||
ULONG ulMaxW = WinQuerySysValue(HWND_DESKTOP, SV_CXPOINTER);
|
||||
ULONG ulMaxH = WinQuerySysValue(HWND_DESKTOP, SV_CYPOINTER);
|
||||
HPOINTER hptr;
|
||||
SDL_Cursor* pSDLCursor;
|
||||
|
||||
if ( ( surface->w > ulMaxW ) || ( surface->h > ulMaxH ) )
|
||||
{
|
||||
debug( "Given image size is %u x %u, maximum allowed size is %u x %u",
|
||||
surface->w, surface->h, ulMaxW, ulMaxH );
|
||||
return NULL;
|
||||
}
|
||||
if (surface->w > ulMaxW || surface->h > ulMaxH) {
|
||||
debug_os2("Given image size is %u x %u, maximum allowed size is %u x %u",
|
||||
surface->w, surface->h, ulMaxW, ulMaxH);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hptr = utilCreatePointer( surface, hot_x, ulMaxH - hot_y - 1 );
|
||||
if ( hptr == NULLHANDLE )
|
||||
return NULL;
|
||||
hptr = utilCreatePointer(surface, hot_x, ulMaxH - hot_y - 1);
|
||||
if (hptr == NULLHANDLE)
|
||||
return NULL;
|
||||
|
||||
pSDLCursor = SDL_calloc( 1, sizeof(SDL_Cursor) );
|
||||
if ( pSDLCursor == NULL )
|
||||
{
|
||||
WinDestroyPointer( hptr );
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
pSDLCursor = SDL_calloc(1, sizeof(SDL_Cursor));
|
||||
if (pSDLCursor == NULL) {
|
||||
WinDestroyPointer(hptr);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pSDLCursor->driverdata = (void *)hptr;
|
||||
return pSDLCursor;
|
||||
pSDLCursor->driverdata = (void *)hptr;
|
||||
return pSDLCursor;
|
||||
}
|
||||
|
||||
static SDL_Cursor* OS2_CreateSystemCursor(SDL_SystemCursor id)
|
||||
{
|
||||
SDL_Cursor* pSDLCursor;
|
||||
LONG lSysId;
|
||||
HPOINTER hptr;
|
||||
SDL_Cursor* pSDLCursor;
|
||||
LONG lSysId;
|
||||
HPOINTER hptr;
|
||||
|
||||
switch( id )
|
||||
{
|
||||
switch (id) {
|
||||
case SDL_SYSTEM_CURSOR_ARROW: lSysId = SPTR_ARROW; break;
|
||||
case SDL_SYSTEM_CURSOR_IBEAM: lSysId = SPTR_TEXT; break;
|
||||
case SDL_SYSTEM_CURSOR_WAIT: lSysId = SPTR_WAIT; break;
|
||||
@@ -79,124 +76,119 @@ static SDL_Cursor* OS2_CreateSystemCursor(SDL_SystemCursor id)
|
||||
case SDL_SYSTEM_CURSOR_NO: lSysId = SPTR_ILLEGAL; break;
|
||||
case SDL_SYSTEM_CURSOR_HAND: lSysId = SPTR_ARROW; break;
|
||||
default:
|
||||
debug( "Unknown cursor id: %u", id );
|
||||
return NULL;
|
||||
}
|
||||
debug_os2("Unknown cursor id: %u", id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// On eCS SPTR_WAIT for last paramether fCopy=TRUE/FALSE gives different
|
||||
// "wait" icons. -=8( )
|
||||
hptr = WinQuerySysPointer( HWND_DESKTOP, lSysId,
|
||||
id == SDL_SYSTEM_CURSOR_WAIT );
|
||||
if ( hptr == NULLHANDLE )
|
||||
{
|
||||
debug( "Cannot load OS/2 system pointer %u for SDL cursor id %u",
|
||||
lSysId, id );
|
||||
return NULL;
|
||||
}
|
||||
/* On eCS SPTR_WAIT for last paramether fCopy=TRUE/FALSE gives different
|
||||
* "wait" icons. -=8( ) */
|
||||
hptr = WinQuerySysPointer(HWND_DESKTOP, lSysId,
|
||||
id == SDL_SYSTEM_CURSOR_WAIT);
|
||||
if (hptr == NULLHANDLE) {
|
||||
debug_os2("Cannot load OS/2 system pointer %u for SDL cursor id %u",
|
||||
lSysId, id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pSDLCursor = SDL_calloc( 1, sizeof(SDL_Cursor) );
|
||||
if ( pSDLCursor == NULL )
|
||||
{
|
||||
WinDestroyPointer( hptr );
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
pSDLCursor = SDL_calloc(1, sizeof(SDL_Cursor));
|
||||
if (pSDLCursor == NULL) {
|
||||
WinDestroyPointer(hptr);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pSDLCursor->driverdata = (void *)hptr;
|
||||
return pSDLCursor;
|
||||
pSDLCursor->driverdata = (void *)hptr;
|
||||
return pSDLCursor;
|
||||
}
|
||||
|
||||
static void OS2_FreeCursor(SDL_Cursor *cursor)
|
||||
{
|
||||
HPOINTER hptr = (HPOINTER)cursor->driverdata;
|
||||
HPOINTER hptr = (HPOINTER)cursor->driverdata;
|
||||
|
||||
WinDestroyPointer( hptr );
|
||||
SDL_free( cursor );
|
||||
WinDestroyPointer(hptr);
|
||||
SDL_free(cursor);
|
||||
}
|
||||
|
||||
static int OS2_ShowCursor(SDL_Cursor *cursor)
|
||||
{
|
||||
hptrCursor = cursor != NULL ? (HPOINTER)cursor->driverdata : NULLHANDLE;
|
||||
|
||||
return ( ( SDL_GetMouseFocus() == NULL ) ||
|
||||
WinSetPointer( HWND_DESKTOP, hptrCursor ) ) ? 0 : -1;
|
||||
hptrCursor = (cursor != NULL)? (HPOINTER)cursor->driverdata : NULLHANDLE;
|
||||
return ((SDL_GetMouseFocus() == NULL) ||
|
||||
WinSetPointer(HWND_DESKTOP, hptrCursor))? 0 : -1;
|
||||
}
|
||||
|
||||
static void OS2_WarpMouse(SDL_Window * window, int x, int y)
|
||||
{
|
||||
PWINDATA pWinData = (PWINDATA)window->driverdata;
|
||||
POINTL pointl;
|
||||
WINDATA *pWinData = (WINDATA *)window->driverdata;
|
||||
POINTL pointl;
|
||||
|
||||
pointl.x = x;
|
||||
pointl.y = window->h - y;
|
||||
WinMapWindowPoints( pWinData->hwnd, HWND_DESKTOP, &pointl, 1 );
|
||||
// pWinData->lSkipWMMouseMove++; ???
|
||||
WinSetPointerPos( HWND_DESKTOP, pointl.x, pointl.y );
|
||||
pointl.x = x;
|
||||
pointl.y = window->h - y;
|
||||
WinMapWindowPoints(pWinData->hwnd, HWND_DESKTOP, &pointl, 1);
|
||||
/* pWinData->lSkipWMMouseMove++; ???*/
|
||||
WinSetPointerPos(HWND_DESKTOP, pointl.x, pointl.y);
|
||||
}
|
||||
|
||||
static int OS2_WarpMouseGlobal(int x, int y)
|
||||
{
|
||||
WinSetPointerPos( HWND_DESKTOP, x,
|
||||
WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ) - y );
|
||||
return 0;
|
||||
WinSetPointerPos(HWND_DESKTOP, x,
|
||||
WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - y);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int OS2_CaptureMouse(SDL_Window *window)
|
||||
{
|
||||
return WinSetCapture( HWND_DESKTOP,
|
||||
window == NULL ? NULLHANDLE
|
||||
: ((PWINDATA)window->driverdata)->hwnd )
|
||||
? 0 : -1;
|
||||
return WinSetCapture(HWND_DESKTOP, (window == NULL)? NULLHANDLE :
|
||||
((WINDATA *)window->driverdata)->hwnd)? 0 : -1;
|
||||
}
|
||||
|
||||
static Uint32 OS2_GetGlobalMouseState(int *x, int *y)
|
||||
{
|
||||
POINTL pointl;
|
||||
ULONG ulRes;
|
||||
POINTL pointl;
|
||||
ULONG ulRes;
|
||||
|
||||
WinQueryPointerPos( HWND_DESKTOP, &pointl );
|
||||
*x = pointl.x;
|
||||
*y = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ) - pointl.y - 1;
|
||||
WinQueryPointerPos(HWND_DESKTOP, &pointl);
|
||||
*x = pointl.x;
|
||||
*y = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - pointl.y - 1;
|
||||
|
||||
ulRes = WinGetKeyState( HWND_DESKTOP, VK_BUTTON1 ) & 0x8000
|
||||
? SDL_BUTTON_LMASK : 0;
|
||||
if ( WinGetKeyState( HWND_DESKTOP, VK_BUTTON2 ) & 0x8000 )
|
||||
ulRes |= SDL_BUTTON_RMASK;
|
||||
if ( WinGetKeyState( HWND_DESKTOP, VK_BUTTON3 ) & 0x8000 )
|
||||
ulRes |= SDL_BUTTON_MMASK;
|
||||
ulRes = (WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000)? SDL_BUTTON_LMASK : 0;
|
||||
if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000)
|
||||
ulRes |= SDL_BUTTON_RMASK;
|
||||
if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000)
|
||||
ulRes |= SDL_BUTTON_MMASK;
|
||||
|
||||
return ulRes;
|
||||
return ulRes;
|
||||
}
|
||||
|
||||
|
||||
void OS2_InitMouse(_THIS, ULONG hab)
|
||||
{
|
||||
SDL_Mouse *pSDLMouse = SDL_GetMouse();
|
||||
SDL_Mouse *pSDLMouse = SDL_GetMouse();
|
||||
|
||||
pSDLMouse->CreateCursor = OS2_CreateCursor;
|
||||
pSDLMouse->CreateSystemCursor = OS2_CreateSystemCursor;
|
||||
pSDLMouse->ShowCursor = OS2_ShowCursor;
|
||||
pSDLMouse->FreeCursor = OS2_FreeCursor;
|
||||
pSDLMouse->WarpMouse = OS2_WarpMouse;
|
||||
pSDLMouse->WarpMouseGlobal = OS2_WarpMouseGlobal;
|
||||
pSDLMouse->CaptureMouse = OS2_CaptureMouse;
|
||||
pSDLMouse->GetGlobalMouseState = OS2_GetGlobalMouseState;
|
||||
pSDLMouse->CreateCursor = OS2_CreateCursor;
|
||||
pSDLMouse->CreateSystemCursor = OS2_CreateSystemCursor;
|
||||
pSDLMouse->ShowCursor = OS2_ShowCursor;
|
||||
pSDLMouse->FreeCursor = OS2_FreeCursor;
|
||||
pSDLMouse->WarpMouse = OS2_WarpMouse;
|
||||
pSDLMouse->WarpMouseGlobal = OS2_WarpMouseGlobal;
|
||||
pSDLMouse->CaptureMouse = OS2_CaptureMouse;
|
||||
pSDLMouse->GetGlobalMouseState = OS2_GetGlobalMouseState;
|
||||
|
||||
SDL_SetDefaultCursor( OS2_CreateSystemCursor( SDL_SYSTEM_CURSOR_ARROW ) );
|
||||
if ( hptrCursor == NULLHANDLE )
|
||||
hptrCursor = WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, TRUE );
|
||||
SDL_SetDefaultCursor(OS2_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW));
|
||||
if (hptrCursor == NULLHANDLE)
|
||||
hptrCursor = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, TRUE);
|
||||
}
|
||||
|
||||
void OS2_QuitMouse(_THIS)
|
||||
{
|
||||
SDL_Mouse *pSDLMouse = SDL_GetMouse();
|
||||
SDL_Mouse *pSDLMouse = SDL_GetMouse();
|
||||
|
||||
if ( pSDLMouse->def_cursor != NULL )
|
||||
{
|
||||
SDL_free( pSDLMouse->def_cursor );
|
||||
pSDLMouse->def_cursor = NULL;
|
||||
pSDLMouse->cur_cursor = NULL;
|
||||
}
|
||||
if (pSDLMouse->def_cursor != NULL) {
|
||||
SDL_free(pSDLMouse->def_cursor);
|
||||
pSDLMouse->def_cursor = NULL;
|
||||
pSDLMouse->cur_cursor = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_OS2 */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#ifndef SDL_os2mouse_h_
|
||||
#define SDL_os2mouse_h_
|
||||
|
||||
extern HPOINTER hptrCursor;
|
||||
extern HPOINTER hptrCursor;
|
||||
|
||||
extern void OS2_InitMouse(_THIS, ULONG hab);
|
||||
extern void OS2_QuitMouse(_THIS);
|
||||
|
||||
@@ -26,29 +26,34 @@
|
||||
typedef struct _VODATA *PVODATA;
|
||||
|
||||
typedef struct _VIDEOOUTPUTINFO {
|
||||
ULONG ulBPP;
|
||||
ULONG fccColorEncoding;
|
||||
ULONG ulScanLineSize;
|
||||
ULONG ulHorizResolution;
|
||||
ULONG ulVertResolution;
|
||||
} VIDEOOUTPUTINFO, *PVIDEOOUTPUTINFO;
|
||||
ULONG ulBPP;
|
||||
ULONG fccColorEncoding;
|
||||
ULONG ulScanLineSize;
|
||||
ULONG ulHorizResolution;
|
||||
ULONG ulVertResolution;
|
||||
} VIDEOOUTPUTINFO;
|
||||
|
||||
typedef struct _OS2VIDEOOUTPUT {
|
||||
BOOL (*QueryInfo)(PVIDEOOUTPUTINFO pInfo);
|
||||
PVODATA (*Open)();
|
||||
VOID (*Close)(PVODATA pVOData);
|
||||
BOOL (*SetVisibleRegion)(PVODATA pVOData, HWND hwnd,
|
||||
SDL_DisplayMode *pSDLDisplayMode, HRGN hrgnShape,
|
||||
BOOL fVisible);
|
||||
PVOID (*VideoBufAlloc)(PVODATA pVOData, ULONG ulWidth, ULONG ulHeight,
|
||||
ULONG ulBPP, ULONG fccColorEncoding,
|
||||
PULONG pulScanLineSize);
|
||||
VOID (*VideoBufFree)(PVODATA pVOData);
|
||||
BOOL (*Update)(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects,
|
||||
ULONG cSDLRects);
|
||||
} OS2VIDEOOUTPUT, *POS2VIDEOOUTPUT;
|
||||
BOOL (*QueryInfo)(VIDEOOUTPUTINFO *pInfo);
|
||||
PVODATA (*Open)();
|
||||
VOID (*Close)(PVODATA pVOData);
|
||||
|
||||
BOOL (*SetVisibleRegion)(PVODATA pVOData, HWND hwnd,
|
||||
SDL_DisplayMode *pSDLDisplayMode, HRGN hrgnShape,
|
||||
BOOL fVisible);
|
||||
|
||||
PVOID (*VideoBufAlloc)(PVODATA pVOData, ULONG ulWidth, ULONG ulHeight,
|
||||
ULONG ulBPP, ULONG fccColorEncoding,
|
||||
PULONG pulScanLineSize);
|
||||
|
||||
VOID (*VideoBufFree)(PVODATA pVOData);
|
||||
BOOL (*Update)(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects,
|
||||
ULONG cSDLRects);
|
||||
} OS2VIDEOOUTPUT;
|
||||
|
||||
extern OS2VIDEOOUTPUT voDive;
|
||||
extern OS2VIDEOOUTPUT voVMan;
|
||||
|
||||
#endif /* SDL_os2output_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -24,95 +24,88 @@
|
||||
|
||||
#include "SDL_os2util.h"
|
||||
|
||||
|
||||
HPOINTER utilCreatePointer(SDL_Surface *surface, ULONG ulHotX, ULONG ulHotY)
|
||||
{
|
||||
HBITMAP hbm;
|
||||
BITMAPINFOHEADER2 bmih = { 0 };
|
||||
BITMAPINFO bmi = { 0 };
|
||||
HPS hps;
|
||||
PULONG pulBitmap;
|
||||
PULONG pulDst, pulSrc, pulDstMask;
|
||||
ULONG ulY, ulX;
|
||||
HPOINTER hptr = NULLHANDLE;
|
||||
HBITMAP hbm;
|
||||
BITMAPINFOHEADER2 bmih = { 0 };
|
||||
BITMAPINFO bmi = { 0 };
|
||||
HPS hps;
|
||||
PULONG pulBitmap;
|
||||
PULONG pulDst, pulSrc, pulDstMask;
|
||||
ULONG ulY, ulX;
|
||||
HPOINTER hptr = NULLHANDLE;
|
||||
|
||||
if ( surface->format->format != SDL_PIXELFORMAT_ARGB8888 )
|
||||
{
|
||||
debug( "Image format should be SDL_PIXELFORMAT_ARGB8888" );
|
||||
return NULLHANDLE;
|
||||
}
|
||||
|
||||
pulBitmap = SDL_malloc( surface->h * surface->w * 4 * 2 );
|
||||
if ( pulBitmap == NULL )
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
return NULLHANDLE;
|
||||
}
|
||||
|
||||
// pulDst - last line of surface (image) part of the result bitmap
|
||||
pulDst = &pulBitmap[ (surface->h - 1) * surface->w ];
|
||||
// pulDstMask - last line of mask part of the result bitmap
|
||||
pulDstMask = &pulBitmap[ (2 * surface->h - 1) * surface->w ];
|
||||
// pulSrc - first line of source image
|
||||
pulSrc = (PULONG)surface->pixels;
|
||||
|
||||
for( ulY = 0; ulY < surface->h; ulY++ )
|
||||
{
|
||||
for( ulX = 0; ulX < surface->w; ulX++ )
|
||||
{
|
||||
if ( (pulSrc[ulX] & 0xFF000000) == 0 )
|
||||
{
|
||||
pulDst[ulX] = 0;
|
||||
pulDstMask[ulX] = 0xFFFFFFFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
pulDst[ulX] = pulSrc[ulX] & 0xFFFFFF;
|
||||
pulDstMask[ulX] = 0;
|
||||
}
|
||||
if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) {
|
||||
debug_os2("Image format should be SDL_PIXELFORMAT_ARGB8888");
|
||||
return NULLHANDLE;
|
||||
}
|
||||
|
||||
// Set image and mask pointers on one line up
|
||||
pulDst -= surface->w;
|
||||
pulDstMask -= surface->w;
|
||||
// Set source image pointer to the next line
|
||||
pulSrc = (PULONG)( ((PCHAR)pulSrc) + surface->pitch );
|
||||
}
|
||||
pulBitmap = SDL_malloc(surface->h * surface->w * 4 * 2);
|
||||
if (pulBitmap == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULLHANDLE;
|
||||
}
|
||||
|
||||
// Create system bitmap object.
|
||||
/* pulDst - last line of surface (image) part of the result bitmap */
|
||||
pulDst = &pulBitmap[ (surface->h - 1) * surface->w ];
|
||||
/* pulDstMask - last line of mask part of the result bitmap */
|
||||
pulDstMask = &pulBitmap[ (2 * surface->h - 1) * surface->w ];
|
||||
/* pulSrc - first line of source image */
|
||||
pulSrc = (PULONG)surface->pixels;
|
||||
|
||||
bmih.cbFix = sizeof(BITMAPINFOHEADER2);
|
||||
bmih.cx = surface->w;
|
||||
bmih.cy = 2 * surface->h;
|
||||
bmih.cPlanes = 1;
|
||||
bmih.cBitCount = 32;
|
||||
bmih.ulCompression = BCA_UNCOMP;
|
||||
bmih.cbImage = bmih.cx * bmih.cy * 4;
|
||||
for (ulY = 0; ulY < surface->h; ulY++) {
|
||||
for (ulX = 0; ulX < surface->w; ulX++) {
|
||||
if ((pulSrc[ulX] & 0xFF000000) == 0) {
|
||||
pulDst[ulX] = 0;
|
||||
pulDstMask[ulX] = 0xFFFFFFFF;
|
||||
} else {
|
||||
pulDst[ulX] = pulSrc[ulX] & 0xFFFFFF;
|
||||
pulDstMask[ulX] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bmi.cbFix = sizeof(BITMAPINFOHEADER);
|
||||
bmi.cx = bmih.cx;
|
||||
bmi.cy = bmih.cy;
|
||||
bmi.cPlanes = 1;
|
||||
bmi.cBitCount = 32;
|
||||
/* Set image and mask pointers on one line up */
|
||||
pulDst -= surface->w;
|
||||
pulDstMask -= surface->w;
|
||||
/* Set source image pointer to the next line */
|
||||
pulSrc = (PULONG) (((PCHAR)pulSrc) + surface->pitch);
|
||||
}
|
||||
|
||||
hps = WinGetPS( HWND_DESKTOP );
|
||||
hbm = GpiCreateBitmap( hps, (PBITMAPINFOHEADER2)&bmih, CBM_INIT,
|
||||
(PBYTE)pulBitmap, (PBITMAPINFO2)&bmi );
|
||||
if ( hbm == GPI_ERROR )
|
||||
debug( "GpiCreateBitmap() failed" );
|
||||
else
|
||||
{
|
||||
// Create a system pointer object.
|
||||
hptr = WinCreatePointer( HWND_DESKTOP, hbm, TRUE, ulHotX, ulHotY );
|
||||
if ( hptr == NULLHANDLE )
|
||||
debug( "WinCreatePointer() failed" );
|
||||
}
|
||||
GpiDeleteBitmap( hbm );
|
||||
/* Create system bitmap object. */
|
||||
bmih.cbFix = sizeof(BITMAPINFOHEADER2);
|
||||
bmih.cx = surface->w;
|
||||
bmih.cy = 2 * surface->h;
|
||||
bmih.cPlanes = 1;
|
||||
bmih.cBitCount = 32;
|
||||
bmih.ulCompression = BCA_UNCOMP;
|
||||
bmih.cbImage = bmih.cx * bmih.cy * 4;
|
||||
|
||||
WinReleasePS( hps );
|
||||
SDL_free( pulBitmap );
|
||||
bmi.cbFix = sizeof(BITMAPINFOHEADER);
|
||||
bmi.cx = bmih.cx;
|
||||
bmi.cy = bmih.cy;
|
||||
bmi.cPlanes = 1;
|
||||
bmi.cBitCount = 32;
|
||||
|
||||
return hptr;
|
||||
hps = WinGetPS(HWND_DESKTOP);
|
||||
hbm = GpiCreateBitmap(hps, (PBITMAPINFOHEADER2)&bmih, CBM_INIT,
|
||||
(PBYTE)pulBitmap, (PBITMAPINFO2)&bmi);
|
||||
if (hbm == GPI_ERROR) {
|
||||
debug_os2("GpiCreateBitmap() failed");
|
||||
} else {
|
||||
/* Create a system pointer object. */
|
||||
hptr = WinCreatePointer(HWND_DESKTOP, hbm, TRUE, ulHotX, ulHotY);
|
||||
if (hptr == NULLHANDLE) {
|
||||
debug_os2("WinCreatePointer() failed");
|
||||
}
|
||||
}
|
||||
GpiDeleteBitmap(hbm);
|
||||
|
||||
WinReleasePS(hps);
|
||||
SDL_free(pulBitmap);
|
||||
|
||||
return hptr;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_OS2 */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -33,3 +33,6 @@
|
||||
HPOINTER utilCreatePointer(SDL_Surface *surface, ULONG ulHotX, ULONG ulHotY);
|
||||
|
||||
#endif /* SDL_os2util_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -39,43 +39,44 @@
|
||||
#include "SDL_os2output.h"
|
||||
|
||||
typedef struct SDL_VideoData {
|
||||
HAB hab;
|
||||
HMQ hmq;
|
||||
POS2VIDEOOUTPUT pOutput; // Video output routines.
|
||||
} SDL_VideoData, *PSDL_VideoData;
|
||||
HAB hab;
|
||||
HMQ hmq;
|
||||
OS2VIDEOOUTPUT *pOutput; /* Video output routines */
|
||||
} SDL_VideoData;
|
||||
|
||||
typedef struct _WINDATA {
|
||||
SDL_Window *window;
|
||||
POS2VIDEOOUTPUT pOutput; // Video output routines.
|
||||
HWND hwndFrame;
|
||||
HWND hwnd;
|
||||
PFNWP fnUserWndProc;
|
||||
PFNWP fnWndFrameProc;
|
||||
SDL_Window *window;
|
||||
OS2VIDEOOUTPUT *pOutput; /* Video output routines */
|
||||
HWND hwndFrame;
|
||||
HWND hwnd;
|
||||
PFNWP fnUserWndProc;
|
||||
PFNWP fnWndFrameProc;
|
||||
|
||||
PVODATA pVOData; // Video output data.
|
||||
PVODATA pVOData; /* Video output data */
|
||||
|
||||
HRGN hrgnShape;
|
||||
HPOINTER hptrIcon;
|
||||
RECTL rectlBeforeFS;
|
||||
HRGN hrgnShape;
|
||||
HPOINTER hptrIcon;
|
||||
RECTL rectlBeforeFS;
|
||||
|
||||
LONG lSkipWMSize;
|
||||
LONG lSkipWMMove;
|
||||
LONG lSkipWMMouseMove;
|
||||
LONG lSkipWMVRNEnabled;
|
||||
LONG lSkipWMAdjustFramePos;
|
||||
} WINDATA, *PWINDATA;
|
||||
LONG lSkipWMSize;
|
||||
LONG lSkipWMMove;
|
||||
LONG lSkipWMMouseMove;
|
||||
LONG lSkipWMVRNEnabled;
|
||||
LONG lSkipWMAdjustFramePos;
|
||||
} WINDATA;
|
||||
|
||||
typedef struct _DISPLAYDATA {
|
||||
ULONG ulDPIHor;
|
||||
ULONG ulDPIVer;
|
||||
ULONG ulDPIDiag;
|
||||
} DISPLAYDATA, *PDISPLAYDATA;
|
||||
ULONG ulDPIHor;
|
||||
ULONG ulDPIVer;
|
||||
ULONG ulDPIDiag;
|
||||
} DISPLAYDATA;
|
||||
|
||||
typedef struct _MODEDATA {
|
||||
ULONG ulDepth;
|
||||
ULONG fccColorEncoding;
|
||||
ULONG ulScanLineBytes;
|
||||
} MODEDATA, *PMODEDATA;
|
||||
|
||||
ULONG ulDepth;
|
||||
ULONG fccColorEncoding;
|
||||
ULONG ulScanLineBytes;
|
||||
} MODEDATA;
|
||||
|
||||
#endif /* SDL_os2video_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -34,23 +34,23 @@
|
||||
#include "my_gradd.h"
|
||||
|
||||
typedef struct _VODATA {
|
||||
PVOID pBuffer;
|
||||
HRGN hrgnVisible;
|
||||
ULONG ulBPP;
|
||||
ULONG ulScanLineSize;
|
||||
ULONG ulWidth;
|
||||
ULONG ulHeight;
|
||||
ULONG ulScreenHeight;
|
||||
ULONG ulScreenBytesPerLine;
|
||||
RECTL rectlWin;
|
||||
PVOID pBuffer;
|
||||
HRGN hrgnVisible;
|
||||
ULONG ulBPP;
|
||||
ULONG ulScanLineSize;
|
||||
ULONG ulWidth;
|
||||
ULONG ulHeight;
|
||||
ULONG ulScreenHeight;
|
||||
ULONG ulScreenBytesPerLine;
|
||||
RECTL rectlWin;
|
||||
|
||||
PRECTL pRectl;
|
||||
ULONG cRectl;
|
||||
PBLTRECT pBltRect;
|
||||
ULONG cBltRect;
|
||||
PRECTL pRectl;
|
||||
ULONG cRectl;
|
||||
PBLTRECT pBltRect;
|
||||
ULONG cBltRect;
|
||||
} VODATA;
|
||||
|
||||
static BOOL voQueryInfo(PVIDEOOUTPUTINFO pInfo);
|
||||
static BOOL voQueryInfo(VIDEOOUTPUTINFO *pInfo);
|
||||
static PVODATA voOpen();
|
||||
static VOID voClose(PVODATA pVOData);
|
||||
static BOOL voSetVisibleRegion(PVODATA pVOData, HWND hwnd,
|
||||
@@ -64,448 +64,421 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects,
|
||||
ULONG cSDLRects);
|
||||
|
||||
OS2VIDEOOUTPUT voVMan = {
|
||||
voQueryInfo,
|
||||
voOpen,
|
||||
voClose,
|
||||
voSetVisibleRegion,
|
||||
voVideoBufAlloc,
|
||||
voVideoBufFree,
|
||||
voUpdate
|
||||
voQueryInfo,
|
||||
voOpen,
|
||||
voClose,
|
||||
voSetVisibleRegion,
|
||||
voVideoBufAlloc,
|
||||
voVideoBufFree,
|
||||
voUpdate
|
||||
};
|
||||
|
||||
|
||||
static HMODULE hmodVMan = NULLHANDLE;
|
||||
static FNVMIENTRY *pfnVMIEntry = NULL;
|
||||
static ULONG ulVRAMAddress = 0;
|
||||
static HMODULE hmodVMan = NULLHANDLE;
|
||||
static FNVMIENTRY *pfnVMIEntry = NULL;
|
||||
static ULONG ulVRAMAddress = 0;
|
||||
|
||||
VOID APIENTRY ExitVMan(VOID)
|
||||
{
|
||||
if ( ( ulVRAMAddress != 0 ) && ( hmodVMan != NULLHANDLE ) )
|
||||
{
|
||||
pfnVMIEntry( 0, VMI_CMD_TERMPROC, NULL, NULL );
|
||||
DosFreeModule( hmodVMan );
|
||||
}
|
||||
if (ulVRAMAddress != 0 && hmodVMan != NULLHANDLE) {
|
||||
pfnVMIEntry(0, VMI_CMD_TERMPROC, NULL, NULL);
|
||||
DosFreeModule(hmodVMan);
|
||||
}
|
||||
|
||||
DosExitList( EXLST_EXIT, (PFNEXITLIST)NULL );
|
||||
DosExitList(EXLST_EXIT, (PFNEXITLIST)NULL);
|
||||
}
|
||||
|
||||
static BOOL _vmanInit()
|
||||
static BOOL _vmanInit(void)
|
||||
{
|
||||
ULONG ulRC;
|
||||
CHAR acBuf[255];
|
||||
INITPROCOUT stInitProcOut;
|
||||
ULONG ulRC;
|
||||
CHAR acBuf[255];
|
||||
INITPROCOUT stInitProcOut;
|
||||
|
||||
if (hmodVMan != NULLHANDLE) /* Already was initialized */
|
||||
return TRUE;
|
||||
|
||||
/* Load vman.dll */
|
||||
ulRC = DosLoadModule(acBuf, sizeof(acBuf), "VMAN", &hmodVMan);
|
||||
if (ulRC != NO_ERROR) {
|
||||
debug_os2("Could not load VMAN.DLL, rc = %u : %s", ulRC, acBuf);
|
||||
hmodVMan = NULLHANDLE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Get VMIEntry */
|
||||
ulRC = DosQueryProcAddr(hmodVMan, 0L, "VMIEntry", (PFN *)&pfnVMIEntry);
|
||||
if (ulRC != NO_ERROR) {
|
||||
debug_os2("Could not query address of pfnVMIEntry func. of VMAN.DLL, "
|
||||
"rc = %u", ulRC);
|
||||
DosFreeModule(hmodVMan);
|
||||
hmodVMan = NULLHANDLE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* VMAN initialization */
|
||||
stInitProcOut.ulLength = sizeof(stInitProcOut);
|
||||
ulRC = pfnVMIEntry(0, VMI_CMD_INITPROC, NULL, &stInitProcOut);
|
||||
if (ulRC != RC_SUCCESS) {
|
||||
debug_os2("Could not initialize VMAN for this process");
|
||||
pfnVMIEntry = NULL;
|
||||
DosFreeModule(hmodVMan);
|
||||
hmodVMan = NULLHANDLE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Store video memory virtual address */
|
||||
ulVRAMAddress = stInitProcOut.ulVRAMVirt;
|
||||
/* We use exit list for VMI_CMD_TERMPROC */
|
||||
if (DosExitList(EXLST_ADD | 0x00001000, (PFNEXITLIST)ExitVMan) != NO_ERROR) {
|
||||
debug_os2("DosExitList() failed");
|
||||
}
|
||||
|
||||
if ( hmodVMan != NULLHANDLE )
|
||||
// Already was initialized.
|
||||
return TRUE;
|
||||
|
||||
// Load vman.dll
|
||||
ulRC = DosLoadModule( acBuf, sizeof(acBuf), "VMAN", &hmodVMan );
|
||||
if ( ulRC != NO_ERROR )
|
||||
{
|
||||
debug( "Could not load VMAN.DLL, rc = %u : %s", ulRC, &acBuf );
|
||||
hmodVMan = NULLHANDLE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Get VMIEntry.
|
||||
ulRC = DosQueryProcAddr( hmodVMan, 0L, "VMIEntry", (PFN *)&pfnVMIEntry );
|
||||
if ( ulRC != NO_ERROR )
|
||||
{
|
||||
debug( "Could not query address of pfnVMIEntry func. of VMAN.DLL, "
|
||||
"rc = %u", ulRC );
|
||||
DosFreeModule( hmodVMan );
|
||||
hmodVMan = NULLHANDLE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// VMAN initialization.
|
||||
stInitProcOut.ulLength = sizeof(stInitProcOut);
|
||||
ulRC = pfnVMIEntry( 0, VMI_CMD_INITPROC, NULL, &stInitProcOut );
|
||||
if ( ulRC != RC_SUCCESS )
|
||||
{
|
||||
debug( "Could not initialize VMAN for this process" );
|
||||
pfnVMIEntry = NULL;
|
||||
DosFreeModule( hmodVMan );
|
||||
hmodVMan = NULLHANDLE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Store video memory virtual address.
|
||||
ulVRAMAddress = stInitProcOut.ulVRAMVirt;
|
||||
// We use exit list for VMI_CMD_TERMPROC.
|
||||
if ( DosExitList( EXLST_ADD | 0x00001000, (PFNEXITLIST)ExitVMan )
|
||||
!= NO_ERROR )
|
||||
debug( "DosExitList() failed" );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static PRECTL _getRectlArray(PVODATA pVOData, ULONG cRects)
|
||||
{
|
||||
PRECTL pRectl;
|
||||
PRECTL pRectl;
|
||||
|
||||
if ( pVOData->cRectl >= cRects )
|
||||
return pVOData->pRectl;
|
||||
if (pVOData->cRectl >= cRects)
|
||||
return pVOData->pRectl;
|
||||
|
||||
pRectl = SDL_realloc( pVOData->pRectl, cRects * sizeof(RECTL) );
|
||||
if ( pRectl == NULL )
|
||||
return NULL;
|
||||
pRectl = SDL_realloc(pVOData->pRectl, cRects * sizeof(RECTL));
|
||||
if (pRectl == NULL)
|
||||
return NULL;
|
||||
|
||||
pVOData->pRectl = pRectl;
|
||||
pVOData->cRectl = cRects;
|
||||
return pRectl;
|
||||
pVOData->pRectl = pRectl;
|
||||
pVOData->cRectl = cRects;
|
||||
return pRectl;
|
||||
}
|
||||
|
||||
static PBLTRECT _getBltRectArray(PVODATA pVOData, ULONG cRects)
|
||||
{
|
||||
PBLTRECT pBltRect;
|
||||
PBLTRECT pBltRect;
|
||||
|
||||
if ( pVOData->cBltRect >= cRects )
|
||||
return pVOData->pBltRect;
|
||||
if (pVOData->cBltRect >= cRects)
|
||||
return pVOData->pBltRect;
|
||||
|
||||
pBltRect = SDL_realloc( pVOData->pBltRect, cRects * sizeof(BLTRECT) );
|
||||
if ( pBltRect == NULL )
|
||||
return NULL;
|
||||
pBltRect = SDL_realloc(pVOData->pBltRect, cRects * sizeof(BLTRECT));
|
||||
if (pBltRect == NULL)
|
||||
return NULL;
|
||||
|
||||
pVOData->pBltRect = pBltRect;
|
||||
pVOData->cBltRect = cRects;
|
||||
return pBltRect;
|
||||
pVOData->pBltRect = pBltRect;
|
||||
pVOData->cBltRect = cRects;
|
||||
return pBltRect;
|
||||
}
|
||||
|
||||
|
||||
static BOOL voQueryInfo(PVIDEOOUTPUTINFO pInfo)
|
||||
static BOOL voQueryInfo(VIDEOOUTPUTINFO *pInfo)
|
||||
{
|
||||
ULONG ulRC;
|
||||
GDDMODEINFO sCurModeInfo;
|
||||
ULONG ulRC;
|
||||
GDDMODEINFO sCurModeInfo;
|
||||
|
||||
if ( !_vmanInit() )
|
||||
return FALSE;
|
||||
if (!_vmanInit())
|
||||
return FALSE;
|
||||
|
||||
// Query current (desktop) mode.
|
||||
ulRC = pfnVMIEntry( 0, VMI_CMD_QUERYCURRENTMODE, NULL, &sCurModeInfo );
|
||||
if ( ulRC != RC_SUCCESS )
|
||||
{
|
||||
debug( "Could not query desktop video mode." );
|
||||
return FALSE;
|
||||
}
|
||||
/* Query current (desktop) mode */
|
||||
ulRC = pfnVMIEntry(0, VMI_CMD_QUERYCURRENTMODE, NULL, &sCurModeInfo);
|
||||
if (ulRC != RC_SUCCESS) {
|
||||
debug_os2("Could not query desktop video mode.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pInfo->ulBPP = sCurModeInfo.ulBpp;
|
||||
pInfo->ulHorizResolution = sCurModeInfo.ulHorizResolution;
|
||||
pInfo->ulVertResolution = sCurModeInfo.ulVertResolution;
|
||||
pInfo->ulScanLineSize = sCurModeInfo.ulScanLineSize;
|
||||
pInfo->fccColorEncoding = sCurModeInfo.fccColorEncoding;
|
||||
pInfo->ulBPP = sCurModeInfo.ulBpp;
|
||||
pInfo->ulHorizResolution = sCurModeInfo.ulHorizResolution;
|
||||
pInfo->ulVertResolution = sCurModeInfo.ulVertResolution;
|
||||
pInfo->ulScanLineSize = sCurModeInfo.ulScanLineSize;
|
||||
pInfo->fccColorEncoding = sCurModeInfo.fccColorEncoding;
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static PVODATA voOpen()
|
||||
static PVODATA voOpen(void)
|
||||
{
|
||||
PVODATA pVOData;
|
||||
PVODATA pVOData;
|
||||
|
||||
if ( !_vmanInit() )
|
||||
return NULL;
|
||||
if (!_vmanInit())
|
||||
return NULL;
|
||||
|
||||
pVOData = SDL_calloc( 1, sizeof(VODATA) );
|
||||
if ( pVOData == NULL )
|
||||
{
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
pVOData = SDL_calloc(1, sizeof(VODATA));
|
||||
if (pVOData == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pVOData;
|
||||
return pVOData;
|
||||
}
|
||||
|
||||
static VOID voClose(PVODATA pVOData)
|
||||
{
|
||||
if ( pVOData->pRectl != NULL )
|
||||
SDL_free( pVOData->pRectl );
|
||||
if (pVOData->pRectl != NULL)
|
||||
SDL_free(pVOData->pRectl);
|
||||
|
||||
if ( pVOData->pBltRect != NULL )
|
||||
SDL_free( pVOData->pBltRect );
|
||||
if (pVOData->pBltRect != NULL)
|
||||
SDL_free(pVOData->pBltRect);
|
||||
|
||||
voVideoBufFree( pVOData );
|
||||
voVideoBufFree(pVOData);
|
||||
}
|
||||
|
||||
static BOOL voSetVisibleRegion(PVODATA pVOData, HWND hwnd,
|
||||
SDL_DisplayMode *pSDLDisplayMode,
|
||||
HRGN hrgnShape, BOOL fVisible)
|
||||
{
|
||||
HPS hps;
|
||||
BOOL fSuccess = FALSE;
|
||||
HPS hps;
|
||||
BOOL fSuccess = FALSE;
|
||||
|
||||
hps = WinGetPS( hwnd );
|
||||
hps = WinGetPS(hwnd);
|
||||
|
||||
if ( pVOData->hrgnVisible != NULLHANDLE )
|
||||
{
|
||||
GpiDestroyRegion( hps, pVOData->hrgnVisible );
|
||||
pVOData->hrgnVisible = NULLHANDLE;
|
||||
}
|
||||
|
||||
if ( fVisible )
|
||||
{
|
||||
// Query visible rectangles
|
||||
|
||||
pVOData->hrgnVisible = GpiCreateRegion( hps, 0, NULL );
|
||||
if ( pVOData->hrgnVisible == NULLHANDLE )
|
||||
{
|
||||
SDL_SetError( "GpiCreateRegion() failed" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( WinQueryVisibleRegion( hwnd, pVOData->hrgnVisible ) == RGN_ERROR )
|
||||
{
|
||||
GpiDestroyRegion( hps, pVOData->hrgnVisible );
|
||||
if (pVOData->hrgnVisible != NULLHANDLE) {
|
||||
GpiDestroyRegion(hps, pVOData->hrgnVisible);
|
||||
pVOData->hrgnVisible = NULLHANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( hrgnShape != NULLHANDLE )
|
||||
GpiCombineRegion( hps, pVOData->hrgnVisible, pVOData->hrgnVisible,
|
||||
hrgnShape, CRGN_AND );
|
||||
fSuccess = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
WinQueryWindowRect( hwnd, &pVOData->rectlWin );
|
||||
WinMapWindowPoints( hwnd, HWND_DESKTOP, (PPOINTL)&pVOData->rectlWin, 2 );
|
||||
if (fVisible) {
|
||||
/* Query visible rectangles */
|
||||
pVOData->hrgnVisible = GpiCreateRegion(hps, 0, NULL);
|
||||
if (pVOData->hrgnVisible == NULLHANDLE) {
|
||||
SDL_SetError("GpiCreateRegion() failed");
|
||||
} else {
|
||||
if (WinQueryVisibleRegion(hwnd, pVOData->hrgnVisible) == RGN_ERROR) {
|
||||
GpiDestroyRegion(hps, pVOData->hrgnVisible);
|
||||
pVOData->hrgnVisible = NULLHANDLE;
|
||||
} else {
|
||||
if (hrgnShape != NULLHANDLE)
|
||||
GpiCombineRegion(hps, pVOData->hrgnVisible, pVOData->hrgnVisible,
|
||||
hrgnShape, CRGN_AND);
|
||||
fSuccess = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( pSDLDisplayMode != NULL )
|
||||
{
|
||||
pVOData->ulScreenHeight = pSDLDisplayMode->h;
|
||||
pVOData->ulScreenBytesPerLine =
|
||||
((PMODEDATA)pSDLDisplayMode->driverdata)->ulScanLineBytes;
|
||||
WinQueryWindowRect(hwnd, &pVOData->rectlWin);
|
||||
WinMapWindowPoints(hwnd, HWND_DESKTOP, (PPOINTL)&pVOData->rectlWin, 2);
|
||||
|
||||
if (pSDLDisplayMode != NULL) {
|
||||
pVOData->ulScreenHeight = pSDLDisplayMode->h;
|
||||
pVOData->ulScreenBytesPerLine =
|
||||
((MODEDATA *)pSDLDisplayMode->driverdata)->ulScanLineBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WinReleasePS( hps );
|
||||
WinReleasePS(hps);
|
||||
|
||||
return fSuccess;
|
||||
return fSuccess;
|
||||
}
|
||||
|
||||
static PVOID voVideoBufAlloc(PVODATA pVOData, ULONG ulWidth, ULONG ulHeight,
|
||||
ULONG ulBPP, ULONG fccColorEncoding,
|
||||
PULONG pulScanLineSize)
|
||||
{
|
||||
ULONG ulRC;
|
||||
ULONG ulScanLineSize = ulWidth * (ulBPP >> 3);
|
||||
ULONG ulRC;
|
||||
ULONG ulScanLineSize = ulWidth * (ulBPP >> 3);
|
||||
|
||||
// Destroy previous buffer.
|
||||
voVideoBufFree( pVOData );
|
||||
/* Destroy previous buffer */
|
||||
voVideoBufFree(pVOData);
|
||||
|
||||
if ( ( ulWidth == 0 ) || ( ulHeight == 0 ) || ( ulBPP == 0 ) )
|
||||
return NULL;
|
||||
if (ulWidth == 0 || ulHeight == 0 || ulBPP == 0)
|
||||
return NULL;
|
||||
|
||||
// Bytes per line.
|
||||
ulScanLineSize = ( ulScanLineSize + 3 ) & ~3; /* 4-byte aligning */
|
||||
*pulScanLineSize = ulScanLineSize;
|
||||
/* Bytes per line */
|
||||
ulScanLineSize = (ulScanLineSize + 3) & ~3; /* 4-byte aligning */
|
||||
*pulScanLineSize = ulScanLineSize;
|
||||
|
||||
ulRC = DosAllocMem( &pVOData->pBuffer,
|
||||
(ulHeight * ulScanLineSize) + sizeof(ULONG),
|
||||
PAG_COMMIT | PAG_EXECUTE | PAG_READ | PAG_WRITE );
|
||||
if ( ulRC != NO_ERROR )
|
||||
{
|
||||
debug( "DosAllocMem(), rc = %u", ulRC );
|
||||
return NULL;
|
||||
}
|
||||
ulRC = DosAllocMem(&pVOData->pBuffer,
|
||||
(ulHeight * ulScanLineSize) + sizeof(ULONG),
|
||||
PAG_COMMIT | PAG_EXECUTE | PAG_READ | PAG_WRITE);
|
||||
if (ulRC != NO_ERROR) {
|
||||
debug_os2("DosAllocMem(), rc = %u", ulRC);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pVOData->ulBPP = ulBPP;
|
||||
pVOData->ulScanLineSize = ulScanLineSize;
|
||||
pVOData->ulWidth = ulWidth;
|
||||
pVOData->ulHeight = ulHeight;
|
||||
pVOData->ulBPP = ulBPP;
|
||||
pVOData->ulScanLineSize = ulScanLineSize;
|
||||
pVOData->ulWidth = ulWidth;
|
||||
pVOData->ulHeight = ulHeight;
|
||||
|
||||
return pVOData->pBuffer;
|
||||
return pVOData->pBuffer;
|
||||
}
|
||||
|
||||
static VOID voVideoBufFree(PVODATA pVOData)
|
||||
{
|
||||
ULONG ulRC;
|
||||
ULONG ulRC;
|
||||
|
||||
if ( pVOData->pBuffer == NULL )
|
||||
return;
|
||||
if (pVOData->pBuffer == NULL)
|
||||
return;
|
||||
|
||||
ulRC = DosFreeMem( pVOData->pBuffer );
|
||||
if ( ulRC != NO_ERROR )
|
||||
debug( "DosFreeMem(), rc = %u", ulRC );
|
||||
else
|
||||
pVOData->pBuffer = NULL;
|
||||
ulRC = DosFreeMem(pVOData->pBuffer);
|
||||
if (ulRC != NO_ERROR) {
|
||||
debug_os2("DosFreeMem(), rc = %u", ulRC);
|
||||
} else {
|
||||
pVOData->pBuffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects,
|
||||
ULONG cSDLRects)
|
||||
{
|
||||
PRECTL prectlDst, prectlScan;
|
||||
HPS hps;
|
||||
HRGN hrgnUpdate;
|
||||
RGNRECT rgnCtl;
|
||||
SDL_Rect stSDLRectDef;
|
||||
BMAPINFO bmiSrc;
|
||||
BMAPINFO bmiDst;
|
||||
PPOINTL pptlSrcOrg;
|
||||
PBLTRECT pbrDst;
|
||||
HWREQIN sHWReqIn;
|
||||
BITBLTINFO sBitbltInfo = { 0 };
|
||||
ULONG ulIdx;
|
||||
// RECTL rectlScreenUpdate;
|
||||
PRECTL prectlDst, prectlScan;
|
||||
HPS hps;
|
||||
HRGN hrgnUpdate;
|
||||
RGNRECT rgnCtl;
|
||||
SDL_Rect stSDLRectDef;
|
||||
BMAPINFO bmiSrc;
|
||||
BMAPINFO bmiDst;
|
||||
PPOINTL pptlSrcOrg;
|
||||
PBLTRECT pbrDst;
|
||||
HWREQIN sHWReqIn;
|
||||
BITBLTINFO sBitbltInfo = { 0 };
|
||||
ULONG ulIdx;
|
||||
/* RECTL rectlScreenUpdate;*/
|
||||
|
||||
if ( pVOData->pBuffer == NULL )
|
||||
return FALSE;
|
||||
if (pVOData->pBuffer == NULL)
|
||||
return FALSE;
|
||||
|
||||
if ( pVOData->hrgnVisible == NULLHANDLE )
|
||||
return TRUE;
|
||||
if (pVOData->hrgnVisible == NULLHANDLE)
|
||||
return TRUE;
|
||||
|
||||
bmiSrc.ulLength = sizeof(BMAPINFO);
|
||||
bmiSrc.ulType = BMAP_MEMORY;
|
||||
bmiSrc.ulWidth = pVOData->ulWidth;
|
||||
bmiSrc.ulHeight = pVOData->ulHeight;
|
||||
bmiSrc.ulBpp = pVOData->ulBPP;
|
||||
bmiSrc.ulBytesPerLine = pVOData->ulScanLineSize;
|
||||
bmiSrc.pBits = (PBYTE)pVOData->pBuffer;
|
||||
bmiSrc.ulLength = sizeof(BMAPINFO);
|
||||
bmiSrc.ulType = BMAP_MEMORY;
|
||||
bmiSrc.ulWidth = pVOData->ulWidth;
|
||||
bmiSrc.ulHeight = pVOData->ulHeight;
|
||||
bmiSrc.ulBpp = pVOData->ulBPP;
|
||||
bmiSrc.ulBytesPerLine = pVOData->ulScanLineSize;
|
||||
bmiSrc.pBits = (PBYTE)pVOData->pBuffer;
|
||||
|
||||
bmiDst.ulLength = sizeof(BMAPINFO);
|
||||
bmiDst.ulType = BMAP_VRAM;
|
||||
bmiDst.pBits = (PBYTE)ulVRAMAddress;
|
||||
bmiDst.ulWidth = bmiSrc.ulWidth;
|
||||
bmiDst.ulHeight = bmiSrc.ulHeight;
|
||||
bmiDst.ulBpp = bmiSrc.ulBpp;
|
||||
bmiDst.ulBytesPerLine = pVOData->ulScreenBytesPerLine;
|
||||
bmiDst.ulLength = sizeof(BMAPINFO);
|
||||
bmiDst.ulType = BMAP_VRAM;
|
||||
bmiDst.pBits = (PBYTE)ulVRAMAddress;
|
||||
bmiDst.ulWidth = bmiSrc.ulWidth;
|
||||
bmiDst.ulHeight = bmiSrc.ulHeight;
|
||||
bmiDst.ulBpp = bmiSrc.ulBpp;
|
||||
bmiDst.ulBytesPerLine = pVOData->ulScreenBytesPerLine;
|
||||
|
||||
// List of update rectangles. This is the intersection of requested
|
||||
// rectangles and visible rectangles.
|
||||
|
||||
if ( cSDLRects == 0 )
|
||||
{
|
||||
// Full update requested.
|
||||
stSDLRectDef.x = 0;
|
||||
stSDLRectDef.y = 0;
|
||||
stSDLRectDef.w = bmiSrc.ulWidth;
|
||||
stSDLRectDef.h = bmiSrc.ulHeight;
|
||||
pSDLRects = &stSDLRectDef;
|
||||
cSDLRects = 1;
|
||||
}
|
||||
|
||||
// Make list of destionation rectangles (prectlDst) list from the source
|
||||
// list (prectl).
|
||||
prectlDst = _getRectlArray( pVOData, cSDLRects );
|
||||
if ( prectlDst == NULL )
|
||||
{
|
||||
debug( "Not enough memory" );
|
||||
return FALSE;
|
||||
}
|
||||
prectlScan = prectlDst;
|
||||
for( ulIdx = 0; ulIdx < cSDLRects; ulIdx++, pSDLRects++, prectlScan++ )
|
||||
{
|
||||
prectlScan->xLeft = pSDLRects->x;
|
||||
prectlScan->yTop = pVOData->ulHeight - pSDLRects->y;
|
||||
prectlScan->xRight = prectlScan->xLeft + pSDLRects->w;
|
||||
prectlScan->yBottom = prectlScan->yTop - pSDLRects->h;
|
||||
}
|
||||
|
||||
hps = WinGetPS( hwnd );
|
||||
if ( hps == NULLHANDLE )
|
||||
return FALSE;
|
||||
|
||||
// Make destination region to update.
|
||||
hrgnUpdate = GpiCreateRegion( hps, cSDLRects, prectlDst );
|
||||
// "AND" on visible and destination regions, result is region to update.
|
||||
GpiCombineRegion( hps, hrgnUpdate, hrgnUpdate, pVOData->hrgnVisible,
|
||||
CRGN_AND );
|
||||
|
||||
// Get rectangles of the region to update.
|
||||
rgnCtl.ircStart = 1;
|
||||
rgnCtl.crc = 0;
|
||||
rgnCtl.ulDirection = 1;
|
||||
rgnCtl.crcReturned = 0;
|
||||
GpiQueryRegionRects( hps, hrgnUpdate, NULL, &rgnCtl, NULL );
|
||||
if ( rgnCtl.crcReturned == 0 )
|
||||
{
|
||||
GpiDestroyRegion( hps, hrgnUpdate );
|
||||
WinReleasePS( hps );
|
||||
return TRUE;
|
||||
}
|
||||
// We don't need prectlDst, use it again to store update regions.
|
||||
prectlDst = _getRectlArray( pVOData, rgnCtl.crcReturned );
|
||||
if ( prectlDst == NULL )
|
||||
{
|
||||
debug( "Not enough memory" );
|
||||
GpiDestroyRegion( hps, hrgnUpdate );
|
||||
WinReleasePS( hps );
|
||||
return FALSE;
|
||||
}
|
||||
rgnCtl.ircStart = 1;
|
||||
rgnCtl.crc = rgnCtl.crcReturned;
|
||||
rgnCtl.ulDirection = 1;
|
||||
GpiQueryRegionRects( hps, hrgnUpdate, NULL, &rgnCtl, prectlDst );
|
||||
GpiDestroyRegion( hps, hrgnUpdate );
|
||||
WinReleasePS( hps );
|
||||
cSDLRects = rgnCtl.crcReturned;
|
||||
// Now cRect/prectlDst is a list of regions in window (update && visible).
|
||||
|
||||
// Make lists for blitting from update regions.
|
||||
|
||||
pbrDst = _getBltRectArray( pVOData, cSDLRects );
|
||||
if ( pbrDst == NULL )
|
||||
{
|
||||
debug( "Not enough memory" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prectlScan = prectlDst;
|
||||
pptlSrcOrg = (PPOINTL)prectlDst; // Yes, this memory block will be used again.
|
||||
for( ulIdx = 0; ulIdx < cSDLRects; ulIdx++, prectlScan++, pptlSrcOrg++ )
|
||||
{
|
||||
pbrDst[ulIdx].ulXOrg = pVOData->rectlWin.xLeft + prectlScan->xLeft;
|
||||
pbrDst[ulIdx].ulYOrg = pVOData->ulScreenHeight -
|
||||
( pVOData->rectlWin.yBottom + prectlScan->yTop );
|
||||
pbrDst[ulIdx].ulXExt = prectlScan->xRight - prectlScan->xLeft;
|
||||
pbrDst[ulIdx].ulYExt = prectlScan->yTop - prectlScan->yBottom;
|
||||
pptlSrcOrg->x = prectlScan->xLeft;
|
||||
pptlSrcOrg->y = bmiSrc.ulHeight - prectlScan->yTop;
|
||||
}
|
||||
pptlSrcOrg = (PPOINTL)prectlDst;
|
||||
|
||||
// Request HW
|
||||
sHWReqIn.ulLength = sizeof(HWREQIN);
|
||||
sHWReqIn.ulFlags = REQUEST_HW;
|
||||
sHWReqIn.cScrChangeRects = 1;
|
||||
sHWReqIn.arectlScreen = &pVOData->rectlWin;
|
||||
if ( pfnVMIEntry( 0, VMI_CMD_REQUESTHW, &sHWReqIn, NULL ) != RC_SUCCESS )
|
||||
{
|
||||
debug( "pfnVMIEntry(,VMI_CMD_REQUESTHW,,) failed" );
|
||||
sHWReqIn.cScrChangeRects = 0; // for fail signal only.
|
||||
}
|
||||
else
|
||||
{
|
||||
RECTL rclSrcBounds;
|
||||
|
||||
rclSrcBounds.xLeft = 0;
|
||||
rclSrcBounds.yBottom = 0;
|
||||
rclSrcBounds.xRight = bmiSrc.ulWidth;
|
||||
rclSrcBounds.yTop = bmiSrc.ulHeight;
|
||||
|
||||
sBitbltInfo.ulLength = sizeof(BITBLTINFO);
|
||||
sBitbltInfo.ulBltFlags = BF_DEFAULT_STATE | BF_ROP_INCL_SRC | BF_PAT_HOLLOW;
|
||||
sBitbltInfo.cBlits = cSDLRects;
|
||||
sBitbltInfo.ulROP = ROP_SRCCOPY;
|
||||
sBitbltInfo.pSrcBmapInfo = &bmiSrc;
|
||||
sBitbltInfo.pDstBmapInfo = &bmiDst;
|
||||
sBitbltInfo.prclSrcBounds = &rclSrcBounds;
|
||||
sBitbltInfo.prclDstBounds = &pVOData->rectlWin;
|
||||
sBitbltInfo.aptlSrcOrg = pptlSrcOrg;
|
||||
sBitbltInfo.abrDst = pbrDst;
|
||||
|
||||
// Screen update.
|
||||
if ( pfnVMIEntry( 0, VMI_CMD_BITBLT, &sBitbltInfo, NULL ) != RC_SUCCESS )
|
||||
{
|
||||
debug( "pfnVMIEntry(,VMI_CMD_BITBLT,,) failed" );
|
||||
sHWReqIn.cScrChangeRects = 0; // for fail signal only.
|
||||
/* List of update rectangles. This is the intersection of requested
|
||||
* rectangles and visible rectangles. */
|
||||
if (cSDLRects == 0) {
|
||||
/* Full update requested */
|
||||
stSDLRectDef.x = 0;
|
||||
stSDLRectDef.y = 0;
|
||||
stSDLRectDef.w = bmiSrc.ulWidth;
|
||||
stSDLRectDef.h = bmiSrc.ulHeight;
|
||||
pSDLRects = &stSDLRectDef;
|
||||
cSDLRects = 1;
|
||||
}
|
||||
|
||||
// Release HW.
|
||||
sHWReqIn.ulFlags = 0;
|
||||
if ( pfnVMIEntry( 0, VMI_CMD_REQUESTHW, &sHWReqIn, NULL ) != RC_SUCCESS )
|
||||
debug( "pfnVMIEntry(,VMI_CMD_REQUESTHW,,) failed" );
|
||||
}
|
||||
/* Make list of destination rectangles (prectlDst) list from the source
|
||||
* list (prectl). */
|
||||
prectlDst = _getRectlArray(pVOData, cSDLRects);
|
||||
if (prectlDst == NULL) {
|
||||
debug_os2("Not enough memory");
|
||||
return FALSE;
|
||||
}
|
||||
prectlScan = prectlDst;
|
||||
for (ulIdx = 0; ulIdx < cSDLRects; ulIdx++, pSDLRects++, prectlScan++) {
|
||||
prectlScan->xLeft = pSDLRects->x;
|
||||
prectlScan->yTop = pVOData->ulHeight - pSDLRects->y;
|
||||
prectlScan->xRight = prectlScan->xLeft + pSDLRects->w;
|
||||
prectlScan->yBottom = prectlScan->yTop - pSDLRects->h;
|
||||
}
|
||||
|
||||
return sHWReqIn.cScrChangeRects != 0;
|
||||
hps = WinGetPS(hwnd);
|
||||
if (hps == NULLHANDLE)
|
||||
return FALSE;
|
||||
|
||||
/* Make destination region to update */
|
||||
hrgnUpdate = GpiCreateRegion(hps, cSDLRects, prectlDst);
|
||||
/* "AND" on visible and destination regions, result is region to update */
|
||||
GpiCombineRegion(hps, hrgnUpdate, hrgnUpdate, pVOData->hrgnVisible, CRGN_AND);
|
||||
|
||||
/* Get rectangles of the region to update */
|
||||
rgnCtl.ircStart = 1;
|
||||
rgnCtl.crc = 0;
|
||||
rgnCtl.ulDirection = 1;
|
||||
rgnCtl.crcReturned = 0;
|
||||
GpiQueryRegionRects(hps, hrgnUpdate, NULL, &rgnCtl, NULL);
|
||||
if (rgnCtl.crcReturned == 0) {
|
||||
GpiDestroyRegion(hps, hrgnUpdate);
|
||||
WinReleasePS(hps);
|
||||
return TRUE;
|
||||
}
|
||||
/* We don't need prectlDst, use it again to store update regions */
|
||||
prectlDst = _getRectlArray(pVOData, rgnCtl.crcReturned);
|
||||
if (prectlDst == NULL) {
|
||||
debug_os2("Not enough memory");
|
||||
GpiDestroyRegion(hps, hrgnUpdate);
|
||||
WinReleasePS(hps);
|
||||
return FALSE;
|
||||
}
|
||||
rgnCtl.ircStart = 1;
|
||||
rgnCtl.crc = rgnCtl.crcReturned;
|
||||
rgnCtl.ulDirection = 1;
|
||||
GpiQueryRegionRects(hps, hrgnUpdate, NULL, &rgnCtl, prectlDst);
|
||||
GpiDestroyRegion(hps, hrgnUpdate);
|
||||
WinReleasePS(hps);
|
||||
cSDLRects = rgnCtl.crcReturned;
|
||||
|
||||
/* Now cRect/prectlDst is a list of regions in window (update && visible) */
|
||||
|
||||
/* Make lists for blitting from update regions */
|
||||
pbrDst = _getBltRectArray(pVOData, cSDLRects);
|
||||
if (pbrDst == NULL) {
|
||||
debug_os2("Not enough memory");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
prectlScan = prectlDst;
|
||||
pptlSrcOrg = (PPOINTL)prectlDst; /* Yes, this memory block will be used again */
|
||||
for (ulIdx = 0; ulIdx < cSDLRects; ulIdx++, prectlScan++, pptlSrcOrg++) {
|
||||
pbrDst[ulIdx].ulXOrg = pVOData->rectlWin.xLeft + prectlScan->xLeft;
|
||||
pbrDst[ulIdx].ulYOrg = pVOData->ulScreenHeight -
|
||||
(pVOData->rectlWin.yBottom + prectlScan->yTop);
|
||||
pbrDst[ulIdx].ulXExt = prectlScan->xRight - prectlScan->xLeft;
|
||||
pbrDst[ulIdx].ulYExt = prectlScan->yTop - prectlScan->yBottom;
|
||||
pptlSrcOrg->x = prectlScan->xLeft;
|
||||
pptlSrcOrg->y = bmiSrc.ulHeight - prectlScan->yTop;
|
||||
}
|
||||
pptlSrcOrg = (PPOINTL)prectlDst;
|
||||
|
||||
/* Request HW */
|
||||
sHWReqIn.ulLength = sizeof(HWREQIN);
|
||||
sHWReqIn.ulFlags = REQUEST_HW;
|
||||
sHWReqIn.cScrChangeRects = 1;
|
||||
sHWReqIn.arectlScreen = &pVOData->rectlWin;
|
||||
if (pfnVMIEntry(0, VMI_CMD_REQUESTHW, &sHWReqIn, NULL) != RC_SUCCESS) {
|
||||
debug_os2("pfnVMIEntry(,VMI_CMD_REQUESTHW,,) failed");
|
||||
sHWReqIn.cScrChangeRects = 0; /* for fail signal only */
|
||||
} else {
|
||||
RECTL rclSrcBounds;
|
||||
|
||||
rclSrcBounds.xLeft = 0;
|
||||
rclSrcBounds.yBottom = 0;
|
||||
rclSrcBounds.xRight = bmiSrc.ulWidth;
|
||||
rclSrcBounds.yTop = bmiSrc.ulHeight;
|
||||
|
||||
sBitbltInfo.ulLength = sizeof(BITBLTINFO);
|
||||
sBitbltInfo.ulBltFlags = BF_DEFAULT_STATE | BF_ROP_INCL_SRC | BF_PAT_HOLLOW;
|
||||
sBitbltInfo.cBlits = cSDLRects;
|
||||
sBitbltInfo.ulROP = ROP_SRCCOPY;
|
||||
sBitbltInfo.pSrcBmapInfo = &bmiSrc;
|
||||
sBitbltInfo.pDstBmapInfo = &bmiDst;
|
||||
sBitbltInfo.prclSrcBounds = &rclSrcBounds;
|
||||
sBitbltInfo.prclDstBounds = &pVOData->rectlWin;
|
||||
sBitbltInfo.aptlSrcOrg = pptlSrcOrg;
|
||||
sBitbltInfo.abrDst = pbrDst;
|
||||
|
||||
/* Screen update */
|
||||
if (pfnVMIEntry(0, VMI_CMD_BITBLT, &sBitbltInfo, NULL) != RC_SUCCESS) {
|
||||
debug_os2("pfnVMIEntry(,VMI_CMD_BITBLT,,) failed");
|
||||
sHWReqIn.cScrChangeRects = 0; /* for fail signal only */
|
||||
}
|
||||
|
||||
/* Release HW */
|
||||
sHWReqIn.ulFlags = 0;
|
||||
if (pfnVMIEntry(0, VMI_CMD_REQUESTHW, &sHWReqIn, NULL) != RC_SUCCESS) {
|
||||
debug_os2("pfnVMIEntry(,VMI_CMD_REQUESTHW,,) failed");
|
||||
}
|
||||
}
|
||||
|
||||
return sHWReqIn.cScrChangeRects != 0;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user