PocketMatrix forums

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

PocketHAL sample code

Below I have a sample that 'should' work with PocketHAL, it just initializes a window and calls a dumb pixels drawing routine for 5 secs, afterwards it quits.
However on my Ipaq3850 I notice the program is running for 5 secs, but unfortunately the screen stays untouched, just as the swap is doing nothing.
Can someone try this out on his device? just paste the code in evc++ it should compile.
I guess something is missing, but can't figure out what, did following actions:
-create display
-initialize display
-ask for backbuffer ptr
-fill it
-swap it
should work no?

anxious waiting for feedback, joost

Code:

#include <atlbase.h>
#include "pockethal.h"


Display *display;
DisplayParameters params; //use default params

HINSTANCE hInst;
HWND MainWindow = NULL;
TCHAR szAppName[] = TEXT("pockethal");
TCHAR szTitle[] = TEXT("pockethal");

LRESULT CALLBACK MainProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);


void DrawSomething() {

// fills the screen with a color during one second, repeated 5 times

for (int s=0; s<5; s++) {
Surface *buffer = display->GetBackBuffer();
if (!buffer) return;

uint16_t *buffptr = buffer->GetPixels();

memset(buffptr,0x20 * s, 320*200*2); // fill the buffer with a color

display->Swap();

Sleep(1000); // wait 1 second
}

}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow)
{

HWND hWndThis = NULL;
WNDCLASS WindowClass;

// Window Setup

hWndThis = FindWindow(szAppName, szTitle);
if (hWndThis)
{
SetForegroundWindow(hWndThis);
return 0;
}

hInst = hInstance;

if (!hPrevInstance)
{
WindowClass.style = CS_HREDRAW | CS_VREDRAW;
WindowClass.lpfnWndProc = MainProc;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = hInstance;
WindowClass.hIcon = NULL;
WindowClass.hCursor = NULL;
WindowClass.hbrBackground = NULL;
WindowClass.lpszMenuName = NULL;
WindowClass.lpszClassName = szAppName;

if (!RegisterClass(&WindowClass;)) // if can't register window class then quit program.
return 0;
}

MainWindow = CreateWindow(szAppName,
szTitle,
WS_VISIBLE | WS_POPUP,
0,
0,
240,
320,
NULL,
NULL,
hInstance,
NULL);

SHFullScreen(MainWindow, SHFS_HIDESTARTICON);
SHFullScreen(MainWindow, SHFS_HIDESIPBUTTON);
SHFullScreen(MainWindow, SHFS_HIDETASKBAR);
MoveWindow(MainWindow, 0, 0, 240, 320, TRUE);
ShowWindow(MainWindow, nCmdShow);
UpdateWindow(MainWindow);

// PocketHAL setup

display = Display::Create();
display->Initialize(MainWindow,params);

DrawSomething(); // draw for 5 secs

delete display;

return 0;
}

LRESULT CALLBACK MainProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hWnd, Message, wParam, lParam);
}

i Assume pocketHAL stand for pocket hardware abstractionor acceleration layer.

but where can i download from
It works for me...

I just created a new project, added 1 cpp file and pasted your code in...

Fixed the typo on line 102 - "Param" should be "lParam".

added the header and lib folders, and it ran.

FYI, there is a banner at the bottom that says "pocketHAL - technology prieview" for a couple of seconds, so even if you don't bother to draw anything, you should still see that.
Joost,

I tried it on my Dell Axim, and it worked fine...


Keep up the good work!
Hoping to see some real good stuff from you !!!

Jacques
Kzinti · 09 Oct 2003, 15:53 UTC — PocketHAL sample code
JoostB wrote:
However on my Ipaq3850 I notice the program is running for 5 secs, but unfortunately the screen stays untouched, just as the swap is doing nothing.
Can someone try this out on his device? just paste the code in evc++ it should compile.
I guess something is missing, but can't figure out


The iPAQ 3800 has this upside-down landscape screen. PocketHAL uses the following OEM string to identify it: "Compaq iPAQ H3800". Is it possible that the iPAQ 3850 returns a different string?

Could you try the following: call the GetModel() function and check if it returns MODEL_IPAQ_3800. If not, then I will need to know the OEM string of your Pocket PC. There is plenty of info on how to do this, let us know if you need help with it.


UPDATED: Ok I found the issue. It seems that the special case code for the iPAQ 3800 didn't make it in the release for some reason. This will be fixed in 0.0.2 (within the next few days).
freakedout wrote:
i Assume pocketHAL stand for pocket hardware abstractionor acceleration layer.

but where can i download from


You can get it at http://pockethal.droneship.com
Fixed the typo on line 102 - "Param" should be "lParam".

thanks,indeed, I edited the message, so it should be compiling ok now


UPDATED: Ok I found the issue. It seems that the special case code for the iPAQ 3800 didn't make it in the release for some reason. This will be fixed in 0.0.2 (within the next few days).

Great Thierry, I'll be happy to try it out for you as soon as it's there
Trying it on my old iPAQ 3650. Does not work. Device crashes after calling Swap(). Reset doesn't work either, so I have to to a master reset and clear all data on the thing. Pain :(

Update:
I tried with using ORIENTATION_WEST (same as ORIENTATION_LANDSCAPE / ORIENTATION_ROTATE90CCW). Then it did work. But that sortof removes one of the advantages with pHAL: seamless buffers that are just straight.
The crash with ORIENTATION_NORMAL is probably a small bug. I've e-mailed Thierry.
Malmer wrote:
Trying it on my old iPAQ 3650. Does not work. Device crashes after calling Swap(). Reset doesn't work either, so I have to to a master reset and clear all data on the thing. Pain :(


That's weird. I unfortunately don't have access to an iPAQ 3600. PocketHAL was tested on the E-125 (the only PPC 2000 device I have) and multiples PPC2002 StrongARM devices (Maestro, iPAQ 3800, ...).

Are you using the code above as-is?

Are you using PocketHAL "0.0.2b"?

Did anyone else experience similar problems?
I am using the code above as is.
I am using 0.0.2b

Everything works very smooth in ORIENTATION_WEST. It is when it comes to ORIENTATION_PORTRAIT things gets messy. Make sure you havn't missed something when it comes to blitting on a "west" device.

I can add to the info that the device does not have gx.dll installed (since it has been master reseted quite many times today), so PocketHAL can't use it as a last resort either.

Question is how willing people are to test on their iPAQ:s when it will result in a master reset ;)
The blitting to a "west" device works perfectly. It has to be something else.

Did you try it with GX.DLL the first time? (I assume you did).

Have you tried orientation EAST and SOUTH?
Thierry, I've had the same results on a compaq 3760.

When the program executes, all that is drawn is black stripe at the bottom of the screen. It seems to match up with the pocketHAL demo banner...

The device locks up big time, but with my case - the device will reset but not boot! (the bootloader (?) screen comes up, but it never loads the OS). The only way to get it to restart is to turn the power switch off, then on again.

Also tested the orientation thing that Malmer described (" params.m_orientation = ORIENTATION_WEST; " ) and the program ran fine.


Jason
OK, I will try to investigate this further tonight. I have a good idea what it could be.

I am unfortunately leaving for Italy this Saturday and won't have much time to look at it.
fast_rx wrote:
When the program executes, all that is drawn is black stripe at the bottom of the screen. It seems to match up with the pocketHAL demo banner...

The device locks up big time, but with my case - the device will reset but not boot! (the bootloader (?) screen comes up, but it never loads the OS). The only way to get it to restart is to turn the power switch off, then on again.


Exactly what happened to me, but you describe it so much better ;)
Thierry wrote:
Did you try it with GX.DLL the first time? (I assume you did).

Have you tried orientation EAST and SOUTH?


I've tried with GX. did not help.

EAST
Shows some pixels, then gives fatal application error (0xC0000005: Access violation). Debugger shows it is in: Blit16Rotated180 (appears to be in the calling order: swap - blit16rotated180 - blit16rotated180). Here is the asm for the line:
1E0139D8 ldrh r2, [r5, #2]

SOUTH:
Shows some pixels, then gives same error. Debugger shows it is in: Blit16RotatedCW. Same calling order (swap, then two blit16rotatedcw).
ASM and addr for that line:
1E013718 ldrh r10, [r10]


I have a feeling there is a miss with one line or so. Can quite easily happen when rotating. Think I had an issue like that once when multipling with the full 320 when it should had been 319.
I also tried the code with south and east... It caused the program to crash, but it didn't lock up hard.
From the comments you both provided me, I can only conclude the framebuffer address for rotated modes is not calculated properly.

This is really puzzling as it does work perfectly on the iPAQ 3900 which has the same "landscape" native mode.

I don't have the code here (I'm at work) but will try to take a look tonight.
Malmer wrote:
application error (0xC0000005: Access violation). Debugger shows it is in: Blit16Rotated180 (appears to be in the calling order: swap - blit16rotated180 - blit16rotated180)

SOUTH:
Debugger shows it is in: Blit16RotatedCW. Same calling order (swap, then two blit16rotatedcw).


This shouldn't happen. A blit function calling itself? There is definitely something wrong here.
Maybe that is why it hangs so bad in portrait...while writing to some memoryspace where it shouldn't, causing the bootloader to fail...
Rene Lindsay · 04 Mar 2004, 12:44 UTC — Jornada 710?
Does PocketHAL work with the Jornada 710 HPC2000?
I tried the above source-code, but it all it does, is maximise the window to full-screen for 5 seconds.
Is there a demo, or test-app somewhere, to test if PocketHAL actually works with my device?
Rene Lindsay wrote:Does PocketHAL work with the Jornada 710 HPC2000?


It should work as-is, although nobody has confirmed that this is the case.

Rene Lindsay wrote:I tried the above source-code, but it all it does, is maximise the window to full-screen for 5 seconds.


That's pretty much what it does.

Rene Lindsay wrote:Is there a demo, or test-app somewhere, to test if PocketHAL actually works with my device?


Unfortunately not yet... I am working on PocketFrog 0.8 right now and I am rewritting the samples so that they can work on any device. In case you are wondering, PF 0.8 will be based on PHAL 0.6.

Unfortunately not yet... I am working on PocketFrog 0.8 right now and I am rewritting the samples so that they can work on any device. In case you are wondering, PF 0.8 will be based on PHAL 0.6.


Do you mean that PF 0.8 and phal 0.6 will be unified? So, all the code written on PF 0.7 will be working on PF 0.8, with increased perfomace?
Whenever to expect such a great stuff? ;)

Er, and what about that phal splash screen?
xphere · 16 May 2004, 22:04 UTC — i can't compile...
I'm trying to compile this example.... but i can't make it work... :(
I'm very very new at this, and i've tried to compile this piece of code... with a very lamer result....
Every thing that I've tried to compile of pocketHAL make's me get the same error message:
Code:
D:\CodePocket\directHAL\simple.cpp(5) : error C2143: syntax error : missing ';' before '*'
D:\CodePocket\directHAL\simple.cpp(5) : error C2501: 'Display' : missing storage-class or type specifiers
D:\CodePocket\directHAL\simple.cpp(5) : error C2501: 'display' : missing storage-class or type specifiers
D:\CodePocket\directHAL\simple.cpp(6) : error C2146: syntax error : missing ';' before identifier 'params'
D:\CodePocket\directHAL\simple.cpp(6) : error C2501: 'DisplayParameters' : missing storage-class or type specifiers
D:\CodePocket\directHAL\simple.cpp(6) : fatal error C1004: unexpected end of file found
'

In line:
Code:
#include "include\pockethal.h"
#include "simple.h"


Display *display;
DisplayParameters params; //use default params


I've tried to include the libraries in the right folder and I've tried to put them locally, renamig all the header files (f.e.:#include <common/utility.h> -> #include "common/utility.h"), but I allways get the same error message....

Please help!!!

PD: Any caritetive soul can explain a step by step process to configure eVC for pocketHAL?

thanks in advance!!
Since this code was posted, all the PocketHAL stuff got its own namespace (PHAL). So put a "PHAL::" before all the pocketHAL things, or just be lazy and risk naming clashes with a using delcaration.
xphere · 19 May 2004, 21:08 UTC — thanks!!!
Thanks Andy!!! now all works!! ;)

time to code!! :D