SCC, PSG and KSS help is needed

Pagina 2/2
1 |

Van NYYRIKKI

Enlighted (6016)

afbeelding van NYYRIKKI

25-06-2011, 23:08

I would like to learn more about 'making KSS-header' and 'compile the replayer routine'.

Here is extremely simple and minimal example that outputs perfectly valid KSS-file:



          output "KSSTEST.KSS"

; KSS-file header:
;-----------------

        DB "KSCC"
        DW beginProgram ; (Load address)
        DW endProgram-beginProgram ; (Lenght)
        DW beginProgram ; (Init)
        DW INT          ; (Play)
	DB 0,0,0,0


; Extremely simple example replay routine:
;-----------------------------------------

INTERVAL  EQU   20

	org #100

beginProgram:

        RET  ; Init points here, but this routine does not really need any init.

;------ Some internal variables... look forward

TEMP:    DB INTERVAL
POINTER: DW DATA

;----- interrupt routine -----


INT:	PUSH	AF  ; This routine is called 50 or 60 times / sec

        LD A,(TEMP)
        DEC A
        LD (TEMP),A
        JR NZ,.EXIT ; Is it time to make do something ? No -> return
        CALL DOSOUND  ; Yes -> read data
        LD A,INTERVAL ; How often the effect on should be called (20 in this example)
        LD (TEMP),A
.EXIT:
 	POP	AF
	RET
	

DOSOUND:
        LD HL,(POINTER)
        LD A,(HL)
        INC HL
        LD (POINTER),HL

        CP 254
        JR NZ,.SKIP
        LD DE,DATA
        LD (POINTER),DE
        JR DOSOUND

.SKIP:
        CP 255
        RET Z

        LD E,(HL)
        INC HL
        LD (POINTER),HL

        CALL 147               ;This routine is automatically supported by KSS also

        JR DOSOUND
        
DATA:   ; Music data for the player
;-----------------------------------------
        DB 0,0, 1,1
        DB 7,136 ,8,15 ,255
        DB 1,2, 8,11, 255,255
        DB 8,0, 255,255,255
        DB 254
        
endProgram:
Pagina 2/2
1 |