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.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 opl/opl.c (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c new file mode 100644 index 00000000..d3dfc23b --- /dev/null +++ b/opl/opl.c @@ -0,0 +1,49 @@ +// 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. +// +//----------------------------------------------------------------------------- + +#include "opl.h" + +int OPL_Init(unsigned int port_base) +{ + // TODO + return 1; +} + +void OPL_Shutdown(void) +{ + // TODO +} + +void OPL_WritePort(opl_port_t port, unsigned int value) +{ + // TODO +} + +unsigned int OPL_ReadPort(opl_port_t port) +{ + // TODO + return 0; +} + -- cgit v1.2.3 From 84a05be9dbc9d1b181670f8fd7e036bbe691d856 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 10 Mar 2009 21:55:55 +0000 Subject: Add OPL lib plumbing and Linux native driver. Subversion-branch: /branches/opl-branch Subversion-revision: 1458 --- opl/opl.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 6 deletions(-) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index d3dfc23b..28609223 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -23,27 +23,71 @@ // //----------------------------------------------------------------------------- +#include "config.h" + +#include + #include "opl.h" +#include "opl_internal.h" + +#ifdef HAVE_IOPERM +extern opl_driver_t opl_linux_driver; +#endif + +static opl_driver_t *drivers[] = +{ +#ifdef HAVE_IOPERM + &opl_linux_driver, +#endif + NULL +}; + +static opl_driver_t *driver = NULL; int OPL_Init(unsigned int port_base) { - // TODO - return 1; + int i; + + // Try drivers until we find a working one: + + for (i=0; drivers[i] != NULL; ++i) + { + if (drivers[i]->init_func(port_base)) + { + driver = drivers[i]; + return 1; + } + } + + return 0; } void OPL_Shutdown(void) { - // TODO + if (driver != NULL) + { + driver->shutdown_func(); + driver = NULL; + } } void OPL_WritePort(opl_port_t port, unsigned int value) { - // TODO + if (driver != NULL) + { + driver->write_port_func(port, value); + } } unsigned int OPL_ReadPort(opl_port_t port) { - // TODO - return 0; + if (driver != NULL) + { + return driver->read_port_func(port); + } + else + { + return 0; + } } -- cgit v1.2.3 From 962d6dcf12e740c26c3be035884b310e74947d97 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 11 Mar 2009 20:20:05 +0000 Subject: Debug trace code for register writes. Subversion-branch: /branches/opl-branch Subversion-revision: 1462 --- opl/opl.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 28609223..9afdd980 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -30,6 +30,8 @@ #include "opl.h" #include "opl_internal.h" +#define OPL_DEBUG_TRACE + #ifdef HAVE_IOPERM extern opl_driver_t opl_linux_driver; #endif @@ -75,6 +77,9 @@ void OPL_WritePort(opl_port_t port, unsigned int value) { if (driver != NULL) { +#ifdef OPL_DEBUG_TRACE + printf("OPL_write: %i, %x\n", port, value); +#endif driver->write_port_func(port, value); } } @@ -83,7 +88,15 @@ unsigned int OPL_ReadPort(opl_port_t port) { if (driver != NULL) { - return driver->read_port_func(port); + unsigned int result; + + result = driver->read_port_func(port); + +#ifdef OPL_DEBUG_TRACE + printf("OPL_read: %i -> %x\n", port, result); +#endif + + return result; } else { -- cgit v1.2.3 From d9f55dd56cc2a21dc6be97e9a2512d9bd8f05286 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 29 Mar 2009 22:40:44 +0000 Subject: Fix compile warning. Subversion-branch: /branches/opl-branch Subversion-revision: 1491 --- opl/opl.c | 1 + 1 file changed, 1 insertion(+) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 9afdd980..8f75241b 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -25,6 +25,7 @@ #include "config.h" +#include #include #include "opl.h" -- 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.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 8f75241b..6c2d9c4f 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -105,3 +105,27 @@ unsigned int OPL_ReadPort(opl_port_t port) } } +void OPL_SetCallback(unsigned int ms, opl_callback_t callback, void *data) +{ + if (driver != NULL) + { + driver->set_callback_func(ms, callback, data); + } +} + +void OPL_Lock(void) +{ + if (driver != NULL) + { + driver->lock_func(); + } +} + +void OPL_Unlock(void) +{ + if (driver != NULL) + { + driver->unlock_func(); + } +} + -- cgit v1.2.3 From b09cb29b9f573501206bd31e51f3014ec79d5f95 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 2 Jun 2009 01:08:20 +0000 Subject: Disable debug output. Subversion-branch: /branches/opl-branch Subversion-revision: 1541 --- opl/opl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 6c2d9c4f..5fddf205 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -31,7 +31,7 @@ #include "opl.h" #include "opl_internal.h" -#define OPL_DEBUG_TRACE +//#define OPL_DEBUG_TRACE #ifdef HAVE_IOPERM extern opl_driver_t opl_linux_driver; -- 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.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 5fddf205..e53b5d6e 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -28,6 +28,8 @@ #include #include +#include "SDL.h" + #include "opl.h" #include "opl_internal.h" @@ -36,12 +38,14 @@ #ifdef HAVE_IOPERM extern opl_driver_t opl_linux_driver; #endif +extern opl_driver_t opl_sdl_driver; static opl_driver_t *drivers[] = { #ifdef HAVE_IOPERM &opl_linux_driver, #endif + &opl_sdl_driver, NULL }; @@ -129,3 +133,57 @@ void OPL_Unlock(void) } } +typedef struct +{ + int finished; + + SDL_mutex *mutex; + SDL_cond *cond; +} delay_data_t; + +static void DelayCallback(void *_delay_data) +{ + delay_data_t *delay_data = _delay_data; + + SDL_LockMutex(delay_data->mutex); + delay_data->finished = 1; + SDL_UnlockMutex(delay_data->mutex); + + SDL_CondSignal(delay_data->cond); +} + +void OPL_Delay(unsigned int ms) +{ + delay_data_t delay_data; + + if (driver == NULL) + { + return; + } + + // Create a callback that will signal this thread after the + // specified time. + + delay_data.finished = 0; + delay_data.mutex = SDL_CreateMutex(); + delay_data.cond = SDL_CreateCond(); + + OPL_SetCallback(ms, DelayCallback, &delay_data); + + // Wait until the callback is invoked. + + SDL_LockMutex(delay_data.mutex); + + while (!delay_data.finished) + { + SDL_CondWait(delay_data.cond, delay_data.mutex); + } + + SDL_UnlockMutex(delay_data.mutex); + + // Clean up. + + SDL_DestroyMutex(delay_data.mutex); + SDL_DestroyCond(delay_data.cond); +} + -- 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.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index e53b5d6e..6e75c951 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -117,6 +117,14 @@ void OPL_SetCallback(unsigned int ms, opl_callback_t callback, void *data) } } +void OPL_ClearCallbacks(void) +{ + if (driver != NULL) + { + driver->clear_callbacks_func(); + } +} + void OPL_Lock(void) { if (driver != NULL) -- 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.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 6e75c951..9d73fe0e 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -33,7 +33,7 @@ #include "opl.h" #include "opl_internal.h" -//#define OPL_DEBUG_TRACE +#define OPL_DEBUG_TRACE #ifdef HAVE_IOPERM extern opl_driver_t opl_linux_driver; @@ -195,3 +195,11 @@ void OPL_Delay(unsigned int ms) SDL_DestroyCond(delay_data.cond); } +void OPL_SetPaused(int paused) +{ + if (driver != NULL) + { + driver->set_paused_func(paused); + } +} + -- cgit v1.2.3 From 07f50245788a5a5b259864c1631d4e97eaec92fb Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 24 Sep 2009 21:57:21 +0000 Subject: Disable OPL debug output. Subversion-branch: /branches/opl-branch Subversion-revision: 1689 --- opl/opl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 9d73fe0e..9ec19fd4 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -33,7 +33,7 @@ #include "opl.h" #include "opl_internal.h" -#define OPL_DEBUG_TRACE +//#define OPL_DEBUG_TRACE #ifdef HAVE_IOPERM extern opl_driver_t opl_linux_driver; -- cgit v1.2.3 From 6f3d0abb12bcc05336e780414fe84a8f9f25ec26 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 26 Sep 2009 19:56:24 +0000 Subject: Add OpenBSD/NetBSD native OPL backend. Subversion-branch: /branches/opl-branch Subversion-revision: 1690 --- opl/opl.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 9ec19fd4..f28cd63f 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -38,12 +38,18 @@ #ifdef HAVE_IOPERM extern opl_driver_t opl_linux_driver; #endif +#ifdef HAVE_LIBI386 +extern opl_driver_t opl_openbsd_driver; +#endif extern opl_driver_t opl_sdl_driver; static opl_driver_t *drivers[] = { #ifdef HAVE_IOPERM &opl_linux_driver, +#endif +#ifdef HAVE_LIBI386 + &opl_openbsd_driver, #endif &opl_sdl_driver, NULL -- 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.c | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 238 insertions(+), 6 deletions(-) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index f28cd63f..00c9b04a 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -1,4 +1,4 @@ -// Emacs style mode select -*- C++ -*- +// Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // // Copyright(C) 2009 Simon Howard @@ -28,6 +28,10 @@ #include #include +#ifdef _WIN32_WCE +#include "libc_wince.h" +#endif + #include "SDL.h" #include "opl.h" @@ -56,25 +60,113 @@ static opl_driver_t *drivers[] = }; static opl_driver_t *driver = NULL; +static int init_stage_reg_writes = 1; -int OPL_Init(unsigned int port_base) +// +// Init/shutdown code. +// + +// Initialize the specified driver and detect an OPL chip. Returns +// true if an OPL is detected. + +static int InitDriver(opl_driver_t *_driver, unsigned int port_base) { - int i; + // Initialize the driver. + + if (!_driver->init_func(port_base)) + { + return 0; + } + + // The driver was initialized okay, so we now have somewhere + // to write to. It doesn't mean there's an OPL chip there, + // though. Perform the detection sequence to make sure. + // (it's done twice, like how Doom does it). + + driver = _driver; + init_stage_reg_writes = 1; + + if (!OPL_Detect() || !OPL_Detect()) + { + printf("OPL_Init: No OPL detected using '%s' driver.\n", _driver->name); + _driver->shutdown_func(); + driver = NULL; + return 0; + } - // Try drivers until we find a working one: + // Initialize all registers. + + OPL_InitRegisters(); + + init_stage_reg_writes = 0; + + printf("OPL_Init: Using driver '%s'.\n", driver->name); + + return 1; +} + +// Find a driver automatically by trying each in the list. + +static int AutoSelectDriver(unsigned int port_base) +{ + int i; for (i=0; drivers[i] != NULL; ++i) { - if (drivers[i]->init_func(port_base)) + if (InitDriver(drivers[i], port_base)) { - driver = drivers[i]; return 1; } } + printf("OPL_Init: Failed to find a working driver.\n"); + return 0; } +// Initialize the OPL library. Returns true if initialized +// successfully. + +int OPL_Init(unsigned int port_base) +{ + char *driver_name; + int i; + + driver_name = getenv("OPL_DRIVER"); + + if (driver_name != NULL) + { + // Search the list until we find the driver with this name. + + for (i=0; drivers[i] != NULL; ++i) + { + if (!strcmp(driver_name, drivers[i]->name)) + { + if (InitDriver(drivers[i], port_base)) + { + return 1; + } + else + { + printf("OPL_Init: Failed to initialize " + "driver: '%s'.\n", driver_name); + return 0; + } + } + } + + printf("OPL_Init: unknown driver: '%s'.\n", driver_name); + + return 0; + } + else + { + return AutoSelectDriver(port_base); + } +} + +// Shut down the OPL library. + void OPL_Shutdown(void) { if (driver != NULL) @@ -115,6 +207,146 @@ unsigned int OPL_ReadPort(opl_port_t port) } } +// +// Higher-level functions, based on the lower-level functions above +// (register write, etc). +// + +unsigned int OPL_ReadStatus(void) +{ + return OPL_ReadPort(OPL_REGISTER_PORT); +} + +// Write an OPL register value + +void OPL_WriteRegister(int reg, int value) +{ + int i; + + OPL_WritePort(OPL_REGISTER_PORT, reg); + + // For timing, read the register port six times after writing the + // register number to cause the appropriate delay + + for (i=0; i<6; ++i) + { + // An oddity of the Doom OPL code: at startup initialisation, + // the spacing here is performed by reading from the register + // port; after initialisation, the data port is read, instead. + + if (init_stage_reg_writes) + { + OPL_ReadPort(OPL_REGISTER_PORT); + } + else + { + OPL_ReadPort(OPL_DATA_PORT); + } + } + + OPL_WritePort(OPL_DATA_PORT, value); + + // Read the register port 24 times after writing the value to + // cause the appropriate delay + + for (i=0; i<24; ++i) + { + OPL_ReadStatus(); + } +} + +// Detect the presence of an OPL chip + +int OPL_Detect(void) +{ + int result1, result2; + int i; + + // Reset both timers: + OPL_WriteRegister(OPL_REG_TIMER_CTRL, 0x60); + + // Enable interrupts: + OPL_WriteRegister(OPL_REG_TIMER_CTRL, 0x80); + + // Read status + result1 = OPL_ReadStatus(); + + // Set timer: + OPL_WriteRegister(OPL_REG_TIMER1, 0xff); + + // Start timer 1: + OPL_WriteRegister(OPL_REG_TIMER_CTRL, 0x21); + + // Wait for 80 microseconds + // This is how Doom does it: + + for (i=0; i<200; ++i) + { + OPL_ReadStatus(); + } + + OPL_Delay(1); + + // Read status + result2 = OPL_ReadStatus(); + + // Reset both timers: + OPL_WriteRegister(OPL_REG_TIMER_CTRL, 0x60); + + // Enable interrupts: + OPL_WriteRegister(OPL_REG_TIMER_CTRL, 0x80); + + return (result1 & 0xe0) == 0x00 + && (result2 & 0xe0) == 0xc0; +} + +// Initialize registers on startup + +void OPL_InitRegisters(void) +{ + int r; + + // Initialize level registers + + for (r=OPL_REGS_LEVEL; r <= OPL_REGS_LEVEL + OPL_NUM_OPERATORS; ++r) + { + OPL_WriteRegister(r, 0x3f); + } + + // Initialize other registers + // These two loops write to registers that actually don't exist, + // but this is what Doom does ... + // Similarly, the <= is also intenational. + + for (r=OPL_REGS_ATTACK; r <= OPL_REGS_WAVEFORM + OPL_NUM_OPERATORS; ++r) + { + OPL_WriteRegister(r, 0x00); + } + + // More registers ... + + for (r=1; r < OPL_REGS_LEVEL; ++r) + { + OPL_WriteRegister(r, 0x00); + } + + // Re-initialize the low registers: + + // Reset both timers and enable interrupts: + OPL_WriteRegister(OPL_REG_TIMER_CTRL, 0x60); + OPL_WriteRegister(OPL_REG_TIMER_CTRL, 0x80); + + // "Allow FM chips to control the waveform of each operator": + OPL_WriteRegister(OPL_REG_WAVEFORM_ENABLE, 0x20); + + // Keyboard split point on (?) + OPL_WriteRegister(OPL_REG_FM_MODE, 0x40); +} + +// +// Timer functions. +// + void OPL_SetCallback(unsigned int ms, opl_callback_t callback, void *data) { if (driver != NULL) -- cgit v1.2.3 From d484bfaf001faeb48fee28d046149108ab52a394 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 30 Sep 2009 00:11:44 +0000 Subject: Add Win9x native OPL driver (untested). Subversion-branch: /branches/opl-branch Subversion-revision: 1696 --- opl/opl.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 00c9b04a..749c19d1 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -45,6 +45,9 @@ extern opl_driver_t opl_linux_driver; #ifdef HAVE_LIBI386 extern opl_driver_t opl_openbsd_driver; #endif +#ifdef _WIN32 +extern opl_driver_t opl_win9x_driver; +#endif extern opl_driver_t opl_sdl_driver; static opl_driver_t *drivers[] = @@ -54,6 +57,9 @@ static opl_driver_t *drivers[] = #endif #ifdef HAVE_LIBI386 &opl_openbsd_driver, +#endif +#ifdef _WIN32 + &opl_win9x_driver, #endif &opl_sdl_driver, NULL -- cgit v1.2.3 From 4a70f989d2aacabffc2f02017704de042be7418a Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 1 Oct 2009 00:08:48 +0000 Subject: Convert to American English spellings. Subversion-branch: /branches/opl-branch Subversion-revision: 1700 --- opl/opl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 749c19d1..bf999d47 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -236,9 +236,9 @@ void OPL_WriteRegister(int reg, int value) for (i=0; i<6; ++i) { - // An oddity of the Doom OPL code: at startup initialisation, + // An oddity of the Doom OPL code: at startup initialization, // the spacing here is performed by reading from the register - // port; after initialisation, the data port is read, instead. + // port; after initialization, the data port is read, instead. if (init_stage_reg_writes) { -- cgit v1.2.3 From 73cc6b5a6017a15b02ce3480e0e58d19520b31ba Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 4 Oct 2009 04:21:40 +0000 Subject: Make OpenBSD native OPL backend work on x86_64 as well as i386. Subversion-branch: /branches/opl-branch Subversion-revision: 1707 --- opl/opl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index bf999d47..8e57647e 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -42,7 +42,7 @@ #ifdef HAVE_IOPERM extern opl_driver_t opl_linux_driver; #endif -#ifdef HAVE_LIBI386 +#if defined(HAVE_LIBI386) || defined(HAVE_LIBAMD64) extern opl_driver_t opl_openbsd_driver; #endif #ifdef _WIN32 @@ -55,7 +55,7 @@ static opl_driver_t *drivers[] = #ifdef HAVE_IOPERM &opl_linux_driver, #endif -#ifdef HAVE_LIBI386 +#if defined(HAVE_LIBI386) || defined(HAVE_LIBAMD64) &opl_openbsd_driver, #endif #ifdef _WIN32 -- 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.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 8e57647e..2c8fd692 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -68,6 +68,8 @@ static opl_driver_t *drivers[] = static opl_driver_t *driver = NULL; static int init_stage_reg_writes = 1; +unsigned int opl_sample_rate = 22050; + // // Init/shutdown code. // @@ -182,6 +184,13 @@ void OPL_Shutdown(void) } } +// Set the sample rate used for software OPL emulation. + +void OPL_SetSampleRate(unsigned int rate) +{ + opl_sample_rate = rate; +} + void OPL_WritePort(opl_port_t port, unsigned int value) { if (driver != NULL) -- cgit v1.2.3 From 06b97d2d116b622bc067b245f81b2857767d598e Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 26 Feb 2010 21:07:59 +0000 Subject: Add OPL hardware playback support for Windows NT-based systems. Subversion-branch: /branches/opl-branch Subversion-revision: 1871 --- opl/opl.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 2c8fd692..9e674530 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -46,7 +46,7 @@ extern opl_driver_t opl_linux_driver; extern opl_driver_t opl_openbsd_driver; #endif #ifdef _WIN32 -extern opl_driver_t opl_win9x_driver; +extern opl_driver_t opl_win32_driver; #endif extern opl_driver_t opl_sdl_driver; @@ -59,7 +59,7 @@ static opl_driver_t *drivers[] = &opl_openbsd_driver, #endif #ifdef _WIN32 - &opl_win9x_driver, + &opl_win32_driver, #endif &opl_sdl_driver, NULL @@ -197,6 +197,7 @@ void OPL_WritePort(opl_port_t port, unsigned int value) { #ifdef OPL_DEBUG_TRACE printf("OPL_write: %i, %x\n", port, value); + fflush(stdout); #endif driver->write_port_func(port, value); } @@ -208,10 +209,16 @@ unsigned int OPL_ReadPort(opl_port_t port) { unsigned int result; +#ifdef OPL_DEBUG_TRACE + printf("OPL_read: %i...\n", port); + fflush(stdout); +#endif + result = driver->read_port_func(port); #ifdef OPL_DEBUG_TRACE printf("OPL_read: %i -> %x\n", port, result); + fflush(stdout); #endif return result; -- cgit v1.2.3 From 1398c8aed38b0d42e7081410ae1710858d335f7e Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 27 Feb 2010 17:48:25 +0000 Subject: Fix race condition with condition variable freed before it is signaled. Subversion-branch: /branches/opl-branch Subversion-revision: 1873 --- opl/opl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'opl/opl.c') diff --git a/opl/opl.c b/opl/opl.c index 9e674530..6d0e16db 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -415,9 +415,10 @@ static void DelayCallback(void *_delay_data) SDL_LockMutex(delay_data->mutex); delay_data->finished = 1; - SDL_UnlockMutex(delay_data->mutex); SDL_CondSignal(delay_data->cond); + + SDL_UnlockMutex(delay_data->mutex); } void OPL_Delay(unsigned int ms) -- cgit v1.2.3