1 /*        $NetBSD: oplreg.h,v 1.6 2008/04/28 20:23:51 martin Exp $    */
2 
3 /*
4  * Copyright (c) 1997 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Lennart Augustsson (augustss@NetBSD.org).
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /* Offsets from base address */
33 #define OPL_L                                     0
34 #define OPL_R                                     2
35 
36 /* Offsets from base+[OPL_L|OPL_R] */
37 #define OPL_STATUS                      0
38 #define   OPL_STATUS_IRQ                0x80
39 #define   OPL_STATUS_FT1                0x40
40 #define   OPL_STATUS_FT2                0x20
41 #define   OPL_STATUS_MASK               0xE0
42 #define OPL_ADDR                        0
43 #define OPL_DATA                        1
44 
45 #define OPL_TEST                        0x01
46 #define   OPL_ENABLE_WAVE_SELECT        0x20
47 
48 #define OPL_TIMER1                      0x02
49 #define OPL_TIMER2                      0x03
50 
51 #define OPL_TIMER_CONTROL               0x04      /* Left */
52 #define   OPL_TIMER1_START              0x01
53 #define   OPL_TIMER2_START              0x02
54 #define   OPL_TIMER2_MASK               0x20
55 #define   OPL_TIMER1_MASK               0x40
56 #define   OPL_IRQ_RESET                           0x80
57 
58 #define OPL_CONNECTION_SELECT           0x04      /* Right */
59 #define   OPL_NOCONNECTION              0x00
60 #define   OPL_R_4OP_0                             0x01
61 #define   OPL_R_4OP_1                             0x02
62 #define   OPL_R_4OP_2                             0x04
63 #define   OPL_L_4OP_0                             0x08
64 #define   OPL_L_4OP_1                             0x10
65 #define   OPL_L_4OP_2                             0x20
66 
67 #define OPL_MODE                        0x05      /* Right */
68 #define   OPL3_ENABLE                             0x01
69 #define   OPL4_ENABLE                             0x02
70 
71 #define OPL_KBD_SPLIT                             0x08      /* Left */
72 #define   OPL_KEYBOARD_SPLIT            0x40
73 #define   OPL_COMPOSITE_SINE_WAVE_MODE  0x80
74 
75 #define OPL_PERCUSSION                            0xbd      /* Left */
76 #define   OPL_NOPERCUSSION              0x00
77 #define   OPL_HIHAT                     0x01
78 #define   OPL_CYMBAL                              0x02
79 #define   OPL_TOMTOM                              0x04
80 #define   OPL_SNAREDRUM                           0x08
81 #define   OPL_BASSDRUM                            0x10
82 #define     OPL_PERCUSSION_ENABLE                 0x20
83 #define   OPL_VIBRATO_DEPTH             0x40
84 #define   OPL_TREMOLO_DEPTH             0x80
85 
86 /*
87  * Offsets to the register banks for operators.
88  */
89 /* AM/VIB/EG/KSR/Multiple (0x20 to 0x35) */
90 #define OPL_AM_VIB                      0x20
91 #define   OPL_KSR                       0x10
92 #define   OPL_SUSTAIN                             0x20
93 #define   OPL_VIBRATO                             0x40
94 #define   OPL_TREMOLO                             0x80
95 #define   OPL_MULTIPLE_MASK             0x0f
96 
97 /* KSL/Total level (0x40 to 0x55) */
98 #define OPL_KSL_LEVEL                             0x40
99 #define   OPL_KSL_MASK                            0xc0      /* Envelope scaling bits */
100 #define   OPL_TOTAL_LEVEL_MASK                    0x3f      /* Strength (volume) of OP */
101 
102 /* Attack / Decay rate (0x60 to 0x75) */
103 #define OPL_ATTACK_DECAY                0x60
104 #define   OPL_ATTACK_MASK               0xf0
105 #define   DECAY_MASK                              0x0f
106 
107 /* Sustain level / Release rate (0x80 to 0x95) */
108 #define OPL_SUSTAIN_RELEASE             0x80
109 #define   OPL_SUSTAIN_MASK              0xf0
110 #define   OPL_RELEASE_MASK              0x0f
111 
112 /* Wave select (0xE0 to 0xF5) */
113 #define OPL_WAVE_SELECT                           0xe0
114 
115 #define OPL_MAXREG                      0xf5
116 
117 /*
118  * Offsets to the register banks for voices.
119  */
120 /* F-Number low bits (0xA0 to 0xA8). */
121 #define OPL_FNUM_LOW                              0xa0
122 
123 /* F-number high bits / Key on / Block (octave) (0xB0 to 0xB8) */
124 #define OPL_KEYON_BLOCK                           0xb0
125 #define     OPL_KEYON_BIT                         0x20
126 #define     OPL_BLOCKNUM_MASK           0x1c
127 #define   OPL_FNUM_HIGH_MASK            0x03
128 
129 /* Feedback / Connection (0xc0 to 0xc8) */
130 #define OPL_FEEDBACK_CONNECTION                   0xc0
131 #define   OPL_FEEDBACK_MASK             0x0e
132 #define   OPL_CONNECTION_BIT            0x01
133 #define   OPL_STEREO_BITS               0x30      /* OPL-3 only */
134 #define     OPL_VOICE_TO_LEFT           0x10
135 #define     OPL_VOICE_TO_RIGHT                    0x20
136 
137 #define OPL2_NVOICE 9
138 #define OPL3_NVOICE 18
139