dos33fsprogs/pt3_lib
Vince Weaver ebd8329600 pt3_lib: update to version 0.2
includes more documentation and Mockingboard slot detection
2019-12-28 22:35:14 -05:00
..
empty.dsk pt3_lib: add directory with just the pt3 player 2019-06-07 15:18:51 -04:00
hardware.inc pt3_lib: clean up zero-page usage 2019-06-10 14:08:17 -04:00
hello.bas pt3_lib: update to version 0.2 2019-12-28 22:35:14 -05:00
interrupt_handler.s pt3: create combined version for pt3_lib and pt3_player 2019-09-11 16:08:36 -04:00
Makefile pt3_lib: update the detection code 2019-12-28 18:04:19 -05:00
pt3_lib_core.s pt3_lib: update to version 0.2 2019-12-28 22:35:14 -05:00
pt3_lib_init.s pt3: create combined version for pt3_lib and pt3_player 2019-09-11 16:08:36 -04:00
pt3_lib_irq_handler.s pt3_lib: use 6522 defines everywhere 2019-12-28 19:47:40 -05:00
pt3_lib_mockingboard_detect.s pt3_lib: update to version 0.2 2019-12-28 22:35:14 -05:00
pt3_lib_mockingboard_setup.s pt3_lib: update to version 0.2 2019-12-28 22:35:14 -05:00
pt3_lib.dsk pt3_lib: update to version 0.2 2019-12-28 22:35:14 -05:00
pt3_test.s pt3_lib: update to version 0.2 2019-12-28 22:35:14 -05:00
README.pt3_lib pt3_lib: update to version 0.2 2019-12-28 22:35:14 -05:00
zp.inc pt3_lib: update to version 0.2 2019-12-28 22:35:14 -05:00

The PT3_player Library	version 0.2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	by Vince "Deater" Weaver <vince@deater.net>
	http://www.deater.net/weave/vmwprod/pt3_lib/

	Last Update: 28 December 2019

	Plays Vortex Tracker II .pt3 files on the Apple II

Background:
~~~~~~~~~~~

This code is meant as a relatively simple, reasonably optimized version
of the PT3 Vortex-Tracker player for use in other programs.

A much more optimized version can be found in ../pt3_player/
That codebase has been *extremely* optimized to the point it's no longer
very straightforward to reuse the code.

For some more background on this you can watch the talk I gave
at Demosplash 2019 on this topic.


What is a PT3 file?
~~~~~~~~~~~~~~~~~~~

A PT3 file is a tracker format with a compact file size used on systems
with AY-3-8910 based audio.  This is most commonly the ZX-spectrum
and Atari ST machines.

Originally most PT3 players were in z80 assembly language for use on Z80
based machines.  I have written code that will play the files on modern
systems (using C) and also the included code designed for the 6502-based
Apple II machines with Mockingboard sound cards installed.

You can find many pt3 files on the internet, or you can use the
VortexTracker tracker to write your own.


Using the Code (irq driven):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

See the "pt3_test.s" example.

The code is in cc65 6502 assembly language but should be relatively 
easy to port to other assemblers.

To get a pt3 file playing:
	+ Optionally include "pt3_lib_mockingboard_detect.s" and
		call "mockingboard_detect" and "mockingboard_patch" if
		you want to auto-detect which slot the mockingboard is in.
		Otherwise it will default to Slot#4
		The patch code does a vaguely unsafe find/replace of $C4
		live patch of the slot values, if you want a safer (but much
		larger) version you can go into the file and ifdef out
		the right code.
	+ Be sure to either include the pt3 file as a binary, or load
		it from disk to a buffer pointed to by PT3_LOC.
		Not the beginning of the song needs to be aligned on
		a page boundary (this makes the decode code a bit
		more simple)
	+ If you want to make the code more compact but use a lot of
		the zero page, you can set PT3_USE_ZERO_PAGE in
		"pt3_lib_core.s"  This will use zp $80-$FF
		but make the pt3 code a bit faster/smaller
	+ You can set the interrupt speed in pt3_lib_mockingboard_setup.s
		Generally files you find online are 50Hz.
		For less overhead you can set something like 25Hz but
		in that case you'll want to adjust the speed in the
		tracker otherwise the songs will play at the wrong speed.
	+ Vortex tracker by default assumes a system with a 1.77MHz
		clock and sets frequencies accordingly.  The Mockingboard
		runs at 1MHz, so the pt3_lib converts on the fly.
		For less overhead you can have the tracker generate
		1MHz music and strip out the 1.77MHz conversion code.
	+ If you want the music to Loop then set the LOOP value to 1.
	

Using the Code (cycle-counted):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I started work on a cycle-counted (deterministic cycle count) pt3
decoder, but it turned out to be large and complex enough to not be
worth the trouble.

You can still use pt3 files in cycle-counted demos.  See the
../demosplash2019/ directory for an example.  What this code does
is decode the pt3 files to memory during non-cycle-counted times,
and then use a deterministic playback function to play back this music.
Each frame of music decodes to 11bytes of register info, which means
at 60Hz you can get roughly 4s of music per 3kB of RAM.


Overhead:
~~~~~~~~~

It depends exactly on what features you use, but in general it will use
around 3KB of RAM plus the size of the PT3 file (which is often a few K).
Playback overhead depends on the complexity of the sound file but is typically
in the 10% to 15% range when playing back at 50Hz.

The player also uses 26 zero-page locations.  More compact/faster code
can be generated if you're willing to sacrifice 128+ zero page locations.