AMP16K: Multichannel beeper sound on the ZX Spectrum 16K

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
Nienn Heskil
Microbot
Posts: 132
Joined: Tue Jun 09, 2020 6:14 am
Contact:

AMP16K: Multichannel beeper sound on the ZX Spectrum 16K

Post by Nienn Heskil »

User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: AMP16K: Multichannel beeper sound on the ZX Spectrum 16K

Post by Ast A. Moore »

Awesome. This could be perfect for moderately animated menus and such.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
uglifruit
Manic Miner
Posts: 700
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Re: AMP16K: Multichannel beeper sound on the ZX Spectrum 16K

Post by uglifruit »

This is great.
CLEAR 23855
Nienn Heskil
Microbot
Posts: 132
Joined: Tue Jun 09, 2020 6:14 am
Contact:

Re: AMP16K: Multichannel beeper sound on the ZX Spectrum 16K

Post by Nienn Heskil »

Ast A. Moore wrote: Wed Sep 23, 2020 11:08 am Awesome. This could be perfect for moderately animated menus and such.
Cheers. Normally I'd prefer to leave the border alone when it comes to it... However, the inner loop of the original AMP was exactly 7T slower than necessary for this purpose, which meant one AND opcode was definitely out. :P

Because of memory issues, I don't think such an engine is practical in a 16K game, at least currently. Although the song data format is more optimal than e.g. that of Tritone, it's still 4 bytes per row in the best case, so the song data grows fairly fast. I thought of giving compression a try sometime - I suppose we'll see about that. (Of course there's always the option to use less channels and everything).
Nienn Heskil
Microbot
Posts: 132
Joined: Tue Jun 09, 2020 6:14 am
Contact:

Re: AMP16K: Multichannel beeper sound on the ZX Spectrum 16K

Post by Nienn Heskil »

At the moment, I've changed the pattern row format a little, and it seems quite effective. Even without compression, I was able to save about 2,5K of row data on "Na Zare". The new format is:
+0: %nnnn dddd, - Note map, Drum (if present; codes 2~15). Note map is 4 bits saying if there's a note for the corresponding channel on this row.
+1..+N: Channel note/volume data (if present). One byte each. If bit 7 of a note is set, it means a volume byte follows.

Speaking of compression, I'm not really sure which one would work well here. I've tried DTE previously with the old format, which resulted in similar savings, but I'm not too keen on unpacking it in realtime in this context. And row-based dictionary compression didn't seem too effective. Who knows, it might just be fine as is. :)
User avatar
utz
Microbot
Posts: 114
Joined: Wed Nov 15, 2017 9:04 am
Contact:

Re: AMP16K: Multichannel beeper sound on the ZX Spectrum 16K

Post by utz »

Congratulations on reaching this milestone! Excellent work.

I think your current data layout would indeed be fine as is, provided you use an order list with it (not just one single long pattern).

Any chance for releasing the source code? Preferably under a permissive license (MIT, BSD, WTFPL), would like to include this in Bintracker.
Nienn Heskil
Microbot
Posts: 132
Joined: Tue Jun 09, 2020 6:14 am
Contact:

Re: AMP16K: Multichannel beeper sound on the ZX Spectrum 16K

Post by Nienn Heskil »

Thanks, and sure enough, we do use pattern lists here. :)

Re: source code, no problem. Once I consider it sufficiently finished, I'll release the proper package with documentation, a standalone XM converter and everything. Most of that is already done, so it shouldn't take too long.
Nienn Heskil
Microbot
Posts: 132
Joined: Tue Jun 09, 2020 6:14 am
Contact:

Re: AMP16K: Multichannel beeper sound on the ZX Spectrum 16K

Post by Nienn Heskil »

And done. Post updated with the full archive.
Post Reply