aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/he
diff options
context:
space:
mode:
Diffstat (limited to 'engines/scumm/he')
-rw-r--r--engines/scumm/he/animation_he.h1
-rw-r--r--engines/scumm/he/intern_he.h1
-rw-r--r--engines/scumm/he/logic/football.cpp101
-rw-r--r--engines/scumm/he/script_v100he.cpp3
-rw-r--r--engines/scumm/he/script_v60he.cpp4
-rw-r--r--engines/scumm/he/sound_he.cpp26
-rw-r--r--engines/scumm/he/wiz_he.cpp6
7 files changed, 123 insertions, 19 deletions
diff --git a/engines/scumm/he/animation_he.h b/engines/scumm/he/animation_he.h
index 7fa31a195d..e17c1b9a39 100644
--- a/engines/scumm/he/animation_he.h
+++ b/engines/scumm/he/animation_he.h
@@ -55,7 +55,6 @@ private:
Video::VideoDecoder *_video;
- char baseName[40];
uint32 _flags;
uint32 _wizResNum;
};
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index fc5e4bcdf0..a674288775 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -628,7 +628,6 @@ public:
void parseEvents();
- bool _quit;
OSystem *_syst;
GameSettings _game;
diff --git a/engines/scumm/he/logic/football.cpp b/engines/scumm/he/logic/football.cpp
index b405d634a4..ea990ca86b 100644
--- a/engines/scumm/he/logic/football.cpp
+++ b/engines/scumm/he/logic/football.cpp
@@ -218,10 +218,10 @@ int LogicHEfootball::nextPoint(int32 *args) {
if (res >= (double)args[6]) {
var8 = (double)args[6] * var8 / res;
var10 = (double)args[6] * var10 / res;
- res = (double)args[6] * var6 / res;
+ var6 = (double)args[6] * var6 / res;
}
- writeScummVar(108, (int32)res);
+ writeScummVar(108, (int32)var6);
writeScummVar(109, (int32)var10);
writeScummVar(110, (int32)var8);
@@ -297,6 +297,15 @@ private:
int initScreenTranslations();
int getPlaybookFiles(int32 *args);
int largestFreeBlock();
+
+ float _var0;
+ float _var1;
+ float _var2;
+ float _var3;
+ float _var4;
+ float _angle;
+ int32 _maxX;
+ int32 _minX;
};
int32 LogicHEfootball2002::dispatch(int op, int numArgs, int32 *args) {
@@ -325,8 +334,16 @@ int32 LogicHEfootball2002::dispatch(int op, int numArgs, int32 *args) {
res = 1;
break;
+ case 1030:
+ // Get Computer Name (online play only)
+ break;
+
+ case 1515:
+ // Initialize Session (online play only)
+ break;
+
case 1516:
- // Start auto LAN game
+ // Start auto LAN game (online play only)
break;
default:
@@ -338,13 +355,74 @@ int32 LogicHEfootball2002::dispatch(int op, int numArgs, int32 *args) {
}
int LogicHEfootball2002::translateWorldToScreen(int32 *args) {
- // TODO: Implement modified 2002 version
- return LogicHEfootball::translateWorldToScreen(args);
+ // While this performs the same task as football's 1006 opcode,
+ // the implementation is different. Note that this is also the
+ // same as basketball's 1006 opcode with different constants!
+
+ double v9;
+ if (args[1] >= _minX) {
+ if (args[1] < _maxX) {
+ v9 = (sqrt(_var1 + args[1]) - sqrt(_var1)) / sqrt(_var0);
+ } else {
+ double v10 = sqrt(_var0 * (_maxX + _var1));
+ v9 = 1.0 / (v10 + v10) * (args[1] - _maxX) + 451.0;
+ }
+ } else {
+ double v8 = sqrt(_var0 * (_minX + _var1));
+ v9 = 1.0 / (v8 + v8) * (args[1] - _minX) - 29.0;
+ }
+
+ double v11 = tan(_angle);
+ double v12, v13;
+
+ if (v9 >= -29.0) {
+ if (v9 >= 451.0) {
+ v12 = 1517.0 - (451.0 / v11 + 451.0 / v11);
+ v13 = tan(1.570796326794895 - _angle) * 451.0;
+ } else {
+ v12 = 1517.0 - (v9 / v11 + v9 / v11);
+ v13 = tan(1.570796326794895 - _angle) * v9;
+ }
+ } else {
+ v12 = 1517.0 - (-29.0 / v11 + -29.0 / v11);
+ v13 = tan(1.570796326794895 - _angle) * -29.0;
+ }
+
+ writeScummVar(108, scummRound(v12 * args[0] / 12200.0 + v13 + 41.0));
+ writeScummVar(109, scummRound(611.0 - v9 - v12 * args[2] / 12200.0));
+
+ return 1;
}
int LogicHEfootball2002::translateScreenToWorld(int32 *args) {
- // TODO: Implement modified 2002 version
- return LogicHEfootball::translateScreenToWorld(args);
+ // While this performs the same task as football's 1010 opcode,
+ // the implementation is different. Note that this is also the
+ // same as basketball's 1010 opcode with different constants!
+
+ double v15 = 611.0 - args[1];
+ double v5 = tan(_angle);
+ double v4, v6, v7;
+
+ if (v15 >= -29.0) {
+ if (v15 >= 451.0) {
+ v4 = (_var2 * 902.0 + _var3) * (v15 - 451.0) + _maxX;
+ v6 = 1517.0 - (451.0 / v5 + 451.0 / v5);
+ v7 = tan(1.570796326794895 - _angle) * 451.0;
+ } else {
+ v4 = (v15 * _var2 + _var3) * v15 + _var4;
+ v6 = 1517.0 - (v15 / v5 + v15 / v5);
+ v7 = tan(1.570796326794895 - _angle) * v15;
+ }
+ } else {
+ v4 = (_var3 - _var2 * 58.0) * (v15 - -29.0) + _minX;
+ v6 = 1517.0 - (-29.0 / v5 + -29.0 / v5);
+ v7 = tan(1.570796326794895 - _angle) * -29.0;
+ }
+
+ writeScummVar(108, scummRound((args[0] - (v7 + 41.0)) * (12200.0 / v6)));
+ writeScummVar(109, scummRound(v4));
+
+ return 1;
}
int LogicHEfootball2002::getDayOfWeek() {
@@ -358,7 +436,14 @@ int LogicHEfootball2002::getDayOfWeek() {
}
int LogicHEfootball2002::initScreenTranslations() {
- // TODO: Set values used by translateWorldToScreen/translateScreenToWorld
+ // Set values used by translateWorldToScreen/translateScreenToWorld
+ _var0 = _var2 = 0.0029172597f;
+ _var1 = 4896.3755f;
+ _var3 = 7.5588355f;
+ _var4 = 0.0f;
+ _angle = (float)atan(2.899280575539569);
+ _maxX = 4002;
+ _minX = -217;
return 1;
}
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index a2eb42214b..b024154c7f 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -2237,7 +2237,10 @@ void ScummEngine_v100he::o100_videoOps() {
switch (subOp) {
case 0:
memset(_videoParams.filename, 0, sizeof(_videoParams.filename));
+ _videoParams.status = 0;
+ _videoParams.flags = 0;
_videoParams.unk2 = pop();
+ _videoParams.wizResNum = 0;
break;
case 19:
_videoParams.status = 19;
diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp
index 5e359385b6..bbd8725904 100644
--- a/engines/scumm/he/script_v60he.cpp
+++ b/engines/scumm/he/script_v60he.cpp
@@ -804,7 +804,7 @@ void ScummEngine_v60he::o60_readFile() {
int val;
// Fatty Bear uses positive values
- if (_game.platform == Common::kPlatformPC && _game.id == GID_FBEAR)
+ if (_game.platform == Common::kPlatformDOS && _game.id == GID_FBEAR)
size = -size;
assert(_hInFileTable[slot]);
@@ -834,7 +834,7 @@ void ScummEngine_v60he::o60_writeFile() {
int slot = pop();
// Fatty Bear uses positive values
- if (_game.platform == Common::kPlatformPC && _game.id == GID_FBEAR)
+ if (_game.platform == Common::kPlatformDOS && _game.id == GID_FBEAR)
size = -size;
assert(_hOutFileTable[slot]);
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index f94b74ac45..1afb1b4074 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -804,7 +804,7 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) {
byte *snd1Ptr, *snd2Ptr;
byte *sbng1Ptr, *sbng2Ptr;
byte *sdat1Ptr, *sdat2Ptr;
- byte *src, *dst, *tmp;
+ byte *src, *dst;
int len, offs, size;
int sdat1size, sdat2size;
@@ -844,6 +844,7 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) {
if (sbng1Ptr != NULL && sbng2Ptr != NULL) {
if (chan != -1 && ((SoundHE *)_sound)->_heChannel[chan].codeOffs > 0) {
+ // Copy any code left over to the beginning of the code block
int curOffs = ((SoundHE *)_sound)->_heChannel[chan].codeOffs;
src = snd1Ptr + curOffs;
@@ -851,29 +852,33 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) {
size = READ_BE_UINT32(sbng1Ptr + 4);
len = sbng1Ptr - snd1Ptr + size - curOffs;
- byte *data = (byte *)malloc(len);
- memcpy(data, src, len);
- memcpy(dst, data, len);
- free(data);
+ memmove(dst, src, len);
+ // Now seek to the end of this code block
dst = sbng1Ptr + 8;
while ((size = READ_LE_UINT16(dst)) != 0)
dst += size;
} else {
+ // We're going to overwrite the code block completely
dst = sbng1Ptr + 8;
}
- ((SoundHE *)_sound)->_heChannel[chan].codeOffs = sbng1Ptr - snd1Ptr + 8;
+ // Reset the current code offset to the beginning of the code block
+ if (chan >= 0)
+ ((SoundHE *)_sound)->_heChannel[chan].codeOffs = sbng1Ptr - snd1Ptr + 8;
- tmp = sbng2Ptr + 8;
+ // Seek to the end of the code block for sound 2
+ byte *tmp = sbng2Ptr + 8;
while ((offs = READ_LE_UINT16(tmp)) != 0) {
tmp += offs;
}
+ // Copy the code block for sound 2 to the code block for sound 1
src = sbng2Ptr + 8;
len = tmp - sbng2Ptr - 6;
memcpy(dst, src, len);
+ // Rewrite the time for this new code block to be after the sound 1 code block
int32 time;
while ((size = READ_LE_UINT16(dst)) != 0) {
time = READ_LE_UINT32(dst + 2);
@@ -883,6 +888,7 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) {
}
}
+ // Find the data pointers and sizes
if (findSoundTag(MKTAG('d','a','t','a'), snd1Ptr)) {
sdat1Ptr = findSoundTag(MKTAG('d','a','t','a'), snd1Ptr);
assert(sdat1Ptr);
@@ -906,6 +912,8 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) {
sdat1size = _sndDataSize - _sndPtrOffs;
if (sdat2size < sdat1size) {
+ // We have space leftover at the end of sound 1
+ // -> Just append sound 2
src = sdat2Ptr + 8;
dst = sdat1Ptr + 8 + _sndPtrOffs;
len = sdat2size;
@@ -915,6 +923,8 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) {
_sndPtrOffs += sdat2size;
_sndTmrOffs += sdat2size;
} else {
+ // We might not have enough space leftover at the end of sound 1
+ // -> Append as much of possible of sound 2 to sound 1
src = sdat2Ptr + 8;
dst = sdat1Ptr + 8 + _sndPtrOffs;
len = sdat1size;
@@ -922,6 +932,8 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) {
memcpy(dst, src, len);
if (sdat2size != sdat1size) {
+ // We don't have enough space
+ // -> Start overwriting the beginning of the sound again
src = sdat2Ptr + 8 + sdat1size;
dst = sdat1Ptr + 8;
len = sdat2size - sdat1size;
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 798f703db6..ca360803bd 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1548,12 +1548,18 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
if (rScreen.intersects(clip)) {
rScreen.clip(clip);
} else {
+ if (flags & kWIFBlitToMemBuffer)
+ free(dst);
+
return 0;
}
} else if (_rectOverrideEnabled) {
if (rScreen.intersects(_rectOverride)) {
rScreen.clip(_rectOverride);
} else {
+ if (flags & kWIFBlitToMemBuffer)
+ free(dst);
+
return 0;
}
}