This is my second attempt at making a NES emulator. I wrote one before, but the code was too much of a mess. Now I'm porting it to organized code using OpenGL and SDL Audio, so I think it's portable across many platforms, but currently it's only on Windows. It can emulate several games at once, and I thought it would be nice to have a little gallery of recent played games on startup, all showing running screens (I'm thinking of showing the user's savestates and old plays through the games, so it's more interesting). Maybe someone did that before?

If it is open-source and compatible with C programs and cross-platform, then I might be interested in such thing.

Well, C++ programs can work with a C interface, right? Or maybe you need it entirely in C (which is also possible to do)? It is cross-platform because it only uses the C standard library. I'm just wrapping up some things before releasing it.

Open-source is my goal - I mean, it can't harm, can it? I'm not making profit with this anyway. I just don't really know what the guidelines for releasing open-source software are... What license should I choose, how can I still take credit, and all that.

Dwedit wrote:

What a misleading filename, OpenAL32.dll is an X64 file. I can't run this on my 32-bit operating system.

OpenAL sucks, I think. It's really unstable (at least with me!), and I can't even tweak some settings without the audio getting all chopped and distorted. I don't know well any other audio playing libraries...

It can emulate several games at once, and I thought it would be nice to have a little gallery of recent played games on startup, all showing running screens (I'm thinking of showing the user's savestates and old plays through the games, so it's more interesting). Maybe someone did that before?

A weak copyleft means the library can be used in proprietary projects, but improvements to the library itself must be made available to the public. Use Mozilla Public License/GNU Lesser General Public License dual-license, as Firefox does.

Well, I'm late to this NES thing, anyway. The project started as a way for me to learn more. I wasn't hoping of being innovative.

Maybe I should port my code to pure C? Don't know if that would help its usefulness and "uniqueness"...

Sorry, I wasn't trying to snuff your effort. I was only pointing to the emulator library that I created with similar goals. At present it's only used in two applications--that I know of. Both mine. I didn't use blargg's blip_buffer library...I probably should. But the library interface seems very similar to what you posted.

I probably will catch a lot of noise for this but I don't believe there's any difference whether you choose C or C++. Completely crappy code can be written in either, as can completely concise and correct code.

SDL does sound. I don't know how well, though. Plus it's multi-plat. I tinker with it, it seems okay.

ETA: I would stick with C. I don't want to learn C++ for what reason Linus of Linux has stated, plus it seems like nothing but bloat. Making it objectified might help you, but not others looking at the source.

Last edited by 3gengames on Fri Jan 11, 2013 10:14 pm, edited 1 time in total.

I think that a NES emulator library that's portable and has a clean interface is an asset. It's worth the experience making something really clean and easy to use, as that's often lacking. I aimed for too much performance and made the implementation more complex than was maintainable, and it suffered.

HLorenzi wrote:

Is there something like that already?

kode54 released the source to nes_emu (which QuickNES is based on). It's also mostly portable (I believe it might do some unaligned 32-bit integer accesses, making it fail on some ARM processors). It makes no OS calls, just standard C library stuff. I can't remember whether it has a C wrapper like my other libraries. I haven't worked on it in years, which is why kode54 has been maintaining it.

Quote:

Maybe I should port my code to pure C? Don't know if that would help its usefulness and "uniqueness"...

I tried to port something to C and it was so tedious. Until C and C++ compilers aren't bundled, using "light" C++ is so much more maintainable, and you can easily make a C interface wrapper, which is nice for even C++ clients since it insulates them from changes to your classes etc. and makes the shared library interface more stable across versions.

I think that a NES emulator library that's portable and has a clean interface is an asset. It's worth the experience making something really clean and easy to use, as that's often lacking. I aimed for too much performance and made the implementation more complex than was maintainable, and it suffered.

I'm not saying it's perfect...but...The library I linked has no reliance on any sound or video production libraries. It provides bitmasks for reference so you can pass the controller bits in the right order--but otherwise makes no reference to keyboard, joystick, mouse, or other input technologies. nesSetControllerScreenPosition, for example, could be set from a mouse's position or some other position-aware input device. I admit that the nes_emulator_core.h file could use a lot of clean up...lots of stuff in there that should be elsewhere, but the main gist of the library (with some corrections...some comments were slightly wrong) is:

Code:

// Exported interfaces.// The following interfaces are to be used by a UI to interact with the emulation// core and perform the necessary steps to emulate a NES game. Those steps are:// 1. Set the NES system mode to MODE_NTSC, MODE_DENDY or MODE_PAL using nesSetSystemMode().// 2. Provide a 256x256x4-byte chunk of memory to the emulator core for it to// render the NES TV surface onto, using nesSetTVOut().// 3. Clear any emulation state by using nesUnloadROM().// 4. Pass 16KB PRG-ROM banks in order and 8KB CHR-ROM banks in order to the emulation// core by using nesLoadPRGROMBank() and nesLoadCHRROMBank() respectively. If no// CHR-ROM banks are present, do not call nesLoadCHRROMBank().// 5. If the game has fixed mirroring, tell the emulator core which one it is by// using nesSetHorizontalMirroring() or nesSetVerticalMirroring().// 6. Tell the emulator core you're done passing it ROM data by using// nesLoadROM().// 7. Cause the loaded ROM to be recognized by the emulator core by issuing a// reset. Use the nesResetInitial(mapper) variant to set up the emulator core with the// appropriate mapper for the loaded ROM. Subsequent resets can use the nesReset()// variant.// 8. Run a PPU (video) frame's worth of NES emulation, which generates a full// rendered video frame and an appropriate amount of audio data, by using// nesRun(). Pass in collected joypad input data.// 9. If the emulator supports sound output, the number of audio samples available// can be retrieved by using nesGetAudioSamplesAvailable(). A pointer to the// next buffer of audio samples to play can be retrieved using nesGetAudioSamples().// Once retrieved, the number of available audio samples should be reset using// nesClearAudioSamplesAvailable.

A weak copyleft means the library can be used in proprietary projects, but improvements to the library itself must be made available to the public. Use Mozilla Public License/GNU Lesser General Public License dual-license, as Firefox does.

A permissive license encourages voluntary collaboration among developers who use it. The others rely on forced collaboration and have involved terms which must be followed, which turns away some developers who prefer voluntary collaboration and simplicity. Neither will cause collaboration where there's lack of interest or potential; the best way to get people helping is to form a group of people who want to work on the software. The idea is to focus on making the software valuable, rather than on worrying about how others put it to use.

Who is online

Users browsing this forum: No registered users and 3 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum