aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorWalter van Niftrik2009-08-19 21:08:17 +0000
committerWalter van Niftrik2009-08-19 21:08:17 +0000
commit8bd4cee2d296f8cf6df3b4a936d3d1d94ec72d46 (patch)
treef22a09a5ffafe9aede9a2a1f773cc9dcc5cd43ce /engines
parenta491107ee40347f6acb8db319105a2fa85663e50 (diff)
downloadscummvm-rg350-8bd4cee2d296f8cf6df3b4a936d3d1d94ec72d46.tar.gz
scummvm-rg350-8bd4cee2d296f8cf6df3b4a936d3d1d94ec72d46.tar.bz2
scummvm-rg350-8bd4cee2d296f8cf6df3b4a936d3d1d94ec72d46.zip
SCI: Add autodetection of Amiga views.
svn-id: r43547
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/gfx/gfx_resource.h9
-rw-r--r--engines/sci/resource.cpp62
-rw-r--r--engines/sci/resource.h11
3 files changed, 68 insertions, 14 deletions
diff --git a/engines/sci/gfx/gfx_resource.h b/engines/sci/gfx/gfx_resource.h
index 9c83cf07cd..1e188118ad 100644
--- a/engines/sci/gfx/gfx_resource.h
+++ b/engines/sci/gfx/gfx_resource.h
@@ -77,6 +77,15 @@ extern gfx_pixmap_color_t gfx_sci0_image_colors[][16];
*/
extern Palette* gfx_sci0_pic_colors;
+
+enum ViewType {
+ kViewUnknown,
+ kViewEga,
+ kViewVga,
+ kViewVga11,
+ kViewAmiga
+};
+
struct gfxr_pic0_params_t {
gfx_line_mode_t line_mode; /* one of GFX_LINE_MODE_* */
gfx_brush_mode_t brush_mode;
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 9b9c9ee26c..2479504820 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -510,7 +510,7 @@ void ResourceManager::init() {
if (_sciVersion != SCI_VERSION_AUTODETECT)
debug("Resmgr: Detected %s", versionNames[_sciVersion]);
else
- debug("Resmgr: Couldn't determine SCI version");
+ warning("Resmgr: Couldn't determine SCI version");
switch (_viewType) {
case kViewEga:
@@ -521,6 +521,12 @@ void ResourceManager::init() {
break;
case kViewVga11:
debug("Resmgr: Detected SCI1.1 VGA graphic resources");
+ break;
+ case kViewAmiga:
+ debug("Resmgr: Detected Amiga graphic resources");
+ break;
+ default:
+ warning("Resmgr: Couldn't determine view type");
}
}
@@ -1500,22 +1506,64 @@ ResourceCompression ResourceManager::getViewCompression() {
return kCompNone;
}
-ResourceManager::ViewType ResourceManager::detectViewType() {
+ViewType ResourceManager::detectViewType() {
for (int i = 0; i < 1000; i++) {
Resource *res = findResource(ResourceId(kResourceTypeView, i), 0);
+
if (res) {
- //FIXME: Amiga
switch(res->data[1]) {
- case 0:
- return kViewEga;
- default:
+ case 128:
+ // If the 2nd byte is 128, it's a VGA game
return kViewVga;
+ case 0:
+ // EGA or Amiga, try to read as Amiga view
+
+ if (res->size < 10)
+ return kViewUnknown;
+
+ // Read offset of first loop
+ uint16 offset = READ_LE_UINT16(res->data + 8);
+
+ if (offset + 6U >= res->size)
+ return kViewUnknown;
+
+ // Read offset of first cel
+ offset = READ_LE_UINT16(res->data + offset + 4);
+
+ if (offset + 4U >= res->size)
+ return kViewUnknown;
+
+ // Check palette offset, amiga views have no palette
+ if (READ_LE_UINT16(res->data + 6) != 0)
+ return kViewEga;
+
+ uint16 width = READ_LE_UINT16(res->data + offset);
+ offset += 2;
+ uint16 height = READ_LE_UINT16(res->data + offset);
+ offset += 6;
+
+ // Check that the RLE data stays within bounds
+ int y;
+ for (y = 0; y < height; y++) {
+ int x = 0;
+
+ while ((x < width) && (offset < res->size)) {
+ byte op = res->data[offset++];
+ x += (op & 0x07) ? op & 0x07 : op >> 3;
+ }
+
+ // Make sure we got exactly the right number of pixels for this row
+ if (x != width)
+ return kViewEga;
+ }
+
+ return kViewAmiga;
}
}
}
warning("Resmgr: Couldn't find any views");
- return kViewVga;
+ return kViewUnknown;
}
SciVersion ResourceManager::detectSciVersion() {
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index 4250225ffe..5ba2d03beb 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -34,6 +34,8 @@
#include "sound/audiostream.h"
#include "sound/mixer.h" // for SoundHandle
+#include "gfx/gfx_resource.h" // for ViewType
+
#include "sci/decompressor.h"
namespace Common {
@@ -230,15 +232,10 @@ public:
kResVersionSci32
};
- // TODO: Amiga
- enum ViewType {
- kViewEga,
- kViewVga,
- kViewVga11
- };
-
bool isVGA() const { return (_viewType == kViewVga) || (_viewType == kViewVga11); }
+ ViewType getViewType() const { return _viewType; }
+
/**
* Returns the SCI version as detected by the resource manager
* @return SCI version