View Single Post
  #1    
Old September 14th, 2009 (6:55 PM). Edited April 15th, 2010 by Logan.
Melash's Avatar
Melash Melash is offline
Back for now.
     
    Join Date: May 2008
    Location: Idaho
    Age: 24
    Gender: Male
    Nature: Relaxed
    Posts: 427
    MUSIC HACKING RESOURCE DOCUMENT


    ==============
    Introduction
    ==============

    Before we start out, let me make something clear. This is not a step by step tutorial on how to hack the music in GB/GBC games, but more a resource you can use in hacking. It’s a little unorganized, but it should help some people out. Sorry it's a bit long and bleak, I tried to make it a little interesting.

    ==============
    Purpose for writing
    ==============

    This document will list the offsets of all music headers in all games, explain the format of the music headers, and the basic format of the music data

    ==============
    Getting Started
    ==============

    Programs needed:

    A Hex Editor (Use Google)
    Sound Edit v1.3 (http://crystalfallows.110mb.com/AutoIndex/index.php?dir=tools/GSC/&file=soundedit.zip)

    Skills needed:

    Basic usage of a hex editor
    Elementary knowledge of pointers

    ==============
    GSC Music
    ==============

    First off, I’ll explain a little about how the music works in GBC. There are up to four channels for every music track; Two are the lead tremble part, one is the bass, and the last is the drums. For every music track, there is a music header. The music header points to where the actual music data is located, the notes and such. Here is a full list of where the music headers are located in GSC, sorted by offset:

    Spoiler:

    E9492 - S.S. Aqua
    EA267 - Ice Path
    EAD42 - Trainer- Basic Tune
    EB27C - New Bark Town
    EB3FC - Goldenrod City
    EB61F - Vermilion City
    EBD92 - Unown Ruins
    EBDCB - Whirl Islands
    EBDD5 - Meet trainer - Freaky Tune
    EE35E - Meet Trainer - Japanese Tune 2
    EE45F - Special Fanfare?
    EE569 - Whirl Islands
    EE6C5 - Routes 42-44
    EE852 - Indigo Plateau
    EE94B - Routes 38-39
    EEB75 - Rocket's Hideout
    EECE8 - Dragon's Den
    EEDCB - Unown Radio Station
    EEE3E - Trainer Rocket Tune
    EEFB2 - Routes 26-27
    EF5B1 - Weird
    EF9BC - Dance Theatre
    EFB3E - Bug Contest Results
    0F0386 - Routes 34-37
    0F07FD - Printer Error
    F4602 - Killed a Wild Pokemon
    F605C - Wild Pokemon (Johto)
    F66C3 - Trainer Girl Tune
    F6811 - Tin Tower
    F6974 - Sprout Tower
    F6A99 - Burned Tower
    F6BF2 - Meet Mom
    F6C72 - Victory Road
    F6D79 - Pokemon Lullaby
    F6E23 - Pokemon March
    F7055 - Intro - Part 1
    F7308 - Intro - Part 2
    F766D - Rockets Take Radio Tower
    F78FD - New Game/Continue
    F7B13 - Pokeflute
    F7C16 - Bug Contest


    Now you know where the headers are located, it’s time to learn the format of the music headers. Here is the format of all music formats:

    vv ww ww 01 xx xx 02 yy yy 03 zz zz

    vv: Byte at beginning of header, not exactly sure what it means
    ww ww: 2-byte pointer to first channel
    xx xx: 2-byte pointer to second channel
    yy yy: 2-byte pointer to third channel
    zz zz: 2-byte pointer to fourth channel

    If a music track doesn’t have a fourth channel, it simply won’t have the pointer to it. Okay, so we now know where all the music headers are located, and their format. Now it’s time to learn the format of the actual music data. Here’s the note structure for Gold and Silver, I’m assuming it’s the same for Crystal:

    Spoiler:

    Notes (x = note delay)
    0x - No Note
    1x - C
    2x - C#
    3x - D
    4x - D#
    5x - E
    6x - F
    7x - F#
    8x - G
    9x - G#
    Ax - A
    Bx - A#
    Cx - B (H)
    D0 - Octave 7
    D1 - Octave 6
    D2 - Octave 5
    D3 - Octave 4
    D4 - Octave 3
    D5 - Octave 2
    D6 - Octave 1
    D7 - Octave 0
    D8 xx yz - xx Frames per note delay unit, Velocity y, Note Length z
    DA hh ll - Set Tempo (yes, hh ll, not ll hh, the lower the value the faster)
    DB xx - Duty Cycle (00-03), might also be instrument selection for Ch3
    DC yz - Velocity y, Note Length z (basicalyl same as D8 without the xx)
    E1 xx yz - Vibrato - Delay xx, Depth y, Rate z
    E3 xx - Noise Setting (instrument?)
    E6 xx xx - Tune (not sure what the arguments for this are..)
    EF xx - Panning (unsure of the arguments..)
    FD 00 ll hh - Jump (this is used to set the loop point for the song, ll = low byte, hh = high byte)
    FE ll hh - Subroutine (ll = low byte, hh = high byte, the return address is the location directly after this command)
    FF - End / Return from Subroutine


    You can use Sound Edit v1.3 to add in basic notes, but you actually have to go in and manually add in the loop points and other small stuff. Very annoying, but it’s the only way to do it.

    ==============
    RBY Music
    ==============

    Since we’ve already learned the basics of music headers, I won’t have to reexplain everything again, I can just give you the offsets. Here are all the locations of music headers in RBY:

    Spoiler:

    822E-8236 Pallet Town
    8237-823F Pokecenter
    8240-8248 Gym
    8249-8254 Viridian / Pewter / Saffron
    8255-825D Cerulean / Fuchsia
    825E-8266 Celedon
    8267-826F Cinnibar
    8270-827B Vermilion
    827C-8287 Lavender
    8288-8290 S.S. Anne
    8291-8299 Meet Prof. Oak
    829A-82A2 Meet Rival
    82A3-82AE Guy Walks you to Museum
    82AF-82B7 Safari Zone
    82B8-82C0 Pokemon get healed
    82C1-82CC Routes 1 / 2
    82CD-82D8 Routes 24 / 25
    82D9-82E4 Routes 3 / 4 / 5 / 6 / 7 / 8 / 9 / 10 / 16 / 17 / 18 / 19 / 20 / 21 / 22
    82E5-82F0 Routes 11 / 12 / 13 / 14 / 15
    82F1-82FD Route 23 / Indigo Plateau
    7C249-7C254 Title Screen
    7C255-7C25D Credits
    7C25E-7C266 Hall of FAme Registration
    7C267-7C26F PRof Oak's LAb
    7C270-7C275 Jigglypuff's Song
    7C276-7C281 Bike Riding
    7C282-7C28A Surfing
    7C28B-7C293 Casino
    7C294-7C29F Introduction Battle
    7C2A0-7C2AB Power Plant / Unknown Dungeon
    7C2AC-7C2B7 Viridian Forest / Seafoam Islands
    7C2B8-7C2C3 Mt. Moon / Rock Tunnel / Victory Road
    7C2C4-7C2CF Cinnibar Mansion
    7C2D0-7C2D8 Pokemon Tower
    7C2D9-7C2E1 Silph Co
    7C2E2-7C2EA Meet Bad Trainer
    7C2EB-7C2F3 Meet Girl Trainer
    7C2F4-7C2FC Meet Angry Trainer


    The music headers have the same format as GSC. It seems Game Freak doesn’t like to change the coding in their games that much. Unfortunately the basic note structure is a little different. Here’s the basic note structure for Red and Blue, once again I’m not sure if Yellow is exactly the same:

    Spoiler:

    Notes (x = note delay)
    0x - B
    1x - C
    2x - C#
    3x - D
    4x - D#
    5x - E
    6x - F
    7x - F#
    8x - G
    9x - G#
    Ax - A
    Bx - A#
    Cx - No Note

    Note Delay:
    x0: 1/16
    x1: 1/8
    x2: 1/8.
    x3: 1/4
    x4:
    x5: 1/4.
    x6:
    x7: 1/2
    xB: 1/2.
    xF: 1

    E0 - Octave 7E1 - Octave 6
    E2 - Octave 5
    E3 - Octave 4
    E4 - Octave 3
    E5 - Octave 2
    E6 - Octave 1
    E7 - Octave 0

    It’s almost the same as GSC. The octave data has changed along with several other bytes. So, you can’t import songs from RBY to GSC by using a “copy and pasting” method, but you can manually redo it without too much stress. Unfortunately I only have the basic structure, and not the other data, such as loops points and other information.

    ==============
    Credits
    ==============

    All right, that’s all the music data I’ve found. If you have any questions, or would like me to add in more information, please ask, and I’ll gladly do so. Credits go to:
    Coolboyman - Giving me most of the music data format I have here
    Data Crystal - Contained a Gold and Red ROM map where I got my offsets
    If I forgot you, please tell me.
    Fin.
    Reply With Quote