(sorry for not posting in this thread for a while, but I've been busy..)
It seems like the performance problem is in the timing code. When the app needs to pause for a specified number of microsecs, this code is run:
public void sleep(long timeMicros){
t1 = currentMicros();
t2 = t1;
while(t2-t1 < timeMicros){
if((t1+timeMicros)-t2 > 500){
try{
thr.sleep(1);
}catch(Exception e){}
}
t2 = currentMicros();
}
}
currentMicros() uses the sun.misc.Perf counter.
Earlier, this ran very smoothly, but after some optimization of the cpu emulation, I got the same problems as I mentioned in the posts above. The speed drops by factor of at least 4. It seems like the looping is the problem, when I use this code instead:
try{
thr.sleep(timeMicros/1000);
}catch(Exception e){}
it runs at normal speed (but not as smooth).
I tried combining the two, having it always sleep at least once, and adjusting the sleeping time, but it didn't help any. As long as it loops at the end of the interval, the speed drop occurs. Do you know of any solutions to this problem?
BTW, an applet version is now available here:
http://www.stud.ntnu.no/~erlinga/nesapplet/fubarnes.php