Big ugly hairy hack to remove Scumm class dependencies to the MidiEmu driver, and add streaming (ahah) emulation - someone please fix this as soon as possible :)
svn-id: r4349
This commit is contained in:
parent
3b4c6ceb0f
commit
427cc598e0
4 changed files with 60 additions and 5 deletions
7
main.cpp
7
main.cpp
|
@ -32,6 +32,9 @@ GameDetector detector;
|
||||||
Gui gui;
|
Gui gui;
|
||||||
|
|
||||||
Scumm *g_scumm;
|
Scumm *g_scumm;
|
||||||
|
/* FIXME */
|
||||||
|
OSystem *g_system;
|
||||||
|
SoundMixer *g_mixer;
|
||||||
|
|
||||||
Config * scummcfg;
|
Config * scummcfg;
|
||||||
|
|
||||||
|
@ -182,6 +185,8 @@ game settings!
|
||||||
MidiDriver *midi = detector.createMidi();
|
MidiDriver *midi = detector.createMidi();
|
||||||
|
|
||||||
SimonState *simon = SimonState::create(system, midi);
|
SimonState *simon = SimonState::create(system, midi);
|
||||||
|
g_system = simon->_system;
|
||||||
|
g_mixer = &simon->_mixer[0];
|
||||||
simon->_game = detector._gameId - GID_SIMON_FIRST;
|
simon->_game = detector._gameId - GID_SIMON_FIRST;
|
||||||
simon->set_volume(detector._sfx_volume);
|
simon->set_volume(detector._sfx_volume);
|
||||||
simon->_game_path = detector._gameDataPath;
|
simon->_game_path = detector._gameDataPath;
|
||||||
|
@ -190,6 +195,8 @@ game settings!
|
||||||
} else {
|
} else {
|
||||||
Scumm *scumm = Scumm::createFromDetector(&detector, system);
|
Scumm *scumm = Scumm::createFromDetector(&detector, system);
|
||||||
g_scumm = scumm;
|
g_scumm = scumm;
|
||||||
|
g_system = scumm->_system;
|
||||||
|
g_mixer = &scumm->_mixer[0];
|
||||||
g_scumm->_sound_volume_master = 0;
|
g_scumm->_sound_volume_master = 0;
|
||||||
g_scumm->_sound_volume_music = detector._music_volume;
|
g_scumm->_sound_volume_music = detector._music_volume;
|
||||||
g_scumm->_sound_volume_sfx = detector._sfx_volume;
|
g_scumm->_sound_volume_sfx = detector._sfx_volume;
|
||||||
|
|
3
scumm.h
3
scumm.h
|
@ -45,6 +45,9 @@ typedef void (Scumm::*OpcodeProc)();
|
||||||
|
|
||||||
/* Use this one from error() ONLY */
|
/* Use this one from error() ONLY */
|
||||||
extern Scumm *g_scumm;
|
extern Scumm *g_scumm;
|
||||||
|
/* BIG HACK for MidiEmu - FIXME */
|
||||||
|
extern OSystem *g_system;
|
||||||
|
extern SoundMixer *g_mixer;
|
||||||
|
|
||||||
/* System Wide Constants */
|
/* System Wide Constants */
|
||||||
enum {
|
enum {
|
||||||
|
|
|
@ -1425,6 +1425,8 @@ Scumm *Scumm::createFromDetector(GameDetector *detector, OSystem *syst)
|
||||||
|
|
||||||
/* HACK !!! */
|
/* HACK !!! */
|
||||||
g_scumm = scumm;
|
g_scumm = scumm;
|
||||||
|
g_system = scumm->_system;
|
||||||
|
g_mixer = &scumm->_mixer[0];
|
||||||
/* END HACK */
|
/* END HACK */
|
||||||
|
|
||||||
// scumm->_fullScreen = detector->_fullScreen;
|
// scumm->_fullScreen = detector->_fullScreen;
|
||||||
|
|
|
@ -970,6 +970,7 @@ public:
|
||||||
void send(uint32 b);
|
void send(uint32 b);
|
||||||
void pause(bool pause);
|
void pause(bool pause);
|
||||||
void set_stream_callback(void *param, StreamCallback *sc);
|
void set_stream_callback(void *param, StreamCallback *sc);
|
||||||
|
static int midiemu_callback_thread(void *param);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct midi_channel {
|
struct midi_channel {
|
||||||
|
@ -1001,9 +1002,9 @@ private:
|
||||||
StreamCallback *_stream_proc;
|
StreamCallback *_stream_proc;
|
||||||
void *_stream_param;
|
void *_stream_param;
|
||||||
int _mode;
|
int _mode;
|
||||||
FM_OPL *_opl;
|
|
||||||
int chp[9][3];
|
int chp[9][3];
|
||||||
unsigned char myinsbank[128][11];
|
unsigned char myinsbank[128][11];
|
||||||
|
FM_OPL *_opl;
|
||||||
midi_channel ch[16];
|
midi_channel ch[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1035,8 +1036,10 @@ MidiDriver_MIDIEMU::MidiDriver_MIDIEMU(){
|
||||||
}
|
}
|
||||||
|
|
||||||
int MidiDriver_MIDIEMU::open(int mode) {
|
int MidiDriver_MIDIEMU::open(int mode) {
|
||||||
_opl = OPLCreate(OPL_TYPE_YM3812, 3579545, g_scumm->_system->property(OSystem::PROP_GET_SAMPLE_RATE,0));
|
_opl = OPLCreate(OPL_TYPE_YM3812, 3579545, g_system->property(OSystem::PROP_GET_SAMPLE_RATE,0));
|
||||||
g_scumm->_mixer->setup_premix((void*) this, premix_proc);
|
g_mixer->setup_premix((void*) this, premix_proc);
|
||||||
|
if (_stream_proc)
|
||||||
|
g_system->create_thread(midiemu_callback_thread, this);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1242,6 +1245,46 @@ void MidiDriver_MIDIEMU::pause(bool pause) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define NUMBER_MIDI_EVENTS 64
|
||||||
|
|
||||||
|
int MidiDriver_MIDIEMU::midiemu_callback_thread(void *param) {
|
||||||
|
MidiDriver_MIDIEMU *driver = (MidiDriver_MIDIEMU*) param;
|
||||||
|
MidiEvent my_evs[NUMBER_MIDI_EVENTS];
|
||||||
|
bool need_midi_data = true;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
int number;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (need_midi_data) {
|
||||||
|
number = driver->_stream_proc(driver->_stream_param, my_evs, NUMBER_MIDI_EVENTS);
|
||||||
|
if (!number) {
|
||||||
|
// No MIDI data available for the moment
|
||||||
|
g_system->delay_msecs(10);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
need_midi_data = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0; i<number; i++) {
|
||||||
|
uint32 event;
|
||||||
|
|
||||||
|
event = my_evs[i].event;
|
||||||
|
if ((event>>24) == ME_TEMPO) {
|
||||||
|
event = (MEVT_TEMPO << 24) | (event & 0xFFFFFF);
|
||||||
|
}
|
||||||
|
driver->send(event);
|
||||||
|
if (my_evs[i].delta) {
|
||||||
|
g_system->delay_msecs(my_evs[i].delta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
need_midi_data = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void MidiDriver_MIDIEMU::set_stream_callback(void *param, StreamCallback *sc) {
|
void MidiDriver_MIDIEMU::set_stream_callback(void *param, StreamCallback *sc) {
|
||||||
_stream_param = param;
|
_stream_param = param;
|
||||||
_stream_proc = sc;
|
_stream_proc = sc;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue