Remove SCUMM dependancies from SDL.C - This fixes a regular crash in Simon due to the autosaver.

This changes the OSystem interface. Porters beware.

svn-id: r4318
This commit is contained in:
James Brown 2002-05-14 18:14:16 +00:00
parent b5a8bb6b2a
commit a592de4333
8 changed files with 35 additions and 25 deletions

View file

@ -464,6 +464,7 @@ Credits:
Thanks! Thanks!
Special thanks to: Special thanks to:
Sander Buskens - For his work on the initial reversing of Monkey2
Jimmi Thogersen - For ScummRev, and much obscure code/documentation Jimmi Thogersen - For ScummRev, and much obscure code/documentation
Kevin Carnes - For Scumm16, the basis of ScummVM older gfx codecs Kevin Carnes - For Scumm16, the basis of ScummVM older gfx codecs

View file

@ -2710,13 +2710,14 @@ void Scumm::decodeParseString()
offset = 0; offset = 0;
delay = (int)((getVarOrDirectWord(0x40) & 0xffff) * 7.5); delay = (int)((getVarOrDirectWord(0x40) & 0xffff) * 7.5);
if (_gameId == GID_LOOM256) { if (_gameId == GID_LOOM256) {
_vars[VAR_MI1_TIMER] = 0;
#ifdef COMPRESSED_SOUND_FILE #ifdef COMPRESSED_SOUND_FILE
if (playMP3CDTrack(1, 0, offset, delay) == -1) if (playMP3CDTrack(1, 0, offset, delay) == -1)
#endif #endif
_system->play_cdrom(1, 0, offset, delay); _system->play_cdrom(1, 0, offset, delay);
} } else {
else
warning("parseString: 8"); warning("parseString: 8");
}
} }
break; break;
case 15: case 15:

View file

@ -1140,7 +1140,8 @@ public:
uint32 _CLUT_offs, _EPAL_offs; uint32 _CLUT_offs, _EPAL_offs;
uint32 _IM00_offs, _PALS_offs; uint32 _IM00_offs, _PALS_offs;
bool _fullScreen, _fullRedraw, _BgNeedsRedraw, _shakeEnabled; //ender: fullscreen
bool _fullRedraw, _BgNeedsRedraw, _shakeEnabled;
bool _screenEffectFlag, _completeScreenRedraw; bool _screenEffectFlag, _completeScreenRedraw;
int _cursorHotspotX, _cursorHotspotY, _cursorWidth, _cursorHeight; int _cursorHotspotX, _cursorHotspotY, _cursorWidth, _cursorHeight;

View file

@ -28,6 +28,12 @@
#include "string.h" #include "string.h"
#include "gameDetector.h" #include "gameDetector.h"
int autosave(int interval) /* Not in class to prevent being bound */
{
g_scumm->_doAutosave = true;
return interval;
}
void Scumm::initRandSeeds() void Scumm::initRandSeeds()
{ {
_randSeed1 = 0xA943DE35; _randSeed1 = 0xA943DE35;
@ -170,6 +176,8 @@ void Scumm::scummInit()
#ifdef COMPRESSED_SOUND_FILE #ifdef COMPRESSED_SOUND_FILE
_current_cache = 0; _current_cache = 0;
#endif #endif
_system->set_timer(5 * 60 * 1000, &autosave);
} }
@ -1198,7 +1206,7 @@ void Scumm::waitForTimer(int msec_delay) {
_fastMode ^= 1; _fastMode ^= 1;
else if (event.kbd.keycode=='g') else if (event.kbd.keycode=='g')
_fastMode ^= 2; _fastMode ^= 2;
else if ((event.kbd.keycode=='d') && (_fullScreen == false)) else if ((event.kbd.keycode=='d') && (!_system->property(OSystem::PROP_GET_FULLSCREEN, 0)))
g_debugger.attach(this); g_debugger.attach(this);
else if (event.kbd.keycode=='s') else if (event.kbd.keycode=='s')
resourceStats(); resourceStats();
@ -1410,7 +1418,7 @@ Scumm *Scumm::createFromDetector(GameDetector *detector, OSystem *syst)
g_scumm = scumm; g_scumm = scumm;
/* END HACK */ /* END HACK */
scumm->_fullScreen = detector->_fullScreen; // scumm->_fullScreen = detector->_fullScreen;
scumm->_debugMode = detector->_debugMode; scumm->_debugMode = detector->_debugMode;
scumm->_bootParam = detector->_bootParam; scumm->_bootParam = detector->_bootParam;
scumm->_gameDataPath = detector->_gameDataPath; scumm->_gameDataPath = detector->_gameDataPath;

25
sdl.cpp
View file

@ -96,6 +96,9 @@ public:
// Set a parameter // Set a parameter
uint32 property(int param, Property *value); uint32 property(int param, Property *value);
// Add a callback timer
void set_timer(int timer, void* callback);
static OSystem *create(int gfx_mode, bool full_screen); static OSystem *create(int gfx_mode, bool full_screen);
private: private:
@ -176,8 +179,7 @@ private:
void hotswap_gfx_mode(); void hotswap_gfx_mode();
void get_320x200_image(byte *buf); void get_320x200_image(byte *buf);
static uint32 autosave(uint32);
void setup_icon(); void setup_icon();
}; };
@ -203,14 +205,6 @@ void atexit_proc() {
SDL_Quit(); SDL_Quit();
} }
uint32 OSystem_SDL::autosave(uint32 interval)
{
g_scumm->_doAutosave = true;
return interval;
}
OSystem *OSystem_SDL::create(int gfx_mode, bool full_screen) { OSystem *OSystem_SDL::create(int gfx_mode, bool full_screen) {
OSystem_SDL *syst = new OSystem_SDL(); OSystem_SDL *syst = new OSystem_SDL();
syst->_mode = gfx_mode; syst->_mode = gfx_mode;
@ -225,7 +219,6 @@ OSystem *OSystem_SDL::create(int gfx_mode, bool full_screen) {
#endif /* doesn't do COOPERATIVE mode*/ #endif /* doesn't do COOPERATIVE mode*/
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
SDL_SetTimer(5 * 60 * 1000, (SDL_TimerCallback) autosave);
/* Setup the icon */ /* Setup the icon */
syst->setup_icon(); syst->setup_icon();
@ -236,6 +229,9 @@ OSystem *OSystem_SDL::create(int gfx_mode, bool full_screen) {
return syst; return syst;
} }
void OSystem_SDL::set_timer(int timer, void* callback) {
SDL_SetTimer(timer, (SDL_TimerCallback) callback);
}
OSystem *OSystem_SDL_create(int gfx_mode, bool full_screen) { OSystem *OSystem_SDL_create(int gfx_mode, bool full_screen) {
return OSystem_SDL::create(gfx_mode, full_screen); return OSystem_SDL::create(gfx_mode, full_screen);
} }
@ -891,7 +887,6 @@ uint32 OSystem_SDL::property(int param, Property *value) {
case PROP_TOGGLE_FULLSCREEN: case PROP_TOGGLE_FULLSCREEN:
_full_screen ^= true; _full_screen ^= true;
g_scumm->_fullScreen = _full_screen;
if (!SDL_WM_ToggleFullScreen(sdl_hwscreen)) { if (!SDL_WM_ToggleFullScreen(sdl_hwscreen)) {
/* if ToggleFullScreen fails, achieve the same effect with hotswap gfx mode */ /* if ToggleFullScreen fails, achieve the same effect with hotswap gfx mode */
@ -899,6 +894,9 @@ uint32 OSystem_SDL::property(int param, Property *value) {
} }
return 1; return 1;
case PROP_GET_FULLSCREEN:
return _full_screen;
case PROP_SET_WINDOW_CAPTION: case PROP_SET_WINDOW_CAPTION:
SDL_WM_SetCaption(value->caption, value->caption); SDL_WM_SetCaption(value->caption, value->caption);
return 1; return 1;
@ -1050,9 +1048,6 @@ void OSystem_SDL::stop_cdrom() { /* Stop CD Audio in 1/10th of a second */
} }
void OSystem_SDL::play_cdrom(int track, int num_loops, int start_frame, int end_frame) { void OSystem_SDL::play_cdrom(int track, int num_loops, int start_frame, int end_frame) {
/* Reset sync count */
g_scumm->_vars[g_scumm->VAR_MI1_TIMER] = 0;
if (!num_loops && !start_frame) if (!num_loops && !start_frame)
return; return;

View file

@ -47,11 +47,6 @@ void fileWriteBE16(FILE *in, uint16 value);
#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
#define CHECK_BOUNDS(x,y) assert((uint)(x)<ARRAYSIZE(y)) #define CHECK_BOUNDS(x,y) assert((uint)(x)<ARRAYSIZE(y))
enum {
CHILD1_SIZE = 12,
CHILD2_SIZE = 16
};
struct Child { struct Child {
Child *next; Child *next;
uint16 type; uint16 type;
@ -87,6 +82,10 @@ struct ThreeValues {
uint16 a, b, c; uint16 a, b, c;
}; };
enum {
CHILD1_SIZE = sizeof(Child1) - sizeof(uint16),
CHILD2_SIZE = sizeof(Child2) - sizeof(int16)
};
struct Item { struct Item {
uint16 parent; uint16 parent;

View file

@ -160,6 +160,7 @@ void Scumm::playSound(int sound)
ptr = getResourceAddress(rtSound, sound); ptr = getResourceAddress(rtSound, sound);
if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) { if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) {
ptr += 8; ptr += 8;
_vars[VAR_MI1_TIMER] = 0;
#ifdef COMPRESSED_SOUND_FILE #ifdef COMPRESSED_SOUND_FILE
if ((playMP3CDTrack(ptr[16], ptr[17] == 0xff ? -1 : ptr[17], if ((playMP3CDTrack(ptr[16], ptr[17] == 0xff ? -1 : ptr[17],
(ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0)) == -1) (ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0)) == -1)

View file

@ -62,6 +62,7 @@ public:
PROP_SET_GFX_MODE = 4, PROP_SET_GFX_MODE = 4,
PROP_SHOW_DEFAULT_CURSOR = 5, PROP_SHOW_DEFAULT_CURSOR = 5,
PROP_GET_SAMPLE_RATE = 6, PROP_GET_SAMPLE_RATE = 6,
PROP_GET_FULLSCREEN = 7
}; };
union Property { union Property {
char *caption; char *caption;
@ -135,6 +136,9 @@ public:
// Update cdrom audio status // Update cdrom audio status
virtual void update_cdrom() = 0; virtual void update_cdrom() = 0;
// Add a new callback timer
virtual void set_timer(int timer, void* callback) = 0;
// Quit // Quit
virtual void quit() = 0; virtual void quit() = 0;
}; };