Page 3 of 3

Re: Setting inesprg to 2 makes game stop running

Posted: Mon Mar 25, 2019 1:51 pm
by Jay John
lidnariq wrote:What are you trying to get the MMC1 to do? The behavior you're seeing is correct for the value you're writing...
Change the mirroring.

Re: Setting inesprg to 2 makes game stop running

Posted: Mon Mar 25, 2019 1:55 pm
by lidnariq
And what value do you want for the other bits that are set at the same time?

Re: Setting inesprg to 2 makes game stop running

Posted: Mon Mar 25, 2019 2:11 pm
by Jay John
lidnariq wrote:And what value do you want for the other bits that are set at the same time?
Fix bank at $8000 (for now) in prg and switch 4 kb at a time in chr

Re: Setting inesprg to 2 makes game stop running

Posted: Mon Mar 25, 2019 2:20 pm
by lidnariq
When you boot up, you write $80 to $8000, resetting the MMC1. That sets the bank at $C000 to bank 15, and leaves the bank at $8000 undefined.
Shortly afterwards, you write %110MM (M=mirroring) to the MMC1 at $8000, which sets the bank at $8000 to bank 0, and leaves the bank at $C000 undefined.
So you have to set things up to handle this.

One possibility would be to have multiple reset stages:
One in every 16K bank that writes $80 to $8000, resetting the MMC1's shift register and setting the bank at $C000 to be known
edit: now you have a temporary fixed bank 15, which contains code that writes %00000 or %10000 to $A000 so that the bank at $8000 is the same bank #0 that will happen when you switch layouts
jumps to the "real" code in your desired fixed bank
which then writes $110MM to $8000 so that the bank at $C000 is the one that can be changed.

After all this dance, both 16K banks will be at bank 0, and subsequent writes to $A000 will set the bank at $C000, as you apparently desire.

Re: Setting inesprg to 2 makes game stop running

Posted: Mon Mar 25, 2019 2:45 pm
by tokumaru
lidnariq wrote:When you boot up, you write $80 to $8000, resetting the MMC1. That sets the bank at $C000 to bank 15, and leaves the bank at $8000 undefined.
Shortly afterwards, you write %110MM (M=mirroring) to the MMC1 at $8000, which sets the bank at $8000 to bank 0, and leaves the bank at $C000 undefined.
At this point, I think you should reconsider your decision to make $8000-$BFFF fixed, since it's the switch from the more common setup (fixed bank at $C000-$FFFF) to the alternate one that might be causing you problems. The only real justification for making $C000-$FFFF switchable is if you need to bankswitch DPCM samples, which is not very common in actual games, considering you wouldn't be able to use bankswitching for other purposes.

Re: Setting inesprg to 2 makes game stop running

Posted: Mon Mar 25, 2019 7:14 pm
by Jay John
tokumaru wrote:
lidnariq wrote:When you boot up, you write $80 to $8000, resetting the MMC1. That sets the bank at $C000 to bank 15, and leaves the bank at $8000 undefined.
Shortly afterwards, you write %110MM (M=mirroring) to the MMC1 at $8000, which sets the bank at $8000 to bank 0, and leaves the bank at $C000 undefined.
At this point, I think you should reconsider your decision to make $8000-$BFFF fixed, since it's the switch from the more common setup (fixed bank at $C000-$FFFF) to the alternate one that might be causing you problems. The only real justification for making $C000-$FFFF switchable is if you need to bankswitch DPCM samples, which is not very common in actual games, considering you wouldn't be able to use bankswitching for other purposes.
Done it, and it's finally working!
Thanks!!!