PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Blitting scaled RGBA surfaces + loading a mod file

Hi! I need to blit an RGBA surface using a scaling parameter. In order to do that, I'm using the following method of the ClassEDisplay class:

Code:

void Blt(long center_x, long center_y, E2DSurfaceRGBA *source, RECT *rc, unsigned short rotation, unsigned long scale, unsigned char flipflags = EFLIP_NONE)


Unfortunately, the output isn't showing a scaled image (in fact, it doesn't show any image at all, unless I use 65536 for the scale parameter). Does the aforementioned method deal with scaling parameters different than 65536 or should I keep on checking my code?

My other question is related to the sound wrapper: I'm trying to load a music file using the following method:

Code:

ERESULT LoadMusic(unsigned long index, void *data, unsigned long datasize)


In order to do that, I'm using the following piece of code:

Code:

int iLength;
int ifreadRetVal;
FILE *lpFile;
char *lpAuxBuffer;

lpFile = fopen(lpMusicFilepath,"rb");
if(!lpFile)
{
return SOUNDMANAGER_FAILED;
} // End if.

fseek(lpFile,0,SEEK_END);
iLength = ftell(lpFile);
rewind(lpFile);
lpAuxBuffer = (char*)malloc(iLength);
ifreadRetVal = fread(lpAuxBuffer,sizeof(char),iLength,lpFile);
lResult = m_lpSoundSystem->LoadMusic(iIndex,(void*)lpAuxBuffer,iLength);
free(lpAuxBuffer);
fclose(lpFile);


Unfortunately, the sound file doesn't seem to load properly since I cannot listen to it when I try to play it. Notice that it plays correctly if I replace the code above with the following one:

Code:

lResult = m_lpSoundSystem->LoadMusic(iIndex,lpMusicFilepath);


Is it possible that there might be a bug in the implementation of the first LoadMusic method?

Thanks in advance for your answers,

--Nacho
Hi Nacho,

Currently, scaled RGBA blitting only works through OpenGL. However, rotate/scale RGBA blitting is planned for one of the upcoming releases.

Regarding your sound problem:
Perhaps there is a problem with libc or the filesize. On which platform are you testing on? Perhaps you can use ClassEFile to solve your problem.
Hi edge,

Thanks for your reply.

edge wrote:Currently, scaled RGBA blitting only works through OpenGL. However, rotate/scale RGBA blitting is planned for one of the upcoming releases.


OK, thanks. I'll use RGB surfaces for those sprites that need rotation/scaling, then.

edge wrote:Regarding your sound problem:
Perhaps there is a problem with libc or the filesize. On which platform are you testing on? Perhaps you can use ClassEFile to solve your problem.


I'm testing it on Windows desktop (Win XP SP2). I changed my method implementation in order to use ClassEFile but the problem is still there. The code is as follows:

Code:

int
CSoundManager::LoadMusic(int iIndex,char *lpMusicFilepath)
{
ERESULT lResult;
#if 0
lResult = m_lpSoundSystem->LoadMusic(iIndex,lpMusicFilepath);
#else
int iLength;
ClassEFile EFile;
char *lpAuxBuffer;

if(!EFile.Open(lpMusicFilepath,EFOF_READ))
{
return SOUNDMANAGER_FAILED;
} // End if.

iLength = EFile.Size();
lpAuxBuffer = (char*)malloc(iLength);
if(!EFile.Read(lpAuxBuffer,iLength))
{
return SOUNDMANAGER_FAILED;
} // End if.
lResult = m_lpSoundSystem->LoadMusic(iIndex,(void*)lpAuxBuffer,iLength);
free(lpAuxBuffer);
EFile.Close();
#endif
if(E_OK==lResult)
{
return SOUNDMANAGER_OK;
} // End if.
return SOUNDMANAGER_FAILED;
} // End CSoundManager::LoadMusic().


Notice that if I change "#if 0" to "#if 1", it works flawlessly. Any idea of where can I be making a mistake in my code?

Thanks again for your answer,

--Nacho

Edit: One thing I forgot to add: when I load the file using ClassEFile, the value inside lResult after the execution of LoadMusic is E_OK. Then, when I try to close the application, the VS debugger informs me (in line 116 of hekkus.h) that Windows has triggered a breakpoint in my game's executable.
Hi Nacho,

The breakpoint problem is similar to a problem we've experienced with Hekkus. It was caused by a mismatch of libraries (for example, combining a DLL with a static library definition).

Please check your code, it should be either the following:
- Define HSS_STATICLIB before including HSS.h and use the library inside /HekkusSoundSystem/lib_static/xp
- Don't define HSS_STATICLIB, use the library inside /HekkusSoundSystem/lib/xp

If it fixes the breakpoint problem, it may also fix the other issue. Please check this.
Hi edge,

I've checked the directory where I decompressed Hekkus but it seems that there's no longer an "xp" subdirectory inside "lib_static". I only have the following two: "gp2x" and "psp" (I'm using the 0.99.6.2 version of the library).

Another question: Do I have to include "hss.h"? I'm following this tutorial and it saids that if I want to use Hekkus all I need to do is define ESOUND_HEKKUS before including edgemain.h.

Thanks again for all your answers.

--Nacho
Hi Nacho,

Static libraries are only provided to donators of Hekkus, the only option would be to use the DLL. Please make sure HSS_STATICLIB is defined nowhere in your code. Also check the hekkus.h headerfile in the EDGELIB SDK for this definition (it shouldn't be there).

If you use the ClassESound sound wrapper, you don't need to include HSS.h, because it is already included by EDGELIB when defining ESOUND_HEKKUS.
Hi edge,

I've checked all around my code and, apparently, HSS_STATICLIB hasn't been defined at all. What else can I do?

--Nacho
Hi Nacho,

Try removing the free() function after passing the music buffer to LoadMusic. The sound system will take care of freeing your pointer.
Hi edge,

I tried removing the call to free() as you suggested, but it still doesn't work.

--Nacho
Hi Nacho,

Could you attach a sample project and your Hekkus libraries, headers and DLL's?
Hi edge,

Sure, I have prepared a sample VC++ project with the bare minimum source code so that you can reproduce the problem. Can I send it to you via e-mail?

Thanks!

--Nacho
Hi,

Yes, please send it to support (at) edgelib (dot) com