diff options
author | Simon Howard | 2009-08-29 20:08:21 +0000 |
---|---|---|
committer | Simon Howard | 2009-08-29 20:08:21 +0000 |
commit | ca065a06caac9ba5fab3eb8b1f49d529755506db (patch) | |
tree | 75c23fcf6d65b76423b3e4085c66235ae2376346 /opl | |
parent | e33a4961331301b1e3a5c65d148050fa33c4c594 (diff) | |
download | chocolate-doom-ca065a06caac9ba5fab3eb8b1f49d529755506db.tar.gz chocolate-doom-ca065a06caac9ba5fab3eb8b1f49d529755506db.tar.bz2 chocolate-doom-ca065a06caac9ba5fab3eb8b1f49d529755506db.zip |
Set timer callback for OPL emulator so that the adlib detection routine
works.
Subversion-branch: /branches/opl-branch
Subversion-revision: 1633
Diffstat (limited to 'opl')
-rw-r--r-- | opl/examples/droplay.c | 2 | ||||
-rw-r--r-- | opl/opl_sdl.c | 25 |
2 files changed, 25 insertions, 2 deletions
diff --git a/opl/examples/droplay.c b/opl/examples/droplay.c index 5158fbcd..b1656815 100644 --- a/opl/examples/droplay.c +++ b/opl/examples/droplay.c @@ -89,8 +89,6 @@ int DetectOPL(void) WriteReg(OPL_REG_TIMER_CTRL, 0x60); WriteReg(OPL_REG_TIMER_CTRL, 0x80); -// Temporary hack for SDL driver. -return 1; return val1 == 0 && val2 == 0xc0; } diff --git a/opl/opl_sdl.c b/opl/opl_sdl.c index 849a10b0..42fe3347 100644 --- a/opl/opl_sdl.c +++ b/opl/opl_sdl.c @@ -239,6 +239,29 @@ static void OPL_SDL_Shutdown(void) } } +// Callback when a timer expires. + +static void TimerOver(void *data) +{ + int channel = (int) data; + + OPLTimerOver(opl_emulator, channel); +} + +// Callback invoked when the emulator code wants to set a timer. + +static void TimerHandler(int channel, double interval_seconds) +{ + unsigned int interval_samples; + + interval_samples = (int) (interval_seconds * mixing_freq); + + SDL_LockMutex(callback_queue_mutex); + OPL_Queue_Push(callback_queue, TimerOver, (void *) channel, + current_time + interval_samples); + SDL_UnlockMutex(callback_queue_mutex); +} + static int OPL_SDL_Init(unsigned int port_base) { // Check if SDL_mixer has been opened already @@ -308,6 +331,8 @@ static int OPL_SDL_Init(unsigned int port_base) return 0; } + OPLSetTimerHandler(opl_emulator, TimerHandler, 0); + callback_mutex = SDL_CreateMutex(); callback_queue_mutex = SDL_CreateMutex(); |