PocketMatrix forums

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

PocketFrog 2?

I have just put my hands on an Audiovox Maestro for a good price. I intend on resuming work on that "next graphic library" I was thinking about.

PocketFrog as it is was a nice experiment but I feel it is too limited in both flexibility and ease of use for newcomers to the world of C++.

You can expect a major rework of the functionality set and a speed increase over previously existing graphics toolkits.

The current plan is to have a low-level hardware abstraction layer (HAL) which will be optimized for each device. On top of that, a framework similar to PocketFrog 0.x will be built.

Source code for the HAL won't be available for obvious reasons. But complete source code to the framework will be.

I don't have a time estimate yet as I have to spend some time doing research and developement to validate a few ideas I have. But rest assured, PocketFrog ain't dead yet. Like a phoenix, it will be reborn from it's (not quite yet) ashes.

Thierry
The question is how interesting performance improvements really are. I mean, since it's all basically memory copy operations, it can't be much faster than reading 32-bits and writing 32-bits, perhaps with variable loop unrolling optimized for the instruction cache of the device (this is one of the features of the GapiDraw HAL btw - which is individually optimized for each device, considering data and instruction cache among other features, even taking advantage of hardware blitters).

I'm also not sure if it's a good thing changing the API. PocketFrog have a group of fellow supporters (like Conan and fzammetti). They use PocketFrog since they really like the current API. Letting them know that the PocketFrog API will change significantly sometime in the future might put them off both from (a) continue development on the current platform since all this work probably will be worth nothing once the new HAL is in place, and (b) continue using PocketFrog since they are not motivated on expanding it further.

On GapiDraw we are currently working on providing support for more devices (outside the Microsoft sphere), something I would argue could be more important than features or performance improvements.
sbl wrote:
The question is how interesting performance improvements really are


The question is "what does that question really means coming from someone who always sell GapiDraw as being the fastest toolkit and getting faster all the time".

sbl wrote:
I mean, since it's all basically memory copy operations, it can't be much faster than reading 32-bits and writing 32-bits, perhaps with variable loop


It's not all about memory copy operations. There is other issues like synchronizing with the refresh rate, providing multiple video buffers for true double/tripple buffering, using hardware accelerated raster operations (ROPS), ... Trust me, there is a lot more to be done on the PPC.

sbl wrote:
I'm also not sure if it's a good thing changing the API. PocketFrog have a group of fellow supporters (like Conan and fzammetti). They use PocketFrog since they really like the current API. Letting them know that the PocketFrog API will change significantly sometime in the future (...)


I have no intention of changing the current API except by extending it. Any program written for PocketFrog 0.x will recompile as-is (or with very minor modification). My plan is to get the HAL running on most devices out there and then replace the current "driver" architecture of PocketFrog with it. Specifically, this is the code residing in the "internal" namespace. Code that application developpers aren't using.

sbl wrote:
(a) continue development on the current platform since all this work probably will be worth nothing once the new HAL is in place


Quite the contrary. Games written for PocketFrog v0.x will benefit greatly from this new HAL that will replace the low-level code and some part of the rasterizers.

sbl wrote:
(b) continue using PocketFrog since they are not motivated on expanding it further.


I keep the high level stuff to them. They know more then me what they want. They also have more time to do it. My hope is that this time we will be a time working on this, not me alone.


On GapiDraw we are currently working on providing support for more devices (outside the Microsoft sphere), something I would argue could be more important than features or performance improvements.


It depends on what your project goals are. If for you it's "more platforms", so be it. For me, PocketFrog always has been about getting the most out of my Pocket PCs. I couldn't care less about Smartphone and other devices. (Which BTW doesn't mean PocketFrog won't work on them.)

Thierry
The question is "what does that question really means coming from someone who always sell GapiDraw as being the fastest toolkit and getting faster all the time"


Agreed. While performance is important, if I had the choice now I think I might have implemented GapiDraw on more platforms instead of focusing that hard on performance... I really think the new Sony Ericsson devices such as the P800 are cool, as are the new NGage Nokias... Then, the new Palm Zire is also kind of nice..

I think it's good to hear that you are still active in the Pocket PC camp.. I need some new C++ benchmarks to compare to... :) Also it's nice to hear that the PocketFrog API will keep the same...
interesting news. With some of the current crop of PF programmers already running successful tests in GapiDraw I hope the new PF comes along quite soon or there will have been quite a brain drain.

I'm 'forced' to look at GD now that PocketGL has been successfully bolted on by another coder just to see what the performance is like but no plans to convert from PF as my current game is only half written.
I agree with Thierry and I think I understand him, his goal is not to make a new killer api and forget pocket frog, but insted, rebuilt pocketfrog with more knowledge that he acquired with time, with the same goals as the original pocketfrog, but more powerful.
I think this is great... PocketFrog was kind of a first cruzade into making a simple use api for game programming ( or any other visual application ) for people that just don´t like ( or care about) how directX works and things like that, focusing on the people that want to just take the max that they can from the pocket pc hardware with direct and simple instructions, and now, pocket frog 2 ( or whatever other name ) will incorporate all the knowledge gathered from the time that pocketfrog 1 is alive on the hand of the ones who really like it and added with some powerful knowledge of how to improve on lower levels the performance and on even lower levels some specific instructions for some hardware in special.

And thats for me it just great. I´m ready for the big step 8)
I have been conducting some research tonight in the hope of speeding up a straight fullscreen copy of a backbuffer in system memory to the display (GAPI). This blit is usually done using a single call to memcpy() and takes roughly 4.7 ms to execute.

I have found a way to speed this up by a factor of 2. My blit executes in just under 2.2 ms. This result in a theorical maximum of 455 FPS.

I have serious reasons to believe that similar improvements can be achieved with a 90 degrees rotation (or even a 180 degrees one). What's more, there is still a few ideas I haven't tried yet.

The tests were conducted on a plain (unmodified) Audiovox Maestro that is running the StrongARM processor at 206mhz.
Let me know if you want anything tested. I have a Dell Axim which runs at 400 or 200 Mhz plus an iPaq 3650 arm machine.

My interest in this area is getting PocketGL to write directly to PF's back buffer instead of it's own as this causes me to have to do a copy involving a lock & unlock and I lose lots of FPS. It's been done with GapiDraw recently so must be possible with PF however I have not managed yet with the current version.
The question is how interesting performance improvements really are. I mean, since it's all basically memory copy operations,


The thing is that for most libraries the steps go like this:
1. copy bitmaps to a buffer (or rasterise to it if you like)
2. memcpy the resulting buffer to the video memory
3. repeat

Which is pretty slow. On quite a few devices, stage 2 can be removed and the DMA system "adjusted"/"hijacked" to use more than one bank. Then you can start doing more interesting things. For example, if you're plotting (fairly) linearly and are happy to put up with a small (tiny) amount of display "errors", you could turn the on the caching and write-buffer for the block of memory used by the screen (the errors come when the data you've written to the block is in the cache or in the write buffer and thus hasn't made it out to memory before the DMA picks it up). Generally it's worth a try. ;)

Anyway, a low-level approach could yield many performance gains on many devices, IMHO.
Conan wrote:
Let me know if you want anything tested. I have a Dell Axim which runs at 400 or 200 Mhz plus an iPaq 3650 arm machine.

My interest in this area is getting PocketGL to write directly to PF's back buffer instead of it's own as this causes me to have to do a copy involving a lock & unlock and I lose lots of FPS. It's been done with GapiDraw recently so must be possible with PF however I have not managed yet with the current version.


I am also interested in having PocketGL run faster. That's actually one of my priorities. I will contact you soon for some testing. Meanwhile, do you know PocketGL's frame buffer format? I know it's using 16 bits for the color and 16 bits for the Z buffer, but in what order?

Is it:
(color << 16) | zbuffer
or:
(zbuffer << 16) | color

?
Thierry, any plans on writing a custom image loader? I'm sure everyone is sick of my saying it by now, since there's about 10 threads in the past two weeks with these words: that's one of the big reasons my current project is GD-based. From what I gather from reading Johan's docs, there is a big memory hit using imgdecmp.dll. I had a huge problem with my Invasion: Trivia game because it required far too much memory, in fact about twice as much as I calculated it should. I could never understand why, but reading the GD docs makes me think this is the reason.

The other big advantage to GD from my point of view is it's use of DirectX on the desktop. Thierry, I understand your feelings about PF being for PocketPC's (and I know the "old school" feeling very well, all this relatively low-level stuff makes me feel like I'm back in the Atari 800/C64 days! I love it! Show me where the $d011 register is on a PocketPC and I'll have FLD running in five minutes!). That being said, I like GD because I can simultaneously release for PocketPC's and desktop PC's. This is something I can't do with PF (not with good performance that is). Do you have any thoughts on making PF use DX instead of GDI? Is it possible you can just write an x86 HAL that uses DX? If not, I'm thinking maybe some sort of add-on module or something along those lines. Although I have no DX coding experience, I'm willing to take a stab at this, if I know I can count on your support and, more importantly, guidance in how to incorporate it.

Truthfully though, the image loader issue is what I would actually consider a problem, the DX thing is just a big bonus, and I could do without it ultimately.
(Never used PF or GD - I'm just an interested "bystander").

Frank:

Was the "extra" memory ("twice as much") that was used at the storage/file stage or at the decompression stage?
fzammetti:

Image loading will be changed for sure. What SBL says is that imgdecmp.dll has too much overhead for game programming, and it might well be the case.

It should be trivial to recompile libjpg and/or libpng to work with PF, and I am really surprise no one has done it yet. I guess it wasn't a priority forme.

But yes, image loading will be one of the first thing that will be improved.


Concerning DirectX: PocketFrog already supports different display drivers, and adding a DX one should be trivial. Another thing that can easily be added but that I never had the time to do. I understand that this point is something a lot of people one, so it shall be added. I am also sick of playing PF game in a small 240x320 window.
The decompression stage. The game executable is 4.5M, but the game needs ~14M to run without crashing. I did an admittedly rough test, saving all my graphics as uncompressed BMP's instead of PNG's, and the WAVs are uncompressed to begin with. All the resources in those forms, plus the code and data, shouldn't require more than about 8M, give or take a bit, which means that the memory requirements is about double, a little more even, what I think it should be. This jives with what Johan states about imgdecmp.dll.
fzammetti wrote:
Although I have no DX coding experience, I'm willing to take a stab at this, if I know I can count on your support and, more importantly, guidance in how to incorporate it.


If you want to do it, look at the Internal::DisplayDriver interface. This is what needs to be implemented. An example of this is the GAPIDisplay class.

Initialization takes place inside class PocketPC. It shouldn't be too hard to find.

Let me know if you have any questions.
I will take a look at the DX stuff as time allows. I've also had libpng on my list for about three weeks now, I haven't gotten around to it yet, so I'm not sure when time will actually allow.

Johan did mention in another thread that just using libpng straight away still leaves some innefficiency, but I'm not sure of the extent at that point. It's of course better than imgdecmp.dll in any case. But since your planning on rewriting image loading for PF2 anyway, I'm not sure there's any sense in my even looking at it now. Maybe I'll concentrate more on the high-level stuff, as you said previously. There's still some functions I'd like to see added (as would others I think) that I think I can actually find the time to do.
fzammetti wrote:
Johan did mention in another thread that just using libpng straight away still leaves some innefficiency, but I'm not sure of the extent at that point.


I am also really curious about what he was referring to. libpng (and libjpg) are well known open source projects that have been reviewed/tested by so many people. That there would be something inefficient in them is a little surprising.

fzammetti wrote:
It's of course better than imgdecmp.dll in any case.


Most probably as imgdecmp.dll implies creating a DIB, a DC, and so on.

fzammetti wrote:
But since your planning on rewriting image loading for PF2 anyway, I'm not sure there's any sense in my even looking at it now. Maybe I'll concentrate more on the high-level stuff, as you said previously. There's still some functions I'd like to see added (as would others I think) that I think I can actually find the time to do.


Make sense. If I can find the time, I will try to hook libjpg/libpng to the current PF and sent you the result so that you can integrate it in your next release. (If you are still up for releasing PF 0.x versions.)
Yes, I have no current plans of stopping development of the 0.x branch (I suppose it's correct to call it that at this point). Even if I myself am using GD for my current project, I will still put out PF releases on occassion for those using PF. When PF2 is out I'm going to be first in line to see what you've done, to see if I should "come back home", as it were :)

Absolutely, if you get those libraries hooked up send me the changes. First thing I'll do is recompile Invasion: Trivia with it, and we should very quickly see the difference (still assuming that was the issue of course).
PocketGL frame buffer: The PGL code changes between version 1.0 & version 1.2 so I will need to send you info re: V1.2 (as well as 1.0). I'm intending to convert over to V1.2 for my next project

It's time to go to work so I will dig this out tonight.
Preliminary testing for rotated blits: I am getting 4.5 ms for a 90 degrees rotation using C code. I should be able to get some extra speed using assembly.

The nice thing is this is even a little faster then a straight memcpy (4.7 ms).

Looking good.
fzammetti wrote:
Absolutely, if you get those libraries hooked up send me the changes. First thing I'll do is recompile Invasion: Trivia with it, and we should very quickly see the difference (still assuming that was the issue of course).


I just finished testing libjpeg on my PPC and it works wonderfully. Loading a 227x149 jpeg image takes 50 ms. I will have to test the old method to be able to compare numbers.

The library supports JPG, BMP, GIF, PPM, RLE and TGA. Not too bad heh?

There is one problem though: to support loading from memory (or resources), a "data source manager" has to be implemented. Shouldn't be too much of a deal, but it might take some of my time. In any case, I want it for PF 2.0...

If I can find the time tomorrow or over the weekend, I will integrate it with PF 0.7.0 and send you the results.
Johan did mention in another thread that just using libpng straight away still leaves some innefficiency, but I'm not sure of the extent at that point.


What I meant was that one must use row-level reads to optimize memory overhead, which requires a bit more work than simply reading the whole image to a memory area. But it's not difficult, just a couple of dozen parameters to set and some callback functions.

Thierry: A few questions:
(1) It would be interesting to know how much libjpeg added to the DLL size. GapiDraw uses libpng + zlib which adds at least 100k.
(2) Is zlib also required for libjpeg?
(3) Is it possible to read "stripes" / image rows using libjpeg? On some formats (like RLE-BMP) reading an image row-by-row is not supported. Have they restricted image reading to a "allocate full memory buffer and fill with image data", or can one read one row at a time? If one must allocate memory for the whole image there isn't that much gain over using imgdecmp.dll.

I have no plans of integrating libjpeg into GD (PNG support seems to be enough for most cases), I'm just curious...
sbl wrote:
What I meant was that one must use row-level reads to optimize memory overhead, which requires a bit more work than simply reading the whole image to a memory area. But it's not difficult, just a couple of dozen parameters to set and some callback functions.


libjpeg works one row at a time internally. So yes, it's working at the row-level. It doesn't produce 565 pixels though. So I have to allocate the image width * 3 bytes (888) and convert that to 565 afterward.

sbl wrote:
Thierry: A few questions:
(1) It would be interesting to know how much libjpeg added to the DLL size. GapiDraw uses libpng + zlib which adds at least 100k.


The size overhead of libjpeg is 66.5K.

sbl wrote:
(2) Is zlib also required for libjpeg?


No, libjpeg doesn't use zlib at all. It has it's own implementation of Huffman encoding.

sbl wrote:
(3) Is it possible to read "stripes" / image rows using libjpeg? On some formats (like RLE-BMP) reading an image row-by-row is not supported. Have they restricted image reading to a "allocate full memory buffer and fill with image data", or can one read one row at a time? If one must allocate memory for the whole image there isn't that much gain over using imgdecmp.dll.


libjpeg allows you to read as many rows as you want at a time, even one. I haven't tested the non-jpg formats, but I have no reason to believe they won't work in "one-row mode".
That's great news, I look forward to whatever you send me.

Can I extrapolate that adding lpbpng you expect to be just as easy?

I think sbl is right that PNG support is enough for most people. I can say personally that I do all my images as PNG's these days, I don't touch the other formats at all. If you don't hook in libpng as well (or in place of libjpg), I won't be able to do a simple recompile of Invasion: Trivia, and I think that is maybe the best overall test of this, as far as load times and memory go (I do all my loads up-front, which makes it take 60+ seconds on my E-125, so we can easily compare that, and I've already mentioned the memory issue)
I can take a shot at libpng. Maybe SBL is willing to provide us with the changes he made to libpng? If not, it will take a little more time (like an extra session of work). I don't expect this to be more difficult that what I did for libjpg.

I am curious as to why you use PNG files. I sure haven't see any in my immediate surroundings.
A couple of quite tangible reasons:

(1) On average, PNG compression ratios seem to be better. Not drastically, but enough to matter in a PPC environment.

(2) I also find that the quality of an image at a given file size is superior to other formats at the same file size.

(3) PNG is a lossless format. I.e., load, edit and save it as many times as you want and you won't lose any information or quality. JPG gets progressively worse and worse. GIF is lossless too, but I think the real question is JPG vs. PNG since the only thing GIF offers over the others is animation (and there is an extension to PNG to do animation, but I don't think it's an official part of the spec yet).

(4) Copyright issues, to a lesser extent. This is the reason I stay away from GIFs (unless I need animated images for a web site, but then I should be shot anyway). JPG I don't think has any such issues either, but PNG is clean from the outset in this regard, so why risk it?

(4) There seems to be more options with PNG images. For instance, pulling up the optimizer (what you can think of as advanced options in a sense) for JPG's in Paint Shop Pro: I can alter compression ratio as you would expect, and whether it's standard or progressive loading. PNG's on the other hand, I see: color choices (palette-based image (where I can select the number of colors from 16 to 256, 8-bit grayscale or 24-bit, dithering %) transparency (none, single-color or alpha-channel) and whether it should be interlaced or not. That's quite a bit more, and most if not all of it is simply not supported by other formats (not ALL of it anyway). I would say it might just be the optimizier in Paint Shop Pro, but since JPG has been out years longer than PNG, I tend to think this isn't the case and the format is just superior as far as options go.

Those are my reasons anyway.
You are only wrong on one point: PNG is not lossless compression. In that regard, it is similar to jpeg. The fact that you can "recompress" it and not loose more info doesn't mean it's lossless. The first time around you did loss some info. If PNG has a lossless mode, that's great, but that's not what you want to use on the PPC.

So the real issue is JPG vs PNG. They are both hassle-free, they both have a nice optimized library (libjpg/libpng). The compression rate for the same quality are about the same. The real benefit of PNG over JPG is when you went to progressively display the image over a slow network link: PNG is a progressive format where jpeg is not.

In any case, I intend to support both (it only make sense and doesn't require that much extra work). Probably some compile switches to enable/disable the formats you want in your game would be nice. This way you don't pay for what you don't use.
Take a peek at http://www.w3.org/Graphics/PNG/. It does say it's lossless compression. I admit I can't find any concrete info that says "lossless all the time" vs. "lossless after the first compression", but it does seem to in fact be lossless from what I can find.

Even better perhaps is http://www.libpng.org/pub/png/, which says "non-patented (you betcha!), completely lossless compression". This also gives a better list than I did for why PNG is better (IMHO anyway).

Like you said though, your going to support both, so I certainly don't want to start a file format war :)
Then I was wrong. Dunno where I got that idea. PNG was basically developped to replace the dated GIF format (that also has patent issues), and not JPG like I first though.
This may be a little off topic, but PNG's have been my favorite format. Small and lossless compression, cant really beat that. The only thing that im not terribly happy with is the built in gamma correction. They do not often do well when trying to match colors in a webpage such as having the same color value but different gamma levels.
I always used JPG as background images ( they can have some loss but they are true color ) and gifs for the lossless images ( like the characters on Infestation, unfortunately they have only 8 bits for color )

But I´ll try the PNG format, seems to be a good one, I just wanted a good lossless true-color format.
Conan · 20 Jun 2003, 07:25 UTC — Info re: frame buffer for Thierry
You wanted to know about the frame buffer order. Here's the standard flush code. Does this tell you?
NOte: I don;t think it's worth spending any time looking at V1.0 although it's what I currently use. If PF 2 came along in a few months supporting PGL1.2 then I would just port over at that point.

Code:
void Flush_Standard(void)
{
unsigned int *Dest2 = (unsigned int *)GXBeginDraw();

if (!Renderer.DisplayReverse)
{
Dest2 += 319*120;
ArmFlushV((unsigned int *)VScreen, Dest2, GdRGBTab);
}
else
{
unsigned int *VData0 = (unsigned int *)VScreen;
Dest2 += 119;

for (int y=0; y<DISP_Y/2; y++) // 0->240
{
unsigned int *Dest = Dest2--;
unsigned int *End = Dest + (120*DISP_X);

while (Dest < End)
{
register A;

A = GdRGBTab[*(unsigned short *)&VData0[DISP_X]];
VData0[DISP_X] = ((FAR_CLIP * -1) << 16);
A |= GdRGBTab[(*(unsigned short *)VData0)] << 16;
*(VData0++) = ((FAR_CLIP * -1) << 16);
*Dest = A;
Dest += 120;
}
VData0 += DISP_X;
}
}
GXEndDraw();
}


In addition here's some other info:-
PocketGL Frame Buffer

Version 1.2 information

// virtual screen
int VScreen[DISP_X*DISP_Y]; // contain display data + zbuffer
PGLDLL_API extern int VScreen[DISP_X*DISP_Y]; // contain display data + zbuffer
The flush code is custom for various models at the point in time it was written plus generic code
this includes an assembler flush routine used in some cases

I will ask the chap who did the GapiDraw convert for his permission to give you his code
His comment 'the version of pgl you are using has a
separate screen buffer and zbuffer. V1.2 has the 2 combined. In the end, I
just copied and modified his Flush routine to move it to the gapidraw buffer'

Version 1.0 information, only relevant as it's what I do at present & includes an extra buffer copy each frame

which I would like to get rid of.

The PGL data is created as follows:-
header file has
VScreen
extern unsigned short VScreen[DISP_X*DISP_Y]
and the PGL cpp has
unsigned short VScreen[DISP_X*DISP_Y]
ZBuffer
.h
short ZBuffer[DISP_X*DISP_Y];//DISP_Y
cpp
extern short ZBuffer[DISP_X*DISP_Y];

In my PocketFrog
Code:

DemoInit();// initialise PocketGL
ZBuff = (long*)&ZBuffer[0];
PGL = display->GetBackBuffer();

sample code copying over PGL to PF & clearing Z buffer
Note I'm only using 240 x 240 here
//show Splash Screen

for(int z = 0; z<50;z++)//125
{
draw_splash3d();//splash screen

Surface::LockInfo buffer;

CLIP = (FAR_CLIP<<16);// make a long containing [far_clip<<16+far_clip] to make copy faster
CLIP += FAR_CLIP;// add on the 2nd far_clip
offs = 0;// init the counter
PGL->Lock(buffer,true);
// static int dy = buffer.pitch >> 1;

memcpy(buffer.pixels,VScreen,96000);//copy 240 x 200 = 48000 ints as bytes = 96000

PGL->Unlock();//back to normal PF
back3d->Lock(buffer);
memcpy(VScreen,buffer.pixels,96000);// clear the vscreen
back3d->Unlock();

for(int y = 0; y < 24000; y++)//copy longs containing [far_clip|far_clip]
{
// set offset to beginning of the next line to draw
ZBuff[offs] = CLIP;
offs++;
}
Thierry: Another advantage of PNGs are the variable alpha that can be embedded (which is also fully compressed losslessly).

I'll make a DIFF with the original libpng files if I have the time tomorrow (I'll be leaving for vacation on Tuesday).. It was just a couple of comments to make it work in the emulators... Otherwise the most hazzle was in setting up the png transform when the image is read... Which wasn't that difficult but the lack of documentation made it take some time...
... it was me posting above.. I forgot to login...
Thanks SBL...

Also, I was wrong about libjpg: all it supports is JPG images. No GIF/BMP/whatever. Kinda reduce it's usefulness.
Some news...

1) Finishing and integrating the new HAL with the current PF is going to be more work then I expected and sub-optimal. I am afraid doing so wouldn't do justice to the new HAL. Hence, my current plan is to add libpng (and maybe libjpg) to the current PF. DirectX support might also be added for the desktop (where are you with that Frank?). This would become PF 0.8 and eventually 1.0 when it stabilizes.

2) Meanwhile, I will do a major cleanup through all PF to efficiently use the new HAL. This would then form the basis on which PF 1.x-2.0 will be built.

On a side note, I have been able to have true double-buffering on devices that use the ARM built-in LCD controller. Although this is a nice feature, it limits the frame rate to the refresh of your display (around 56-59 FPS). It also suffers from one major problem: if your game crashes, the display needs to be restored properly. I haven't found a good way to do so, and without it, you are stuck and need to soft-reset your device. Not something very user friendly.
I took a look at it for about an hour a few nights ago, but most of that time was spent just learning about DirectDraw. Work isn't being kind to me, and what little time I've had at home I've been devoting to my new game. In short, I wouldn't count on me for the DirectX stuff, not unless you don't mind it coming a few months from now.
Thierry, kind of a side issue, but do you think it might be a good idea to consolidate PF web sites? I don't mind using my bandwidth to host it and maintain it, which would free you for more important work, but I don't want to be presumptuous here. Just let me know if you want to do something, else the status quo stands.
fzammetti wrote:
In short, I wouldn't count on me for the DirectX stuff, not unless you don't mind it coming a few months from now.


Sure, I'll start working on it over the weekend. What exactly is needed? I was thinking about having fullscreen 320x240 and I am unsure how to handle 240x320? Using 640x480 and stretching the image by 2? How does GapiDraw work?

Also what about windowed mode? Is it really needed? If so, with user-specified zoom factors?
fzammetti wrote:
Thierry, kind of a side issue, but do you think it might be a good idea to consolidate PF web sites? I don't mind using my bandwidth to host it and maintain it, which would free you for more important work, but I don't want to be presumptuous here. Just let me know if you want to do something, else the status quo stands.


I'd love that actually. The web site is what is taking too much of my time. I will let you know when the code is ready.
GapiDraw allows you to stretch the window, I *THINK* to any size you want. DirectDraw does smoothing when you stretch the surface (I may be confusing terms here, I'm not that familiar with it, but the point is you get antialiasing when you make the window bigger).

My own feeling is that by default the window whould be 240x320, and you can then set zoom dimensions to any size you want, just like GD does. I think that would be the ideal solution.
What exactly is needed? I was thinking about having fullscreen 320x240 and I am unsure how to handle 240x320? Using 640x480 and stretching the image by 2? How does GapiDraw work?


(back from my trip to Stockholm)

If you do not use surfaces stored in video memory, I would recommend sticking with 320 and stretch it up to 640x480. GapiDraw 1.01 did not use hardware-accelerated surfaces and the MFC demo running at 640x480 pixels (with DirectDraw double-buffered flip) was simply too demanding for most people's computers.

In current GapiDraw you can specify any resolution (from 320x240) in full screen mode. It is not possible to stretch the resolution in full screen mode (simply for performance reasons since I want a real "flip" to be performed). In windowed mode you can stretch the display to any size (OpenDisplay() takes four parameters - display size x/y and window size x/y).

As for 240x320 in full screen mode, this is supported if the display is opened with w=320, h=240, and the display mode is set to mode=ROTATE_90CW or mode=ROTATE_90CCW. A simple #ifdef _WIN32_WCE usually does the trick. Please feel free to check the documentation on www.gapidraw.com (I have tried most solutions to handling different resolutions in full screen mode in previous releases and the current is the most flexible based on the user feedback I have gotten).
Oh, a couple of tips:

1. Use the debug build of DirectX.. DX is very sensitive that all things are shut down in correct order.. Also you'll get all the lost surface messages correctly... It's quite easy to get a full screen version up and running, but with GD it took a couple of months before it was tested on some thousand of systems before it was getting stable (DirectDraw is kind of a mess)...
2. 555/565.. Many computers running Win 95/98/ME use 555 graphic adapters. GapiDraw uses a surface adapter internally which is a template, so both formats perform equally. I'm not sure if the best solution would be to perform a pixel-by-pixel conversion on 555 systems in PF...
SBL: it seems to me it would be much easier to simply set the screen resolution to 320x240 and use a normal GDI blit. In windowed mode, this is already way faster then on the PPC (I easily get > 600 fps on my desktop PC). It also solves the 555 vs 565 format issue quite nicely.

I feel what people are really after is a full screen game, and not one that uses DirectX. If a game is not fast enough to run on the desktop with GDI, I don't see how one can expect it to run on the PPC.

Am I missing anything? Anyone?
I'm not sure full-screen is really the big selling point of using DX, although it's a nice bonus.

It's simply a question of speed. When you say you get > 600 FPS on your desktop using GDI, is this with your new HAL architecture? In either case, what are you running to get that result?

There was floating around a while ago a PF sample of doing sprites with a simple parallax background (it may even be included with the latest PF build, I don't recall).

This sample as I remember it runs way too slow on the desktop, but on a PPC it runs acceptably well. The point being, GDI on a desktop is considerbaly slower than GAPI on a PPC, all other factors being equal (or ignored), or so it seems judging by this sample, which is probably more representative of an actual game than the blit sample, as a comparison.

If this is all true, DX is the answer to get the speed on par in all cases.

Speed aside, DX also gives you the nice antialiasing support, which really is required if your going to write games for a PPC at 240x320 and let people run it at something else on a desktop (i.e., a 640x480 window for example). Without this antialiasing, you either have to have two sets of graphics for the various window sizes (more than two actually) or it will look pixelated when expanded.
Thierry: Agreed. I am actually thinking of switching to GDI bitblt in windowed mode from the current "memcpy backbuffer to directx surface and then blt with stretch to the window" (as is currently used when GapiDraw is windowed). I'll try it out tomorrow and post what was faster in this topic.. I am beginning to use GDI in many surfaces in GapiDraw so it will also fit the architecture more nicely...

I think the solution you propose with simply changing display resolution and using gdibitblt would be both the easiest and best solution to quickly get fullscreen working. In fact, I only see advantages with using GDI in fullscreen as long as the resolution is 640x480 or less (debugging full screen applications are impossible in directdraw for example - which is a major pain).

The only reason I went through all the hazzle with fullscreen mode / dx / hw surfaces in GapiDraw is a project I did called Total Recall. We used Mimio Xi whiteboard pens as tracking devices, and had to run the display in 1600x1200 for maximum resolution (driver not available and we used the pens as mouse pointers).

fzammetti: Unfortunately not all display drivers perform antialiasing in 2D blt stretch.. There are also several issues with the Blt stretch (with mouse pointers / z-order etc so avoiding it could imho be worth some work...
I wasn't aware of that sbl, I thought it was supported by all relatively recent drivers.

I guess my only point, and this would go for both of you for both libraries: whether they are using GDI or DX doesn't really matter to me personally, as long as the performance is there (and how you really judge this is of course an interesting question).

Arguably more importantly though, whatever resolutions you support (whether it's the ability to stretch a window to whatever size I want or go to full screen or you just list one or two resolutions that I can use and that's it), antialiasing is very important.

This might mean implementing your own AA algorithm internally, but to me this is a very important thing. I could be missing something, but I don't see how you can easily run on both a desktop and a PPC (or other mobile device) without it and have results that look good in all cases without having to deal with multiple versions of images.

I'm still a PPC developer first, and if that means I can't release a desktop version of my products so be it. However, the ability to do both is very appealing, hence my emphasis on the AA ability, however it's implemented.
fzammetti wrote:
It's simply a question of speed. When you say you get > 600 FPS on your desktop using GDI, is this with your new HAL architecture? In either case, what are you running to get that result?


No, that's with PF 0.7. I get 400-800 FPS using a 1:1 ratio. When I enable the "desktopZoom" factor, it does go down horribly (22 fps for BLIT). Using StretchBlt() is too slow =(


fzammetti wrote:
Speed aside, DX also gives you the nice antialiasing support, which really is required if your going to write games for a PPC at 240x320 and let people run it at something else on a desktop (i.e., a 640x480 window for example).


DX doesn't give you that. If you want "nice stretching", you have to do it yourself. Am I missing something?
fzammetti wrote:
Arguably more importantly though, whatever resolutions you support (whether it's the ability to stretch a window to whatever size I want or go to full screen or you just list one or two resolutions that I can use and that's it), antialiasing is very important.


If you want to same result on all desktop PC, you have to implement your own AA / Stretch algo. And I don't see how one can write a generic AA algo that will work with all games (or please everyone).

fzammetti wrote:
This might mean implementing your own AA algorithm internally, but to me this is a very important thing. I could be missing something, but I don't see how you can easily run on both a desktop and a PPC (or other mobile device) without it and have results that look good in all cases without having to deal with multiple versions of images.


That's precisely why PF never supported full screen mode. I don't see how 320x240 full screen can look good at all. Even streching with "AA" looks blurry and ugly. That's why I never bothered.

My take on this is that if you want 640x480 (or higher) on the desktop, you will have to use a different set of sprites/images anyways. One example would be to design my game to use a resolution of 640x480 and then reduce the size of the sprites/images by two for the PPC version. Appropriate filtering would be applied. This way my game would like good on both the desktop and the PPC. Going to other way around will never give "nice" result on the PC and is ackward at best.

fzammetti wrote:
I'm still a PPC developer first, and if that means I can't release a desktop version of my products so be it. However, the ability to do both is very appealing, hence my emphasis on the AA ability, however it's implemented.


Again, this will never look very good. That's why I never added fullscreen support to PF.
DX doesn't give you that. If you want "nice stretching", you have to do it yourself. Am I missing something?


My understanding is that DirectDraw has something called SmoothScaling, and this is what I've been calling antialiasing (perhaps I'm using the wrong term here). This is what happens when you run a GapiDraw-based application on the desktop and expand the window. I believe, sbl can correct me if I'm wrong of course, that this is something that DX does for you, he didn't have to do anything special for it in GD. This is the function I find most important.

No, that's with PF 0.7. I get 400-800 FPS using a 1:1 ratio. When I enable the "desktopZoom" factor, it does go down horribly (22 fps for BLIT). Using StretchBlt() is too slow =(


Yeah, that was very much a hack. I just expanded on what gersen did in PocketFrogPlus. If anyone uses it for anything other than development, that's their problem :) 400-800 FPS still sounds high to me though. In any case, as I said before, I don't think the blit sample is really a good indicator of speed as opposed to a real-world game.

That's precisely why PF never supported full screen mode. I don't see how 320x240 full screen can look good at all. Even streching with "AA" looks blurry and ugly. That's why I never bothered.


I absolutely grant you that the results will never be OPTIMAL, but still using GD as the example, the results are actually rather good. In developing my current game, I have the desktop window zoomed to 480x640 all the time (my eyes ain't what they used to be), and the resultant images (designed for a PPC screen) look about as good as I would expect if I reduced them from larger images in Photoshop myself.

Assuming that the emphasis is on the PPC version of the game and the desktop version secondary only, it's results are certainly good enough. If it's the other way around then your solution of using two sets of images is the only way to go. But in the former case, it's just extra work that would be better put somewhere else, IMHO.

If you want to same result on all desktop PC, you have to implement your own AA / Stretch algo. And I don't see how one can write a generic AA algo that will work with all games (or please everyone).


I certainly don't know either :) All I do know is that it is done, GD being a good example (well, ok, that's not a custom AA/Stretch algo, true, but it IS a generic approach that works well).
Dave Johnston · 02 Jul 2003, 06:33 UTC
Thierry wrote:
I don't see how 320x240 full screen can look good at all.


Go back ~10 years and 80% of games ran full-screen, 320x240, some people even played them on 21" monitors to get the best experience! Yes, they were pixelated, but no one cared then for graphics - they wanted good games (case in point: Doom, all those Apogee Commander Keen titles, etc. etc.)
Dave Johnston wrote:
Go back ~10 years and 80% of games ran full-screen, 320x240, some people even played them on 21" monitors to get the best experience!


Err no... 10 years ago peoples were using 14" and rich ones might have had 15". When I say 320x240 is ugly, I think about those 21".
As we are talking about AA, something to try out is the Super Eagle effect, used on ZSnes and some other console emulators...
I don't know... I had a 21" monitor when I started working for my current company, that was 8 years ago. I had a 17" at home at that time. I can believe the rich had 21", as Dave said.

*I* wasn't one of them (err... still ain't!), but someone had to be able to afford it!
Damn it, one of these days PocketMatrix is going to not blow away my cookie every time and I can stay logged in. The above was me.
HTK wrote:
As we are talking about AA, something to try out is the Super Eagle effect, used on ZSnes and some other console emulators...


Where can I found info on the Super Eagle effect?
A quick sidestep from this thread:
FZammetti wrote:Damn it, one of these days PocketMatrix is going to not blow away my cookie every time and I can stay logged in.

The cookie erase has happened to me only once (or maybe twice) in eight months, so it can't be THAT common although it looks like its happening to you every other time. A quick tip is to check if you are logged in BEFORE you post a note.

Must be some kind of security setting on your OS or browser.

(Although I was stupid enough to write this post on this thread, I strongly suggest starting a new thread about the cookie erase problem if it needs further dwelling)
I already did start a thread in the feedback forum. No respons last I checked. I played with browser settings today (basically turned off all security). Strangely, the problem went away after doing that at work, but not at home. In any case, it does seem to be on my side, so I'll stop bitching :)

We now return you to your regularly scheduled thread...
I already did start a thread in the feedback forum. No respons last I checked.

Sorry about that =)
No reason to apologize adde.
Thierry":3k2g78u1]


Maybe a good place is the Zsnes source code itself: grab it at: http://www.zophar.net/snes.html
PocketFrog and GapiDraw are the coolest graphics library for PPC 8)

"Good to hear that PocketFrog is still alive and kickin..."

I personally not used PocketFrog but thru readings... I can conclude that Thiery and Johan... are Peter Norton and Bill Gates of Pocket PCs.

You're works help a lot of Pocket PC developers... Cheers...
? What's the point of having a PC screen other than 240 x 320 ? I don't expect to develop games for PocketPC which will also have PC versions. I can understand GapiDraw going this way if they are heading in the direction of applications which run across platforms rather than gaming but if PocketFrog is a games platform then it should be aimed at PocketPC / Smartphone screen sizes & possibly looking in the future to Symbian ( depends on where the games market goes )

ps: I started making my current game with Smartphone in mine but once I played with the SDK I gave up ( the menu is still that size however )
Well, 2 things come to mind:

(1) You never know when Microsoft may decide to mandate something other than 240x320. My understanding is that some Palms already have a higher resolution, so how long before MS decides they have to play catch-up? Why not have PF be ready for that now?

(2) Much more importantly is exactly what you said: some people do want to be able to develop for multiple platforms, me included. How many extra sakes could I get by having a desktop version of my games available? Maybe none, maybe a lot, but it's an option I want to have, hence the need for other resolutions because 240x320 on a desktop certainly isn't cool.
Thierry,

I would be interested if you ended up finding any info on the super eagle effect or something close to it. I downloaded the zsnes code and most of it is in x86 asm.

I dont know if you have ever seen this effect in action, but it makes snes games almost look like they were hand drawn.
Anonymous wrote:
I would be interested if you ended up finding any info on the super eagle effect or something close to it. I downloaded the zsnes code and most of it is in x86 asm.


I haven't seen the effect. I guess I should try it. The source code is a big pile of undocumented and hard to read assembly.
Oh,the guest post above was me. I took a look at the ASM, and I dont know how easy it will be to decipher. I learned ASM on a mips machine and x86 asm is a little odd.
Each to their own. I started on Motorola 86000 Assembler which was brilliant & freaked when I changed to x86 (but eventually came to like it). I've never even thought about trying ARM assembler as it took so long to cross over to C/C++
Hi guys, sorry for the ASM source I pointed to, this time I found some C++ source, this one from a Nes Emulator called Nestopia:
http://nestopia.znes.org/index.php?l=files
Take a look at the 2xSaI source, The Super eagle effect seems to be a variation of the original 2xSaI effect. Anyway, they are both on this source code.
Argh, Assembly... Makes my brain hurt these days... Which is weird, because back in the '84-'91, all I did was Assembly virtually all day long (Atari, then C64 and then some x86 before I realize how stupid it was to still be doing 100% Assembly!). I had to take Assembly two years ago while going back to school to finish my CS degree, and it was a riot watching all the "kids" sweat their asses off because nothing they'd ever seen was anything like Assembly (for me it was just remembering what I knew, so I did just fine after the first week).

I still believe that after you learn some variation of Basic, you should then be forced to learn Assembly to some extent before touching higher-level languages. Gives you such a better understanding of computers and programming.

But, after you get through that trial, you shouldn't ever touch the stuff again! (Assembly OR Basic come to think of it!)
Rock!, Thanks HTK. Ill grab that and take a look.

Edit:

Hmm... You know, I always wanted to find this code, but now I cant remember what the reason was. This would be great for a desktop version of a pocket pc game running full screen, but other than that a PPC wouldnt be able to handel all the calculations and keep a high frame rate i dont think. Also, since I would be developing specifically for the ppc, I cant find a reason why my graphics would be pixelated and need to be 2xSaied ;)