GGVm: Port, Package, and Protect NES rom for PC, Mobile

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

GGVm: Port, Package, and Protect NES rom for PC, Mobile

Post by GradualGames »

GGVm is a porting layer for NES homebrew games. It's similar to an emulator, but a small amount of customization needs to be done for most games. The goal is for it to be a convenient, free, no-strings attached way for an NES homebrew developer to get their game wrapped up and ready to publish on multiple platforms without having to pay anybody or ask for permission.

GGVm supports a subset of the NES's full capabilities. This subset was chosen to support the needs of most of today's homebrew developers. This enabled us to complete the project quickly enough to return to creating homebrew games. In addition, this allowed us to take large shortcuts in how the system is emulated, which enables games to run smoothly at 60 fps with little or no stuttering even on somewhat old Android devices. Please read the feature list below to get an idea of what GGVm's capabilities are.

Here is the github repository.
GGVm on Github

If you wish to donate to support the development of GGVm, you may paypal the following email address:
gradualgames@gmail.com

Here is the Wiki. This is a repository for information about publishing on digital platforms.
GGVm Wiki

Here's a demo of Dushlan, an open source NES game, wrapped up in GGVm. You'll need Java to run it.
Download Dushlan GGVm jar

Here's the same demo, packaged up in GGVm for Android. You'll want to hook up a usb cable, turn on "unknown sources" in your settings, put the file somewhere and install it via a file manager on your android device.

Download Dushlan APK

Here's The Legends of Owlia (demo) packaged up in GGVm for Android.
Download The Legends of Owlia DEMO APK

Here are some games that were adapted to GGVm. Some are on Steam, itch.io, or KickStarter! Games can be packaged up for the following platforms with the push of a button and no modified code:
  • -Windows
    -Mac
    -Linux
    -Android
    -iOS
For PC, games can be distributed as a Jar, if desired, or, GGVm's build system is also easy to use to package up your game with an embedded JRE for your target platform so users do not have to fiddle with installing Java. It also minifies the JRE so you're not distributing large chunks of the JRE that are not used by your game.

Touch controls for mobile platforms are functional and close to completion.

Features and limitations:
  • -Smooth 60fps play on pc systems up to ~8 years old and on Android phones and tablets up to ~3 years old that I have tested. Running at 60fps on devices as old as iPad 2nd gen.
    -No input lag added beyond latency already present in the controller subsystem.
    -Games must not rely on CPU for timing, only nmi (for example, Dushlan had used cpu for gameplay timing---I modified it to use nmis instead)
    -6502 cpu core. Only write your game ONCE, for the NES!
    -No real PPU emulation. Split screen capabilities are provided via special registers.
    -No real APU emulation. Games must write to special GGVm only hardware registers to play music and sfx back from a list that you provide from your game module.
    -Background sprites may partially hide foreground sprites, assuming bg sprites are solid 8x8 squares of pixels.
    -You can leave out the iNES header and configure from GGVM, which discourages someone from extracting your rom.
    -Due to coding audio adapter, you can gut sound-engine. Thus if anyone extracts your ROM, it'll have no audio and they wasted their time.
    -Mapper 0, 2, and 30 supported. Mapper 4 support is planned.
    -Live CHR-RAM streaming supported
    -No undocumented cpu opcodes supported yet, but can add support
    -Automatic save/restore state
    -Controller configuration for XBOX 360 and Retrousb controllers, manual config for others
    -Windowed or fullscreen mode
GGVm is always going to be 100% free. The whole point of this project is to allow NES homebrewers to publish on the modern platform of their choice without paying anybody or asking permission of an emulator author. That said, I am not turning away donations in return for volunteering to help adapt games to GGVm.

In case you're wondering, GGVm stands for: "Gradual Games Virtual Machine."
Last edited by GradualGames on Tue Jun 20, 2017 7:59 am, edited 70 times in total.
User avatar
Dwedit
Posts: 4922
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Help me test my emulator, GGVm, by sending me a demo ROM

Post by Dwedit »

I guess my Chu Chu Rocket clone is way out of the question, being written for the tight timing of a NES.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: Help me test my emulator, GGVm, by sending me a demo ROM

Post by GradualGames »

By timing dependent I mean free of bugs that are related to timing. I.e. if somehow the NES could change its cpu speed arbitrarily and randomly your game would be robust against that and not crash.

But timing involving say, split screens or several split points should be supportable. It's designed to do as little as possible emulating the actual hardware, so each game requires game-specific adapters for the graphics or audio. Super simple games with no split screens will work out of the box.

As an example from my own game The Legends of Owlia I had precisely timed empty loops at the end of my constant-timed vblank routine to keep graphics off for 16 scanlines at the top of the screen to hide scrolling updates. For the adaptation to GGVm, I removed all this code from the actual ROM and instead I have an adapter in place that just draws a black rectangle over the top 16 scanlines where the scroll updates are occurring.

I saw this as a compromise between working out a contract with a full emulator author and fully rewriting my game for PC. Interestingly enough it seems to support how many other homebrew games were written.
User avatar
Dwedit
Posts: 4922
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Help me test my emulator, GGVm, by sending me a demo ROM

Post by Dwedit »

So what's the benefit to not just use an accurate emulator?
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: Help me test my emulator, GGVm, by sending me a demo ROM

Post by GradualGames »

The benefit for me was I didn't have to ask permission or pay anybody. I'm planning to give ggvm to fellow homebrewers totally unlicensed, so they can distribute on several platforms with only modest effort (usually about an afternoon to a weekend of work to adapt a given game).

If somebody comes along and offers a full emulator no strings attached that can push to pc, mac, linux, android, and iOS without changing a line of code, then there'd be no reason to offer ggvm at that point, but to my knowledge this hasn't been done yet.

Another benefit is, due to ggvm's design, should any rom-hackers extract the rom from the wrapped up executable, they will have a broken rom: No iNES header. And if they fill in the header, no music engine or data will be there they will have a broken rom and will have wasted their time. All that is of course possible with a real emulator too, but with ggvm it's designed from the start to make it fairly easy to do this and you kinda have to if you want your game fully operational.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Help me test my emulator, GGVm, by sending me a demo ROM

Post by tepples »

GradualGames wrote:Supported mappers right now are Mapper 0 and Mapper 2, however it shouldn't be too hard to implement new mappers.
I'd recommend extending mapper 2 implementation to cover the Action 53 mapper (28), which has mappers 0, 2, 3, 7, and half of 34 as subsets. There's a test ROM; search this forum for "test28".
GradualGames wrote:I'll be adding Mapper 4 at some point as my current game project uses it.
My employer might be interested in this. Where can I donate to support this project?
GradualGames wrote:All games require a game-specific adapter to be written to support the soundtrack as there is no APU emulation. Instead ggvm listens to sound engine calls and turns these into playback of OGG files.
Can it play them at different rates, such as what happens when you knock a shell into multiple enemies in Super Mario World or multiple explosions in Tetris Attack? I'm told SDL_mixer's one weakness is resampling.
GradualGames wrote:By timing dependent I mean free of bugs that are related to timing. I.e. if somehow the NES could change its cpu speed arbitrarily and randomly your game would be robust against that and not crash.
Does this include timing to read the vertical position of the light gun from $4017 D3? Or will have to be ported to a different protocol, such as Oeka Kids if absolute or Mario Paint if relative?
GradualGames wrote:I'm planning to give ggvm to fellow homebrewers totally unlicensed
Point of terminology: "Unlicensed" in copyright law means look but don't touch. You need to attach some sort of license just so they can use it, even if it's something as all-permissive as the zlib license or the WTFPL, or a public domain dedication instrument such as the so-called Unlicense or Creative Commons Zero.
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: Help me test my emulator, GGVm, by sending me a demo ROM

Post by GradualGames »

tepples wrote:
GradualGames wrote:Supported mappers right now are Mapper 0 and Mapper 2, however it shouldn't be too hard to implement new mappers.
I'd recommend extending mapper 2 implementation to cover the Action 53 mapper (28), which has mappers 0, 2, 3, 7, and half of 34 as subsets. There's a test ROM; search this forum for "test28".
My plan for mappers is to add them as I need them, or add ones that a particular homebrewer's game uses, to help them out.
tepples wrote:
GradualGames wrote:I'll be adding Mapper 4 at some point as my current game project uses it.
My employer might be interested in this. Where can I donate to support this project?
I'm not interested in donations, but once I have this up on github you'd be quite welcome to use it. *edit* It turns out folks continue to offer donations, and I'm not turning these away as a consultant in getting games set up in ggvm. It is not required, however.
tepples wrote:
GradualGames wrote:All games require a game-specific adapter to be written to support the soundtrack as there is no APU emulation. Instead ggvm listens to sound engine calls and turns these into playback of OGG files.
Can it play them at different rates, such as what happens when you knock a shell into multiple enemies in Super Mario World or multiple explosions in Tetris Attack? I'm told SDL_mixer's one weakness is resampling.
In theory it can, I think, I haven't tried it. But if the game's sound engine calls included a parameter for speed of playback of a sound effect, it should be possible in theory when writing that game's adapter.
tepples wrote:
GradualGames wrote:By timing dependent I mean free of bugs that are related to timing. I.e. if somehow the NES could change its cpu speed arbitrarily and randomly your game would be robust against that and not crash.
Does this include timing to read the vertical position of the light gun from $4017 D3? Or will have to be ported to a different protocol, such as Oeka Kids if absolute or Mario Paint if relative?
This is outside my realm of expertise, haha. I have no plans of adding peripherals other than controller to this emulator. I actually prefer to call it a virtual machine that my games (and some other homebrews) happen to be compatible with as well as the NES.
tepples wrote:
GradualGames wrote:I'm planning to give ggvm to fellow homebrewers totally unlicensed
Point of terminology: "Unlicensed" in copyright law means look but don't touch. You need to attach some sort of license just so they can use it, even if it's something as all-permissive as the zlib license or the WTFPL, or a public domain dedication instrument such as the so-called Unlicense or Creative Commons Zero.
If I do put this on github I'll be including UNLICENSE with it. I have absolutely zero interest in having anybody pay me or ask me permission, I just want fellow homebrewers to be able to have total freedom in publishing their games on pretty much everything, without having to worry too much about platform specific details, provided their games do match the imposed requirements listed above.
Last edited by GradualGames on Wed Mar 15, 2017 5:48 am, edited 1 time in total.
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: Help me test my emulator, GGVm, by sending me a demo ROM

Post by GradualGames »

Just checked. The library ggvm uses does provide a "pitch" parameter when playing back sound effects. So yes, playing sfx at different rates can be supported on a per game basis. That might not be what you meant though, if you meant playing back a sfx without pitch modified but at a different speed (feeding the various parameters through square 1, 2, triangle, noise etc.)...then no, this is not possible. In that case you would have to record several different versions of the sound effect.
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: GGVm, the free NES homebrew emulator

Post by GradualGames »

OP updated with Dushlan, an open source NES game, wrapped up in GGVm, as a demo. You'll need Java to run it. I'm hoping to have GGVm's source code available soon, probably on github as I anticipate some community involvement in the project.

Download Dushlan GGVm jar
Last edited by GradualGames on Fri Mar 10, 2017 5:47 pm, edited 2 times in total.
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: GGVm: Port, package, and protect NES rom on PC, Android,

Post by GradualGames »

Previously, games which were not 100% robust against nmi landing in unsafe spots required hacks to the game rom itself to work in GGVm. This is no longer necessary, provided games still use nmi for timing and synchronization.
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: GGVm: Port, package, and protect NES rom to PC, Android,

Post by FrankenGraphics »

This is some really great, possibility-expanding work. Just wanted to cheer you on! :beer:
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: GGVm: Port, package, and protect NES rom to PC, Android,

Post by GradualGames »

OP updated with new version of the Dushlan ggvm jar, available here:
Download Dushlan GGVm jar

A couple of subtle bugs were fixed, such as during screen transitions.

Things are getting a lot cleaner in the build process, and once I have the mobile controls implemented I'm going to be making the source code available.
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: GGVm: Port, package, and protect NES rom to PC, Mobile

Post by GradualGames »

GGVm demo featuring Dushlan available as an apk for Android.

Download Dushlan APK

Note: touch controls still under development, they are ugly and have bugs. Working on it.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: GGVm: Port, package, and protect NES rom to PC, Mobile

Post by tepples »

Speaking of "touch controls", do you plan to offer a mode that exposes touch coordinates directly to the emulated game, for things like in-game menus and Thwaite?
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: GGVm: Port, package, and protect NES rom to PC, Mobile

Post by GradualGames »

tepples wrote:Speaking of "touch controls", do you plan to offer a mode that exposes touch coordinates directly to the emulated game, for things like in-game menus and Thwaite?
That's a fun idea. It's certainly possible. I guess games which use a mouse peripheral would benefit from that perhaps (I thought I heard about a game in development which uses a mouse somehow). Or even something like Duck Hunt. Haha. Though, that'd make that game too easy probably :lol:
Post Reply