It is currently Sun Nov 19, 2017 2:39 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Sat Oct 01, 2016 2:29 am 
Offline
User avatar

Joined: Sat Oct 01, 2016 2:20 am
Posts: 40
Location: Australia, the land of British 50hz and obscure sports games.
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.


Top
 Profile  
 
PostPosted: Sat Oct 01, 2016 6:08 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19229
Location: NE Indiana, USA (NTSC)
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?


Top
 Profile  
 
PostPosted: Sat Oct 01, 2016 2:50 pm 
Offline
User avatar

Joined: Sat Oct 01, 2016 2:20 am
Posts: 40
Location: Australia, the land of British 50hz and obscure sports games.
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.


Top
 Profile  
 
PostPosted: Sun Oct 02, 2016 4:13 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
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).


Top
 Profile  
 
PostPosted: Sun Oct 02, 2016 4:45 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19229
Location: NE Indiana, USA (NTSC)
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.


Top
 Profile  
 
PostPosted: Sun Oct 02, 2016 4:56 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
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.


Top
 Profile  
 
PostPosted: Mon Oct 03, 2016 1:18 am 
Offline
User avatar

Joined: Sat Oct 01, 2016 2:20 am
Posts: 40
Location: Australia, the land of British 50hz and obscure sports games.
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?


Top
 Profile  
 
PostPosted: Mon Oct 03, 2016 9:16 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
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.


Top
 Profile  
 
PostPosted: Mon Oct 03, 2016 9:52 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
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.


Top
 Profile  
 
PostPosted: Mon Oct 03, 2016 5:38 pm 
Offline
User avatar

Joined: Sat Oct 01, 2016 2:20 am
Posts: 40
Location: Australia, the land of British 50hz and obscure sports games.
I am running the rom on a PAL-A system with an everdrive n8, not powerpak


Top
 Profile  
 
PostPosted: Mon Oct 03, 2016 9:21 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
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.


Top
 Profile  
 
 Post subject: Re: rainwarrior
PostPosted: Tue Oct 04, 2016 1:01 am 
Offline
User avatar

Joined: Sat Oct 01, 2016 2:20 am
Posts: 40
Location: Australia, the land of British 50hz and obscure sports games.
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group