Resetting Micro Machines

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Resetting Micro Machines

Post by zeroone »

Regarding Cvetnye Linii (Color Lines), Nintendulator appears to fully reset the APU on reset. In the snippet below, the power on code is identical to the reset code, including clearing the IRQ request flags:

Code: Select all

void	PowerOn  (void)
{
#ifndef	NSFPLAYER
	ZeroMemory(Regs, 0x18);
#endif	/* !NSFPLAYER */
	Frame::PowerOn();
	Square0::PowerOn();
	Square1::PowerOn();
	Triangle::PowerOn();
	Noise::PowerOn();
	DPCM::PowerOn();
	Race::PowerOn();
	Cycles = 1;
	CPU::WantIRQ &= ~(IRQ_FRAME | IRQ_DPCM);
	InternalClock = 0;
}
void	Reset  (void)
{
#ifndef	NSFPLAYER
	ZeroMemory(Regs, 0x18);
#endif	/* !NSFPLAYER */
	Frame::Reset();
	Square0::Reset();
	Square1::Reset();
	Triangle::Reset();
	Noise::Reset();
	DPCM::Reset();
	Race::Reset();
	Cycles = 1;
	CPU::WantIRQ &= ~(IRQ_FRAME | IRQ_DPCM);
	InternalClock = 0;
}
This may not reflect actual hardware behavior. Per the discussion above, I suspect that Cvetnye Linii (Color Lines) won't reset properly on a real system.

In any case, should emulators fully reset the APU on reset?
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Resetting Micro Machines

Post by rainwarrior »

Reset at least silences the APU (like writing 0 to $4015). Reset doesn't affect any expansion audio that I know of, though.

I'm not sure about the rest of it. Silence via $4015 requires at least the high byte of frequency to be reloaded before they can produce sound again, but I haven't really tested if the other registers have surviving information.

I think lidnariq determined that the noise LFSR was reset to 0 as well?

Mega Man seems to rely on sweep being disabled at least at power-on (i.e. the "game genie" sound problem), not sure if it's affected by reset.

$4017 is not reset, as discussed early.
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: Resetting Micro Machines

Post by lidnariq »

No, the noise LFSR is left as-is. It just comes out of a cold boot all 0, like most other things in the CPU. (due to how NMOS works, I suspect.)

As far as what things are cleared on warm boot? I've been meaning to sit down with Visual2A03 and find every stupid place that _res winds through, but there's an awful lot of them: 312.
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Resetting Micro Machines

Post by zeroone »

rainwarrior wrote:$4017 is not reset, as discussed early.
Agreed. But, there might be many poorly tested games out there that fail on reset, not just this Dendy ROM. Are there any side effects to fully resetting the APU on reset? Will any games actually break? Since Cvetnye Linii (Color Lines) resets properly in most emulators, I suspect all of them are already resetting the APU on reset.
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: Resetting Micro Machines

Post by lidnariq »

To briefly summarize: Of the 312283 (I forgot to deduplicate) nodes that are cleared during reset, (at least) 161159 are given names in Visual2A03:
* frame_irq (acknowledging the IRQ but not disabling it)
* frm_c
* snd_halt
* spr_addrX (to cleanly abort an in-progress DMA, I assume)
* sq0_cX, sq0_envcX, sq0_envtX, sq0_lenX, sq0_on, sq0_swptX, sq0_tX
* sq1_cX, sq1_envcX, sq1_envtX, sq1_lenX, sq1_on, sq1_swptX, sq1_tX
* tri_cX, tri_lcX, tri_lenX, tri_on, tri_tX
* noi_envcX, noi_envtX, noi_lenX
* pcm_aXX, pcm_bitsX, pcm_en, pcm_irq, pcm_lcXX, pcm_on
Last edited by lidnariq on Mon Feb 06, 2017 1:56 pm, edited 2 times in total.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Resetting Micro Machines

Post by rainwarrior »

zeroone wrote:Are there any side effects to fully resetting the APU on reset? Will any games actually break?
Except for $4017 the registers are write only. I think the only way it can affect anything but sound is through an IRQ? (DPCM and/or Frame Counter.)

So... the consequences of an incorrectly initialized APU are quite low, especially since it's silenced by the reset.
lidnariq wrote:No, the noise LFSR is left as-is. It just comes out of a cold boot all 0, like most other things in the CPU. (due to how NMOS works, I suspect.)
Ah, thanks for the clarification.
lidnariq wrote:To briefly summarize: Of the 312 nodes that are cleared during reset, (at least) 161 are given names in Visual2A03:
* frame_irq (acknowledging the IRQ but not disabling it)
* frm_c
* snd_halt
* spr_addrX (to cleanly abort an in-process DMA, I assume)
* sq0_cX, sq0_envcX, sq0_envtX, sq0_lenX, sq0_on, sq0_swptX, sq0_tX
* sq1_cX, sq1_envcX, sq1_envtX, sq1_lenX, sq1_on, sq1_swptX, sq1_tX
* tri_cX, tri_lcX, tri_lenX, tri_on, tri_tX
* noi_envcX, noi_envtX, noi_lenX
* pcm_aXX, pcm_bitsX, pcm_en, pcm_irq, pcm_lcXX, pcm_on
Interesting!
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: Resetting Micro Machines

Post by lidnariq »

Ok, I made an effort to trace down the remaining nodes.

Of the 283 unique nodes that are grounded during +RESET, 159 are as above.
Another 22×4=88 nodes keep the address bus, OUTn, /JOYn, and R/W pins Hi-Z during +RESET.
(You'll notice M2 is not in the list. reset goes through several extra inverters before eventually disabling the drivers for M2, so they're not counted in the 283)

6: The upper six bits of the delta channel DAC (W4011) are cleared (but not the LSB)
8: The DPCM shift register is cleared.
4: The lower four bits of noise frequency register (W400E) are cleared (but not the noise/tonal bit)
4: The lower four bits of the channel enable register (W4015) are cleared (but not the DPCM in-progress flag)
1: glue node for connecting the outer 2A03 hardware to the 6502

The remaining 13 nodes I kinda gave up on; they are mostly related to DPCM and DPCM DMA.
(they are : somethings pertaining to [apu_clk2 ; the frame sequencer ; -reset ; 2x pcm_doadjust ; 2x rdy ; use_spr_ab ; 2x noi_t ; pcm_t ; dpcm ; dpcm dma] )

The attached text file are my added set of node names for Visual2A03. You'll want to remove or improve the "something_XXX" node names rather than using my terrible halfassed names.
Attachments
new_nodenames_for_reset.txt
(2.79 KiB) Downloaded 108 times
Great Hierophant
Posts: 780
Joined: Tue Nov 23, 2004 9:35 pm

Re: Resetting Micro Machines

Post by Great Hierophant »

The Aladdin Deck Enhancer ROM of Micro Machines does not hang on the menu screens when I press the reset button on my Famicom and AV Famicom. It only mutes the sound until the screen changes. Sometimes the graphics may appear garbled for a second, but they will appear normally thereafter. The European ROM of Micro Machines always does a proper reset on my Famicom and AV Famicom regardless of the screen you are on. The European ROM does not adjust the speed in any way for PAL machines, it runs perfectly on an NTSC console.
Post Reply