PocketMatrix forums

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

EasyCE 1.6 release

Hey all,

I have just uploaded EasyCE 1.6. I'm working on the updated documentation; I expect to upload that later today. In the meantime, you can check out the latest version at this url:

http://www.pocketmatrix.com/phantom/easyce16.zip

So what's new? A lot. :) Here's a list:

  • Better screen handling for iPaq 3800 models
  • Faster line drawing code by Mirek
  • A basic sound class for loading and playing wavs
  • The tga class no longer expects wide character strings, wich makes it easier to develop for PC and PPC simultaneously
  • A new AAnim class for handling animated sprites
  • An actor class to ease the development of games in general
  • Some more...


This is quite a major upgrade, and I think everyone should switch over. The API hardly changed, but especially the 3800 code makes it very worthwhile to use 1.6 from now on. One last thing that didn't make it in yet is the improved message handling that Dan suggested; this will probably be added quite soon (I need it myself :) ).

The zip file contains a small sample project that compiles for both PC and PocketPC. The sample illustrates various concepts, but it's primarily intended to help you setup your own project for PC or PocketPC (there's quite a couple of settings that need to be just right).

The zipfile also contains the GAPI stuff for all major platforms, and my version of OpenPTC for debugging on a PC.

As I said, docs will follow shortly. Have fun!

- Jacco

Last modification: Phantom - 12/18/01 at 06:03:50
I see you decided not to include the palette device (HP525) in this release. Will you include it in future releases?

LLcooL :(Last modification: LLcooL - 12/18/01 at 08:59:19
I don't know if it was intended, but you are still printing that you detected a iPAQ3800 during each updatedisplay();
Ehm oops, yep, there's a debugging message in the 1.6 release. Well I'll leave it as an excercise to the coders to get rid of it. :)

About the palette code: It's a bit risky to include it; I can't test it... Anyway, if I find some time tomorrow I'll add it. That will be a 'beta feature', I'll wait for your comments before I call it 'stable'.Last modification: Phantom - 12/18/01 at 11:56:48
New bug. Sigh.
Phantom,

Is that in the palette code or some where else?

Cheers
Bad
BigCanoe · 19 Dec 2001, 09:49 UTC — Emulator
Can this be run in the PocketPC emulator?
The 'new bug' refers to a bug in the message board system of PocketMatrix, not to a bug in EasyCE. :) Sorry for the confusion.

About using EasyCE on the emulator: I have no idea, I never tried it. :) When I don't want to test on a PocketPC, I test on the PC (native) by compiling the project using Visual C++. This gives me all the advantages of native debugging, and it works great. This fails only when I encounter data alignment errors, but I suspect that the emulator doesn't crash on those either, so I don't see any reason at all to use the emulator.
New bug, will be else where as the palette code as not been released.

To test the palette code, Lemmings could be modified and release as a binary only to HP525 beta testers, the a demo beta version of the Nutcracker. :)
Here's a suggestion for the next release. :) I'm doing some experimenting, and noticed display problems due to my drawing the iPaq screen from the top down (portrait-wise). The iPaq does it's hardware drawing from left to right. I checked the EasyCE source and see you do the same thing I've been doing - always drawing relative to your backbuffer from top to bottom. Of course on the Casio that coincides with the hardware layout, but on the iPaq you really should draw exactly as the GAPI properties dictate, and jump around in your backbuffer appropriately. You can really see the effect of the "scan lines" during smooth scrolling if you are drawing perpendicular to them.

Dan East
LLCool,

I just looked through your 256 color stuff, and I'm afraid this approach is not going to work very well. First of all, you included a huge table (65536 elements). This is quite logical, since calculating this table will take about 1-2 secs on a PPC, wich is not nice, especially not if this would happen a couple of times at runtime. However, if you would load a tga file and you wanted to change the palette, this 'color cube' would have to be regenerated, wich would thus take 2 secs. You omitted this code, but adding it doesn't seem to make sense, because of the expected delays.

Right now, I've taken a different approach: I took your code to initialize the palette, and changed it so that it now essentially makes a 2-3-2 hicolor palette. Then, when updating the display, I turn each 16bit color (5-6-5) into an 8-bit color (2-3-2). This color is then plotted. Given the terrible color resolution, this would not look very good, but it would work, and it should work under all circumstances with unchanged code (outside EasyCE). So for the moment, I'll keep this.

There are two ways to improve the image quality: The first one is dithering; I could use the extra bits to address a dithering table. This would probably lift the image quality to an acceptable level.

The other way is less attractive: Simulate 3-4-3 or so using the 2-3-2 palette by rapidly changing the color value of each pixel. I did this to simulate 32 greyscales on 2 bit devices, but I don't know how good it would look on color devices. Biggest problem with this is that it requires calling 'update' as often as possible, but at least 50 times a second. That makes this approach unusable for The Nutcracker.

I'll upload my changes tomorrow; if you can verify that they at least work, then 525 owners can finally play all those cool games that work with EasyCE. :) It won't be pretty for the moment, but it should get better over time.

- Jacco.
GeoffSulcer · 19 Dec 2001, 16:05 UTC

I don't see any reason at all to use the emulator.


Except that eVC++ is free and VC++ is decidedly not free ;)

I've tried to use EasyCE with the emulator and haven't had any success.  First, EasyCE uses GAPI and Microsoft didn't include an emulator version of GAPI.  I tried a 3rd party GAPI that is supposed to work on the emulator but had no success getting that to work either.

I do most of my development directly to my PocketPC rather then the emulator, but it would be nice to test on the emulator too (faster debugging).

-Snork

Dan,

Excellent idea. Thanks for the suggestion. I'll modify the code. I'll also try to add that two-pixel-at-once stuff to improve the speed of the rotation somewhat.

- Jacco.
Peter Balogh · 19 Dec 2001, 18:54 UTC
I don't know if it's intentional in some way or not, but you're not using 'inline' too much.
I'm writing my own sprite engine (for games like 'Snails') and measured that function calls are damn slow. Using inlines can make you code bigger but can improve speed radically sometimes.
Anyway, you probably have your reasons, I was just curious...
Oh, and your actual drawing code seems to be long and difficult. Of course using them wisely they can probably be fast, but a simple getpixel has lots of opcodes... No offense meant, of course.
It's great that someone publishes this lot of code for free for pocketpc.
Phantom stated more then once once that all easyCE is supposed to do is giving a hardware independent access to a framebuffer, so you can develop without bothering about the device you run on

all extra's in easyCE are just for prototyping and definately NOT optimized :-)

Kind Regards,
Willem

Zensunni is right, all graphics primitives are slow implementations that I just hacked together to have something when I set up a project. Usually, my projects implement things like line and getpixel themselves (in fact, I would never use a plot or getpixel method, I would just address the pixels directly in the frame buffer), and that has a very good reason: Most of the times I use 'primitives', I need some odd special case, like alpha blended lines, thick lines or whatever. It's really rare that a default primitive does the job.

An exception is the sprite code, wich is optimized. It's a cut-and-paste job from The Nutcracker source code, and I made sure the code in that game is optimal. It is a large piece of source indeed, but if you study it closely you'll notice that it's basically a couple of if's that rapidly get you to the core code. The Nutcracker needs lots of flags to draw sprites: Some are alpha blended, sometimes I need white silhouette sprites (when the player is hit) and sometimes I want to mirror a sprite. But the code is absolutely fast, at least 'pretty fast'.

BTW, EasyCE 1.6 has some much more generic things, like an Actor class. Basically I'm taking a different road with EasyCE; I'm adding more stuff that I frequently need so that I can quickly build a game by adding just EasyCE. So by studying 1.6 you can see how I develop games. I use lots of actors. :)
Hi,

someone in this thread mentioned that there were problems using EasyCE on the emulator but it is working fine for me. I am using a modified version of EasyCE 1.5 and I think the only thing I changed was that GXOpenDisplay needs to be called with a win handle and not NULL, so my EasyCE looks like...

#ifdef _X86_
           GXOpenDisplay( hWnd, GX_FULLSCREEN );
#else
           GXOpenDisplay( NULL, GX_FULLSCREEN );
#endif

you might have to change some things to actually have a win handle when GXOpenDisplay is called.

This works really good for me, I have found all bugs (except aligment errors) with the emulator.
Thanks for the tip! I added the lines you proposed to EasyCE. As soon as I have the iPaq display code operational that Dan suggested I'll release 1.7. :)
Phantom,

Will you be posting 1.7 today? I am away for a week and wouldn't mind having an upto date copy for reading/understanding before I leave (in about 4 hours time)

Thanks
Bad
GeoffSulcer · 20 Dec 2001, 08:06 UTC
Anders,

What did you use for GAPI on the emulator?  
I tried to use the GAPI x86 Emulator by Thierry Tremblay but I get an exception error when I start my app.

Thanks,


-Snork
Dan,

I have tried the suggestion you made about moving through VRAM one pixel at a time rather than through the source buffer. Here's some code:

Code:

#if 0
     // Dan's way
     dst -= 319;
     src += 319 * 240;
     for ( int y = 0; y < 240; y++ )
     {
           PIXEL* lsrc = src;
           unsigned int* ldst = (unsigned int*)dst;
           for ( int x = 0; x < 160; x++ )
           {
                 *ldst++ = *lsrc + (*(lsrc - 240) << 16);
                 lsrc -= 480;
           }
           dst += 320;
           src++;
     }
#else
     // original way
     for ( int y = 0; y < 320; y++ )
     {
           PIXEL* ldst = dst;
           for ( int x = 0; x < 240; x++ )
           {
                 *(ldst) = *src++;
                 ldst += 320; // (xpitch >> 1);
           }
           dst += -1; // ypitch >> 1;
     }
#endif


And here's a suprise: Despite the fact that I am plotting two pixels at once in this code, it's A LOT slower than the original code. Some may want a further specification of 'A LOT': ;) Well, Crystal Balls ran fine at 50fps, it used about 80% of the 1/20th second to render the image. Most of this time is spend rendering the framebufefr, only a fraction is needed to do the actual update. With these modifications, Crystal Balls drops to less then 20fps, wich basically means that the update method just got 500-1000% slower, maybe even more. I have no explanation for this, but here's a guess: Apparently, violating every cache rule available is better when this happens in VRAM than in RAM. :) Moving 240 bytes backwards to retrieve each pixel is far worse then moving 1 pixel backwards to advance a line. Wich sounds logical in a way. :)

So, unless you really need smooth scrolling, this is not an option...

- Jacco.
Phantom,

--------------------------------------------------
I just looked through your 256 color stuff, and I'm afraid this approach is not going to work very well. First of all, you included a huge table (65536 elements).
--------------------------------------------------

This array is used as a lookup and avoids dithering calculations, GetNearestPaletteIndex, etc. And will give you a better result than converting from 5-6-5 to 2-3-2.

-------------------------------------------------
However, if you would load a tga file and you wanted to change the palette, this 'color cube' would have to be regenerated, wich would thus take 2 secs.
--------------------------------------------------

The 64k array is only update if a custom palette is use and then with 256 entries. Therefore changing the palette will be mseconds.
Using a custom palette will always give you the bests result.

I have tested the palette code on Lemmings, Bounce and AliCE all of which work and will run without a custom palette.

Maybe Nutcracker is unsutable for palette PPC's (This is your call) but alot of a games are and will be.

http://forums.pocketmatrix.com/forums/welcome.pl?board=Phantom&action=display&num=2769&start=12
Adam_Gregrowicz · 24 Dec 2001, 16:40 UTC
I change code which copy data from framebuffer into screen for iPaq 36xx, from:
Code:

for ( int y = 0; y < 320; y++ )
{
 PIXEL* ldst = dst;
 for ( int x = 0; x < 240; x++ )
 {
   *(ldst) = *src++;
   ldst += (xpitch>>1);
 }
 dst += (ypitch>>1);
}

into:
Code:

// only for 36xx - experimental, faster - AdamGr 2001.12.24
// tylko dla 36xx - eksperymentalna, szybasza metoda
for ( int y = 0; y < 320; y++ )
{
 PIXEL* ldst = dst;
 for ( int x = 0; x < 8; x++ )
 {
   // keep in cache as big code as possible
   // wpychamy do cache tyle kodu ile sie da
   // 30 x "*(ldst) = *src++; ldst += 320;" (30x8 = 240 pixels per line)
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
   *(ldst) = *src++; ldst += 320;
 }
 dst --;
}


Why? Simply for fun :)
Original code takes about 11,60 ms per frame. My code takes about 8,69 ms.
You can say: "It's only 2,91 ms!", but it's 25% faster!!! (to be honest it's 20-25%).
I don't know cache size in StrongARM, but this kind of optimisation may help speed up some functions.
By the way, i'm searching StrongARM deassembler (and assembler too).

PS
Of course my code works only for devices with xpitch == 640 and ypitch == -2 but it's only a draft.

PS
Feel free to correct my English :)
hey adam, nice to find someone from poland!:D well your function gives a pretty decent speedup and I guess it might be used in more places (esp. if someone is using tiles with a preset width, it might get a decent performace increase there):)
Thanks for sharing your code...

(polish now, sorry guys, too lazy...)
pozatym skad jestes? moze poznan?:)
wesolych swiat i narka, mam nadzieje, ze sie jeszcze spotkamy:)
Adam_Gregrowicz · 25 Dec 2001, 03:31 UTC
Hi,

In my opinion this type of loops should be written in pure assembler. This can speed up this function much more (I hope). I know that need diffrent code for every processor but in this library (EasyCE) it's acceptable (with C version for exotic/future processors).
Is it any way to include assembly code into project in eVC? (maybe as external OBJ or DLL - but how create OBJ or DLL from StrongARM (or any else pocketpc processor) assembly code?)

--
To Mirek: Jestem z Bydgoszczy.
Adam_Gregrowicz · 25 Dec 2001, 12:44 UTC
I just found /FA switch in project option in eVC.
So I look at my C code:
Series of "*(ldst) = *src++; ldst += 320;" was assembled into:
Code:

       ldrh      lr, [r2]
       add       r0, r0, #0xA, 26  ; 0x280 = 640
       add       r2, r2, #2
       strh      lr, [r0]
       add       r0, r0, #0xA, 26  ; 0x280 = 640

       ldrh      lr, [r2]
       add       r2, r2, #2
       strh      lr, [r0]
       add       r0, r0, #0xA, 26  ; 0x280 = 640

       ldrh      lr, [r2]
       add       r2, r2, #2
       strh      lr, [r0]
       add       r0, r0, #0xA, 26  ; 0x280 = 640
...

Next I try to remove one "add" by use "ldrh" with offset. C code was:
Code:

       *(ldst) = *(src+0);
       ldst += 320;
       *(ldst) = *(src+1);
       ldst += 320;
       *(ldst) = *(src+2);
       ldst += 320;
       *(ldst) = *(src+3);
       ldst += 320;
       *(ldst) = *(src+4);
       ldst += 320;
       *(ldst) = *(src+5);
       ldst += 320;
       *(ldst) = *(src+6);
       ldst += 320;
       *(ldst) = *(src+7);
       ldst += 320;
       src += 8;
(I put in loop (30x) - 8x30=240 pixels per line)

eVC assemble this C code into
Code:

       ldrh      r2, [r4]
       strh      r2, [r0]
       add       r0, r0, #0xA, 26  ; 0x280 = 640

       ldrh      r2, [r4, #2]
       strh      r2, [r0]
       add       r0, r0, #0xA, 26  ; 0x280 = 640

       ldrh      r2, [r4, #4]
       strh      r2, [r0]
       add       r0, r0, #0xA, 26  ; 0x280 = 640

       ldrh      r2, [r4, #6]
       strh      r2, [r0]
       add       r0, r0, #0xA, 26  ; 0x280 = 640
...
...
...

So, it translate into assembler really good.
Next I test speed of new procedure and... it isn't faster :(
Maybe "ldrh" with offset is slower than "ldrh" without offset and "add", or maybe beetwen read from main memory and write to display memory must be some type of delay. Or maybe I do something wrong?

Last modification: AdamGr - 12/25/01 at 10:44:38
hey,
particle actor class is great and easy to use!
Easyce would be the best lib,if it integrated a 3d engine.Maybe just phantom's stuff to load any 3d meshes.(http://members.tripodnet.nl/easyce/)
by the way..
how to play a sound with easyce1.5?(not in docs)
There are no description of the sound class in docs
Yeah, I forgot to document the sound class. Well it's really simple, just instantiate it using a filename as a parameter, and call the 'play' method to play it. It's a very simple encapsulation of the standard windows wave file playback, so there's no way to play multiple samples at once or to play mods.
ok ,thanks