Page 1 of 1

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

Posted: Sat May 02, 2015 11:57 pm
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.

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

Posted: Sun May 03, 2015 1:16 am
by thefox
Practically no games use them. So yes, you can skip them when you're just getting started.

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

Posted: Sun May 03, 2015 11:52 am
by Petruza
Yay! thanks.

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

Posted: Sun May 03, 2015 12:53 pm
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)

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

Posted: Sun May 03, 2015 2:09 pm
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...

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

Posted: Sun May 03, 2015 2:47 pm
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.

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

Posted: Sun May 03, 2015 6:25 pm
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.

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

Posted: Sun May 03, 2015 7:41 pm
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.

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

Posted: Sun May 03, 2015 7:51 pm
by Dwedit
Puzznic is CNROM, that's pretty close...

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

Posted: Sun May 03, 2015 9:09 pm
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.

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

Posted: Mon May 04, 2015 12:22 am
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.

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

Posted: Mon May 04, 2015 8:12 am
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?

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

Posted: Mon May 04, 2015 8:34 am
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.

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

Posted: Mon May 04, 2015 9:27 am
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.

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

Posted: Tue May 05, 2015 1:59 pm
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)