Undertale had a ton of memorable elements, including its characters, humor, story and genuine message of kindness. It's also known for its soundtrack, which is both a wonderful compliment to the game and full of great ambient tracks. One song that stands out among the rest is the final boss theme "Megalovania," which has quickly become one a classic video game boss battle theme.

However, the boss fight against Sans wasn't the first time Toby Fox used a version of "Megalovania," as the song had made numerous appearances in previous works Fox was involved in. In a way, the song is like Fox's audio signature, in a similar vein to "Totaka's Song" by Nintendo's Kazumi Totaka.  Here's how one of gaming's most iconic boss themes became what it is today.

RELATED: Sonic's Green Hill Zone Music Just Got Lyrics - and Its a Royalties NIGHTMARE

"Megalovania" was first used back in 2008 in Toby Fox's ROM hack of EarthBound known as Radiation's Halloween Hack. The game is fairly Halloween-themed, with missing children, old sewers, lost souls and a mad scientist who uses fourth-wall-breaking tactics to mock the player. Said mad scientist, Dr. Andonuts, has a climactic boss fight at the end of the game that features the earliest known version of "Megalovania."

Undertale Characters in a line

According to the hack's official website, the inspirations for "Megalovania" were the tracks "Megalomania" from the game Live A Live and "Gadobadorrer" from Brandish 2: The Planet Buster. This version has a much slower build-up than the Undertale version, though it's certainly sounds like the same track. Given how much of an inspiration EarthBound was on Undertale and Toby Fox, it should be no surprise that the first rendition of "Megalovania" is more subdued and ambient like EarthBound's soundtrack.

RELATED: How Persona 5 Royal's Soundtrack Tells the Game's Story

After appearing in Radiation's Halloween Hack, "Megalovania" would pop up again in another medium. Fans of the webcomic Homestuck may remember the track "MeGaLoVania" from the scene "(S) Wake," which is an important point in Homestuck's story. Toby Fox was involved with making music for Homestuck, composing around 61 tracks for the original webcomic and the adventure game spin-off Hiveswamp.

The Homestuck composition of "Megalovania" is quite different than the version most fans know. For one, there's a prominent guitar riff throughout the entire song, which gives it more of a dramatic punch. The build-up from the Halloween Hack version is there, but has been shortened dramatically, with the entire song instead building up in intensity up until the end. After a quick beat of silence, the song kicks back in with a guitar solo that fits shockingly well. This version is certainly more cinematic, which is fitting given the song's use.

The next version of "Megalovania" is the iconic Undertale version. The build-up that was prominent in the last two versions is gone, with the song going full-energy right from the get-go. While the previous versions had more layers to them, this one is kept steadier to work within the context of Undertale.

RELATED: Tetris Effect Is Secretly the PERFECT Rhythm Game

Due to the popularity of Undertale and "Megalovania," this version of the song would show up in a couple of other games. It surprised fans when it was added to Super Smash Bros. Ultimate alongside a Sans Mii Costume. Stylized as "MEGALOVANIA," this is a remix of the Undertale version, with bits of Heartache and Papyrus' boss themes snuck in near the end as a nod to the two characters closest to Sans.

The song's most recent appearance was as DLC for the rhythm game Taiko no Tatsujin: Drum 'n' Fun, though this is not a remix, but simply the Undertale version. Given how Undertale propelled "Megalovania" into immense popularity, some might think that it'd be difficult for future versions of the song to separate themselves from the final boss fight again Sans, where the track cemented the character as an amazing final boss.

However, if there's anything to be said about "Megalovania" in all its iterations is that this song is versatile enough to be used in everything from narrative climaxes to dramatic final bosses. It's incredibly likely that "Megalovania" will pop up in Toby Fox's work again, with some kind of new twist put on the composition.

Keep Reading: Tokyo Olympics' Opening Ceremonies Were Scored with Iconic Video Game Music