I did some testing for the NES game called Kage (Shadow of the Ninja) and saved 6 frames on level 1-1. I continued with 1-2, but I lost 5 frames there. The game is very though to optimize, the speed is not constant and lag frames. Which means you could be faster at first, then you're slower, but in the end you end up faster, exactly what happened to me in 1-1. Taking all this into account it gets very annoying comparing a old movie with a second emulator open. So I had an idea to make comparing your work to an old movie easier.
I wrote a lua script that saves all the RAM addresses I want to compare for a level/segment into a txt-file.
Here is the lua script:
Language: lua
Name = "1-1 started"; -- Marker note in TAS Editor of the segment you want to compare
RAMlog = io.open("RAMlog.txt", "a");
RAMlog:write(Name, "\n");
RAMlog:close();
RAMlog_values=function()
XPos1 = memory.readbyte(0x0610);
XPos2nd1 = memory.readbyte(0x0620);
YPos1 = memory.readbyte(0x0630);
YPos2nd1 = memory.readbyte(0x0640);
XPosition1 = XPos2nd1*256 + XPos1;
YPosition1 = YPos2nd1*256 + YPos1;
RAMlog = io.open("RAMlog.txt", "a");
RAMlog:write("XP=", XPosition1, " ", "YP=", YPosition1, "\n"); -- message which is written to the txt-file and displayed later using another script
RAMlog:close();
end;
FCEU.registerafter(RAMlog_values);
You can change the logged RAM addresses and the message to what ever you want.
This script creates a txt-file, which looks like this:
1-1 started
XP=5632 YP=8704
XP=5656 YP=8704
XP=5679 YP=8618
XP=5704 YP=8538
XP=5752 YP=8464
XP=5798 YP=8396
.
.
.
1-2 started
XP=5632 YP=8704
.
.
.
Another lua script should read a specific line from the txt-file depending on the framecounter. Note: This only works with TAS Editor due to the usage of Marker which is important.
Here's the script for it so far,
I need a bit of help to finish it.
Language: lua
Disp=function()
if taseditor.engaged() == true
then
Marker = taseditor.getmarker(movie.framecount());
M_Str = taseditor.getnote(Marker);
-- todo: function that finds the frame number of the Marked frame
Diff = movie.framecount() - M_frame; -- Diff points at the line in the RAMlog.txt file used for the current frame
RAMlog = io.open("RAMlog.txt", "r");
-- todo:
-- Search for String in the RAMlog.txt file which is the same as the marker note
-- From there use the Diff to pick the right line in the RAMlog.txt file
RAMlog:close();
end;
end;
FCEU.registerafter(Disp);
How should this work:
The script reads the frame number and the note of the marker where the playback cursor currently is. Then it calculates a difference between the frame where playback cursor is and the frame number of the marker.
Then it searches for a string in the txt-file which is the same string as in the marker note. After something is found it uses the difference between framecounter and marker to pick up the right line.
Let's say your marked frame with the note "1-1 started" is frame 300 and the playback cursor is at 305. Five lines after the string "1-1 started" in the txt-file is the right line ("XP=5752 YP=8464"), which should be read out. The marked frame would be the second line in the txt-file. On a new level another marker will point to other areas in the txt-file and read out the corresponding data.
As already mentioned this one is
not finished, and I would be glad if someone finishes it. I need some help with the io-functions and I couldn't find a function that returns the frame number of a marker.
I hope everything is well written and understandable, if not feel free to ask.