PocketMatrix forums

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

Suspend without suspense

Maybe I do not understand what GameSuspend means,
but when I compile my game or Hekkus sample from the PocketFrog samples - GameSuspend doesn't work.
I switch my app to background both on PC and PPC but the music still plays.

And it's sure not a Hekkus fault - I added Shutdown in the HekkusSample to see if the GameSuspend or GameResume ever called, but they aren't:

Code:
void HekkusSample::GameSuspend()
{

// Suspend the Hekkus Sound System
m_sound.suspend();
Shutdown();
}

I tried Alt-Tab, just clicking on background window or ShowWindow(SW_MINIMIZE)

I use 0.8.1 and recompiled the libs several times.
Maybe I'm missing something really obvious?

But as I expect GameSuspend should be automatically called when app goes on background :( (lost focus,or inactive) is it true?

I didn't change the code in HekkusSample, only 2 lines with Shutdown - GameSuspend and GameResume are still public virtual void.

I attached HekkusSample (hss.dll and exe) to this post - it should call Shutdown() if GameSuspend or GameResume is called, just put it into Hekkus sample folder to try on a PC.

OK finally my question - HOW TO MAKE THE GAME SUSPEND on battery messages or just switching to background, I found some previous threads discussing this problem, but they didn't help

Nothing crashing - just the GameSuspend and GameResume never called :(

Ben
Attachments:
HekkusSample.zip (167 KB)
I had the same problem. Look at the middle of the second page of this thread:
http://www.pocketmatrix.com/forums/view ... w&start=15

Specifically, the part where I say
Looks like the problem is the call to the GameSuspend and GameResume in the OnActivate. Removing the 'Game::' from them allows the user declared functions to run instead of the default ones (is overridden the correct term to use?).


So, inside game.cpp, it should be
Code:

LRESULT Game::OnActivate( UINT msg, WPARAM wparam, LPARAM lparam, BOOL& bHandled )
{
if (LOWORD(wparam) == WA_INACTIVE)
{
if (!m_bSuspended)
{
m_bSuspended = true;
/*Game::*/ GameSuspend(); // Added 6/10/2003 by Frank W. Zammetti

}
}
else
{
if (m_bSuspended)
{
m_bSuspended = false;
/*Game::*/ GameResume(); // Added 6/10/2003 by Frank W. Zammetti

}
}


ShowTaskbar( LOWORD(wparam) == WA_INACTIVE );

return 0;
}
...All the pain gone
Thanks a lot

Some bugs in PocketFrog aren't still eliminated:

1. is in pDisplay->DrawVLine(....) - it draws one additional pixel.

2. The Draw/Fill rect have one common bug - the Fill starts at the same top-left corner, so if you do Fill and then Draw the same rect the upper line and the line on the left would be redrawn(or mix if Alpha<255) with the previously Filled Rect color. The top and left line also overlap in the upper-left pixel, so if you do fill and draw the same rect - this pixel would be redrawn(or mixed) 3 times.

Hope, someone could fix them.

P.S. Sorry Jason, I saw your post, but overlooked the solution.
BIGBEN wrote:1. is in pDisplay->DrawVLine(....) - it draws one additional pixel.


Are you sure? It looks ok here...

BIGBEN wrote:2. The Draw/Fill rect have one common bug - the Fill starts at the same top-left corner, so if you do Fill and then Draw the same rect the upper line and the line on the left would be redrawn(or mix if Alpha<255) with the previously Filled Rect color.


This is normal. The fill rect doesnt fill the last row/column. But DrawRect does. Perhaps DrawRect should be removed or updated to behave like FillRect.

BIGBEN wrote:The top and left line also overlap in the upper-left pixel, so if you do fill and draw the same rect - this pixel would be redrawn(or mixed) 3 times.


I will double check this, but I am pretty sure it doesn't do that.
Thierry":3q9e5cw0]
BIGBEN wrote:1. is in pDisplay->DrawVLine(....) - it draws one additional pixel.

Are you sure? It looks ok here...

Here is the code, just put it into the gameloop:

Code:
pDisplay = GetDisplay();
pDisplay->Clear(0);
pDisplay->DrawVLine(80, 160, 1, 0xffff);//here lives little buggie
pDisplay->DrawHLine(160, 160, 1, 0xffff);
pDisplay->Update();

The 1 pixel just to see the diff, the same 1 additional would be for 2-pixel and longer lines.

Thierry wrote:
This is normal. The fill rect doesnt fill the last row/column. But DrawRect does. Perhaps DrawRect should be removed or updated to behave like FillRect.

Hope the DrawRect would be updated, not removed ;)

Thierry wrote:
[quote="BIGBEN wrote:The top and left line also overlap in the upper-left pixel, so if you do fill and draw the same rect - this pixel would be redrawn(or mixed) 3 times.


I will double check this, but I am pretty sure it doesn't do that.


Oops I overlooked that actually it redraws two pixels - one is upper left, the other is lower left, just try this code, and you'll see that these pixels redrawn:

Code:
pDisplay = GetDisplay();
pDisplay->Clear(0);
pDisplay->SetBlending(50);
pDisplay->DrawRect(80,80,160,160,0xffff);
pDisplay->Update();


Hope this will help frog to hop into the new life :wink:

-LATER

Ok this code is even better and would make it obvious (DrawRect):

Code:
pDisplay = GetDisplay();
pDisplay->Clear(0);
pDisplay->SetBlending(50);
for(int k=0; k<10; k++)
{
pDisplay->DrawRect(80+k,80+k,160-k,160-k,0xffff);
}
pDisplay->Update();
Thierry,
I looked into rasterizer.cpp and here is what I can suggest:

First of all, I can't eliminate the bug in DrawVLine, just because I have no access to VLine function, the bug is in this function.

The second thing, IF Thierry will eliminate this bug, then the DrawRect bug(2pixels overwritten) & fix(Draw the same rect as FillRect fills) could be fixed by this:

in rasterizer.cpp OLD CODE:

Code:
void Rasterizer::DrawRect( int x1, int y1, int x2, int y2, Pixel color )
{
DrawHLine( x1, y1, x2-x1, color );
DrawVLine( x1, y1, y2-y1, color );
DrawVLine( x2, y1, y2-y1, color );
DrawHLine( x1, y2, x2-x1, color );
}


replace with this code (after the DrawVLine bug fixed):

Code:
void Rasterizer::DrawRect( int x1, int y1, int x2, int y2, Pixel color )
{
DrawHLine( x1, y1, x2-x1, color );
DrawVLine( x1, y1+1, y2-y1-2, color );
DrawVLine( x2-1, y1+1, y2-y1-2, color );
DrawHLine( x1, y2-1, x2-x1, color );
}


Note: if the length values are negative DrawXLine function would just return(as I see from the DrawXLine code);

Hope this helps to fix the code ;)
Thierry, finally I killed all those bugs (found VLine in algo2d).
The code of VLine is completely the different from HLine, but the bug is really cute one, you should see ;)

The updated bugfix will be posted in this thread:
http://www.pocketmatrix.com/forums/viewtopic.php?t=21765

I will also provide the description for users of non-PHaled Frog how to fix those bugs.
fast_rx wrote:I had the same problem. Look at the middle of the second page of this thread:
http://www.pocketmatrix.com/forums/view ... w&start=15

Specifically, the part where I say
Looks like the problem is the call to the GameSuspend and GameResume in the OnActivate. Removing the 'Game::' from them allows the user declared functions to run instead of the default ones (is overridden the correct term to use?).


So, inside game.cpp, it should be
Code:

LRESULT Game::OnActivate( UINT msg, WPARAM wparam, LPARAM lparam, BOOL& bHandled )
{
if (LOWORD(wparam) == WA_INACTIVE)
{
if (!m_bSuspended)
{
m_bSuspended = true;
/*Game::*/ GameSuspend(); // Added 6/10/2003 by Frank W. Zammetti

}
}
else
{
if (m_bSuspended)
{
m_bSuspended = false;
/*Game::*/ GameResume(); // Added 6/10/2003 by Frank W. Zammetti

}
}


ShowTaskbar( LOWORD(wparam) == WA_INACTIVE );

return 0;
}