From 9f8ab35852dfd68eb6cc92ab84b79a90995dc027 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 10 Mar 2009 00:02:41 +0000 Subject: Add opl library main header and stub functions. Subversion-branch: /branches/opl-branch Subversion-revision: 1455 --- opl/opl.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 opl/opl.h (limited to 'opl/opl.h') diff --git a/opl/opl.h b/opl/opl.h new file mode 100644 index 00000000..62b507f7 --- /dev/null +++ b/opl/opl.h @@ -0,0 +1,73 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 2009 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program 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, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// OPL interface. +// +//----------------------------------------------------------------------------- + + +#ifndef OPL_OPL_H +#define OPL_OPL_H + +typedef enum +{ + OPL_REGISTER_PORT = 0, + OPL_DATA_PORT = 1 +} opl_port_t; + +#define OPL_NUM_OPERATORS 21 +#define OPL_NUM_VOICES 9 + +#define OPL_REG_TIMER1 0x02 +#define OPL_REG_TIMER2 0x03 +#define OPL_REG_TIMER_CTRL 0x04 +#define OPL_REG_FM_MODE 0x08 + +// Operator registers (21 of each): + +#define OPL_REGS_TREMOLO 0x20 +#define OPL_REGS_LEVEL 0x40 +#define OPL_REGS_ATTACK 0x60 +#define OPL_REGS_SUSTAIN 0x80 + +// Voice registers (9 of each): + +#define OPL_REGS_FREQ_1 0xA0 +#define OPL_REGS_FREQ_2 0xB0 + +// Initialise the OPL subsystem. + +int OPL_Init(unsigned int port_base); + +// Shut down the OPL subsystem. + +void OPL_Shutdown(void); + +// Write to one of the OPL I/O ports: + +void OPL_WritePort(opl_port_t port, unsigned int value); + +// Read from one of the OPL I/O ports: + +unsigned int OPL_ReadPort(opl_port_t port); + +#endif + -- cgit v1.2.3 From ca7f823d48bb78eda9048750909cdb315836125c Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 10 Mar 2009 21:21:16 +0000 Subject: Initialise OPL registers on startup, initialise voices. Subversion-branch: /branches/opl-branch Subversion-revision: 1457 --- opl/opl.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'opl/opl.h') diff --git a/opl/opl.h b/opl/opl.h index 62b507f7..352e6696 100644 --- a/opl/opl.h +++ b/opl/opl.h @@ -36,6 +36,7 @@ typedef enum #define OPL_NUM_OPERATORS 21 #define OPL_NUM_VOICES 9 +#define OPL_REG_WAVEFORM_ENABLE 0x01 #define OPL_REG_TIMER1 0x02 #define OPL_REG_TIMER2 0x03 #define OPL_REG_TIMER_CTRL 0x04 @@ -47,11 +48,13 @@ typedef enum #define OPL_REGS_LEVEL 0x40 #define OPL_REGS_ATTACK 0x60 #define OPL_REGS_SUSTAIN 0x80 +#define OPL_REGS_WAVEFORM 0xE0 // Voice registers (9 of each): #define OPL_REGS_FREQ_1 0xA0 #define OPL_REGS_FREQ_2 0xB0 +#define OPL_REGS_FEEDBACK 0xC0 // Initialise the OPL subsystem. -- cgit v1.2.3 From 98ee23f4268dbb1395aa0b2cbfad9f53d1092b33 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 30 May 2009 23:24:11 +0000 Subject: Add initial callback/timer API. Subversion-branch: /branches/opl-branch Subversion-revision: 1538 --- opl/opl.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'opl/opl.h') diff --git a/opl/opl.h b/opl/opl.h index 352e6696..515950b1 100644 --- a/opl/opl.h +++ b/opl/opl.h @@ -27,6 +27,8 @@ #ifndef OPL_OPL_H #define OPL_OPL_H +typedef void (*opl_callback_t)(void *data); + typedef enum { OPL_REGISTER_PORT = 0, @@ -72,5 +74,19 @@ void OPL_WritePort(opl_port_t port, unsigned int value); unsigned int OPL_ReadPort(opl_port_t port); +// Set a timer callback. After the specified number of milliseconds +// have elapsed, the callback will be invoked. + +void OPL_SetCallback(unsigned int ms, opl_callback_t callback, void *data); + +// Begin critical section, during which, OPL callbacks will not be +// invoked. + +void OPL_Lock(void); + +// End critical section. + +void OPL_Unlock(void); + #endif -- cgit v1.2.3 From e33a4961331301b1e3a5c65d148050fa33c4c594 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 28 Aug 2009 18:04:04 +0000 Subject: Working SDL OPL driver. Subversion-branch: /branches/opl-branch Subversion-revision: 1632 --- opl/opl.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'opl/opl.h') diff --git a/opl/opl.h b/opl/opl.h index 515950b1..3413e3ab 100644 --- a/opl/opl.h +++ b/opl/opl.h @@ -88,5 +88,9 @@ void OPL_Lock(void); void OPL_Unlock(void); +// Block until the specified number of milliseconds have elapsed. + +void OPL_Delay(unsigned int ms); + #endif -- cgit v1.2.3 From 076adeb0aa24e9bdc677435ddb6e444db58d5436 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 30 Aug 2009 12:07:04 +0000 Subject: Add method to clear all existing callbacks. Subversion-branch: /branches/opl-branch Subversion-revision: 1642 --- opl/opl.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'opl/opl.h') diff --git a/opl/opl.h b/opl/opl.h index 3413e3ab..a0998404 100644 --- a/opl/opl.h +++ b/opl/opl.h @@ -79,6 +79,10 @@ unsigned int OPL_ReadPort(opl_port_t port); void OPL_SetCallback(unsigned int ms, opl_callback_t callback, void *data); +// Clear all OPL callbacks that have been set. + +void OPL_ClearCallbacks(void); + // Begin critical section, during which, OPL callbacks will not be // invoked. -- cgit v1.2.3 From 79698ecfd9e025f28350566d2b89b223688a1b45 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 21 Sep 2009 22:20:33 +0000 Subject: Implement pausing of music. Subversion-branch: /branches/opl-branch Subversion-revision: 1688 --- opl/opl.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'opl/opl.h') diff --git a/opl/opl.h b/opl/opl.h index a0998404..f5b93a64 100644 --- a/opl/opl.h +++ b/opl/opl.h @@ -96,5 +96,9 @@ void OPL_Unlock(void); void OPL_Delay(unsigned int ms); +// Pause the OPL callbacks. + +void OPL_SetPaused(int paused); + #endif -- cgit v1.2.3 From dce2c95f05b8f5ed734d1a1b75ccd7bfb2260557 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 26 Sep 2009 23:52:41 +0000 Subject: Move register read/write code into OPL library. Detect OPL in the library code, so that we fall back to software emulation if we have port access but an OPL is not detected. Fix detection of ioperm in configure. Subversion-branch: /branches/opl-branch Subversion-revision: 1692 --- opl/opl.h | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'opl/opl.h') diff --git a/opl/opl.h b/opl/opl.h index f5b93a64..9f5d0a9f 100644 --- a/opl/opl.h +++ b/opl/opl.h @@ -58,7 +58,11 @@ typedef enum #define OPL_REGS_FREQ_2 0xB0 #define OPL_REGS_FEEDBACK 0xC0 -// Initialise the OPL subsystem. +// +// Low-level functions. +// + +// Initialize the OPL subsystem. int OPL_Init(unsigned int port_base); @@ -74,6 +78,31 @@ void OPL_WritePort(opl_port_t port, unsigned int value); unsigned int OPL_ReadPort(opl_port_t port); +// +// Higher-level functions. +// + +// Read the cuurrent status byte of the OPL chip. + +unsigned int OPL_ReadStatus(void); + +// Write to an OPL register. + +void OPL_WriteRegister(int reg, int value); + +// Perform a detection sequence to determine that an +// OPL chip is present. + +int OPL_Detect(void); + +// Initialize all registers, performed on startup. + +void OPL_InitRegisters(void); + +// +// Timer callback functions. +// + // Set a timer callback. After the specified number of milliseconds // have elapsed, the callback will be invoked. -- cgit v1.2.3 From e30325c40f6ea482862745db0f4555e513f2952e Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 17 Oct 2009 22:36:15 +0000 Subject: Add OPL library API function to set software emulation sample rate, and set from snd_samplerate in the configuration file. Subversion-branch: /branches/opl-branch Subversion-revision: 1723 --- opl/opl.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'opl/opl.h') diff --git a/opl/opl.h b/opl/opl.h index 9f5d0a9f..04d3cf27 100644 --- a/opl/opl.h +++ b/opl/opl.h @@ -70,6 +70,10 @@ int OPL_Init(unsigned int port_base); void OPL_Shutdown(void); +// Set the sample rate used for software emulation. + +void OPL_SetSampleRate(unsigned int rate); + // Write to one of the OPL I/O ports: void OPL_WritePort(opl_port_t port, unsigned int value); -- cgit v1.2.3