What's new

Do any guides exist for altering ROMs or Bin Files?

timsithD

Student
Joined
Jan 18, 2019
Messages
68
Reaction score
38
Location
Glen Allen, VA
Do any guides exist for altering ROMs or Bin Files? I wouldn't call it a hack per se but I really like all the music in the initial D arcade stage games. However each one only has a small selection of the music from the series. Years ago I modded my PS2 to play special stage which had all the music (Or most of it) from the series. So is it possible to alter the code of the rom to install additional tracks? Ideally what I would like to do is add the music from IDSS to IDAS Ver3 and then upload the altered bin file to Gakman's repository after testing. Does any one know if this has been done? (Not that I can tell in my searches) and if not could someone point me in the right direction on how to do this?) I work in Python all the time I just have never fooled with attempting to alter the code in a rom.
 
Hmm... I guess that is a no. I guess what I am thinking is the game already has a listing of songs it can play and knows which track to play based on what item is selected. You would think it would be somewhat easier to alter that code and add to it.

https://segaretro.org/ROM_hacking


Music hacking
Music hacks are relatively rare, due to the wide variety of ways games store music data (hence the difficulty in locating and modifying this data) and the difficulties in composing new music (or porting music from another game).
 
Hmm... I guess that is a no.
Well it's only been about two hours...

Initial D is /way/ down the road in complexity. There's a guide on KLOV about romhacking, starting with things like high score editing/saving, and some other stuff for 80s games. IIRC a few users really got into it and expanded it a good bit. If I find it I'll edit this, if not it's worth looking into as it should teach some basics.
 
There's a site dedicated to extracting music from games: https://vgmrips.net

I don't think they have anything related to initial D.

What you need to do is figure out if you can isolate the music tracks in the sound data for both games, then if you're lucky and the use the same format and are the same size you could swap them.

maybe @MetalliC has some insight into this?
 
many Naomi games have game data in common ISO9660 file system.
in the case of InitialD v1-3:
- grab decrypted game binary
- open it in HEX editor and cut first 8Mbytes (0x800000)
- save remaining data as something.iso
- open it in whatever ISO tool (UltraISO, ISOBuster) or mount in virtual drive.
music files located in \sound\stream\ folder

how to play them ?
- install Foobar2000 player https://www.foobar2000.org/
- install vgmstream plugin https://www.foobar2000.org/components/view/foo_input_vgmstream
- rename/copy all music files from .bin to .spsd
- add files in player list

how to replace music files ? - no idea, I know none software wich may encode WAV to SPSD container/format.
at least container format is more-less documented, https://github.com/losnoco/vgmstream/blob/master/src/meta/naomi_spsd.c
and seems to be just a wrapped Yamaha ADPCM, so its possible to write an a tool to convert ADPCM to SPSD
 
Wow! Now that is the type of advice I am talking about! Thanks a ton. To be clear I don't want to really take music files out per se. I want to encode and add additional tracks. So I would need to add the encoded files to the iso file and add code to the menus to call the additional tracks. I think there is enough space left over to not exceed 256 mb total size. I think your point about the encoding will be somewhat complicated as well. Worst case to by pass that step so to speak is I could extract the sound files from the other version of the game (Which are already in the correct format) and add them to the ISO. Again though that still brings up altering the code to include them in the song selection menu before the race and or if it would cause any bugs due to the code selecting a default track at the start. Either way it should be a pretty fun learning experience. I guess this would be like an initial d ver 3.1 so to speak hahaha or perhaps Initial D Ver 3 Best Music Stage hahaha.
many Naomi games have game data in common ISO9660 file system.
in the case of InitialD v1-3:
- grab decrypted game binary
- open it in HEX editor and cut first 8Mbytes (0x800000)
- save remaining data as something.iso
- open it in whatever ISO tool (UltraISO, ISOBuster) or mount in virtual drive.
music files located in \sound\stream\ folder

how to play them ?
- install Foobar2000 player https://www.foobar2000.org/
- install vgmstream plugin https://www.foobar2000.org/components/view/foo_input_vgmstream
- rename/copy all music files from .bin to .spsd
- add files in player list

how to replace music files ? - no idea, I know none software wich may encode WAV to SPSD container/format.
at least container format is more-less documented, https://github.com/losnoco/vgmstream/blob/master/src/meta/naomi_spsd.c
and seems to be just a wrapped Yamaha ADPCM, so its possible to write an a tool to convert ADPCM to SPSD
 
Does anyone know if the Naomi Games do any sort of CRC check? I wonder if my assertion above is too simple. IE I don't know if the code looks at total byte size or anything.
 
I think your point about the encoding will be somewhat complicated as well.
there is 2 steps:
encode PCM/WAV to Yamaha ADPCM, which is quite straightforward - Katana (Dreamcast) SDK is public and have wavecon.exe tool which can do this.
wrap ADPCM file into SPSD container format, and I don't know if there such tools public available


Worst case to by pass that step so to speak is I could extract the sound files from the other version of the game (Which are already in the correct format) and add them to the ISO.
this will be simpler, however to add new tracks (not replace existing ones) you'll be needed some skills to edit game executable data and probably code too.
 
To do that are talking like decompiling the exe altering the code and the recompiling if so my guess is that is going to be interesting/ really complicated. Got any advice for that? Not sure if you know of any programs I can alter that code with.
I think your point about the encoding will be somewhat complicated as well.
there is 2 steps:encode PCM/WAV to Yamaha ADPCM, which is quite straightforward - Katana (Dreamcast) SDK is public and have wavecon.exe tool which can do this.
wrap ADPCM file into SPSD container format, and I don't know if there such tools public available


Worst case to by pass that step so to speak is I could extract the sound files from the other version of the game (Which are already in the correct format) and add them to the ISO.
this will be simpler, however to add new tracks (not replace existing ones) you'll be needed some skills to edit game executable data and probably code too.
 
right, start from simpler things first.


Got any advice for that? Not sure if you know of any programs I can alter that code with.
as was said - you'll need skills, 99% of such tasks is made using human brain, software tools like IDA Pro and HEX editor just makes remaining 1% of work more comfortable.
 
Fair enough, am I missing something with the hex editor I am cutting the value you mentioned and then saving as a iso but it keeps throwing errors when I attempt to mount the file. Am I missing something?
 

Attachments

  • selection.PNG
    selection.PNG
    89 KB · Views: 103
  • mounttry.PNG
    mounttry.PNG
    91 KB · Views: 106
SUCCESS! I was able to get Station to Station to play where Speedy Speedy Boy would normally play by renaming the file and putting it back into the ISO and then adding the first 8. No issues from what I can tell. So at this point we at least have a proof of concept. At a minimum I could remove the songs I dislike and replace them with the sound files from songs I do like from the other two version of the game. I'd still like to figure out how to add additional tracks. Looks like some of the file strings are called out when I am looking in the hex editor. I wonder if I can add an entry here and then see if it shows up in the menu. My guess is hell no but who knows. See the picture attached to get what I am talking about. Either way this is definitely a step in the right direction a big thanks for all the help.

Also ty for the part on how to play the files hahaha I assumed they would be nicely named. They um were not hahaha DT02 or something of the like was the name of the file I wanted.
 

Attachments

  • perhaps.PNG
    perhaps.PNG
    55.2 KB · Views: 110
I worked on this some over the weekend. I created a version with the songs listed below but it was only by changing out the files and such if anyone wants this version please let me know and I will upload it to Gakman repository.

Regarding adding or altering the code to display the correct song names, I was able to find where the code looks for the music files and where the folder structure is called in order to know where the music lives. The problem is each of the entities for each file seem to be preceded by some value. From what I can tell this value corresponds to a value in a table which then links to the songs name and artist along with a songID. The problem with adding any entries to these tables is they are compressed in some weird ass format. Something like table.nz so that part is the biggest road block as I have no wsy to uncompress them for editing. I feel like if I could get into those tables I could easily add music. If anyone has any ideas on how to crack one of those bad boys open I am all ears :)


Track Song
1 Speedy Speed Boy
2 Space Boy
3 Station to Station
4 Over the Rainbow
5 Stop your self Control
6 Rock Me To The Top
7 Grand Prix
8 Running in the 90's
9 Heartbeat
10 Nights on Fire!
 
Back
Top