Page 1 of 2

Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 12:52 pm
by AlexE
Is a NES game able to detect if it is being emulated or not? If so, could it be possible to detect if a save state has been made and loaded? It'd be neat to screw with the player for CHEATING.

Re: Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 1:07 pm
by dougeff
No.

But, I can imagine a scenario where you have a password system at the beginning, and you could screw with people who put in a false password by making the game unwinnable... or have special in-game text about cheaters, or make the game ridiculously hard. Lots of options.

Re: Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 1:12 pm
by lidnariq
AlexE wrote:Is a NES game able to detect if it is being emulated or not?
Only in less accurate emulators.
If so, could it be possible to detect if a save state has been made and loaded?
Absolutely not. The entire point of a save state is to store all the state necessary for the game; being able to detect a save state would imply that there was something that the emulator should have and failed to save.

Re: Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 1:47 pm
by tepples
AlexE wrote:Is a NES game able to detect if it is being emulated or not?
On a perfect emulator, no. But it can test for inaccuracies in popular emulators. For example, NESticle does not clear bit 7 of $2000 after reading. During a typical 5-second copyright notice, it can probably squeeze in dozens of behavior tests, just as the HackMii installer on Wii does a bunch of low-level vulnerability tests during its own notice screen.

You could do what arcade games do. Put a security token of some sort on the cartridge, and have the 6502 code depend on what it outputs. In fact, run some of the game logic inside the security token. Running game logic on a separate MCU is why Bubble Bobble was emulated wrong for years until its MCU was finally dumped.

Re: Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 2:03 pm
by rainwarrior
There is no perfect emulator. If you really wanted to, you should be able to devise a test for every known emulator. (I suppose the various NES test ROMs are indirectly a form of this.) Though, any test that an emulator fails that works on the machine might be a call to arms to improve that emulator, at which point you might need to find yourself a new test. Certainly most currently popular NES emulators have very prominent holes in their emulation if you know were to look.

As for detecting savestates, I have no idea how you'd go about doing that. If an emulator correctly knows its own state, there shouldn't be any mechanism for knowing the difference between resuming from a saved state and any other execution.

I don't understand why you'd want to even attempt this, though. Why exactly do you care if people cheat at an NES game?

Re: Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 2:07 pm
by tokumaru
Not to mention that hacking the ROM to skip all these tests should be pretty trivial.

Re: Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 2:17 pm
by tepples
rainwarrior wrote:There is no perfect emulator.
Yet. Eventually someone is likely to create an executable program with a proof of its equivalence to the netlist in Visual 2A03/2C02. Or what bugs have been found in Visual 2A03/2C02?
Why exactly do you care if people cheat at an NES game?
Because it's cheaper than flying top-ranked players out to your location to verify their achievements.

Re: Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 2:25 pm
by rainwarrior
tepples wrote:Or what bugs have been found in Visual 2A03/2C02?
That's a bit of "unknown unknown" territory, since Visual 2A03 is so slow it's not practical for large scale testing. Do you honestly believe it is bug-free and also complete? (As I recall it's been tweaked more than once to fix scanning errors.)

Re: Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 2:31 pm
by tepples
Then someone could at least spot-check it by running it on an FPGA, then run it in parallel with an authentic NES chipset and compare the signals. But that'd take money that the Visual 6502 project doesn't have. Yet.

Re: Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 2:57 pm
by rainwarrior
Also, if you make a mistake your anti-emulator test can backfire and make you look like a fool. :P

There's that lovely RTC 2K demo that tells you it's running on an emulator even if you run it on an NES.

There's games out there that do things like wipe your save game if anything seems amiss. Whether or not this stops cheaters or pirates, it also tends to inconvenience legitimate users as collateral damage.

Re: Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 7:10 pm
by Memblers
You could detect if a Game Genie is being used because it leaves a lot of code in RAM. But then, one can make a code that disables the detection, heh.

Re: Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 11:03 pm
by AlexE
memblers wrote:You could do what arcade games do. Put a security token of some sort on the cartridge, and have the 6502 code depend on what it outputs. In fact, run some of the game logic inside the security token. Running game logic on a separate MCU is why Bubble Bobble was emulated wrong for years until its MCU was finally dumped.
That sounds like a neat idea. I don't know how I would go about doing that exactly, but I'll keep that in mind for when and if I ever go about implementing an emulation detector.
rainwarrior wrote:I don't understand why you'd want to even attempt this, though. Why exactly do you care if people cheat at an NES game?
I've managed to think of two reasons.
  • 1. Valid achievements
  • 2. A self-referential, fourth wall-breaking NES game

Re: Is a NES game able to detect if it is being emulated?

Posted: Thu Mar 03, 2016 11:37 pm
by rainwarrior
What do you mean by "valid achievement" on an NES game?

Like I understand what this means for a platform that has achievements, since you might have an opinion that achievements earned via the built-in achievement system are competitive and/or should be meaningful, but NES doesn't connect to an outside network.

(I don't have that opinion of achievement systems, personally, but that's a side topic of its own.)

Re: Is a NES game able to detect if it is being emulated?

Posted: Fri Mar 04, 2016 2:47 pm
by AlexE
rainwarrior wrote:What do you mean by "valid achievement" on an NES game?
Like I understand what this means for a platform that has achievements, since you might have an opinion that achievements earned via the built-in achievement system are competitive and/or should be meaningful, but NES doesn't connect to an outside network.
(I don't have that opinion of achievement systems, personally, but that's a side topic of its own.)
I never really experienced achievements as something that is made for online gaming. Personally, I always thought of them as a way to provide the player with a "tangible" sense that he's making progress, sort of like positive reinforcing. It's also an opportunity to put in the occasional gag like when in Metal Gear Solid 3 if you kill Ocelot, an important antagonist in the sequels, you get a game over for causing a time paradox and an Achievement that says "Well, the series is over. Go home" or something like that. That might be because I don't do online gaming since my internet can't really handle it, though. Achievements can also provide the player with a replayability factor so that he can complete all the challenges laid out.

Re: Is a NES game able to detect if it is being emulated?

Posted: Fri Mar 04, 2016 3:59 pm
by rainwarrior
Perhaps I should rephrase: what is an "achievement" in an NES game, and what makes it "valid", and why would you want to address the validity with an anti-cheat mechanism? The key part that I'm very curious about is the NES context, specifically.

Do you just mean you want to prevent people from cheating at your game?