Skip to content

Experimental PSG packer and Z80 player for ZX Spectrum

Notifications You must be signed in to change notification settings

jounikor/psgpacker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

psgpacker v0.8 - an experimental PSG packer and Z80 player for ZX Spectrum

The psgpacker.py requires python3 to run. It coverts PSG files for AY-3-8910 into
a compact (compressed) form and the companion player written in Z80 assembly 
depacks the compressed file on fly before outputting data to AY.

The player is divided into two parts: 
 - Depack next frame of AY register data. This routine has variable cycle count.
 - Play depacked AY register data. This routine is cycle exact (562 at the moment).
This arrangement is made to allow using music with raster/timing critical effects.

usage: psgpacker.py [-h] [--verbose] [--debug] [--lz] [--multi] [--oneput]
                    [--bankswitch] [--cache]
                    input_file [output_file]

positional arguments:
  input_file        PSG file or '' if stdin
  output_file       Output file or stdout if missing

optional arguments:
  -h, --help        show this help message and exit
  --verbose, -v     Show some process output
  --debug           Show debug output
  --lz, -z          Enable history references
  --multi, -m       Enable multi-frame matches of history references
  --oneput, -o      Enable single changed register output
  --bankswitch, -b  Add 16K bank boundary marks
  --cache, -c       Cache most used AY register writes

To init player:
   LD   HL,bankswitch_callback
   CALL psgplayer+6

To unpack a frame:
   CALL psgplayer+4 (variable cycles)

To update AY registers (cycle exact):
    CALL psgplayer+0

To stop music:
   CALL psgplayer+2
   CALL psgplayer+0

Note 1: that the '_regbuf' really needs to be 256 byte aligned.
Note 2: the player has the following assumptions on the bank switching callback function:
- The callback MUST return the module address in HL and "wait" amount in A.
- On entry A = 0 if this was called by the _init/_stop function.
           A > 0 then this was called for a bankswitch.
           D = HIGH(_regbuf) = HIGH(_cache)
Note 3: The _init and _stop functions actually call the callback to get the module ptr.

The psgplayer.asm has the following assembly time switches:
USE_CACHE - This must be set to 1 if PSGPacker used --cache and must be 0 otherwise
USE_ONEPUT - This must be set to 1 if PSGPacker used --oneput

About

Experimental PSG packer and Z80 player for ZX Spectrum

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published