diff options
-rw-r--r-- | backends/platform/dc/audio.cpp | 23 | ||||
-rw-r--r-- | backends/platform/dc/dc.h | 24 | ||||
-rw-r--r-- | backends/platform/dc/dcmain.cpp | 11 | ||||
-rw-r--r-- | backends/platform/dc/input.cpp | 6 | ||||
-rw-r--r-- | backends/platform/dc/time.cpp | 47 |
5 files changed, 15 insertions, 96 deletions
diff --git a/backends/platform/dc/audio.cpp b/backends/platform/dc/audio.cpp index 1a88c4fc1a..ce82d36b11 100644 --- a/backends/platform/dc/audio.cpp +++ b/backends/platform/dc/audio.cpp @@ -24,6 +24,7 @@ #include <common/stdafx.h> #include <common/scummsys.h> #include "engines/engine.h" +#include "sound/mixer.h" #include "dc.h" EXTERN_C void *memcpy4s(void *s1, const void *s2, unsigned int n); @@ -36,28 +37,12 @@ void initSound() do_sound_command(CMD_SET_BUFFER(SOUND_BUFFER_SHIFT)); } -bool OSystem_Dreamcast::setSoundCallback(SoundProc proc, void *param) -{ - assert(SAMPLE_MODE == 0); - - _sound_proc_param = param; - _sound_proc = proc; - - return true; -} - -void OSystem_Dreamcast::clearSoundCallback() -{ - _sound_proc = NULL; - _sound_proc_param = NULL; -} - void OSystem_Dreamcast::checkSound() { int n; int curr_ring_buffer_samples; - if(!_sound_proc) + if(!_mixer) return; if(read_sound_int(&SOUNDSTATUS->mode) != MODE_PLAY) @@ -75,8 +60,8 @@ void OSystem_Dreamcast::checkSound() if(n<100) return; - _sound_proc(_sound_proc_param, (byte*)temp_sound_buffer, - 2*SAMPLES_TO_BYTES(n)); + Audio::Mixer::mixCallback(_mixer, (byte*)temp_sound_buffer, + 2*SAMPLES_TO_BYTES(n)); if(fillpos+n > curr_ring_buffer_samples) { int r = curr_ring_buffer_samples - fillpos; diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index 0178a99567..bda9d36def 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -23,6 +23,7 @@ #include <common/system.h> #include <ronin/soundcommon.h> +#include "backends/timer/default/default-timer.h" #define NUM_BUFFERS 4 #define SOUND_BUFFER_SHIFT 3 @@ -38,19 +39,6 @@ class Interactive class OSystem_Dreamcast : public OSystem { - private: - - // Set function that generates samples - typedef void (*SoundProc)(void *param, byte *buf, int len); - bool setSoundCallback(SoundProc proc, void *param); - void clearSoundCallback(); - - // Add a callback timer - typedef int (*TimerProc)(int interval); - void setTimerCallback(TimerProc callback, int timer); - - Common::SaveFileManager *createSavefileManager(); - public: OSystem_Dreamcast(); @@ -200,7 +188,7 @@ class OSystem_Dreamcast : public OSystem { Common::SaveFileManager *_savefile; Audio::Mixer *_mixer; - Common::TimerManager *_timer; + DefaultTimerManager *_timer; SoftKeyboard _softkbd; int _ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_old_x, _ms_old_y; @@ -209,18 +197,12 @@ class OSystem_Dreamcast : public OSystem { int _overlay_x, _overlay_y; unsigned char *_ms_buf; unsigned char _ms_keycolor; - SoundProc _sound_proc; - void *_sound_proc_param; bool _overlay_visible, _overlay_dirty, _screen_dirty; int _screen_buffer, _overlay_buffer, _mouse_buffer; bool _aspect_stretch, _softkbd_on, _enable_cursor_palette; float _overlay_fade, _xscale, _yscale, _top_offset; int _softkbd_motion; - uint32 _timer_duration, _timer_next_expiry; - bool _timer_active; - int (*_timer_callback) (int); - unsigned char *screen; unsigned short *mouse; unsigned short *overlay; @@ -237,6 +219,8 @@ class OSystem_Dreamcast : public OSystem { unsigned char *buf, bool visible); void setScaling(); + + Common::SaveFileManager *createSavefileManager(); }; diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp index aecb61759d..96ec3aa6aa 100644 --- a/backends/platform/dc/dcmain.cpp +++ b/backends/platform/dc/dcmain.cpp @@ -32,7 +32,6 @@ #include <common/config-manager.h> #include "backends/plugins/dc/dc-provider.h" -#include "backends/timer/default/default-timer.h" #include "sound/mixer.h" @@ -42,7 +41,7 @@ const char *gGameName; OSystem_Dreamcast::OSystem_Dreamcast() : _devpoll(0), screen(NULL), mouse(NULL), overlay(NULL), _softkbd(this), - _ms_buf(NULL), _sound_proc(NULL), _timer_active(false), + _ms_buf(NULL), _timer(NULL), _mixer(NULL), _savefile(NULL), _current_shake_pos(0), _aspect_stretch(false), _softkbd_on(false), _softkbd_motion(0), _enable_cursor_palette(false) { @@ -51,19 +50,11 @@ OSystem_Dreamcast::OSystem_Dreamcast() memset(ovl_tx, 0, sizeof(ovl_tx)); } -static int timer_handler(int t) { - DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager(); - tm->handler(); - return t; -} - void OSystem_Dreamcast::initBackend() { _savefile = createSavefileManager(); _mixer = new Audio::Mixer(); _timer = new DefaultTimerManager(); - setSoundCallback(Audio::Mixer::mixCallback, _mixer); - setTimerCallback(&timer_handler, 10); } diff --git a/backends/platform/dc/input.cpp b/backends/platform/dc/input.cpp index 50587ad59d..49b6a56e6f 100644 --- a/backends/platform/dc/input.cpp +++ b/backends/platform/dc/input.cpp @@ -191,10 +191,8 @@ bool OSystem_Dreamcast::pollEvent(Event &event) { unsigned int t = Timer(); - if(_timer_active && ((int)(t-_timer_next_expiry))>=0) { - _timer_duration = _timer_callback(_timer_duration); - _timer_next_expiry = t+USEC_TO_TIMER(1000*_timer_duration); - } + if(_timer != NULL) + _timer->handler(); if(((int)(t-_devpoll))<0) return false; diff --git a/backends/platform/dc/time.cpp b/backends/platform/dc/time.cpp index a4bbfb8be6..1912bed773 100644 --- a/backends/platform/dc/time.cpp +++ b/backends/platform/dc/time.cpp @@ -49,49 +49,10 @@ void OSystem_Dreamcast::delayMillis(uint msecs) getMillis(); unsigned int t, start = Timer(); int time = (((unsigned int)msecs)*100000U)>>11; - while(((int)((t = Timer())-start))<time) + while(((int)((t = Timer())-start))<time) { + if(_timer != NULL) + _timer->handler(); checkSound(); - getMillis(); -} - -void OSystem_Dreamcast::setTimerCallback(TimerProc callback, int timer) -{ - if (callback != NULL) { - _timer_duration = timer; - _timer_next_expiry = Timer() + USEC_TO_TIMER(1000*timer); - _timer_callback = callback; - _timer_active = true; - } else { - _timer_active = false; } + getMillis(); } - - -/* -void waitForTimer(Scumm *s, int time) -{ - if(time<0) - return; - unsigned int start = Timer(); - unsigned int devpoll = start+USEC_TO_TIMER(25000); - unsigned int t; - int oldmousex = s->mouse.x, oldmousey = s->mouse.y; - time = (((unsigned int)time)*100000U)>>11; - int mask = getimask(); - while(((int)((t = Timer())-start))<time) - if(((int)(t-devpoll))>0) { - setimask(15); - checkSound(); - handleInput(locked_get_pads(), s->mouse.x, s->mouse.y, - s->_leftBtnPressed, s->_rightBtnPressed, s->_keyPressed); - setimask(mask); - devpoll += USEC_TO_TIMER(17000); - if(s->mouse.x != oldmousex || s->mouse.y != oldmousey) { - extern void updateScreen(Scumm *s); - updateScreen(s); - oldmousex = s->mouse.x; - oldmousey = s->mouse.y; - } - } -} -*/ |