nesdev.com
https://forums.nesdev.com/

CPU ram Initial value is 0x00?
https://forums.nesdev.com/viewtopic.php?f=3&t=13199
Page 1 of 1

Author:  zxbdragon [ Fri Sep 04, 2015 5:07 am ]
Post subject:  CPU ram Initial value is 0x00?

fceux is 0x00 (NTSC)
nestopia is 0xFF (NTSC),or 0x00(DENDY)

Which is the right one?

Author:  Bregalad [ Fri Sep 04, 2015 5:09 am ]
Post subject:  Re: CPU ram Initial value is 0x00?

The memory is filled randomly with values which varies from system to system, usually it's $ff but with some bits randomly clear. This is not just CPU RAM, but also VRAM, as both are materialized 6116 chips on the NES' motherboard.

I have no idea of the initial state of the Dendy or other famiclones though.

Author:  Zepper [ Fri Sep 04, 2015 5:17 am ]
Post subject:  Re: CPU ram Initial value is 0x00?

It doesn't matter. All memory must be initialized by software.

Author:  zxbdragon [ Fri Sep 04, 2015 5:19 am ]
Post subject:  Re: CPU ram Initial value is 0x00?

Zepper wrote:
It doesn't matter. All memory must be initialized by software.

No, initialization is different, a game may be different

Author:  Zepper [ Fri Sep 04, 2015 5:23 am ]
Post subject:  Re: CPU ram Initial value is 0x00?

zxbdragon wrote:
Zepper wrote:
It doesn't matter. All memory must be initialized by software.

No, initialization is different, a game may be different


Argh, read what Bregalad wrote.

Author:  tokumaru [ Fri Sep 04, 2015 5:35 am ]
Post subject:  Re: CPU ram Initial value is 0x00?

AFAIK the initial contents of RAM can change depending on how the chip is manufactured, the temperature, and a whole lot of other unpredictable analog variables. There are no "official" values an emulator can use, which is why different emulators use different values.

Games aren't supposed to rely on uninitialized memory, unless they're using it as a source of randomness (the randomness is quite poor though, since many addresses tend to be either $00 or $ff, with few flipped bits, and the same memory location tends to assume the same value every time). If they do rely on it, and can possibly misbehave with any values, then that's a bug.

Author:  Dwedit [ Fri Sep 04, 2015 5:57 am ]
Post subject:  Re: CPU ram Initial value is 0x00?

Bootleg versions of games ripped from multicarts often rely on uninitialized memory, since the menu program would initialize them. Hence World 0-1 in bad versions of Super Mario Bros.
Final Fantasy 1 uses uninitialized memory for the RNG.

Author:  zxbdragon [ Fri Sep 04, 2015 6:17 am ]
Post subject:  Re: CPU ram Initial value is 0x00?

Dwedit wrote:
Bootleg versions of games ripped from multicarts often rely on uninitialized memory, since the menu program would initialize them. Hence World 0-1 in bad versions of Super Mario Bros.
Final Fantasy 1 uses uninitialized memory for the RNG.


0-1 Will not happen in fceux

Author:  Dwedit [ Fri Sep 04, 2015 6:22 am ]
Post subject:  Re: CPU ram Initial value is 0x00?

FCEUX uses a 0000 FFFF 0000 FFFF pattern that happens to put the world byte as 0, so it starts on 1-1. Real hardware would probably have FF there, so it would start at 0-1.

Author:  rainwarrior [ Fri Sep 04, 2015 8:54 am ]
Post subject:  Re: CPU ram Initial value is 0x00?

There's some valid reasons not to entirely initialize memory.

The most common is to retain some state after reset, like how Mario Bros. will remember which world you got to for the "continue" cheat code even after you reset. It checks for a very specific "key" value somewhere in RAM on startup, and if it's there it presumes that you've already been playing and it should leave it how it is. (The key value should be at least few bytes, with a healthy mix of 0 and 1 bits, something unlikely to happen by accident.) This is how the SMB / Tennis "swap trick" works: https://www.youtube.com/watch?v=eEEnEoKSgQs

Games that have a battery backed save will have to deal with uninitialized SRAM at first boot, and after any battery failure. Obviously it shouldn't be initialized if the player already has something saved there. Similar techniques apply in this case.

Of course, there's a bunch of games that just straight up forget to initialize memory, and rely on "lucky" startup values to run correctly.

Author:  tepples [ Fri Sep 04, 2015 11:49 am ]
Post subject:  Re: CPU ram Initial value is 0x00?

The initial values in CPU RAM ($0000-$1FFF) and VRAM are unspecified. The same is true of PRG RAM (usually at $6000-$7FFF) and CHR RAM on the cartridge unless they're battery-backed.

(I use "unspecified" with the meaning that the C and C++ standards use.)

Author:  AWJ [ Fri Sep 04, 2015 3:05 pm ]
Post subject:  Re: CPU ram Initial value is 0x00?

zxbdragon wrote:
Zepper wrote:
It doesn't matter. All memory must be initialized by software.

No, initialization is different, a game may be different


If a game runs differently depending on the initial contents of RAM, it'll run differently on different NES consoles.

Author:  rainwarrior [ Fri Sep 04, 2015 6:53 pm ]
Post subject:  Re: CPU ram Initial value is 0x00?

AWJ wrote:
If a game runs differently depending on the initial contents of RAM, it'll run differently on different NES consoles.

In theory it may run differently on the same console at different times too.

In practice, RAM usually initializes mostly to 1s, with a few 0 bits here and there. Most of the time, uninitialized RAM bugs are only dependent on the state of a few bytes, and most of the time they will be $FF.

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