A question about CPU address exposed to the cartridge

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

stan423321
Posts: 53
Joined: Wed Sep 09, 2020 3:08 am

Re: A question about CPU address exposed to the cartridge

Post by stan423321 »

Apologies for necrobumping, but I'm haunted by one of the most stupid questions that also happens to be related to the answer(s) to OP.

Is it known which of 2A03 register accesses can be observed from outside the chip?

In particular, could a cartridge directly snoop on $4016 and $4017 reads, including ones doubled by the DPCM glitch?

For standard controller reading, baking that into a cart would be an absolute overkill, but, one, I'm just curious, two, it could be worth it for programs using those ports a lot, e.g. for floppies or something.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: A question about CPU address exposed to the cartridge

Post by lidnariq »

Yes. External hardware can snoop on everything except reads from $4015.
stan423321
Posts: 53
Joined: Wed Sep 09, 2020 3:08 am

Re: A question about CPU address exposed to the cartridge

Post by stan423321 »

Thank you, that was quick. I didn't expect one to be different from the others. Now that I've read your reply, I guess this property of $4015 is mentioned on the wiki, but in a way that doesn't make it obvious it doesn't apply to other ones, especially in context of this thread ("internal to the CPU").

Now, how to rephrase it...
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: A question about CPU address exposed to the cartridge

Post by lidnariq »

Mind mentioning what page on the wiki so that I could try to figure out how to rephrase it to make that clear?
Fiskbit
Posts: 891
Joined: Sat Nov 18, 2017 9:15 pm

Re: A question about CPU address exposed to the cartridge

Post by Fiskbit »

He's likely referring to this bullet point here: "This register is internal to the CPU and so the external CPU data bus is disconnected when reading it. Therefore the returned value cannot be seen by external devices and the value does not affect open bus."

While there's probably no harm in calling out here that this is the only such place on the system where this happens, I'm not sure it's the right place. I think my best suggestion for that right now is CPU memory map. I think the default assumption should be that everything is visible on the bus. Since joypad reads are coming from the joypads, I also think it's reasonable to assume those might be using the bus as normal, meaning $4015 is the only readable CPU address that is coming from a place internal to the CPU.
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: A question about CPU address exposed to the cartridge

Post by creaothceann »

Fiskbit wrote: Wed Apr 05, 2023 12:36 pm Since joypad reads are coming from the joypads, I also think it's reasonable to assume those might be using the bus as normal, meaning $4015 is the only readable CPU address that is coming from a place internal to the CPU.
Coming from the SNES, I'd assume the NES joypads have dedicated lines going to/from the CPU...
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
Fiskbit
Posts: 891
Joined: Sat Nov 18, 2017 9:15 pm

Re: A question about CPU address exposed to the cartridge

Post by Fiskbit »

On the NES, the output-to-joypad path uses special pins (OUT0, OUT1, OUT2, joypad 1 /OE, joypad 2 /OE), while the input-from-joypad path just uses the bus as normal.

(Speaking of which, on SNES, we currently say on the wiki that the upper bits for joypad reads are open bus, but I'm wondering if that's external open bus or internal open bus. And more generally, does reading from a 5A22 register have the same behavior as reading from $4015 where it isolates the CPU's internal bus from the external bus? If anyone knows, please message me the answer so I can update the wiki.)
User avatar
aquasnake
Posts: 515
Joined: Fri Sep 13, 2019 11:22 pm

Re: A question about CPU address exposed to the cartridge

Post by aquasnake »

lidnariq wrote: Tue Apr 04, 2023 4:29 pm Yes. External hardware can snoop on everything except reads from $4015.
Isn't that a function of save state?

Almost all registers, internal workram, ciram, external workram, pattern table, palette, and so on...

However, the PC cannot be restored, that's not important. After entering the interrupt through nmi, it will be resynchronized
Post Reply