some cleanup, changed type timer procedure - passed Scumm pointer
svn-id: r4743
This commit is contained in:
parent
7f3ba176e1
commit
f2faf9063b
8 changed files with 27 additions and 42 deletions
12
bundle.h
12
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];
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
2
scumm.h
2
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);
|
||||
|
|
|
@ -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()
|
||||
|
|
20
sound.cpp
20
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)
|
||||
|
|
14
timer.cpp
14
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) {
|
||||
|
|
7
timer.h
7
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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue