diff --git a/bundle.h b/bundle.h index 912bd74e368..c95cc853cd4 100644 --- a/bundle.h +++ b/bundle.h @@ -23,6 +23,12 @@ #include "scummsys.h" +class Scumm; + +class Bundle { + +private: + struct CompTable { int32 offset; int32 size; @@ -35,12 +41,6 @@ struct BundleAudioTable { int32 offset; }; -class Scumm; - -class Bundle { -protected: - -private: int32 compDecode(byte *src, byte *dst); int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 size); CompTable _compVoiceTable[50]; diff --git a/insane.cpp b/insane.cpp index 5b35f509c96..fb5ec383499 100644 --- a/insane.cpp +++ b/insane.cpp @@ -41,9 +41,8 @@ SmushPlayer::SmushPlayer(Scumm * parent) { SmushPlayer::~SmushPlayer() { } -static int smush_handler (int t) { +static void smush_handler (Scumm * _scumm) { h_sp->update(); - return t; } byte * SmushPlayer::loadTres() { diff --git a/mac/mac.cpp b/mac/mac.cpp index 7a6397069af..f22d72666b7 100644 --- a/mac/mac.cpp +++ b/mac/mac.cpp @@ -195,7 +195,7 @@ private: void blit_to_screen(); void update_rects(); - static uint32 autosave(uint32); + static void autosave(Scumm * scumm); UInt8 *buffer[2]; CmpSoundHeader header; @@ -608,9 +608,9 @@ OSystem *OSystem_MAC::create(int gfx_mode, bool full_screen) { return syst; } -uint32 OSystem_MAC::autosave(uint32 interval) +void OSystem_MAC::autosave(Scumm * scumm) { - g_scumm->_doAutosave = true; + scumm->_doAutosave = true; return interval; } diff --git a/scumm.h b/scumm.h index 9fb54b9f9e8..c79c302c2a5 100644 --- a/scumm.h +++ b/scumm.h @@ -775,7 +775,7 @@ public: void playBundleMusic(int32 song); void pauseBundleMusic(bool state); void stopBundleMusic(); - int bundleMusicHandler(int t); + void bundleMusicHandler(Scumm * scumm); void decompressBundleSound(int index); int playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned = false); int playSfxSound_MP3(void *sound, uint32 size); diff --git a/scummvm.cpp b/scummvm.cpp index 95f371857d2..a6acab1caf4 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -38,10 +38,9 @@ extern void GraphicsOff(void); #endif -int autosave(int interval) /* Not in class to prevent being bound */ +void autosave(Scumm * scumm) /* Not in class to prevent being bound */ { - g_scumm->_doAutosave = true; - return interval; + scumm->_doAutosave = true; } void Scumm::initRandSeeds() diff --git a/sound.cpp b/sound.cpp index 0d40b168c70..8eaf61792f1 100644 --- a/sound.cpp +++ b/sound.cpp @@ -625,7 +625,7 @@ int Scumm::startSfxSound(void *file, int file_size) char ident[8]; int block_type; byte work[8]; - uint size = 0, i; + uint size = 0; int rate, comp; byte *data; @@ -775,11 +775,8 @@ bool Scumm::isSfxFinished() return !_mixer->has_active_channel(); } -static Scumm * h_scumm; - -static int music_handler (int t) { - h_scumm->bundleMusicHandler(t); - return t; +static void music_handler (Scumm * scumm) { + scumm->bundleMusicHandler(scumm); } #define OUTPUT_SIZE 66150 // ((22050 * 2 * 2) / 4) * 3 @@ -791,7 +788,6 @@ void Scumm::playBundleMusic(int32 song) { sprintf(buf, "%s%smusic.bun", _gameDataPath, _exe_name); if (_bundle->openMusicFile((char*)&buf) == false) return; - h_scumm = this; _musicBundleBufFinal = (byte*)malloc(OUTPUT_SIZE); _musicBundleBufOutput = (byte*)malloc(10 * 0x2000); _currentSampleBundleMusic = 0; @@ -829,7 +825,7 @@ void Scumm::stopBundleMusic() { } } -int Scumm::bundleMusicHandler(int t) { +void Scumm::bundleMusicHandler(Scumm * scumm) { byte * ptr; int32 l, num = _numberSamplesBundleMusic, length, k; int32 rate = 22050; @@ -838,7 +834,7 @@ int Scumm::bundleMusicHandler(int t) { ptr = _musicBundleBufOutput; if (_pauseBundleMusic) - return t; + return; for (k = 0, l = _currentSampleBundleMusic; l < num; k++) { length = _bundle->decompressMusicSampleByIndex(_numberBundleMusic, l, (_musicBundleBufOutput + ((k * 0x2000) + _offsetBufBundleMusic))); @@ -849,7 +845,7 @@ int Scumm::bundleMusicHandler(int t) { if (tag != MKID_BE('iMUS')) { warning("Decompression of bundle sound failed"); _numberBundleMusic = -1; - return t; + return; } ptr += 12; @@ -876,7 +872,7 @@ int Scumm::bundleMusicHandler(int t) { if (size < 0) { warning("Decompression sound failed (no size field)"); _numberBundleMusic = -1; - return t; + return; } header_size = (ptr - _musicBundleBufOutput); } @@ -916,8 +912,6 @@ int Scumm::bundleMusicHandler(int t) { } _mixer->play_raw(NULL, buffer, s_size, rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_16BITS | SoundMixer::FLAG_STEREO); - - return t; } void Scumm::playBundleSound(char *sound) diff --git a/timer.cpp b/timer.cpp index b272824090a..2a3fc74024e 100644 --- a/timer.cpp +++ b/timer.cpp @@ -44,8 +44,6 @@ static int timer_handler (int t) int Timer::handler(int * t) { uint32 interval, l; - _osystem->lock_mutex(_mutex); - if (_timerRunning) { _lastTime = _thisTime; _thisTime = _osystem->get_msecs(); @@ -56,14 +54,12 @@ int Timer::handler(int * t) { _timerSlots[l].counter -= interval; if (_timerSlots[l].counter <= 0) { _timerSlots[l].counter += _timerSlots[l].interval; - _timerSlots[l].procedure (0); + _timerSlots[l].procedure (_scumm); } } } } - _osystem->unlock_mutex(_mutex); - return *t; } @@ -85,7 +81,6 @@ bool Timer::init() { _timerSlots[l].counter = 0; } - _mutex = _osystem->create_mutex(); _thisTime = _osystem->get_msecs(); _osystem->set_timer (10, &timer_handler); @@ -101,6 +96,7 @@ void Timer::release() { return; _timerRunning = false; + _osystem->set_timer (0, NULL); _initialized = false; for (l = 0; l < MAX_TIMERS; l++) { @@ -108,11 +104,9 @@ void Timer::release() { _timerSlots[l].interval = 0; _timerSlots[l].counter = 0; } - _osystem->delete_mutex(_mutex); - } -bool Timer::installProcedure (int ((*procedure)(int)), int32 interval) { +bool Timer::installProcedure (TimerProc procedure, int32 interval) { int32 l; bool found = false; @@ -141,7 +135,7 @@ bool Timer::installProcedure (int ((*procedure)(int)), int32 interval) { return true; } -void Timer::releaseProcedure (int ((*procedure)(int))) { +void Timer::releaseProcedure (TimerProc procedure) { int32 l; if (_initialized == false) { diff --git a/timer.h b/timer.h index c87a05376ac..a4f4c7080dc 100644 --- a/timer.h +++ b/timer.h @@ -23,9 +23,9 @@ #include "scummsys.h" -#define MAX_TIMERS 3 +#define MAX_TIMERS 5 -typedef int (*TimerProc)(int); +typedef void (*TimerProc)(Scumm *); #ifdef __MORPHOS__ #include "morphos/morphos_timer.h" @@ -43,10 +43,9 @@ private: void *_timerHandler; int32 _thisTime; int32 _lastTime; - void *_mutex; struct TimerSlots { - int ((*procedure) (int)); + TimerProc procedure; int32 interval; int32 counter; } _timerSlots[MAX_TIMERS];