2nd of April a new ym player…

In German there is a saying:

Aus der Not eine Tugend machen.

I guess a close translation would be

“Making a virtue out of necessity”.

Coming home from a short weekend stay at a friends place – I got an eMail from VTK with the “final” version of his composition for the in game music for Release.

Looking at what he had to work with I am absolutely marveled at the song. Yes I know many of you guys will say there are way better and more fantastic songs about, but consider this:

  • the song is playing in only ONE channel
  • the song does not use any kind of noise
  • the song does not use any envelope data
  • the song thus refreshes only 3 PSG chip registers, namely 0, 1 and 8, which is a cycle “wonder” for playing music!
  • and last but certainly not least – the song was especially made for Release!

The result is, that I have two complete channel (noise/voice) and one additional noise channel left for ingame sound effects.

There was however a slight drawback. I generously calculated that the song would be about 10kb. The song that arrived here was well over 13kb, which (as you might guess reading the last blog entry) was about 3kb to large.

I am not THAT good at optimizing already optimized code – and I absolutly hate throwing good code away… so here comes the part about the “Making a virtue out of necessity”.

In the early days (a month ago 🙂 ) of Release when I was discussing music with VTK we “decided” that the good old Arkos Tracker (Link: Arkos Tracker) would be a good starting point to play around with – and so he did. Here a screenshot of the “beast”:

Along the way I thought about porting a player for Arkos modules (which I still might do at some point). The tracker actually comes with source code of diverse players (CPC, MSX, Spectrum) but all of these are Z80 CPU based – AND the code uses selfmodifying code which I would rather not do on a vectrex, since it would have to play in RAM space.

On “our” facebook group was an interesting posting about porting the original (z80 based) arcade pacman to a 6809 based cpu (Link: z80-to-motorola-6809-transcode). Glen (the blogs author) mentioned a tool to convert Z80 source to 6809 source and he actually provided that tool after nicely asking. Soooo – the groundwork for writing the tracker is at least a little bit paved already :-)…

Anyway getting back to current affairs. If you look at the above Arkos Tracker image you might notice the colored lines I drew (under channel 1).

Here you see despite the song consisting of 81 patterns- only 21 different tracks were used to form those 81 patterns. With these optimizing opportunity in mind I wrote a “halfbread” player.

I exported each track as ym data packed them up, built a structure around them and now am able to play the whole song using tracks like a “real” player – but I use ym data packages instead of instrument and note informations.

Here is what it looks like in source:

The data save is actually “enormous” – the whole song now fits in exactly 3339 bytes (including the track data – streamed incoding btw!). Now you may see why I postponed the actual transcoding of the player. The original binary data of the Arkos Tracker file is about 1500 byte – still half the size – but these 1800 bytes are nothing I worry about to much. And doing the original “playing” will certainly be not faster than at maximum setting 3 PSG registers per update round!

Hip hip hurray!

Malban

2 thoughts on “2nd of April a new ym player…

    1. Malban Post author

      The “final” in game music piece arrived yesterday (another final). Now we think about a “title” song. But how I will fit that into the remaining 3kb – I don’t know.
      (The ingame music got about 1 minute longer – and so the size expanded as well…)

Leave a Reply to Malban Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.