News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: SMB1 MMC3 Conversion - Scanline IRQ problem  (Read 1702 times)

Nalwonk

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
SMB1 MMC3 Conversion - Scanline IRQ problem
« on: January 01, 2021, 08:03:42 am »
I'm in the process of converting SMB1 to MMC3 as a base for hacking it, and I'm having a bit of trouble converting the status bar from a sprite 0 hit to an MMC3 IRQ.

It seems like it's having trouble actually stopping at the scanline I've indicated, and I'm getting scrolling errors, sometimes to about halfway down the screen.  I couldn't really find any good instructions on how to set this up though, so I'm sure I'm missing a step.

I've set up the MMC3 like this:

Code: [Select]
lda #30
sta $c000
sta $c001
sta $e001
inc IRQAckFlag

My IRQ code is as follows:
Code: [Select]
sei
php
pha
txa
pha
tya
pha



sta $e000

lda HorizontalScroll
sta PPU_SCROLL_REG
lda VerticalScroll
sta PPU_SCROLL_REG
lda #$00
sta IRQAckFlag


pla
tay
pla
tax
pla
plp

cli

rti


Nalwonk

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: SMB1 MMC3 Conversion - Scanline IRQ problem
« Reply #2 on: January 02, 2021, 12:39:38 am »
I can't really find anything in there that would cause this to be happening.

https://youtu.be/WAgvhdk9oLg

never-obsolete

  • Jr. Member
  • **
  • Posts: 32
    • View Profile
Re: SMB1 MMC3 Conversion - Scanline IRQ problem
« Reply #3 on: January 02, 2021, 08:38:16 pm »
Couple of things:

1. Is there more than one irq firing per frame?

2. At approximately what dots are the writes to $2005 landing?

3. You might need to write to $2000 in your irq handler.

This section of the nesdev wiki on scrolling might help: https://wiki.nesdev.com/w/index.php/PPU_scrolling#Split_X_scroll

Nalwonk

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: SMB1 MMC3 Conversion - Scanline IRQ problem
« Reply #4 on: January 07, 2021, 03:26:35 am »
Turns out the problem was I wasn't accounting for which page of the name table I was on and that was causing it to bug out.  Mario 2/Lost Levels adjusts the code for scrolling to account for that, but I wasn't understanding what the extra code in its IRQ routine was or how to implement it properly.

The disassembly of 2 is based on the FDS version so it was based on the FDS's IRQ routine and the numbers I needed to set for things were different.

I tried looking at the edited disassembly for the MMC3 conversion of 2/LL, but the code isn't commented and I'm a bit too inexperienced to know what's going on.

I'm having a new problem now where the whole screen shakes up and down when I load the game in some emulators, hopefully the link you've provided will give me enough to go on to figure that out.  It hadn't occurred to me to look on documentation for scrolling in general since the game already has a scrolling system built.

It seems like whenever I ask for help here, the problem isn't what I think it is so I don't give people enough information to actually help me.  Ooops!

January 07, 2021, 06:59:24 am - (Auto Merged - Double Posts are not allowed before 7 days.)
Seems to have been a timing issue, changing the amount of delay around has removed the earthquakes.

Hopefully, last problem I'm having in relation to this:

When Mario passes through the boundary between the scroll areas, there seems to be a dead scanline on certain emulators, but not others.  Lost Levels MMC3 doesn't have the same problem, so presumably it's something that can be dealt with.



EDIT: Turns out I'd disabled rendering at the beginning of the IRQ because I'd been testing something else, oops
« Last Edit: January 07, 2021, 07:03:30 am by Nalwonk »

Nalwonk

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: SMB1 MMC3 Conversion - Scanline IRQ problem
« Reply #5 on: March 02, 2021, 06:58:11 am »
Having a new problem with it.

It seems to be mostly working now, but something in the castle victory code is causing it to break. Whenever I grab the axe, the screen mostly flips to the other nametable, with graphical errors making it look like the IRQ isn't firing on the correct frame, though it does appear to be.  I recorded a video of the issue:

https://youtu.be/JubusKJN3WE

Does anyone know what the problem might be?

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 625
  • I am the baldest romhacker
    • View Profile
Re: SMB1 MMC3 Conversion - Scanline IRQ problem
« Reply #6 on: March 08, 2021, 02:34:48 pm »
Check scrolling values written to 2005 register, and 2 highest bits (nametable) in 2000. Compare this to original rom.

IRQ must fire each frame, so I guess you're talking about scanlines instead. Check writes to C000 just in case.

If you have backup versions without this glitch, check your changelog.