Jump to content
IGNORED

YM player


Recommended Posts

Some years ago, I wrote some PHP code to convert YM files originally created for the Atari ST to an Intellivision format, along with a CP-1610 assembly player. I was recently asked to share this code, so I thought it would be better to make a public release here, in case other people are interested. The PHP code is pretty bad and not especially fast, but it gets the job done.

 

A YM file basically consists of a large dump of the AY-3-8910 registers, compressed with the LHA algorithm. I'm using this program to unpack the data (the Windows built is included in the archive). The PHP script processes the raw data and re-compress it into the final Intellivision format. The output of this process is a .asm data file which is compatible with the player. If the 5th argument of the ymToIntv::process() method is set to true, it will also attempt to generate the player ROM file, provided that as1600 is available in the path. Again, a Windows environment is assumed, but it should be very easy to have it running in another OS (see ymToIntv::generateRom()).

 

Some YM files include information about special PSG effects. Most of them rely on high-frequency interrupts. These effects are ignored, as the Intellivision would not be able to render them anyway. Consequently, not all YM files can be properly converted. YM files sometimes come in several versions. If possible, choose a version without Digidrums and without SID Voice.

 

The following tunes are included as examples:

 

  • Best part of the Creation by Gunnar Gaubatz
  • Chambers of Shaolin by Jochen Hippel
  • Crapman Anthems by Joe Maarten de Man
  • Cuddly Demos / Big Sprite by Jochen Hippel
  • Custodian by David Whittaker
  • Decade Demo / Giga-Dist by Nic Alderton
  • Ghouls'n Ghosts Theme by Tim Follin
  • Hystanders 2 by Doclands
  • Leaving Teramis by Jochen Hippel
  • Line of Fire by Tao
  • Primus by Scavenger
  • Rectangular Waves by Nils Feske
  • R-Type Intro by Wally Beben
  • Sharpness Buzztone by Jean-Sébastien Gerard
  • Virtual Escape by Furax
  • Zynaps #1 by Dave Rogers

post-28473-0-88480700-1496330800.gif

ymToIntv.zip

  • Like 5
Link to comment
Share on other sites

Can you say more about the compressed format you generate to feed you player?

It seems compressed as well, but not using LHZ

 

This is actually using some kind of Lempel-Ziv compression, but with variable bit-width depending on the stream that's being processed.

 

Namely, there are 6 different kind of streams for a total of 10 distinct streams:

  • tone periods (x3) : 12 bits
  • volumes (x3) : 5 bits
  • envelop period : 16 bits
  • envelop type : 4 bits
  • noise period : 5 bits
  • mixer : 6 bits

Each stream maintains its own sliding window for backward references. Each window is 1024 words long. They're stored at $9000-$B7FF. Conveniently, this range ends just before the GRAM write-sensitive aliases at $B800-$BFFF.

 

The decompression algorithm works as follows. For each stream:

  • read one bit
  • if it's a one, the next block is a backward reference:
    • read 10 bits to get the distance of the reference
    • read 8 bits to get the size of the reference, multiply it by the bit-width of the stream and copy the corresponding number of bits from the sliding window
  • if it's a zero, the next block is unpacked data:
    • read 5 bits to get the size of the block, multiply it by the bit-width of the stream and read the corresponding number of bits directly from the stream
Edited by Arnauld
Link to comment
Share on other sites

Just a few more words about the player.

 

You can mute/unmute channels by pressing [1], [2] and [3] on the keypad.

 

"E" is the current hardware envelope. The first nibble is the envelope type and the next 4 nibbles represent the envelope period. "NP" is the noise period. "MX" is the mixer register. Below each channel, the 3-nibble value is the tone period and the 2-nibble value is the volume. It's worth noting that the volume is stored as a 5-bit quantity and that we systematically expand it to 0x30 when bit #4 is set (IIRC, this is required for some versions of the PSG that make a difference between 0x10 and 0x30 for hardware envelope amplitudes and would not sound loud enough if we were using 0x10).

Edited by Arnauld
Link to comment
Share on other sites

Wait, what? The Intellivision as far as I know doesn't have those 20 kB of general purpose RAM, not even with the ECS. I understand there are modern cartridge boards that add RAM though, but you didn't mention this in the message, perhaps it is mentioned in the file archive.

 

I was about to say that a register dump file, even with relative timestamps, would quickly become quite large but I know you can map ROM into large areas on the Intellivision so perhaps that is not too much of a problem.

 

I still think tracker based music formats, or possibly even the converted MIDI as presented by Decle are to prefer over register dumps. Surely all the AY/YM based systems should've had a unified higher level music format, but then again every coder/musician worth their salt will want to roll an own format (*) so perhaps in the end it is register dumps that remain as a common format.

 

BTW Arnauld, your own Intellivision tracker is great, in particular after obtaining tools to convert raw data from other formats!

 

(*) Just look at the C64. I don't have a number of how many different player formats it has, but surely in the range of three digits if you count all variations. People who don't understand the SID file format often can't quite grasp that the SID player on a PC basically is a C64 emulator minus inputs and video generation, so it executes a custom player routine built into each song file.

Link to comment
Share on other sites

Yes, it does require extra RAM. I don't think that 20 kB is much of an issue for modern boards. If you were to store the uncompressed raw data in ROM, it would be about 285 kB for Chambers of Shaolin -- which would probably be more problematic.

 

That said, I fully agree with you: tracker based music is the way to go. This YM project was more of a fun hack and a way to demonstrate the capabilities of the Intellivision PSG when pushed to its limits.

 

And incidentally, the vast majority of tunes available today in YM format were originally generated with trackers (like these ones).

  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...