improved copyImage function
split up copyImage to cpyImg16 and cpyImg32 unified D3D & DDraw copyImage behavior no pitch hacks for 16 bit necessary anymore git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@202 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
f8ed7b0b9a
commit
6ba79876a2
|
@ -353,25 +353,43 @@ void Direct3DDisplay::render()
|
||||||
DXTRACE_ERR_MSGBOX( _T("Can not lock texture"), hr );
|
DXTRACE_ERR_MSGBOX( _T("Can not lock texture"), hr );
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if( !theApp.filterFunction ) {
|
unsigned short pitch = theApp.sizeX * ( systemColorDepth >> 3 ) + 4;
|
||||||
copyImage(
|
if( theApp.filterFunction ) {
|
||||||
pix,
|
// pixel filter enabled
|
||||||
lr.pBits,
|
theApp.filterFunction(
|
||||||
(systemColorDepth == 32) ? theApp.sizeX
|
pix + pitch,
|
||||||
: theApp.sizeX + 1, // TODO: workaround results in one pixel black border at right side
|
|
||||||
theApp.sizeY,
|
|
||||||
lr.Pitch,
|
|
||||||
systemColorDepth
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
u32 pitch = theApp.filterWidth * (systemColorDepth>>3) + 4;
|
|
||||||
theApp.filterFunction( pix + pitch,
|
|
||||||
pitch,
|
pitch,
|
||||||
(u8*)theApp.delta,
|
(u8*)theApp.delta,
|
||||||
(u8*)lr.pBits,
|
(u8*)lr.pBits,
|
||||||
lr.Pitch,
|
lr.Pitch,
|
||||||
theApp.filterWidth,
|
theApp.sizeX,
|
||||||
theApp.filterHeight);
|
theApp.sizeY
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// pixel filter disabled
|
||||||
|
switch( systemColorDepth )
|
||||||
|
{
|
||||||
|
case 32:
|
||||||
|
cpyImg32(
|
||||||
|
(unsigned char *)lr.pBits,
|
||||||
|
lr.Pitch,
|
||||||
|
pix + pitch,
|
||||||
|
pitch,
|
||||||
|
theApp.sizeX,
|
||||||
|
theApp.sizeY
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
cpyImg16(
|
||||||
|
(unsigned char *)lr.pBits,
|
||||||
|
lr.Pitch,
|
||||||
|
pix + pitch,
|
||||||
|
pitch,
|
||||||
|
theApp.sizeX,
|
||||||
|
theApp.sizeY
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
emulatedImage->UnlockRect( 0 );
|
emulatedImage->UnlockRect( 0 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -569,7 +569,7 @@ void DirectDrawDisplay::render()
|
||||||
if(hret == DD_OK) {
|
if(hret == DD_OK) {
|
||||||
hret = ddsOffscreen->Restore();
|
hret = ddsOffscreen->Restore();
|
||||||
|
|
||||||
if(hret == DD_OK) {
|
if(hret == DD_OK) {
|
||||||
hret = ddsOffscreen->Lock(NULL,
|
hret = ddsOffscreen->Lock(NULL,
|
||||||
&ddsDesc,
|
&ddsDesc,
|
||||||
DDLOCK_WRITEONLY|
|
DDLOCK_WRITEONLY|
|
||||||
|
@ -580,46 +580,49 @@ void DirectDrawDisplay::render()
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hret == DD_OK) {
|
if(hret == DD_OK) {
|
||||||
if(theApp.filterFunction) {
|
unsigned short pitch = theApp.sizeX * ( systemColorDepth >> 3 ) + 4;
|
||||||
if(systemColorDepth == 16)
|
if( theApp.filterFunction ) {
|
||||||
(*theApp.filterFunction)(pix+theApp.filterWidth*2+4,
|
// pixel filter enabled
|
||||||
theApp.filterWidth*2+4,
|
theApp.filterFunction(
|
||||||
(u8*)theApp.delta,
|
pix + pitch,
|
||||||
(u8*)ddsDesc.lpSurface,
|
pitch,
|
||||||
ddsDesc.lPitch,
|
(u8*)theApp.delta,
|
||||||
theApp.filterWidth,
|
(u8*)ddsDesc.lpSurface,
|
||||||
theApp.filterHeight);
|
ddsDesc.lPitch,
|
||||||
else
|
theApp.sizeX,
|
||||||
(*theApp.filterFunction)(pix+theApp.filterWidth*4+4,
|
theApp.sizeY
|
||||||
theApp.filterWidth*4+4,
|
);
|
||||||
(u8*)theApp.delta,
|
} else {
|
||||||
(u8*)ddsDesc.lpSurface,
|
// pixel filter disabled
|
||||||
ddsDesc.lPitch,
|
switch( systemColorDepth )
|
||||||
theApp.filterWidth,
|
{
|
||||||
theApp.filterHeight);
|
case 32:
|
||||||
|
cpyImg32(
|
||||||
} else {
|
(unsigned char *)ddsDesc.lpSurface,
|
||||||
int copyX = 240;
|
ddsDesc.lPitch,
|
||||||
int copyY = 160;
|
pix + pitch,
|
||||||
|
pitch,
|
||||||
if(theApp.cartridgeType == 1) {
|
theApp.sizeX,
|
||||||
if(gbBorderOn) {
|
theApp.sizeY
|
||||||
copyX = 256;
|
);
|
||||||
copyY = 224;
|
break;
|
||||||
} else {
|
case 16:
|
||||||
copyX = 160;
|
cpyImg16(
|
||||||
copyY = 144;
|
(unsigned char *)ddsDesc.lpSurface,
|
||||||
}
|
ddsDesc.lPitch,
|
||||||
}
|
pix + pitch,
|
||||||
if( systemColorDepth == 16 ) {
|
pitch,
|
||||||
copyX++; // TODO: workaround results in one pixel black border at right side
|
theApp.sizeX,
|
||||||
|
theApp.sizeY
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
copyImage( pix, ddsDesc.lpSurface, copyX, copyY, ddsDesc.lPitch, systemColorDepth );
|
|
||||||
}
|
|
||||||
if(theApp.showSpeed && (theApp.videoOption > VIDEO_4X || theApp.skin != NULL)) {
|
if(theApp.showSpeed && (theApp.videoOption > VIDEO_4X || theApp.skin != NULL)) {
|
||||||
char buffer[30];
|
char buffer[30];
|
||||||
if(theApp.showSpeed == 1)
|
if(theApp.showSpeed == 1)
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory.h>
|
||||||
|
|
||||||
enum DISPLAY_TYPE {
|
enum DISPLAY_TYPE {
|
||||||
DIRECT_DRAW = 0,
|
DIRECT_DRAW = 0,
|
||||||
DIRECT_3D = 1,
|
DIRECT_3D = 1,
|
||||||
|
@ -43,46 +45,27 @@ class IDisplay {
|
||||||
virtual int selectFullScreenMode(GUID **) = 0;
|
virtual int selectFullScreenMode(GUID **) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void copyImage( void *source, void *destination, unsigned int width, unsigned int height, unsigned int destinationPitch, unsigned int colorDepth )
|
inline void cpyImg32( unsigned char *dst, unsigned int dstPitch, unsigned char *src, unsigned int srcPitch, unsigned short width, unsigned short height )
|
||||||
{
|
{
|
||||||
// fast, iterative C version
|
// fast, iterative C version
|
||||||
register unsigned int lineSize;
|
// copies an width*height array of visible pixels from src to dst
|
||||||
register unsigned char *src, *dst;
|
// srcPitch and dstPitch are the number of garbage bytes after a scanline
|
||||||
switch(colorDepth)
|
register unsigned short lineSize = width<<2;
|
||||||
{
|
|
||||||
case 16:
|
|
||||||
lineSize = width<<1;
|
|
||||||
src = ((unsigned char*)source) + lineSize + 4;
|
|
||||||
dst = (unsigned char*)destination;
|
|
||||||
do {
|
|
||||||
MoveMemory( dst, src, lineSize );
|
|
||||||
src+=lineSize;
|
|
||||||
dst+=lineSize;
|
|
||||||
src += 2;
|
|
||||||
dst += (destinationPitch - lineSize);
|
|
||||||
} while ( --height);
|
|
||||||
break;
|
|
||||||
case 32:
|
|
||||||
lineSize = width<<2;
|
|
||||||
src = ((unsigned char*)source) + lineSize + 4;
|
|
||||||
dst = (unsigned char*)destination;
|
|
||||||
do {
|
|
||||||
MoveMemory( dst, src, lineSize );
|
|
||||||
src+=lineSize;
|
|
||||||
dst+=lineSize;
|
|
||||||
src += 4;
|
|
||||||
dst += (destinationPitch - lineSize);
|
|
||||||
} while ( --height);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// compact but slow C version
|
while( height-- ) {
|
||||||
//unsigned int nBytesPerPixel = colorDepth>>3;
|
memcpy( dst, src, lineSize );
|
||||||
//unsigned int i, x, y, srcPitch = (width+1) * nBytesPerPixel;
|
src += srcPitch;
|
||||||
//unsigned char * src = ((unsigned char*)source)+srcPitch;
|
dst += dstPitch;
|
||||||
//unsigned char * dst = (unsigned char*)destination;
|
}
|
||||||
//for (y=0;y<height;y++) //Width
|
}
|
||||||
//for (x=0;x<width;x++) //Height
|
|
||||||
//for (i=0;i<nBytesPerPixel;i++) //Byte# Of Pixel
|
inline void cpyImg16( unsigned char *dst, unsigned int dstPitch, unsigned char *src, unsigned int srcPitch, unsigned short width, unsigned short height )
|
||||||
//*(dst+i+(x*nBytesPerPixel)+(y*destinationPitch)) = *(src+i+(x*nBytesPerPixel)+(y*srcPitch));
|
{
|
||||||
|
register unsigned short lineSize = width<<1;
|
||||||
|
|
||||||
|
while( height-- ) {
|
||||||
|
memcpy( dst, src, lineSize );
|
||||||
|
src += srcPitch;
|
||||||
|
dst += dstPitch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue