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:

Resetting Micro Machines

Post by zeroone »

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?
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Resetting Micro Machines

Post by tepples »

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.
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 »

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.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Resetting Micro Machines

Post by tepples »

Instead of choosing Emulation > Soft Reset (FCEUX SDL) or NES > Reset (FCEUX Windows) or Nintendulator's counterpart once, choose the menu item twice.
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 »

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?
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Resetting Micro Machines

Post by tepples »

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?
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 »

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.
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: Resetting Micro Machines

Post by thefox »

Create a trace log from a power-on, then from a soft reset. See where they diverge.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
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 »

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

Code: Select all

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: Select all

 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?
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: Resetting Micro Machines

Post by thefox »

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
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Resetting Micro Machines

Post by rainwarrior »

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.)
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: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?
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Resetting Micro Machines

Post by rainwarrior »

$2004 isn't readable on a lot of Famicom units. Micro Machines polls it to time some raster effects.
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Resetting Micro Machines

Post by Zepper »

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..???
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Resetting Micro Machines

Post by rainwarrior »

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.
Post Reply