Help removing iNes header of rom?

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
User avatar
taskforce
Posts: 21
Joined: Mon Jul 21, 2008 12:33 pm
Location: Ontario, Canada

Help removing iNes header of rom?

Post by taskforce »

Hi there,

I'm still relatively new to this whole thing, but I am in the process of doing a repro of an SMB2J cart. There has been a ton of info on here for doing so and I think I have everything figured out except one little detail.

I'm attempting to remove the header of the iNes file. I understand that this step is necessary before burning the EPROM chips.

My problem is that I'm not sure at what point to remove the iNes header. Do you remove it before you split the NES file into CHR and PRG? If so, then what happens is ucon64 nor readnes will even open the file, saying that it has a bad header.

Do I just strip the first 16 bytes from the final PRG file in the end? This is pretty confusing, so any help would be greatly appreciated.

Using readnes to duplicate the CHR and PRG, I ended up with the following file sizes:

SMB2J.PRG - 129 KB (132,218 bytes)
SMB2J.CHR - 128 KB (131,312 bytes)

The problem is in the .PRG file right? That is perhaps where the header should be removed. I'm really not sure.

Thanks alot,
Brian
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

The sizes should be exactly 131,072 (2^17) bytes.
User avatar
electro
Posts: 132
Joined: Tue Jan 29, 2008 11:12 am
Location: New York

Post by electro »

I want through this too, but it was a little easier for me because I was only using PRG data.

What hex editor do you use?

There's a thread from about February where I was helped with this stuff. In my case I only had to remove the first 16 bytes right off of the very top line of my hex code.

(I was only working with sound, no video. So there was no CHR code in my case.)

See this thread: http://nesdev.com/bbs/viewtopic.php?t=3 ... highlight=

Then I just had to concatenate the edited code (copy and paste it X number of times to fill the capacity of the particular chip I was using. There's another thread about this too, should be located in Feb, around where the above thread is.

See this thread:
http://nesdev.com/bbs/viewtopic.php?t=3 ... highlight=

I use HXD Hex editor, and in the editor the first line of hex code looks like this:

4E 45 53 1A 01 00 01 00 00 00 00 00 00 00 00 00 NES.............

I just cut that whole line out, then copy and paste the edited code to accommodate the capacity of the chip I'm using.


Hope that helps a little.

Tony
User avatar
taskforce
Posts: 21
Joined: Mon Jul 21, 2008 12:33 pm
Location: Ontario, Canada

Hex

Post by taskforce »

thanks for the responses.

I actually read through that thread yesterday to try and figure out what I was trying to get.

However, I'm using HXD to edit my files. I'm not having any troubles with the copying and pasting, however, I'm just not sure why my file sizes are off.

As tepples mentioned, the file sizes should be exactly 131,072. This is definitely off from the numbers I'm getting. Mainly because I did NOT remove the iNES header from the actual .NES rom before splitting.

Did you remove your header from the PRG file AFTER splitting them?

This is what I find really confusing. When to actually remove the iNES header.
User avatar
electro
Posts: 132
Joined: Tue Jan 29, 2008 11:12 am
Location: New York

Post by electro »

I didn't have to "split" anything because I was not using any video in my code, only audio.

I don't really know, but it would seem logical that you should remove the header first, before doing any other editing such as splitting or copy/paste?

Hopefully someone with more experience will chime in on this because I'n not sure.
User avatar
electro
Posts: 132
Joined: Tue Jan 29, 2008 11:12 am
Location: New York

Post by electro »

It was explained a little more on this thread in another forum:
http://www.nesworld.com/cgi-bin/yabb/Ya ... 1202861725

The guy who replied to my post said this:

"You then need to strip the header off the ROM, split it into its PRG and CHR segments."

So, I assume that means, remove the header first, then split and then concatenate.
User avatar
taskforce
Posts: 21
Joined: Mon Jul 21, 2008 12:33 pm
Location: Ontario, Canada

headers

Post by taskforce »

okay, that makes sense.
my issue was that once I removed the header, both ucon64 and readnes would not recognize the file, saying that it had a bad header. On my NES rom file, this is what the header looks like in HXD:

Left side:

Code: Select all

4E 45 53 1A 04 01 41 00 00 00 00 00 00 00 00 00
And on the right side:

Code: Select all

NES...A.........
This is what I want to remove, correct?
User avatar
electro
Posts: 132
Joined: Tue Jan 29, 2008 11:12 am
Location: New York

Post by electro »

I've never used ucon64 and readnes, since I never needed to split the code.

Hopefully someone will help us figure out what's going on here.
User avatar
Hamtaro126
Posts: 786
Joined: Thu Jan 19, 2006 5:08 pm

Post by Hamtaro126 »

Yes, That is the Header!

BTW: I could not even belive that no-one ever known how to use mappers and how to look for one. Everyone should have known about this stuff before even entering this site!
User avatar
taskforce
Posts: 21
Joined: Mon Jul 21, 2008 12:33 pm
Location: Ontario, Canada

header

Post by taskforce »

okay, well I figured that this was the iNES header that I had to remove.

However, now I'm wondering how to split the CHR and PRG file from the NES rom. After you remove the header from the NES file, ucon64 and readnes will no longer recognize the file, or they say that it has a bad header.

All I did was go into the NES file with HXD and deleted those first 16 bytes.

Am I doing this wrong? And if not, then how did you split your PRG and CHR files after killing the header?

Thanks!
User avatar
taskforce
Posts: 21
Joined: Mon Jul 21, 2008 12:33 pm
Location: Ontario, Canada

solved!

Post by taskforce »

Okay, so I just figured out a really great way to successfully pull the PRG and CHR files along with the iNes header (HDR).

If you would like to split your iNES files all in one go, use tniNES 2.6. Here is a link: http://huizen.dds.nl/~patriekl/tniNES.html

This is definitely the easiest way to go, and then just use a hex (I use HXD) editor to copy the CHR & PRG for your desired size.

Thanks a lot for everybody's contributions and input to this post!
User avatar
electro
Posts: 132
Joined: Tue Jan 29, 2008 11:12 am
Location: New York

Post by electro »

So using tniNES 2.6, did you first split the code and then remove the header?

Curious, I might be doing this in the future.

Glad to know you figured it out. I'm surprised you didn't get more help in this thread. Maybe due to summer.
User avatar
taskforce
Posts: 21
Joined: Mon Jul 21, 2008 12:33 pm
Location: Ontario, Canada

Post by taskforce »

whats great about tnines is that it actually splits the code, and puts the header in its own separate file (a .HDR file). that way the PRG and CHR are extracted without any headers left in them at all.

Its as simple as doing this:
tnines -s mario.nes

check it out. the only thing is, roms with things like VRAM i don't understand because it created a footer file (.FTR) when I tried to do this. But so far it works with CHR ROM stuff.
User avatar
electro
Posts: 132
Joined: Tue Jan 29, 2008 11:12 am
Location: New York

Post by electro »

I see.

I wonder why though, you weren't able to first remove the header and then split manually?

Well, it's good to know you found a solution.
Post Reply