SIX BIT SOUND
EXAMPLE CODE
Note: The following public domain code does not contain the *waveform* or *music note* data.
Many examples of these are available in various Rainbow Magazine articles as well as in the Musica example song files.
;********************************************************************* ;* Title: PLAY.s (c) 1984 Speech Systems. Released to Public Domain. ;********************************************************************* ;* Author: Speech Systems ;* ;* Description: 4-voice player ;* ;* Documentation: See the MUSICA manual ;* pg. 15 for usage and license ;* pg. 19 for memory map and note format ;* pp. 20-22 for source ;* ;* Include Files: none ;* ;* Assembler: lwasm 1.4.2 ;* ;* Revision History: ;* Rev # Date Who Comments ;* ----- ----------- ------ --------------------------------------- ;* 1.0 1984 SS Original Source From Manual ;********************************************************************* PIA0AC equ $ff01 PIA0BC equ $ff03 PIA1AD equ $ff20 PIA1BC equ $ff23 ; org $3f40 ; ($3540 in tape version) PLAY: lda #$3f ; set DP register ($35 in tape version) tfr A,DP setdp $3f ; ($35 in tape version) lda $ff01 ; turn on TV sound port anda #$f7 sta $ff01 lda $ff03 anda #$f7 sta $ff03 lda #$3c sta $ff23 pshs CC ; save condition register orcc #$50 ; disable interrupts ldx #$4400 ; x=note pointer ($3a00 in tape version) lda ,X+ ; load tempo from music sta TEMPO ldd ,X++ ; load tone table high addresses sta <V1PT stb <V2PT ldd ,X++ sta <V3PT stb <V4PT bra NEWNT1 TEST: cmpa #$fe ; test for new wave table pointers bne NEWNOT ldd 0,X ; update wave table pointers sta <V1PT stb <V2PT ldd 2,X sta <V3PT stb <V4PT lda 4,X ; update TEMPO sta <TEMPO NEWNOT: leax 8,X ; advance note pointer NEWNT1: lda ,X+ ; load note duration bmi TEST ; if duration>$7F, not a note beq PLAY2 ; duration=0 if end of music PLAY1: sta <DUR ldb <TEMPO ; save TEMPO stb <TEMPO+1 MAIN: lda [V1PT] ; output voices to sound port adda [V2PT] adca [V3PT] adca [V4PT] sta $ff20 ldd <V1PT+1 ; increment voice pointers addd ,x ; only the LSB and "fractional" std <V1PT+1 ; bytes are changed ldd <V2PT+1 ; second voice addd 2,x std <V2PT+1 ldd <V3PT+1 ; third voice addd 4,x std <V3PT+1 ldd <V4PT+1 ; fourth voice addd 6,x std <V4PT+1 dec <TEMPO+1 ; update tempo counter bne WAIT dec <DUR ; update duration counter beq NEWNOT ldb <TEMPO ; restore tempo counter stb <TEMPO+1 bra MAIN WAIT: leax 0,X ; (to equalize loop times) leax 0,X leax 0,X leax 0,X leax 0,X bra MAIN PLAY2: clra ; return from subroutine tfr A,DP puls CC,PC V1PT rmb $3 ; voice time table pointers V2PT rmb $3 ; only the last 2 bytes are V3PT rmb $3 ; changed; the 3rd byte is V4PT rmb $3 ; "fractional" DUR rmb $1 TEMPO rmb $2 end PLAY
RTS
Return to Tandy Color Computer