diff options
author | James Brown | 2002-05-14 18:14:16 +0000 |
---|---|---|
committer | James Brown | 2002-05-14 18:14:16 +0000 |
commit | a592de43330c4ab1162b83599e12e70696cb661c (patch) | |
tree | 4d6d4b0296fdb2fa34ae89fec6925a766f29506c | |
parent | b5a8bb6b2a3e8ae28ca4cee1464395cb6302acb7 (diff) | |
download | scummvm-rg350-a592de43330c4ab1162b83599e12e70696cb661c.tar.gz scummvm-rg350-a592de43330c4ab1162b83599e12e70696cb661c.tar.bz2 scummvm-rg350-a592de43330c4ab1162b83599e12e70696cb661c.zip |
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
-rw-r--r-- | readme.txt | 1 | ||||
-rw-r--r-- | script_v1.cpp | 5 | ||||
-rw-r--r-- | scumm.h | 3 | ||||
-rw-r--r-- | scummvm.cpp | 12 | ||||
-rw-r--r-- | sdl.cpp | 25 | ||||
-rw-r--r-- | simon/simon.h | 9 | ||||
-rw-r--r-- | sound.cpp | 1 | ||||
-rw-r--r-- | system.h | 4 |
8 files changed, 35 insertions, 25 deletions
diff --git a/readme.txt b/readme.txt index 9a281ff3c6..3ce3d0685c 100644 --- a/readme.txt +++ b/readme.txt @@ -464,6 +464,7 @@ Credits: Thanks! Special thanks to: + Sander Buskens - For his work on the initial reversing of Monkey2 Jimmi Thogersen - For ScummRev, and much obscure code/documentation Kevin Carnes - For Scumm16, the basis of ScummVM older gfx codecs diff --git a/script_v1.cpp b/script_v1.cpp index 607bdb11f3..ebf149fa1c 100644 --- a/script_v1.cpp +++ b/script_v1.cpp @@ -2710,13 +2710,14 @@ void Scumm::decodeParseString() offset = 0; delay = (int)((getVarOrDirectWord(0x40) & 0xffff) * 7.5); if (_gameId == GID_LOOM256) { + _vars[VAR_MI1_TIMER] = 0; #ifdef COMPRESSED_SOUND_FILE if (playMP3CDTrack(1, 0, offset, delay) == -1) #endif _system->play_cdrom(1, 0, offset, delay); - } - else + } else { warning("parseString: 8"); + } } break; case 15: @@ -1140,7 +1140,8 @@ public: uint32 _CLUT_offs, _EPAL_offs; uint32 _IM00_offs, _PALS_offs; - bool _fullScreen, _fullRedraw, _BgNeedsRedraw, _shakeEnabled; + //ender: fullscreen + bool _fullRedraw, _BgNeedsRedraw, _shakeEnabled; bool _screenEffectFlag, _completeScreenRedraw; int _cursorHotspotX, _cursorHotspotY, _cursorWidth, _cursorHeight; diff --git a/scummvm.cpp b/scummvm.cpp index a80a2e97a7..e6e1af29b8 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -28,6 +28,12 @@ #include "string.h" #include "gameDetector.h" +int autosave(int interval) /* Not in class to prevent being bound */ +{ + g_scumm->_doAutosave = true; + return interval; +} + void Scumm::initRandSeeds() { _randSeed1 = 0xA943DE35; @@ -170,6 +176,8 @@ void Scumm::scummInit() #ifdef COMPRESSED_SOUND_FILE _current_cache = 0; #endif + + _system->set_timer(5 * 60 * 1000, &autosave); } @@ -1198,7 +1206,7 @@ void Scumm::waitForTimer(int msec_delay) { _fastMode ^= 1; else if (event.kbd.keycode=='g') _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); else if (event.kbd.keycode=='s') resourceStats(); @@ -1410,7 +1418,7 @@ Scumm *Scumm::createFromDetector(GameDetector *detector, OSystem *syst) g_scumm = scumm; /* END HACK */ - scumm->_fullScreen = detector->_fullScreen; +// scumm->_fullScreen = detector->_fullScreen; scumm->_debugMode = detector->_debugMode; scumm->_bootParam = detector->_bootParam; scumm->_gameDataPath = detector->_gameDataPath; @@ -96,6 +96,9 @@ public: // Set a parameter 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); private: @@ -176,8 +179,7 @@ private: void hotswap_gfx_mode(); - void get_320x200_image(byte *buf); - static uint32 autosave(uint32); + void get_320x200_image(byte *buf); void setup_icon(); }; @@ -203,14 +205,6 @@ void atexit_proc() { 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_SDL *syst = new OSystem_SDL(); syst->_mode = gfx_mode; @@ -225,7 +219,6 @@ OSystem *OSystem_SDL::create(int gfx_mode, bool full_screen) { #endif /* doesn't do COOPERATIVE mode*/ SDL_ShowCursor(SDL_DISABLE); - SDL_SetTimer(5 * 60 * 1000, (SDL_TimerCallback) autosave); /* Setup the icon */ syst->setup_icon(); @@ -236,6 +229,9 @@ OSystem *OSystem_SDL::create(int gfx_mode, bool full_screen) { 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) { return OSystem_SDL::create(gfx_mode, full_screen); } @@ -891,7 +887,6 @@ uint32 OSystem_SDL::property(int param, Property *value) { case PROP_TOGGLE_FULLSCREEN: _full_screen ^= true; - g_scumm->_fullScreen = _full_screen; if (!SDL_WM_ToggleFullScreen(sdl_hwscreen)) { /* 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; + case PROP_GET_FULLSCREEN: + return _full_screen; + case PROP_SET_WINDOW_CAPTION: SDL_WM_SetCaption(value->caption, value->caption); 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) { - /* Reset sync count */ - g_scumm->_vars[g_scumm->VAR_MI1_TIMER] = 0; - if (!num_loops && !start_frame) return; diff --git a/simon/simon.h b/simon/simon.h index 9f8801b6a6..464d4fe23a 100644 --- a/simon/simon.h +++ b/simon/simon.h @@ -47,11 +47,6 @@ void fileWriteBE16(FILE *in, uint16 value); #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) #define CHECK_BOUNDS(x,y) assert((uint)(x)<ARRAYSIZE(y)) -enum { - CHILD1_SIZE = 12, - CHILD2_SIZE = 16 -}; - struct Child { Child *next; uint16 type; @@ -87,6 +82,10 @@ struct ThreeValues { uint16 a, b, c; }; +enum { + CHILD1_SIZE = sizeof(Child1) - sizeof(uint16), + CHILD2_SIZE = sizeof(Child2) - sizeof(int16) +}; struct Item { uint16 parent; @@ -160,6 +160,7 @@ void Scumm::playSound(int sound) ptr = getResourceAddress(rtSound, sound); if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) { ptr += 8; + _vars[VAR_MI1_TIMER] = 0; #ifdef COMPRESSED_SOUND_FILE if ((playMP3CDTrack(ptr[16], ptr[17] == 0xff ? -1 : ptr[17], (ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0)) == -1) @@ -62,6 +62,7 @@ public: PROP_SET_GFX_MODE = 4, PROP_SHOW_DEFAULT_CURSOR = 5, PROP_GET_SAMPLE_RATE = 6, + PROP_GET_FULLSCREEN = 7 }; union Property { char *caption; @@ -135,6 +136,9 @@ public: // Update cdrom audio status virtual void update_cdrom() = 0; + // Add a new callback timer + virtual void set_timer(int timer, void* callback) = 0; + // Quit virtual void quit() = 0; }; |