MMC2 question

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
Disch
Posts: 1849
Joined: Wed Nov 10, 2004 6:47 pm

Post by Disch » Fri Nov 18, 2011 11:51 am

Are you fetching the 34th tile? The game might rely on it, even if it is never rendered.

User avatar
Zepper
Formerly Fx3
Posts: 3192
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Fri Nov 18, 2011 4:40 pm

That's probably the golden point for bankswitching, somewhere between cycles 256~323. AFAIK, it never access $2007, as mentioned "there and there". :)

Update: the game does NOT glitch if a tile fetch occurs on dot 256 (257th pixel). Works fine. The game fetches tiles $FD->$FE->$FD->$FE->... and if the fetch at 256 isn't allowed, it glitches.

User avatar
Disch
Posts: 1849
Joined: Wed Nov 10, 2004 6:47 pm

Post by Disch » Fri Nov 18, 2011 7:39 pm

Every fetch is allowed. It doesn't matter when it is. Any fetch from anywhere (rendering or $2007) at any time will cause the swap.

Although I don't know why there would be a fetch at 256. Isn't that a NT fetch?

User avatar
Zepper
Formerly Fx3
Posts: 3192
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Fri Nov 18, 2011 7:49 pm

Someone else must try out. Perhaps it's a problem with my gfx engine.

User avatar
MottZilla
Posts: 2832
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla » Fri Nov 18, 2011 8:45 pm

The fetch should occur after the 8th and final pixel of the FD/FE tile is drawn. It's pretty straight forward in that respect. But I am not sure how you render graphics. Someway you need to implement so that after the tile pattern fetch for the 8 pixels of tile FD/FE for it to trigger the bankswitching. Switching apon reads through $2007 is not important to get PunchOut working properly as I remember.

User avatar
Zepper
Formerly Fx3
Posts: 3192
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Sat Nov 19, 2011 6:54 am

My sprite code matches the hardware procedure perfectly; the BG render no. I just take the current ppu address and fetch the data for that pixel. I know that a rewrite should be required for fixing a few other issues, but I couldn't yet.

User avatar
Disch
Posts: 1849
Joined: Wed Nov 10, 2004 6:47 pm

Post by Disch » Sat Nov 19, 2011 6:17 pm

Well the boxers are rendered with sprites, so if they are messing up, then something is wrong with your MMC2 code or your sprite fetching.

User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

Post by miker00lz » Sun Dec 04, 2011 4:23 pm

i've got a problem with MMC2 in my emulator as well. it works absolutely perfectly and looks correct right up until it switches to the ring with the fight starting.

at that point, it looks like this:

Image



what is so different between before the fight and during the fight? the location of the tile that triggers the switching?

User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

Post by miker00lz » Sun Dec 04, 2011 4:31 pm

i partially fixed it myself, yeah i had to read the tile that was to the right of the screen. fetching that fixed the background, but i still have a problem with the sprites:

Image

User avatar
Zepper
Formerly Fx3
Posts: 3192
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Sun Dec 04, 2011 5:14 pm

I fixed the sprites by doing CHR bankswitches during cycles 256~320 of sprite fetches. Since the game uses 8x8 sprites, you should check the secondary OAM, the tile number stored there.

User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

Post by miker00lz » Tue Dec 06, 2011 12:11 am

that helped, thanks! it works correctly now.

User avatar
Zepper
Formerly Fx3
Posts: 3192
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Tue Dec 06, 2011 2:46 am

How exactly did you fix the ring?

User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

Post by miker00lz » Tue Dec 06, 2011 2:43 pm

i wasn't fetching the pattern data for the invisible tile just off the right side of the display, which the real NES accesses even if it isn't shown. that's the one that triggers the CHR swap.

User avatar
Zepper
Formerly Fx3
Posts: 3192
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Tue Mar 13, 2012 8:51 pm

miker00lz wrote:i wasn't fetching the pattern data for the invisible tile just off the right side of the display, which the real NES accesses even if it isn't shown. that's the one that triggers the CHR swap.
I was kinda harsh with you guys, my apologies. Anyway, for my gfx engine, I had to render (but not displaying it) the 257th pixel, in order to fetch the 34th tile. Punch Out seems to be working ok.

User avatar
MottZilla
Posts: 2832
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla » Wed Mar 14, 2012 9:42 pm

That is one way to fix it and it doesn't really effect anything for the user, atleast not negatively.

Post Reply