Z80 ASM library (and C conversion/compression tools) to allow replay of VGMs as background music/SFX in SEGA 8 bit homebrew programs
Typical workflow:
-
You (or a friend of yours) track one or more module(s) and SFX(s) using either Mod2PSG2 or DefleMask or VGM Music Maker (or whatever tool you prefer as long as it supports exporting in VGM format).
-
Optional, but warmly suggested: optimize your VGM(s) using Maxim's VGMTool
-
Convert the VGM to PSG file(s) using the vgm2psg tool.
-
Optional, suggested: compress the PSG file(s) using the psgcomp tool. The psgdecomp tool can be used to verify that the compression was right.
-
include the library and 'incbin' the PSG file(s) to your Z80 ASM source.
-
call PSGInit once somewhere near the beginning of your code.
-
Set up a steady interrupt (vertical blanking for instance) so to call PSGFrame and PSGSFXFrame at a constant pace (very important!). The two calls are separated so you can eventually switch banks when done processing background music and need to process SFX.
-
Start/stop tunes when needed using PSGPlay and PSGStop calls, start/stop SFXs when needed using PSGSFXPlay and PSGSFXStop calls.
-
Looping SFXs are supported too: fire them using a PSGSFXPlayLoop call, cancel their loop using a PSGSFXCancelLoop call.
-
Tunes can be set to run just once instead of endlessly using PSGPlayNoRepeat call, or set a playing tune to have no more loops using PSGCancelLoop call at any time.
-
To check if a tune is still playing use PSGGetStatus call, to check if a SFX is still playing use PSGSFXGetStatus call.