MMC3 Scanline Counter - Nestopia / Mesen / FCEUX

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
wonder
Posts: 46
Joined: Sat Aug 31, 2019 2:12 pm

MMC3 Scanline Counter - Nestopia / Mesen / FCEUX

Post by wonder » Sat Jan 11, 2020 2:49 am

Hi guys!

I need your help... :/

I wrote some code based on the 8bitworkshop MMC3 Scanline Counter example (https://8bitworkshop.com/v3.5.0/?file=i ... atform=nes) and once I downloaded the ROM, I noticed that the split/scrolling didn't work on Nestopia nor Mesen. It works only on FCEUX and 8bitworkshop itself (JNES).

Convinced the problem was in my code, I decided to download the example ROM (link above / see attached) and try it out. Similar behavior:
8bitworkshop (JNES): OK
FCEUX: OK
Mesen: Blank screen
Nestopia: Blank screen

Video: https://youtu.be/no_aSFzjQuM
EDIT: See this post for further clarification: http://forums.nesdev.com/viewtopic.php? ... 86#p246093

The neslib.s and crt0.s versions used to compile this rom can be found here: https://github.com/sehugg/neslib

I haven't had much time to test it, but it seems that the code in the function below is only executed by JNES and FCEUX.

Code: Select all

// From the MMC3 example
void __fastcall__ irq_nmi_callback(void) {
  // check high bit of A to see if this is an IRQ
  if (__A__ & 0x80) {
    // it's an IRQ from the MMC3 mapper
    // change PPU scroll registers
    PPU.scroll = counters[irqcount & 0x7f] >> 8;
    PPU.scroll = 0;
    // advance to next scroll value
    ++irqcount;
    // acknowledge interrupt
    MMC3_IRQ_DISABLE();
    MMC3_IRQ_ENABLE();
  } else {
    // this is a NMI
    // reload IRQ counter
    MMC3_IRQ_RELOAD();
    // reset scroll counter
    irqcount = 0;
  }
}
Can you guys help me out?
Attachments
irq.nes
(128.02 KiB) Downloaded 61 times
Last edited by wonder on Sun Jan 12, 2020 2:29 am, edited 2 times in total.
Image

User avatar
BluRaf
Posts: 1
Joined: Sat Jan 11, 2020 1:38 pm
Contact:

Re: MMC3 Scanline Counter - Nestopia / Mesen / FCEUX

Post by BluRaf » Sat Jan 11, 2020 1:46 pm

It looks like by default 8bitworkshop compiler puts startup code at $C000, which with MMC3 might be swapped with bank at $8000
http://wiki.nesdev.com/w/index.php/MMC3#PRG_Banks
viewtopic.php?p=121187#p121187

User avatar
Quietust
Posts: 1607
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: MMC3 Scanline Counter - Nestopia / Mesen / FCEUX

Post by Quietust » Sat Jan 11, 2020 9:32 pm

BluRaf wrote:
Sat Jan 11, 2020 1:46 pm
It looks like by default 8bitworkshop compiler puts startup code at $C000, which with MMC3 might be swapped with bank at $8000
http://wiki.nesdev.com/w/index.php/MMC3#PRG_Banks
viewtopic.php?p=121187#p121187
To clarify, the MMC3's only guaranteed "fixed bank" is at $E000-$FFFF, though $C000-$DFFF is usually safe.

For what it's worth, Nintendulator doesn't seem to like this ROM either, displaying nothing but a screen full of "B"s.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
wonder
Posts: 46
Joined: Sat Aug 31, 2019 2:12 pm

Re: MMC3 Scanline Counter - Nestopia / Mesen / FCEUX

Post by wonder » Sun Jan 12, 2020 2:15 am

For what it's worth, Nintendulator doesn't seem to like this ROM either, displaying nothing but a screen full of "B"s.
It seems that I might have created some confusion with the GIF (now replaced) I originally posted.

On 8bitworkshop this is the scanline counter MMC3 example: https://8bitworkshop.com/v3.5.0/?file=i ... atform=nes
The expected behavior is to have the screen filled with horizontally moving characters ("A"s, for some reason I changed it into "B"s):

Image
This is the expected behavior

To download the ROM, you go to drop-down menu on the top-left --> Download --> Download ROM Image

Once you have it (irq.c.rom) it only works in FCEUX. On both Mesen and Nestopia, the ROM loads, but we get nothing but a blank screen.
Image

User avatar
Quietust
Posts: 1607
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: MMC3 Scanline Counter - Nestopia / Mesen / FCEUX

Post by Quietust » Sun Jan 12, 2020 6:29 am

So, I just found another problem: when you turn on the PPU, it's configuring the Sprites and Background to load from the same pattern table (i.e. it's writing $80 to $2000), which means no IRQs get generated if the emulator is doing "accurate" MMC3 emulation (see wiki for more info).


Once I patched this (by changing the "LDA #$80; STA $12" at address $C0BB to instead use #$88), I started getting some animation in Nintendulator, though there are a few minor differences in how the rows move (i.e. some don't move at all).
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

Post Reply