Jump to content

Photo

YM player

music

10 replies to this topic

#1 Arnauld OFFLINE  

Arnauld

    Space Invader

  • 42 posts
  • Location:Paris / France

Posted Thu Jun 1, 2017 9:49 AM

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

Attached Thumbnails

  • shot0002.gif

Attached Files



#2 First Spear OFFLINE  

First Spear

    Stargunner

  • 1,322 posts
  • Location:Somewhere in Uptown

Posted Thu Jun 1, 2017 11:54 AM

Wow man, that is great! I did some pretty heavy (heavy for me, anyway) investigation of YM->Intellivision last year and found the format to be pretty difficult to parse and interpret. Thanks for sharing that!



#3 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 11,646 posts
  • The P-Machinery AGE is almost here!
  • Location:NC, USA

Posted Thu Jun 1, 2017 2:30 PM

Thank you for sharing this, Arnauld. :thumbsup:

#4 artrag OFFLINE  

artrag

    Stargunner

  • 1,165 posts

Posted Thu Jun 1, 2017 4:28 PM

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

It seems compressed as well, but not using LHZ

If you explain the algorithm I could try to port the player to msx and colecovision 



#5 Arnauld OFFLINE  

Arnauld

    Space Invader

  • Topic Starter
  • 42 posts
  • Location:Paris / France

Posted Thu Jun 1, 2017 5:50 PM

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, Fri Jun 2, 2017 2:01 AM.


#6 Arnauld OFFLINE  

Arnauld

    Space Invader

  • Topic Starter
  • 42 posts
  • Location:Paris / France

Posted Fri Jun 2, 2017 2:37 AM

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, Fri Jun 2, 2017 2:38 AM.


#7 artrag OFFLINE  

artrag

    Stargunner

  • 1,165 posts

Posted Fri Jun 2, 2017 5:12 AM

How much ram do you need?

#8 Arnauld OFFLINE  

Arnauld

    Space Invader

  • Topic Starter
  • 42 posts
  • Location:Paris / France

Posted Fri Jun 2, 2017 5:41 AM

Quite a lot, actually. As described above, the sliding windows require 10 x 1K-word (20,480 bytes). The space occupied by other variables is negligible.



#9 artrag OFFLINE  

artrag

    Stargunner

  • 1,165 posts

Posted Fri Jun 2, 2017 6:30 AM

It is too much for practical usages. Could the data and the sliding windows be stored in rom? Having a mapper you could slide pointers

#10 carlsson ONLINE  

carlsson

    Metagalactic Mule

  • 8,026 posts
  • Location:Västerås, Sweden

Posted Fri Jun 2, 2017 7:34 AM

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.



#11 Arnauld OFFLINE  

Arnauld

    Space Invader

  • Topic Starter
  • 42 posts
  • Location:Paris / France

Posted Fri Jun 2, 2017 7:53 AM

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).







Also tagged with one or more of these keywords: music

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users