It is currently Sat Oct 21, 2017 12:42 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue Apr 16, 2013 2:56 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Lately I've been writing an YM player for the Neo Geo Pocket Color. In case you don't know, .YM files are register logs (16 bytes per frame) for the YM2149 chip and its clones (like the AY-3-8910). These chips were used in the Atari ST, ZX Spectrum, Amstrad CPC, and probably a lot of other '80s home computers and arcade machines.

While the sound chip in the NGPC is quite similar to the one found in the SEGA Master System, which in turn is relatively similar in capabilities to the YM/AY chips, there were differences that made me not choose to emulate the YM/AY using the NGPC's PSG (for example, it can't generate low-enough frequencies).

So what I do instead is to generate PCM data and output it to the NGPC's 8-bit audio DACs. This is of course a lot more CPU-intensive, so I had to settle for very low sample rates. Currently the maximum output sample rate I've been able to use is 8 kHz. The NGPC's main CPU (a TLCS-900/H) runs at 6.144 MHz, with every two cycles making up one CPU state. At an 8 kHz sample rate this gives me 3072000/8000 = 384 states per sample. The fastest instructions take 2 states to complete, but most take more.

Here's a video of the first version which used a 6 kHz sample rate.

And here's a video of an optimized version using an 8 kHz sample rate. I've also made the ROM available for this version, which you can run on your NGPC if you happen to own a flash cart (I'm unsure if there are any emulators available that will run it correctly).


Top
 Profile  
 
PostPosted: Tue Apr 16, 2013 3:27 am 
Offline

Joined: Sat Jan 23, 2010 11:41 pm
Posts: 1161
Nice experiment. Sadly, it is known from earlier attempts on the software AY emulation on Z80 at 10 MHz fully dedicated to it is not enough to complete emulation of the chip, with the noise and envelope (the best part of the chip) generators with nice quality. I guess TLCS-900 at 3 MHz processing power is close to Z80 at 10 MHz.

By the way, in fact AY is the original, YM is a clone.


Top
 Profile  
 
PostPosted: Tue Apr 16, 2013 3:38 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Well, I can probably get it up to 9.6 kHz with some more work. But I believe 16 kHz would be the lower limit for where it would start sounding half-decent.
I've been considering various ways of moving parts of the emulation to the sound co-processor (a 3.072 MHz Z80) - for example the envelope generation, which is the most expensive part. But I haven't yet come up with a cheap way that would keep the two processors in sync.


Top
 Profile  
 
PostPosted: Wed Apr 17, 2013 11:05 pm 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Do I feel silly. I had been hunting cycles everywhere I could find them in my playback code, and it still didn't add up. I'd counted the best-case and worst-case cycles manually but for some reason the code seemed to perform worse than it should when I actually ran it on my NGPC.

It wasn't until yesterday that I (accidentally) realized that I had put an absolute jump at the end of my playback loop, instead of a long relative jump. My code runs from RAM (which is faster because of the wider bus), but because of this error, every sample except the first one of each buffer would be generated and mixed by code running from ROM.
At least this had made me look harder for ways of optimizing the code compared to what I otherwise might have.

And with that I give you some videos of YM files being played back at 16000 Hz on my NGPC:

Saboteur 2
Pablo and the gold of Montezuma
DOC Zak 1

Here's a zip file with the corresponding ROMs.


Top
 Profile  
 
PostPosted: Sat Apr 20, 2013 3:45 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
I've improved the envelope generator emulation a bit, so a lot of songs now sound better. And I also drew some graphics instead of just using the system font on a plain background.

Image

Videos:
Epic Tune 19
Oblaka

ROM download. There's a tool included (for Windows) that allows you to easily generate new ROMs with different YM files. The source code of the player is also included.


Top
 Profile  
 
PostPosted: Sun Apr 21, 2013 9:31 pm 
Online
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 929
VGM format can also log the register writes of AY-3-8910 and of various other sound chips. Can it be used with VGM too? Furthermore, Sunsoft 5B audio in NSF is also a clone of AY-3-8910, too (and I suppose it might be logged to VGM). What programs are there to write musics for this chips other than ppMCK and VGMCK and Vortex Tracker? (There is also AY8930, which VGM format supports and VGMCK can be used to write music for it, but VGMPlay does not yet support. Is your program compatible with AY8930?)

_________________
.


Top
 Profile  
 
PostPosted: Sun Apr 21, 2013 10:26 pm 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Quote:
Can it be used with VGM too?

That might be difficult, but it would depend on how the VGM had been generated. If the whole file looked like write-reg0 write-reg1 ... write-reg13 wait-frame it would probably be doable, otherwise it might not be.

Quote:
What programs are there to write musics for this chips other than ppMCK and VGMCK and Vortex Tracker?

maxYMizer comes to mind. There are probably a lot of other ones. I'm not all that familiar with the Atari ST or Spectrum scene.

Quote:
Is your program compatible with AY8930?

If you only use its AY-3-8910 compatibility mode, then yes. But it won't play anything that uses the extra registers.


Top
 Profile  
 
PostPosted: Mon Apr 22, 2013 1:55 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
I've posted a short write-up that goes into some detail on the YM/AY chip and the NGPC hardware, and then describes how the player works.


Top
 Profile  
 
PostPosted: Mon Apr 22, 2013 10:58 am 
Online
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 929
mic_ wrote:
Quote:
Can it be used with VGM too?

That might be difficult, but it would depend on how the VGM had been generated. If the whole file looked like write-reg0 write-reg1 ... write-reg13 wait-frame it would probably be doable, otherwise it might not be.
Maybe it is possible to convert other features into write-reg0 write-reg1 etc and then convert to .YM format, possibly

Quote:
Quote:
Is your program compatible with AY8930?

If you only use its AY-3-8910 compatibility mode, then yes. But it won't play anything that uses the extra registers.
Same as VGMPlay; it doesn't currently support the extra registers either. Do you know of a program that does support it? (preferable open-source, and that might be made to work with VGMPlay; otherwise, it still may be possible to convert .VGM into another format supported by other program, so that you can use VGMCK to write music of AY8930 and convert it to play in the other program)

You say if 7-Zip is installed you can right-click the file; I have the command-line program installed and just typing in "7z x" and the filename will extract it. (Note: Don't download the "command-line only" version, which omits many features; download the full version, it includes the full-featured command-line program. However, if you don't want the GUI you can delete that and the command-line still works.)

_________________
.


Top
 Profile  
 
PostPosted: Tue Apr 23, 2013 1:39 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Quote:
Maybe it is possible to convert other features into write-reg0 write-reg1 etc and then convert to .YM format, possibly

If they use short delays to write to the chip multiple times per frame my player wouldn't support it. If the VGM file only contains YM/AY register write commands and "wait one frame"-commands it will practically be the same as an .YM file and then it would be easy to support it.

Quote:
Do you know of a program that does support [the AY8930]?

No.

Quote:
I have the command-line program installed and just typing in "7z x" and the filename will extract it.

Oh, ok. That's nice. I only ever use the GUI version for Windows and Ubuntu.


Top
 Profile  
 
PostPosted: Fri Oct 04, 2013 12:17 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2295
Quote:
So what I do instead is to generate PCM data and output it to the NGPC's 8-bit audio DACs. This is of course a lot more CPU-intensive, so I had to settle for very low sample rates. Currently the maximum output sample rate I've been able to use is 8 kHz. The NGPC's main CPU (a TLCS-900/H) runs at 6.144 MHz, with every two cycles making up one CPU state. At an 8 kHz sample rate this gives me 3072000/8000 = 384 states per sample. The fastest instructions take 2 states to complete, but most take more.


Does that mean the 6 Mhz TLCS-900/H in the NGPC is roughly the same speed as the 12 Mhz 68000 in the "full sized" Neo Geo?


Top
 Profile  
 
PostPosted: Fri Oct 04, 2013 12:41 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19114
Location: NE Indiana, USA (NTSC)
A 68000 has four cycles per state, but I seem to remember that the fastest instructions finish in one state. Correct me if I'm wrong though.


Top
 Profile  
 
PostPosted: Fri Oct 04, 2013 5:03 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2295
I misread 2 states as 2 cycles.


Top
 Profile  
 
PostPosted: Sat Oct 05, 2013 1:31 am 
Offline
User avatar

Joined: Wed Feb 13, 2008 9:10 am
Posts: 578
Location: Estonia, Rapla city (50 and 60Hz compatible :P)
Most instructions that operate on registers alone take 4 cycles. Most common instructions go from 4 to 20 in steps of 2 cycles, all comes down to the addressing modes used and whether or not you deal with byre/word or longs. Every byte/word access is 4 cycles, longs take 8 cycles. Register operations don't normally add extra cycles, arithmetic adds in steps of 2, depending on operation. Address register increment comes for free, and arranging your data for sequential access makes things lovely.

_________________
http://www.tmeeco.eu


Top
 Profile  
 
PostPosted: Sat Oct 05, 2013 4:46 am 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2295
So basically the 68000 and TLCS-900/H are about the same performance wise?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group