OpenCores
URL https://opencores.org/ocsvn/rtf65002/rtf65002/trunk

Subversion Repositories rtf65002

[/] [rtf65002/] [trunk/] [software/] [asm/] [Piano.asm] - Blame information for rev 40

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 40 robfinch
 
2
; ============================================================================
3
;        __
4
;   \\__/ o\    (C) 2013, 2014  Robert Finch, Stratford
5
;    \  __ /    All rights reserved.
6
;     \/_//     robfinch@opencores.org
7
;       ||
8
;
9
;
10
; This source file is free software: you can redistribute it and/or modify
11
; it under the terms of the GNU Lesser General Public License as published
12
; by the Free Software Foundation, either version 3 of the License, or
13
; (at your option) any later version.
14
;
15
; This source file is distributed in the hope that it will be useful,
16
; but WITHOUT ANY WARRANTY; without even the implied warranty of
17
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
; GNU General Public License for more details.
19
;
20
; You should have received a copy of the GNU General Public License
21
; along with this program.  If not, see .
22
;
23
; Piano.asm
24
; ============================================================================
25
;
26
;--------------------------------------------------------------------------
27
;--------------------------------------------------------------------------
28
;
29
public Piano:
30
        jsr             RequestIOFocus
31
        lda             #15                             ; master volume to max
32
        sta             PSG+64
33
playnt:
34
        jsr             KeybdGetChar
35
        cmp             #CTRLC
36
        beq             PianoX
37
        cmp             #'a'
38
        beq             playnt1a
39
        cmp             #'b'
40
        beq             playnt1b
41
        cmp             #'c'
42
        beq             playnt1c
43
        cmp             #'d'
44
        beq             playnt1d
45
        cmp             #'e'
46
        beq             playnt1e
47
        cmp             #'f'
48
        beq             playnt1f
49
        cmp             #'g'
50
        beq             playnt1g
51
        bra             playnt
52
PianoX:
53
        jsr             ReleaseIOFocus
54
        rts
55
 
56
playnt1a:
57
        ld              r4,#7217
58
        bra             playnta
59
playnt1b:
60
        ld              r4,#8101
61
        bra             playnta
62
playnt1c:
63
        ld              r4,#4291
64
        bra             playnta
65
playnt1d:
66
        ld              r4,#4817
67
        bra             playnta
68
playnt1e:
69
        ld              r4,#5407
70
        bra             playnta
71
playnt1f:
72
        ld              r4,#5728
73
        bra             playnta
74
playnt1g:
75
        ld              r4,#6430
76
playnta
77
        lda             #1      ; priority 1
78
        ldx             #0      ; no flags
79
        ldy             #Tone
80
        ld              r5,#5                   ; associate with JCB #5
81
        int             #4
82
        db              1                               ; start task
83
        bra             playnt
84
 
85
; The PSG supports four voices, so we use all the voices in succession.
86
; The Tone task is reentrant. Multiple copies of the tone task may be
87
; playing tones at the same time.
88
;
89
Tone:
90
        pha
91
        phx
92
        inc             tone_cnt
93
        ldx             tone_cnt
94
        and             r2,r2,#3
95
        asl             r2,r2,#2                ; PSG has groups of four registers
96
        sta             PSGFREQ0,x
97
        ; decay  (16.384 ms)2
98
        ; attack (8.192 ms)1
99
        ; release (1.024 s)A
100
        ; sustain level C
101
        lda             #0xCA12
102
        sta             PSGADSR0,x
103
        lda             #0x1104                 ; gate, output enable, triangle waveform
104
        sta             PSGCTRL0,x
105
        lda             #20                             ; delay about 100ms
106
        int             #4
107
        db              5                               ; Sleep
108
;       jsr             Delay10
109
        lda             #0x0104                 ; gate off, output enable, triangle waveform
110
        sta             PSGCTRL0,x
111
        lda             #20                             ; delay about 100ms
112
        int             #4
113
        db              5                               ; Sleep
114
;       jsr             Delay10
115
        lda             #0x0000                 ; gate off, output enable off, no waveform
116
        sta             PSGCTRL0,x
117
        plx
118
        pla
119
        rts
120
 
121
; This routine used when Sleep() didn't work.
122
Delay10:
123
        lda             #500000
124
dly10a:
125
        dea
126
        bne             dly10a
127
        rts

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.