Next Generation Emulation banner
1 - 1 of 1 Posts

·
Banned
Joined
·
42 Posts
Discussion Starter · #1 · (Edited)
Hello.

I won't normally post this, but I am in need of some assistance.

code to RPI.CPP

Code:
static HINSTANCE rpiDLL = NULL;
static RENDPLUG_Output fnOutput = NULL;
static RENDPLUG_GetInfo fnGetInfo = NULL;
static RENDER_PLUGIN_INFO MyPlugInfo;
static RENDER_PLUGIN_OUTP MyPlugOutput;
static int nScaleFactor;

bool rpiInit(const char *sPluginName)
{
	rpiCleanup();

	char sBuffer[256];
	char *ptr;

	GetModuleFileName(NULL, sBuffer, sizeof(sBuffer));
	ptr = strrchr(sBuffer, '\\');
	if (ptr)
		*ptr = '\0';
	strcat(sBuffer, "\\plugins\\");
	strcat(sBuffer, sPluginName);

  	rpiDLL = LoadLibrary(sBuffer);
  	if (!rpiDLL)
  		return false;

	fnGetInfo = (RENDPLUG_GetInfo) GetProcAddress(rpiDLL, "RenderPluginGetInfo");
	fnOutput = (RENDPLUG_Output) GetProcAddress(rpiDLL, "RenderPluginOutput");
	if (fnGetInfo == NULL || fnOutput == NULL)
	{
		FreeLibrary(rpiDLL);
		rpiDLL = NULL;
		return false;
	}

	RENDER_PLUGIN_INFO *pRPI = fnGetInfo();
	if (pRPI == NULL)
	{
		FreeLibrary(rpiDLL);
		rpiDLL = NULL;
		return false;
	}

	memcpy(&MyPlugInfo, pRPI, sizeof(MyPlugInfo));

	unsigned long Flags = MyPlugInfo.Flags & 0x0000F0000;

	if (Flags == RPI_OUT_SCL2)
	{
		nScaleFactor = 2;
	}
	else if (Flags == RPI_OUT_SCL3)
	{
		nScaleFactor = 3;
	}
	else if (Flags == RPI_OUT_SCL4)
	{
		nScaleFactor = 4;
	}
	else
	{
		nScaleFactor = 2;
	}

	return true;
}

void rpiFilter(unsigned char *srcPtr, unsigned int srcPitch, unsigned char *dstPtr, unsigned int dstPitch, int width, int height)
{
	MyPlugOutput.Size = sizeof(MyPlugOutput);
	MyPlugOutput.Flags = MyPlugInfo.Flags;
	MyPlugOutput.SrcPtr = srcPtr;
	MyPlugOutput.SrcPitch = srcPitch;
	MyPlugOutput.SrcW = width;
	MyPlugOutput.SrcH = height+(nScaleFactor/2);
	MyPlugOutput.DstPtr = dstPtr;
	MyPlugOutput.DstPitch = dstPitch;
	MyPlugOutput.DstW = width * nScaleFactor;
	MyPlugOutput.DstH = (height+(nScaleFactor/2)) * nScaleFactor;
	MyPlugOutput.OutW = width * nScaleFactor;
	MyPlugOutput.OutH = (height+(nScaleFactor/2)) * nScaleFactor;
	fnOutput(&MyPlugOutput);
}

char* rpiFilterName()
{
	return MyPlugInfo.Name;
}

int rpiScaleFactor()
{
	return nScaleFactor;
}

void rpiCleanup()
{
	if (rpiDLL != NULL)
	{
		FreeLibrary(rpiDLL);
		rpiDLL = NULL;
	}
}
Code in my application...

Code:
int pitch = NES_DISP_WIDTH*3;
	int bufsize = NES_DISP_WIDTH * NES_DISP_HEIGHT * 3 * rpiScaleFactor();
	int dest_pitch = NES_DISP_WIDTH*3*rpiScaleFactor();
	unsigned char* ImageBuffer_Dest = (unsigned char*)malloc(bufsize); 
	rpiFilter((unsigned char*)buffer, pitch, ImageBuffer_Dest, dest_pitch, NES_DISP_WIDTH, NES_DISP_HEIGHT);
	free(ImageBuffer_Dest);
Its just a test, but whenever rpiFilter() gets called, I receive access violations in regards to memory writes. Not sure what's the issue, so I could do with some assistance.

Before people ask, I
* Use OpenGL 1.1
* Use RGB-565 as my pixel format, so I know Kega Fusion filters should work, as they support that explicit image format.
 
1 - 1 of 1 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top