How often does the CIC chip reset?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

How often does the CIC chip reset?

Post by orlaisadog » Thu Jul 12, 2018 11:18 am

The Wikipedia page on the chip (en.m.wikipedia.org/wiki/CIC_(Nintendo))
says that the chip resets every cycle, but the NesDev Wiki (http://wiki.nesdev.com/w/index.php/CIC_lockout_chip) implies it resets every second (1Hz square wave). Which is true? If it resets every second, could a game with no CIC be created by using RAM persistence over resets to hold state information?
By the way, this is my first post

lidnariq
Posts: 9021
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: How often does the CIC chip reset?

Post by lidnariq » Thu Jul 12, 2018 11:28 am

orlaisadog wrote:If it resets every second, could a game with no CIC be created by using RAM persistence over resets to hold state information?
Yes.

I made a trivial proof-of-concept of something like this that plays a simple song: https://forums.nesdev.com/viewtopic.php ... 47#p184247

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: How often does the CIC chip reset?

Post by orlaisadog » Thu Jul 12, 2018 11:29 am

So this could help make one of those 1 chip cartridges?

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: How often does the CIC chip reset?

Post by orlaisadog » Thu Jul 12, 2018 11:34 am

Also, would this cause a flashing screen because of PPU resets?

User avatar
rainwarrior
Posts: 7717
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: How often does the CIC chip reset?

Post by rainwarrior » Thu Jul 12, 2018 12:06 pm

Yes, a reset can cause a TV to lose signal. On a CRT they come back up really quick, but a lot of modern TVs take a few seconds, so the continual reset might make them unable to display any picture or sound at all. (Depends on the TV.)

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: How often does the CIC chip reset?

Post by orlaisadog » Thu Jul 12, 2018 12:28 pm

Which colour would the flashes be and how long? 2 frames for PPU initialization? On a CRT, could it be disguised as a lightning strike if the game has a rain effect or would that be too annoying? Anything else I'd need to know if I did this?

User avatar
koitsu
Posts: 4216
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: How often does the CIC chip reset?

Post by koitsu » Thu Jul 12, 2018 12:51 pm

The colours vary per PPU (read: per NES console). Really. It's been discussed before. (see Quietust's response). Grey is the most common, but I think every single person here has seen variance (some shade of green, peach, or red).

As for the duration: on the NES side, it's consistent (I believe every 1 second), but the real-world results (on screen) are going to vary because of what rainwarrior said. CRTs tend to handle video signal being dropped (line held low) quickly, so visually you see the screen flashing every 1 second. LCDs and other present-day TVs don't tend to do this, they tend to "screw around" a lot (often for several seconds) when the video signal is lost and restored; it usually has to do with logic relating to determining signal "type" (ex. 240p vs. 480p vs. 480i). So you might not see anything on Model X of a Samsung LCD, while Model Y of a Samsung LCD might show something, and Model B of a Sony might behave similarly to a CRT. There is tremendous variance that you have no control over, sadly.

If you're developing something that requires you to have specific timing or are concerned about this for a good reason, I would suggest using an actual CRT for testing/development, rather than fighting with the idiocies of LCD behaviour. Another possibility I suppose would be to use an oscilloscope instead of a TV; I imagine lidnariq could talk about that (I sure can't).

Maybe it would help us if you explained why you're asking the question. It's a good first time post and legitimate question, but your follow-up questions are perplexing -- one of those "why does this person care about that" scenarios. If we understand better the "why", maybe we can help you better. :-)

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: How often does the CIC chip reset?

Post by orlaisadog » Thu Jul 12, 2018 12:58 pm

I'm doing it for:
A: Fun
and
B: viewtopic.php?f=2&t=9342&start=90
If there was a competition I think I have an idea for a Mario game with 1 chip

User avatar
koitsu
Posts: 4216
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: How often does the CIC chip reset?

Post by koitsu » Thu Jul 12, 2018 1:11 pm

Oh I see... the focus being that the cartridge have basically a single chip for PRG and no other IC-based discrete logic.

I don't know how you'd deal with bypassing the CIC in that situation. Might have to be a compo that is guaranteed to run on a modded (CIC disabled) NES.

The CIC page on the Wiki describes some bypassing methods used by unlicensed game developers at the time, but as noted there later versions of the console added diodes to ensure that method of bypass can't be used (I'm not sure why it says "but not on the reset pins" in the Wiki, almost like that's implying bypass is still possible in some way through that). More a question for hardware guys than me, that's for sure.

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: How often does the CIC chip reset?

Post by orlaisadog » Thu Jul 12, 2018 1:24 pm

Yes but we can do what I just said. Also, by the length, I meant how long the flash itself would last. "2 frames for PPU initialization?" Also, could it be disguised as lightning as I said earlier?

lidnariq
Posts: 9021
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: How often does the CIC chip reset?

Post by lidnariq » Thu Jul 12, 2018 2:40 pm

orlaisadog wrote:Which colour would the flashes be and how long?
The PPU's palette is not changed during /RESET, but the PPU itself is forced stopped. (No video is generated at all). On an old CRT, that means the screen will probably be black? But on some it might be blue.
2 frames for PPU initialization?
Exactly 262 scanlines (312 on PAL NES). The PPU exits reset drawing the very first line of the visible field (but video is disabled), and you can start accessing the registers after the first vblank finishes. Usually you don't care about this, but in this specific case it might be worth optimizing things to start drawing sooner.
On a CRT, could it be disguised as a lightning strike if the game has a rain effect or would that be too annoying?
The PPU is held in reset, and allowed to draw, for an equal amount of time. I think it'd be too uniform to plausibly be lightning.

Yes, during that first one or two fields after the PPU were released from reset, the PPU would display whatever color you'd left in palette memory at $3F00 before the CIC asserted /RESET.
Anything else I'd need to know if I did this?
https://wiki.nesdev.com/w/index.php/PPU_power_up_state and to a lesser extent https://wiki.nesdev.com/w/index.php/CPU_power_up_state

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: How often does the CIC chip reset?

Post by orlaisadog » Thu Jul 12, 2018 11:54 pm

So why do we normally wait 2 frames?

lidnariq
Posts: 9021
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: How often does the CIC chip reset?

Post by lidnariq » Fri Jul 13, 2018 12:07 am

Because vblanks are the simplest and there aren't very many other external clock sources.

The point at which we can change the PPU is 20(2C02)/70(2C07) scanlines after the first NMI. But we can't set up any kind of timer from the PPU to let us know when that happens.

I think I've seen timed code init loops once or twice (guaranteed to take at least 312×341×5÷16 CPU instructions)

tepples
Posts: 21841
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: How often does the CIC chip reset?

Post by tepples » Fri Jul 13, 2018 12:36 am

That and you can detect the TV system during the vblank wait loop, as seen in paldetect.s:

1. wait for one vblank to start (by spinning on $2002)
2. wait for enough cycles to pass second vblank on NTSC (341*262/3) but not PAL NES (341*312/3.2) and check $2002
3. wait for enough cycles to pass second vblank on PAL NES but not PAL famiclone (341*312/3) and check $2002

Post Reply