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