W
whale_cancer
Guest
Hello!
Working on a utility for seeking and replacing graphics in .NES ROM files. These (the ROMs that is) are just .bin files for my purposes.
What I have done so far:
1. take a strip of sprites, turn them in to a .txt file in a more manageable file format. In my case, this is a .txt file that just contains a serious of 8 bytes on each line, with 2 lines forming a single tile image
2. do the above but with a second file.
3. do the above, but with the original ROM files graphics.
This all works. I can convert the files into my .txt format and output them as graphics again. My problem is I want to take the text of the first strip (spr_marioStrip.txt) find all lines in the original ROM files graphics (bin.txt) that match that first strip and replace them with the values of the second strip (spr_warioStrip.txt).
However, I find no matches. If I manually look at the .txt files, I can see that it should be finding values spr_marioStrip.txt in bin.txt, but my code fails to do so.
For example, here are the first two lines of spr_marioStrip.txt:
Here are lines 10689 and 10690 in bin.txt
You can see they are the same, but my code doesn't find this. Here is my code:
My code:
Any ideas on what could be going wrong?
Working on a utility for seeking and replacing graphics in .NES ROM files. These (the ROMs that is) are just .bin files for my purposes.
What I have done so far:
1. take a strip of sprites, turn them in to a .txt file in a more manageable file format. In my case, this is a .txt file that just contains a serious of 8 bytes on each line, with 2 lines forming a single tile image
2. do the above but with a second file.
3. do the above, but with the original ROM files graphics.
This all works. I can convert the files into my .txt format and output them as graphics again. My problem is I want to take the text of the first strip (spr_marioStrip.txt) find all lines in the original ROM files graphics (bin.txt) that match that first strip and replace them with the values of the second strip (spr_warioStrip.txt).
However, I find no matches. If I manually look at the .txt files, I can see that it should be finding values spr_marioStrip.txt in bin.txt, but my code fails to do so.
For example, here are the first two lines of spr_marioStrip.txt:
Code:
0000001100001111000111110000101000111010010000000100111100111111
0000001100001100000100000000111100111111011111110111111100110000
Code:
0000001100001111000111110000101000111010010000000100111100111111
0000001100001100000100000000111100111111011111110111111100110000
My code:
Code:
for (var j = 0; j < 64; j += 1)
{
mario_binRowOne = file_text_readln(mario_file);
mario_binRowTwo = file_text_readln(mario_file);
wario_binRowOne = file_text_readln(wario_file);
wario_binRowTwo = file_text_readln(wario_file);
show_debug_message("Searching through strip files at line "+string(j*2));
for (var i = 0; i < 8192; i += 1)
{
bin_binRowOne = file_text_readln(bin_file);
bin_binRowTwo = file_text_readln(bin_file);
if bin_binRowOne == mario_binRowOne
&& bin_binRowTwo == mario_binRowTwo
{
bin_binRowOne = wario_binRowOne;
bin_binRowTwo = wario_binRowTwo;
show_debug_message("Match found!");
}
file_text_write_string(binNew_file, bin_binRowOne)
file_text_write_string(binNew_file, bin_binRowTwo)
}
}
Last edited: