NESCore 0.9 now up for general use

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
NESCore 0.9 now up for general use
by on (#26997)
http://iphone.natetrue.com/nescore/

NESCore is a multi-platform Nintendo Entertainment System emulation core designed for high portability on mobile and embedded devices. Although NESCore can be easily ported to run on many desktop platforms, it has been designed with performance in mind, rather than accuracy. Certain options, however, can be turned on to trade off speed for better accuracy on faster CPUs.

Implementing NESCore requires minimal coding, only of operating-system specific functions to manage controller presses, video, and sound.

NESCore was originally forked from InfoNES, which was derived from pNESx. The original author of InfoNES refused to repair many (many) problems with his emulator core, and thus NESCore was born. NESCore provides a significant rewrite of the old InfoNES core, fixes many problems, and provides new features such as integrated Game Genie support. If you are using InfoNES in your project, it should be very simple to switch to NESCore.

I invite any constructive feedback and/or patches.

by on (#29392)
Hey,

I am playing around with nes emulation on the nintendo DS. So far I have found two existing emulators for this platform:
1) nesds: high speed, but it has problems with the two games I own and want to play (punchout, and super mario 1). The source code is available, but it won't compile without a commercial ARM compiler. The code is a a huge crystal of arm assembly that I doubt I can port to the free devkitpro compiler.
2) nesterds 0.3. Older, and runs unplayably slowly. Additionally, doesn't support run-time rom loading (ie, you build the rom into the exe). I have the source code, and after some tweaking, I can build it with the latest devkitpro/libnds

I'm considering creating a franken-nesterds based on nesterds, but with run time rom loading using the libfat with the latest libnds. The problem of speed still remains. So far I have been playing with some manual profiling (anyone have tips on doing this on a DS?), but I haven't found a defining "problem-to-fix" yet.

I'm also considering replacing the nes core on the nesterds base. I think its an older core (copyrights say 2000), and I believe I could replace it with a more modern core. I see it uses floats/doubles/division a few times per rendered frame, which I think I can remove.


So, I'm considering plugging Nervegas's Nescore into this code.

Is the Nescore understandable and fast enough? Will it run punchout playably (not perfect, just reasonably playable)?

by on (#29399)
I'm kinda on-and off about porting PocketNES's code to target GCC. (nesds is basically pocketnes). If you want, I could try to jump forward in porting it over.
Since PocketNES and NesDS get most of their speed from using the GBA 2D hardware to run graphics, I think it would be a much better effort to port NesDS over to GCC, than to modify a NES emulator which generates graphics in software.

In a couple weeks, I will have a break from school where I could try to fix up Punch Out in PocketNES.

Hey, I was wondering if you could whip up an SDL version of Nescore so I can see it in action.

by on (#29410)
I like nesDS for the most part, it's just the lack of DMC/raw support that really bothers me. Why couldn't that be included, anyway?

by on (#29414)
For one thing, when nesDS was still being actively developed, the sound hardware of the DS wasn't fully reverse engineered, and DS emulators running on PC weren't close to accurate.

by on (#29417)
NesDS uses Nezplug for its sound, but didn't seem to completely use all parts.

by on (#29418)
hey, here is a messy sdl demo build i whipped together for nescore. No real user input, audio, etc. Also, the color table is somehow very wrong.

http://members.cox.net/red_mage/NESCore_sdldemo.zip

It built for me with sdl/mingw. By default I ran and tested it with galaxxon.nes, a homebrew CMU Nes rom freely available from: http://bobrost.com/nes/games.php

Added:
Apologies for how messy it is. Today was my first use of SDL and second day of looking at NeScore. NesCore is very clean to implement out of the box. I'm less clear on implementing it on the arm7/9 pair.

One more thing: Out of the box, nescore needed select, which I could not get to work in my WinXP/mingw environment (even with trying winsock 1 and 2). I replaced it with Sleep. I'm not 100% sure about that, but thats all it seemed to be used for in the original nescore. I may have tweaked a few other items. I'd suggest running a diff if particulars are needed.

by on (#29420)
It fails at slalom.

by on (#29425)
My experience so far:
I've run it with the galaxxon cmu project rom. It seems to run ok. It crashes with punchout! until I went and commented out calls to NESCore_pAPU_VSync();, then it seems to run, with some minor texture issues. I tried running megaman and it seemed to work through the opening scenes.

Again, this isn't my library, I just tried plugging it into SDL to see what would happen. Its possible I'm not using it correctly.

by on (#29454)
I rewrote the SDL front-end to have proper colors and sound, and couldn't help making a few changes to the nescore source to make it more portable and compile with ANSI C (source code only, no executable):

NESCore-sdl-mod.zip

Tip: libraries should be configurable without having to modify the headers/source files. I made some changes towards this goal.

by on (#29455)
Wow,

I am new to these boards and I am very impressed with how helpful everyone is here. Thanks for the rewrite blargg, I'm checking it out now. And thanks Dwedit for offering to take a look at pocketnes updates. And of course thanks to NerveGas for the nescore. I'm having a bunch of fun poking around with this.

by on (#29456)
I just built the nescore SDL version with Visual C++ 6.0, and I'm getting major game logic bugs in Slalom. Looks like Visual C++ 6's optimizer may be messing this up, because a Debug build works fine.
Edit: Works fine when I build it on cygwin, just the usual slalom graphics errors.
-------------------------------
by on (#29459)
I got blargg's version to work. On my environment, I included <windows.h> in sdl_demo.c to get Sleep(). This machine has no sound so I could not test that. Build lines that worked with mingw:
Code:
gcc -c -DUNIX_WAIT -DNO_DECIMAL  sdl_demo.c -o sdl_demo.o
gcc -c -DUNIX_WAIT -DNO_DECIMAL  sync_audio.c -o sync_audio.o
gcc -c -DUNIX_WAIT -DNO_DECIMAL  nescore/M6502.c -o nescore/M6502.o
gcc -c -DUNIX_WAIT -DNO_DECIMAL  nescore/NESCore_pAPU.c -o nescore/NESCore_pAPU.o
gcc -c -DUNIX_WAIT -DNO_DECIMAL  nescore/NESCore_Mapper.c -o nescore/NESCore_Mapper.o
gcc -c -DUNIX_WAIT -DNO_DECIMAL  nescore/NESCore.c -o nescore/NESCore.o
gcc -o NES sdl_demo.o sync_audio.o nescore/M6502.o nescore/NESCore.o nescore/NESCore_Mapper.o nescore/NESCore_pAPU.o -lmingw32 -lSDLmain -lSDL -mwindows -mno-cygwin


I ran Galaxxon fine. Then I tried nestress.nes. (I have no firm idea of how the results of this should be interpreted). With the DNO_DECIMAL, the cpu test went perfectly. As an aside, the default should probably be no decimal and you should have to define DO_DECIMAL or something like that.

The most significant nestress problem I saw was it failing the sprite collision test.

Also, as far as input - I'm unclear on exactly what the controller's normal functions are, but in the controller test, it looked a bit off to me. I'll have to read up on that.

by on (#29460)
Dwedit wrote:
I just built the nescore SDL version with Visual C++ 6.0, and I'm getting major game logic bugs in Slalom. Looks like Visual C++ 6's optimizer may be messing this up, because a Debug build works fine.
Edit: Works fine when I build it on cygwin, just the usual slalom graphics errors.


It not working with your optimizer is a worry. It has been my experience that more often than not, this is a sign of a c runtime error.