Community

The PokéCommunity

We are still working on a better slogan!

Visit Index



Advertise here

Go Back   The PokéCommunity Forums > ROM Hacking > Tools, Tutorials & Resources
Notices

Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.
New threads in this forum are to be approved by a moderator before they are displayed.

Post Reply
 
Thread Tools
  #1    
Old September 5th, 2010, 10:22 AM
Sonic65's Avatar
Sonic65
welp
 
Join Date: Aug 2010
Location: Columbia, Maryland
Age: 20
Gender: Male
Nature: Quirky

Advertise here
Figured I should probably register and post this here too, since this thread here was a big help to me...even if this entire post is basically just a copypaste from the Pokecommunity one (well, will be as soon as it gets approved anyway)

Anyway, I've been researching R/B/Y ROM hacking for a short while now, and I found that there was little real documentation or tools on the music side of the game (well actually in general, compared to 2nd/3rd gen). So I made this program to import music into an R/B/Y ROM - more specifically, import .ftm songs made with the program Famitracker, a music tracker for the NES.


What does it support?
  • Importing of all 4 basic sound channels (square 1/2, triangle, noise)
  • Both .ASM and .BIN export
  • Quick ROM inject feature for .BINs
  • Famitracker note fade-outs (using the volume column) and duty cycle changes (by changing instruments)


What doesn't it support?
  • MIDI import or any other file format other than .ftm
  • Any Famitracker effects



Files in zip:
  • rbyImport.exe - The actual RBY Music Importer program.
  • blitz3d_gui_dll.dll - A DLL the program uses.
  • readme.txt - Derp. Doesn't have anything this post doesn't anyway.
  • route202.ftm - Sample FTM file to import (used in tutorial below). A NES/GB demake of the Route 202 theme for Pokemon Diamond/Pearl.
  • noiseChannelDoc.txt - Documentation on the music format Pokemon R/B/Y uses for noise channels (this didn't seem to be documented anywhere, so I investigated it myself - it's different from the regular music channels, and uses drum presets)
  • pkms.asm - Macros and equates for ASM files created with RBY Music Importer. (PKMS is what I call the Pokemon RBY music format, standing for Pokemon Music System)
  • rgbasm.exe - GB compiler, part of RGBDS suite
  • xlink.exe - GB linker, part of RGBDS suite


How to Use: A Tutorial

To illustrate how to use RBY Music Importer, we're going to import the sample song (route202.ftm) and replace Pallet Town's music with it. Here's a step-by-step guide (I suck at writing tutorials but hopefully you'll understand this):

  • Open up RBY Music Importer and go to the FTM->ASM section. Load route202.ftm using the Load FTM button.
  • Using the DataCrystal ROM map of Pokemon Red, you'll find that Pallet Town's music data starts at $A7C5, so put in $A7C5 as the start offset.
  • Check the "Import noise channel" box. You don't need to change the tempo for this particular song, but you might need to for other songs (more on that later).
  • Click the "Make ASM File" button. RBY Music Importer will generate an .asm file called route202.asm. At this point you have one of two options: either you can go and tweak the ASM file (changing notes, adding effects like vibrato and modulation, etc.), or just proceed straight to .BIN conversion. Let's go straight to .BIN conversion and injecting, for the purposes of this tutorial.
  • Go to the ASM->BIN section and load the route202.asm file we just created.
  • Click the "Inject music into ROM" checkbox.
  • Set $A7C5 (the same offset as above) as the injection offset. (If you changed the start offset in the ASM file, you'd put that value here instead.) Using the same ROM map as above, you'll find that Pallet Town's song pointers start at $822E, so input that for the pointer offset.
  • Click the "Compile BIN File" button.
  • Done! If you did everything right, when you load your RBY ROM, Pallet Town's music should be replaced with Route 202!


Special Notes

There doesn't appear to be any hard-set formula for converting Famitracker song tempo into PKMS song tempo, but here are a few tempo matchups which might be useful to you:

Code:
$E0 - speed 6, tempo 85
$D0 - speed 6, tempo 90
$C0 - speed 6, tempo 100
$B0 - speed 6, tempo 110
$A0 - speed 6, tempo 120
$90 - speed 6, tempo 140
$80 - speed 6, tempo 160
$70 - speed 6, tempo 180
$60 - speed 6, tempo 200
$50 - speed 6, tempo 220
$40 - speed 6, tempo 260
$30 - speed 6, tempo 340
Finally, I'd like to thank:
  • Coolboyman and Melash, for creating the document I linked
  • Data Crystal, for their Pokemon ROM map


So yeah, that's all. Hopefully this utility will be useful to somebody other than me.

Last edited by Sonic65; September 12th, 2010 at 09:46 AM.
  #2    
Old September 6th, 2010, 08:54 AM
~Teh Panda~'s Avatar
~Teh Panda~
Sea of Dreams - Redux
 
Join Date: Aug 2007
Well this looks certainly interesting, but do you think you could post how this would be more beneficial then using Sappy, or if it's different as a whole. Because I haven't tried it and don't see reason to until I know exactly what it can do better than what we have.

Thanks

EDIT: Wow, this is for Red, Blue, Yellow. I am stupid... XD...

Well this should be nice for GB/GBC era hackers...




Mystic still in work to let you know...
  #3    
Old September 6th, 2010, 08:59 AM
Team Fail's Avatar
Team Fail
The fine line between in|sanity
Community Supporter
 
Join Date: May 2009
Age: 19
Gender: Male
Nature: Brave
OMG. ILY. :3 This is something I so want! This is a must try for me! I also love Famitracker! Now, to find FTM Files on the internet! WOOOOSH!
EDIT: Can you get this to work with .nsf files as well?

Pairs:
Kevin, Echidna
Follow me on Twitter! @TeamFail
Alt 1, リザードン
Miiverse
Pokémon Hackers Online
Alt 2: Jack Cayman



[04:20.39] <@GoGo> I WILL INSERT WITH PLEASURE
[04:20.45] <@GoGo> shut it Bela

[05:41.55] <Team_Fail> Blue Spider is interesting, but #MEHMasterRace
[05:42.20] <diegoisawesome> Team_Fail: Sounds like a bunch of unmotivated people that still want to try to take over the world

Last edited by Team Fail; September 6th, 2010 at 09:33 AM.
  #4    
Old September 6th, 2010, 09:42 AM
Sonic65's Avatar
Sonic65
welp
 
Join Date: Aug 2010
Location: Columbia, Maryland
Age: 20
Gender: Male
Nature: Quirky
Quote:
Originally Posted by Team Fail View Post
EDIT: Can you get this to work with .nsf files as well?
An NSF file is literally just a modified NES ROM, with only music code and data - since the format of music data and how it's played differs from game to game, there's no standard format and it can't really be done (although VirtuaNSF has a keyboard player thing for NSFs, I might look and see how that's done). You'll have to do with manually recreating songs in Famitracker (or composing new original ones).

I might be able to put in MIDI support later down the line, but that's just a pipe dream for now.
  #5    
Old September 6th, 2010, 09:55 AM
Team Fail's Avatar
Team Fail
The fine line between in|sanity
Community Supporter
 
Join Date: May 2009
Age: 19
Gender: Male
Nature: Brave
Quote:
Originally Posted by Sonic65 View Post
An NSF file is literally just a modified NES ROM, with only music code and data - since the format of music data and how it's played differs from game to game, there's no standard format and it can't really be done (although VirtuaNSF has a keyboard player thing for NSFs, I might look and see how that's done). You'll have to do with manually recreating songs in Famitracker (or composing new original ones).

I might be able to put in MIDI support later down the line, but that's just a pipe dream for now.
Ok, I'm good with that. I'll have to look further then. Hmmm...
Edit: FT has a MIDI importer, but it is poor quality. Unless the tempo can go beyond 255 (FF) bytes, then songs I want cannot be done.

Pairs:
Kevin, Echidna
Follow me on Twitter! @TeamFail
Alt 1, リザードン
Miiverse
Pokémon Hackers Online
Alt 2: Jack Cayman



[04:20.39] <@GoGo> I WILL INSERT WITH PLEASURE
[04:20.45] <@GoGo> shut it Bela

[05:41.55] <Team_Fail> Blue Spider is interesting, but #MEHMasterRace
[05:42.20] <diegoisawesome> Team_Fail: Sounds like a bunch of unmotivated people that still want to try to take over the world

Last edited by Team Fail; September 6th, 2010 at 01:27 PM.
  #6    
Old September 9th, 2010, 02:37 PM
Chaos Rush's Avatar
Chaos Rush
im sexy and i know it
 
Join Date: May 2007
Location: Taylor Swift
Gender: Male
Nature: Adamant
Would this work for Pokémon Gold? Also, how would I port R/B/Y music over to Gold?
  #7    
Old September 12th, 2010, 09:49 AM
Sonic65's Avatar
Sonic65
welp
 
Join Date: Aug 2010
Location: Columbia, Maryland
Age: 20
Gender: Male
Nature: Quirky
Updated OP with new bugfixed version, which should hopefully fix some of the bugs people are having. (Thanks to Team Fail for his help with this, even though we could never get it completely working on his computer )

Quote:
Would this work for Pokémon Gold? Also, how would I port R/B/Y music over to Gold?
If you changed the equates/macros in the pkms.asm file it could probably work, at least with the first three channels (noise channel values are hardcoded as of now, so you'd need to change those manually in the .asm file that RBY Music Importer outputs before compiling the .bin). This document is a pretty good resource for the G/S/C and R/B/Y music format (though I had to find the RBY coordination flags myself, but those are already documented in pkms.asm).

As for porting music from R/B/Y, that's not something this tool allows you to do (unless you resequence the entire thing in Famitracker, LOL) - you'd have to do that manually in a hex editor (changing pointers and all).
  #8    
Old September 22nd, 2010, 05:53 AM
Heart's Soul's Avatar
Heart's Soul
Hey, look, I was gone.
 
Join Date: Nov 2007
Age: 19
Gender: Male
Interesting, considering most of the Red ROM map was made by Coolboyman.
"No calendar today. Oh, that's a shame. What day is it today? It is no day. The calendar does not exist anymore. Today does not exist." - Professional Idiot
  #9    
Old January 1st, 2011, 10:35 AM
Chaos Rush's Avatar
Chaos Rush
im sexy and i know it
 
Join Date: May 2007
Location: Taylor Swift
Gender: Male
Nature: Adamant
I'm having trouble getting this to work with G/S/C. This is what I've changed the pkms file to:

Code:
    ; ===========================================================================
    ; PKMS equates and macros
    ;
    ; ===========================================================================

    ; equs
    MUSIC            EQU 0
    SFX            EQU 4
    CH1            EQU 0
    CH2            EQU 1
    CH3            EQU 2
    CH4            EQU 3

    ; notes
    ntC            EQU $00
    ntC#          EQU $10
    ntD            EQU $20
    ntD#          EQU $30
    ntE            EQU $40
    ntF            EQU $50
    ntF#          EQU $60
    ntG            EQU $70
    ntG#          EQU $80
    ntA            EQU $90
    ntA#          EQU $A0
    ntB            EQU $C0
    ntRst          EQU $B0

    ; special drum EQUs
    dNote          EQU $C0
    dRst            EQU $B0
    dNormSpd     EQU $DC
    d4d3Spd       EQU $D8
    d5d3Spd       EQU $D4
    d2Spd          EQU $D0

    ; octaves
    oct0            EQU $D7
    oct1            EQU $D6
    oct2            EQU $D5
    oct3            EQU $D4
    oct4            EQU $D3
    oct5            EQU $D2
    oct6            EQU $D1
    oct7            EQU $D0

               
    ; header stuff
    pkmsHeader:    MACRO
                db    ((\1 - 1) * $40) | (\2 + \3)
            ENDM
                   
    pkmsChannel:    MACRO
                    dw    \1
                       
                    IF \2 != 0
                        db    \2
                    ENDC
                ENDM

    ; coordination flags

    ; set velocity/note fade (\1 is velocity, \2 is note length, both 0-15)
    ; format:    pkmsSetVel        vel, length
    pkmsSetVel:        MACRO
                    db    $DC
                    db    ((\1 << 4) | \2)
                ENDM
    ; stop sound
    ; format:    pkmsEndSound
    pkmsEndSound:    MACRO
                    db     $FF
                ENDM
               
    ; $E8 (unknown)
    ; format:    pkmsE8
    pkmsE8:        MACRO
                    db    $E8

                ENDM
               
    ; set modulation (\1 is delay, \2 is depth, \3 is rate)
    ; format:    pkmsModSet        delay, depth, rate
    pkmsModSet:        MACRO
                    db    $E1
                    db    \1
                    db    ((\2 << 4) | \3)
                ENDM

    ; set duty cycle (\1: 0 = 12.5%, 1 = 25%, 2 = 50%, 3 = 75%)
    ; format:    pkmsSetDuty        duty
    pkmsSetDuty:    MACRO
                    db    $DB
                    db    \1
                ENDM
               
    ; set music tempo (\1 is divider, \2 is modifier)
    ; format:    pkmsSetTempo    divider, modifier
    pkmsSetTempo:    MACRO
                    db    $DA
                    db    \1
                    db    \2
                ENDM
               
    ; set volume (\1 is volume)
    ; format: pkmsSetVolume        volume
    ; (may actually be panning?)
    pkmsSetVolume:    MACRO
                    db    $F0
                    db    \1
                ENDM

    ; call offset \1
    ; format:    pkmsCall    offset
    pkmsCall:        MACRO
                    db    $FE
                    dw    ((\1 % $4000) + ((\1 >= $4000) * $4000))
                ENDM
                           
    ; jump to offset \1
    ; format:    pkmsJump    offset
    pkmsJump:        MACRO
                    db    $FD
                    db    $00
                    dw    ((\1 % $4000) + ((\1 >= $4000) * $4000))
                ENDM
All I've managed to do so far is to replace New Bark Town music with silence. I looked at the Gold Music Hacking Resource document, and changed the bytes accordingly, but all I get is blank music.
  #10    
Old July 13th, 2011, 09:06 AM
WrathOfArceus's Avatar
WrathOfArceus
Arceus Tamer
 
Join Date: Jun 2011
Gender: Male
I did it write,But when i click compile BIN File to insert it, it says memory access violation,And Pallet town's music is still playing.Help!!!!
  #11    
Old July 15th, 2011, 10:38 AM
Cheesewig's Avatar
Cheesewig
Hi!
 
Join Date: Jul 2011
Gender: Male
Nature: Relaxed
Every time I insert an FTM the game freezes when I go to the location.
  #12    
Old March 1st, 2013, 09:16 AM
gatarda
Half-PokéGod
 
Join Date: Oct 2012
Location: Netherlands
Age: 16
Gender: Male
Nature: Gentle
Send a message via Yahoo to gatarda
Too bad, this program has no Apreggio and ''4XX'' support.
PS: The ''4XX'' effect is a feature which is used in Game Boy games like Tetris, Name Entry.
I hope you will make a new version with support for that.
The ones who still ask what they know, just go walk long on a short pier!

Last edited by gatarda; March 1st, 2013 at 09:16 AM. Reason: ENTER
  #13    
Old April 12th, 2013, 08:52 AM
gatarda
Half-PokéGod
 
Join Date: Oct 2012
Location: Netherlands
Age: 16
Gender: Male
Nature: Gentle
Send a message via Yahoo to gatarda
That "4XX"-effect is called LFO.
The ones who still ask what they know, just go walk long on a short pier!
  #14    
Old October 20th, 2013, 12:01 AM
Airikita's Avatar
Airikita
 
Join Date: Oct 2013
Gender: Female
I can't download your tool, I get a message on that site that prevents me from downloading....

The Vocaloids battling with Pokemon? What could go wrong?
http://www.youtube.com/watch?v=xI8YOOHlEXQ
Po pi po! (Pokemon Gold music import)
Check out my channel for more!
Post Reply
Quick Reply

Sponsored Links


Advertise here
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 08:27 AM.

About Us
© 2002 - 2014 The PokéCommunity™, pokecommunity.com. Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.

Copyright
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com. PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator. Header artwork by Jordanice of deviantART.

Social Media
If you would like to stay up-to-date with us on the go, when we're down, or other such things, follow us on social media sites--most notibly Twitter, Facebook, and Google Plus--by clicking on the links provided.

Design presented by Peitharchia. Special thanks to Hiroshi Sotomura and Ausaudriel.