don't click here

Green Hill on a TX81Z

Discussion in 'Engineering & Reverse Engineering' started by saxman, Jul 29, 2011.

  1. saxman

    saxman

    Oldbie Tech Member
    [youtube]http://www.youtube.com/watch?v=aQAd6ckYrjk[/youtube]


    This is the classic Green Hill Zone playing on a Yamaha TX81Z. I hand-ported each voice from the game, used ValleyBell's SMPS2MID program to create a MIDI sequence of the song, and then played it through the TX81Z.

    Some problems that occur:
    - TX81Z timing is apparently slower, making attack and decay times slower than that of the YM2612
    - The modulation in the MIDI file is a bit too much
    - The TX81Z doesn't change voices instantly, so everytime a voice has to be set, you hear a stutter in the music
    - There's no PSG or DAC for obvious reasons



    UPDATE: Conversion guide is here!

    http://www.4shared.com/document/GnatNkzF/How_to_Play_Sonic_1_Music_on_a.html

    Code (Text):
    1.  
    2. How to Play Sonic 1 Music on a Yamaha TX81Z
    3. Written by Damian Grove
    4. 07/29/2011
    5.  
    6.  
    7.  
    8. ==============================================================================
    9. Introduction
    10. ==============================================================================
    11.  
    12. It has been long established that a directly relationship exists between the
    13. YM2612 and the Yamaha DX synthesizer series. I happen to be an owner of two
    14. such synthesizers -- a Yamaha DX7 II-FD, and the Yamaha TX81Z. Technically
    15. they're not mine (they're my dad's), but he doesn't really use them anymore.
    16.  
    17. I created Sonic QX after discovering that the YM2612 worked very similar to
    18. the DX7. Upon further examination, I realized that while the DX7 had a total
    19. set of 32 algorithms and 6 operators, the YM2612 had 8 and 4 respectively.
    20. I then realized I owned one such synthesizer, but it wasn't the DX7.
    21.  
    22. As I started learning the voice format in Sonic 2, started matching all of the
    23. registers in the YM2612 to the TX81Z. Some register names were the same, and
    24. some weren't. What was absolutely clear however was the envelope generator was
    25. identical.
    26.  
    27. When I released Sonic QX back in 2003, it was capable of converting voices
    28. from the TX81Z over to Sonic 2. I intended to create a way to convert the
    29. other direction, but I never got around to it, and eventually I abandoned
    30. Sonic QX altogether.
    31.  
    32. Recently, I decided it would be a cool thing to witness the TX81Z playing back
    33. a Sonic tune. So I downloaded a couple tools to help read voice data from the
    34. first Sonic the Hedgehog game so I could port the data over. The process was
    35. supposed to be relatively easy, but due to some bugs in SOME (Sonic One Music
    36. Editor) and some minor differences between the TX81Z and YM2612, it took me a
    37. good while to figure out exactly how to get the conversion process working.
    38.  
    39. I posted a video on YouTube demonstrating the end result. I wanted to write a
    40. guide explaining how I did everything in hopes that it would increase some
    41. awareness of the TX81Z and how it can be used as a music editor for music in
    42. the Sonic series. If anything, it can be a useful guide to anyone interested
    43. in writing software to convert Sonic voices to the TX81Z and other DX series
    44. synthesizers.
    45.  
    46.  
    47.  
    48. ==============================================================================
    49. Basic TX81Z setup
    50. ==============================================================================
    51.  
    52. Before we do anything, we need to unprotect the memory. To do that, press
    53. UTILITY button. Then navigate through the options using the PARAMETER buttons
    54. until you see "Mem Protect:" displayed following either "on" or "off". If it
    55. is on, press the DEC button to turn memory protection off. The TX81Z is now
    56. ready to have data written to it.
    57.  
    58. Next we will need to ensure the TX81Z can process MIDI input data correctly.
    59. While still in Utility Mode, scroll to "Midi Control?" and press INC. Now
    60. scroll to "P.Change" and use the DATA ENTRY buttons to set it to "ind". Then
    61. scroll over to "Init P.Cng Tbl?" and press INC twice.
    62.  
    63.  
    64.  
    65. ==============================================================================
    66. Porting a voice
    67. ==============================================================================
    68.  
    69. We need to be in Play Single mode for this part of the tutorial. Enter this
    70. mode by pressing the PLAY/PERFORM button. It will have the words "PLAY SINGLE"
    71. on top.
    72.  
    73. Next, we'll initialize a voice so we can start fresh. While in Play Single
    74. mode, use the DEC and INC buttons to set the voice number. We need to use a
    75. voice from bank I since the other banks are ROM, so any voice from I01 to I32
    76. will do (however, to ensure proper playback of music I strongly recommend you
    77. use I01 for your first voice, I02 for your second, and so on). Now go into
    78. Utility Mode using the UTILITY button and use the left and right PARAMETER
    79. buttons to scroll until you see "Init Voice?". Press the INC button twice.
    80. This will automatically put you into Edit Mode (which can also be accessed via
    81. the EDIT/COMPARE button).
    82.  
    83. Before we go any further, let's open SOME. Go to File->Open and select your
    84. Sonic the Hedgehog ROM. Now go to Tools->Voice Editor. Select the track and
    85. voice number you wish to port over. There are a few bugs to take note of. This
    86. guide will point them out as needed to ensure all voices are ported correctly.
    87.  
    88. On the TX81Z, you will use the PARAMETER buttons to scroll between pages, the
    89. CURSOR buttons to move to different parameters on a page, and the DATA ENTRY
    90. buttons to change the data. Below is a chart of the values that need to be
    91. changed on the TX81Z. Any values not listed should be left alone.
    92.  
    93.     TX81Z                   SOME
    94.     ----------------------------------------
    95.     ALG                     ALG
    96.     Feedback(OP4)           FBL
    97.     "Sensitivity?"
    98.         AMS [1-4]           AME
    99.     "Edit Frequency?"
    100.         CRS(RATIO) [1-4]    MUL [1-4]
    101.     DET [1-4]               DET [1-4]
    102.     "Edit EG?"
    103.         AR [1-4]            AR [1-4]
    104.         D1R [1-4]           D1R [1-4]
    105.         D1L [1-4]           D1L [1-4]
    106.         D2R [1-4]           D2R [1-4]
    107.         RR [1-4]            RR [1-4]
    108.     OUT [1-4]               TL [1-4]
    109.     "Scaling?"
    110.         RS [1-4]            RS [1-4]
    111.     "Function?"
    112.         Poly Mode
    113.         Middle C
    114.         Name
    115.  
    116.  
    117.  
    118. One problem (not necessarily with SOME, but instead with the documentation
    119. from Sega that was used to make SOME) is the operators are numbered backward.
    120. An order of 1, 2, 3, and 4 on the TX81Z would be 4, 3, 2, and 1 in SOME. Where
    121. SOME messes up is the order in which it presents some of it's data -- the
    122. second and third operators are actually swapped for all values except DET. The
    123. first and fourth operators are swapped for DET.
    124.  
    125. Out of anticipation for possible confusion, I have provided a simplified
    126. breakdown of how the conversion process should go.
    127.  
    128.     For DET values:
    129.  
    130.     TX81Z                   SOME
    131.     ---------------------------------------
    132.     OP 1                    OP 1
    133.     OP 2                    OP 3
    134.     OP 3                    OP 2
    135.     OP 4                    OP 4
    136.  
    137.     For all other values:
    138.  
    139.     TX81Z                   SOME
    140.     ---------------------------------------
    141.     OP 1                    OP 4
    142.     OP 2                    OP 2
    143.     OP 3                    OP 3
    144.     OP 4                    OP 1
    145.  
    146.  
    147.  
    148. Some things to pay attention to:
    149.  
    150. * The ALG values range from 0 to 7 in SOME and 1 to 8 on the TX81Z. Whatever
    151. the value is in SOME, add 1 to it for the TX81Z.
    152.  
    153. * MUL values are equal to CRS values, but without the extra precision to the
    154. right of the decimal. When MUL is 0, just use 0.50 for CRS.
    155.  
    156. * TL values are backwards from the OUT values. In addition, TL values have a
    157. 128 value range, whereas OUT values have a 100 value range. Luckily, the
    158. volume intervals are identical despite the different ranges. OUT should be 99
    159. minus whatever TL is.
    160.  
    161. * D1L is also backwards between SOME and the TX81Z. D1L on the TX81Z should be
    162. 15 minus the D1L value in SOME.
    163.  
    164. * SOME presents the RR data on a larger scale, but with the same number of
    165. selectable values. Subtract 1 from the value and divide it by 2 to create the
    166. RR value for the TX81Z. Note however that Yamaha introduced a very slight
    167. compatibility issue in the DX series with the TX81Z in that RR cannot be 0.
    168. Yamaha's solution is to make RR equal 1 instead of 0. So if you come up with
    169. 0 after your math, you should do the same.
    170.  
    171. * The Poly Mode can be changed to Mono Mode if you want to ensure that only a
    172. single note is played (meeting the limitation of the YM2612). However, it is
    173. not necessary since our performance data will ensure correct playback anyhow.
    174.  
    175. * Middle C should be set to C4 so SMPS2MID conversions are played at the right
    176. pitch.
    177.  
    178. * Name can be whatever you decide it should be. Obviously I would recommend
    179. you incorporate the level name in there somehow.
    180.  
    181.  
    182.  
    183. It should be noted that the timing of the YM2612 versus the TX81Z is not the
    184. same. Attack and decay rates will be slower on the TX81Z. I do not have a
    185. definite solution for this other than playing around with the RS values and
    186. individual attack/decay values.
    187.  
    188.  
    189.  
    190. Once all the data has been converted, go back into Play Single mode, but DO
    191. NOT change the voice selection or your changes will be lost. To preserve our
    192. changes, hold the STORE/EG COPY button and press INC one time. The two voice
    193. numbers displayed should match. Release the buttons and press INC again. The
    194. data should now be saved.
    195.  
    196.  
    197.  
    198. ==============================================================================
    199. Creating a performance
    200. ==============================================================================
    201.  
    202. Performance Mode is meant to be used when playing a song. It allows multiple
    203. voices to be used on the TX81Z (up to 8). We create a performance to properly
    204. patch the SMPS2MID sequence we will generate so it plays with the instruments
    205. from the game.
    206.  
    207. Enter Performance Mode using the PLAY/PERFORM button. You will see "pF" with
    208. a number displayed when in Performance Mode. Use the INC and DEC buttons to
    209. select the performance number you wish to use.
    210.  
    211. We will want to initialize the performance. To do so, press UTILITY and use
    212. the PARAMETER buttons to scroll to "Init Perfrm?". Press INC twice. It will
    213. put you in Edit Mode.
    214.  
    215. Use the left PARAMETER button to scroll back to "ED MAX NOTES". Set each of
    216. the eight values to 1 using the DATA ENTRY buttons. Use the CURSOR buttons to
    217. move to change the selections.
    218.  
    219. We will be able to use this performance for any SMPS2MID generated file.
    220. Therefore, we could scroll over to "Name" and call it "PlayYM2612" if you so
    221. desire.
    222.  
    223. Now press PLAY/PERFORM to go back into Performance Mode. We need to save our
    224. changes before going further, so hold down the STORE/EG COPY button and press
    225. INC one time and release. The two performance numbers showing should match.
    226. Press the INC button once more to save the performance.
    227.  
    228.  
    229.  
    230. ==============================================================================
    231. Converting a song
    232. ==============================================================================
    233.  
    234. For this step, we will need SMPS2MID, a neat utility created by ValleyBell.
    235. This program will take SMPS sequence data from a Sonic game and convert it
    236. into a General MIDI sequence file. While the program isn't perfect, it is
    237. currently the best option out on the internet.
    238.  
    239. To begin, run the program and click "Open File". Select the Sonic the Hedgehog
    240. ROM. Change SMPS Type to Sonic 1. Now click SMPS2MID, type the name of the
    241. General MIDI file you wish to create and click "Save".
    242.  
    243. Open the MIDI sequence file in a MIDI editor (such as SONAR). We will have to
    244. configure our channels to properly interface with the TX81Z.
    245.  
    246. Set the FM tracks to use channels 1, 2, 3, 4, and 5 respectively. Mute all
    247. other tracks. Set the output on each channel to the port you have connected
    248. to the TX81Z.
    249.  
    250. To play the song properly through the TX81Z, ensure that the TX81Z is set to
    251. Performance Mode and using the performance you created before starting the
    252. MIDI sequence.
    253.  
    254. It is important to understand that the TX81Z doesn't switch voices quite as
    255. quickly as the Sonic games, so the music may stutter when voice change events
    256. occur. This is an unfortunate limitation to the hardware. However, the fewer
    257. voice change events that occur in a short period of time, the better it will
    258. be and the less noticeable any stuttering will be.
    259.  
    260.  
    261.  
    262. ==============================================================================
    263. Conclusion
    264. ==============================================================================
    265.  
    266. There you have it! I hope someone out there gets something useful from this
    267. guide. I learned a lot from this experiment, and I hope you did too. I want to
    268. give special thanks to Fuzzbuzz and ValleyBell for your tools that helped make
    269. this experiment possible.
    270.  
    271.  
     
  2. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,202
    432
    63
    Japan
    Ah I see the modulation is slightly off, this is pretty cool though, sounds rather accurate too =D
     
  3. saxman

    saxman

    Oldbie Tech Member
    Update: conversion guide posted! See top post.
     
  4. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    Code (Text):
    1. To begin, run the program and click "Open File". Select the Sonic the Hedgehog
    2. ROM. Change SMPS Type to Sonic 1. Now click SMPS2MID, type the name of the
    3. General MIDI file you wish to create and click "Save".
    I you want to note that it is not neccessary to change the SMPS Type to Sonic 1. The autodetection works fine as long as you don't use a hacked ROM. (e.g. Sonic 2 with Sonic 1 sound driver)

    Also smps2mid knows currently just modulation on or off. (That's why the modulation is way too strong.) It will be better in the next smps2mid.