News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: How to tell if a ROM is headered or unheadered?  (Read 51517 times)

Apocass1n

  • Newbie
  • *
  • Posts: 3
    • View Profile
How to tell if a ROM is headered or unheadered?
« on: January 05, 2015, 04:45:27 pm »
I recently made a post saying that I can't run Metal Gear on fMSX, and someone said that it might be because the emulator requires either an unheadered or headered rom and the ROM i'm using isn't what it needs.

SunGodPortal

  • Hero Member
  • *****
  • Posts: 2919
  • 2 + 2 = 5
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #1 on: January 05, 2015, 06:34:56 pm »
No no no. Not because the emulator requires it, but because of the patch you wanted to apply.

Think of a patch as being like "Okay, so the data at this location needs to be overwritten with this data." So, if the patch was designed for a ROM with a header and you try to use it on a ROM that has no header, all of the changes will be made in the wrong spots, period.

Suppose you needed someone to fix your tail light and they tried to use the parts for that on your transmission and did so even though it was obviously the wrong thing to do. It would destroy your vehicle's ability to function. It's kinda like that.

I just wanted to clear that up. Someone else more knowledgeable can help with the other part.

EDIT: Come on somebody. Help this dude out already.
Cigarettes, ice-cream, figurines of the Virgin Mary...

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7037
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #2 on: January 05, 2015, 06:52:33 pm »
In Windows, the easiest way to tell is by looking at the file in File Explorer.
ROMs will be an exact number of kilobytes in size (not sure what size MSX ROMs use. I think it's 32, 64, 128, 256 and 512 KB). ALL OF THOSE even numbers.
If any data (such as a header) is added, it will push up the reported size, probably to an odd number.
"My watch says 30 chickens" Google, 2018

puzzledude

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #3 on: January 06, 2015, 04:42:56 pm »
I recently made a post saying that I can't run Metal Gear on fMSX, and someone said that it might be because the emulator requires either an unheadered or headered rom and the ROM i'm using isn't what it needs.
Emulators ignore the header, the external one anyway and display the basic data of the internal header. (But let us forget the internal one). The header is a leftover of the copier, which scaned the carteidge into the rom file and it needs additinal data written at the beginning of the file. This is a nightmare, since all addresses are then shifted, but (for instance) the pointers point to the old locations, ignoring the header. The first thing to do before trying to edit or patch any game, is to remove the header; but some games actually need one, since the creator of the ips decided to keep it.

The TUSH lets you know if the file has a header or not, and will remove it or add it, depends on what you want.
http://www.romhacking.net/utilities/608/

This program is also very usefull, it tells you if you have a header as well as all hashes (file IDs) to verify if you have the correct original rom to patch to.
http://www.romhacking.net/utilities/1002/



Gideon Zhi

  • Discord Staff
  • Hero Member
  • *****
  • Posts: 3531
    • View Profile
    • Aeon Genesis
Re: How to tell if a ROM is headered or unheadered?
« Reply #4 on: January 06, 2015, 04:55:31 pm »
Emulators ignore the header, the external one anyway and display the basic data of the internal header. (But let us forget the internal one). The header is a leftover of the copier, which scaned the carteidge into the rom file and it needs additinal data written at the beginning of the file. This is a nightmare, since all addresses are then shifted, but (for instance) the pointers point to the old locations, ignoring the header. The first thing to do before trying to edit or patch any game, is to remove the header; but some games actually need one, since the creator of the ips decided to keep it.

The TUSH lets you know if the file has a header or not, and will remove it or add it, depends on what you want.
http://www.romhacking.net/utilities/608/

This program is also very usefull, it tells you if you have a header as well as all hashes (file IDs) to verify if you have the correct original rom to patch to.
http://www.romhacking.net/utilities/1002/

Most of this info (with the exception of perhaps the rom hasher) is applicable to SNES games; the game in question is MSX. Do MSX games even *have* headers?

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7037
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #5 on: January 06, 2015, 05:09:17 pm »
I don't think MSX games have headers, which could actually be the real problem: I've suspected MSX emulators have used a database to look up mappers for known cart games.
Perhaps the translation is not in the database (likely, isn't fMSX really old? Last I played MSX was with blueMSX.)
So, try the unpatched game, see if it tells you what mapper the game used, then choose that when loading the ROM.
(I recall blueMSX' recent ROMs list would thankfully remember the mappers for those as well)
"My watch says 30 chickens" Google, 2018

SunGodPortal

  • Hero Member
  • *****
  • Posts: 2919
  • 2 + 2 = 5
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #6 on: January 06, 2015, 06:22:28 pm »
I tried to look some of this stuff up the other night and I remember reading that some of the MSX Metal Gear ROMs floating around out there are from a bad dump. Maybe he got unlucky and happened to downloaded a version that was broken to begin with.
Cigarettes, ice-cream, figurines of the Virgin Mary...

henke37

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #7 on: January 07, 2015, 11:18:38 am »
Of course, it is possible that a hack changes the mapper.

Double

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #8 on: December 29, 2015, 06:14:08 pm »
Sorry for the necrothread, but something is not clear. Do headers apply to SNES roms only, or are other platforms/portables affected as well? My rom patching days are on hold until I know for certain what to deal with.

Also, can headers be added to or removed from ips patches, or does this only apply to roms? If both, which is recommended?

vortex

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #9 on: December 29, 2015, 06:35:48 pm »
Quote
Sorry for the necrothread, but something is not clear. Do headers apply to SNES roms only, or are other platforms/portables affected as well? My rom patching days are on hold until I know for certain what to deal with.

Also, can headers be added to or removed from ips patches, or does this only apply to roms? If both, which is recommended?
"Everything" has a header. Which of course doesn't mean the header in a sence of what you consider as a header for ROMs.

ROMs have headers because of the copiers. This is an additional data written at the beginning of the ROM, which is a leftover data, that the copier needed when scanning the cartridge into the file. "Such" headers are useless. These are called copier headers or external ROM headers.

Some other "types" of headers are however essential, like the header in a zip file, similar with IPS.

Simplified: IPS doesn't have the same type of header, which would be "compatible" to what we know as a ROM header, since every ROM has the "actual" or "inner" header.

No external ROM header is recomended, since they only cause trouble, when patching and when calculating pointers in hex. Also: IPS can not have an external header. But you can falsly make an IPS by comparing a headered original and unheadered hack. It is best to avoid external headers.

But since I come from the SMW community, external headers are popular, since the main editor rquires one. So if you are patching any SMW hacks, you definitely need this obsolete data, since after any SMW hack is complete, everyone tends to leave the header.

Quote
My rom patching days are on hold until I know for certain what to deal with.
Before you patch, make sure you check the "Rom/Iso info". You have the CRC of the file to patch to there. It has to match with the CRC of your original ROM. At "patching info" check if it says header or no header. This should clear things up.

Another problem however is, if authors included the header in the CRC calculation or not. (Or in other words: if only these annoing headers wouldn't exist).

SunGodPortal

  • Hero Member
  • *****
  • Posts: 2919
  • 2 + 2 = 5
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #10 on: December 29, 2015, 06:41:43 pm »
Quote
Also, can headers be added to or removed from ips patches, or does this only apply to roms? If both, which is recommended?

I doubt it. If a patch designed for a headered ROM is applied to one without a header all of the changes will be applied 200 bytes off. Every single change will be wrong.

Though it's really easy to add or remove a header (use a program like Tush or open it in a hex editor and either add 200 bytes to the beginning or take away 200 bytes) and it is also really easy to tell if a ROM has one or not (assuming it doesn't have an irregular size due to previous hacking, if the file size ends in an odd number it has a header).

Quote
Sorry for the necrothread, but something is not clear. Do headers apply to SNES roms only, or are other platforms/portables affected as
well?

I'm not sure what you mean, but emulators don't care about the header and will ignore it if it's there.
Cigarettes, ice-cream, figurines of the Virgin Mary...

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7037
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #11 on: December 29, 2015, 09:36:32 pm »
If we're talking about all systems, the only console I know of where headers are needed is the NES.
I've seen headers on PCE/TurboGrafx ROMs, and I've heard of headers on GB/GBC but never seen one.
SNES was the only one where it was common enough to be a major headache.
"My watch says 30 chickens" Google, 2018

Double

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #12 on: December 30, 2015, 04:44:09 pm »
"Everything" has a header. Which of course doesn't mean the header in a sence of what you consider as a header for ROMs.

Before you patch, make sure you check the "Rom/Iso info". You have the CRC of the file to patch to there. It has to match with the CRC of your original ROM. At "patching info" check if it says header or no header. This should clear things up.
Correct me if I'm wrong, but I imagine the patch as a type of overlay that "lays" itself over an original rom during the patching process. My understanding is that a patch designed for a headered rom, has similar header data included, so that a match can be made. Are you saying that the 'rom header' and 'patch header' are completely unrelated to each other?

Though it's really easy to add or remove a header (use a program like Tush or open it in a hex editor and either add 200 bytes to the beginning or take away 200 bytes) and it is also really easy to tell if a ROM has one or not (assuming it doesn't have an irregular size due to previous hacking, if the file size ends in an odd number it has a header).
Is it better to add/remove header with a utility, or find an original rom already with/without the header? I have no clue where you might find headered roms, I've only ran across (and prefer) the No-Intro roms which (by No-Intro standards) are supposed to be headerless.

I'm not sure what you mean, but emulators don't care about the header and will ignore it if it's there.
I was just wondering if NES/GB/GBC/GBA/GEN/etc roms could be altered by headers too, not just SNES roms. I've only seen header utilities for SNES and NES, so I figured headers were exclusive to Nintendo only.

If we're talking about all systems, the only console I know of where headers are needed is the NES.
I've seen headers on PCE/TurboGrafx ROMs, and I've heard of headers on GB/GBC but never seen one.
SNES was the only one where it was common enough to be a major headache.
Are you saying that NES patches only work on headered NES roms?

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7037
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #13 on: December 30, 2015, 04:59:30 pm »
Yes, NES patches will only work on headered ROMs because you will only find headered NES ROMs (because NES ROM headers contain information vital to emulating the games correctly, which emulators cannot guess from anything else in the ROM).
"My watch says 30 chickens" Google, 2018

FAST6191

  • Hero Member
  • *****
  • Posts: 2962
    • View Profile
Re: How to tell if a ROM is headered or unheadered?
« Reply #14 on: December 30, 2015, 05:20:51 pm »
To answer some of Double's questions, though probably not in a terribly useful way.

There are probably three types of headers
1) Those which were present in the original ROM/PCB/memory chips/CD/... Stuff like http://problemkaputt.de/gbatek.htm#gbacartridgeheader basically. This might be a problem with some homebrew as companies stuck trademarked or copyrighted logos in there and required them to be present and homebrew authors opted out (the sega vs accolade court case having something to say about that but paranoia is not a bad thing when the only ones winning are the lawyers). These should never be removed, though there may be reasons for altering them.

2) Those which ROM dumpers made up to help things work -- if I just dump 5 ROM storage chips the emulator/flash cart will have no idea about how it is all arranged, and that is before we get onto extra hardware and custom setups that the ROM might need. The easiest way, especially if you are building a system with things still coming out, is to stick a header on the start of the ROM (or on the end as a footer, or some specified place...) and get everybody to agree to use it. The NES is a popular example but a variation on the theme has been seen as recently as the xbox 360 where unwriteable sections of consumer discs were faked and stored in other parts of the iso which the hacked firmwares played back as though they were "real". For the chips thing then the ROM/hardware does not care -- the extra hardware is there on the chip and you certainly don't care about emulators (or what's that in 1989?) or flash cart pirates.

3) Those which ROM dumpers/specific flash carts cooked up because they were incompetent or wanted some kind of vendor lock in. Seen as late as the early days of the DS (see golden sun team/GST dumps and neoflash if you are really bored, just don't ask anybody sorting release databases during that time) but some stuff exists for the NES and SNES. You might occasionally meet one that is technically 2) but using a format that failed to catch on, or was dreamt up by some emulator author, flash cart company, dumping collective or general fans of a device after the patch was made. Related to this would be things like interleaved ROMs and ROMs that opt for a different approach to endianness but it is usually a simple enough operation to convert between things.

There are a few extra annoyances that could crop up -- intros, additional compression (seen a few times on the DS for instance where some groups would compress the binaries using a legit tool but still compressed), alternative dumps (the PS1 era was also the era of 900 competing iso formats and everybody had their favourite, occasionally grudgingly moving to another when the need arose) and general modification (seen many times on the original xbox) but let us not go there right now.

Yes the classic patch method, such as IPS, is basically an overlay. Some newer types will have verification will rescan for the right offsets (close to what a patch itself will do), some older types have some basic logic (repeat this patch at these locations sort of thing) but the idea will still be the same. If you have a bunch of data offset from where the patch would be then you are going to struggle. If a header is just some extra data at the start then you likely can add the equivalent amount of data, patch, remove the equivalent amount of data and carry on with life.

In general if the nfo/release notes for the hack say it wants a header then if you have a headered ROM then great, otherwise there will probably be a tool built by someone that deals with ROM images for your chosen system. http://www.romhacking.net/utilities/ has most of them, or at least the good ones. As I mentioned the GBA earlier then without checking to see if they are there then http://www.no-intro.org/tools.htm for fixing and basic manipulation and http://www.gameboy-advance.net/rom_tools/flash_advance_toolkit.htm for the more advanced stuff/homebrew.