You can make this a bit shorter though:3gengames wrote:Something like:
Code: Select all
NMI: PHA LDA $2002 INC Frame PLA RTI
Code: Select all
NMI:
BIT $2002
INC Frame
RTIModerator: Moderators
You can make this a bit shorter though:3gengames wrote:Something like:
Code: Select all
NMI: PHA LDA $2002 INC Frame PLA RTI
Code: Select all
NMI:
BIT $2002
INC Frame
RTIOK I just took some throught about this, and I ended up with the conclusion that it's the exact same as MMC3. Look at the following piece of ultra-optimized code that bankswitch a 16k prg bank, the first part is MMC1, and the second does the exact same with the MMC3 :I also hate how long it takes to complete one single lousy mapper write, because the overhead of bankswitching several times in the same frame becomes too significant.
Code: Select all
lda #$01
ldx #$00
stx Reg3
sta Reg3
sta Reg3
stx Reg3
stx Reg3
ldx #$06
ldy #$18
stx $8000
sty $8001
inx
iny
stx $8000
sty $8001Unless there is other rogue code that is writing to the MMC1 registers, or if the hypotheses is false and the rogue bank switch is coming from some other source than an inconvenient NMI / IRQ.Bregalad wrote:This will work with no bugs and solve all your problems, with the inconvenient of potentially stealing a dozen of NMI cycles because of the non-interruptible work.
On the MMC3, unless you're mapper-hacking, you probably want the two 8 KiB banks pointed at different places, switched separately instead of as a unit.Bregalad wrote:OK I just took some throught about this, and I ended up with the conclusion that it's the exact same as MMC3. Look at the following piece of ultra-optimized code that bankswitch a 16k prg bank, the first part is MMC1, and the second does the exact same with the MMC3 :Both are exactly 24 cycles long.Code: Select all
lda #$01 ldx #$00 stx Reg3 sta Reg3 sta Reg3 stx Reg3 stx Reg3 ldx #$06 ldy #$18 stx $8000 sty $8001 inx iny stx $8000 sty $8001
I don't see many reasons why anyone would want to use CHR-ROM that's swapable in 4KB chunks over CHR-RAM though. It's not like you'll be doing CHR animations, because that would require a lot of tiles (the non-animated ones) to be repeated.MottZilla wrote:Or if you are wanting to use CHR-ROM, the other benefit to MMC1 over UxROM.
My problem in bug-checking was that I was ONLY checking for this sound engine backup-bank/switch-bank routine I described in the first post. However, as I explained, many different sections of code utilize the simple PRG bank switching subroutine. The PRG bank always gets backed up before jumping to it and then restored later when the engine is ready to return to the other swappable banks. When I did a check for the actual bank-switch sub, on the immediate previous occurance this sub was called it was indeed cut up by my NMI. It only got through four writes to $E000 and then NMI happened.clueless wrote: Part way through changing the MMC1 bank via the 'lsr, sta' unrolled loop, your code gets interrupted, and the interrupt handler resets the latch, changes banks, does its work, then resets the bank back to what it found on entry. Your "main" thread then resumes banging out the final bits tot he MMC1 bank register, which is no longer properly latched, so the MMC1 sees an incomplete switch request.
See? I've been told that I overcomplicate things when I suggest newbies use more robust NMI handlers, but it's almost a certainty that one day they will reach the CPU's limit, and then they'll be dealing with a very hard to track bug. One could argue that dealing with this problem is a part of the learning process, and I kinda agree, but there are cases when fixing this is very frustrating because it requires great changes in the game's architecture.bigjt_2 wrote:Like I said, I thought I had everything safely working within the frame with twenty-odd scanlines to spare, but I may be getting to the point on my project where it's too hard to gae-ron-tee that everything will fit within the frame 100% of the time.
tepples wrote:And then end up in an endless loop because you keep writing five times in a row, but you keep writing bits 3, 4, 0, 1, 2 instead of 0, 1, 2, 3, 4. Unlike with $2002 reads resetting the $2005/$2006 latch, there isn't anything on the MMC1 that only resets the 5-write state without also resetting the PRG banking mode to fixed-$C000.