FCEUX Default Memory Values and Rom for Reading Values.

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

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

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by rainwarrior »

So, it sounds like what you want is to be able to practice/TAS a particular setup that you could later duplicate on a live hardware run?

On the frame where you press start to begin it seems to keep cranking on the PRNG seed for a few more frames before it starts setting up those location variables. It seems like any subtle timing differences are still going to lead to divergence right up to that point. So if you're going to insert values it would probably be right at that moment.

I don't think you can really do this through the PRNG seed though ($12-14). You can't really reverse engineer what values to put in there from what you see in the game. You could probably just set up the location values manually at that point, though? Like it seems that the stuff that it sets up there at the start of the game is the only thing that's reliable anyway, so maybe just focus on building that?


Something that may be interesting, the first frame where $12-14 get written on FCEUX New PPU vs Bizhawk, $12 and $14 are the same but $13 is different (on one, that entropy-gathering loop doesn't get to $13 before the NMI interrupts it) but if I "correct" FCEUX's byte $13 manually at that point they seem to synchronize perfectly afterward across the whole RAM. So... after that first frame of activity (something like 14 frames after boot) it seems like they do start to agree on the results. The divergence may only be due to differences in how the reset timing is emulated?
CLChambers00
Posts: 78
Joined: Wed Jul 19, 2017 10:23 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by CLChambers00 »

Correct, being able to TAS out thousands of input variations and different frames upon which to initiate start would be extremely expedient. For example, instead of holding A and pressing start on frame 534, I could see immediately all the variations such as holding A, B, and Select, and checking out pressing start for frames 534 through 553. That spreadsheet that I linked earlier in this thread was me tracking all of the item placement results. If the results from the emulator were the same as hardware I would be able to duplicate the same inputs on the same frames and get the same item placements. It is about finding the most optimized route quickly, and something which can be reasonably duplicated.

The syncing that you managed between FCEUX New PPU vs Bizhawk was only a matter of changing a value in the $13 address? If so could it then be possible for me to play around with this value and potentially sync with original hardware? Obviously I will have to examine the item placement addresses and run many trials to see if sync occurs using same input manipulation that I do for console. It is possible for this to work? I am only looking at 255 possible values right? Maybe the idea of syncing one of these emulators to original hardware is possible, if we can force them to sync with one another?
CLChambers00
Posts: 78
Joined: Wed Jul 19, 2017 10:23 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by CLChambers00 »

How are you "correcting" $13? When I change the value via lua script it does not seem to really change anything since values are being written to it by something that I am not changing. Though maybe if $13 is being read at that time then perhaps it does alter something?
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by rainwarrior »

I started the game in FCEUX and advanced until the first frame where $12-15 changed (something like 14 frames), then I did the same in Bizhawk. At that point, only $13 was different between the two, so I set the value at $13 in FCEUX to be equal to the one from Bizhawk. After that they stayed the same on subsequent frames.

The game is just spinning in a loop that cycles $15,14,13,12. Between the two emulators one of them seems to come out of reset very slightly later than the other, so that first frame gets one more tick of the loop, which updates $13 one more time. So, aside from that very small timing difference after reset the two emulators actually appear to match up.
CLChambers00
Posts: 78
Joined: Wed Jul 19, 2017 10:23 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by CLChambers00 »

My observations are different. FCEUX (New PPU) populates $12-$14 on frame 16, and Bizhawk(NesHawk) populates them on frame 15. I observe that the initial values in these addresses...

Addresses $12 and $13 were the same, it was $14 that was different.

$12 (69)
$13 (109)
$14 (-71 FCEUX), (185 Bizhawk)

These are the values taken from FCEUX on frame 16, and from Bizhawk on frame 15.
CLChambers00
Posts: 78
Joined: Wed Jul 19, 2017 10:23 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by CLChambers00 »

Also when I write in a value it shows it changed for that frame but then all the subsequent frames are the same as what they would have been had I not changed it.
CLChambers00
Posts: 78
Joined: Wed Jul 19, 2017 10:23 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by CLChambers00 »

Also, you mentioned earlier that address $11 was a constant 80 after startup but it is -128 for me. This is using FCEUX New PPU. Why would this be different?
Last edited by CLChambers00 on Mon Jul 24, 2017 11:06 pm, edited 1 time in total.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by lidnariq »

CLChambers00 wrote:(-71 FCEUX), (185 Bizhawk)
-71 and 185 are the same 8-bit byte, just interpreted as a signed or unsigned type. (Either way, it's $B9)
CLChambers00 wrote:Also, you mentioned earlier that address $11 was a constant 80 after startup but it is 128 for me.
He said it was a constant $80. The $ means "hexadecimal". The 8-bit byte $80 is the unsigned decimal quantity 128, or the signed decimal quantity -128.
Last edited by lidnariq on Mon Jul 24, 2017 11:09 pm, edited 1 time in total.
CLChambers00
Posts: 78
Joined: Wed Jul 19, 2017 10:23 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by CLChambers00 »

Oh, ok, it is a signed/unsigned issue. Did not know that was an issue. Sorry for the false observations.
CLChambers00
Posts: 78
Joined: Wed Jul 19, 2017 10:23 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by CLChambers00 »

Ok, after setting all the ram watch addresses to unsigned I see the following:
0012-0014 are the same in both FCEUX and Bizhawk for the first two initial frames, on the 3rd initial frame in either 0013 and 0014 both diverge.

0013 in Bizhawk 199, while it is 202 in FCEUX
0014 in Bizhawk 238, while it is 144 in FCEUX

That is frame 17 in Bizhawk, frame 18 in FCEUX
CLChambers00
Posts: 78
Joined: Wed Jul 19, 2017 10:23 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by CLChambers00 »

So when I write 199 and 238 respectively into via a Lua Script file which merely includes the following text:

memory.writebyte(0x0013,199)
memory.writebyte(0x0014,238)

I run this script and then progress one frame, to the frame I want those values written to.

... I see that it changed the values for that frame but when I progress one more frame these addresses populate the same values they would have 219 and 145 respectively. So changing those values did not seem to change the outcomes. Unless I am doing something wrong?
CLChambers00
Posts: 78
Joined: Wed Jul 19, 2017 10:23 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by CLChambers00 »

^ Is a Lua script like this sufficient for an address change? I see that it changes in RAM watch but as it progresses I so no influence from it.
CLChambers00
Posts: 78
Joined: Wed Jul 19, 2017 10:23 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by CLChambers00 »

So concerning the NMI and PPU Alignment, if I am really only getting a 1 in 4 chance for my input manipulation, when done perfectly, then could it be possible that one of the other 3 PPU alignments actually syncs with FCEUX or Bizhawk?
CLChambers00
Posts: 78
Joined: Wed Jul 19, 2017 10:23 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by CLChambers00 »

Also, I am offering a $200 bounty for the person who figures out how to get outcomes to match in original hardware and an emulator with TAS such as Bizhawk and FCEUX. If interested please send me a PM, and we can discuss the details.
CLChambers00
Posts: 78
Joined: Wed Jul 19, 2017 10:23 am

Re: FCEUX Default Memory Values and Rom for Reading Values.

Post by CLChambers00 »

ok, so the emulator route is totally out, I have exhausted today's nes emulation capability but I another twitch streamer by the name threecreepio hacked the rom so that it gives you the values in the score section upon starting the game so we can try out new variations, found a new route and carved off 1.5 seconds already, will grind it some more but another route may work better
Post Reply