TESTSSG.ASM
Play a 12 note scale starting at middle C on a CoCoPSG in Multi-Pak slot 1:
;********************************************************************* ;* Title: testssg.asm ;********************************************************************* ;* Author: R. Allen Murphey ;* ;* Description: Support for Ed Snider's CoCoPSG Cart ;* ;* Documentation: ;* AY-3-8910 PC6001 CHANNEL OPERATION ;* R1/R0 R1/R0 A Tone Generator Control 1-4095 ;* R3/R2 R3/R2 B Tone Generator Control 1-4095 ;* R5/R4 R5/R4 C Tone Generator Control 1-4095 ;* R6 R6 - Noise Generator Control 1-31 ;* R7 R7 - Mixer Control / I/O Enable ;* IOA|IOB|NOISEC|NOISEB|NOISEA|TONEC|TONE|TONEA ;* R10 R8 A Amplitude Control ;* x|x|x|M|L3|L2|L1|L0 ;* R11 R9 B Amplitude Control ;* x|x|x|M|L3|L2|L1|L0 ;* R12 R10 C Amplitude Control ;* x|x|x|M|L3|L2|L1|L0 ;* R14/R13 R12/R11 - Envelope Period Control 1-65535 ;* R15 R13 - Envelope Shape / Cycle Control ;* x|x|x|x|CONT|ATT|ALT|HOLD ;* ;* Include Files: none ;* ;* Assembler: lwasm 1.4.2 ;* lwasm -o testssg.bin testssg.asm ;* decb dskinit testssg.dsk OR ;* decb kill testssg.dsk,TESTSSG.BIN ;* decb copy testssg.bin testssg.dsk,TESTSSG.BIN -2 ;* LOADM"TESTSSG":EXEC ;* ;* Revision History: ;* Rev # Date Who Comments ;* ----- ----------- ------ --------------------------------------- ;* 00 2020 RAM Initial note table ;********************************************************************* skip2 equ $8C ; use CMPX # to skip next 2 bytes SSGPORTA: equ $FF5E SSGPORTB: equ $FF5F SSGTONAL: equ $00 SSGTONAH: equ $01 SSGTONBL: equ $02 SSGTONBH: equ $03 SSGTONCL: equ $04 SSGTONCH: equ $05 SSGNOISE: equ $06 SSGMIXER: equ $07 SSGVOLA: equ $08 SSGVOLB: equ $09 SSGVOLC: equ $0A SSGENVLO: equ $0B SSGENVHI: equ $0C SSGENVSH: equ $0D SSGIOA: equ $0E SSGIOB: equ $0F org $7000 SSGTEST: ; SETUP ; switch MPI to slot 1 lda $FF7F anda #$F0 sta $FF7F ; enable CART sound on MUX lda #$34 ; MUX SEL 1 sta $FF01 ; MUX Select Lo lda #$3F ; MUX SEL 2 sta $FF03 ; MUX Select Hi lda #$38 ; Enable SNDEN sta $FF23 ; SNDEN ; MAIN clrb ldy #SSGNOTES1 ; PLAYSSG: lda #SSGTONAH ; SSG Tone A Lower 8 bits sta SSGPORTA ; write to SSG to latch register 1 bsr WDELAY ; write delay ; lda b,y ; load upper 4 bits of note sta SSGPORTB ; write to SSG register 1 bsr WDELAY ; write delay ; lda #SSGTONAL ; SSG Tone A Upper 4 bits register 1 sta SSGPORTA ; write to SSH to latch register 1 bsr WDELAY ; incb ; move to next value in note table lda b,y ; load it from table sta SSGPORTB ; write the lower eight bits of note bsr WDELAY ; write delay ; lda #SSGMIXER ; SSG IO port and mixer settings Register 7 sta SSGPORTA ; write to register latch bsr WDELAY ; write delay ; lda #%11111110 ; Enable Tone A with bit zero 0 sta SSGPORTB ; write mixer out bsr WDELAY ; write delay ; lda #SSGVOLA ; SSG Level of Channel A Register 8 sta SSGPORTA ; write Channel A volume register to SSG bsr WDELAY ; write delay ; lda #%00001111 ; 0% attention (volume full) sta SSGPORTB ; write attenuation message to SSG bsr BDELAY ; big delay while note sounds ; incb ; move to next item in table cmpb #24 ; have we read all 12 x 12bit notes? bne PLAYSSG ; no keep playing notes ; TEARDOWN lda #SSGVOLA ; Register 8 Level of Channel A sta SSGPORTA ; write Channel A volume register to SSG bsr WDELAY ; write delay ; lda #%00000000 ; volume off sta SSGPORTB ; turn off volume bsr WDELAY ; write delay rts BDELAY: ldx #$4000 bra WDELAY2 WDELAY: ldx #$08 WDELAY2: leax -1,X bne WDELAY2 rts SSGNOTES1: ; Tone Periods at 1MHz clock fcb $00,$EF ; C4 261.626 Hz Middle C fcb $00,$E1 ; C#4 277.183 Hz fcb $00,$D5 ; D4 293.665 Hz fcb $00,$C9 ; D#4 311.127 Hz fcb $00,$BE ; E4 329.628 Hz fcb $00,$B3 ; F4 349.228 Hz fcb $00,$A9 ; F#4 369.994 Hz fcb $00,$9F ; G4 391.995 Hz fcb $00,$96 ; G#4 415.305 Hz fcb $00,$8E ; A4 440.000 Hz fcb $00,$86 ; A#4 466.164 Hz fcb $00,$7F ; B4 493.883 Hz SSGNOTES2: ; Tone Periods at 2MHz clock fcb $01,$DE ; C4 261.626 Hz Middle C fcb $01,$C3 ; C#4 277.183 Hz fcb $01,$AA ; D4 293.665 Hz fcb $01,$92 ; D#4 311.127 Hz fcb $01,$7B ; E4 329.628 Hz fcb $01,$66 ; F4 349.228 Hz fcb $01,$52 ; F#4 369.994 Hz fcb $01,$3F ; G4 391.995 Hz fcb $01,$2D ; G#4 415.305 Hz fcb $01,$1C ; A4 440.000 Hz fcb $01,$0C ; A#4 466.164 Hz fcb $00,$FD ; B4 493.883 Hz END SSGTEST ;********************************************************************* ;* End of testssg.asm ;*********************************************************************
RTS
Return to Tandy Color Computer or CoCoPSG