URL
https://opencores.org/ocsvn/rtf65002/rtf65002/trunk
Subversion Repositories rtf65002
[/] [rtf65002/] [trunk/] [software/] [asm/] [Piano.asm] - Rev 40
Compare with Previous | Blame | View Log
; ============================================================================; __; \\__/ o\ (C) 2013, 2014 Robert Finch, Stratford; \ __ / All rights reserved.; \/_// robfinch<remove>@opencores.org; ||;;; This source file is free software: you can redistribute it and/or modify; it under the terms of the GNU Lesser General Public License as published; by the Free Software Foundation, either version 3 of the License, or; (at your option) any later version.;; This source file is distributed in the hope that it will be useful,; but WITHOUT ANY WARRANTY; without even the implied warranty of; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; GNU General Public License for more details.;; You should have received a copy of the GNU General Public License; along with this program. If not, see <http://www.gnu.org/licenses/>.;; Piano.asm; ============================================================================;;--------------------------------------------------------------------------;--------------------------------------------------------------------------;public Piano:jsr RequestIOFocuslda #15 ; master volume to maxsta PSG+64playnt:jsr KeybdGetCharcmp #CTRLCbeq PianoXcmp #'a'beq playnt1acmp #'b'beq playnt1bcmp #'c'beq playnt1ccmp #'d'beq playnt1dcmp #'e'beq playnt1ecmp #'f'beq playnt1fcmp #'g'beq playnt1gbra playntPianoX:jsr ReleaseIOFocusrtsplaynt1a:ld r4,#7217bra playntaplaynt1b:ld r4,#8101bra playntaplaynt1c:ld r4,#4291bra playntaplaynt1d:ld r4,#4817bra playntaplaynt1e:ld r4,#5407bra playntaplaynt1f:ld r4,#5728bra playntaplaynt1g:ld r4,#6430playntalda #1 ; priority 1ldx #0 ; no flagsldy #Toneld r5,#5 ; associate with JCB #5int #4db 1 ; start taskbra playnt; The PSG supports four voices, so we use all the voices in succession.; The Tone task is reentrant. Multiple copies of the tone task may be; playing tones at the same time.;Tone:phaphxinc tone_cntldx tone_cntand r2,r2,#3asl r2,r2,#2 ; PSG has groups of four registerssta PSGFREQ0,x; decay (16.384 ms)2; attack (8.192 ms)1; release (1.024 s)A; sustain level Clda #0xCA12sta PSGADSR0,xlda #0x1104 ; gate, output enable, triangle waveformsta PSGCTRL0,xlda #20 ; delay about 100msint #4db 5 ; Sleep; jsr Delay10lda #0x0104 ; gate off, output enable, triangle waveformsta PSGCTRL0,xlda #20 ; delay about 100msint #4db 5 ; Sleep; jsr Delay10lda #0x0000 ; gate off, output enable off, no waveformsta PSGCTRL0,xplxplarts; This routine used when Sleep() didn't work.Delay10:lda #500000dly10a:deabne dly10arts
