PocketMatrix forums

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

Notifications crashing game? help needed, game is LIVE

A registered user has reported notifications crashing the game. I'm waiting on more info from him but can anyone suggest what I could be missing? I think I did exactly what Thierry said but could have omitted a step. (this is really urgent as the game is on sale already)

Thierry wrote:-
I reproduced with PF 0.7 and fixed. Simply edit class Game.h and remove the "OnSetFocus" and the "OnKillFocus" callbacks.

You need to remove the two functions from Game.cpp and remove the two entries in the message map (Game.h).

I don't know what I was thinking when I used these callbacks. OnActive() is the (only) way to go to handle this issue.


update: I found that I had 2 lines PocketPC::Suspend and PocketPC::Resume in game.cpp onActivate which are not in PF 0.8 so I have removed and I'm testing...
now after a rebuild all the game won't run on PPC but ok on PC ...
You removed the wrong thing. What you want to remove is the OnSetFocus() and OnKillFocus() callbacks. Remove them from game.h and game.cpp (three places: message map, declaration and implementation).

You still need the PocketPC::Suspend() and PocketPC::Resume() calls in OnActivate().
Thierry, these lines (PocketPC::Suspend etc) are NOT in PF 0.8.0
Instead there's Game::GameSuspend() & Game::GameResume()

The set focus stuff was removed but I'm going to check all 3 items gone. Will post my source here if still stuck.

My Code:
game.h
Code:

MESSAGE_HANDLER( WM_ACTIVATE, OnActivate )
//following 2 lines removed to fix resume bug
// MESSAGE_HANDLER( WM_SETFOCUS, OnSetFocus )
// MESSAGE_HANDLER( WM_KILLFOCUS, OnKillFocus )
MESSAGE_HANDLER( WM_PAINT, OnPaint )


LRESULT OnActivate( UINT msg, WPARAM wparam, LPARAM lparam, BOOL& bHandled );
// LRESULT OnSetFocus( UINT msg, WPARAM wparam, LPARAM lparam, BOOL& bHandled );
// LRESULT OnKillFocus( UINT msg, WPARAM wparam, LPARAM lparam, BOOL& bHandled );
LRESULT OnPaint( UINT msg, WPARAM wparam, LPARAM lparam, BOOL& bHandled );

game.cpp
Code:
LRESULT Game::OnActivate( UINT msg, WPARAM wparam, LPARAM lparam, BOOL& bHandled )
{
if (LOWORD(wparam) == WA_INACTIVE)
{
if (!m_bSuspended)
{
// PocketPC::Suspend();
m_bSuspended = true;
Game::GameSuspend(); // Added 6/10/2003 by Frank W. Zammetti
}
}
else
{
if (m_bSuspended)
{
// PocketPC::Resume();
m_bSuspended = false;
Game::GameResume(); // Added 6/10/2003 by Frank W. Zammetti
}
}


ShowTaskbar( LOWORD(wparam) == WA_INACTIVE );

return 0;
}


/*
LRESULT Game::OnSetFocus( UINT msg, WPARAM wparam, LPARAM lparam, BOOL& bHandled )
{
return OnActivate( WM_ACTIVATE, WA_ACTIVE, 0, bHandled );
}



LRESULT Game::OnKillFocus( UINT msg, WPARAM wparam, LPARAM lparam, BOOL& bHandled )
{
return OnActivate( WM_ACTIVATE, WA_INACTIVE, 0, bHandled );
}
*/


LRESULT Game::OnPaint( UINT msg, WPARAM wparam, LPARAM lparam, BOOL& bHandled )
{
They are not in PF 0.8 because PocketHAL takes care of the display for you. They are needed in PF 0.7.

This is what you want:

Code:

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


ShowTaskbar( LOWORD(wparam) == WA_INACTIVE );

return 0;
}



/*
LRESULT Game::OnSetFocus( UINT msg, WPARAM wparam, LPARAM lparam, BOOL& bHandled )
{
return OnActivate( WM_ACTIVATE, WA_ACTIVE, 0, bHandled );
}



LRESULT Game::OnKillFocus( UINT msg, WPARAM wparam, LPARAM lparam, BOOL& bHandled )
{
return OnActivate( WM_ACTIVATE, WA_INACTIVE, 0, bHandled );
}
*/
that's what I now have. Did a rebuld all.
Game is still exiting on power on with owner information on startup active. Will test an appointment.

What else can I be missing?

update: I can see it's crashing as it powers off not as it goes on when it's already gone (if that helps)
This works on all three PPCs I have. It was also reported to fix the issue for many peoples.

What do you use for sound? Can you disable the sound engine completely and see if the problem is still there?

What do you see when it crashes?

Here is an idea to test it without having to shutdown the power: modify GAPILibrary.cpp by removing the call to GXOpenInput() on line 313. Now when your game is running (under the debugger), press the contacts button (this will bring the contacts app). Your game will lose focus and you will hopefully break in the debugger.
I'm using Hekkus. It's supposed to deal with this. It would be very hard to disable it as it's used all over the place (it's a game after all)

within input.cpp there's a pair of functions:-

Code:
MyGame::GameSuspend(){
m_sound.suspend();
}
MyGame::GameResume(){
m_sound.resume();
}


I can do a small test with Hekkus in & out. If there's anything else I should look at let me know. Many thanks for your help
Like I said, try disabling GXOpenInput() and make your game lose focus while running in the debugger.
thanks, testing this now. Forced to go to work soon. Will report back later
I commented out GXOpenInput(), rebuilt the debug lib, did a rebuild all & debug, go but the hard buttons (contact etc) don't cause anything to happen as the game is running? Same happens out of the debugger, the buttons have no effect. I will test with an appointment pop up
Thierry wrote:
What do you use for sound? Can you disable the sound engine completely and see if the problem is still there?


To disable Hekkus simply comment the speaker.open call on your game. All the other Hekkus function calls do nothing if you haven't open the speaker object.
Conan, you might also want to try the Blit sample and try to reproduce with it. If it crashes, then its PF... If it doesn't, then its not.
Conan · 04 Aug 2004, 10:42 UTC — results captured from debugger
Update on below: I had linked the non-debug Frog so doing again with the debug one!

The game crashes with or without Hekkus operational.
The debugger does not give me anything I can interpret but here's the output just in case it makes sense to someone

The error info is:-
Data Abort: Thread=86f337dc Proc=84024330 'treker.exe'
AKY=00020001 PC=01fc7800 RA=00078ab4 BVA=24000000
The program 'C:\Windows CE Tools\frog\treker\ARMDbg\treker.exe' has exited with code 0 (0x0).

there's a context 25fc78000

I don't know if this means anything to you but this is what appears (no source just disassembly).the first line is where the first chance exception points to

Code:
25FC7800 str r4, [r0], #4
25FC7804 str r5, [r0], #4
25FC7808 str r6, [r0], #4
25FC780C str r7, [r0], #4
25FC7810 str r8, [r0], #4
25FC7814 str r9, [r0], #4
25FC7818 str r10, [r0], #4
25FC781C str r11, [r0], #4
25FC7820 cmp r2, #0x80 ; 0x80 = 128
25FC7824 bmi 25FC7848 ; pc+8+28
25FC7828 ldrnvb pc, [r1, #0x60] ; 0x60 = 96
25FC782C ldrnvb pc, [r1, #0x80] ; 0x80 = 128
25FC7830 ldmia r1!, {r4 - r11} ; ldmfd
25FC7834 stmia r0!, {r4 - r11} ; stmea
25FC7838 ldmia r1!, {r4 - r11} ; ldmfd
25FC783C stmia r0!, {r4 - r11} ; stmea
25FC7840 sub r2, r2, #0x40 ; 0x40 = 64
25FC7844 b 25FC7820 ; pc+8-44
25FC7848 cmp r2, #0x80 ; 0x80 = 128
25FC784C bls 25FC7854 ; pc+8+0
25FC7850 ldrnvb pc, [r1, #0x80] ; 0x80 = 128
25FC7854 cmp r2, #0x20 ; 0x20 = 32
25FC7858 bmi 25FC786C ; pc+8+12
25FC785C ldmia r1!, {r4 - r11} ; ldmfd
25FC7860 stmia r0!, {r4 - r11} ; stmea
25FC7864 sub r2, r2, #0x20 ; 0x20 = 32
25FC7868 b 25FC7854 ; pc+8-28
25FC786C ands r3, r2, #0x1C ; 0x1C = 28
25FC7870 beq 25FC80AC ; pc+8+2100
25FC7874 sub r2, r2, r3
25FC7878 rsb r3, r3, #0x20 ; 0x20 = 32
25FC787C add r12, pc, #0
25FC7880 add pc, r12, r3
25FC7884 ldr r4, [r1], #4
25FC7888 ldr r5, [r1], #4
25FC788C ldr r6, [r1], #4
25FC7890 ldr r7, [r1], #4
25FC7894 ldr r8, [r1], #4
25FC7898 ldr r9, [r1], #4
25FC789C ldr r10, [r1], #4
25FC78A0 ldr r11, [r1], #4
25FC78A4 add r12, pc, #0
25FC78A8 add pc, r12, r3
25FC78AC str r4, [r0], #4
25FC78B0 str r5, [r0], #4
25FC78B4 str r6, [r0], #4
25FC78B8 str r7, [r0], #4
25FC78BC str r8, [r0], #4
25FC78C0 str r9, [r0], #4
25FC78C4 str r10, [r0], #4
25FC78C8 str r11, [r0], #4
25FC78CC rsb r2, r2, #4
25FC78D0 add r12, pc, #0
25FC78D4 add pc, r12, r2, lsl #2
25FC78D8 ldrb r3, [r1], #1
25FC78DC ldrb r4, [r1], #1
25FC78E0 ldrb r5, [r1], #1
25FC78E4 ldrb r6, [r1], #1
25FC78E8 add r12, pc, #0
25FC78EC add pc, r12, r2, lsl #2
25FC78F0 strb r3, [r0], #1
25FC78F4 strb r4, [r0], #1
25FC78F8 strb r5, [r0], #1
25FC78FC strb r6, [r0], #1
25FC7900 ldmia sp!, {r0, r3 - r12, pc} ; ldmfd
25FC7904 bic r3, r1, #3
25FC7908 ldr lr, [r3], #4
25FC790C mov lr, lr, lsr #8
25FC7910 and r4, r0, #0x1C ; 0x1C = 28
25FC7914 rsb r4, r4, #0x20 ; 0x20 = 32
25FC7918 and r5, r2, #0x1C ; 0x1C = 28
25FC791C cmp r4, r2
25FC7920 movhi r4, r5
25FC7924 cmp r4, #0
25FC7928 beq 25FC79C0 ; pc+8+144
25FC792C rsb r6, r4, #0x20 ; 0x20 = 32
25FC7930 and r6, r6, #0x1C ; 0x1C = 28
25FC7934 sub r2, r2, r4
25FC7938 add r12, pc, #0
25FC793C add pc, r12, r6, lsl #2
25FC7940 ldr r4, [r3], #4
25FC7944 orr r12, lr, r4, lsl #24
25FC7948 str r12, [r0], #4
25FC794C mov lr, r4, lsr #8
25FC7950 ldr r4, [r3], #4
25FC7954 orr r12, lr, r4, lsl #24
25FC7958 str r12, [r0], #4
25FC795C mov lr, r4, lsr #8
25FC7960 ldr r4, [r3], #4
25FC7964 orr r12, lr, r4, lsl #24
25FC7968 str r12, [r0], #4
25FC796C mov lr, r4, lsr #8
25FC7970 ldr r4, [r3], #4
25FC7974 orr r12, lr, r4, lsl #24
25FC7978 str r12, [r0], #4
25FC797C mov lr, r4, lsr #8
25FC7980 ldr r4, [r3], #4
25FC7984 orr r12, lr, r4, lsl #24
25FC7988 str r12, [r0], #4
25FC798C mov lr, r4, lsr #8
25FC7990 ldr r4, [r3], #4
25FC7994 orr r12, lr, r4, lsl #24
25FC7998 str r12, [r0], #4
25FC799C mov lr, r4, lsr #8
25FC79A0 ldr r4, [r3], #4
25FC79A4 orr r12, lr, r4, lsl #24
25FC79A8 str r12, [r0], #4
25FC79AC mov lr, r4, lsr #8
25FC79B0 ldr r4, [r3], #4
25FC79B4 orr r12, lr, r4, lsl #24
both the blit sample (PF 0.8) and the hekkus sample (PF 0.7) survive across a power off/on with owner information.

If it's not the setup of PocketFrog's suspend/resume which is going wrong then what else could it be? Only PF is involved in rendering stuff to the screen.

Obviously Space Treker is a much bigger program than the two samples. Does anyone else have a full-sized game which is working ok? I'm thinking about building using the HAL version to see what happens. Report back later.
I had two problems when releasing 3D CEdice when switching on/off the device. The first one was related to hekkus and my 1940, which didn't like to be switched off. Gersen fixed it asap in the last version. The second one was related to pockethal and my bad coding habits :) , appeared in e740/e750 iirc, and I think Thierry also fixed it in the last PH version.


About the asm dump, I think it'd be more interesting to have the code before the problem, not the one after it. Also you could generate a map file and a source listing with evc, you probably would know where in your code the problem is located. (even if the code is not in your code you should be able to know which module is giving the problem).
I have run lots & lots of test today none of them pointing to what's going wrong. I have converted over to PF0.8.1/PHal and the problems still happen. I tried adding pop-ups into the game to simulate notifications but these all worked fine.

I'm going to try to catch the error again in the debugger now I'm on the latest version but any suggestions will be most welcome. I've taken 2 days leave so I have a long weekend to deal with this.

ok: When it crashed the diary reminder came up went away came up & stayed up & down went the game.

I caught the error in the debugger but don't know what to do with it. All I see is what appears to be the same disassembly. In threads it says "Stopped,1st chance,[Frog::Intern" but otherwise nothing new. What can I do once I get it to break if it's not showing me source?
Conan wrote:The error info is:-
Data Abort: Thread=86f337dc Proc=84024330 'treker.exe'
AKY=00020001 PC=01fc7800 RA=00078ab4 BVA=24000000
The program 'C:\Windows CE Tools\frog\treker\ARMDbg\treker.exe' has exited with code 0 (0x0).


Isn't a "data abort" a misaligned read or write to memory?

http://groups.google.ca/groups?q=%22dat ... p08&rnum=8

Looks like the code is trying to store a dword at an unaligned address. Can you post the registers values at the point of crash?
Conan wrote:I caught the error in the debugger but don't know what to do with it. All I see is what appears to be the same disassembly. In threads it says "Stopped,1st chance,[Frog::Intern" but otherwise nothing new. What can I do once I get it to break if it's not showing me source?


Can you post the whole call stack here so we can see what you are dealing with?
Are you compiling with EVC4? If not, you should. There is some compiler problems with EVC3 that could explain this.

Look for posts by Sergey Chaban in the Gen Dev forum on how to setup EVC3 to use the EVC4 compiler.