How to: Play a SKS file in your project

Before going any further, you need to know :

  • The address in memory where you want to put the player code.
  • The address in memory where you want to put the music data.

1/ Compile your SKS

SKS Player GeneratorRun the GenSong utility :
- Disc version is on side A of the full STarKos release, RUN”GS
- |GS (ùGS on french keyboard) if you're using the ROMs
List all SKS files on the discInsert your disk, with the SKS file(s) you want to compile, in the appropriate disc drive and press 1 to list all the SKS files on the current drive to check that your file(s) shows up
SKS Compilation step 3Go back to the menu and press 3 “Load and Compile a song”, the program will ask for the filename of your file.
SKS Compilation step 4Then the address in memory where you want to put the music data
SKS Compilation step 5It will load the song and as soon as the compilation is finished, it will display some infos (size) and ask for Auto or Custom Size. Choose Auto.
SKS Compilation step 6Your compiled file will be saved on the disc, same filename as your song but with a .BIN file extension. If everything is ok, it will say so, otherwise the screen will turn red.

For more detailled informations about compiling STarKos songs, see the documentation FR,EN,DE.

2/ Compile your player

Run the GenPlay utility.

  • Disc version is on side A of the full STarKos release, RUN”GP
  • |GP (ùGP on french keyboard) if you're using the ROMs

Choose 2 - Generate ASM Player

  • Size : &98B bytes
Generate an ASM PlayerThis is the smallest and fastest of the 3 types of STarKos players.

The program will ask for the address in memory where the player will be located and the filename of the generated player.

This player is incompatible with the firmware! It must be used in a firmware-less environnement (most likely a demo or something similar). It does not preserve the CPU secondary register set which is used by the firmware.

Usage

To play the song, you have to call the player periodically (according to the song frequency: 50Hz, 100Hz, 300Hz, etc) :

		; Exemple how to play a 50Hz STarKos song
		; with the ASM Player
 
; address of your STarKos player
sks_player	equ &4000
; address of your STarKos compiled song
sks_songdata	equ &5000
 
		; disable the firmware interrupt service routine
		ld hl,&C9FB	; poke "EI:RET"
		ld (&38),hl	; in the IM1 vector
		im 1		; select IM1 just in case
 
		; Initialize the STarKos player
		ld de,sks_songdata
		call sks_player
 
		; Synchronisation with the frame flyback
		; which should be a 50Hz signal (if no
		; one messed up with the CRTC before =)
wait_vsync	ld b,&F5
		in a,(c)
		rra
		jr nc,wait_vsync+2
 
		; wait for a few 300Hz interrupts
		halt
		halt
		halt
 
		; Set a white raster in the BORDER to "see" how much
		; CPU time the player takes.
		ld bc,&7F10
		out (c),c
		ld c,&4B
		out (c),c
 
		; Play the STarKos song
		call sks_player+3
 
		; Set the BORDER to black
		ld bc,&7F54
		out (c),c
 
		; Exit after 20 seconds
		ld hl,20*50
var_timer	equ $-2
		dec hl
		ld (var_timer),hl
		ld a,h
		or l
		jr nz,wait_vsync
 
		; Stop the STarKos player / Mute sounds
		call sks_player+6
 
		; [...]

Choose 3 - Generate BASIC Player

  • Size : &9A6 bytes
Generate a BASIC PlayerThis player will work in all cases, with or without Firmware, from a BASIC or Assembly program.

The program will ask for the address in memory where the player will be located and the filename of the generated player.

Usage

To use it from assembly, see the ASM Player exemple above, it's exactly the same except that this player is a bit slower and bigger.

From BASIC :

10 MEMORY &3FFF
20 LOAD "SKSBAS.BIN",&4000 ' Load the player
30 LOAD "SONG.BIN",&5000 ' Load the song
40 CALL &4000,&5000 ' Initialize the player
50 ' 50Hz Loop
60 CALL &BD19 ' Wait frame fly back
70 CALL &4003 ' Play the song
80 IF INKEY$<>" " THEN GOTO 60 ' loop until space is pressed
90 CALL &4006 ' Stop player and mute sounds

Choose 4 - Generate INTERRUPTION Player

  • Size : &9FC bytes
Generate an INTERRUPT based playerThis player should be the prefered one to play a STarKos song in a BASIC program (but it will run fine from an assembly program too). The music will run automagically from a firmware interrupt, you won't have to care about periodically calling the player routine.

The program will ask for the address in memory where the player will be located and the filename of the generated player.

This player can not be compiled within the Lower and Upper ROM mapping address space (&0000-&3FFF and &C000-&FFFF).

Usage

From BASIC :

10 MEMORY &3FFF
20 LOAD "SKSINT.BIN",&4000 ' Load the player
30 LOAD "SONG.BIN",&5000 ' Load the song
40 CALL &4000,&5000 ' Initialize the player and start playing the music
50 IF INKEY$<>" " THEN GOTO 50 ' do nothing until space is pressed
90 CALL &4003 ' Stop player and mute sounds

For more detailled informations about the STarKos player generator, see the documentation FR,EN,DE.

documentations/software/starkos/howto.integration.guide.txt · Last modified: 2009/05/13 15:26 by grim