nesdev.com
http://forums.nesdev.com/

Resetting Micro Machines
http://forums.nesdev.com/viewtopic.php?f=3&t=15427
Page 1 of 4

Author:  zeroone [ Mon Jan 23, 2017 7:17 pm ]
Post subject:  Resetting Micro Machines

In Nintendulator and my emulator, if you reset Micro Machines, it crashes the CPU (it jumps to a bad location and executes a KIL instruction). But, I have yet to figure out why. It must be sensitive to initial memory values or the state of the CPU. Anyone have a clue on this one?

Author:  tepples [ Mon Jan 23, 2017 8:14 pm ]
Post subject:  Re: Resetting Micro Machines

Did you try to reset twice in a row?

I don't own a copy of Micro Machines, but I do own a copy of Bee 52, and I know that all Codemasters games share library code, such as the "happy face" ROM test and possibly the CHR codec. While testing the Codemasters logo screen for zeroone, I discovered that if I press Reset once, the power light turns off and stays off. If I press Reset again, it comes back up. Perhaps a Reset press at certain points in the program confuses the code that drives the CIC stun circuit.

Author:  zeroone [ Mon Jan 23, 2017 8:21 pm ]
Post subject:  Re: Resetting Micro Machines

tepples wrote:
Did you try to reset twice in a row?

I don't own a copy of Micro Machines, but I do own a copy of Bee 52, and I know that all Codemasters games share library code, such as the "happy face" ROM test and possibly the CHR codec. While testing the Codemasters logo screen for zeroone, I discovered that if I press Reset once, the power light turns off and stays off. If I press Reset again, it comes back up. Perhaps a Reset press at certain points in the program confuses the code that drives the CIC stun circuit.


It's a bit difficult to reset a crashed CPU in an emulator.

Author:  tepples [ Mon Jan 23, 2017 10:25 pm ]
Post subject:  Re: Resetting Micro Machines

Instead of choosing Emulation > Soft Reset (FCEUX SDL) or NES > Reset (FCEUX Windows) or Nintendulator's counterpart once, choose the menu item twice.

Author:  zeroone [ Tue Jan 24, 2017 8:30 am ]
Post subject:  Re: Resetting Micro Machines

tepples wrote:
Instead of choosing Emulation > Soft Reset (FCEUX SDL) or NES > Reset (FCEUX Windows) or Nintendulator's counterpart once, choose the menu item twice.


I don't follow. Can you please clarify what you want me to try?

Author:  tepples [ Tue Jan 24, 2017 8:48 am ]
Post subject:  Re: Resetting Micro Machines

I want you to try a soft reset in your emulator, but try it twice in a row. If the first leads to a STP (also called KIL), the second may cause execution to continue.

Or am I misunderstanding what you meant by "a crashed CPU"? Is your emulator's core actually crashing? Or does a soft reset fail to pull it out of STP?

Author:  zeroone [ Tue Jan 24, 2017 8:55 am ]
Post subject:  Re: Resetting Micro Machines

tepples wrote:
I want you to try a soft reset in your emulator, but try it twice in a row. If the first leads to a STP (also called KIL), the second may cause execution to continue.

Or am I misunderstanding what you meant by "a crashed CPU"? Is your emulator's core actually crashing? Or does a soft reset fail to pull it out of STP?


Ah. I understand now.

The second reset does pull it out of the halt state; however, it shortly thereafter executes the same KIL instruction that halted it on the first reset. Successive resets produce more halts.

Edit: For testing purposes, I modified my emulator to clear main memory and vram on reset, to reset all the mapper banks and to clear all the CPU registers and flags. And, the CPU still jams on reset! That's really strange. Some other state information is causing this.

Author:  thefox [ Tue Jan 24, 2017 9:26 am ]
Post subject:  Re: Resetting Micro Machines

Create a trace log from a power-on, then from a soft reset. See where they diverge.

Author:  zeroone [ Tue Jan 24, 2017 11:30 am ]
Post subject:  Re: Resetting Micro Machines

thefox wrote:
Create a trace log from a power-on, then from a soft reset. See where they diverge.


Code:
BFC8  CA        DEX                             A:0B X:B3 Y:01 P:A5 SP:FB CYC:302 SL:240
BFC9  D0 FD     BNE $BFC8                       A:0B X:B3 Y:01 P:A5 SP:FB CYC:308 SL:240
BFC8  CA        DEX                             A:0B X:B2 Y:01 P:A5 SP:FB CYC:317 SL:240
BFC9  D0 FD     BNE $BFC8                       A:0B X:B2 Y:01 P:A5 SP:FB CYC:323 SL:240
BFC8  CA        DEX                             A:0B X:B1 Y:01 P:A5 SP:FB CYC:332 SL:240
BFC9  D0 FD     BNE $BFC8                       A:0B X:B1 Y:01 P:A5 SP:F8 CYC:338 SL:240
0300  4C 1A FC  JMP $FC1A                       A:0B X:B1 Y:01 P:A5 SP:F8 CYC: 27 SL:241
FC1A  A6 21     LDX $21 = FA                    A:0B X:FA Y:01 P:A5 SP:F8 CYC: 36 SL:241
FC1C  9A        TXS                             A:0B X:FA Y:01 P:A5 SP:FA CYC: 45 SL:241
FC1D  6C 03 03  JMP ($0303) = 9EC7              A:0B X:FA Y:01 P:A5 SP:FA CYC: 51 SL:241
9EC7  33 99     RLA ($99),Y = 0000 @ 0001 = 78  A:01 X:FA Y:01 P:24 SP:FA CYC: 66 SL:241
9EC9  CC E6 72  CPY $72E6 = 00                  A:01 X:FA Y:01 P:25 SP:FA CYC: 90 SL:241
9ECC  90 3C     BCC $9F0A                       A:01 X:FA Y:01 P:25 SP:FA CYC:102 SL:241
9ECE  18        CLC                             A:01 X:FA Y:01 P:24 SP:FA CYC:108 SL:241
9ECF  00        BRK                             A:01 X:FA Y:01 P:24 SP:F7 CYC:114 SL:241
FFFF  FF 00 F1  ISB $F100,X @ F1FA = 53         A:AC X:FA Y:01 P:A4 SP:F7 CYC:135 SL:241


The deviation happens at that spontaneous jump to $0300. From the SL, it coincides with NMI. Prior to the jump, it was in loop that was decrementing X to 0. I will keep investigating.

Edit:

The last bank in mapper 71 is fixed. Here is the NMI address:

Code:
 0F:FFFA:00        BRK
 0F:FFFB:03        UNDEFINED


NMI directs execution to code loaded into RAM.

Edit 2:

I can fix the problem by writing $00 to the PPU CTRL register ($2000) on reset, disabling NMI's. Should that be happening?

Author:  thefox [ Tue Jan 24, 2017 11:51 am ]
Post subject:  Re: Resetting Micro Machines

zeroone wrote:
I can fix the problem by writing $00 to the PPU CTRL register ($2000) on reset, disabling NMI's. Should that be happening?

Yes on NES. No on Famicom (reset line is not connected to PPU).

http://wiki.nesdev.com/w/index.php/PPU_power_up_state

Author:  rainwarrior [ Tue Jan 24, 2017 2:38 pm ]
Post subject:  Re: Resetting Micro Machines

So Micro Machines has yet another way that it runs properly on an NES but not a Famicom! Interesting.

(The other way is reading $2004.)

Author:  zeroone [ Tue Jan 24, 2017 3:03 pm ]
Post subject:  Re: Resetting Micro Machines

rainwarrior wrote:
So Micro Machines has yet another way that it runs properly on an NES but not a Famicom! Interesting.

(The other way is reading $2004.)


It sounds like it should also fail on reset for the NES-101. If anyone has the hardware, please confirm.

What is the reading $2004 issue?

Author:  rainwarrior [ Tue Jan 24, 2017 3:35 pm ]
Post subject:  Re: Resetting Micro Machines

$2004 isn't readable on a lot of Famicom units. Micro Machines polls it to time some raster effects.

Author:  Zepper [ Tue Jan 24, 2017 3:45 pm ]
Post subject:  Re: Resetting Micro Machines

zeroone wrote:
I can fix the problem by writing $00 to the PPU CTRL register ($2000) on reset, disabling NMI's. Should that be happening?

The wiki says clearly to set $2000 to $00 on powerup and RESET in the NTSC version. Well, so the PPU state is different in a Famicom..???

Author:  rainwarrior [ Tue Jan 24, 2017 4:40 pm ]
Post subject:  Re: Resetting Micro Machines

Zepper wrote:
zeroone wrote:
I can fix the problem by writing $00 to the PPU CTRL register ($2000) on reset, disabling NMI's. Should that be happening?

The wiki says clearly to set $2000 to $00 on powerup and RESET in the NTSC version. Well, so the PPU state is different in a Famicom..???


Indeed:
The wiki wrote:
On top-loaders (Famicom, NES-101), the Reset button resets only the CPU.

Page 1 of 4 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/