aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2002-11-10 17:19:43 +0000
committerMax Horn2002-11-10 17:19:43 +0000
commitda5a347d3e6220f6dcd141706e9fb6243bb6d319 (patch)
tree19d11d67abe1dd6b3b32faa7a33a578a38e6100e /scumm
parent2965bd27086e443018cc9d63ac59befc884eed5b (diff)
downloadscummvm-rg350-da5a347d3e6220f6dcd141706e9fb6243bb6d319.tar.gz
scummvm-rg350-da5a347d3e6220f6dcd141706e9fb6243bb6d319.tar.bz2
scummvm-rg350-da5a347d3e6220f6dcd141706e9fb6243bb6d319.zip
completly decoupled engine.h/.cpp from simon.h and scumm.h; removed some static variables from drawFlashlight() and made them members of class Scumm instead
svn-id: r5506
Diffstat (limited to 'scumm')
-rw-r--r--scumm/gfx.cpp63
-rw-r--r--scumm/scumm.h4
-rw-r--r--scumm/scummvm.cpp21
3 files changed, 55 insertions, 33 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index 36cb8b092b..daa3a861fb 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -612,26 +612,23 @@ void Scumm::moveMemInPalRes(int start, int end, byte direction)
void Scumm::drawFlashlight()
{
- static byte *flashBuffer = NULL;
- static int flashX, flashY, flashW, flashH;
-
int i, j, offset;
// Remove the flash light first if it was previously drawn
if (_flashlightIsDrawn) {
- updateDirtyRect(0, flashX<<3, (flashX+flashW)<<3, flashY, flashY+flashH, 0x80000000);
+ updateDirtyRect(0, _flashlight.x<<3, (_flashlight.x+_flashlight.w)<<3, _flashlight.y, _flashlight.y+_flashlight.h, 0x80000000);
- if (flashBuffer) {
+ if (_flashlight.buffer) {
- offset = _realWidth - flashW*8;
- i = flashH;
+ offset = _realWidth - _flashlight.w*8;
+ i = _flashlight.h;
do {
- j = flashW*2;
+ j = _flashlight.w*2;
do {
- *(uint32 *)flashBuffer = 0;
- flashBuffer += 4;
+ *(uint32 *)_flashlight.buffer = 0;
+ _flashlight.buffer += 4;
} while (--j);
- flashBuffer += offset;
+ _flashlight.buffer += offset;
} while (--i);
}
@@ -643,50 +640,50 @@ void Scumm::drawFlashlight()
// Calculate the area of the flashlight
Actor *a = a = derefActorSafe(_vars[VAR_EGO], "drawFlashlight");
- flashW = _flashlightXStrips;
- flashH = _flashlightYStrips * 8;
- flashX = a->x/8 - flashW/2 - _screenStartStrip;
- flashY = a->y - flashH/2;
+ _flashlight.w = _flashlightXStrips;
+ _flashlight.h = _flashlightYStrips * 8;
+ _flashlight.x = a->x/8 - _flashlight.w/2 - _screenStartStrip;
+ _flashlight.y = a->y - _flashlight.h/2;
// Clip the flashlight at the borders
- if (flashX < 0)
- flashX = 0;
- else if (flashX > gdi._numStrips - flashW)
- flashX = gdi._numStrips - flashW;
- if (flashY < 0)
- flashY = 0;
- else if (flashY > virtscr[0].height - flashH)
- flashY = virtscr[0].height - flashH;
+ if (_flashlight.x < 0)
+ _flashlight.x = 0;
+ else if (_flashlight.x > gdi._numStrips - _flashlight.w)
+ _flashlight.x = gdi._numStrips - _flashlight.w;
+ if (_flashlight.y < 0)
+ _flashlight.y = 0;
+ else if (_flashlight.y > virtscr[0].height - _flashlight.h)
+ _flashlight.y = virtscr[0].height - _flashlight.h;
// Redraw any actors "under" the flashlight
- for (i = flashX; i < flashX+flashW; i++) {
+ for (i = _flashlight.x; i < _flashlight.x+_flashlight.w; i++) {
gfxUsageBits[_screenStartStrip + i] |= 0x80000000;
virtscr[0].tdirty[i] = 0;
virtscr[0].bdirty[i] = virtscr[0].height;
}
byte *bgbak;
- offset = flashY * _realWidth + virtscr[0].xstart + flashX * 8;
- flashBuffer = virtscr[0].screenPtr + offset;
+ offset = _flashlight.y * _realWidth + virtscr[0].xstart + _flashlight.x * 8;
+ _flashlight.buffer = virtscr[0].screenPtr + offset;
bgbak = getResourceAddress(rtBuffer, 5) + offset;
- blit(flashBuffer, bgbak, flashW*8, flashH);
+ blit(_flashlight.buffer, bgbak, _flashlight.w*8, _flashlight.h);
// Round the corners. To do so, we simply hard-code a set of nicely
// rounded corners.
int corner_data[] = { 8, 6, 4, 3, 2, 2, 1, 1 };
int minrow = 0;
- int maxcol = flashW * 8 - 1;
- int maxrow = (flashH - 1) * _realWidth;
+ int maxcol = _flashlight.w * 8 - 1;
+ int maxrow = (_flashlight.h - 1) * _realWidth;
for (i = 0; i < 8; i++, minrow += _realWidth, maxrow -= _realWidth) {
int d = corner_data[i];
for (j = 0; j < d; j++) {
- flashBuffer[minrow + j] = 0;
- flashBuffer[minrow + maxcol - j] = 0;
- flashBuffer[maxrow + j] = 0;
- flashBuffer[maxrow + maxcol - j] = 0;
+ _flashlight.buffer[minrow + j] = 0;
+ _flashlight.buffer[minrow + maxcol - j] = 0;
+ _flashlight.buffer[maxrow + j] = 0;
+ _flashlight.buffer[maxrow + maxcol - j] = 0;
}
}
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 6186c8b7fc..2255596d1f 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -714,6 +714,10 @@ public:
byte _newEffect, _switchRoomEffect2, _switchRoomEffect;
bool _doEffect;
+ struct {
+ int x, y, w, h;
+ byte *buffer;
+ } _flashlight;
uint16 _flashlightXStrips, _flashlightYStrips;
bool _flashlightIsDrawn;
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index 0f1e69ac08..9cd5fe20e8 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -51,6 +51,26 @@ void autosave(void * engine)
g_scumm->_doAutosave = true;
}
+Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst)
+{
+ Engine *engine;
+
+ if (detector->_features & GF_OLD_BUNDLE)
+ engine = new Scumm_v2(detector, syst);
+ else if (detector->_features & GF_OLD256)
+ engine = new Scumm_v3(detector, syst);
+ else if (detector->_features & GF_SMALL_HEADER) // this forces loomCD as v4
+ engine = new Scumm_v4(detector, syst);
+ else if (detector->_features & GF_AFTER_V7)
+ engine = new Scumm_v7(detector, syst);
+ else if (detector->_features & GF_AFTER_V6) // this forces SamnmaxCD as v6
+ engine = new Scumm_v6(detector, syst);
+ else
+ engine = new Scumm_v5(detector, syst);
+
+ return engine;
+}
+
void Scumm::initRandSeeds()
{
_randSeed1 = 0xA943DE33;
@@ -265,6 +285,7 @@ void Scumm::scummInit()
_vars[VAR_CURRENT_LIGHTS] = LIGHTMODE_actor_base | LIGHTMODE_actor_color | LIGHTMODE_screen;
_flashlightXStrips = 7;
_flashlightYStrips = 7;
+ _flashlight.buffer = NULL;
}
mouse.x = 104;