MMC3 scanline counter

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
lemmurg
Posts: 25
Joined: Fri May 07, 2021 3:22 pm

MMC3 scanline counter

Post by lemmurg »

Trying to implement the MMC3 scanline counter by deciphering information from the Wiki. I'm generating either way too many IRQs, or too few, so I guess some of my assumptions must be wrong.

What I have gathered so far:
  • A12 is high when PPU reads/writes from/to addresses that have bit #12 set (0x1000-0x1fff, 0x3000-0x3fff), and low for all other addresses
  • A12 must remain low for a while for rising edges to have an effect on the counter.
  • Writing to $2006 is reflected on the address lines, even though no memory access happens.
Does that last point mean that every change to v affects the address lines? For example, v is incremented every 8 cycles, can it affect A12?
The MMC3 scanline counter is based entirely on PPU A12, triggered on rising edges (after the line remains low for two falling edges of M2).
What does the part between the parentheses mean? What is M2?
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: MMC3 scanline counter

Post by Ben Boldt »

2 falling edges of M2 means 2 CPU cycles.
lemmurg
Posts: 25
Joined: Fri May 07, 2021 3:22 pm

Re: MMC3 scanline counter

Post by lemmurg »

Ah, thanks.

I got it mostly figured out now through trial and error. If someone could confirm this is correct, that would be great:

Potential triggers for change in A12:

- Second write to $2006
- Write $2007
- Read $2007
- Read/Write PPU addresses $1000-$1fff (or $3000-$3fff)
- Read/Write VRAM (A12 always low)

This is all I have implemented for mapper 4 and it seems to work. Games are working, tests pass, except for that one "thing occurs too soon" problem which plagues me in all IRQ/NMI tests. There must be a bug in my general interrupt handling somewhere.
lemmurg
Posts: 25
Joined: Fri May 07, 2021 3:22 pm

Re: MMC3 scanline counter

Post by lemmurg »

...and there's this one question that's really bugging me: What the fuck is a "NES"`?

I guess I have to figure this shit out on my own.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: MMC3 scanline counter

Post by Pokun »

I heard it's some silly video game system from the early '80s.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: MMC3 scanline counter

Post by calima »

Now I'm really curious what the OP is doing implementing MMC3 counters when it's not for a NES emulator.
lemmurg
Posts: 25
Joined: Fri May 07, 2021 3:22 pm

Re: MMC3 scanline counter

Post by lemmurg »

I work at a scanline factory and I'm tired of counting all those scanlines by hand. This MMC3 thing was the first thing that came up in my Google search, but I can't find any tutorials that explain how to do it in Excel.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: MMC3 scanline counter

Post by Pokun »

I kind of thought it was a joke and played along. You have been a member here for some time developing an NES emulator, and you still have no idea what a NES is?

The NES (Nintendo Entertainment System) is the international version of Nintendo's Famicom (Family Computer), an 8-bit video game system. It is one of the most influential video game systems in history.
Some info here.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: MMC3 scanline counter

Post by lidnariq »

Ooh, do you know where I can bulk-order scanlines? I've always wanted a bunch.
lemmurg
Posts: 25
Joined: Fri May 07, 2021 3:22 pm

Re: MMC3 scanline counter

Post by lemmurg »

Pokun wrote: Wed Jun 02, 2021 3:38 pm I kind of thought it was a joke and played along. You have been a member here for some time developing an NES emulator, and you still have no idea what a NES is?
It was just a self-depreciating joke, because several of the questions I was asking so far were apparently too stupid to deserve answers. Asking what the hell an "NES" even is in my own thread about a highly specific emulation detail seemed ironic and funny to me, and it was the stupidest question I could think of. "Worker at a scanline factory" should've tipped you off tbh.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: MMC3 scanline counter

Post by calima »

They're not too stupid, rather they're too specific and the handful of people able to answer don't have the will to do so. That has something to do with there already being 15,824 NES emulators.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: MMC3 scanline counter

Post by Pokun »

Oh I won't be fooled that easily what do you take me for? I worked part-time on a scanline factory in 8th grade. Never dropped a single one either.
Post Reply