aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/simon/debug.cpp11
-rw-r--r--engines/simon/debug.h62
-rw-r--r--engines/simon/simon.cpp52
-rw-r--r--engines/simon/simon.h5
-rw-r--r--engines/simon/vga.cpp121
5 files changed, 193 insertions, 58 deletions
diff --git a/engines/simon/debug.cpp b/engines/simon/debug.cpp
index 8414dd4cfd..30a8b4cad7 100644
--- a/engines/simon/debug.cpp
+++ b/engines/simon/debug.cpp
@@ -210,13 +210,10 @@ void SimonEngine::dump_video_script(const byte *src, bool one_opcode_only) {
case 'b':
fprintf(_dumpFile, "%d ", *src++);
break;
- case 'd': {
- int16 tmp = (int16)readUint16Wrapper(src);
- if (tmp < 0) tmp = vcReadVar(-tmp);
- fprintf(_dumpFile, "%d ", tmp);
- src += 2;
- break;
- }
+ case 'd':
+ fprintf(_dumpFile, "%d ", (int16)readUint16Wrapper(src));
+ src += 2;
+ break;
case 'v':
fprintf(_dumpFile, "[%d] ", readUint16Wrapper(src));
src += 2;
diff --git a/engines/simon/debug.h b/engines/simon/debug.h
index 5b7bf45eeb..1e2a799d3b 100644
--- a/engines/simon/debug.h
+++ b/engines/simon/debug.h
@@ -145,16 +145,16 @@ static const char *const simon1dos_opcode_name_table[256] = {
NULL,
/* 96 */
"WB|UNK_96",
- "W|LOAD_VGA",
+ "W|LOAD_ZONE",
"WBWWW|START_VGA",
"W|KILL_SPRITE",
/* 100 */
"|VGA_RESET",
- "BWWWWWW|UNK_101",
- "B|UNK_102",
+ "BWWWWWW|DEFINE_WINDOW",
+ "B|CHANGE_WINDOW",
"|UNK_103",
/* 104 */
- "B|UNK_104",
+ "B|CLOSE_WINDOW",
NULL,
NULL,
"WWWWWIW|ADD_ITEM_HITAREA",
@@ -172,9 +172,9 @@ static const char *const simon1dos_opcode_name_table[256] = {
"IB|SET_FLAG",
"IB|CLEAR_FLAG",
NULL,
- "W|WAIT_VGA",
+ "W|WAIT_SYNC",
/* 120 */
- "W|UNK_120",
+ "W|SYNC",
"BI|SET_VGA_ITEM",
NULL,
NULL,
@@ -383,16 +383,16 @@ static const char *const simon1talkie_opcode_name_table[256] = {
NULL,
/* 96 */
"WB|UNK_96",
- "W|LOAD_VGA",
+ "W|LOAD_ZONE",
"WBWWW|START_VGA",
"W|KILL_SPRITE",
/* 100 */
"|VGA_RESET",
- "BWWWWWW|UNK_101",
- "B|UNK_102",
+ "BWWWWWW|DEFINE_WINDOW",
+ "B|CHANGE_WINDOW",
"|UNK_103",
/* 104 */
- "B|UNK_104",
+ "B|CLOSE_WINDOW",
NULL,
NULL,
"WWWWWIW|ADD_ITEM_HITAREA",
@@ -410,9 +410,9 @@ static const char *const simon1talkie_opcode_name_table[256] = {
"IB|SET_FLAG",
"IB|CLEAR_FLAG",
NULL,
- "W|WAIT_VGA",
+ "W|WAIT_SYNC",
/* 120 */
- "W|UNK_120",
+ "W|SYNC",
"BI|SET_VGA_ITEM",
NULL,
NULL,
@@ -621,16 +621,16 @@ static const char *const simon2dos_opcode_name_table[256] = {
NULL,
/* 96 */
"WB|UNK_96",
- "W|LOAD_VGA",
+ "W|LOAD_ZONE",
"WWBWWW|START_VGA",
"WW|KILL_SPRITE",
/* 100 */
"|VGA_RESET",
- "BWWWWWW|UNK_101",
- "B|UNK_102",
+ "BWWWWWW|DEFINE_WINDOW",
+ "B|CHANGE_WINDOW",
"|UNK_103",
/* 104 */
- "B|UNK_104",
+ "B|CLOSE_WINDOW",
NULL,
NULL,
"WWWWWIW|ADD_ITEM_HITAREA",
@@ -648,9 +648,9 @@ static const char *const simon2dos_opcode_name_table[256] = {
"IB|SET_FLAG",
"IB|CLEAR_FLAG",
NULL,
- "W|WAIT_VGA",
+ "W|WAIT_SYNC",
/* 120 */
- "W|UNK_120",
+ "W|SYNC",
"BI|SET_VGA_ITEM",
NULL,
NULL,
@@ -863,16 +863,16 @@ static const char *const simon2talkie_opcode_name_table[256] = {
NULL,
/* 96 */
"WB|UNK_96",
- "W|LOAD_VGA",
+ "W|LOAD_ZONE",
"WWBWWW|START_VGA",
"WW|KILL_SPRITE",
/* 100 */
"|VGA_RESET",
- "BWWWWWW|UNK_101",
- "B|UNK_102",
+ "BWWWWWW|DEFINE_WINDOW",
+ "B|CHANGE_WINDOW",
"|UNK_103",
/* 104 */
- "B|UNK_104",
+ "B|CLOSE_WINDOW",
NULL,
NULL,
"WWWWWIW|ADD_ITEM_HITAREA",
@@ -890,9 +890,9 @@ static const char *const simon2talkie_opcode_name_table[256] = {
"IB|SET_FLAG",
"IB|CLEAR_FLAG",
NULL,
- "W|WAIT_VGA",
+ "W|WAIT_SYNC",
/* 120 */
- "W|UNK_120",
+ "W|SYNC",
"BI|SET_VGA_ITEM",
NULL,
NULL,
@@ -1105,16 +1105,16 @@ static const char *const feeblefiles_opcode_name_table[256] = {
NULL,
/* 96 */
"WB|UNK_96",
- "W|LOAD_VGA",
+ "W|LOAD_ZONE",
"WWBWWW|START_VGA",
"WW|KILL_SPRITE",
/* 100 */
"|VGA_RESET",
- "BWWWWWW|UNK_101",
- "B|UNK_102",
+ "BWWWWWW|DEFINE_WINDOW",
+ "B|CHANGE_WINDOW",
"|UNK_103",
/* 104 */
- "B|UNK_104",
+ "B|CLOSE_WINDOW",
NULL,
NULL,
"WWWWWIW|ADD_ITEM_HITAREA",
@@ -1132,9 +1132,9 @@ static const char *const feeblefiles_opcode_name_table[256] = {
"IB|SET_FLAG",
"IB|CLEAR_FLAG",
NULL,
- "W|WAIT_VGA",
+ "W|WAIT_SYNC",
/* 120 */
- "W|UNK_120",
+ "W|SYNC",
"BI|SET_VGA_ITEM",
"ORACLE_TEXT_DOWN",
"ORACLE_TEXT_UP",
@@ -1185,7 +1185,7 @@ static const char *const feeblefiles_opcode_name_table[256] = {
NULL,
/* 160 */
"B|UNK_160",
- "BWBW|SETUP_TEXT",
+ "BWWW|SETUP_TEXT",
"BBTW|PRINT_STR",
"W|SOUND_1",
/* 164 */
diff --git a/engines/simon/simon.cpp b/engines/simon/simon.cpp
index 9eb4db7094..ab38dfc137 100644
--- a/engines/simon/simon.cpp
+++ b/engines/simon/simon.cpp
@@ -392,6 +392,7 @@ SimonEngine::SimonEngine(OSystem *syst)
memset(_bitArray, 0, sizeof(_bitArray));
memset(_variableArray, 0, sizeof(_variableArray));
+ memset(_variableArray2, 0, sizeof(_variableArray2));
memset(_windowArray, 0, sizeof(_windowArray));
@@ -1054,7 +1055,11 @@ uint SimonEngine::getNextVarContents() {
uint SimonEngine::readVariable(uint variable) {
if (variable >= 255)
error("Variable %d out of range in read", variable);
- return _variableArray[variable];
+
+ if (getGameType() == GType_FF && getBitFlag(83))
+ return _variableArray2[variable];
+ else
+ return _variableArray[variable];
}
void SimonEngine::writeNextVarContents(uint16 contents) {
@@ -1064,7 +1069,11 @@ void SimonEngine::writeNextVarContents(uint16 contents) {
void SimonEngine::writeVariable(uint variable, uint16 contents) {
if (variable >= 256)
error("Variable %d out of range in write", variable);
- _variableArray[variable] = contents;
+
+ if (getGameType() == GType_FF && getBitFlag(83))
+ _variableArray2[variable] = contents;
+ else
+ _variableArray[variable] = contents;
}
void SimonEngine::setItemParent(Item *item, Item *parent) {
@@ -2352,8 +2361,11 @@ void SimonEngine::set_video_mode_internal(uint mode, uint vga_res_id) {
_scrollCount = 0;
_scrollFlag = 0;
_scrollHeight = 134;
- if (_variableArray[34] != -1)
+ if (_variableArray[34] != -1) {
+ if (getGameType() == GType_FF)
+ _variableArray[250] = 0;
_variableArray[251] = 0;
+ }
}
vc_ptr_org = _vcPtr;
@@ -2612,8 +2624,8 @@ void SimonEngine::timer_vga_sprites() {
if (_paletteFlag == 2)
_paletteFlag = 1;
- if (getGameType() == GType_SIMON2 && _scrollFlag) {
- timer_vga_sprites_helper();
+ if ((getGameType() == GType_SIMON2 || getGameType() == GType_FF) && _scrollFlag) {
+ scrollEvent();
}
vsp = _vgaSprites;
@@ -2653,7 +2665,7 @@ void SimonEngine::timer_vga_sprites() {
_vcPtr = vc_ptr_org;
}
-void SimonEngine::timer_vga_sprites_helper() {
+void SimonEngine::scrollEvent() {
byte *dst = getFrontBuf();
const byte *src;
uint x;
@@ -2664,15 +2676,21 @@ void SimonEngine::timer_vga_sprites_helper() {
memmove(dst, dst + 8, _screenWidth * _scrollHeight - 8);
}
- x = _scrollX - 1;
+ x = _scrollX;
+ x -= (getGameType() == GType_FF) ? 8 : 1;
if (_scrollFlag > 0) {
dst += _screenWidth - 8;
- x += 41;
+ x += (getGameType() == GType_FF) ? 648 : 41;
}
- src = _scrollImage + x * 4;
- decodeStripA(dst, src + READ_BE_UINT32(src), _scrollHeight);
+ if (getGameType() == GType_FF) {
+ src = _scrollImage + x / 2;
+ decodeStripA(dst, src + READ_LE_UINT32(src), _scrollHeight);
+ } else {
+ src = _scrollImage + x * 4;
+ decodeStripA(dst, src + READ_BE_UINT32(src), _scrollHeight);
+ }
memcpy(_sdl_buf_attached, _sdl_buf, _screenWidth * _screenHeight);
dx_copy_from_attached_to_3(_scrollHeight);
@@ -2905,6 +2923,11 @@ void SimonEngine::o_pathfind(int x, int y, uint var_1, uint var_2) {
uint x_diff, y_diff;
uint best_i = 0, best_j = 0, best_dist = 0xFFFFFFFF;
+ if (getGameType() == GType_FF) {
+ x += _scrollX;
+ y += _scrollY;
+ }
+
if (getGameType() == GType_SIMON2) {
x += _scrollX * 8;
}
@@ -2933,8 +2956,13 @@ void SimonEngine::o_pathfind(int x, int y, uint var_1, uint var_2) {
}
}
- _variableArray[var_1] = best_i;
- _variableArray[var_2] = best_j;
+ if (getGameType() == GType_FF && getBitFlag(83)) {
+ _variableArray[var_1] = best_i;
+ _variableArray[var_2] = best_j;
+ } else {
+ _variableArray[var_1] = best_i;
+ _variableArray[var_2] = best_j;
+ }
}
// ok
diff --git a/engines/simon/simon.h b/engines/simon/simon.h
index c5cc75fde0..824a1cf84d 100644
--- a/engines/simon/simon.h
+++ b/engines/simon/simon.h
@@ -371,6 +371,7 @@ protected:
uint16 _bitArray[48];
int16 _variableArray[256];
+ int16 _variableArray2[256];
WindowBlock *_windowArray[8];
@@ -814,6 +815,8 @@ protected:
void vcSkipNextInstruction();
int getScale(int y, int x);
+ void checkScrollX(int x);
+ void checkScrollY(int y);
bool itemIsSiblingOf(uint16 val);
bool itemIsParentOf(uint16 a, uint16 b);
@@ -901,7 +904,7 @@ protected:
void o_83_helper();
void o_waitForMark(uint i);
- void timer_vga_sprites_helper();
+ void scrollEvent();
void decodeStripA(byte *dst, const byte *src, int height);
void scroll_timeout();
diff --git a/engines/simon/vga.cpp b/engines/simon/vga.cpp
index 131373a372..a1c0c37228 100644
--- a/engines/simon/vga.cpp
+++ b/engines/simon/vga.cpp
@@ -723,7 +723,31 @@ void SimonEngine::vc10_draw() {
if (getGameType() == GType_FF) {
if (width > 640) {
- debug(0, "Horizontal scrolling not supported");
+ debug(0, "Horizontal scrolling");
+
+ const byte *src;
+ byte *dst;
+ uint w;
+
+ _scrollXMax = 640;
+ _scrollYMax = 0;
+ _scrollImage = state.depack_src;
+ _scrollHeight = height;
+ if (_variableArray[34] == -1)
+ state.x = _variableArray[251];
+
+ _scrollX = state.x;
+
+ vcWriteVar(251, _scrollX);
+
+ dst = getBackBuf();
+ src = state.depack_src + (_scrollX - 8) / 2;
+
+ for (w = 0; w < 80; w++) {
+ decodeStripA(dst, src + READ_LE_UINT32(src), height);
+ dst += 8;
+ src += 4;
+ }
return;
}
if (height > 480) {
@@ -1832,7 +1856,7 @@ void SimonEngine::vc48_setPathFinder() {
y = vsp->y;
vsp->y = y1;
- //checkScrollY(y, diff);
+ checkScrollY(y1 - y);
_variableArray[11] = readUint16Wrapper(p);
_variableArray[13] = pos;
@@ -2311,9 +2335,7 @@ void SimonEngine::vc76_setScaleXOffs() {
vsp->x += getScale(vsp->y, x);
_variableArray[var] = vsp->x;
- if (_scrollXMax) {
- // TODO: Scroll check
- }
+ checkScrollX(x);
vsp->flags = kDFScaled;
}
@@ -2322,11 +2344,14 @@ void SimonEngine::vc77_setScaleYOffs() {
VgaSprite *vsp = findCurSprite();
vsp->image = vcReadNextWord();
- int16 x = vcReadNextWord();
+ int16 y = vcReadNextWord();
int var = vcReadNextWord();
- vsp->y += getScale(vsp->y, x);
+ vsp->y += getScale(vsp->y, y);
_variableArray[var] = vsp->y;
+
+ checkScrollY(y);
+
vsp->flags = kDFScaled;
}
@@ -2412,4 +2437,86 @@ void SimonEngine::vc84_stopSoundLoop() {
debug(0, "STUB: vc84_stopSoundLoop");
}
+// Scrolling functions for Feeble Files
+void SimonEngine::checkScrollX(int x) {
+ if (_scrollXMax == 0 || getBitFlag(80) || getBitFlag(82) || x == 0)
+ return;
+
+ int16 tmp;
+ if (x > 0) {
+ if (_scrollCount != 0) {
+ if (_scrollCount >= 0)
+ return;
+ _scrollCount = 0;
+ } else {
+ if (_scrollFlag != 0)
+ return;
+ }
+
+ if (x - _scrollX >= 480) {
+ _scrollCount = 320;
+ tmp = _scrollXMax - _scrollX;
+ if (tmp < 320)
+ _scrollCount = tmp;
+ }
+ } else {
+ if (_scrollCount != 0) {
+ if (_scrollCount < 0)
+ return;
+ _scrollCount = 0;
+ } else {
+ if (_scrollFlag != 0)
+ return;
+ }
+
+ if ((uint16)(x - _scrollX) < 161) {
+ _scrollCount = -320;
+ tmp = _scrollXMax - _scrollX;
+ if (_scrollX < 320)
+ _scrollCount = -_scrollX;
+ }
+ }
+}
+
+void SimonEngine::checkScrollY(int y) {
+ if (_scrollYMax == 0 || getBitFlag(80))
+ return;
+
+ int16 tmp;
+ if (y > 0) {
+ if (_scrollCount != 0) {
+ if (_scrollCount >= 0)
+ return;
+ _scrollCount = 0;
+ } else {
+ if (_scrollFlag != 0)
+ return;
+ }
+
+ if (y - _scrollY >= 440) {
+ _scrollCount = 240;
+ tmp = _scrollYMax - _scrollY;
+ if (tmp < 240)
+ _scrollCount = tmp;
+ }
+ } else {
+ if (_scrollCount != 0) {
+ if (_scrollCount < 0)
+ return;
+ _scrollCount = 0;
+ } else {
+ if (_scrollFlag != 0)
+ return;
+ }
+
+ if ((uint16)(y - _scrollY) < 100) {
+ _scrollCount = -240;
+ tmp = _scrollYMax - _scrollY;
+ if (_scrollY < 240)
+ _scrollCount = -_scrollY;
+ }
+ }
+}
+
+
} // End of namespace Simon