Hi, i'm new to the world of Famitracker and Hex editing. I've done lots of research with no answer to my question. How do you convert a NTSC only game's music file (TMNT 3 was never released in europe) to increase the pitch and tempo of the music so that it runs properly on a PAL console? What hex value(s) to you have to edit for that game specifically? I'd like to hear from someone with the knowledge of the game's music engine.
The level of detail of an explanation that you would find most useful depends on your level of familiarity with 6502 assembly language. How familiar are you with it?
I have little knowledge of 6502. i know it has something to do with tracking hex data when performing a certain action in the rom or something, but i can't figure the layout of it.
Adjusting the tempo: Relatively easy. Just add a counter that runs the play routine twice on every fifth frame (converts 60 to 50 fps).
Adjusting the pitch: usually this involves finding a table of note frequencies somewhere in the ROM and replacing it. The table might be 12 entries long (one octave, which is shifted to get values for other octaves) or it might be more like 60 or 100 entries long, depending on the engine. It also might be a table of 16-bit values, or two tables of 8-bit values (the high and low separately).
It's not normally important to adjust pitch unless the game uses tuned DPCM sounds (e.g. playing chords or bassline on DPCM samples). Everything else maintains proper relative pitch with everything else, so despite sounding lower all of the musical relationships will be intact. So: high probability you don't need to adjust pitch (only a handful of games use tuned samples).
rainwarrior wrote:
It's not normally important to adjust pitch unless the game uses tuned DPCM sounds (e.g. playing chords or bassline on DPCM samples). Everything else maintains proper relative pitch with everything else, so despite sounding lower all of the musical relationships will be intact. So: high probability you don't need to adjust pitch (only a handful of games use tuned samples).
In particular, I don't think
Probotector/
Contra uses tuned DPCM, but
Super C does. So do
Bee 52 and later Sunsoft games. For anything that doesn't, you can just add one semitone to the pitch value from the music engine to get approximately correct pitch.
tepples wrote:
you can just add one semitone to the pitch value from the music engine to get approximately correct pitch.
Well that's an interesting approach, but I'm not sure where this approximation would be a desirable solution over replacing the pitch table?
If you can find the spot in the engine that fetches a note number, the pitch table value will usually be the very next thing that is fetched, i.e. if you've found one, you should be able to find the other with very little additional effort.
Replacing the pitch table will give you more accurate control of the pitch retuning,
and won't require finding a place to insert new code.
I am so thankful for all the replies sent my way, i think i am pointed in the right direction but i have some more questions. Rainwarrior you said that you could set a counter within the rom itself to fix the tempo but as i said before i have little knowledge of 6502. Can you explain how to set up such a thing?
If it's an
NSF:
1. Find an empty location in RAM for your counter. Often stuff at the end of RAM is open, like $7FF. (Put a read/write breakpoint on it in FCEUX and see if/when it gets hit.)
2. Find where PLAY points to in the ROM. (In FCEUX you can simply type PLAY into the breakpoint field and it auto-complete it to set a breakpoint for you.)
3. Find empty space somewhere near PLAY where you can put your counter code. The code might look like this:
Code:
inc counter ; counter = $7FF ?
lda counter
cmp #5
bcc :+ ; if counter >= 5 call PLAY an extra time and reset counter
jsr play ; play = address of PLAY routine
lda #0
sta counter
:
jmp play
You can insert assembly code directly into the ROM in FCEUX by left-clicking on the vertical strip to the left of the disassembly pane in the debugger.
4. Finally, edit the NSF header to replace the PLAY address with this routine you just created.
Though, there may be a simpler solution. You said "runs properly on a PAL console". How are you running a modified ROM on the console?
If you have a PowerPak, an NSF will play at the speed specified by its header, independently of the system's video rate. The pitch will be lower on PAL than NTSC but the playback rate is driven by a separate timer that will keep it at the original rate.
So, you might just be able to play the NSF on a PowerPak and have it already run at 60 Hz, if that's what the NSF has specified in its header. (If it doesn't, see the
NSF file format and replace the 2 byte PAL speed in the NSF with 60 Hz.)
Doing that is probably much easier than trying to modify the ROM, if you have a PowerPak already, anyway.
I am running the rom on a PAL-A system with an everdrive n8, not powerpak
Hmm, well unless the Everdrive N8 gets updated with an NSF player I guess you'll have to hack the ROM.
Looking at the NSF version might help you find the music code in the game ROM though, it will normally be at the same address as PLAY (or called quickly by a small stub PLAY routine), so it could give you a good idea where to start looking. Once you find the music code, sort of the same steps as before, but it might be a little trickier than trying to hack just an NSF.
Thank you for your full explanation, i am starting work on it right away. This hack won't just fix the music for PAL, i also wish to fix some visual bugs occuring in the game due to resolution problems.