don't click here

Thunder Force II Music Hacking Tutorial In Progress

Discussion in 'Technical Discussion' started by Dracula, Feb 28, 2016.

  1. Dracula


    I'm watching you!
    Converting NES Mappers to MMC5
    Thunder Force II Music Hacking Tutorial

    I started this since yesterday while I was learning how to hack NES music and somehow, I learned how to do it in Sega Genesis games as well. Thanks with a little help from Exodus and BizHawk, I was able to test something out in Hex while the game is running. I believe that it's possible to hack music in Thunder Force 2,3 & 4.

    The only thing to complete this is the main header and the Effect List: I might not understand how music works but some of you might understand it.

    Main Header?

    00: ?
    01: Music Volume
    02: Main tempo modifier
    03: Main pitch modifier
    04: ?
    05: ? same as 04?
    06: ?
    07: ?
    08: ?
    09: ?
    0A: ?
    0B: ?
    0C: ?
    0D: ?
    0E: ?
    0F: ?
    Volume Controll for each channel:

    10: Volume for channel 1
    11: Volume for channel 2
    12: Volume for channel 3
    13: Volume for channel 4
    14: Volume for channel 5
    15: Volume for channel 6
    16: Volume for PSG 1
    17: Volume for PSG 2
    18: Volume for PSG 3

    Channel Pointer:

    19: Pointer to channel 1
    1B: Pointer to channel 2
    1D: Pointer to channel 3
    1F: Pointer to channel 4
    21: Pointer to channel 5
    23: Pointer to channel 6
    25: Pointer to PSG 1
    27: Pointer to PSG 2

    Value Definitions

    $80-$DF Notes
    $E0-$FF Coordination flags

    Note Value Equivalents: Notes is based off of OpenMPT and the values
    is based off the game.

    Notes Value

    C-1: 80
    C#1: 81
    D-1: 82
    D#1: 83
    E-1: 84
    F-1: 85
    F#1: 86
    G-1: 87
    G#1: 88
    A-1: 89
    A#1: 8A
    B-1: 8B

    C-2: 8C
    C#2: 8D
    D-2: 8E
    D#2: 8F
    E-2: 90
    F-2: 91
    F#2: 92
    G-2: 93
    G#2: 94
    A-2: 95
    A#2: 96
    B-2: 97

    C-3: 98
    C#3: 99
    D-3: 9A
    D#3: 9B
    E-3: 9C
    F-3: 9D
    F#3: 9E
    G-3: 9F
    G#3: A0
    A-3: A1
    A#3: A2
    B-3: A3

    C-4: A4
    C#4: A5
    D-4: A6
    D#4: A7
    E-4: A8
    F-4: A9
    F#4: AA
    G-4: AB
    G#4: AC
    A-4: AD
    A#4: AE
    B-4: AF

    C-5: B0
    C#5: B1
    D-5: B2
    D#5: B3
    E-5: B4
    F-5: B5
    F#5: B6
    G-5: B7
    G#5: B8
    A-5: B9
    A#5: BA
    B-5: BB

    C-6: BC
    C#6: BD
    D-6: BE
    D#6: BF
    E-6: C0
    F-6: C1
    F#6: C2
    G-6: C3
    G#6: C4
    A-6: C5
    A#6: C6
    B-6: C7

    C-7: C8
    C#7: C9
    D-7: CA
    D#7: CB
    E-7: CC
    F-7: CD
    F#7: CE
    G-7: CF
    G#7: D0
    A-7: D1
    A#7: D2
    B-7: D3

    C-8: D4
    C#8: D5
    D-8: D6
    D#8: D7
    E-8: D8
    F-8: D9
    F#8: DA
    G-8: DB
    G#8: DC
    A-8: DD
    A#8: DE
    B-8: DF

    Effect List:

    E0: Instrument number
    Parameters: E0 xx

    E8: Pitch ?
    Parameters: E8 xx

    E9: ?
    Parameters: E9 xx

    EC: Loop; EC 00 is infinity loop.
    Parameters: EC xx

    ED: Fade in
    Parameters: ED xx

    The music list is here in this topic: http://forums.sonicr...95
  2. vladikcomper


    Tech Member
    Sonic Warped
    Wow, I didn't know someone else is actually interested in T.S. Sound Driver! I just came across this topic by chance.

    I've been reverse-engineering T.S. Sound Driver v.1.31 used in Thunder Force IV for years now. My goal was to achieve highly accurate music porting from Thunder Force games to my own sound driver. Currently, I have most of the driver's format and routines completely figured out.
    My research is already complete enough to make it possible to convert music to other formats and program it from scratch. Moreover, a while ago (about half of a year now) I managed to get conversion quality so perfect you barely can tell the converted songs from their originals. This covers most of Technosoft games. I also attempted to write music from scratch for TF4, but it was more of a proof-of-concept and I didn't work much in that department.

    From I can tell, in terms of BGM format, T.S. Sound Driver didn't change much from TF2 to TF4, except for PSG handling (early T.S. games, including TF2 have some weird extra flags in PSG patterns). But generally speaking, format is actually the same, so while I've been researching TF4 driver exclusively, the knowledge learned also worked perfectly for TF3 and TF2 (almost).
    I can expand the information you provided here with my own research, for instance:

    Code (Text):
    1. ------------------
    2. BGM Header format
    3. ------------------
    5.     00h b   Number of channels (always must be 09h = 6 FM + 3 PSG)
    6.     01h b   Volume (99 = max, 0 = min)
    7.     02h b   Tempo modifier
    8.     03h b   Pitch modifier
    9.     04h w   Volume table pointer
    10.     06h w   Channel tracks table pointer
    11.     08h w   Patterns table pointer
    12.     0Ah w   FM Voices bank pointer
    13.     0Ch w   PSG Voices bank pointer
    14.     0Eh w   End of file offset
    16.     Channel tracks table stores offset for all 9 sound channels used by driver in the following order:
    17.         FM1, FM2, FM3, FM4, FM5, FM6, PSG1, PSG2, PSG3
    18.     Channel tracks cannot be skipped -- if the channel is unused, corresponding track should start with byte 0FFh (end of track marker).
    20.     Each FM/PSG track refers to patterns from patterns table by table entry number. Both tracks and patterns can execute coordinate flags.
    I was planning to release all my research eventually as soon as I get all the information organized and explained properly. But seeing it can actually help you with your tutorial and save a lot of your time, I don't mind sharing it with you. I hope you'll make a really good use of it:
    To be fair, it's a little messy, it needs some clean-up and some important information is missing or isn't explained properly. You see, I just used this file for general notes and documenting. I also have conversion tool for my custom sound driver that I've been working on for long. That tool has the rest of the stuff documented or otherwise cleared up in its code. I'm afraid I cannot release the tool; I wrote it for my own use for own own sound driver format. But I see you've figured a lot of stuff on your own already, excellent job! I believe you'll pick up the rest you need easily.

    Good luck with your tutorial!~
  3. Shadow Hog

    Shadow Hog

    "I'm a superdog!" Member
    I assume Dragon's Fury uses a similar driver, then?
  4. vladikcomper


    Tech Member
    Sonic Warped
    Yes, Dragon's Fury driver is almost identical to both Thunder Force III and IV. The game also features remixes from other T.S. games in its hidden BGM slots (this includes Elemental Master, Herzog Zwei, TF2 and TF3).
  5. Dracula


    I'm watching you!
    Converting NES Mappers to MMC5
    Wow! Thank you very much! I'll give you credit for it as well. You can also port a song from another T.S. sound driver without have to change a lot of stuff. I ported Thunder Force 4 stage 6 boss to Thunder Force 2 and it played very well.