NestopiaUE VRC2 H/V mirroring selection bug

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

NestopiaUE VRC2 H/V mirroring selection bug

Post by koitsu »

So it seems NestopiaUE doesn't do something relating to VRC2 (mapper 23) H/V mirroring selection ($9000-9003) correctly. This becomes readily apparent in Konami Wai Wai World during the vertically-scrolling part of the game. (Said part of game is also shown during one of the demo phases, so can be tested there too). I still haven't figured out what the root cause of the final ending screen + sound select being garbled is, but gut feeling is it's probably related.

I've tried digging through the source to see if the problem was easily fixable, but the amount of abstraction is making it difficult. Was hoping someone else (lidnariq?) might have insights or know what's busted:

* https://github.com/rdanbrook/nestopia/b ... miVrc2.cpp
* https://github.com/rdanbrook/nestopia/b ... miVrc2.hpp

References for the NmtSwap stuff:

* https://github.com/rdanbrook/nestopia/b ... tBoard.cpp
* https://github.com/rdanbrook/nestopia/b ... tBoard.hpp

I've looked through commits between October 2014 and present and don't see anything relevant to fixing this. On the other hand, I do see other issues with NestopiaUE and VRC2 discussed but that's CHR page swapping and not mirroring.

I'm happy to file a ticket/Issues request with rdanbrook for getting this fixed, but like I said, it's convoluted (for me anyway).

FCEUX 2.2.3 (devel/svn build, date 2015/10/13) gets this right (at least the vertically-scrolling gameplay portion, haven't tested the ending), so it's definitely specific to at least NestopiaUE.
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by lidnariq »

I can reproduce in Nintendulator.

All three emulators use the same mapping of 0,1,2,3 to "VH01".

The NMI handler of Wai Wai World always copies the byte at $07FF to $9000.
For the vertically scrolling portion in the demo there, the chunk of code at $8064 through $8068 writes $FF to $07FF, which is parsed as 1-screen mirroring by Nintedulator and Nestopia.

FCEUX, on the other hand, contains this gem:

Code: Select all

                case 0x9000:
                case 0x9001: if (V != 0xFF) mirr = V; Sync(); break;
Without someone to test on the original hardware, it's hard to say if that's a bug in the game that FCEUX is working around, or previously-undocumented behavior.


(P.S. to anyone else: if you have a Wai Wai World cartridge, would you mind testing?)
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by koitsu »

Sorry about the longevity of reply/delay. This subject came up today when talking to deadbody.

FYI, I do have a a Wai Wai World cartridge and original Famicom hardware, but I'm not exactly sure how to go about testing anything related to what's been posted. I can assure you the game visually looks like what FCEUX shows, but what's going on hardware-wise is a different question.

We do have VRC2 documentation now (all in Japanese), but I can get that translated by my neighbour. $9000/$9001 does have special handling according to the VRC2 docs (see file 0012.jpg, bottom) pertaining to H/V mirroring (docs seem to imply only bit 0 is honoured, and 0 = H, 1 = V). I don't know what V or mirr are in FCEUX code. There's no mention of a special $FF value in the docs, but maybe there's something in native Japanese I'm missing. The $07FF write may be what's most relevant though (same document), as there's some kind of correlation between those two things.

Really need to get that VRC2 document translated. I'll ask my neighbour.
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by lidnariq »

koitsu wrote:FYI, I do have a a Wai Wai World cartridge and original Famicom hardware, but I'm not exactly sure how to go about testing anything related to what's been posted. I can assure you the game visually looks like what FCEUX shows, but what's going on hardware-wise is a different question.
The trivial test is wait for the vertical-scrolling shmup section of the attract mode. If it looks correct, then writing $FF has to do something funny. If there's an obvious seam as in Nestopia, then it's a game bug.

... Oooh, or maybe the VRC2 only supports H/V, and the VRC4 is what supports H/V/0/1, and this entire bug is another instance of the conflation of the VRC2 and VRC4?Nope, the VRC2 definitely supports 1-screen layouts; the scientist-person talking at you in attract mode is missing his computer if you disable 0/1 as options. (edit: errāvī)
Last edited by lidnariq on Sat Sep 02, 2017 1:46 pm, edited 1 time in total.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by koitsu »

I'm having some of the VRC2 documentation (the bits relevant to this) translated to English, mainly the pages relating to CHR page mapping and H/V.

It's interesting that all the documentation available (Disch vs. Goroh vs. the Wiki vs. Firebug vs. emulator code) have somewhat conflicting information about how mapper 23 behaves in this regard. The wiki is, well... the way I'd describe it is "all fucked up" for the H/V bits (for both VRC2 and VRC4). You'll just have to look to see what I mean. It looks like someone half-assed something.

Possibly this confusion stems from multiple revisions (2a vs. 2b) and the fact that VRC2/VRC4 were considered in early days to be the exact same? Not really sure.

Spoke with deadbody some more and I mentioned that this may be a good opportunity to have someone like Tepples make a test/exploration ROM for these types of features. There is obviously behaviour of this chip which we either don't understand, aren't documented, or stem from different revision behaviours. Possibly the official documentation we have doesn't match the exact revision of chip used in the cart? If you look at Goroh's document, you'll see that he ended up testing the behaviour on a per-game basis and the behaviour changes.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by rainwarrior »

I wouldn't expect to find anything useful in that ancient documentation like Goroh's or the others you mentioned. They're always inadequate in cases like this. Disch's documents are just based on emulators available at the time of their writing, for example.

What's the documentation you're translating, though?

Just get somebody to do a hardware test. You can hotswap some test code in RAM, no need to do any hardware mods. All a tester needs is a famicom, a relevant cartridge, and something to run the test program from. (I don't have any VRC2/4 games, personally, so I can't help as a tester at the moment.)
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by koitsu »

VRC2 documentation being translated: viewtopic.php?f=2&t=10611
Black Zero
Posts: 41
Joined: Sat Jul 20, 2013 10:14 pm

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by Black Zero »

This is also present in puNES:

Image

and the issue have been reported on GitHub.

As for the ending + sound select in puNES I'm not sure about that but I can definitely say that this is not occurring on original hardware at all as I own both a Famicom and a copy of the game.
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by lidnariq »

Here is a simple hot-swappable test.

* It'll beep when it's ready to remove the original cartridge.

* Press A to start the test

* It'll play a 30-second long "song", corresponding to
- The 32 different values that can be written to the mirroring control register (the VRC2 isn't connected to CPU D5,6,7 so those cannot change things)
- Each of which consist of five notes, each 183ms long, which are Upper Left, Upper Right, Lower Left, Lower Right, Spacer.
+ 874 Hz = nametable A
+ 437 Hz = nametable B
+ 218 Hz = spacer
Attachments
vrc24mir_hotswap_test.zip
(2.87 KiB) Downloaded 666 times
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by koitsu »

How exactly would this hot-swap methodology work? Use a NES/Famicom cartridge adapter (so a Famicom cart can be used on a NES), load ROM via PowerPak, once loaded/running yank cart, insert VRC2 cart + adapter, press A? Sorry if this seems like a stupid question, but...
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by lidnariq »

On a front-loading NES you'll need to somehow bypass/disable the CIC. Otherwise, yes.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by rainwarrior »

Hotswaps often crash during the insertion/removal, so you might have to try 2 or 3 times before it works (try to pull out straight and swift).

Otherwise, yeah, you got it.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by tokumaru »

rainwarrior wrote:Hotswaps often crash during the insertion/removal
I remember someone saying that executing OAM DMAs repeatedly helps with preventing crashes, because that means the CPU spends most of the time doing something that doesn't involve reading opcodes from memory, I believe. Can anyone confirm this?
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by lidnariq »

Either way I forgot to add that <_<
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: NestopiaUE VRC2 H/V mirroring selection bug

Post by koitsu »

I've a front-loader, a top-loader, and a Famicom AV (but no NES cart->Famicom adapter, only Famicom cart->NES). Looks like the top-loader is the best choice for this given its lack of 10NES/CIC. And yeah, what rainwarrior said was another level of concern I had. I'll try to give it a try Tuesday or after, as I've too much stuff tonight and Monday to take care of first.

English translation of a couple pages from the VRC2 docs will be coming later tonight.
Post Reply