PocketMatrix forums

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

Glitchy PHAL::GetClock() ?

I've been rebuilding some games for WM6 and I've found the following problem:


I have the following messy code (it's my style, sorry kids):

Code:

int rv1,rv2,iterations=0;

rv1=PHAL::GetClock ();
while (1)
{
rv2=PHAL::GetClock ();
if (rv2>(rv1+1000)) break;
rv1=rv2;
iterations++;
}

appLog ("RV1=%d RV2=%d, iter=%d",rv1,rv2,iterations);

rv1=PHAL::GetClock ();
appLog ("RV1=%d ",rv1);

exit(0);



which basically executes PHAL::GetClock() until it gets a difference bigger than 1000 ms between executions, and gives the following output:

RV1=41091388 RV2=41807216, iter=595
RV1=41091391

So, after 595 iterations, three consecutive calls to PHAL::GetClock gives me:
41091388
41807216
41091391

The number of iterations is random, and I have no other threads in my app running which could interfere. I removed the device's battery and still got the same results.

At first I thought it was a buffer overrun problem in my app, so I started looking for it, but it leaded me to that code.

Any ideas? (If you want me to test anything Thierry just tell me, it's my own phone, an SPV E200)

TIA!
Kak

p.s. I'm using the 1.0.5 RC_2 without logging posted in the 1.0.4, and before that I was using 1.0.4 which also had the problem. I'm almost sure the problem wasn't in 0.7.7 (the last version I used to compile the game), but it could have gone unnoticed... if so, poor customers, because you get randomly killed :)
GetClock() is using the QueryPerformanceCounter() on Windows CE.

I know this can be a problem on PCs (bad BIOS or drivers), but I didn't know it could drift like that on Windows CE.

I have an SPV 200 and will try to reproduce this. But I will probably switch to use GetTickCount() if it proves to be more reliable.

Thanks for reporting this!
OK, I thought I had access to an SPV E200, but I don't.

PocketHAL uses QueryPerformanceCounter() because GetTickCount() doesn't work properly on some devices (ex: Toshiba E330/E335, E740 and some others).

Could you try using GetTickCount() instead of PHAL::Clock() and see if you run into the same problem?

Also, can you run the logged version of the library so that I can get the OEM string?

If GetTickCount() works, I will hard code PocketHAL to use it on the SPV E200.
Kzinti wrote:OK, I thought I had access to an SPV E200, but I don't.

PocketHAL uses QueryPerformanceCounter() because GetTickCount() doesn't work properly on some devices (ex: Toshiba E330/E335, E740 and some others).

Could you try using GetTickCount() instead of PHAL::Clock() and see if you run into the same problem?

Also, can you run the logged version of the library so that I can get the OEM string?

If GetTickCount() works, I will hard code PocketHAL to use it on the SPV E200.


Sure, I'll have a go at it this weekend when I reach home!
Hi Thierry,

GetTickCount works, the log is here:

Code:

OEM String: "HTC VOYAGER"
PocketHAL (Version 1.0.4)
Display::Create( hwnd = 001A58F0, W:176, H:220, O:0, S:1 )
Initializing display...
VideoDetect::DetectDrivers()
GDIDriver: Detect()
GDIDriver: Found W:176, H:220, D:16
VideoDetect: OS Version is 4.20
DriverVGA: Detect()
DriverVGA: GETRAWFRAMEBUFFER failed
GAPI: Detect()
GAPI: Loading GX.DLL
GAPI: Calling GXOpenDisplay( 001A58F0, GX_FULLSCREEN )
GAPI: Calling GXGetDisplayProperties()
GAPI: Detecting orientation
GAPI: Native orientation is 0 (176 x 220)
GAPI: Calling GXIsDisplayDRAMBuffer() @ 029D1B38
GAPI: GXIsDisplayDRAMBuffer() returned FALSE
GAPI: Detecting PocketPC model
GAPI: framebuffer address unknown, calculating offset
GAPI: Offset is 0
GAPI: Calling GXBeginDraw() @ 029D1678 to retrieve framebuffer
GAPI: framebuffer at 46300000
GAPI: Calling GXEndDraw()
GAPI: Final framebuffer address = 46300000
GAPI: Calling GXCloseDisplay()
GAPI: Found W:176, H:220, P:352, O:0, FB:46300000
Imageon100: Detect()
Imageon100: Not an Imageon100
MediaQ: Detect()
MediaQ: not a MediaQ [1]
CreateDriver( 00000003 )
Initializing video driver...
GAPI: Initialize()
Driver initialized!
Success, returning display params to caller (W:176, H:220, O:0, S:2)

Thanks, I will release 1.0.5 shortly.