aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Hamm2002-03-21 00:40:18 +0000
committerVincent Hamm2002-03-21 00:40:18 +0000
commit3858266b66e67723437c953a0619fd26af40e3a3 (patch)
tree9d6b5d5fc4a172897a7dec0886b280a578e03239
parentd2d2ae7e7df7aee8fb08f2381a995d6250168869 (diff)
downloadscummvm-rg350-3858266b66e67723437c953a0619fd26af40e3a3.tar.gz
scummvm-rg350-3858266b66e67723437c953a0619fd26af40e3a3.tar.bz2
scummvm-rg350-3858266b66e67723437c953a0619fd26af40e3a3.zip
Completly change the way the Scumm object is handled. Now the main execution loop is done INSIDE the Scumm object. Low level system access (like delays, cd tracks,...) are called using the _system object. Changed the insane main loop to use _system calls
svn-id: r3795
-rw-r--r--gfx.cpp2
-rw-r--r--insane.cpp8
-rw-r--r--scumm.h17
-rw-r--r--scummvm.cpp10
-rw-r--r--sdl.cpp44
5 files changed, 56 insertions, 25 deletions
diff --git a/gfx.cpp b/gfx.cpp
index 7a18cf6902..f94ca047d2 100644
--- a/gfx.cpp
+++ b/gfx.cpp
@@ -87,7 +87,7 @@ void Scumm::initVirtScreen(int slot, int top, int height, bool twobufs, bool fou
size += 320*4;
// createResource(rtBuffer, slot+1, size);
- vs->screenPtr = _videoBuffer+320*top;
+ vs->screenPtr = _videoBuffer+328*top;
if (twobufs) {
createResource(rtBuffer, slot+5, size);
diff --git a/insane.cpp b/insane.cpp
index 6b45036084..3a89efbb07 100644
--- a/insane.cpp
+++ b/insane.cpp
@@ -109,7 +109,7 @@ bool SmushPlayer::parseTag() {
void SmushPlayer::parseAHDR() {
-// memcpy(_fluPalette, _block, 0x300);
+ memcpy(_fluPalette, _block, 0x300);
_paletteChanged = true;
printf("parse AHDR\n");
@@ -591,7 +591,7 @@ void SmushPlayer::startVideo(short int arg, byte* videoFile)
if(_in==NULL)
return;
- if (fileReadBE32() != 'ANIM')
+ if (fileReadBE32() != 'ANIM')
error("file is not an anim");
fileSize=fileReadBE32();
@@ -612,8 +612,8 @@ void SmushPlayer::startVideo(short int arg, byte* videoFile)
blitToScreen(sm,sm->_videoBuffer, 0, 0, 320 ,200);
updateScreen(sm);
- waitForTimer(sm,20);
-
+ sm->delta = sm->_system->waitTick(sm->delta);
+
if(sm->_keyPressed == sm->_vars[sm->VAR_CUTSCENEEXIT_KEY])
return;
} while (1);
diff --git a/scumm.h b/scumm.h
index bbcf225d19..c24886d03d 100644
--- a/scumm.h
+++ b/scumm.h
@@ -24,6 +24,8 @@
#include <mad.h>
#endif
+#include "system.h"
+
#if defined(macintosh) && !defined(__APPLE__CW)
#define Point SCUMM_Point
#endif
@@ -923,11 +925,20 @@ public:
/* video buffer */
- byte _videoBuffer[320*200];
- byte _svideoBuffer[320*200+4*320];
+ byte _videoBuffer[328*200]; // main video buffer
+
+ /* system call object */
+
+ OSystem *_system;
+
+ /* Scumm main loop */
+
+ void mainRun();
+ int delta; // global time
+
void scummInit();
- void scummMain(int argc, char **argv);
+ void scummMain(int argc, char **argv); // is it still used ?
int scummLoop(int delta);
void initScummVars();
diff --git a/scummvm.cpp b/scummvm.cpp
index 37aba0e60f..66f56c6235 100644
--- a/scummvm.cpp
+++ b/scummvm.cpp
@@ -1332,3 +1332,13 @@ void checkHeap() {
#endif
}
+void Scumm::mainRun() {
+
+ delta=0;
+
+ do
+ {
+ _system->waitTick(delta);
+ delta = scummLoop(delta);
+ }while(1);
+}
diff --git a/sdl.cpp b/sdl.cpp
index a4779e184c..77e3c8a53c 100644
--- a/sdl.cpp
+++ b/sdl.cpp
@@ -35,6 +35,7 @@ static unsigned int scale;
Scumm scumm;
ScummDebugger debugger;
Gui gui;
+OSystem _system;
SoundEngine sound;
SOUND_DRIVER_TYPE snd_driv;
@@ -922,25 +923,17 @@ int main(int argc, char* argv[]) {
scumm._gui = &gui;
gui.init(&scumm);
sound.initialize(&scumm, &snd_driv);
- scumm.scummMain(argc, argv);
+
+ scumm.delta=0;
+ scumm._system = &_system;
+
+ scumm.scummMain(argc, argv); // Todo: need to change that as well
+
gui.init(&scumm); /* Reinit GUI after loading a game */
- last_time = SDL_GetTicks();
- delta = 0;
- do {
- updateScreen(&scumm);
-
- new_time = SDL_GetTicks();
- waitForTimer(&scumm, delta * 15 + last_time - new_time);
- last_time = SDL_GetTicks();
-
- if (gui._active) {
- gui.loop();
- delta = 5;
- } else {
- delta = scumm.scummLoop(delta);
- }
- } while(1);
+ _system.last_time = SDL_GetTicks();
+
+ scumm.mainRun();
return 0;
}
@@ -1958,3 +1951,20 @@ void Scale_2xSaI (uint8 *srcPtr, uint32 srcPitch, uint8 * /* deltaPtr */,
dstPtr += dstPitch;
}
}
+
+
+/********* ScummVM call back functions **********/
+
+int OSystem::waitTick(int delta)
+{
+ updateScreen(&scumm);
+ new_time = SDL_GetTicks();
+ waitForTimer(&scumm, delta * 15 + last_time - new_time);
+ last_time = SDL_GetTicks();
+ if (gui._active) {
+ gui.loop();
+ delta = 5;
+ }
+
+ return(delta);
+}