PocketMatrix forums

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

Quality of code -> performances ?

I'm making a simple 2D Gaidraw based game (action) but I have some problems with the performances. I want it to run @ 45FPS on a old 206Mhz device (HP568)

I am not a great programmer that's why I think the low performances are directly due to the quality of my code.

Each element of my program is processed in a function so the main architecture is like that:

Code:

HRESULT CMyApplication::ProcessNextFrame(CGapiSurface& backbuffer, DWORD dwFlags)
{
UpdateThis1(backbuffer);
UpdateThat1(backbuffer);
UpdateThis2(backbuffer);
UpdateThat2(backbuffer);
UpdateThis3(backbuffer);
UpdateThat3(backbuffer);

return S_OK;
}


And in those functions there are other functions called, like that:

Code:

void CMyApplication::UpdateThis1(CGapiSurface& backbuffer)
{
if (condition1)
UpdateThing1(backbuffer);
else if (condiction2)
UpdateThing2(backbuffer);
else if (condition3)
UpdateThing3(backbuffer);
else if (condition4)
UpdateThing4(backbuffer);
}


or
Code:

void CMyApplication::UpdateThis2(CGapiSurface& backbuffer)
{
switch (variable1)
{
case 1:
UpdateThing1(backbuffer);
case 2:
UpdateThing2(backbuffer);
case 3:
UpdateThing3(backbuffer);
case 4:
UpdateThing4(backbuffer);
}
}


Each function make BltFasts in the backbuffer, that's why I think the way I am coding is wrong.
Many games decompose the display in many functions so that they are more modular thus I do not think that my architecture is bad but the way I code is not good I think.

Can you help me optimizing my code giving me some advices about GapiDraw/C++ coding.

Other question, do I have to use DWORDs instead of int, is it realy better?