Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
YM player
youtube video

This is a small project I started a couple of days ago. The goal was to attempt playback of uncompressed YM files on the NGPC (these files are register logs for the YM2149 / AY-3-8910 chips, used e.g. in the Atari ST and ZX Spectrum).
I Figured I'd have it up and running at 16 kHz in no-time.


I had to lower the sampling rate to 12 kHz, then 9.6, then 8, and finally to a measly 6 kHz. And at the same time I searched for ways of shaving cycles from my code, to the point where I'm now using all general-purpose registers in every register bank in my playback loop.
The output obviously doesn't sound too good with such a low sample rate - but hey, it does kinda work. And hopefully I can make further optimizations at some point.
I did it years ago in my first ngpc game (column).
It was not fully compatible but some tunes were working fine.
I made a converted with my own compression code (lzw), and it was a bit time consuming.
If you get good result, I'll be happy to us your plyer in my games!
I'm guessing that you used the NGPC's square wave / noise channels for the sound output(?). Otherwise I don't see how you possibly could get it fast enough to be used in a game.

My playback code will certainly not be fast enough to be useable in a game, since I generate PCM data which I write to the DACs. And this eats up all available CPU cycles.

If you're making a game or demo for the NGPC it would be better to use a music format that was designed for the NGPC in the first place. Otherwise you're always going to end up wasting cycles and/or space.
(04-15-2013, 05:53 AM)mic_ Wrote: I'm guessing that you used the NGPC's square wave / noise channels for the sound output(?).

Yes sir
My converter takes register values from ym and transpose them to the ngpc sound processor.
There is some code to unpack data on the main processor and it sends them to the z80 code to play.
The sound processors are quite similar.
Quote:The sound processors are quite similar.

Yeah, I considered that before I started writing my player. But there were a few differences that I felt would make a lot of songs sound weird:

* The YM/AY chip uses 12-bit counters for the tone channels. When clocked at 1.7 MHz they are capable of going down to about 27 Hz. The NGPC's sound chip meanwhile is clocked higher and uses 10-bit counters, and therefore can't go lower than about 94 Hz, which would make songs with a lot of bassy content sound way off. The NGPC's noise channel can generate square waves at lower frequencies, but it doesn't have the right duty cycle, plus you'd lose the noise channel.

* The shift register used for generating noise on the NGPC differs from the one on the YM/AY. The NGPC has a 15-bit shift register, while the YM (AFAIK) has a 17-bit shift register. The tapped bits might also differ. In any case the generated noise sequences will differ, so percussion sounds will be a bit off.

There may also be other problems that I haven't thought of.
And for the vgm player? is it ok to use it in games?
Can I create vgm tracks with DefleMask ( ) using the SMS system output and play them on NGPC?
I've optimized the code a bit, so it now generates audio at 8 kHz (and is close to being able to do 9.6 kHz): youtube video

Here's a ROM that you can run on your NGPC if you want to torture your ears.

Quote:And for the vgm player? is it ok to use it in games?

Should be. The VGM playback code runs on the Z80, so the TLCS-900 only needs to move more VGM data to the shared RAM area periodically, which shouldn't take that much processing power.
But it's not a full-blown sound engine - for example there's no support for playing sound effects, which is something you'd expect in most games. So I don't know if it'd be very useful for that purpose.
After a lot of optimization (and fixing a bug that caused my code to execute from ROM, instead of from RAM like it was supposed to) I now have stable 16 kHz output from my YM player.

Video 1: Saboteur 2, by Rob Hubbard
Video 2: Pablo and the gold of Montezuma, by Jochen Hippel
Video 3: DOC Zak 01, by DOC

The ROMs are here in case you want to try them on your flashmasta cart.
I've improved the emulation a bit, and written a Windows tool that lets you generate new NGP files from YM songs of your own liking.

Download (source code included)

[Image: nymp-4.png]

youtube video

Forum Jump:

Users browsing this thread: 1 Guest(s)