Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (498)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2
1  Game Development / Performance Tuning / Re: So for the first time in a few years I tried A on: 2004-02-07 23:14:36
About 7 or 8 months ago I too finally got tired of this predicament.  I felt I had finally hit a wall and this time no nasty trick was going to get me though it, or round it, over it or under it.

I suppose what really gnaws at whats left of my soul at night is that you are so close to a group of tangibly good instruction that might just *might* get you out of the mess your in but you know what. They're forever out of reach. I was thinking MMX.

Yes folks, I admit it I once learned machine code and liked it. In fact it bit me so hard its difficult to forget, no matter how good compilers get or how easy Java is some times or even the fact that if you get it wrong it'll run slower on the next generation of CPUs.

So late at night, when one of the b*stard neighbours staggers in at 5am and decides "Hey, this is a good time to party" and promptly put the worst piece of music (or should that be muzak) you have ever heard at full volume, I get attacks of "what ifs..."....


I sure you all get them, and as you know a "what if" is hard to live with.

My what if is/was called Troll Fluff.
High Rez timer
EXACT CPU clock cycle counting
Direct Input Keyboard.
Direct Input Wheelie mouse.
Direct Audio for ultra low latency and click free sound.
Hardware V-Sync (at last *proper* arcade action)
Lets you know the Mhz rating of the CPU you are using.
(all that lot works)

The intention was to release it as Open Source, but still it lays un touched and un finished on my hard drive. Its compilable with MinGW too (against DX7).

"So what" I hear you cry, most of this can be done in various shades of bad with the latest greatest Java.

Well, me being me, decided that I'd make the effort to get it to work in as many JVM's as possible:
IBM 1.3
SUN 1.3
SUN 1.4
Symantics 1.1.5 (Thats Netscape 4.73 folks)
Microsofts 1.1.4

Also I'm not so fond of big downloads having a modem, so it was/is a 6K class file and a ~100k .dll.

And it works for Applets live on the web WITHOUT having to use a certified JAR file, which makes life a whole lot easier. Only Netscape 4.73 throws up a dialogue box, to which you click on "Grant" and off your go.

Anyway this was just to let Cas know that its quite possible to get an Applet to run with a DLL. In fact I must apologies because I had intended to take a look at the LWJGL library see if I could get it too work as such, but I'm afraid I've got lazy and tired of java.

The only mild trouble would be creating an auto installer, as its a bit of a nightmare finding out which version of Java is running and where it is located (Suns java plug in does not help). A Manual install is not very difficult to do, copy 2 files and modify a third (or unzip for MS).

Additional problems, unloading the DLL once the applet has finished (because some JVM's seem to need the JVM to quit entirely) and the low thread priority in Applets (much lower than Applications) + plus have you seen how many threads & processes Java needs to run, it no surprise its difficult to get something running smooth.

Hope that helps
---------
Woz.
P.S.
Yes I have got a mutilated version of .:Redemption:. running at 60Hz  hardware vsync with thumpingly loud music and AT LAST sound effects that go off when they are triggered! Looks great on a telly.

P.P.S.
If you hadn't noticed Troll Fluff was an attempt to plug some of the (gapping?) holes in Java, that even a 1983 home micro computer would support.
Things like why on earth didn't they include a blitter function, why stop at System.arraycopy()? an almost entirely useless command if you ask me.
2  Game Development / Performance Tuning / Re: Crazy bytecode madness... on: 2004-01-16 12:09:50
Dom,

floatToIntBits() is a JNI call, once you have the value in C or C++ you can do what you like to it.

Although you should still adhere to sun's type definition, so most likely the value is loaded into a jvalue as a jfloat and then read out as an jint. This is exactly how Kaffe does it:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
Extract taken from Fp.c of Kaffe 1.0.7.

/*
 * Convert float to int.
 */

jint
floatToInt(jfloat val)
{
        jvalue d;

      d.f = val;
      return d.i;
}


Extract from Sun's JNI header file shipped with SDK1.3 jni.h

typedef union jvalue {
    jboolean z;
    jbyte    b;
    jchar    c;
    jshort   s;
    jint     i;
    jlong    j;
    jfloat   f;
    jdouble  d;
    jobject  l;
} jvalue;


Although the couple hundered clock cycles required to make the JNI call make this unsuitable for your inner loop as the Divide is considerably less.

Hope that helps,
------
Woz.
3  Game Development / Performance Tuning / Re: Fill rate on: 2004-01-07 16:23:47
Orangy is right,

TBDR stands for Tile Based Deferred Renderer.

Although its Kyro not Kryo, although I kept calling it that when I when for an interview at Power VR to write display drivers for it [hey it looked like a frozen dead dude on the cover box  Cheesy ]. That was just before ST Micro Electronics ditched them - even though they were making a profit with them - throwing Power VR into oblivion. Although they are supposed to have a DX9 peice out and about...

Heres a short url describing the process, translated from German:  * here * My understanding is that they own a load of patents on the subject.

I thought the Dream Cast had fantastic picture quality and it supported 60Hz on a UK telly (Soul Calibur was arcade perfect). Pitty it boomed.

------
Woz.
4  Game Development / Performance Tuning / Re: Finding index of single 1 bit in a long on: 2003-12-18 11:56:48
bitIndex6()














456.719
457
ibm13index6e.csv
Thread priority = 5
Classic VM
IBM Corporation
1.3.0
1.3.0
IBM Corporation
486.462
486
ms114index6e.csv
Thread priority = 5
null
null
null
1.1.4
Microsoft Corp.
361.481
361
sun12index6e.csv
Thread priority = 5
Classic VM
Sun Microsystems Inc.
1.2
1.2
Sun Microsystems Inc.
591.169
591
sun131index6e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.3.1-b24
1.3.1
Sun Microsystems Inc.
728.77
729
sun141index6e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.4.1-b21
1.4.1
Sun Microsystems Inc.
606.939
607
sun142index6e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.4.2_01-b06
1.4.2_01
Sun Microsystems Inc.

bitIndex8()












418.503
418
ibm13index8e.csv
Thread priority = 5
Classic VM
IBM Corporation
1.3.0
1.3.0
IBM Corporation
455.988
456
ms114index8e.csv
Thread priority = 5
null
null
null
1.1.4
Microsoft Corp.
337.237
337
sun12index8e.csv
Thread priority = 5
Classic VM
Sun Microsystems Inc.
1.2
1.2
Sun Microsystems Inc.
567.88
568
sun131index8e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.3.1-b24
1.3.1
Sun Microsystems Inc.
627.207
627
sun141index8e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.4.1-b21
1.4.1
Sun Microsystems Inc.
574.385
574
sun142index8e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.4.2_01-b06
1.4.2_01
Sun Microsystems Inc.

Evil looking bitIndex9()












22.033
22
ibm13index9e.csv
Thread priority = 5
Classic VM
IBM Corporation
1.3.0
1.3.0
IBM Corporation
463.16
463
ms114index9e.csv
Thread priority = 5
null
null
null
1.1.4
Microsoft Corp.
322.418
322
sun12index9e.csv
Thread priority = 5
Classic VM
Sun Microsystems Inc.
1.2
1.2
Sun Microsystems Inc.
523.457
523
sun131index9e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.3.1-b24
1.3.1
Sun Microsystems Inc.
523.457
523
sun131index9e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.3.1-b24
1.3.1
Sun Microsystems Inc.
513.895
514
sun142index9e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.4.2_01-b06
1.4.2_01
Sun Microsystems Inc.


It would appear that IBM's JVM optimized bitIndex9() out!

As a whole they appear to be slower (than bitIndex5() ) under microbench mark conditions. Personnally I was expecting that the JIT compilers would be considerably slower due to most JIT's being nothing more than a Interpreter without the overheads of interpreting (!). Interpreters dont reorder code they execute each byte code as it comes.

All but one JVM is able to beat the original bitIndex2().

Note that the 1.4.2 -server -Xcompile scores are not present, as I have not finished playing with it yet.
I have tested it on bitTest2, 4 & 5.
Using -Xcompile made no difference to the client JVM as neither did changing the amount of "warm up" time.

The server version when using just the -server switch manages to optimize out the the benchmark completely giving a score of zero. When combined with -Xcompile a score is presented, it has the greatest gain (percentage increase over bitIndex2() ) in the order of  190% for bitIndex4(), which is faster that bitIndex5(). But is using 308 clocks to do it.

Obviously the microbenchmark is going to have to be modified in order to stop the code being optimized out.

It would be interesting to try them on a P4 which has a very long pipeline, so surely bitIndex9() would be faster than bitIndex5().

Cold fish all round then!
-------
Woz.
5  Game Development / Performance Tuning / Re: Finding index of single 1 bit in a long on: 2003-12-18 11:17:18
Here you go Dom,

It takes anywhere between 1-2 hours to gather the results for each test, so you'll have to forgive the slight delay.

Some slight code modifications on the each bitIndex() were required, as Dom wrote bitIndex6() off the top of his head, and Pamler's initial version was only accepted integers as parameters.

So here are the modifed versions:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
  public static int bitIndex6(long x)
  {
    int r = 0;
    int a = (int)x;
    int b = (int)(x>>32);

//    if( a == 0 )
//    {
//        a = (int)(x >> 32);
//        r += 32;
//    }

    int c = ( a >> 31) | (( -a ) >> 31);  // 0 if a is 0
   a = (a & c) | (b & (~c));  // a = b if a was 0
   r = 32 & (~c);

    //if ((a & 0xFFFF0000) != 0) r += 16;
   b = a & 0x0000ffff;
    b = ~(( -b ) >> 31);  // 0 if b was non-zero
   r |= 16 & b;

    //if ((a & 0xFF00FF00) != 0) r += 8;
   b = a & 0x00ff00ff;
    b = ~(( -b ) >> 31);  // 0 if b was non-zero
   r |= 8 & b;

    //if ((a & 0xF0F0F0F0) != 0) r += 4;
   b = a & 0x0f0f0f0f;
    b = ~(( -b ) >> 31);  // 0 if b was non-zero
   r |= 4 & b;

    //if ((a & 0xCCCCCCCC) != 0) r += 2;
   b = a & 0x33333333;
    b = ~(( -b ) >> 31);  // 0 if b was non-zero
   r |= 2 & b;

    //if ((a & 0xAAAAAAAA) != 0) r++;
   b = a & 0x55555555;
    b = ~(( -b ) >> 31);  // 0 if b was non-zero
   r |= 1 & b;

    return r;
  }


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
  public static int bitIndex8(long x)
  {
    int r = 0;
    int a = (int)x;
    int b = (int)(x>>32);
    int c = ( a >> 31) | (( -a ) >> 31);  // 0 if a is 0

    a = (a & c) | (b & (~c));  // a = b if a was 0
   r = 32 & (~c);

    b = ((a & 0x0000FFFF) - 1) >> 31;
    r |= 16 & b;

    b = ((a & 0x00FF00FF) - 1) >> 31;
    r |= 8 & b;

    b = ((a & 0x0F0F0F0F) - 1) >> 31;
    r |= 4 & b;

    b = ((a & 0x33333333) - 1) >> 31;
    r |= 2 & b;

    b = ((a & 0x55555555) - 1) >> 31;
    r |= 1 & b;

    return r;
  }



And a most evil looking version, in an attempt to (some what doubtfully) get the method to inline.
1  
2  
3  
4  
5  
6  
7  
8  
  public static int bitIndex9(long x)
  {
    int a = (int)x;
    int c = (a | -a) >> 31;
    a = (a & c) | (((int)(x >> 32)) & ~c);

    return ((32 & (~c)) | (16 & (((a & 0x0000FFFF) - 1) >> 31)) | (8 & (((a & 0x00FF00FF) - 1) >> 31)) | (4 & (((a & 0x0F0F0F0F) - 1) >> 31)) | (2 & (((a & 0x33333333) - 1) >> 31)) | (1 & (((a & 0x55555555) - 1) >> 31)) );
  }


Results in next post.

------
Woz.
6  Game Development / Performance Tuning / Re: Finding index of single 1 bit in a long on: 2003-12-13 11:29:43
Wow Jeff calm down!

The comparison was which routine was quicker, for me its bitIndex5().

This was the IBM Run Time JVM I downloaded and use, IBM has either moved or removed the page since, but google still caches it.

Google Cache

This has a RunTime installable package, ibm-cpt-rn20.exe.

Planet mirror still has it:
http:// http://public.planetmirror.com/pub/java-ibm/1.3.0/win32/

I did not use the -Xcompile switch with Suns 1.4.x (or any of the other JVMs), although I allowed time for the JVMs to warm up.

[move]Shall have a go and see if it makes any difference, when I've got the some time free.[/move]
-------
Woz.
7  Game Development / Performance Tuning / Re: Finding index of single 1 bit in a long on: 2003-12-12 19:00:41
Erik,

IBM still do make a JVM, its just part of Web Sphere now.
http://www-106.ibm.com/developerworks/java/jdk/
IBM typically runs a bit behind in the version numbers though, they were at version 1.1.8 for ages.

But what I don't understand is why they have a version of 1.4.1 for Linux but not windows, the Linux crowd have had it for ages too.

I completely agree with Cystal Squid, conditional branches kill modern CPUs (especially the P4 with its super long pipeline). It would be interesting to try and make as much of that code run in parallel (super scalar architecture). But do you know what! The BSF opcode is supposed to run in 1-2 clocks on the PPro, PII and above!!!

Native One I would not necessarily say that SUN 1.2 is faster than 1.4 series as this is only one test, the rest of the JVM may very well suck! It may not scale at all, have bad array access and a poor I/O sub system.

One thing you can note is that there is a difference between JITs and Hotspots, the JIT compilers like your code, Hotspots - for what ever reason do not. IBM's JVM is a Hotspot compiler but they seem to have managed to keep all the benefits of JIT too. Unfortunately all these JVM's are closed source so it really difficult to work out the actual reason for it.  Also this is only on MY machine, it is entirely possible to be the other way around on your PC. Although typically all PII & PIII systems would behave the same in this test because the memory sub system is hardly used.

But then of course this is not a "live" environment, the code does not actually do anything and it is not used the way you intend it to be used. The code is so small that the entire program should fit in the L1 cache of the CPU, something that probably wont happen when your chess program is finished.

As to which programming language you should use, I see no reason why you should not use Java, its (relatively) easy to use, and changes can be made quickly. OK speed of execution "could" be a problem, but if this is your first go at a chess program its not really going to be an issue, your hardly going to be running the thing against Deep Thought are you!!??

Anyway hope you found this all useful, if not at least interesting!

All the best,
-------
Woz.
8  Game Development / Performance Tuning / Re: Finding index of single 1 bit in a long on: 2003-12-11 19:53:18
For those interested in dots.

Appologies for the large post, and you probably want to go full screen to get the table data lined up (sorry).

The clock cycles given include the loop over head, the top value is the average cycles, the value below it is the median.
CPU = 1Ghz PIII coppermine with approx  CPU Clock Speed = 997453224 Cycles per second

Clock Cycles for bitIndex2().








335.163
335
ibm13index2e.csv
Thread priority = 5
Classic VM
IBM Corporation
1.3.0
1.3.0
IBM Corporation

462.998
463
ms114index2e.csv
Thread priority = 5
null
null
null
1.1.4
Microsoft Corp.

334.378
334
sun12index2e.csv
Thread priority = 5
Classic VM
Sun Microsystems Inc.
1.2
1.2
Sun Microsystems Inc.

612.59
612
sun131index2e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.3.1-b24
1.3.1
Sun Microsystems Inc.

626.142
626
sun141index2e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.4.1-b21
1.4.1
Sun Microsystems Inc.

635.11
635
sun142index2e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.4.2_01-b06
1.4.2_01
Sun Microsystems Inc.


Clock cycles for bitIndex4()








216.247
216
ibm13index4e.csv
Thread priority = 5
Classic VM
IBM Corporation
1.3.0
1.3.0
IBM Corporation

354.651
354
ms114index4e.csv
Thread priority = 5
null
null
null
1.1.4
Microsoft Corp.

308.959
309
sun12index4e.csv
Thread priority = 5
Classic VM
Sun Microsystems Inc.
1.2
1.2
Sun Microsystems Inc.

501.409
501
sun131index4e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.3.1-b24
1.3.1
Sun Microsystems Inc.

487.529
487
sun141index4e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.4.1-b21
1.4.1
Sun Microsystems Inc.

470.736
471
sun142index4e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.4.2_01-b06
1.4.2_01
Sun Microsystems Inc.


Clock cycles for bitIndex5()




















208.485
208
ibm13index5e.csv
Thread priority = 5
Classic VM
IBM Corporation
1.3.0
1.3.0
IBM Corporation

342.374
342
ms114index5e.csv
Thread priority = 5
null
null
null
1.1.4
Microsoft Corp.

278.477
278
sun12index5e.csv
Thread priority = 5
Classic VM
Sun Microsystems Inc.
1.2
1.2
Sun Microsystems Inc.

466.484
466
sun131index5e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.3.1-b24
1.3.1
Sun Microsystems Inc.

460.837
461
sun141index5e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.4.1-b21
1.4.1
Sun Microsystems Inc.

450.049
450
sun142index5e.csv
Thread priority = 5
Java HotSpot(TM) Client VM
Sun Microsystems Inc.
1.4.2_01-b06
1.4.2_01
Sun Microsystems Inc.
-----
Speed gain when
using bitIndex5()
instead of using
bitIndex2()
161%135%120%131%135%141%

As you can clearly see it is worth using bitIndex5() over bit Index2() giving at worst a 20% speed increase (at best a 61% increase).
If you want to know which JVM was faster on my machine, well that goes (unsurprisingly) to IBM's 1.3.

Unfortunately I didn't get to include Kaffe due to the version I have being broken on Windows. And I didn't succeed in compiling a .exe via GNU's GCJ, due to a jni link error which is most likely my fault (but haven't finished with this yet).
---------
Woz.
9  Game Development / Performance Tuning / Re: Finding index of single 1 bit in a long on: 2003-12-10 06:58:25
Guess who managed to post the wrong piece of code last night!
Ooops, sorry about that, this is the one you want:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
  public static int bitIndex5(long x)
  {
    int r = 0;
    int a = (int)x;

    if( a == 0 )
    {
      a = (int)(x >> 32);
      r += 32;
    }

    if ((a & 0xFFFF0000) != 0) r += 16;
    if ((a & 0xFF00FF00) != 0) r += 8;
    if ((a & 0xF0F0F0F0) != 0) r += 4;
    if ((a & 0xCCCCCCCC) != 0) r += 2;
    if ((a & 0xAAAAAAAA) != 0) r++;

    return r;
  }


Caused by looking at the wrong spread sheet!! Anyway this one is faster and smaller than bitIndex4() as it avoids doing 2 casts in 50% of cases and the execution path is a little cleaner.

Sorry about that.
-------
Woz.
10  Game Development / Performance Tuning / Re: Finding index of single 1 bit in a long on: 2003-12-09 21:44:00
Native One,

After some testing I reckon this version is faster:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
   public static int bitIndex4(long x)
   {
    final int a = (int)x;
    final int b = (int)(x >> 32);
    int r = 0;

    if( a == 0 )
    {
      if ((b & 0xFFFF0000) != 0) r += 16;
      if ((b & 0xFF00FF00) != 0) r += 8;
      if ((b & 0xF0F0F0F0) != 0) r += 4;
      if ((b & 0xCCCCCCCC) != 0) r += 2;
      if ((b & 0xAAAAAAAA) != 0) r++;
      r += 32;
    }
    else
    {
      if ((a & 0xFFFF0000) != 0) r += 16;
      if ((a & 0xFF00FF00) != 0) r += 8;
      if ((a & 0xF0F0F0F0) != 0) r += 4;
      if ((a & 0xCCCCCCCC) != 0) r += 2;
      if ((a & 0xAAAAAAAA) != 0) r++;
    }
   return r;
  }


Although I'm not happy about the casting at the top but I assume you have to use longs, also there is a bit of a hole in that your style of code allows a value of 0 to be returned as if a bit 0 has been set.

This has fallen through into the int version thus:
bitIndex2( 0L ) returns 0
bitIndex2( 1L ) returns 0
bitIndex4( 0L ) returns 32
bitIndex4( 1L ) returns 0

Which does not affect the way you want it to work but is something to at least be aware of.

Java 1.3.1
On a 1Ghz PIII coppermine with approx  CPU Clock Speed = 997453224 Cycles per second.

I was getting a consistant average (on 10000 x  64 tests) of
1154 clock cycles per call on bitIndex2()
1050 clock cycles per call on bitIndex4()

These value includes the loop overhead per iteration but profiling down to this level if farely hard and should be considered a micro benchmark as on first run its possible to see how much cpu the hotspot takes to optimize the execution path when in bitIndex4() bit 32 is set causing to take the other branch.

Profiling the actual methods results in bitIndex4() being ~20cc faster than bitIndex2() when done in a smaller bits 1 to 64 set test. Which is a different value from the 10000 * 64 tests.

Microsoft JVM also mirrored this speed increase, although it is much faster,  values of 515cc for bitIndex4() not unheard of (again jumps around a lot).

Although I'm not happy with the profiling environment as I just wacked the code into an existing applet, so there are plenty of other threads running.

So perhaps tomorrow I'll try it in a clean testbed and see if the values are any more consistant.

-------
Woz.
11  Game Development / Performance Tuning / Re: Finding index of single 1 bit in a lon! on: 2003-12-09 19:29:09
Arrh yes the good old BSF opcode.

What am I saying!?! It used to be a one of the slowest instructions on the 486 taking upto 43 clock cycles, people used to do everything to avoid using it including using the FPU stack!!

[cold shirver runs down spine...]

Luckily the 486 days are gone for good (unless you work for nasa).

Native One you seem to be using 64-bit Longs, it would be better to break it into 2 32-bit integers.

But do you need to be using longs in the first place?

The -server version *may* handle these longs better as it is SSE enabled, although I have no idea if it supports 64 bit longs (a job for MMX not SSE).

You also have do not have an immediate escape clause in that if x is zero you still run through all 6 of those 64-bit checks before returning zero.

On the server version you also have the ability to set the size of code you want to inline, this could seriously help you if bitIndex is being called reguarly.

Hope that helps a bit.
-------
Woz.



12  Java Game APIs & Engines / J2ME / Re: Midlet size on: 2003-11-18 14:35:27
Hi Laszlo,

Those scores for the T-610 look extreme fishy, they are all over the place. A genuine score seems to be ~279, yet there are scores up to 402 and as low as 175. But the dates are intermixed, so a recent score does not mean a higher score (so would not suggest a firmware update).

http://www.jbenchmark.com/index.html?F=D&D=SonyEricsson%20T610%20T616

This seems a bit funny for a device which has not been changed (as in a faster CPU for new versions) or (to my knowledge) a faster KVM + libraries.

The T-610 is not a fast beast when it comes to J2ME, it used to be 3rd from bottom on your list at one point. Which is rather disappointing as the phone is quite good.

Of course it could be just down to the benchmark being interrupted, or even an inaccurate system clock.

A system clock accuracy test would be a good one to add to JBenchmark, at least it would be informative (would also force phone Manufacturers to at least try and make them accurate, because it would look bad if they didn't).

You also don't impose a penalty for failing a test, the T-610 cannot generate an image larger than its screen size and so fails the animation test.

Got to ask, whilst I'm at it, whats ATi's connection with your JBenchmark 2 are they about to launch a mobile gfx chip? Your NDA is safe with us, we can keep a secret! Honest Cheesy

All the best with JBenchmark2,
-------
Woz.
13  Java Game APIs & Engines / J2ME / Re: Midlet size on: 2003-11-14 11:48:17
I particularly like the way that the Pre-verifier adds (at least for me) 15%-22% size increase to the class files!!

Have a go at compiling your classes manually then look at the class file size before and after Preverify and note how much bigger they get...

Does anybody actually know what the Preverifier actually does? Its only supposed to add a stack map attribute to each method but I've come across classes it does not seem to touch.

Thats another way to squeeze those class files, use as few methods as possible!

The MIDP V1.0 spec states that for memory consumption the minimum should be:

128K of non-volatile memory for the MIDP components.
8K of non-volatile memory for application-created persistence data
32K of volatile memory for java runtime (heap etc).

All these other limitations (such as max class file size, or jar file size)  are just imposed by the manufacturer.

For example almost all (if not all) current (2003) Siemens phones have a wonderful size constraints of 16K on everything:
Quote

quote taken from page 96 of the Siemens Mobility Toolkit
(SMTK)for Java (tm) Development Programmer's Reference Version 3.1,0 6 /2003.

NOTE: Siemens Java (tm)-enabled mobile phones have a memory limitation that
only allows to be created instance of classes and variables with size fewer than
16.384 bytes (16Kb). So, be sure if your image file has a size smaller that the
maximum size.


MIDP V1.0 spec (thats JSR-37) can be found here:
http://jcp.org/aboutJava/communityprocess/final/jsr037/index.html

MIDP V2.0 spec (JSR-118 ) :
http://jcp.org/aboutJava/communityprocess/final/jsr118/index.html

And a list of all the JSR extensions for J2ME can be found here (all 55 of them!):
http://jcp.org/en/jsr/tech?listBy=1&listByType=platform

Whats needed is a list of phones (or KVM's) and their limitations. Because manufacturer are quite happy to leave out this information from specs.

I had hoped http://www.jbenchmark.com would, but they don't even seem to bother filtering out bogus scores.

------
Woz.

14  Game Development / Performance Tuning / Re: Converting from 1.4 to 1.1... on: 2003-11-07 10:06:26
Dom,

I think the reason why it is not working under 1.3 is that you are compiling the code using a 1.4 compiler.

Try using the -target switch on Javac.

The Javac doc is located here: http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html

I'm getting a java.lang.ClassFormatError in class am of Bee Mania.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
Error unable to create jar cache in /tmp directory : java.util.zip.ZipException: error in opening zip file
Error unable to create jar cache in /tmp directory : java.util.zip.ZipException: error in opening zip file
java.lang.ClassFormatError: am (Bad magic number)
      at java.lang.ClassLoader.defineClass0(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:496)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:117)
      at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:146)
      at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:325)
      at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:112)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:257)
      at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:370)
      at sun.applet.AppletPanel.createApplet(AppletPanel.java:583)
      at sun.plugin.AppletViewer.createApplet(Unknown Source)
      at sun.applet.AppletPanel.runLoader(AppletPanel.java:519)
      at sun.applet.AppletPanel.run(AppletPanel.java:297)
      at java.lang.Thread.run(Thread.java:498)
Begin Stats

Using IBM's 1.3 JVM.

------
Woz.

P.S.
There is also the possibility of your obfuscation process causing it.
15  Game Development / Performance Tuning / Re: Converting from 1.4 to 1.1... on: 2003-11-06 09:53:01
nonnus29,

JEF stands for Java Emulation Frame Work and is a Source Forge project which can be located here:

https://sourceforge.net/projects/jef/
Quote
Many common emulator related problems are solved in JEF such as CPU emulation, graphics decoding and rendering etc.


It also handles sound, emulating various sound chips such as the AY8910 + others.

If you do a search in these forums you will find many-a-thread on it. Cheesy

Hey DOM any joy changing the a,r,g,b order?

------
Woz.
16  Game Development / Performance Tuning / Re: Converting from 1.4 to 1.1... on: 2003-11-05 10:26:12
Dom,

The ImageProducer really only hands the image over to the ImageConsumer. SetPixels indicates which pixels have changed and should be draw. BUT the ImageConsumer.setHints() controls how they are received so its not as versatile as it could be as SINGLE_PASS is always used. A call to ImageConsumer.imageComplete() sends the image to the screen.

So the general process should be:
1  
2  
3  
graphics.drawImage( image, 0, 0, width, height, null); 
consumer.setPixels( 0, 0, width, height, colourModel, pixels, 0, width );
consumer.imageComplete( ImageConsumer.SINGLEFRAMEDONE );


Be very careful you don't end up with something that only works in Microsofts JVM, get hold of Netscape 4.7x if you can get it to run under both then chances are it will work under dreaded Mac OS 9, (there are  a lot of iMacs out there still).

Take a glance at TinyPTC http://www.gaffer.org/tinyptc/ which has a correct ImageProducer/ImageConsumer model, although  I have not used it plenty of people like it.

I will point out that the ImageConsumer model is much slower on Java 1.2 upwards and you should use BufferedImage instead, which should cover your 1.2 & 1.3 gap nicely.

Try using System.arrayCopy() to speed up your non-transparent images, as it is ints you are copying not bytes (so a 32 pixel  linear transfer is actually 128 bytes which arraycopy does quicker than byte codes).

Changing the memory order of your pixel buffer is not really worth it UNLESS you know you are getting lots of cache misses (things like rotation, zoom, line drawing and texture mapping) this is because it takes longer for Java to decode your custom address structure than without. Both seem to cause address interlocks, because they are tight loops but loop unrolling is mainly a no no in Java.

All the best,
------
Woz.

17  Game Development / Performance Tuning / Re: Converting from 1.4 to 1.1... on: 2003-11-04 11:35:14
Hi CrystalsSquid,

I too failed to get either Bee Mania or Traffic Jam working.

That was using:
  • Mozilla 1.4.1browser
  • IBM's 1.3 JVM.
  • Windoze.


What are you using in 1.4.2 that's stopping it working in the rest?

Obviously it would be very silly of me to say whether your games can be converted to 1.1 with any speed as I have been unable to run them so have no idea the number of sprites or weather the screen is moving etc. So here are some thoughts instead.

But I should not think you would have much problem getting them to work in 1.1 faster, but you will basically have to ignore all the AWT and write all your gfx routines which you've tried(?).

You also do not say what spec of machine you are using for 1.1, which makes quite a difference as the Athlon does not get slowed down anywhere nearly as much when it comes to redrawing that screen in IE compared to a PIII.

640 x480 is also pushing your luck under 1.1 in 32 bit colour, as the amount of bandwidth is massive and often causes the cache to be emptied.

So you could:
a) make the screen smaller.

b) break up the screen into smaller sections so that only the areas that need updating are. (for example the status panel could be a separate canvas entirely).

c) Stop using 32bit colour and use 8bit colour (for reasons unknown Sun decided not to include 16bit colour in 1.1, although it can be faked).

Use an ImageProducer instead of MemoryImageSource, although I shall admit I don't think there is too much difference as a MIS is just another level of abstraction for an ImageProduce. I use a ImageProducer though.

Ultimately there is not much you can do about the time it takes to draw a 32 bit 640 x 480 MemoryImageSource to the screen, you just have to make everything else faster!

It may, however, be too much work to get running at the same speed as 1.4.2, as you have already finished. So perhaps it would be better to concentrate on getting them working under 1.3 and the Mac first.

Although I suppose you would be happy just to get 10fps instead of 5fps?Cheesy

Hope that helps a bit.
-------
Woz.
18  Game Development / Performance Tuning / Re: GCJ, a quest for speed. on: 2003-10-22 11:21:01
I didn't have that much trouble getting hello world down to < 500K.

You've just got to use lots of GCC switches!

Page 2 of this topic has the correct switches listed to get < 500K.

They are supposed to be doing something about the size in GCJ V3.4 but how much difference it will make is another matter - bearing in mind that you have to provide the functionality of the JVM and the compiled code in order for it to execute properly.

Jacko points out that a preview of 3.4 is available from the http://www.thisiscool.com/gcc_mingw.htm but whether that includes the size modifier I don't know. Neither have I been able to try it yet due to an annoying combination of zero time and a hard drive failure.

As to the array speed test, this does not surprise me but did you try it with the Array Bound Checking switched off in GCJ?

The simple fact is that the array fill is compiling into exactly what it has been asked to be. Which is not particully optimal for execution speed on the cpu and memory subsystem. This is a problem of it looking fast to humans, but not being fast for a cpu. For example I would not use that code in C (other than for easy of use that is [read laziness  Cheesy]).

There has been a lot of success with GCJ and SWT, for example Eclipse has been successfully compile, which is hardly a small product.

Hopefully using GCJ will become easier.

-------
Woz.
19  Game Development / Performance Tuning / Re: Performance Myths on: 2003-06-27 12:34:22
If you would care to look at the Kaffe Ports page you will notice that this open source JVM has been available for the PS2 for some time: http://www.kaffe.org/ports.shtml

Kaffe has been ported to a vast number of platforms, mainly those ones that Sun can't be bothered with, such as BeOS or  Amiga OS. This is the benefit of open source.

The link points to a Japanese web site( http://www.sofarts.com/oldnew/computer/env-soft/pc-unix/ps2linux/kaffe.htm ), but you will notice in the top left corner there is a button with "English" written in it, this will translate the page into something proposing to be English...

Now before you all start getting excited, I will point out now that it is meant for Linux for PS2:
http://uk.playstation.com/hardware/linux_hardware.jhtml?linktype=NAV
Note the 40Meg hard drive and the 8meg ram card needed.

However, this is not that much different from the rumoured spec for the new PSX featuring DVD writer, 120Meg H-Drive, internet connection etc (see http://www.psx2.com/news/view_news.php?time=1054179401#1054179401 )

But they miss out on any greater technical detail, as memory is going to be vitally important if you are expecting anything other than crappy MIDlets to run on it.

The point being is that its got to be running on some OS for internet connection, and as most likely Linux would be chosen (cant see Windows CE some how).


This also highlights another problem, speed, the CPU in the PS2 runs at 294Mhz and is a RISC processor, with 8K data cache its going to be hard on Java.

But I couldn't find the memory bus speed, or the width of the data bus (32,64, 128 bits), used to know it but have forgotten.  It also uses dreaded RD-Ram (Rimbus anyone? Thought not), Which is fine for bandwidth but has very poor latency. These are more important.

32 Meg of ram, of which 4 Meg is Vram hardly cuts it today either.


(A technical overview of the ps2 : http://www.arstechnica.com/cpu/1q99/playstation2-pr.html  Take with a pinch of salt.)


------
Woz.

Don't expect a hotspot compiler, which is arguably a disadvantage to entertainment software anyway.


20  Game Development / Performance Tuning / Re: GCJ, a quest for speed. on: 2003-05-16 12:20:57
GCC 3.3 is released,

containing quite a few changes to GCJ, although not really enough to be useful to most of you. So we'll have to wait for version 3.4 - which was expected anyway.

New GCJ features:
   * The java.sql and javax.sql packages now implement the JDBC 3.0 (JDK 1.4) API.
   * The JDK 1.4 assert facility has been implemented.
   * The bytecode interpreter is now direct threaded and thus faster.

But contains plenty of bug fixes, there is to many to list but can be found here http://gcc.gnu.org/gcc-3.3/changes.html.

The http://www.mingw.org version is not yet ready (judging from source forge), but should be soon-ish...

---------------------

Just to clear up what Jacko is saying:

Here is the most exciting "hello world" program, in java:


1  
2  
3  
4  
5  
6  
7  
public class hello 
{
  public static void main(String[] args)
  {
    System.out.println("Hello World");
  }
}


Compiling this file using GCJ to produce an .exe file with:
1  
gcj --main=hello -o hello hello.java

Produces a file that is 2,606,061 bytes in size or 2.6Meg !

To remove symbols from the .exe file, compile instead with:

1  
gcj --main=hello -o hello hello.java -Wl,--strip-all 

Be careful with the syntax that is an L in the -Wl, it's also case sensative.
This will produce a file size of 1,816,064 bytes or 1.8 meg.

Using a well known .exe file compressor UPX (Ultimate Packer for eXecutables) by Markus Franz Xaver Johannes Oberhumer (that is just one person) and László Molnár.

This can be located on the UPX web site http://upx.sourceforge.net/.

Using the recommanded switches for best compression :
1  
upx --best --crp-ms=999999 --nrv2d -o hellod.exe hello.exe

Produces a file size of 495,104 bytes or ~483K.

A great improvement on the 2.6 Meg file initially created.

All the best,
-------
Woz.

P.S.
Jacko get back to the revision! You'll only regret it if you mess up your exams!
Best of luck with them too!
21  Game Development / Performance Tuning / Re: A* Pathfinder tutorial on: 2003-05-06 11:00:39
Luke,

A linear search will suffice, as the list is ordered always start at the end nearest to the target location (I assume bottom in your case, but I have a tendency to visualise it at the top - just like the stack in the example).

Because A* always tries to move closer to the target each iteration, it makes sense that each node will either be equal to or grater than the value on the top of the stack (if not very close to it). So you will usually only have to search the first few nodes.

(When I say value I mean the distance value from the current location to the target location).

Unless your map has lots of obstacles, and so may make several wrong decisions, a link list will be fine.

On a map with lots of obstacles you will need to start using a different data structure, like a binary tree, so that you can find the location to insert at quicker (as it could be anywhere in the list). A binary tree will accelerate the search into a binary search, which divides the data set in halve repeatedly until it has found the appropriate location.

In order to simplify and accelerate the check to see if the node is already on the open list, you can use a 2 dimensional array for each location on the map, true for already on the open list, false for available to use.

Most people will reduce this down to a single large array, or use a bitmap to save some space.

------
Woz.

P.S.
Don't worry about the CS degree, you don't need one to be able to write good code.
22  Java Game APIs & Engines / Java Sound & OpenAL / Re: Procedural Instruments on: 2003-05-05 21:26:18
Erik,

To play a RMF (or Rich Music Format (tm) to give it's full name) is no different from play a wav file in java.

It uses the same AudioClip class the only difference is the file name.

For example to play the standard "Ambient.rmf" file that comes with all SDK's in your applet, place the following code in your start() method:

1  
2  
3  
        URL url = MyApplet.class.getResource("Ambient.rmf" );
        AudioClip clip = Applet.newAudioClip(url);
        clip.play();


Where "MyApplet" is the name of your applet class, the "Ambient.rmf" must be placed in the same directory as the generated class files.

The RMF file allows you to create your own instruments, which are stored in the RMF file as well. These are not General Midi instruments (although you have access to all the "soundbank.gm" instruments that comes with Java if you so wish).

These RMF files, even though they contain the insturments as well as the note information are considerably smaller than the same peice of music converted to a wav file. Which just about brings them into the size range for modem users, although it will depend on the size/type/range of instruments used.

Beatnik's .pdf description of the RMF file, albeit a short one, can be found here:
http://www.beatnik.com/pdf_files/rmf_datasheet.pdf.

Which should make clear what a RMF file is, and what it contains.

------
Woz.

23  Java Game APIs & Engines / Java Sound & OpenAL / Re: Procedural Instruments on: 2003-05-05 15:32:49
In order to create RMF files, you need the Beatnik Editor http://www.beatnik.com/products/editor.html which will cost you $299.

Should have made that clearer.

There is no Linux version at all, although it is available for the Mac & Windows.

Using a midi to wave convertor is often a cunning solution when CPU usage is tight, but unfortunately generates some large files unsuitable for modem access. 31Meg for 3 minutes at CD stereo quality.

MP3 would normally be a good idea but prending a lisensing issue MP3 encoding and decoding has been removed from JMF 2.1.1b (Available since, 29-Aug-02, and works with Java 1.4 ).

Personally I would have thought that it was an encoding issue.

------
Woz.
24  Java Game APIs & Engines / Java Sound & OpenAL / Re: Procedural Instruments on: 2003-05-05 12:55:52
Zigbat it is quite possible to create procedual instruments, if you are prepared to spent $299.

In yet another big mistake made by SUN they decided to use proprietary technology to try and improve Java, rather than use open standards.

This is not the first time they've done this and it wont be the last (deciding not to use OpenGL, was another big mistake - although this appears to be a spat between the Java Community Process [JCP] and the ARB).

Of course I would argue that this would never have happened if Java was Open Source in the first place, but then Java is very much product (it wont ever be open source unless IBM buys SUN) and is the only thing that keeps SUN visible in the computer market place (Java this, Java that, J-blahblah).

No hires timer, only mono support for 8Khz .au files in Java 1.1.4, the list goes on.

This behaviour seem to be on purpose too, because they are just not address the issues relevant to game developers. Sure they've always got something round the corner...  This is called vapourware!


It's interesting to note that Microsofts J++ allows access to Direct X, but sun still haven't got things sorted out to an equivalent level.

Does Java support 24bit audio? Does it support 96Khz? Does it support > 32 channels? Will it ever? Not that its got the processing power to use it.

Have they fixed the audio latency problem yet? No, of course this could very well be classes as not possible due to audio being classified as "Hard Real Time", in that any slight pause will cause the audio stream to stop and cause crackling and stutters.

Hard real time applications are very difficult to do in Java, which is why there is a LARGE audio buffer to stop the crackling, this is not helped by Javas poor timing, in both threads and system clock ms accuracy is FAR to low we should be having Mhz timing not some pathetic sub 1 Khz range.

Anyway I'm sure your not that interested in all this so what you need to be doing is creating a RMF file, which is capable of storing both music and instruments of your own creation. You can then just open it like a standard wave file to play in Java.

They still have latency problems though apparently (50-100ms), and from the sun examples I've played with they have timing problems too. But I could hardly say I'm an expert in using them so have a play around yourself rather than taking my word.

Do a search in your JDK/SDK (not JRE) for *.RMF files, there will be a demo for you to try:
SDK 1.3 : There is a Java2D demo containing RMF playback, look for the mix tab (bottom left) "Java Media".
JDK 1.2.1 : Had a separate JavaSound.class demo, that requires running with java demos.Mix.JavaSound

It's quite simple to use (if memory serves correct), something like:
       URL url = JavaSound.class.getResource( name );
       clip = Applet.newAudioClip(url);

In order to create RMF files you will need the Beatnik Editor located here:
http://www.beatnik.com/products/editor.html

The trial version will not save RMF files. The Beatnik Editor is the only piece of software that will allow you to create RMF files (unless things have changed radically since I last looked).

The sound channels (all 32 of them) are at least mixed natively, so you will actually be able to do other things whilst it is playing.

Personally I'd try an XM player, which Beatnik is based on anyway and they are either free or shareware. It's also an open standard so you can write your own player if you so wish.

There are also plenty of Midi to XM converters floating around.

------
Woz.

P.S. This sounds like trolling, but the only way to get SUN to fix it is to get on their back. Have they changes anything since the Java Media Framework implementation??? No.

P.P.S. You don't have to go far to find someone having difficulty implementing JavaX.Sound.
25  Game Development / Performance Tuning / Re: A* Pathfinder tutorial on: 2003-05-03 16:35:02
A typical link list will allow you to insert nodes anywhere in the list.

If you order your link list correctly (not difficult) the nearest node (to the target) will always be at the top, first in the list.

This looks clean in an implementation, but the memory distribution of (the link list) Objects is not contiguous, in that they could located be anywhere in ram. This will generate cache misses (a bad thing).

Although modern Generation Garbage Collection suggests that objects are grouped by age, unfortunately the cache is so small that it will not cover each generations collection of objects (several meg each, or even bigger), the objects are not guaranteed to be localised enough to be in the cache all at the same time.

This is always a major draw back of Object Orientated Languages, which is FAR MORE serious for Java because it does not support structures, which could be used to greater effect in this situation. Although you are not going to get linear memory access (it's a link list after all) at least each link will be very close to the next.

It does, however, eliminate the need for sort the open list each iteration as you can just insert your nodes (typically only 3, 5 if moving diagonally).

I would strongly suggest using a pool of object, to remove any GC activity that WILL occur.

It soon turns into quite a heavy piece of code, simply because it has to be fast (unless your not using it in a real-time situation).

Of course you could always just call it every other frame (or even less). For those that like using Threads it could be possible to stick everything in a round-robin style list and stick it on a low priority and have it running in the back ground, refeshing targets when possible.

------
Woz.



26  Game Development / Performance Tuning / A* Pathfinder tutorial on: 2003-05-02 12:26:43
Hi  all,

I've recently had the pleasure of debugging a friends A* pathfinder routine, and decided to write a tutorial on the subject.

For those that don't know A* is able to find the shortest path between two points avoiding objects in the way.

Which can be located : http://RealmDesigns.Russki.net/?command=tutor&t=3

It is broken down into easy to follow steps, so its relatively painless to follow.

It also covers some of the common pitfalls that will be encountered and performance problems like how to deal with heuristic failure (which is why I've posted it in this forum - moderator shoot me if I'm wrong!)

There is no code, so Cut & Paste Queens will be disappointed..

Anyone implementing it in a real-time enironment is going to have to work on their optimization in order to get lots of objects moving!

I'd certainly like to hear from peoples experience!!
Data structure is definately the key, in order to eliminate the sort per move.

All the best.
------
Woz.

P.S.
Tutorial 2 (Garbage Collection, and how to avoid it) keeps getting bigger and bigger so it isn't finished (probably wont for some time).
But it should at least be interesting!
27  Game Development / Performance Tuning / Re: GCJ, a quest for speed. on: 2003-04-29 11:11:09
Hi all,

just thought I'd inform you all that a *slightly* newer version of the GCC has been release.

I say slightly because its Version 3.2.3 which is a bug fix for V3.2.2.

try: http://gcc.gnu.org/gcc-3.2/changes.html#3.2.3
It does contain a couple of bug fixes for GCJ, but I don't think it will effect any one here (anyone running irix???!).
Bug fixes:
# 9652: libgcj build fails on irix6.5.1[78]
# 10144: gas on solaris complains about bad .stabs lines for java, native as unaffected.

I have no idea why Version 3.3 has not been released yet, althought the preview is still available (can be found in a post above) and works a just fine.

All the best.
-------
Woz.

P.S.
As a side note I noticed Out-of-the-Box 2.0 has been released, which may/may not interested people:
http://www.ejbsolutions.com/new-projects.html
28  Game Development / Performance Tuning / Re: 1.1 performance renderer on: 2003-02-27 14:53:41
Thats because Sun is crap! Lips Sealed Tongue Lips Sealed

That even the idea of providing decent documentation is beyond them.

A MemoryImageSource is a ImageProducer anyway, so there is (usually) little if no difference between performance.

The big kill is the 32 bit colour model over the crappy 24 bit colour model - this makes a massive difference.

But I do hope you are implementing a BufferedImage for Java 2 folk as this much faster than an ImageProducer.

The best thing most Java developers can do is ignore those near useless JavaDocs and go straight for the source code, you will learn more about how java works. Although there are plenty of unreference static attributes - what they are for can sometimes be a mistery!

Don't even get me started on Java Sound, it does work - just! - if you stay with certain parameters. Always use 44.1Khz Stereo 16bit sound as it may not work right if you don't. (Problems with different sound card et al.)

I was under the impression that they had got someone in to fix it, but that was ages ago and still it has the worst latency I have ever seen.

------
Woz.

P.S.
Does this class as trolling? Pitty on the old board they would have thrown me in the troll bin!
29  Game Development / Performance Tuning / Re: GCJ, a quest for speed. on: 2003-02-25 11:28:18
What is Alien Flux?

At the moment I don't think GCJ would be faster than Jet as GCJ is still in it's early stages.

But then you have the ability to turn off bounds checking with GCJ, which is the bit making my fingers itch!

Of course I don't actually have Jet to make a comparision, which sounds like a job for you Cas  Wink

Neither would it meet you magic 5 Meg file size at the moment, as even simple applications are compiling to around 4 meg. Although interestingly the files are initially 1/3 smaller, then mysteriously bump up a meg or so.

Those error messages look quite confusing, I haven't encountered them at all (or at least don't remember).

If this is a large project try starting with a small section and get that running - then enlarge.

It might be just that it is not finding the correct files, although GCJ does have some quirks in its language parser.
things like this:
1  
import java.awt.image.*;

did not work for me, I had to make my libraries explicit
1  
2  
import java.awt.image.MemoryImageSource;
import java.awt.blahblahblah;

(Note: not that the awt exists in GCJ V3.2, I just used it as an example!)

-----
Woz.

30  Game Development / Performance Tuning / Re: 1.1 performance renderer on: 2003-02-25 11:09:54
This is perfectly normal I'm afraid.

You should try using a 32 bit colour model though with:
1  
dcmModel = new DirectColorModel(32, 0xff0000, 0xff00, 0xff);


Using a desktop colour depth of 16bits will also speed this up considerably.

Although at the end of the day the PIII just falls over - best solution for this is to get an Athlon!

You should also try using a BufferedImage, this will speed it up to the point of a redraw being a non-issue, especially in Java 1.4.1 as MemoryImageSource has been sidelined (since 1.2.1 I believe) and has steadily been getting slower and more buggie (I wont use 1.4.1 until it's fixed).

So slow in fact that MS 1.1.4 JVM can usually beat it (but there in lies a riddle, with an interesting answer).

Interestingly it is still quicker to use a 32bit colour BufferedImage when using a 16bit colour desktop, especially for IBM's 1.3 JVM.

-----
Woz.
Pages: [1] 2
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (27 views)
2014-04-15 18:08:23

BurntPizza (23 views)
2014-04-15 03:46:01

UprightPath (38 views)
2014-04-14 17:39:50

UprightPath (20 views)
2014-04-14 17:35:47

Porlus (36 views)
2014-04-14 15:48:38

tom_mai78101 (61 views)
2014-04-10 04:04:31

BurntPizza (119 views)
2014-04-08 23:06:04

tom_mai78101 (219 views)
2014-04-05 13:34:39

trollwarrior1 (186 views)
2014-04-04 12:06:45

CJLetsGame (193 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!