Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  fubarNES NES emulator  (Read 4431 times)
0 Members and 1 Guest are viewing this topic.
Offline coramoor

Senior Newbie




Java games rock!


« Posted 2003-12-02 21:46:55 »

Hi!

I'm currently coding an NES emulator, and need some feedback on whether it will run/how fast on different systems..

http://www.stud.ntnu.no/~erlinga/nesemu/fubarNES_03.zip

Edit: Webstart version now available:
http://www.stud.ntnu.no/~erlinga/nesapplet/webstart/launch.jnlp

I've tried underclocking my own system, trying out different cpu speeds, but that's not likely to resemble the performance on a system with slower memory, etc. I want to know what is the lowest specs it will run on.
There is no FPS counter, but if the sound is ok, it should be locked on 60FPS.

The emulation is far from perfect yet, but a lot of games do actually work (like the Super Mario and Adventure Island games, Journey To Silius, Ducktales, etc). You'll have to get ROMs to test it with yourself, though   Tongue
Offline tortoise

Junior Member




<3 Shmups


« Reply #1 - Posted 2003-12-02 22:02:07 »

Runs very well on my machine, solid 60fps. In comparison, I can just barely get 10fps with NesCafe (another Java NES emulator). I have an Athlon 1.1ghz, 640megs of ram, WinXP, Sun Java 1.4.2.
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #2 - Posted 2003-12-03 14:26:29 »

Runs horrible (sry Smiley) on my machine with 2-5 fps (I can count em).

K7 500, 128mb, gf2mx, win98se, java 1.4.2 (it would be nice to know if it works with 700 or 800 mhz)

Oh and no sound at all... I expected to get ugly noise n stuff but it was just silent (sound was default-ish enabled).

Webstart would be nice (autoupdates n stuff... /me points at that 0.3 Smiley)

The filechooser should start in the current working directory (usually the way to the roms is shorter then).

Well looks nice so far. GJ Smiley

Ooooh and a small nice NSF player would be cool (little spinoff project for the next rainy sunday)

弾幕 ☆ @mahonnaiseblog
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline coramoor

Senior Newbie




Java games rock!


« Reply #3 - Posted 2003-12-03 14:54:28 »

It could be either a problem with the timing (I'm using the perftimer), or the sound code..
I've tested it on some 700 MHz pc's at university, and it seems to run at almost full speed with sound disabled, so I expect you should get more than 2-5 FPS if the code was correct..

I'll probably take a look at it after christmas, right now there are some horrible exams I have to study full time for  Huh
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #4 - Posted 2003-12-03 15:08:54 »

Hadn't noticed a big speed increase after disabling sound... unlikely that it's the fault of the sound code.

Well good luck with your exams Smiley

弾幕 ☆ @mahonnaiseblog
Offline coramoor

Senior Newbie




Java games rock!


« Reply #5 - Posted 2003-12-19 11:07:05 »

I don't get this.. I'm testing the emu on a system with 1.2 GHz AMD Athlon CPU, and it's slow as hell.. Why does it run faster on a 750 MHz machine?? What's up with java? (BTW I'm using 1.4.2_03).

I tried profiling the app, but it gave the exact same results as on the systems it works with. There's some garbage collecting going on, but not on that scale.. Any ideas?  Huh
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #6 - Posted 2003-12-19 11:37:22 »

Can you post the profiler output of both systems?

Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #7 - Posted 2003-12-19 13:56:22 »

Quote
I don't get this.. I'm testing the emu on a system with 1.2 GHz AMD Athlon CPU, and it's slow as hell.. Why does it run faster on a 750 MHz machine?? What's up with java? (BTW I'm using 1.4.2_03).


Different graphics cards?  Different graphics drivers? Different operating systems (winXP vs win98)?  Different anything other than CPU??

Offline Jeff

JGO Coder




Got any cats?


« Reply #8 - Posted 2003-12-19 16:22:46 »

As the other guys have said.  Job one for any performance analysis is a profile.

Once you've done that you may even answer your own question.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline coramoor

Senior Newbie




Java games rock!


« Reply #9 - Posted 2004-03-17 12:20:47 »

(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
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline coramoor

Senior Newbie




Java games rock!


« Reply #10 - Posted 2004-06-10 14:53:24 »

Hi again,

I've done some changes to the rendering and sound code of the emulator, and now it seems to run a lot faster, at least on my computer. In fullscreen (without scaling) I get ~140 FPS with sound disabled (now, if only it wouldn't crash horribly on entering fullscreen mode the second time :-/) I'd appreciate feedback on whether you get it to run any faster now than before :-)

I've also made it webstartable:
http://www.stud.ntnu.no/~erlinga/nesapplet/webstart/launch.jnlp

There's still some trouble with syncing the sound, though Embarrassed
If the sound seems to be ok while the graphics stutter, it's probably because it runs too fast, causing the sound line to block.
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #11 - Posted 2004-06-11 00:05:45 »

Mac OS X 10.3.4  Java 1.4.2

Creating papu channels..
..finished.
Starting PAPU sound lines..
Sound buffer size: 65536
..finished.
Creating new PPU tiles.
HiRes frequency = 33330231
Native library jxinput not loaded due to an UnsatisfiedLinkError.
apple.awt.EventQueueExceptionHandler Caught Throwable : java.lang.NullPointerException
java.lang.NullPointerException
     at GUI.loadRom(GUI.java:814)
     at GUI.actionPerformed(GUI.java:615)
     at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1819)
     at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1872)
     at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
     at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
     at javax.swing.AbstractButton.doClick(AbstractButton.java:321)
     at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1113)
     at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:943)
     at java.awt.Component.processMouseEvent(Component.java:5100)
     at java.awt.Component.processEvent(Component.java:4897)
     at java.awt.Container.processEvent(Container.java:1569)
     at java.awt.Component.dispatchEventImpl(Component.java:3615)
     at java.awt.Container.dispatchEventImpl(Container.java:1627)
     at java.awt.Component.dispatchEvent(Component.java:3477)
     at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
     at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
     at java.awt.Container.dispatchEventImpl(Container.java:1613)
     at java.awt.Window.dispatchEventImpl(Window.java:1606)
     at java.awt.Component.dispatchEvent(Component.java:3477)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:481)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:184)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:170)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

Offline coramoor

Senior Newbie




Java games rock!


« Reply #12 - Posted 2004-06-11 10:49:06 »

Weird, I can't understand what can wrong there..

The code looks like this:

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  
public void loadRom(){
            
            if(filechooser==null)filechooser=new JFileChooser();
            filechooser.setDialogTitle("Load ROM File..");
            filechooser.setAcceptAllFileFilterUsed(true);
            MyRomFileFilter romFilter = new MyRomFileFilter();
            filechooser.addChoosableFileFilter(romFilter);
            
            if(lastDirectory != null){
                  filechooser.setCurrentDirectory(lastDirectory);
            }
            
            int retVal = filechooser.showOpenDialog(this);
            filechooser.removeChoosableFileFilter(romFilter);
            
            if(retVal == JFileChooser.APPROVE_OPTION){
                  lastDirectory = filechooser.getCurrentDirectory();
                  String romFile = filechooser.getSelectedFile().getAbsolutePath();
                  boolean running = nes.getCpu().isRunning();
                  stopEmulation();
                  nes.reset();
                  initBufferViews();
                  if(!nes.loadRom(romFile)){
                        JOptionPane.showMessageDialog(this, "Invalid ROM file!");
                        disableComponents();
                        return;
                  }
                  windowCaption = "fubarNES - "+filechooser.getSelectedFile().getName();
                  setTitle(windowCaption);
                  enableComponents();
                  if(running){
                        startEmulation();
                  }
            }
      }


Do you see anything that could go wrong there? (I've changed the code a bit, so the line numbers don't match) I have no problems running it on any windows machine..

BTW, I checked off 'Notify of Replies', but it doesn't seem to work..
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #13 - Posted 2004-06-11 17:13:31 »

which line is line 814?  That's where the null pointer happned.

Offline coramoor

Senior Newbie




Java games rock!


« Reply #14 - Posted 2004-06-11 17:18:39 »

I know, but I've been modifying the code a bit, so it's not line 814 any longer..
Offline JuddMan

Senior Member


Medals: 1


Your Ad Here


« Reply #15 - Posted 2004-06-22 15:17:45 »

is this emulator based on IMBNes for playstation? it seems to work very similarly to that.

btw webstart no longer works, i dl'd the code, works a little slow. also i take it the save ram system isnt working? smb3 which seems to be constantly using some sort of save ram (probably just a custom chip they put in the cart) keeps spitting out heaps of errors over and over.
Offline coramoor

Senior Newbie




Java games rock!


« Reply #16 - Posted 2004-06-23 11:14:13 »

The code is written from scratch, not based on anything other than the documentation from http://nesdev.parodius.com/.
The webstart version won't work with games that use saveram unless a save directory can be created on the desktop (uses default directory). You could try creating that folder manually.

I've noticed it runs markably slower on some machines. The 1.2 GHz AMD Athlon family PC gives about the same performance as a 750 MHz PC at university (~55 FPS without sound and scaling), so I'll have to compare the specs some time. My own 2.0 GHz system performs a lot better, ~140 FPS. Maybe it's the cache size that's the problem, the CPU emulation code is quite big, and it also does a horrible amount of method calls (the picture processing unit and the sound unit is being clocked for every CPU instruction that's executed).
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

pw (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

ctomni231 (55 views)
2014-07-18 06:55:21

Zero Volt (47 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!