EasyCE 2.0
I'm considering to start on EasyCE 2.0, because EasyCE 1.x is rapidly becoming a dirty pile of handy tools (perhaps it always have been a dirty pile of handy tools

).
Anyway, here are some basic ideas that I would like some feedback on before I start:
- EasyCE 2 will be initialized in the same manner as EasyCE 1.x, using a winmain in the library and a main in the application that you write. This way, I don't force anyone to use C++ code (except for some classes); one year ago that would have been reason enough to skip such a library for me.

- Instead of a pointer to the frame buffer and stuff like that I want a surface class that defaults to 240x320. That way, you can simply create a new surface, instead of a PIXEL array, if you want to swap screens or whatever. Copying from one surface to another would also require far less parameters and stuff like that. Would be generally better. The framebuffer would in that case be a special case surface.
- Surfaces can be 'rotated'. The hardware framebuffer of the iPaq is an example of this. Allowing this for all surfaces also makes it possible to use a 'rotated' temporary buffer (currently the 'internal EasyCE buffer') so that the app runs better on ARM devices (wich seem to take the lead at the moment), while still supporting MIPS.
- EasyCE 2.0 will come as a .lib instead of a .cpp and .h. That way, EasyCE can consist of multiple sources, wich will improve the maintainability.
- EasyCE 2.0 will be completely free.
- PC support will stay.
- 3D stuff will be added; initially my fixed point matrix and vector stuff plus basic polygon rasterizers.
- MikMod and ZLib will be added. These are libraries that you simply 'need'. I'll encapsulate them so that they can be replaced by alternatives when anyone feels like it without breaking apps that use EasyCE.
But the surface class is the most important thing. It would make things Easier, IMHO.
What do you guys think?
- Jacco.
If I understand #3 right, does that mean the backbuffer(s) can be rotated to match the native orientation of the hardware, so final display blitting can be performed in alignment with the scanlines? That would solve the smooth-scrolling issue I mentioned in another post (with landscape-hardware), without incurring the cache-thrashing penalties.
Dan East
I use a lock/unlock paradigm on my surfaces (similar to DDraw) that allows me to "swizzle" the surface data to any orientation necessary so that when the surface is blitted it will always be a sequential memory copy and won't have to perform a row/column translation. The rotation occurs during the call to unlock. This works well because the locking/unlocking is only done when I load the image from disk into the surface. I don't do any raw pixel access on a per-frame basis - just blits.
In case you're wondering there is also a rotation when the app locks a surface, since the surface is typically stored in a format unknown to the app. This "swizzling" can be controlled by the app though. The lock and unlock calls have parameters that let the API know if the data will be read-only, write-only, or read/write. Those flags determine whether or not a swizzling must take place.
Of course if you're running on a native portrait display none of this would be necessary, however this library supports any screen orientation and would have to swizzle if you wanted to display, say, landscape on a native portrait device.
Anyway, that was a bit longwinded and probably confusing. I hope at least Dan and Jacco understood it. What I tried to do was to minimize the work necessary to perform blits and flips (back to front buffer copy) since they are done each frame. Spending a bit more time in the loading of a surface to do the rotation once seemed like the better way to go.
Hey do you guys know if the newer ARM-based PocketPCs have their displays oriented like the iPaqs? The landscape orientation isn't just an ARM thing, is it?
I think I read somewhere that all the new ARM devices also have rotated framebuffers. I also agree about the "dirty pile of handy tools" (especially the handy part)
Anyway, I think that a surface class is a good idea. I like the idea of a Lock/Unlock to ease the conversionn from rotated/unrotated, but maybe that could be part of a subclass. A few extra things it could have are palletted mode (If I write a program with a pallette (like a demo effect), I have to store a whole extra temporary buffer, which could be eliminated if the conversion was in the blit to the screen. It could also help on palletted devices).
I also think that there should be more options to leave stuff out at compile time, for smaller exes.
You should also have optimized line/box/etc code, possibly even some assembly routines (probably would only be for the ARM, since that's the only one the new PPCs have, and the relative difficulty of assembly code). You should also have code for different types of tga files, and transparent conversion between them. Maybe even have a constructor for the Surface class that creates it from a targa. Some STL type stuff could be useful (linked lists, trees) seeing as how eVC left that out. (of course, you could just tell people to use the port for WinCE, but your version would probably be faster and less "crufty" (tm))
About the anti-c++ people

, maybe you could have a non-c++ function to update the screen using a EasyCE 1.x style PIXEL array. You could also have a similar "PlaySnd" function that would play raw sound data in an array.
It would be nice if you could add back the ce 2.1x support, I've already gotten two requests for Ce2.1x versions of one of my programs (and I just released it on monday).
For libraries, the source code would still be available of course, right?
Oh, Digby, I understood you perfectly well about the Lock/Unlock thing.
yea! finally in C++ !
erm... the lib better be separated by functionality, incase someone only want the graphics without sound... and some may have his better sprite handling routine..Last modification: sillycat - 12/29/01 at 17:55:25
C++? gosh didn't Carmack Quake2 source teach you anything?;P (and no, I don't mean that his code is unreadable...)
To be honest, I simple don't get all that C++ stuff so I prefer C:) going to read Stroustrap book in short future thru so I might understand it better;)
Thanks for the suggestions so far!
About the surfaces: My latest thoughts on this are like this: There is one special surface, that is the framebuffer. That one can be either portrait or landscape, landscape on all ARM devices. In my latest plans, this surface can't be written to using drawing primitives, it can only be updated by a call to 'update' (or something similar).
All other surfaces can be protrait or landscape: If you choose to have them all landscaped, the app will run faster on ARM PPC's (since the 'update' doesn't require rotation); portrait surfaces work faster on MIPS and SH3. Currently EasyCE uses only portrait since the slowest devices handle this more efficiently; the idea was that this would guarantee a more equal performance on all devices. With the large market share of ARM devices, it now seems more logical to aim for ARM devices and have MIPS / SH3 support as a 'nice to have'.
Since you will still be able to use primitives and pixel operations on surfaces, this means that either the app supports landscape or portrait (note that you can use landscape to draw a portrait image, of course, it's just the orientation of the buffer), or perhaps an application programmer chooses to support both (wich means double code for some things, but faster performance on all devices).
So, the 'primary surface' (the framebuffer) doesn't accept lines, plots and so on. Other surfaces do however, so all the current EasyCE drawing primitives will be methods of the surface class.
A call to 'update' will thus detect wether or not the source and / or destination surface is rotated, and it will convert if neccessary.
So far for my ideas. About palettized surfaces: This is an excellent idea. It would be very cool to be able to load a palettized tga and keep it palettized in memory; this saves a lot of space. A palletized surface will of course have a different set of drawing primitives (also palettized), and I don't think it will be possible to copy (part of) a 16bit surface to a palettized surface, unless the target is the primary surface (on 8bit devices).
About excluding parts of the library to keep EasyCE small: I was thinking about having a 'core.lib', containing the surface stuff and some more generic things (probably also the tga loader / saver wich is rather generic IMO) and besides that a '3d.lib', 'audio.lib' and 'game.lib' (containing the actor stuff, a.o.). That way you can link whatever you need.
Besides the surface class I'll also need a 'core class' that handles the mouse stuff, buttons, timers and so on (I want multiple timers this time). I'm not yet sure how this class will be instantiated; I think it must be created by the 'winmain', and after that you can retrieve a pointer or reference to it by calling 'getcore' or whatever. This could have been avoided by making EasyCE an application framework that you extend; as I mentioned earlier I don't like that approach since it's too 'C++'.

One more thing: I want sprites. Not like I did them in EasyCE 1.x, but I want to simulate a display that supports sprites natively. I think I'll attach them to the primary surface; when you call 'update', EasyCE will then first draw the sprites to the primary surface and then draw it. Pitfall: On some devices, modifications to the framebuffer are immediately visible, while on others, a call to 'GXEndDraw' is needed. So perhaps I should attach sprites to surfaces instead, but that would change the surface (you can't remove the sprites without refreshing the entire surface). A solution would be to have an internal backbuffer in the same format as the primary buffer, but that would slow down EasyCE. On the other hand, ARM devices don't need that, so performance would again be better on ARM than on MIPS and SH3... So the sprites still need some thought.
I would also like to add a C-Buffer to at least the primary surface. If you don't want to use it, you won't know it's there and it won't eat any performance. If you know how to use it, it can speed up some sprite operations (of simple sprites) and it is absolutely needed to speed up polygon rasterization.
Well enough babbling. I would really like some comments on the sprite issue. Perhaps I should forget about it and do it just like I did it in EasyCE 1.x.
Oh yeah one more thing: In ARM asm you can load multiple registers from memory with a single command. This could be used to get 24 pixels at once from the source surface and plot them on the primary surface. This trick could probably speed up the rotation significantly, and it is quite simple code to write.

Just an idea.
- Jacco.
Jacco if you're crafty enough, you can allocate the memory for your surfaces via CreateDibSection, and select the resulting bitmap handle into a memory DC. This allows you to return an HDC to the user and they can do things like draw lines, circles, ellipses, fill rects, and use TrueType text (all with varying ROPs) into the surface using GDI APIs. You won't want to do this for every surface because of the memory overhead necessary for the GDI objects, but you could offer the user a flag at surface creation time as to whether they were going to be using GDI with the surface. Just a thought.
Hm, I think the truetype text would be nice, but the rest of the stuff is not exactly what GDI is famous for... Besides, Windows is something I'm trying to evade.

Think mode 0x13h.

Does anyone know this: Does the address that the PocketTV dudes mentioned for framebuffer access on the 3800 also work on the 3600's? And, related to that: 3600's don't update the display until I issue a GXEndDraw command, if I'm right. That suggests the use of an intermediary buffer. Can that be prevented using the 'PocketTV address'?
The 3600s don't use an intermediate buffer. The address returned by GXBeginDraw is 0xAC05029E on my 3670. That is the address of the 0,0 pixel in portrait mode, so the actual start of the display buffer is 0xAC050020 (pixel 0,319).
The iPaq 3800 address is 0xAC0755A0. This is the address of the pixel 239,0 in portrait mode.
Hope that helps.
BTW, GDI is famous for providing a full set of 2D graphics drawing APIs for millions of programmers for well over 10 years. It is both a well-documented and well-understood API (certainly moreso that mode 0x13). The additional work necessary for you to provide an HDC to your surface is minimal. It would keep you from hearing things like, "Jacco, please implement TrueType text..." or "Please consider adding support for drawing circles and ellipses" or "Please write a image loader for bmp, gif, jpg, etc.". You get all of this for free with GDI and THAT is what it is famous for. I don't see how you can lose by adding support for these things. We're only talking about an additional dozen lines of code. However if your #1 mission is to evade Windows rather than provide useful features then you've made the right decision.
Correct me if I'm wrong, but for landscape surfaces you could just rotate the image on load (as previously mentioned and done I believe) and, as long as the frame buffer is 320x240 (in landscape orientation) then all one has to really rewrite is the flip routine correct?
If that's the case, then I'd just have a portrait flip and a landscape flip and a portrait load and a landscape load (for artwork). Maybe that'll take to much work on the user end though since you're writing a lib. I don't know. Just a thought. Unfortunately I have yet to buy an iPAQ so I haven't played with the whole portrait to landscape issue.
I like the palettized image support. In fact, it's something I implemented in my own libraries not to long ago.
Sounds like EasyCE is quickly turning in to what I've been doing with my own libraries

-Hosed
No intermediary buffer on the iPaq? Hm, that means that I probably need to assemble a temporary buffer in landscape format with the rotated framebuffer and the sprites in it. That's still one 240x320 memcpy extra compared to EasyCE 1.x... I'll need to time that memcpy to see what the penalty is.
About GDI: Please forgive me, but indeed, I do like to evade Windows. What you mentioned does sound cool however. It would indeed be nice to at least be able to do things, even if *I* don't plan to use them. Perhaps you could add this GDI stuff? It would probably take you far less time than me...
What do other coders think about this GDI stuff? Do you need it?
Jacco,
If I understand you correctly, it doesn't matter if you provide the back buffer or if the particular display buffer does... there will still be an additional copy taking place as the data is copied from the intermediate buffer to the primary surface.
Hosed,
If you use a back buffer that is oriented the same as the primary surface, and then you rotate the source content (sprites) when loaded, you don't need to rewrite the back buffer-to-primary update routine as it becomes a single contiguous copy operation. You do have to adjust the Blt (x,y) position of the sprites to handle the rotation though.
Digby,
Problem is; EasyCE 1.x lets you copy a freely accessible 240x320 buffer to the hardware frame buffer. That results in some nasty effects: Sometimes scrolling is a little jerky because of this. The only solution would be to use a third buffer that is used to draw the rotated image in (plus sprites), wich can then be copied in the fastest possible way to the hardware framebuffer. That should virtually eliminate the jerkyness.
However, desprite how good that is for all sorts of things, it's slower. And that sucks.
How about this: I offer the game programmer the choice: Either he uses a 320x240 buffer to hold the final image (rotations (if neccessary) and sprites) - This buffer would thus be the 'primary surface' and the hardware framebuffer would be 'hidden' to the programmer; OR he looses sprite support and accepts jerkyness, with the advantage of the raw speed of EasyCE 1.x (or even better, since you could use a 320x240 buffer in your game, so that the rotation could be skipped).
This 'choice' needs a good API, of course, and one of those needs to be the default modus of operation. The sprite + 320x240 buffer approach seems to be the most logical 'default modus', as it's really cool for most games.
One other thing: I gave the lock / unlock stuff some thought, but I think it's not going to work for EasyCE since I really want free access to the pixels of the surface. Perhaps some coders like to work with blits and primitives, but I like raw access.

All my games write to the frame buffer quite randomly in every frame, so a lock / unlock feature like you described would effectively result in TWO rotations per frame. That doesn't mean that the lock / unlock stuff is bad, it just doesn't fit in with my coding style.

Regarding the lock/unlock paradigm, similar to what DDraw does, you can lock only a subrect of the surface. That will keep you from having to rotate the entire surface. Using the read_only or write_only flags can also eliminate the need for one of the rotations.
My 2D code doesn't need to touch the raw pixels on a per-frame basis, but my 3D rasterizer sure does. In that case, the rasterizer works with a back buffer that is oriented the same as the primary surface. It works out well because on the iPaqs I just append another transform that rotates the vertices into landscape orientation.
Wow, you guys are really talking professional stuff! If everyone at PM was like you
a) We would be the leading Developer board
b) I wouldnt understand a word

Great job boys!
Aw come on, we (PM as a whole) ARE the ultimate coding board.

Everyone plays PocketQuake, everyone uses EasyCE, everyone waits for Argentum.

Back to Digby and the other coders: I've uploaded a small document describing the current plans. I'm implementing them right now, but finishing them will take more than just tonight.

I'm starting to like the idea of the three modi, it's comfort for starters and pure control for pro's. Can't beat that.
O yeah, that doc is here:
http://www.pocketmatrix.com/phantom/design.txt
hey,
about the GDI stuff, i think its a very cool idea. i would suggest doing it like it is done in directx, namely providing a GetDC() and ReleaseDC() method, and warning the developer that it will be very slow to use it

cryo
As Digby suggested, if instead of malloc'ing your bitmap arrays you use CreateDIBSection, then when the user wants a DC to draw to, you just CreateCompatibleDC, then select in your bitmap handle. Other benefits include the ability to fall back to Windows API for blitting out to the display, and emulator support. Everything I do in the Pocket PC emulator on my 300 mhz laptop with BitBlt to output to the window's DC is still faster than GAPI with my iPaq.
Dan East
If I recall correctly, isn't Quake and/or Doom Triple buffered? Obviously speed comparisons don't apply, just thought it was an interesting note. Dan would obviously know if this is true or not.
I personally don't much care for GDI, but Dan makes a good point, for Emu support it's the way to go. For my own uses I've just ported my libraries over to DirectX/Win32 and have a little PC based version of my game that I can test on. Combined with my modified asserts it's worked fairly well so far. I had other reasons for going that route though.
Also, I recommend using TCHARs instead of CHAR*. tchar.h I believe. It's what all Win32 programmers use to support unicode and ANSI seamlessly. You do still have to use the TEXT(), _T() macros, but that's a good thing in my opinion as it means you're truely platform independent in regards to unicode then.
-Hosed
Last modification: Hosed - 01/02/02 at 23:51:45
Not to my knowledge. WinQuake was using some 3rd party library for its Windows drawing, etc. It may have been triple buffered, but I didn't really look into it. I just chopped all that out and replaced it with my GAPI code. I take the main palettized bitmap and blit it out to the hardware, looking up the color values in the palette along the way. Quake2 handled all the Windows stuff itself.
Dan East
I've just read your plans for EasyCE 2.0.
I'm currently creating some C++ classes over the pure EasyCE1.6 functions.
Currently it has:
- ImageLoader class (TGA TGAZ)
- Surface class (target of draw and blit operations)
- Screen object (representing the device screen)
- Sprite class supporting:
o MIRROR_X/Y,ROTATION,R,G,B-FILTERING, COLORIZATION,GRAYSCALE,OUTLINE,ALPHABLENDING
o Supports several images for a single sprite (ie:ImageLists)
o Destination to any Surface object (not just the main screen buffer)
o Adjustable clipping rectangle
Planned:
o palettized image loading and support
o displaying sprites with false coloring
- FontWriter class
o Support for bitmap fonts
o Color support
o Fixed and proportional display (from the same
font data)
o Adjustable spacing
Planned:
o Word wrapping
o Line justification
An animation class is also in work (using the image list support of the Sprite class)
If it's intersting, I'm offering it as a starting point/prototype/source for ideas or whatever.
Regards, Rudolf
Sounds like cool stuff.

Looks like we have some overlapping features though. I implemented the skeleton of the surface stuff; I can now instantiate 4/8/16 bit surfaces, either landscape or portrait, and tonight I'll be able to convert between them (using slow default copiers, specific format-to-format converters will be added as needed).
Once the surface stuff is good enough I'll start adding handy things like sprite code, MikMod, Zlib and so on. I'm very interested in your sprite code, btw, sounds like quite a bit more advanced stuff than I had for 1.6.
I hope to have something to show ASAP (one week or so), after that we should really discuss how we can share our efforts. Especially now that everyone seems to be doing coding libraries. Frogs.

Anyone see the "PocketFrog" game library as reported on PocketGamer? Sounds like someone has been reading these threads...
http://www.pocketgamer.org/archives/00000720.shtml
Dan East
Now that I followed the link I posted, I see you have, Jacco!

Dan East
YAGA (yet another gapi abstraction)
It's interesting to read the features of the PocketFrog library. You'd swear the guy generated that list directly from our discussions here.
Jacco's right, there seems to be a dozen people working on different libraries for some reason. I don't really get it. I'd be happier if these folks spent their time writing games instead. (Jacco, you're off the hook here because you've actually shipped games using your lib)
Here's a theory, maybe these guys write libraries instead of games because they have trouble producing content for a game? Maybe one day when we get tremendously bored we could cajole a few of the more artistic members of PM to produce a dozen or so animated sprite characters, then have a contest against the bitheads here to write a game using those characters. It could be any genre of game, the only requirement would be that you'd have to use those sprites and have it run on the current crop of Pocket PC devices. Might be fun.
Hi all,
I don't agree with Digby in his affirmation regarding the developpers of new libraries for the PocketPC plataform. With new libraries, new ideas will come to scene, new functions will be implemented, and the end, programmers who develop games will have better tools to do their work.
In the case of the author of pocketfrog, he is also the author of the emulation gapi tool that exists, and that a lot a people works with, his frog library exists from some time now, but not for the pocketpc, and he has simply ported it and updated to new requirements.
Notherless, i agree that to much libraries will bring disperstion, and a lot of work will be leading to no where, but then may all is just a question of grouping the pocketpc developpers into groups instead of individual work.
In the linux community, all the major developments are distributed through teams that worldspread, instead of doing their lonely coding in the night...
I know that,because since I am trying to port the Allegro library to the PocketPc, i didn't received any solicitation to participate in the project.
I think that we are still in the infancy, and we must learn a lot with other communities which are a lot more organized and developped than ours... But then?Maybe in this environment (pocketpc) is orientaded in soon or later, create somekind of company and earn money from , and not create opensouce quality software.
regards,
Danyblue
Phantom:
easyCE 2.0 sounds extremely good

I'll definately make easy3D as an addon to that, and not go with own stuff. You are right concerning library development, there is no point in reinventing the weel, and easyCE 2.0 seems like it could be the ideal starting point for extension..
In response too to many libraries, yeah, there's a lot of public ones being developed. I myself am writing my own as EasyCE didn't meet the needs I wanted when I started my project and I'm so close to being done now that I see no point waiting for others to finish their own. That, and mine was never intended to be public, though that may change if I feel there's an actual need out there. With EasyCE 2.0 and other libs though I highly doubt people would want a lib that was aimed at more specific requirements.
-Hosed
I just noticed on PocketGamer that there is a new 2D library named GapiTools. The lib looks so good that I need to seriously look into it before I decide whether or not it's worthwhile to continue developing EasyCE 2.0. So if anyone spots anything in GapiTools that could be better, please post to this thread... So far, I see a couple of potential problems:
- The MFC stuff (I don't like MFC)
- The lib only supports ARM
But that's about it. The thing looks very fast, and seems to offer everything you could possibly need.
About EasyCE 2.0, I have implemented the core: 6 surface types: portrait & landscape surfaces in 4/8/16 bit. The base surface class can now convert between these formats, but that's implemented using a slow generic approach; for optimal performance I would need 36 converters, 6 per surface type to convert to all surface types. Of course, we could implement only the most often used ones first.
Before I start implementing those, I want some more functionality; I'm working on sprite support right now. That's a lot of work: Sprites draw from a surface to a surface. That means: 36 sprite routines... Right now, I intend to skip a couple: The source surface for sprites can only be 8 or 16 bit, and must be landscape. This reduces the number of sprite routines to 12, wich is still an aweful lot.
That's why I am considering dropping the project, it looks like it's going to be too much work.
Any ideas / encouraging words?

- Jacco.
and after a first short look it looks like the sourcecode for the actual library is not there, he ships it as a library..
i don't like that..
and after a first short look it looks like the sourcecode for the actual library is not there, he ships it as a library..
i don't like that..
and no grayscale/8bpp colour support, and only arm processors..
i don't like that either
Last modification: Zensunni - 01/09/02 at 08:41:42
Phantom,
I, for one, would most certainly hope you continue to work on EasyCE2.0 I've been using EasyCE for a few months now and your plans for 2.0 sound like they will provide some very nice things that I don't have currently.
There are three main reasons I chose to work with EasyCE versus other tools:
1. Platform-specific stuff is done. I don't have to worry about it (much). In other words, even though I only have a Casio E-125, I can develop code and have a (reasonable) chance that it will work on other devices as well. Therefore I spend more time on the game/app code.
2. Microsoft Windows and GAPI stuff is done. I'm not a fan of the Windows programming model, especially MFC. But, I do know C/C++, so having a main function and routines that handle the buffer and keypresses are just what I want. Again, I spend more time on game/app code.
3. It's free and I can make changes to the source when I need to.
So, unless you were planning to do away with any of those three, my guess is 2.0 will still be my choice. And, I'm betting that there are others that feel the same way.
Plus, I still use my Casio (MIPS) so anything that is ARM specific is useless to me.
Maybe you can just implement a few of the most commonly used converters and when you release it, some of us in the community can add in the rest as needed.
Anyway, keep up the good work, I look forward to 2.0 and more tutorials!
-Snork
Jacco,
You should do what makes you happy. From what I've seen, working on EasyCE does make you happy so that work should continue. As far as justification for your work: I would think there are enough people out there who don't want to use MFC that would like to use your library. Besides, you already have a version out there that some people are using. You've also got this great support forum for EasyCE here. I would think people aren't too keen on the GAPI Tools startup logo being shown everytime you run your app either. Libraries like this will continue to be released. Some day (and soon from what I've heard) Microsoft will release a DirectX implementation for the Pocket PC. At that point, most of the support for these YAGA libraries will wane.
I went to the GAPI Tools website and read this in their FAQ:
Q: How did you get that kind of graphics speed in all screen orientations?
A: GapiTools uses advanced pixel translations, and always transfers as many pixels as possible in chunks using 32-bit memory transfers. All bitmaps are converted to match the native screen format once they are loaded, and they also have to be recalculated each time the screen is rotated. All code is assember-optimized inline C++, and it has as much redundancy as possible to improve operating speed.
Gee, the part about loading the bitmaps and rotating them to the native orientation sounds really familiar...
You're right about the native orientation stuff.

About EasyCE: I'm a bit confused at the moment. The big issue is not the 4/8/16 bit stuff; ultimately, there will only be 16bit landscape stuff. Or even more ultimately, there will be arbitrary sized buffer stuff at arbitrary bitdepth, with 3D acceleration.

But for the moment, 'boosting PPC game coding' needs something more down-to-earth. The big issue is, IMHO, do we stick with the intuitive portrait orientation, do we permanently switch to landscape, or should we postpone a decision by offering surface rotation? Let me explain that: Rotation is a slow and basically unneccessary process that makes things harder: You can easily provide drawing primitives that make a landscape surface look like a portrait surface, but as soon as a user asks for a pointer to pixel data, you either start rotating (basically wasting time), or you confuse the user.
Perhaps I should never have started on that stuff. Perhaps EasyCE 2.0 should do what EasyCE 1 did: Offer a canvas that is the same for all devices, but this time a landscape one. An update will copy it to the iPaq frame buffer, or rotate it to the Casio frame buffer. That way, the strong become stronger, while the weak can temporarily join the fun, at a reduced speed. Later on, we drop portrait support altogether.
Right now, doing a sprite engine that supports all those surface formats just doesn't make sense. The best solution would be to make one generic sprite engine that handles all surface formats. That way, once 640x480 PPC's appear, the sprite library is still useful. Same goes for 3D stuff, drawing primitives and so on.
There are some things certain, IMO: Such a dedicated sprite library would be valuable for at least 3 more years. I think the PPC form factor / screen resolution will be used for at least that long. 3D acceleration won't be with us soon, meaning that 2D stuff will always be interesting. FPU's won't arrive soon, making 3D acceleration even less likely (what would a GeForce be without an FPU?

) - So a generic software rasterizer would be interesting. In fact, I think I'll focus on that for a while.

I'm really interested in your opinions on these matters. I'm going through a bit of an identity crisis right now.

In short: GapiTools looks awesome and unbeatable, but I'm rapidly becoming a 'rotation maddness skeptic'.
GapiTools looks awesome and unbeatable
I disagree. As I said, limiting to ARM only is a huge drawback, IMO. There are still a lot of MIPS and SH3 devices around and I don't see them going away anytime soon.
On the other hand, all of the PPC2002 are ARM and if they all have the landscape rotation, then that is certainly the default and those of us with portrait will either suffer the performance penalty, or alter the EasyCE source to suit our particular need.
Personally, I'd love to see some more stuff added to EasyCE for 3D software rendering. That's the stuff that I am looking for now. But, having the library itself improved is good and I have some ideas for sprite-based games that I may try too.
Oh and one more thing: I think there are a heck of a lot of us that have learned a lot by playing with EasyCE, talking about it, and in general, benefitting from Jacco's experience. I'd say the discussion so far has been educational and seeing EasyCE move forward would be even more so.
Okay, enough rambling!
-Snork
I think the following:
- EasyCE is worth continuing with even with GapiTools for several reasons (MFC, no source, ARM only, etc)
- Digby is right; do what you want to do. But...
- If you decide to work on something else, release what you have now for us to play with. Maybe someone could start a project on sourceforge with it or something. (That might be a good idea regardless)
I also think a lot more than that, but to list it all PocketMatrix would need a server with
much more memory.
Last modification: billcow - 01/09/02 at 13:31:02
Phantom,
I have checked GapiTools and other similar stuff (DieselEngine) and my preference is still EasyCE over the others:
Opinions on GapiTools:
pros:
- fast (have not tested, but seems to be

- support for different screen orientations
cons:
- ARM only
- no sources only libs
- MFC is an unnecessary dependency in my mind
- not object oriented
- does not abstract fully from the Windows programming model (you still use events for keypresses etc and the winmain stuff is also present)
- no real sprite support (just blit operations)
- no EMULATION on PC !!!
DieselEngine:
pros:
- nice blit effects
- free image rotation/scretching
- PC mode
cons:
- no sources
- no real sprite support (as far as I remeber), just support for surfaces and blitting them.
In general I'm rather reluctant to use something that is not accessible in source form, becuase even if the thing meets your requirements, bugs can be found in the lib and you are depending on someone else... I would be rather happy with a component having a BSD license or something similar (BTW what license do you plan for EasyCE?)
In my mind speed isn't everything. Usually I prefer more functionality, ease of use and code maintanablility than raw speed. (ok it's nice to have, but I would rather sacrify it if that would lock to ARM and would not allow debugging on PC).
IMHO EasyCE is still the best choice for me and I hope you will continue (and enjoy) it...
As for technical stuff: I think ARM devices will rule the world and EasyCE 2.0 should be optimized for them, but at this time the support for other devices is still important...
As you suggested there is a lot of work to be done regarding the conversion between different surface types and regarding sprite drawing.
My question is: Do You(we) need really such a generic approach to have both landscape/portrait and 4/8/16 bit surfaces for both the source and destination of the copy/blit operations? You could consider dropping some of them to ease the development:
- ARM devices will have landscape
- Does it really make sense to have 4/8 bit surfaces as a destination? Ok maybe the update() function should be able to convert from 16 bit to the device specific format (but that's only 3x2 function in worst case, not to mention how many pallettized/grayscale device exists...maybe some can be droped)
- IMHO the source of the blit op can be a 8 or 16 bit surface (I see no reasons for having a 4 bit sprite) this would also decrease the amount of work...
I propose:
8/16 bit Landscape surface (sprite)
blit to
16 bit Landscape back buffer surface
blit to
Hardware specific buffer (device screen)
(4?/8?/16 bit Landscape/Portrait)
The middle layer (16bit lsc back buffer) can be optional, if the device screen has similar characteristic)
What do you/the others think?
Rudolf
PS: I have sent you my sprite code in mail (it's just 16->16 bit)
Phantom:
It would too bad that you just quit the development of your library because there are other that are appearing into scene.
I have been working with your libraries for other 6 months now, and they are great. In the beginning i did miss more primitives to do some work, but then I had added them simply to your core library.
When I began, Your library allowed me to go forward because there just wern't anyother proper tool to develop. I even sent you some e-mails asking help, which were rapidly and effectivly answered.
So i think you should keep going on. If the work is too much then just open source code with you as project manager, i am sure that a lot of the people who are participating in your forum would jump to the "train" .
My thanks to you and to your work,
Danyblue
Danyblue, Rudolf, others:
Thanks for your support; I appreciate it. I know btw that EasyCE has helped a lot of coders, and I too enjoyed the discussions on this forum very much. I even bet that some of the other libraries borrowed ideas from EasyCE, or took advantage of discussions on this forum. Whatever, EasyCE helped coders and it was fun. So no hard feelings.

The problem is the current development of EasyCE 2.0. At the same time that I found out that the development would require a huge amount of time, 2D libs popped up everywhere. To make things worse, I started to doubt the whole generic surface idea, wich is the basis of EasyCE 2.0, and also of GapiTools.
I agree with you guys that there is still need for something called 'EasyCE 2.0', especially because the others are not open source. I also think Rudolf has some very good points.
Right now, I would like to propose the following:
EasyCE 1.6 will be enhanced with a surface class. This class will ease the use of sprites and all other buffers. You will be able to load a tga to a surface directly, or to create a surface using just a filename as a parameter. These are Good Things, even if the main philosophy behind EasyCE 2.0 (as I described it earlier) sucks.
Another Good Thing is the 'hardware sprite emulation' that I proposed.
Also 'Good' are 8-bit surfaces, to bring down memory consumption.
So, I would like to hear your opinions on the following modifications to EasyCE 1.6:
EasyCE 1.7 (or whatever) will use a landscape buffer by default. There will be three 'surfaces': The hardware framebuffer (in a format that could be anything); the primary surface (16bit, landscape) and the secondary surface (also 16 bit, landscape). The primary surface is neccessary for the 'hardware sprite emulation', and can be skipped if this feature is not used (spritecount = zero). The format of the primary buffer is optimized for iPaqs and will result in optimal performance and minimal tearing on these devices. Support for all other devices is considered 'less important' and will therefore be less optimal.
This way, sprite code and primitives will only need to worry about 16bit landscape surfaces. The only code that needs to support many surface formats is the code that copies from a 16bit landscape buffer to a 4/8/16bit landscape/portrait buffer. That's 6 routines, and most of them are available in EasyCE 1.6 already. I consider that 'manageable'.
Forgot one thing: An 8-bit surface can be used as a source surface for sprite operation and image blits. You can never blit TO an 8-bit surface (although this will happen internally on 8-bit devices, but that's device specific stuff); but being able to blit from them is useful for 8-bit image data.
After these enhancements, I think EasyCE 1.7 will be significantly better than 1.6, and interesting for everyone, even if there are other libs. We can do the blitters in asm, to get perfect performance. And all other code should go to dedicated libraries anyway.
This stuff can be done in little time, and doesn't require throwing away the 1.6 code. I like it.

Hello Phantom,
I'm totally agree with the above approach so go ahead please... Also have some questions/ideas:
- Would it be hard to implement the blitting in a way that during the library/primarybuffer initialization you could state that yo would like to get a rotated screen? (ie left or right landscape mode) this case the primary/secondary surface would be 320x240 instead of the standard 240x320 (ok it may incrase the number of required blitting routines, but maybe they can be written in a clever way to have common code and be still optimal)
Thanks
Rudolf,
The idea is to have 320x240 by default to get the highest possible performance on ARM devices. So basically, with the latest plans, every EasyCE app would be landscape. If you want a portrait app, you still fill a landscape surface, but you do that rotated in your own app.
I want the primary surface to be the same format as the iPaq frame buffer so I can do the fastest possible blit from that buffer to the frame buffer. That way, you get less tearing than with EasyCE 1.6.
Jacco,
Wouldn't you need to support two different landscape modes since the iPaq 3800 series is "inverted" landscape (compared to the 36xx devices)? Or are you going to perform a rotation for the 3800s similar to the Casios?
Phantom,
I think a big strength of your EasyCE for me (besides the abstraction from WinMain etc.) was the excellent tutorials for getting started. Your constant presence on this board is great too.
Perhaps after the next minor update of EasyCE, you could consider an update and/or extension of the tutorials. It seems many of the items which have been discussed over the last couple of months are leaving them behind a bit!
well, I have heard that those new IPAQ's have got an inverted screen, but god, how can this be??? Someone is boring himself at his design desk to create such stupid solutions? The PPC platform could be great, by going the "one processor" route it becomes a great platform to develop for, but no... let's make things "better" and invert the screen.
Someone is interested in making PPC go the PC route - make uncompatible hardware and don't care about developers at all?
I wouldn't like to see the same thing happening with additional sound/graphic processing cards, but as it seems the PPC will become developing hell just like the PC. If they can't make their device use the same screen buffer what will happen if few graphic/sound card vendors appear???
God bless PPC hardware design staff.
It does seem to be that every single ppc has a different screen layout. Soon they will have to stop adding new ones though, they will have run out of new possible ways to do it!
At least with ppc2002 we can use arm assembler on all machines.
Perhaps it is best to just use one screen buffer format, optimise all blits for that format, then have an arm assembler function which rotates the buffer when it is copied to the screen.
Does anyone know if the newer Pocket PCs that use the StrongARM have rotated displays like the iPaqs? Is there any StrongARM-based Pocket PC that has a native portrait oriented display?
I have heard that the Jornada 56x has the same layout as the 54x
They will all be different, life is like that

Aargh, yep, that's true. 3800's have a different screen orientation than 3600's... So it doesn't make sense to have just a single landscape mode in EasyCE: We'll need to rotate anyway. In that case, perhaps it's better to stick with the EasyCE 1.6 approach of having an internal 240x320 16-bit buffer and convert from there? It would definitely be the most intuitive approach, and surfaces would still enhance even this approach.

Major drawback is the sprite stuff: I was hoping to draw sprites to a buffer that is in the same format as the frame buffer. That way, the final display, including sprites, could be copied to the frame buffer in the fastest possible way. But if the frame buffer can be in two different orientations on the iPaq series alone, the sprite code AGAIN needs two versions... And probably three or more once more weird ARM devices pop up.

Well I still want to do the rotation to an intermediary buffer and draw sprites on that buffer too. I like the idea of hardware sprites, and for the moment, I won't let it go.

Hi all,
I would probably make the figure of a fool to suggest the following addon, but i think that it is something very important for anyone that will developping code through the next platform evolutions.
The question is the following, at this moment the standard resolution is 240x320 pixels, with various flavors of colors (12 Bits, 16 bits, 8 bit) etc.
There are already to software that are doing the emulation of higher resolutions,like Jymmy and Nydot.
When you develop and application or a a game the standard resolution come to short, so i would like to put to the general thinking that it wouldn't be nice to include a mechanism that could define/emulate higher screen resolutions or just implement them if available on the device.
I don't know if it would be too much work to include this in EasyCE, but i really think that it would be a key feature.
Regards,
Danyblue
I think it's quite possible. The problems with EasyCE 2.0 had nothing to do with resolution; in fact, the code on my HD supports arbitray resolutions (you need that to copy from / to sprite surfaces that are not 240x320).
You could even make it so that if you copy a 240x320 buffer to a 640x240 buffer (on a HPC), you would simply just fill the left half of the HPC screen. Or to put it simpler: EasyCE 1.7 should allow copies between surfaces that are not equally sized.
The problem with EasyCE 2.0 is that I wanted to support blits between rotated landscapes in various bitdepth. All problems are gone if I assume a single format buffer that is used by the application programmer.
There are only 3 processors running PocketPC at the moment: SH3, MIPS and StrongARM.
There are assemblers available for everyone of them so wouldn't be a good idea to write a asm library for each processor with only one functions:
void easyce_updateframe(easyce_buffer,x,y,width)
The resulting .obj file would then be linked to the project and called from updatedisplay() in EasyCE.
The docs for SH3, MIPS and StrongARM are readily available and the routine should be very easy to write and optimize.
Comments?
Karl,
Writing ASM blitters for all processors is definitely the way to go, and quite feasible too.
I'm trying to figure out however how internal surface management should be done. EasyCE 1.6 uses a fixed frame buffer, 240x320 pixels, 16bit, and converts that to the native format of the device that you run on.
This has a disadvantage: On iPaqs (and all other current ARM devices), this requires a rotation. This obviously is slower than a raw copy, and to make things worse, by far the fastest way to do this copy is by fetching pixels sequentially and writing them to the rotated positions instead of writing them sequentially. The problem with that is that you might experience some tearing, when the LCD updates during the execution of the rotation code.
That's why I'm considering adding another buffer. You still work with a 240x320 buffer, but it gets rotated to another offscreen buffer, wich is ready to be blitted to the frame buffer. Of course, that means an extra blit. To make up for that, I wanted to add hardware sprite emulation. Instead of the EasyCE 1.6, wich stay right where you drawed them until you paint something over them, having an intermediate buffer would allow for 'true hardware sprites' that move independently of the buffer contents.
That does mean however that the sprite code needs to be able to draw to all surface formats that the intermediate buffer could possibly have. That's at least 3 versions: One for portrait 240x320, one for 3600 landscape and one for 3800 landscape.
I hope it's clear this way.

- Jacco.
Thanks for the explaination Jacco.
Couldn't the asm function handle the rotation as well, using lookup tables or whatever? the 3800.asm object file would rotate and then blit, the mips.asm would just blit, etc, etc.
That way all drawing would be onto the EasyCE buffer[240x320] in C which then would blit using the asm function in the update().
IMHO the sprites in 1.6 are more than sufficient. I love the simplicity of your library.
Cheers
Karl
Karl,
I agree that the sprite system of 1.6 is sufficient for most applications, but in some cases, you redraw the backdrop just because you're moving sprites and you're too lazy to implement dirty rectangles.

So I figured, since all ARM devices require rotation and thus the intermediate buffer, I might just as well make good use of it and draw sprites on the intermediate buffer. You could simply split the asm code in two parts (rotating & blitting) and execute the sprite code in between. Would be quite cool and fast.

Only drawback is the boring sprite code in three versions.
- Jacco.
P.S. Register! You know you like it here.
Last modification: Phantom - 01/11/02 at 09:21:51
Jacco wrote:
This has a disadvantage: On iPaqs (and all other current ARM devices), this requires a rotation. This obviously is slower than a raw copy, and to make things worse, by far the fastest way to do this copy is by fetching pixels sequentially and writing them to the rotated positions instead of writing them sequentially. The problem with that is that you might experience some tearing, when the LCD updates during the execution of the rotation code.
Do you have any metrics on how long this rotation takes? I'm interested in the perf difference between reading sequentially and writing sequentially.
I would guess the reason why it's faster to read sequentially is that you're reading from system memory which is cached. I'm not sure, but I believe the display memory isn't cached so you won't see any advantage to writing to sequential addresses.
If your app does nothing but copy the contents of a back buffer to display memory and rotates along the way, what is the maximum frame rate you can achieve?
I bet you want precise figures.

Well I'm too lazy to send a test app to my iPaq.

Anyway, two weeks ago or so I was experimenting with Dan's suggestion to write sequentially in order to reduce tearing. Using that approach, I couldn't get anything faster than about 12fps (I would say, GDI performance

). I'm not sure about the regular rotate that EasyCE is using, but Crystal Balls (you know, that mysterious, almost mythical game) runs at 50fps and that still leaves me enough time to do some pretty heavy drawing. So I would say that about 70fps or more is possible with my C implementation of the rotation technique. No asm in the world is going to get that to 200 fps (Douglas Beck claims that speed on an iPaq, without rotation I suppose) but 100+ fps would be close enough for me. After all it's just the display blit. I read that the iPaq physically updates the LCD 25 times a second, so 25 fps should be enough.

- Jacco.
Digby:it was said in some recent posts, a memcpy takes 5ms on ipaq (200fps), a ipaq special case copy function (using words but assuming all the values to add etc) takes about 10ms (100fps) , a very general approach by myself (could be surelly optimized because for ex. I do >>1 to get proper values instead precalculating it while getting this info from gapi) i get about 60-66fps(probably it could be easily hyped to 70 or so)
Well the difference is quite obvious, as the 10ms one takes (to get full 24fps) 240ms while the 5ms one takes 120ms, nice 12% cpu time more for other stuff. I believe the 10ms could be easily optimized assuming you will get a kickass routine that loads and stores dwords and switches the words in registers (assuming it's possible on ipaqs, like mov bx,ax on PC), as it seems the only point where this function is slower is the data read/write because it takes exactly 100% more time to read/write 2 words instead 1 dword.
So if someone came up with a decent implementation of something like:
1.read two dwords from backbuffer(assuming we're converting from 240x320 to ipaq 320x240 the pixels would be 0,0 and 0,1 for first dword and 1,0 and 1,1 for second dword or so)
2.exchange the word placement so we get two dwords like (0,0 and 1,0 for the first one and 0,1 and 1,1 for the second one)
3.store two dwords
possible you would want to use 4dwords at a time or so to prevent stalls (not exactly sure how Arm chip works, I'm pretty much speaking now like we would have an 80x86 cpu)
so this is my idea, it would have to be slightly changed depending on the device, but it should enable us to, hopefully, get closer to the 5ms mark per backbuffer->frontbuffer copy and use a 240x320 (or 320x240) surface all the time.
Unfortunately, the ARM cpu, unlike the x86, only allows access to the entire 32-bits at once. I know this is also true on the SH3, but I haven't done any assembly programming on the MIPS, so it might be possible on that, but it's a moot point because all the MIPS PPCs have regular (240x320) framebuffers, and don't require rotating.
Hi all,
I'm kind of new to this forum, but I am not new to graphics programming for the Pocket PC.
I have tried most approaches of implementing fast landscape support for the Pocket PC, and the only feasible solution I found was to access all pixel surfaces (buffers) in a format compatible with the display format and avoid rotating at all costs. GapiTools does not perform a single rotation on any device (except for precalced bitmaps conversion).
This approach requires a bit more logic in the drawing functions, to translate the coordinates used for drawing and flip x/y loops to optimize speed (n+1 is faster than n+240 for example), but the increase in speed for copying a pixel surface to the display more than makes up for it.
All simple blits in GapiTools are done by using fast 32-bit memory loops. Factors such as analyzing pixel strip length to decrease loop counts, stepping in the smallest direction with respect to x/y pitch and re-using word alignments can also be used to increase speed further (unless an entire surface is to be copied as a memory block).
The overhead in translating the coordinates in each drawing function does not involve too much logic, and the performance drawback is most visible using single SetPixel/GetPixel accesses.
With all new screens emerging on the Pocket PC, I personally believe that direct drawing to a screen buffer (using raw mem pointer access) should be avoided at all costs, and let a thin middleware (such as the one implemented in GapiTools) do all coordinate transformations. Which is a shame because of the overhead requirements.. In a perfect world all PDA's have perfectly aligned screen buffers.
Best regards,
Johan Sanneblad
www.gapitools.com
<<<Removed>>>
FYI, I've started a new topic in the General Developer Discussion forum on rotated blit performance.
Here's a link:
Rotated Blits