Hello ! I'm making a dll to convert 640x480x32 resolution to 320x240x8 but I don't why, it crash ! Can someone help me ? (I try to work with LCC WIN 32)
This dbpro code :
lock backbuffer
ptr=get backbuffer ptr()
pitch=get backbuffer pitch()
load dll "bits8.dll",1
call dll 1,"__Rezo80",ptr,pitch
delete dll 1
unlock backbuffer
and this the C source for lcc win
* --- The following code comes from C:\lcc\lib\wizard\dll.tpl. */
#include <windows.h>
/*------------------------------------------------------------------------
Procedure: LibMain ID:1
Purpose: Dll entry point.Called when a dll is loaded or
unloaded by a process, and when new threads are
created or destroyed.
Input: hDllInst: Instance handle of the dll
fdwReason: event: attach/detach
lpvReserved: not used
Output: The return value is used only when the fdwReason is
DLL_PROCESS_ATTACH. True means that the dll has
sucesfully loaded, False means that the dll is unable
to initialize and should be unloaded immediately.
Errors:
------------------------------------------------------------------------*/
BOOL WINAPI __declspec(dllexport) LibMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// The DLL is being loaded for the first time by a given process.
// Perform per-process initialization here. If the initialization
// is successful, return TRUE; if unsuccessful, return FALSE.
break;
case DLL_PROCESS_DETACH:
// The DLL is being unloaded by a given process. Do any
// per-process clean up here, such as undoing what was done in
// DLL_PROCESS_ATTACH. The return value is ignored.
break;
case DLL_THREAD_ATTACH:
// A thread is being created in a process that has already loaded
// this DLL. Perform any per-thread initialization here. The
// return value is ignored.
break;
case DLL_THREAD_DETACH:
// A thread is exiting cleanly in a process that has already
// loaded this DLL. Perform any per-thread clean up here. The
// return value is ignored.
break;
}
return TRUE;
}
int __declspec(dllexport) _Rezo80(unsigned long *ptr, unsigned long pitch)
{
int scl;
int x,y;
unsigned long *oldptr;
unsigned long col,colr,colg,colb;
scl=1;
for (y=0; y<=479; y++)
{
oldptr=ptr;
for (x=0; x<=639; x=+2)
{
if (scl==3)
{
//(*ptr)=4278190080;
ptr=ptr+1;
//(*ptr)=4278190080;
ptr=ptr+1;
}
else
{
col=((*ptr) && 4278190080);
colr=((*ptr) && 16711680)/48*48;
colg=((*ptr) && 65280)/48*48;
colb=((*ptr) && 255)/48*48;
//(*ptr)=col+colr+colg+colb;
ptr=ptr+1;
//(*ptr)=col+colr+colg+colb;
ptr=ptr+1;
}
}
scl=scl+1;
if (scl==4) scl=1;
ptr=oldptr+(pitch/4);
}
return 0;
}