Do Mapper 0 games use illegal opcodes? (no, a bit, a lot?)

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Petruza
Posts: 307
Joined: Mon Dec 22, 2008 10:45 pm
Location: Argentina

Do Mapper 0 games use illegal opcodes? (no, a bit, a lot?)

Post by Petruza »

I've compared my emulator's disassembly to nestest's log and fixed every difference until I hit an illegal opcode, of which I haven't implemented any yet.
Since my phase 1 goal is making the emulator work with mapper 0 games, I'd like to know if implementing all the illegal codes is a must or if I can avoid them for now.
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by thefox »

Practically no games use them. So yes, you can skip them when you're just getting started.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
Petruza
Posts: 307
Joined: Mon Dec 22, 2008 10:45 pm
Location: Argentina

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by Petruza »

Yay! thanks.
Sik
Posts: 1589
Joined: Thu Aug 12, 2010 3:43 am

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by Sik »

I think Nintendo had imposed a ban on them, hadn't they? That doesn't mean some didn't slip past them but it explains why they're so rare in general. (I imagine they were concerned a later revision of the system would break them - this happened between the C64 and C128 because of the switch to CMOS 6502, after all)
User avatar
Myask
Posts: 965
Joined: Sat Jul 12, 2014 3:04 pm

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by Myask »

None of the games we have listed as using unofficial opcodes that are in Bootgod's database use NROM=mapper 0. (Not sure about Beauty and the Beast (E) 036.)
Of the homebrew games mentioned, Driar uses MMC1, STREEMERZ uses UxROM, Attribute Zone uses Color Dreams, and I expect zzo's Zork port is going to use a custom mapper therefor: so none of them use mapper 0 either.

Mind, implementing unofficial NOPs and the alternate SBC aren't going to cost you very much...
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by tepples »

Driar was ported to NROM for the multicart. That's the only NROM game I know of that uses unofficial opcodes. The rest are opcode tests.
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by zzo38 »

Nevertheless, for the implementation to be correct (even if you are only implementing mapper 0) you still have to implement the stable unofficial opcodes even if no mapper 0 games currently used them; however, you need not implement them now; you can implement other stuff first and then add it later on to make it complete.

What Myask (and tepples) said is probably correct though. So, unless you want it to run the NROM version of Driar even before you complete the implementation, you do not need to implement these opcodes right now.
(Free Hero Mesh - FOSS puzzle game engine)
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by thefox »

Sik wrote:I think Nintendo had imposed a ban on them, hadn't they?
It's possible, but as far as I know it's just speculation. We could find out by asking some of the programmers from back in the day whether such a restriction was in place.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by Dwedit »

Puzznic is CNROM, that's pretty close...
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by rainwarrior »

thefox wrote:It's possible, but as far as I know it's just speculation. We could find out by asking some of the programmers from back in the day whether such a restriction was in place.
1. I would highly suspect that they were forbidden in documentation given by Nintendo to licensed developers, and of course, also undocumented.

2. I sincerely doubt they had any practical test to verify whether illegal opcodes were being used, so whether or not they were "forbidden" is a moot issue.

3. Licensed games do end up executing illegal opcodes now and then due to programming bugs that end up running non-code data as code. It's rare, and usually leads to an unrecoverable crash anyway, but it happens.
Drag
Posts: 1615
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by Drag »

The reason Nintendo would've discouraged the use of undocumented opcodes is for situations where NES games might be running on a revision of the NES that didn't use the same 6502 core, and thus, had incompatible undocumented opcodes. The SNES would've been a great example of this, but Nintendo scrapped the NES backwards compatibility they originally wanted it to have.

Given this information, I would speculate that the NES library contains very little in the way of undocumented opcodes. It'll be mainly unlicensed games and homebrews that use them, very few licensed games.
User avatar
Petruza
Posts: 307
Joined: Mon Dec 22, 2008 10:45 pm
Location: Argentina

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by Petruza »

rainwarrior wrote:1. I would highly suspect that they were forbidden in documentation given by Nintendo to licensed developers, and of course, also undocumented.
Is such a documentation available somewhere? Is there any Nintendo official programming reference for the NES?
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by tepples »

I'm not privy to any official NES docs. But the fact that unofficial opcodes other than $89 mostly appeared in games released after the Super Famicom came out (fourth quarter 1990) might be part of it. Opcode $89 (BIT #ii) works identically on all 6502 versions except that it doesn't affect the Z flag on the original 6502.

The 1-byte NOPs in Dynowarz, on the other hand, pose a problem to this hypothesis.
Drag
Posts: 1615
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by Drag »

Yeah, that's what I was thinking, if any licensed games used unofficial opcodes (other than NOPs and stuff), it would've likely been after the SNES was released, which is when developers would've known Nintendo scrapped the NES backwards compatibility.
Sik
Posts: 1589
Joined: Thu Aug 12, 2010 3:43 am

Re: Do Mapper 0 games use illegal opcodes? (no, a bit, a lot

Post by Sik »

rainwarrior wrote:1. I would highly suspect that they were forbidden in documentation given by Nintendo to licensed developers, and of course, also undocumented.
When did undocumented opcodes become commonplace in the C64 demoscene? (as far as I know it's based off the same 6502 core, ergo the same undocumented opcodes)
Post Reply