/ 

Converting Lunar: Eternal Blue to PAL - Work In Progress

URL copied to clipboard
By Xhojn dated  last updated 
![Welcome to the madness that is hacking the music for Lunar: Eternal Blue](/static/img/mm/gaming/38169541_s.jpg) Before delving into the pit of madness, I should give some background context. I really enjoy playing RPGs, they are one of my favourite genres of games (it's just a pity they take so long to complete). I’m mostly interested in playing retro ones, though I will dabble with some newer ones on occasion. Over the last couple of years, I have pulled out my old Mega Drive (Sega Genesis for my American/Canadian cousins). Thanks to a Christmas bonus almost two years ago, I bought a Mega CD (Sega CD). With my new CD-based add-on, I wanted to see what games were available -- so straight to YouTube I go, looking for top ten lists. Sadly, there are a bunch of games that were never released in the PAL territory (Europe and Australia). Through the wonders of being in the future, there are options for getting around this. One popular method is to mod the console to not only play imports, but also to run at 60Hz (retro NSTC/Japan games run at 60Hz, but PAL ran at 50Hz….it’s a long story). I would've needed to mod my Mega Drive as well as my Mega CD, and I didn’t have the heart to do that. Plan B! There are people who mod the games so they will run on PAL consoles instead! There is one game, though, that hasn’t been converted, and that is Lunar: Eternal Blue (which will be shortened to "Lunar" for the rest of this post).

Lunar: Eternal Blue is the sequel to Lunar: Silver Star Story, both of which are JRPGs. Neither of them was released in PAL. The first game, Silver Star Story, has been converted and is commercially available on the internet. With Mega CD games, one thing that usually has to be done is to alter the music to play at the correct speed for 50Hz. In most cases this is a trivial task: use Audacity to extend the CDA tracks and add them back to the game. The reason this is easy is because the first track of a Mega/Sega CD game is the actual ‘game’, and every track after is the music. This means you can plunk the CD into any CD player, and, except for track 1, the music will play like any audio CD. This was not the case for the second Lunar game. When Lunar was being developed, they created around 260 tracks. These would never have fitted onto a single disc with the game -- so compression was needed! The way they got around it was to have the music as PCM audio within the game itself. Okay this makes the job harder to stretch the music, but not impossible….right? Wrong, it was designed in what I have read is an elegant way, but to me is a pain in the ass. At this point, I will link to two people who have been instrumental in helping me understand all of this. I will link to their articles, but they are [Kode54 aka Christopher Snowhill](https://gitlab.com/kode54/foo_lunar2/-/tree/main) and [Misty De Meo](https://www.mistys-internet.website/blog/blog/2016/01/26/elegance/)... but, I’m getting ahead of myself. I had the idea to try and convert the music myself in early 2021 and we’re now in September 2022 -- just to show how long I have been trying to do this. Even though I have a method, it’s still not perfect. Anyway, the first job is to grab a copy of the American game and delve into the files to understand what is there, and read through various [articles that explain what I’m looking at](https://tcrf.net/Lunar:_Eternal_Blue). There are two traditional CDA files on the disc, but the rest are files named like `RP001.PCM`. Helpfully, there is also a cut file that lists which tracks are used for cutscenes (turns out these are animated cutscenes and not in-engine cutscenes….great /s). I now know which tracks (except one in-engine scene) make up the intro until the player needs to do something, so I can make changes and easily test the results. ![binary-g6acfdd0c3_1280.jpg](/static/img/mm/data/binary-g6acfdd0c3_1280.jpg) Oh boy, did I have to do so many, many, many tests to try and find something that would work. As described in the links the PCM files are double the length they need to be, as they are padded with zeroes. The TLDR is: because two bytes represent stereo, but the music is mono (except for two random PCM tracks), so only one byte is needed. Also, I have been unable to find a tool that will allow me to edit PCM files. So, the solution? Use [a community-made converter that takes the game’s PCM files and turns them into WAV files](https://www.techhouse.org/~lou/lunar/lunar2/lunar2sounds.html). Now I can use Audacity to slow the music down for 50Hz, BUT we now have files that are half the size they once were and oh boy does the music play at double speed when tested in the game. So now we need to use Audacity to then double the length of the track to compensate. We now have music that is the correct length, but in the wrong format. Another community tool to the rescue, in the form of [SCDTools SCDWAV2PCM](https://github.com/classiccoding/scdtools). You need Perl installed to run it. So I insert the music back into the disc and... it won’t play the first cutscene. Great. Yep, the tracks are now larger, so the table of contents for the disc is now incorrect. Now we need another community application in the form of [CD-Replace](https://www.romhacking.net/utilities/852/) which is an awesome tool when it wants to work. I think this was designed for older OS’s as it will end prematurely on updating the TOC and give you an unusable file. This still happens even when I tested with a Windows 7 32bit virtual machine. When it works, it’s great, but you may have to hit up and enter to redo the command a bunch, before getting a workable result. Sadly, you have to do this file-by-file... So we have some updated tracks, they have been inserted back into the disc correctly, and they play! Except they cut off prematurely and cycle the last couple of seconds that was played. More reading... and big thanks to Christopher Snowhill, who answered my questions. In each PCM file, there are two sets of data that are the start loops and end loop for the track. In his own words – “(bytes) 2/3/4/5 and 6/7/8/8 are the loop offsets, in big endian format. Loop start is sector count (offset divided by 2048), end is an offset into the entire stream, in exact samples, and is inclusive.” Using this information, I update the two byte loops (hopefully they are correct). And they kind of are? In the example video below, you will see what I mean. In some cases the music is perfect but in others they aren’t. <div style="margin: 0px auto;"><iframe width="560" height="315" src="https://www.youtube.com/embed/z_yAk7YfInI" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen style="display: block; margin: 0px auto;"></iframe></div> So what now? The method isn’t perfect. Unless I can sort this, then it means I would need to play through the whole game (potentially multiple times as saves won’t work with the game files being moved around the disc) to test the music... which will be time intensive. I’m now trying to see if the original PCMs could be altered, and the [only tool I have found](https://www.romhacking.net/utilities/733/) doesn’t want to play nice on my PC, or my Windows 7 32-bit virtual machine either. I don’t want to give up on this project -- I’m so close -- but I don’t want to put time into going through the game if it’s not the best way to achieve this. For now, this is still just a work in progress...

For more by&nbsp;Xhojn, click here.

🔍

Valid HTML!Valid CSS!Powered by Node.js!Powered by Express.js!Powered by MongoDB!