The PowerPak has pull-up resistors on the data bus for its FPGA (which is 5V tolerant but can't drive pins above 2.5V).
Which means that devices that care about open bus not being $FF (such as Paperboy's joypad-reading code) require intervention.
PowerPak MMC3 fixes: accurate IRQ, MC-ACC submapper, iNES 2 CHR-RAM
Moderator: Moderators
- rainwarrior
- Posts: 8734
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: PowerPak MMC3 jitter fix for loopy's mapper
Ohhh so it's simulating one specific case of the open bus high bits of $4016/$4017. I suppose this wouldn't stand up to scrutiny of adversarial tests involving indirection/page-crossing, but good enough for the normal approach.
So I suppose this should be safe to just enable. Maybe loopy had it off by default because it adds complexity that's unnecessary for the majority of games? (Looks like there's 4 known MMC3 games, and 2 known CNROM games that need this fix.)
Though, I'm curious about why the WRAM disable seems to work perfectly for Low G Man. The change was just adding "cfg_wramnoten" here:
Code: Select all
assign wram_oe= m2_n & ~nesprg_we & prgain[15:13]==3'b011 & ~cfg_wramnoten
Re: PowerPak MMC3 jitter fix for loopy's mapper
As far as I know, no, they all behave the same. In the linked thread, you said
which seems like it explains why the PowerPak's pull-up resistors are safe.rainwarrior wrote: ↑Fri Aug 07, 2015 6:37 pm Anyhow, the patch is pretty simple. Treat it as regular MMC3 with WRAM and no expectation that the WRAM disable will work. Initialize the entire WRAM to $FF and never disable it. Seems to take care of all the problems, and it appears to play just fine on both my PowerPak and Everdrive N8.
- rainwarrior
- Posts: 8734
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: PowerPak MMC3 jitter fix for loopy's mapper
Oh! Right, my patch just used $FF as a blanket value. I guess I had analyzed the nature of the bug and found that $FF was suitable and simpler. I thought I had filled everything with the high byte of it's address (i.e. the most likely open bus value, barring a page cross?), but I guess not:
Thanks for pointing that out. I had forgotten.
Hrm, well this makes me think I should instead simulate it by initializing 8k of WRAM to high-byte and then write protecting it, rather than using wram_oe.
Code: Select all
FFC0 [1F] A9 00 LDA #$00
FFC2 [1F] 85 00 STA $00
FFC4 [1F] A8 TAY
FFC5 [1F] AA TAX
FFC6 [1F] A9 60 LDA #$60
FFC8 [1F] 85 01 STA $01
FFCA [1F] A9 80 LDA #$80
FFCC [1F] 8D 01 A0 STA $A001
FFCF [1F] A9 FF LDA #$FF
FFD1 [1F] 91 00 STA ($00),Y
FFD3 [1F] C8 INY
FFD4 [1F] D0 FB BNE $FFD1
FFD6 [1F] E6 01 INC $01
FFD8 [1F] E8 INX
FFD9 [1F] E0 20 CPX #$20
FFDB [1F] 90 F4 BCC $FFD1
FFDD [1F] A9 00 LDA #$00
FFDF [1F] 8D 00 80 STA $8000
FFE2 [1F] 60 RTS
Hrm, well this makes me think I should instead simulate it by initializing 8k of WRAM to high-byte and then write protecting it, rather than using wram_oe.
- rainwarrior
- Posts: 8734
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: PowerPak MMC3 jitter fix for loopy's mapper
Alright! MC-ACC seems to be working? If I put submapper 3 on Incredible Crash Dummies or Mickey's Safari in Letterland they both look very solid!
Otherwise I switched the WRAM disable flag to actually disable writes, and instead the WRAM will be pre-filled with high-byte-of-address values to simulate open bus. I moved the pre-fill step to the PowerPak menu code (which will be part of a PowerPak OS update release I've been working on), which ends up solving the problem for other games as well (e.g. Battletoads & Double Dragon).
This was the relevant code for MC-ACC. Keeping the rest of the logic the same but replacing the 3xM2 delay line of regular MMC3 with the Fall/8 style of the ACC. Turned on by a config input from the loader that looks for iNES 2 submapper 3:
Otherwise this new code should only activate for submapper 3, and doesn't seem to have broken anything else. Blargg's tests are the same. A summary of what's changed since Loopy's version:
Otherwise I switched the WRAM disable flag to actually disable writes, and instead the WRAM will be pre-filled with high-byte-of-address values to simulate open bus. I moved the pre-fill step to the PowerPak menu code (which will be part of a PowerPak OS update release I've been working on), which ends up solving the problem for other games as well (e.g. Battletoads & Double Dragon).
This was the relevant code for MC-ACC. Keeping the rest of the logic the same but replacing the 3xM2 delay line of regular MMC3 with the Fall/8 style of the ACC. Turned on by a config input from the loader that looks for iNES 2 submapper 3:
Code: Select all
// MC-ACC
// clocks on falling edge of a12, then ignores the next 7 edges
// resets ignore on writes to $C001
// (a12 pre-filter was needed for this implementation)
reg [3:0] acc_counter;
reg acc_reload;
reg acc_clear_reload;
reg acc_clear_reload_delay; // signals reload has been serviced, delayed until negedge-a12
always @(negedge a12_pre_filtered) begin
if (acc_reload) begin
acc_counter <= 0;
acc_clear_reload_delay <= 1;
end else begin
acc_counter <= acc_counter + 1;
acc_clear_reload_delay <= 0;
end
end
always @(posedge a12_pre_filtered) acc_clear_reload <= acc_clear_reload_delay;
always @(posedge write_c001, posedge acc_clear_reload) begin
if (acc_clear_reload) acc_reload <= 0;
else acc_reload <= 1;
end
wire a12_acc = (acc_counter == 0) & (~acc_reload | acc_clear_reload_delay);
// a12 selects regular MMC3 or MC-ACC a12 behaviour
wire cfg_acc = cfg_mapaux[6]; // loader can select submapper 3: MC-ACC
wire a12 = (~cfg_acc & !a12_delay_line[2]) | (cfg_acc & a12_acc);
wire a12_n = ~a12;
- IRQ timing is fixed, no longer jittery, timing seems to be accurate and passes Blargg's tests as much as I think is possible.
- Submapper 3 (MC-ACC) support for Incredible Crash Dummies, Mickey in Letterland, etc.
- Large CHR-RAM iNES 2 support.
- No PRG-RAM iNES 2 support (approximate, and requires a pending OS update).
- New loader with simple progress bar.
Re: PowerPak MMC3 jitter fix for loopy's mapper
I'm glad someone picked up the torch. It's been on my "fix this someday" list for years now
- rainwarrior
- Posts: 8734
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: PowerPak MMC3 jitter fix for loopy's mapper
Thanks for providing the source to continue from!
While you're here, there were a few mappers in your mapper pack that weren't present in your source pack. Do you still have any of these sources, and if so are you willing to share them?
- MAP05 - iNES 005 MMC5
- MAP5A - iNES 090 JY Company
- MAP22 - iNES 034 BNROM / NINA-001
- MAP47 - iNES 071 Camerica / Codemasters
- N.MAP - NSF