PocketMatrix forums

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

BltFast Error Codes

I'm having a rather strange issue with BltFast.

I've got the same module schema with OnNextFrame and RenderScreen routines that you use in the demos but on 2003 devices I'm having a problem with my About screen which is a module.

When the user selects the About command from the main menu on my Level module it loads the About module which then BltFast's a background PNG then some text and a button. But in 2003 PPC's the background PNG does not display. It blits the text and button right over the Level module's display.

When I tried to check the error code of the BltFast to determine what the problem was I found that BltFast was returning an error code of 1 for both 2005 which displays correctly and 2003 which doesn't. I'm also not getting any errors when loading the PNG's into RGB surfaces.

Any ideas on how I can trouble shoot and find out why 2003 is not blitting right?
Hi Jeffer,

You can check the number of the error code definition in edge.h, search for E_ERROR. Code 1 is E_ERROR which will be returned if there is something not loaded correctly in one of the surfaces.

Are you able to write the background PNG picture to a bitmap file using surface->WriteBmp()?
I will try to use WriteBmp and get you an answer. Unfortunately this only works incorrectly on a 2003 QVGA unit which my partner has to test for me because I don't have one.

Strange thing is BltFast seems to ALWAYS return E_ERROR.

It's only in 2003 QVGA that it fails to display but it ALWAYS returns E_ERROR even in the working devices (2005 QVGA and VGA and 2003 VGA).
That's strange.

I've checked the Edge source code and the only reason it will return E_ERROR is when the source or destination surface is type 'NONE' (not loaded). It returns before it has drawn anything (otherwise it returns E_OK, always).

Maybe you can check the variables of your render function to see if they are initialized correctly, or check for variables with the same name (for example an internal class variable and one local variable with the name 'result').

If everything fails, you may also want to use the following pragma: #pragma optimize("", on/off)
Sometimes the optimizer works incorrectly, but this only happens in rare cases.

Of course, we can also help testing. We have a Dell Axim X5v QVGA Pocket PC with Windows Mobile 2003.
Just got the test results back. WriteBmp() writes the surface to a bmp file on all devices. They all write the same thing to the file that gets written to screen but the 2003 QVGA image is still wrong and missing the background image.

I tried to attact an image but my web server seems to be hosed. I'll send when I can.

I don't have any other vars called result so I know this is the value that BltFast is returning and again all the other devices yield the same E_ERROR but they correctly display the images.[/img]
I've created a small sample using the Edge 2.60 SDK and everything seems to work properly (the result is E_OK as well).

Maybe you can try to replace main.h temporarily with the following code:

Code:

/////////////////////////////////////////////////////////////////////
// Class definition //
/////////////////////////////////////////////////////////////////////

//The application framework
class ClassMain : public ClassEdge
{
private:
E2DSurface pngimage;
unsigned long result;
public:
ClassMain(const EDGEDATA *data);
~ClassMain(void);
ERESULT OnCreate(EDGECONFIG *config, EDGEDATA *data);
ERESULT OnDisplayInit(EINSTANCE instance, ClassEDisplay *display);
ERESULT OnNextFrame(ClassEDisplay *display, unsigned long timedelta);
void OnButtonDown(unsigned long bnr, EBUTTONLIST *blist);
void OnStylusDown(POINT pnt);
};


/////////////////////////////////////////////////////////////////////
// ClassMain: public //
/////////////////////////////////////////////////////////////////////

//ClassMain: constructor
ClassMain::ClassMain(const EDGEDATA *data) : ClassEdge(data){ }

//ClassMain: destructor
ClassMain::~ClassMain(void){ }

//Callback: Called immediatly after starting the program, configure Edge here
ERESULT ClassMain::OnCreate(EDGECONFIG *config, EDGEDATA *data)
{
config->resolution = ERS_DEVICEDEFAULT;
return(E_OK);
}

//Callback: Called when the display mode has changed, use this to initialize your surfaces, etc.
ERESULT ClassMain::OnDisplayInit(EINSTANCE instance, ClassEDisplay *display)
{
if (display->CreateSurface(&pngimage;, "image.png") != E_OK)
{
SetErrorMsg("Error loading image.png");
return(E_ERROR);
}
result = E_OK;
return(E_OK);
}

//Callback: Called every frame
ERESULT ClassMain::OnNextFrame(ClassEDisplay *display, unsigned long timedelta)
{
if (result == E_OK)
result = display->buffer.BltFast(
display->buffer.GetWidth() / 2 - pngimage.GetWidth() / 2,
display->buffer.GetHeight() / 2 - pngimage.GetHeight() / 2,
&pngimage;,
NULL,
EFX_COLORKEY
);
display->buffer.DrawFont(2, 2, &display-;>fontinternal, result);
return(E_OK);
}

//Callback: Called when the user pressed a key or button
void ClassMain::OnButtonDown(unsigned long bnr, EBUTTONLIST *blist)
{
Quit();
}

//Callback: Called when the user points the stylus down or clicks the left mouse button
void ClassMain::OnStylusDown(POINT pnt)
{
Quit();
}
OK, this code works for me too in 2005 QVGA.

But you're calling it with a EFX_COLORKEY this is what I'm using:

Code:

#define OPACITY_NONE 255
result = display->buffer.BltFast(0, 0, &about;, NULL, EFX_OPACITY, OPACITY_NONE);


Can you try that to see if it still works. Also, you're loading an image directly and I'm loading from a EFX file like this:

Code:

void ClassFormAbout::LoadGraphicRGBA(char *filename, E2DSurfaceRGBA *surface)
{
if (!active)
{
unsigned char *filedata;
unsigned long filedatasize, fileid;
// Load the menu background
if (ef.PackSearchFile(filename, fileid))
{
int success = ef.PackGetFileData(filedata, filedatasize, fileid);
if (success == E_OK)
{
success = game->ecd->dsp->CreateSurface(surface, filedata, filedatasize, EST_SYSMEMORY | EST_DITHER);
if (success != E_OK)
game->ui->FatalError(MODULE_ABOUT, ERR_GRAPHICRGBA, filename);
ClassEMemory::DeAlloc(filedata);
}
else
game->ui->FatalError(MODULE_ABOUT, ERR_GRAPHICRGBA, filename);
}
else
game->ui->FatalError(MODULE_ABOUT, ERR_GRAPHICRGBA, filename);
}
}



See any issues there?

Also, what could be different in here that it would work for 2005 VGA and QVGA and 2003 VGA, but not 2003 QVGA? As far as we can tell the machines are the same memory and processor-wise.
Yes, that's the strange part. Some devices have the same architecture, but there are small differences in hardware or memory which can make a big difference in a case like this. Your code looks like it should run correctly.

I've made these changes to the sample above:
- Changed the surface to RGBA
- Changed EFX_COLORKEY to EFX_OPACITY
- Added a parameter to BltFast, with value 255 (full opacity).

It still returns 0 and works on our Axim X5v. Loading the surface from an Edge pack shouldn't make a difference to the return value of the BltFast() function.

Can you tell us the QVGA Pocket PC 2003 device you're working on? Maybe it's just the device itself, and could work on another QVGA 2003 Pocket PC such as the Axim X5v.
OK, I don't know what was wrong with this but its fixed.

I was loading images in two places, once at game startup for stuff that's used all the time but also I was loading some images (in this case the About page images) only when the user opened that page.

I moved this secondary loading to the startup loading and everything works fine. So something about loading the images at a different time was causing this for some reason.

At this point I don't care what because I have other pressing work so...
Alright, good to know that you've found a way to fix it.

It could be a memory issue (not enough memory when loading the surface). In the upcoming 2.70 release it should return the correct error code when not enough memory is available (in the current release it returns E_ERROR).