My code won't run on PlayChoice10

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

My code won't run on PlayChoice10

Post by oRBIT2002 »

I'm working with a small project that are going to run on some sort of PlayChoice10-setup. Problem is, my code won't work. The cart is using MMC1 (uncertain of which model) but I can't get it running. I don't have access to the hardware itself so I'm e-mailing a guy my progress.
I'm not very familiar with the cart that my stuff is running on (besides it seems to run a majority of other MMC1-based stuff out there).
I've tested my stuff on Everdrive (not really the same thing but still..) and Mesen on my Windows PC. Works fantastic..
My only theory is that it's somehow bankswapping related, that the initialization is bad. Wrong bank at the wrong place perhaps even caused by some sort of bad initial state of the MMC1 itself (wild wild guesses...)
My MMC1-initcode looks like this (borrowed from LoZ), but I don't think that's the issue..? I've tried a few others aswell, same result..

Code: Select all

			ldx #$ff
			stx $8000
			stx $a000
			stx $c000
			stx $e000
Anyone got any good ideas?
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: My code won't run on PlayChoice10

Post by Dwedit »

MMC1 is supposed to start in an undefined initial state, so every 16K bank should end with initializtion code. Just a single write with bit 0x80 set is enough to reset the MMC1 back to Fixed Bank at C000-FFFF mode. From there, you can proceed to jump to the main entry point.

Have every 16K bank end with this code: (placed 12 bytes from the end of the bank)

FFF4:
INC $FFFC
jmp EntryPoint
FFFA: .dw xxxx (NMI vector)
FFFC: .dw $FFF4 (Reset vector)
FFFE: .dw xxxx (IRQ vector)

(Post was edited several times, thank you Quietust for corrections)
Last edited by Dwedit on Thu Jan 20, 2022 10:52 am, edited 4 times in total.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Quietust
Posts: 1920
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: My code won't run on PlayChoice10

Post by Quietust »

Dwedit wrote: Tue Dec 07, 2021 1:57 pm Usually, it's a 16 byte 'footer' for every bank to include this code at FFF0:

FFF0:
lda #$80
sta $FFFF
jmp EntryPoint
FFFA: NMI vector
FFFC: Reset vector
FFFE: IRQ vector

If you feel like saving 2 bytes, you can replace the 'LDA # / STA xxxx' with 'INC FFFC', and that might work too. Then the 'footer' starts at FFF2 instead of FFF0
Unless my math is wrong, the original code is only 14 bytes (starting at $FFF2), so the "smaller" one would just be 12 bytes (and start at $FFF4).
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: My code won't run on PlayChoice10

Post by Memblers »

There is some kind of watchdog reset, though I'm not 100% clear on its operation. It's in the schematic, but it's a chain of stuff spanning multiple pages (and into the Z80 code), I don't want to suss it out. I've seen it happen with Pung by jero32. You'd finish a match in Pung, then it jumps back to the Playchoice menu, but with the game de-listed. My assumption was the game disables NMI, stops reading the controller, or something like that. If you do that too long, it triggers the reset. Just a guess.

I'd also second what Dwedit said too, the MMC1 cart I modded years ago always has a random bank at startup.
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: My code won't run on PlayChoice10

Post by oRBIT2002 »

I've noticed my code actually runs (a soundeffect is heard) but the PC10-menu never disappears.. Seems some code is actually executed but by some reason the ROM exists (obviously very fast). Very odd. Any conditions I should be aware of? My MMC1 init code is obviously ok since it seems to run but something else triggers this behaviour...
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: My code won't run on PlayChoice10

Post by Memblers »

It's identical to the NES, except for the palette, and having the Z80 supervisor thing. The games are identical to the NES versions and don't do anything special to avoid the watchdog reset, indeed people run normal NES games using cart adapters without any problems (that I've heard of, anyways).

So, one guess is your program is doing something differently than a normal NES game, like leaving NMI disabled or not reading the controllers.

Other factors would be like:
1: What is on the cart's Z80 EPROM?
2: Is the EPROM used the same as your ROM size?
3: Which Playchoice cart or game, and is it definitely wired for EPROM? They may be wired for maskROM also, seems to be done by setting jumpers.

I have a Playchoice and at least one MMC1 EPROM cart, which is Rad Racer (but it has WRAM installed, must have been factory converted from another game). Maybe I could test your program, but the turn-around time will be slow.
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: My code won't run on PlayChoice10

Post by oRBIT2002 »

I actually wasn't using NMI (until recently, awaiting testresults).. Why does the system bothers about these kind of things?
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: My code won't run on PlayChoice10

Post by lidnariq »

There's no other way for the Z80 to know if the 2A03 has crashed, so you (mostly) have to leave NMI on
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: My code won't run on PlayChoice10

Post by oRBIT2002 »

Using the NMI solved the problem obviously! But my ROM seems to disappear from the menu once reset.. Strange..

There seems to be limitations on what you can/cannot do, is this behaviour documented somewhere?
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: My code won't run on PlayChoice10

Post by oRBIT2002 »

I has disassembled a few other PC10 specific ROMS and try to follow their pattern:
* Use NMI
* Write to $2000 at frequent intervals

The NMI stuff got my ROM running obviously, $2000 writes doesn't seem to matter.. The ROM still disappears from the menu on reset and I can't figure out why. Annoying. :/
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: My code won't run on PlayChoice10

Post by Memblers »

I seem to remember having to fiddle with it to get it stay on the list after the PC10 called it bad.. I had to change cart slots, maybe. The Playchoice Z80 has some bookkeeping RAM that's backed-up by a "supercapacitor" (instead of a battery), which will maintain it for a short time (like, overnight is probably what they were going for). This is mostly speculation, but it's possible that the slot/game combination could be marked as bad in that RAM. Visibly, the "bookkeeping" consists of only tracking the number of times a game was selected, so it may as well also track the number of times it failed. Swapping slots would give it a clean slate.
brizzo
Site Admin
Posts: 34
Joined: Mon Feb 03, 2014 1:08 am

Re: My code won't run on PlayChoice10

Post by brizzo »

https://problemkaputt.de/everynes.htm#n ... aychoice10
Watchdog
The watchdog is disabled (and its frame counter is reset to zero) when Port 08h and/or Port 09h are set to nonzero values; ie. the watchdog is active ONLY during periods when NMIs are off (Port 08h=0) and only when the Watchdog is on (Port 09h=0). When active, the watchdog resets the Z80 CPU after 8 frames.
Only reasons a game is removed from the PC10 menu is if the watch dog was triggered or if there is a problem with the INSTROM (eprom read by Z80 containing cartridge title and on screen instructions). Power cycling will restore it to the menu (book keeping does not retain there was a watchdog triggered).

Is the cartridge that is being tested with using an original INSTROM + RP5H01 security chip from another game?
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: My code won't run on PlayChoice10

Post by oRBIT2002 »

I'm 100% sure I've got an NMI running. But the game disappears after it has been run once from the menu. If the INSTROM(?) was bad, should the ROM appear in the first place, or?
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: My code won't run on PlayChoice10

Post by oRBIT2002 »

Problem finally detected and solved.
Doing multiple inits of MMC1 caused this behaviour. Don't do that. :)
I did a
lda #$80
sta $8000
and a bit later did the same thing again and stuff went crazy..
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: My code won't run on PlayChoice10

Post by Ben Boldt »

I don't see how that should matter. Do you know why, or did you just remove the 2nd one and then it started working?
Post Reply