Home | History | Annotate | Line # | Download | only in ic
oplreg.h revision 1.1
      1 /*	$NetBSD: oplreg.h,v 1.1 1998/08/17 21:16:13 augustss Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * Author: Lennart Augustsson
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *        This product includes software developed by the NetBSD
     20  *        Foundation, Inc. and its contributors.
     21  * 4. Neither the name of The NetBSD Foundation nor the names of its
     22  *    contributors may be used to endorse or promote products derived
     23  *    from this software without specific prior written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     26  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 /* Offsets from base address */
     39 #define OPL_LO				0
     40 #define OPL_HI				2
     41 
     42 /* Offsets from base+[LO|HI] */
     43 #define OPL_STATUS			0
     44 #define   OPL_STATUS_IRQ		0x80
     45 #define   OPL_STATUS_FT1		0x40
     46 #define   OPL_STATUS_FT2		0x20
     47 #define   OPL_STATUS_MASK		0xE0
     48 #define OPL_ADDR			0
     49 #define OPL_DATA			1
     50 
     51 #define OPL_TEST			0x01
     52 #define   OPL_ENABLE_WAVE_SELECT	0x20
     53 
     54 #define OPL_TIMER1			0x02
     55 #define OPL_TIMER2			0x03
     56 
     57 #define OPL_TIMER_CONTROL		0x04	/* LO */
     58 #define   OPL_TIMER1_START		0x01
     59 #define   OPL_TIMER2_START		0x02
     60 #define   OPL_TIMER2_MASK		0x20
     61 #define   OPL_TIMER1_MASK		0x40
     62 #define   OPL_IRQ_RESET			0x80
     63 
     64 #define OPL_CONNECTION_SELECT		0x04	/* HI */
     65 #define   OPL_NOCONNECTION		0x00
     66 #define   OPL_HI_4OP_0			0x01
     67 #define   OPL_HI_4OP_1			0x02
     68 #define   OPL_HI_4OP_2			0x04
     69 #define   OPL_LO_4OP_0			0x08
     70 #define   OPL_LO_4OP_1			0x10
     71 #define   OPL_LO_4OP_2			0x20
     72 
     73 #define OPL_MODE			0x05	/* HI */
     74 #define   OPL3_ENABLE			0x01
     75 #define   OPL4_ENABLE			0x02
     76 
     77 #define OPL_KBD_SPLIT			0x08	/* LO */
     78 #define   OPL_KEYBOARD_SPLIT		0x40
     79 #define   OPL_COMPOSITE_SINE_WAVE_MODE	0x80
     80 
     81 #define OPL_PERCUSSION			0xbd	/* LO */
     82 #define   OPL_NOPERCUSSION		0x00
     83 #define   OPL_HIHAT			0x01
     84 #define   OPL_CYMBAL			0x02
     85 #define   OPL_TOMTOM			0x04
     86 #define   OPL_SNAREDRUM			0x08
     87 #define   OPL_BASSDRUM			0x10
     88 #define	  OPL_PERCUSSION_ENABLE		0x20
     89 #define   OPL_VIBRATO_DEPTH		0x40
     90 #define   OPL_TREMOLO_DEPTH		0x80
     91 
     92 /*
     93  *	Offsets to the register banks for operators. To get the
     94  *	register number just add the operator offset to the bank offset
     95  *
     96  *	AM/VIB/EG/KSR/Multiple (0x20 to 0x35)
     97  */
     98 #define OPL_AM_VIB			0x20
     99 #define   OPL_KSR			0x10
    100 #define   OPL_SUSTAIN			0x20
    101 #define   OPL_VIBRATO			0x40
    102 #define   OPL_TREMOLO			0x80
    103 #define   OPL_MULTIPLE_MASK		0x0f
    104 
    105  /*
    106   *	KSL/Total level (0x40 to 0x55)
    107   */
    108 #define OPL_KSL_LEVEL			0x40
    109 #define   OPL_KSL_MASK			0xc0	/* Envelope scaling bits */
    110 #define   OPL_TOTAL_LEVEL_MASK		0x3f	/* Strength (volume) of OP */
    111 
    112 /*
    113  *	Attack / Decay rate (0x60 to 0x75)
    114  */
    115 #define OPL_ATTACK_DECAY		0x60
    116 #define   OPL_ATTACK_MASK		0xf0
    117 #define   DECAY_MASK			0x0f
    118 
    119 /*
    120  * Sustain level / Release rate (0x80 to 0x95)
    121  */
    122 #define OPL_SUSTAIN_RELEASE		0x80
    123 #define   OPL_SUSTAIN_MASK		0xf0
    124 #define   OPL_RELEASE_MASK		0x0f
    125 
    126 /*
    127  * Wave select (0xE0 to 0xF5)
    128  */
    129 #define OPL_WAVE_SELECT			0xe0
    130 
    131 #define OPL_MAXREG			0xf5
    132 
    133 /*
    134  *	Offsets to the register banks for voices. Just add to the
    135  *	voice number to get the register number.
    136  *
    137  *	F-Number low bits (0xA0 to 0xA8).
    138  */
    139 #define OPL_FNUM_LOW			0xa0
    140 
    141 /*
    142  *	F-number high bits / Key on / Block (octave) (0xB0 to 0xB8)
    143  */
    144 #define OPL_KEYON_BLOCK			0xb0
    145 #define	  OPL_KEYON_BIT			0x20
    146 #define	  OPL_BLOCKNUM_MASK		0x1c
    147 #define   OPL_FNUM_HIGH_MASK		0x03
    148 
    149 /*
    150  *	Feedback / Connection (0xc0 to 0xc8)
    151  *
    152  *	These registers have two new bits when the OPL-3 mode
    153  *	is selected. These bits controls connecting the voice
    154  *	to the stereo channels. For 4 OP voices this bit is
    155  *	defined in the second half of the voice (add 3 to the
    156  *	register offset).
    157  *
    158  *	For 4 OP voices the connection bit is used in the
    159  *	both halves (gives 4 ways to connect the operators).
    160  */
    161 #define OPL_FEEDBACK_CONNECTION		0xc0
    162 #define   OPL_FEEDBACK_MASK		0x0e	/* Valid just for 1st OP of a voice */
    163 #define   OPL_CONNECTION_BIT		0x01
    164 /*
    165  *	In the 4 OP mode there is four possible configurations how the
    166  *	operators can be connected together (in 2 OP modes there is just
    167  *	AM or FM). The 4 OP connection mode is defined by the rightmost
    168  *	bit of the FEEDBACK_CONNECTION (0xC0-0xC8) on the both halves.
    169  *
    170  *	First half	Second half	Mode
    171  *
    172  *					 +---+
    173  *					 v   |
    174  *	0		0		>+-1-+--2--3--4-->
    175  *
    176  *
    177  *
    178  *					 +---+
    179  *					 |   |
    180  *	0		1		>+-1-+--2-+
    181  *						  |->
    182  *					>--3----4-+
    183  *
    184  *					 +---+
    185  *					 |   |
    186  *	1		0		>+-1-+-----+
    187  *						   |->
    188  *					>--2--3--4-+
    189  *
    190  *					 +---+
    191  *					 |   |
    192  *	1		1		>+-1-+--+
    193  *						|
    194  *					>--2--3-+->
    195  *						|
    196  *					>--4----+
    197  */
    198 #define   OPL_STEREO_BITS		0x30	/* OPL-3 only */
    199 #define     OPL_VOICE_TO_LEFT		0x10
    200 #define     OPL_VOICE_TO_RIGHT		0x20
    201 
    202 #define OPL2_NVOICE 9
    203 #define OPL3_NVOICE 18
    204