Simple example

If you're working in Z80, this page is for you. There are already ready-to-use testers in the AT2 package ("players/playerAkg/sources/tester", to name only one), but here is a very simple example of how the players work.

We will use AKG player here, which is the "generic" player, but the other players work the same way.

This page is made to be straightforward, so let's be concise.

Export of the song via command line

Let's use the command line tools to export your song. You can do it from the graphic interface inside the software, but we want to go fast!

There are many example songs, but let's focus on "Targhan - A Harmless Grenade.aks" located in the songs\ArkosTracker2\3Channels folder.

The command line tools are located in the tools folder. The following command will create the source code of the exported music, which we call music.asm. The input file is of course, the music we talked about just above:

SongToAkg.exe "Targhan - A Harmless Grenade.aks" music.asm

Assemble the whole

The AKG player is located in the players\playerAkg\sources folder, and named PlayerAkg.asm. Let's create a wrapper around it to play the song every 50hz. We use Rasm to assemble. If you want to use any other assembler, please check this tutorial.

This sample targets the Amstrad CPC, but choosing a MSX, Spectrum or anything else works exactly the same. The only specific code is the wait for the frame flyback. Please adapt it according to your target computer.

    org #1000

;Moves the system out of the way.
di
ld hl,#c9fb
ld (#38),hl
ld sp,$ ;Put the stack out of the way (it can destroy the beginning of our code, we don't care).

;Let's initialize the song.
ld hl,MusicStart ;Declared below.
xor a ;Subsong 0 (the main one).
call PLY_AKG_Init

;Wait for the frame flyback.
;On CPC, we do it this way:
Sync:
ld b,#f5
Sync2: in a,(c)
rra
jr nc,Sync2
ei
nop
halt
halt
di

;Let's play our song!
call PLY_AKG_Play
jr Sync

;Of course, we need to include the player and the music to play.
;Uncomment the target you want. Declare this BEFORE the player is included.
PLY_AKG_HARDWARE_CPC = 1
;PLY_AKG_HARDWARE_MSX = 1
;PLY_AKG_HARDWARE_SPECTRUM = 1
;PLY_AKG_HARDWARE_PENTAGON = 1

include "PlayerAkg.asm"
MusicStart: include "music.asm"

That's it! Just execute this code, starting in 0x1000 and music will be heard!