[Scummvm-cvs-logs] SF.net SVN: scummvm: [28001] scummex/branches/gsoc2007-gameresbrowser
zbychs at users.sourceforge.net
zbychs at users.sourceforge.net
Tue Jul 10 06:54:42 CEST 2007
Revision: 28001
http://scummvm.svn.sourceforge.net/scummvm/?rev=28001&view=rev
Author: zbychs
Date: 2007-07-09 21:54:41 -0700 (Mon, 09 Jul 2007)
Log Message:
-----------
Added support for Scumm Images and Scripts.
ExplorationTree is now lazy in a good way.
Lots of improvements.
Modified Paths:
--------------
scummex/branches/gsoc2007-gameresbrowser/src/core/common/scummsys.h
scummex/branches/gsoc2007-gameresbrowser/src/core/debugmem.h
scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp
scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h
scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.cpp
scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.cpp
scummex/branches/gsoc2007-gameresbrowser/src/gui/ExplorationTree.cpp
scummex/branches/gsoc2007-gameresbrowser/src/gui/ExplorationTree.h
scummex/branches/gsoc2007-gameresbrowser/src/gui/FileInfoPresenter.cpp
scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.cpp
scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.h
scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.cpp
scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.h
scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.wxform
scummex/branches/gsoc2007-gameresbrowser/src/gui/MainFormCommands.cpp
scummex/branches/gsoc2007-gameresbrowser/src/gui/Test1.cpp
scummex/branches/gsoc2007-gameresbrowser/src/gui/Test2.cpp
scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/GUIInterfaces.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/VirtualNode.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockInfoPresenter.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockInfoPresenter.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/resource.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/resource.h
scummex/branches/gsoc2007-gameresbrowser/vc8/plugins/plugins.vcproj
Added Paths:
-----------
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImage.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImageDetail.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/bomp.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/bomp.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/codec37.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/codec37.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/codec47.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/codec47.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/descumm.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/descumm.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/descumm6.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/scaler.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/scaler.h
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/common/scummsys.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/common/scummsys.h 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/common/scummsys.h 2007-07-10 04:54:41 UTC (rev 28001)
@@ -398,4 +398,106 @@
#endif
+FORCEINLINE uint32 SWAP_BYTES_32(uint32 a) {
+ return ((a >> 24) & 0x000000FF) |
+ ((a >> 8) & 0x0000FF00) |
+ ((a << 8) & 0x00FF0000) |
+ ((a << 24) & 0xFF000000);
+}
+
+FORCEINLINE uint16 SWAP_BYTES_16(uint16 a) {
+ return ((a >> 8) & 0x00FF) + ((a << 8) & 0xFF00);
+}
+
+
+#if defined(SCUMM_LITTLE_ENDIAN)
+
+ #define PROTO_MKID(a) ((uint32) \
+ (((a) >> 24) & 0x000000FF) | \
+ (((a) >> 8) & 0x0000FF00) | \
+ (((a) << 8) & 0x00FF0000) | \
+ (((a) << 24) & 0xFF000000))
+ #define PROTO_MKID_BE(a) ((uint32)(a))
+
+ #if defined(INVERSE_MKID)
+ # define MKID(a) PROTO_MKID_BE(a)
+ # define MKID_BE(a) PROTO_MKID(a)
+ #else
+ # define MKID(a) PROTO_MKID(a)
+ # define MKID_BE(a) PROTO_MKID_BE(a)
+ #endif
+
+ #define READ_UINT32(a) READ_LE_UINT32(a)
+
+ #define FROM_LE_32(a) ((uint32)(a))
+ #define FROM_LE_16(a) ((uint16)(a))
+
+ #define TO_LE_32(a) ((uint32)(a))
+ #define TO_LE_16(a) ((uint16)(a))
+
+ #define TO_BE_32(a) SWAP_BYTES_32(a)
+ #define TO_BE_16(a) SWAP_BYTES_16(a)
+
+#elif defined(SCUMM_BIG_ENDIAN)
+
+ #define MKID(a) ((uint32)(a))
+ #define MKID_BE(a) ((uint32)(a))
+ //#define MKID_BE(a) SWAP_BYTES_32(a)
+
+ #define READ_UINT32(a) READ_BE_UINT32(a)
+
+ #define FROM_LE_32(a) SWAP_BYTES_32(a)
+ #define FROM_LE_16(a) SWAP_BYTES_16(a)
+
+ #define TO_LE_32(a) SWAP_BYTES_32(a)
+ #define TO_LE_16(a) SWAP_BYTES_16(a)
+
+ #define TO_BE_32(a) ((uint32)(a))
+ #define TO_BE_16(a) ((uint16)(a))
+
+#else
+
+ #error No endianness defined
+
#endif
+
+
+
+#if defined(SCUMM_NEED_ALIGNMENT) || defined(SCUMM_BIG_ENDIAN)
+ FORCEINLINE uint16 READ_LE_UINT16(const void *ptr) {
+ const byte *b = (const byte *)ptr;
+ return (b[1] << 8) + b[0];
+ }
+ FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) {
+ const byte *b = (const byte *)ptr;
+ return (b[3] << 24) + (b[2] << 16) + (b[1] << 8) + (b[0]);
+ }
+#else
+ FORCEINLINE uint16 READ_LE_UINT16(const void *ptr) {
+ return *(const uint16 *)(ptr);
+ }
+ FORCEINLINE uint32 READ_LE_UINT32(const void *ptr) {
+ return *(const uint32 *)(ptr);
+ }
+#endif
+
+
+#if defined(SCUMM_NEED_ALIGNMENT) || defined(SCUMM_LITTLE_ENDIAN)
+ FORCEINLINE uint16 READ_BE_UINT16(const void *ptr) {
+ const byte *b = (const byte *)ptr;
+ return (b[0] << 8) + b[1];
+ }
+ FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) {
+ const byte *b = (const byte*)ptr;
+ return (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + (b[3]);
+ }
+#else
+ FORCEINLINE uint16 READ_BE_UINT16(const void *ptr) {
+ return *(const uint16 *)(ptr);
+ }
+ FORCEINLINE uint32 READ_BE_UINT32(const void *ptr) {
+ return *(const uint32 *)(ptr);
+ }
+#endif
+
+#endif
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/debugmem.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/debugmem.h 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/debugmem.h 2007-07-10 04:54:41 UTC (rev 28001)
@@ -18,6 +18,7 @@
#if defined(_MSC_VER) && defined(_DEBUG)
+#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#define DEBUG_NEW new( _CLIENT_BLOCK, __FILE__, __LINE__)
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/guid.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -38,18 +38,20 @@
}
bool BGUID::operator<(const BGUID& other) const {
- if (facility < other.facility) return true;
- if (facility > other.facility) return false;
- if (identifier < other.identifier) return true;
- if (identifier > other.identifier) return false;
+ int res;
+ res = identifier.Cmp(other.identifier);
+ if (res != 0) return res < 0;
+ res = facility.Cmp(other.facility);
+ if (res != 0) return res < 0;
return version < other.version;
}
bool BGUID::operator>(const BGUID& other) const {
- if (facility > other.facility) return true;
- if (facility < other.facility) return false;
- if (identifier > other.identifier) return true;
- if (identifier < other.identifier) return false;
+ int res;
+ res = identifier.Cmp(other.identifier);
+ if (res != 0) return res > 0;
+ res = facility.Cmp(other.facility);
+ if (res != 0) return res > 0;
return version > other.version;
}
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/guid.h 2007-07-10 04:54:41 UTC (rev 28001)
@@ -47,6 +47,30 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+#ifdef HAVE_HASH_MAP
+
+#include <hash_map>
+
+template<class Traits = less<BGUID> >
+class hash_compare_BGUID : hash_compare<BGUID, Traits> {
+ static wxStringHash shasher;
+ static wxIntegerHash ihasher;
+public:
+ hash_compare_BGUID() {}
+ hash_compare_BGUID(Traits pred) : hash_compare(pred) {};
+ size_t operator()(const BGUID& guid) const {
+ unsigned long hash = ihasher(guid.version);
+ hash ^= shasher(guid.facility);
+ hash ^= shasher(guid.identifier);
+ return hash;
+ }
+};
+
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
class GUIDObject {
public:
virtual const BGUID& get_GUID() = 0;
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/pinslot.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -201,7 +201,18 @@
#ifdef NO_REALIZE_DEBUG
void BObject::dumpRealizing(ObjectChain* ochain) {}
-void BObject::dumpRealized(ObjectChain* ochain, bool result) {}
+//void BObject::dumpRealized(ObjectChain* ochain, bool result) {}
+
+void BObject::dumpRealized(ObjectChain* ochain, bool result) {
+ if (result)
+ return;
+ ASSERT_STATICS_ALLOWED();
+ _dump_realize_indent--;
+ dump_realize_indent();
+ infoout << (result ? wxT("REALIZED: ") : wxT("R-FAILED: "));
+ infoout << this->dumpName() << wxT("\t\t") << this << wxT(" oc: ") << ochain << std::endl;
+}
+
void BObject::dumpUnrealizing(ObjectChain* ochain) {}
void BObject::dumpUnrealized(ObjectChain* ochain) {}
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/DirectoryPresenter.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -126,7 +126,7 @@
RCPtr<VirtualNode> virtualDir( new VirtualDirectory(kidTreeItem, idirectory) );
- VirtualNodeItemData* itemData = new VirtualNodeItemData(virtualDir.get(), NULL, false);
+ VirtualNodeItemData* itemData = new VirtualNodeItemData(virtualDir.get(), NULL);
ExplorationTree::get()->setItemData(kidTreeItem, itemData);
guid_list parsers;
@@ -159,7 +159,7 @@
VirtualFile* virtualFile = new VirtualFile(kidTreeItem, ifile);
RCPtr<VirtualNode> virtualNode(virtualFile);
- VirtualNodeItemData* itemData = new VirtualNodeItemData(virtualFile, NULL, false);
+ VirtualNodeItemData* itemData = new VirtualNodeItemData(virtualFile, NULL);
ExplorationTree::get()->setItemData(kidTreeItem, itemData);
//Here we try to figure the fileType and the best parsers for it:
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/ExplorationTree.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/ExplorationTree.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/ExplorationTree.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -142,6 +142,7 @@
_rootObjectChain = new ObjectChain();
_panelMap = new PanelMap();
_dirMap = new DirMap();
+ _notCompletedCount = 0;
}
ExplorationTree::~ExplorationTree() {
@@ -159,6 +160,9 @@
ExplorationTree* ExplorationTree::_instance = NULL;
+/*static*/ bool ExplorationTree::canGet() {
+ return _instance != NULL;
+}
/*static*/ ExplorationTree* ExplorationTree::get() {
ASSERT(_instance);
return _instance;
@@ -178,15 +182,64 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+bool ExplorationTree::onIdleRec(const wxTreeItemId& item) {
+ ASSERT_VALID_TREE_ITEM(item);
+ VirtualNodeItemData* data = VirtualNodeItemData::getForNode(item);
+ if (data && !data->getCompleted()) {
+ ObjectChain* kidchain = data->getObjectChain();
+ ASSERT(kidchain);
+
+ infoout << wxT("INFO: ExplorationTree::onIdleRec(): completing") << std::endl;
+ kidchain->complete();
+ _notCompletedCount--;
+ data->setCompleted(true);
+
+ //WORKAROUND: in wxMSW SetItemHasChildren does not work, so we include a Dummy:
+ if (!kidchain->isContained(DirectoryPresenter::static_GUID())) {
+ ExplorationTree::get()->deleteChildren(item); //delete the Dummy added by the ExplorationTree
+ }
+
+ return true;
+ }
+ getItemText(item);
+
+ wxTreeItemIdValue cookie;
+ wxTreeItemId child = _explorationTree->GetFirstChild(item, cookie);
+ while (child.IsOk()) {
+ if (onIdleRec(child))
+ return true;
+ child = _explorationTree->GetNextChild(item, cookie);
+ }
+
+ return false;
+}
+
+bool ExplorationTree::onIdle() {
+ if (_notCompletedCount <= 0)
+ return false;
+
+ infoout << wxT("INFO: ExplorationTree::onIdle(): trying to complete: ") << _notCompletedCount << std::endl;
+ return onIdleRec(_explorationTree->GetRootItem());
+}
+
void ExplorationTree::realizeVisible(bool dirsOnly /*= true*/) {
wxTreeItemId item = _explorationTree->GetFirstVisibleItem();
while (item.IsOk() &&
_explorationTree->IsVisible(item)) { //WORKAROUND: in wxMSW this is necessary
- realizeNode(item, dirsOnly);
- item = _explorationTree->GetNextVisible(item);
+ realizeNode(item, dirsOnly);
+ item = _explorationTree->GetNextVisible(item);
}
}
+bool ExplorationTree::isNodeRealized(const wxTreeItemId& item) {
+ ASSERT_VALID_TREE_ITEM(item);
+ VirtualNodeItemData* data = VirtualNodeItemData::getForNode(item);
+ if (!data)
+ return false;
+
+ return data->getRealized();
+}
+
bool ExplorationTree::realizeNode(const wxTreeItemId& item, bool dirsOnly /*= false*/) {
ASSERT_VALID_TREE_ITEM(item);
VirtualNodeItemData* data = VirtualNodeItemData::getForNode(item);
@@ -194,20 +247,27 @@
return false;
if (!data->getRealized()) {
+
ObjectChain* kidchain = data->getObjectChain();
ASSERT(kidchain);
- kidchain->complete();
+ if (!data->getCompleted()) {
+ kidchain->complete();
+ _notCompletedCount--; //FIXME: the counting is not entirely correct
+ data->setCompleted(true);
+ }
if (dirsOnly) {
- if (!kidchain->isContained(DirectoryPresenter::static_GUID()))
+ if (kidchain->isContained(DirectoryPresenter::static_GUID()))
return true;
//WORKAROUND: in wxMSW SetItemHasChildren does not work, so we include a Dummy:
- wxTreeItemId dummyTreeItem = ExplorationTree::get()->appendItem(
- item, wxT("Dummy"));
+ ExplorationTree::get()->deleteChildren(item); //delete the Dummy added by the ExplorationTree
return true;
}
+ if (!kidchain->isContained(DirectoryPresenter::static_GUID()))
+ ExplorationTree::get()->deleteChildren(item); //delete the Dummy added by the ExplorationTree
+
wxString name = getItemText(item);
infoout << wxT("ExplorationTree::realizeNode(): realizing chain for node: ")
<< name << std::endl;
@@ -246,6 +306,8 @@
VirtualNode* ExplorationTree::getSelectedNode() {
wxTreeItemId item = getSelected();
+ if (!item.IsOk())
+ return NULL;
VirtualNode* node = getNode(item);
return node;
}
@@ -260,29 +322,16 @@
wxTreeItemId item = _explorationTree->AppendItem(parent, title, -1, -1, NULL);
ASSERT_VALID_TREE_ITEM(item);
//_explorationTree->SetItemHasChildren(item);
+ _notCompletedCount++;
return item;
}
-void ExplorationTree::_recDel(const wxTreeItemId& item, bool thisToo) {
- ASSERT_VALID_TREE_ITEM(item);
- wxTreeItemIdValue cookie;
- while (true) {
- wxTreeItemId child = _explorationTree->GetFirstChild(item, cookie);
- if (!child.IsOk())
- break;
- _recDel(child, true);
- }
-
- if (thisToo) {
- ASSERT_VALID_TREE_ITEM(item);
- _explorationTree->Delete(item);
- }
-}
-
void ExplorationTree::deleteItem(const wxTreeItemId& item) {
ASSERT_VALID_TREE_ITEM(item);
+ VirtualNodeItemData* data = VirtualNodeItemData::getForNode(item);
+ if (data && !data->getCompleted())
+ _notCompletedCount--;
_explorationTree->Delete(item);
- //_recDel(parent, false);
}
void ExplorationTree::deleteChildren(const wxTreeItemId& parent) {
@@ -316,11 +365,14 @@
wxTreeItemId ExplorationTree::addRoot(wxString title) {
wxTreeItemId item = _explorationTree->AddRoot(title, -1, -1, NULL);
+ _notCompletedCount = 1;
ASSERT_VALID_TREE_ITEM(item);
+ _explorationTree->AppendItem(item, wxT("Dummy"), -1, -1, NULL); //WORKAROUND
return item;
}
void ExplorationTree::deleteAllItems() {
+ _notCompletedCount = 0;
_explorationTree->DeleteAllItems();
}
@@ -431,7 +483,23 @@
void ExplorationTree::itemExpanded(wxTreeItemId item) {
VirtualNode* node = getNode(item);
if (node) {
- realizeVisible();
+ //realizeVisible();
+
+ //TODO: make it nicer
+ //WORKAROUND: adding Dummies
+ ASSERT_VALID_TREE_ITEM(item);
+ wxTreeItemIdValue cookie;
+ wxTreeItemId child = _explorationTree->GetFirstChild(item, cookie);
+ while (child.IsOk()) {
+ if (!isNodeRealized(child)) {
+ wxTreeItemIdValue cookie2;
+ wxTreeItemId child2 = _explorationTree->GetFirstChild(child, cookie2);
+ if (!child2.IsOk())
+ _explorationTree->AppendItem(child, wxT("Dummy"), -1, -1, NULL); //WORKAROUND
+ }
+
+ child = _explorationTree->GetNextChild(item, cookie);
+ }
}
}
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/ExplorationTree.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/ExplorationTree.h 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/ExplorationTree.h 2007-07-10 04:54:41 UTC (rev 28001)
@@ -41,11 +41,14 @@
VirtualNode* _activeNode;
DirMap* _dirMap;
+ int _notCompletedCount;
+
private:
ExplorationTree();
~ExplorationTree();
public:
+ static bool ExplorationTree::canGet();
static ExplorationTree* get();
static void release();
@@ -53,14 +56,16 @@
//static wxTreeCtrl* _getTree();
//wxTreeCtrl* getTree();
+ bool onIdleRec(const wxTreeItemId& item);
+ bool onIdle();
void realizeVisible(bool dirsOnly = true);
+ bool isNodeRealized(const wxTreeItemId& item);
bool realizeNode(const wxTreeItemId& item, bool dirsOnly = false);
VirtualNode* getNode(const wxTreeItemId& item);
VirtualNode* getSelectedNode();
wxTreeItemId getSelected();
wxTreeItemId appendItem(const wxTreeItemId& parent, wxString title);
- void _recDel(const wxTreeItemId& item, bool thisToo); //HACK
void deleteItem(const wxTreeItemId& item);
void deleteChildren(const wxTreeItemId& parent);
void setItemData(const wxTreeItemId& item, wxTreeItemData* data);
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/FileInfoPresenter.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/FileInfoPresenter.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/FileInfoPresenter.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -12,6 +12,8 @@
#include <iostream>
+wxFrame* getMainForm();
+
#include "debugmem.h"
namespace Browser {
@@ -83,7 +85,7 @@
}
wxFileDialog *saveDlg;
- saveDlg = new wxFileDialog(NULL, wxT("Choose a file"), wxT(""), ifile->getName(), wxT("*.*"), wxSAVE | wxOVERWRITE_PROMPT);
+ saveDlg = new wxFileDialog(getMainForm(), wxT("Choose a file"), wxT(""), ifile->getName(), wxT("*.*"), wxSAVE | wxOVERWRITE_PROMPT);
int res = saveDlg->ShowModal();
if (res == wxID_OK) {
@@ -92,7 +94,7 @@
if (!out.IsOk()) {
//errout << wxT("FilePresenter::dumpFile(): could not write file") << std::endl;
wxMessageBox(wxString(wxT("Could not open out stream: ")) + fileName,
- wxT("Dumping File Failed"), wxOK | wxICON_ERROR, NULL);
+ wxT("Dumping File Failed"), wxOK | wxICON_ERROR, getMainForm());
} else {
stream->seek(0, SEEK_SET);
wxInputStream* input = new wxScummInputStream(stream);
@@ -100,15 +102,12 @@
delete input;
if (!out.IsOk() /*HACK: see wxScummInputStream::OnSysRead() || stream->ioFailed()*/) {
wxMessageBox(wxString(wxT("Error writing file: ")) + fileName,
- wxT("Dumping File Failed"), wxOK | wxICON_ERROR, NULL);
- } else {
- wxMessageBox(wxString(wxT("Written file: ")) + fileName,
- wxT("Dumping File"), wxOK | wxICON_INFORMATION, NULL);
+ wxT("Dumping File Failed"), wxOK | wxICON_ERROR, getMainForm());
}
}
}
- delete saveDlg;
+ saveDlg->Destroy();
_fileSlot->releaseInterface();
}
@@ -148,7 +147,7 @@
uint32 p = stream->pos();
uint32 s = stream->size();
text << wxT("Size: ") << s << wxEndl();
- text << wxT("Current position in file: ") << p << wxEndl();
+ //text << wxT("Current position in file: ") << p << wxEndl();
}
_fileSlot->releaseInterface();
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -10,6 +10,8 @@
#include <iostream>
+wxFrame* getMainForm();
+
#include "debugmem.h"
namespace Browser {
@@ -32,7 +34,7 @@
ImagePresenter::ImagePresenter()
-: _bitmap(NULL), _bmpPanel(NULL) {}
+: _bitmap(NULL), _evtHelper(this) {}
ImagePresenter::~ImagePresenter() {
if (_bitmap)
@@ -46,41 +48,81 @@
void ImagePresenter::panelActivate(wxPanel* panel) {
//infoout << wxT("ImagePresenter::panelActivate()") << std::endl;
- if (!_bitmap) {
- IImage* iimage = _imageSlot->getInterface();
- if (!iimage) {
- errout << wxT("ImagePresenter::panelActivate(): could not get IImage interface") << std::endl;
- return;
- }
+ create();
+ if (!_bitmap)
+ return;
- //std::cout << wxT(" -- bitmap: ") << bitmap->getBitmap() << std::endl;
- wxImage* image = iimage->getImage();
- if (!image) {
- errout << wxT("ImagePresenter::panelActivate(): could not get wxImage from IImage interface") << std::endl;
- _imageSlot->releaseInterface();
- return;
- }
-
- _bitmap = new wxBitmap(*image);
- _imageSlot->releaseInterface();
- }
+ wxBoxSizer *panelsizer = new wxBoxSizer( wxVERTICAL );
- _bmpPanel = new BitmapPanel(panel,*_bitmap);
+ wxPanel *bmpPanel = new BitmapPanel(panel, *_bitmap);
+ panelsizer->Add(bmpPanel, 1, wxALL|wxEXPAND, 0);
+ wxButton *dumpButton = new wxButton(panel, wxID_ANY, wxT("Dump Image"), wxPoint(167,450), wxSize(75,25), 0, wxDefaultValidator, wxT("dumpButton"));
+ panelsizer->Add(dumpButton, 0, wxALL, 0);
- /*wxSizer* sizer = panel->GetSizer();
- sizer->Add(bmpPanel, 1, wxALL, 3);
- sizer->Layout();*/
+ panel->SetAutoLayout(true);
+ panel->SetSizer(panelsizer);
+
+ panel->Layout();
+
+ dumpButton->Connect(dumpButton->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
+ wxCommandEventHandler(DumpImageEvtHandler::dumpButtonClick), NULL, &_evtHelper);
}
void ImagePresenter::panelDeactivate() {
//infoout << wxT("ImagePresenter::panelDeactivate()") << std::endl;
+}
- if (_bmpPanel) {
- _bmpPanel->Destroy();
- _bmpPanel = NULL;
+void ImagePresenter::create() {
+ //infoout << wxT("ImagePresenter::create()") << std::endl;
+
+ if (_bitmap)
+ return;
+
+ IImage* iimage = _imageSlot->getInterface();
+ if (!iimage) {
+ errout << wxT("ImagePresenter::create(): could not get IImage interface") << std::endl;
+ return;
}
+
+ //std::cout << wxT(" -- bitmap: ") << bitmap->getBitmap() << std::endl;
+ wxImage* image = iimage->getImage();
+ if (!image) {
+ errout << wxT("ImagePresenter::create(): could not get wxImage from IImage interface") << std::endl;
+ _imageSlot->releaseInterface();
+ return;
+ }
+
+ _bitmap = new wxBitmap(*image);
+ _imageSlot->releaseInterface();
}
+void DumpImageEvtHandler::dumpButtonClick(wxCommandEvent& event) {
+ _that->dumpImage();
+}
+
+void ImagePresenter::dumpImage() {
+ //infoout << wxT("FileInfoPresenter::dumpFile(): ") << std::endl;
+
+ create();
+ if (!_bitmap)
+ return;
+
+ wxFileDialog *saveDlg;
+ saveDlg = new wxFileDialog(getMainForm(), wxT("Choose a file"), wxT(""), wxT("image.bmp"), wxT("*.bmp"), wxSAVE | wxOVERWRITE_PROMPT);
+ int res = saveDlg->ShowModal();
+
+ if (res == wxID_OK) {
+ wxString fileName = saveDlg->GetPath();
+ bool res = _bitmap->SaveFile(fileName, wxBITMAP_TYPE_BMP);
+ if (!res) {
+ wxMessageBox(wxString(wxT("Error writing file: ")) + fileName,
+ wxT("Dumping Image Failed"), wxOK | wxICON_ERROR, getMainForm());
+ }
+ }
+
+ saveDlg->Destroy();
+}
+
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.h 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/ImagePresenter.h 2007-07-10 04:54:41 UTC (rev 28001)
@@ -14,6 +14,15 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+class ImagePresenter;
+
+struct DumpImageEvtHandler : public wxEvtHandler {
+ ImagePresenter* _that;
+ DumpImageEvtHandler(ImagePresenter* that)
+ : _that(that) {}
+ void dumpButtonClick(wxCommandEvent& event);
+};
+
class ImagePresenter : public BObject, public PanelReciever {
DECLARE_BOBJECT_CLASS(ImagePresenter, BObject)
@@ -22,8 +31,9 @@
Pin<IPanelReciever>* _panelRecieverPin;
wxBitmap* _bitmap;
- wxPanel* _bmpPanel;
+ DumpImageEvtHandler _evtHelper;
+
public:
ASSIGN_DESC(0,wxT("CoreObjects"), 1)
@@ -36,6 +46,8 @@
virtual coreString getPanelTitle();
virtual void panelActivate(wxPanel* panel);
virtual void panelDeactivate();
+ virtual void create();
+ virtual void dumpImage();
IPanelRecieverImpl* getPanelRecieverImpl();
};
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -14,9 +14,8 @@
#include <fstream>
#include "ExplorationTree.h"
+#include "oregistry.h"
#include "ftregistry.h"
-#include "oregistry.h"
-#include "VirtualNode.h"
#include "safe_static.h"
@@ -41,6 +40,7 @@
////Manual Code End
EVT_CLOSE(MainForm::OnClose)
+ EVT_IDLE(MainForm::MainFormIdle)
EVT_MENU(ID_OPEN, MainForm::OnOpen)
EVT_MENU(wxID_EXIT, MainForm::OnExit)
EVT_MENU(ID_DUMPROOTOBJECTCHAIN, MainForm::OnDumpRootObjectChain)
@@ -57,16 +57,32 @@
END_EVENT_TABLE()
////Event Table End
+wxFrame* getMainForm() {
+ return MainForm::getMainForm();
+}
+
+MainForm* MainForm::_mainForm = NULL;
+/*static*/ MainForm* MainForm::getMainForm() {
+ ASSERT(_mainForm);
+ return _mainForm;
+}
+
MainForm::MainForm(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style) {
CreateGUIControls();
- SetClientSize( wxSize(640, 480) );
- GetSizer()->SetMinSize(640, 480);
- mainPanel->SetMinSize( wxSize(400, 300) );
- mainPanel->SetSize( wxSize(400, 300) );
- Layout();
+ //SetClientSize( wxSize(640, 480) );
+ //GetSizer()->SetMinSize(640, 480);
+ //mainPanel->SetMinSize( wxSize(400, 300) );
+ //mainPanel->SetSize( wxSize(400, 300) );
+ //Layout();
+ WxSplitterWindow1->SetSashGravity(0.3);
+ _mainForm = this;
ExplorationTree::initialize(browserTree, browserNotebook);
+ /*_timer = new wxTimer();
+ _timer->SetOwner(this, 5);
+ this->Connect(5, wxEVT_TIMER, wxTimerEventHandler(MainForm::OnTimer));
+ _timer->Start(300);*/
wxChar* leak = new wxChar[5]; // a deliberate memory leak
leak[0] = 'L'; leak[1] = 'E'; leak[2] = 'A'; leak[3] = 'K'; leak[4] = '\0';
@@ -74,6 +90,12 @@
void MainForm::ZCleanup() {
+ /*_timer->Stop();*/
+ /*delete _timer;*/
+
+ //this->Disconnect(_timer.GetId(), wxEVT_TIMER, wxTimerEventHandler(MainForm::OnTimer));
+ //_timer.SetOwner(NULL);
+
InitializedObjects::get()->report();
ExplorationTree::release();
@@ -88,6 +110,7 @@
InitializedObjects::release();
set_statics_not_allowed();
+ _mainForm = NULL;
}
MainForm::~MainForm() {
@@ -106,7 +129,7 @@
WxSplitterWindow1 = new wxSplitterWindow(this, ID_WXSPLITTERWINDOW1, wxPoint(0,0), wxSize(578,392));
WxSplitterWindow1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
- WxBoxSizer1->Add(WxSplitterWindow1,1,wxALIGN_CENTER | wxEXPAND | wxALL,0);
+ WxBoxSizer1->Add(WxSplitterWindow1,1,wxEXPAND | wxALL,0);
browserTree = new wxTreeCtrl(WxSplitterWindow1, ID_BROWSERTREE, wxPoint(5,5), wxSize(185,382), wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT);
browserTree->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
@@ -131,6 +154,7 @@
wxMenu *ID_COMMANDS_MENU_Mnu_Obj = new wxMenu(0);
ID_COMMANDS_MENU_Mnu_Obj->Append(ID_DUMPROOTOBJECTCHAIN, wxT("Dump Root Object Chain"), wxT(""), wxITEM_NORMAL);
+ ID_COMMANDS_MENU_Mnu_Obj->Enable(ID_DUMPROOTOBJECTCHAIN,false);
ID_COMMANDS_MENU_Mnu_Obj->Append(ID_DUMPCURRENTOBJECTCHAIN, wxT("Dump Current Object Chain"), wxT(""), wxITEM_NORMAL);
ID_COMMANDS_MENU_Mnu_Obj->Append(ID_ACTIVATENODE, wxT("Activate Node"), wxT(""), wxITEM_NORMAL);
WxMenuBar1->Append(ID_COMMANDS_MENU_Mnu_Obj, wxT("Commands"));
@@ -143,10 +167,8 @@
WxMenuBar1->Append(ID_TEST_MENU_Mnu_Obj, wxT("Tests"));
SetMenuBar(WxMenuBar1);
- WxOpenFileDialog1 = new wxFileDialog(this, wxT("Choose a file"), wxT(""), wxT(""), wxT("*.*"), wxOPEN);
+ WxSplitterWindow1->SplitVertically(browserTree,mainPanel,185);
- WxSplitterWindow1->SplitVertically(browserTree,mainPanel,329);
-
SetTitle(wxT("Game Resource Browser"));
SetIcon(wxNullIcon);
@@ -169,3 +191,4 @@
void MainForm::OnExit(wxCommandEvent& event) {
Close(true);
}
+
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.h 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.h 2007-07-10 04:54:41 UTC (rev 28001)
@@ -18,7 +18,6 @@
//Header Include Start and Header Include End.
//wxDev-C++ designer will remove them. Add custom headers after the block.
////Header Include Start
-#include <wx/filedlg.h>
#include <wx/menu.h>
#include <wx/notebook.h>
#include <wx/panel.h>
@@ -41,11 +40,16 @@
private:
DECLARE_EVENT_TABLE();
+ static MainForm* _mainForm;
+
public:
MainForm(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("Game Resource Browser"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = MainForm_STYLE);
virtual ~MainForm();
//virtual bool Destroy();
void ZCleanup();
+ void OnTimer(wxTimerEvent& event);
+ static MainForm* getMainForm();
+
void dumpObjectChain(Browser::ObjectChain* ochain);
void ExitClick(wxCommandEvent& event);
void OnTest1Cleanup(wxCommandEvent& event);
@@ -59,13 +63,13 @@
void OnActivateNode(wxCommandEvent& event);
void browserTreeItemExpanded(wxTreeEvent& event);
void OnOpen(wxCommandEvent& event);
+ void MainFormIdle(wxIdleEvent& event);
private:
//Do not add custom control declarations between
//GUI Control Declaration Start and GUI Control Declaration End.
//wxDev-C++ will remove them. Add custom code after the block.
////GUI Control Declaration Start
- wxFileDialog *WxOpenFileDialog1;
wxMenuBar *WxMenuBar1;
wxNotebook *browserNotebook;
wxBoxSizer *WxBoxSizer2;
@@ -74,6 +78,7 @@
wxSplitterWindow *WxSplitterWindow1;
wxBoxSizer *WxBoxSizer1;
////GUI Control Declaration End
+ wxTimer* _timer;
private:
//Note: if you receive any error with these enum IDs, then you need to
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.wxform
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.wxform 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/MainForm.wxform 2007-07-10 04:54:41 UTC (rev 28001)
@@ -4,8 +4,8 @@
AutoScroll = False
BorderIcons = [biSystemMenu, biMinimize]
Caption = 'Game Resource Browser'
- ClientHeight = 392
- ClientWidth = 571
+ ClientHeight = 359
+ ClientWidth = 510
Color = clAppWorkSpace
OldCreateOrder = True
PopupMenu = MainForm.DesignerPopup
@@ -15,6 +15,7 @@
OnDestroy = FormDestroy
OnResize = FormResize
EVT_CLOSE = 'OnClose'
+ EVT_IDLE = 'MainFormIdle'
Wx_ICON.Data = {07544269746D617000000000}
Wx_Name = 'MainForm'
Wx_IDName = 'ID_DIALOG1'
@@ -33,14 +34,17 @@
object WxBoxSizer1: TWxBoxSizer
Left = 0
Top = 0
- Width = 571
- Height = 392
+ Width = 510
+ Height = 359
Align = alClient
TabOrder = 0
Wx_Class = 'wxBoxSizer'
Wx_ControlOrientation = wxControlVertical
Wx_IDName = 'ID_WXBOXSIZER1'
Wx_IDValue = 1013
+ Wx_BorderAlignment = []
+ Wx_Alignment = [wxEXPAND]
+ Wx_StretchFactor = 1
object WxSplitterWindow1: TWxSplitterWindow
Left = 0
Top = 0
@@ -57,11 +61,11 @@
'EVT_UPDATE_UI : OnUpdateUI')
Wx_IDName = 'ID_WXSPLITTERWINDOW1'
Wx_IDValue = 1014
- Wx_SashPosition = 329
+ Wx_SashPosition = 185
Wx_GeneralStyle = []
Wx_SplitterStyle = []
Wx_Border = 0
- Wx_Alignment = [wxALIGN_CENTER, wxEXPAND]
+ Wx_Alignment = [wxEXPAND]
Wx_StretchFactor = 1
object browserTree: TWxTreeCtrl
Left = 5
@@ -82,7 +86,7 @@
Wx_IDName = 'ID_BROWSERTREE'
Wx_IDValue = 1016
Wx_TreeviewStyle = [wxTR_HAS_BUTTONS, wxTR_LINES_AT_ROOT]
- Wx_Alignment = [wxALIGN_CENTER, wxEXPAND]
+ Wx_Alignment = [wxEXPAND]
Wx_StretchFactor = 1
end
object mainPanel: TWxPanel
@@ -102,7 +106,7 @@
Wx_Hidden = False
Wx_IDName = 'ID_MAINPANEL'
Wx_IDValue = 1017
- Wx_Alignment = [wxALIGN_CENTER, wxEXPAND]
+ Wx_Alignment = [wxEXPAND]
Wx_StretchFactor = 1
object WxBoxSizer2: TWxBoxSizer
Left = 1
@@ -115,6 +119,9 @@
Wx_ControlOrientation = wxControlVertical
Wx_IDName = 'ID_WXBOXSIZER2'
Wx_IDValue = 1020
+ Wx_BorderAlignment = []
+ Wx_Alignment = [wxEXPAND]
+ Wx_StretchFactor = 1
object browserNotebook: TWxNotebook
Left = 5
Top = 5
@@ -285,7 +292,7 @@
545778437573746F6D4D656E754974656D5450463018547778437573746F6D4D
656E754974656D577261707065720011436172726965642E49735375624D656E
750810436172726965642E4556545F4D656E7506154F6E44756D70526F6F744F
- 626A656374436861696E12436172726965642E57785F456E61626C6564091143
+ 626A656374436861696E12436172726965642E57785F456E61626C6564081143
6172726965642E57785F48696464656E0811436172726965642E57785F49444E
616D65061649445F44554D50524F4F544F424A454354434841494E1243617272
6965642E57785F494456616C756503020418436172726965642E57785F4D656E
@@ -376,90 +383,4 @@
6F72790800000000}
Wx_HasHistory = False
end
- object WxOpenFileDialog1: TWxOpenFileDialog
- Left = 155
- Top = 110
- Width = 28
- Height = 27
- TabOrder = 2
- Glyph.Data = {
- 36090000424D3609000000000000360000002800000018000000180000000100
- 2000000000000009000000000000000000000000000000000000008080000080
- 8000008080000080800000808000008080000080800000808000008080000080
- 8000008080000080800000808000008080000080800000808000008080000080
- 8000008080000080800000808000008080000080800000808000008080000080
- 8000008080000080800000808000008080000080800000808000008080000080
- 8000008080000080800000808000008080000080800000808000008080000080
- 8000008080000080800000808000008080000080800000808000008080008080
- 8000000000000000000000000000000000000000000000000000000000000000
- 0000000000000000000000000000000000000000000000000000000000000000
- 0000000000000000000000000000000000000000000000808000008080008080
- 8000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0
- C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0
- C000C0C0C000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0
- C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0
- C000C0C0C000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C000C0C0C000000000000000000000000000000000000000
- 000000000000000000000000000000000000000000000000000000000000C0C0
- C000C0C0C000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C000000000000000000000FFFF00C0C0C00000FFFF00C0C0
- C00000FFFF00C0C0C00000FFFF00C0C0C00000FFFF00C0C0C00000FFFF000000
- 0000C0C0C000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C0000000000000FFFF000000000000FFFF00C0C0C00000FF
- FF00C0C0C00000FFFF00C0C0C00000FFFF00C0C0C00000FFFF00C0C0C00000FF
- FF0000000000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C00000000000FFFFFF0000000000C0C0C00000FFFF00C0C0
- C00000FFFF00C0C0C00000FFFF00C0C0C00000FFFF00C0C0C00000FFFF00C0C0
- C00000000000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C0000000000000FFFF00FFFFFF0000000000C0C0C00000FF
- FF00C0C0C00000FFFF00C0C0C00000FFFF00C0C0C00000FFFF00C0C0C00000FF
- FF00C0C0C00000000000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C00000000000FFFFFF0000FFFF00FFFFFF00000000000000
- 0000000000000000000000000000C0C0C00000FFFF00C0C0C00000FFFF00C0C0
- C00000FFFF0000000000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C0000000000000FFFF00FFFFFF0000FFFF00FFFFFF0000FF
- FF00FFFFFF0000FFFF00FFFFFF00000000000000000000000000000000000000
- 000000000000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C00000000000FFFFFF0000FFFF00FFFFFF0000FFFF00FFFF
- FF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF000000
- 0000C0C0C000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C0000000000000FFFF00FFFFFF0000FFFF00FFFFFF0000FF
- FF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF000000
- 0000C0C0C000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C00000000000FFFFFF0000FFFF00FFFFFF0000FFFF00FFFF
- FF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF000000
- 0000C0C0C000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C0000000000000FFFF00FFFFFF0000FFFF00FFFFFF0000FF
- FF0000000000000000000000000000000000000000000000000000000000C0C0
- C000C0C0C000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C000C0C0C000000000000000000000000000000000000000
- 0000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0
- C000C0C0C000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0
- C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0
- C000C0C0C000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0
- C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0C000C0C0
- C000C0C0C000C0C0C000C0C0C000C0C0C0000000000000808000008080008080
- 8000000000000000000000000000000000000000000000000000000000000000
- 0000000000000000000000000000000000000000000000000000000000000000
- 0000000000000000000000000000000000000000000000808000008080008080
- 8000FFFFFF0000000000FF000000FF000000FF000000FF000000FF000000FF00
- 0000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF00
- 000000000000FFFFFF0000000000FFFFFF000000000000808000008080008080
- 8000808080008080800080808000808080008080800080808000808080008080
- 8000808080008080800080808000808080008080800080808000808080008080
- 8000808080008080800080808000808080008080800000808000008080000080
- 8000008080000080800000808000008080000080800000808000008080000080
- 8000008080000080800000808000008080000080800000808000008080000080
- 8000008080000080800000808000008080000080800000808000008080000080
- 8000008080000080800000808000008080000080800000808000008080000080
- 8000008080000080800000808000008080000080800000808000008080000080
- 8000008080000080800000808000008080000080800000808000}
- Wx_Class = 'wxFileDialog'
- Wx_Message = 'Choose a file'
- Wx_Extensions = '*.*'
- Wx_DialogStyle = []
- end
end
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/MainFormCommands.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/MainFormCommands.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/MainFormCommands.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -71,7 +71,7 @@
wxT("Dump Object Chain Failed"), wxOK | wxICON_ERROR, this);
}
- delete saveDlg;
+ saveDlg->Destroy();
}
@@ -100,5 +100,21 @@
ExplorationTree::get()->itemActivated(item);
}
+/*
+* MainFormIdle
+*/
+void MainForm::MainFormIdle(wxIdleEvent& event)
+{
+ //if (ExplorationTree::canGet() && ExplorationTree::get()->onIdle())
+ // event.RequestMore();
+ ExplorationTree::canGet() && ExplorationTree::get()->onIdle();
+}
+
+void MainForm::OnTimer(wxTimerEvent& event)
+{
+ //::wxWakeUpIdle();
+ ExplorationTree::canGet() && ExplorationTree::get()->onIdle();
+}
+
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/Test1.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/Test1.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/Test1.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -68,7 +68,7 @@
RCPtr<RootDirectory> rootDir( new RootDirectory(rootItem) );
ObjectChain* rootChain = ExplorationTree::get()->getRootObjectChain();
- VirtualNodeItemData* itemData = new VirtualNodeItemData(rootDir.get(), rootChain, false);
+ VirtualNodeItemData* itemData = new VirtualNodeItemData(rootDir.get(), rootChain);
ExplorationTree::get()->setItemData(rootItem, itemData);
rootChain->addObject(rootDir);
@@ -104,7 +104,7 @@
RCPtr<RootDirectory> rootDir( new RootDirectory(rootItem) );
ObjectChain* rootChain = ExplorationTree::get()->getRootObjectChain();
- VirtualNodeItemData* itemData = new VirtualNodeItemData(rootDir.get(), rootChain, false);
+ VirtualNodeItemData* itemData = new VirtualNodeItemData(rootDir.get(), rootChain);
ExplorationTree::get()->setItemData(rootItem, itemData);
rootChain->addObject(rootDir);
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/Test2.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/Test2.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/Test2.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -73,6 +73,16 @@
PLUGGED_OBJECT(ScummBlockPresenter)
PLUGGED_OBJECT(ScummBlockInfoPresenter)
PLUGGED_OBJECT(BlockyBlockPresenter)
+
+ PLUGGED_OBJECT(ScummLOFFBlockPresenter)
+ PLUGGED_OBJECT(ScummOFFSBlockPresenter)
+ PLUGGED_OBJECT(ScummRMHDBlockPresenter)
+ PLUGGED_OBJECT(ScummTRNSBlockPresenter)
+ PLUGGED_OBJECT(ScummPALBlockPresenter)
+ PLUGGED_OBJECT(ScummIMGBlockPresenter)
+
+ PLUGGED_OBJECT(ScummScriptBlockPresenter)
+
PLUGIN_END
/////////////////////////////////////////////////////////////////////////////
@@ -90,7 +100,7 @@
RCPtr<RootDirectory> rootDir( new RootDirectory(rootItem) );
ObjectChain* rootChain = ExplorationTree::get()->getRootObjectChain();
- VirtualNodeItemData* itemData = new VirtualNodeItemData(rootDir.get(), rootChain, false);
+ VirtualNodeItemData* itemData = new VirtualNodeItemData(rootDir.get(), rootChain);
ExplorationTree::get()->setItemData(rootItem, itemData);
rootChain->addObject(rootDir);
@@ -110,16 +120,33 @@
{
//TODO: Make it better
- int res = WxOpenFileDialog1->ShowModal();
+ wxString filepath;
+ wxFileDialog *openDlg = new wxFileDialog(this, wxT("Please select an input file."), filepath, wxT(""),
+ wxT("All Files|*|")
+ wxT("Main Resource Files|*.001;*.la1;*.la2;*.lab;*.lfl;*.lec;*.sm1|")
+ wxT("Directory Files|*.000;*.la0;*.lfl;*.sm0"),
+ wxOPEN);
- if (res != wxID_OK)
+ int res = openDlg->ShowModal();
+ if (res != wxID_OK) {
+ openDlg->Destroy();
return;
+ }
+
OnTest1Cleanup(event);
- wxString fileName = WxOpenFileDialog1->GetPath();
+ wxString fileName = openDlg->GetPath();
+ openDlg->Destroy();
+ wxFileName file = wxFileName(fileName);
+
+ filepath = file.GetPath();
+ //_gui->writeConfigValue("DataPath", filepath);
+
+
+
infoout << wxT("Registering Test2 Plugin.") << std::endl;
ObjectRegistry::get()->registerPlugin( &getTest2Plugin, false );
@@ -128,7 +155,7 @@
RCPtr<RootDirectory> rootDir( new RootDirectory(rootItem) );
ObjectChain* rootChain = ExplorationTree::get()->getRootObjectChain();
- VirtualNodeItemData* itemData = new VirtualNodeItemData(rootDir.get(), rootChain, false);
+ VirtualNodeItemData* itemData = new VirtualNodeItemData(rootDir.get(), rootChain);
ExplorationTree::get()->setItemData(rootItem, itemData);
rootChain->addObject(rootDir);
Modified: scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/gui/VirtualNode.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -17,8 +17,8 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-VirtualNodeItemData::VirtualNodeItemData(VirtualNode* node, ObjectChain* ochain, bool realized)
- : _node(node), _ochain(ochain), _realized(realized) {}
+VirtualNodeItemData::VirtualNodeItemData(VirtualNode* node, ObjectChain* ochain)
+ : _node(node), _ochain(ochain), _realized(false), _completed(false) {}
VirtualNode* VirtualNodeItemData::getNode() {
return _node;
@@ -32,6 +32,14 @@
_realized = realized;
}
+bool VirtualNodeItemData::getCompleted() {
+ return _completed;
+}
+
+void VirtualNodeItemData::setCompleted(bool completed) {
+ _completed = completed;
+}
+
ObjectChain* VirtualNodeItemData::getObjectChain() {
return _ochain;
}
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/GUIInterfaces.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/GUIInterfaces.h 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/GUIInterfaces.h 2007-07-10 04:54:41 UTC (rev 28001)
@@ -18,6 +18,9 @@
public:
GUID_FOR(IImage, wxT("GUIInterfaces"), 1)
virtual wxImage* getImage() = 0;
+ virtual void release() {
+ delete this;
+ }
};
/////////////////////////////////////////////////////////////////////////////
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/VirtualNode.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/VirtualNode.h 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/VirtualNode.h 2007-07-10 04:54:41 UTC (rev 28001)
@@ -23,15 +23,18 @@
class VirtualNodeItemData : public wxTreeItemData {
VirtualNode* _node;
bool _realized;
+ bool _completed;
ObjectChain* _ochain;
public:
- VirtualNodeItemData(VirtualNode* node, ObjectChain* ochain, bool realized);
+ VirtualNodeItemData(VirtualNode* node, ObjectChain* ochain);
//virtual ~VirtualNodeItemData() {}
VirtualNode* getNode();
bool getRealized();
void setRealized(bool realized);
+ bool getCompleted();
+ void setCompleted(bool completed);
ObjectChain* getObjectChain();
void setObjectChain(ObjectChain* ochain);
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockInfoPresenter.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockInfoPresenter.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockInfoPresenter.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -5,11 +5,14 @@
#include "scumm/ScummBlockInfoPresenter.h"
#include "scumm/ScummBlockPresenter.h"
+#include "scumm/descumm.h"
#include "CoreInterfaces.h"
#include <iostream>
+wxFrame* getMainForm();
+
#include "debugmem.h"
namespace Browser {
@@ -17,24 +20,19 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-SLOT_DESCS_EX(ScummBlockInfoPresenter)
+SLOT_DESCS_EX(ScummBlockPresenterBase)
SLOT_DESC(_blockSlot, SLOT_DEFAULT)
END_DESCS
-PIN_DESCS_EX(ScummBlockInfoPresenter)
- PIN_DESC_r(_textPin, PIN_DEFAULT | PIN_MULTICAST, getTextImpl, ITextImpl)
- PIN_DESC_r(_urlPin, PIN_DEFAULT | PIN_MULTICAST, getUrlImpl, IUrlImpl)
-END_DESCS
-
-void ScummBlockInfoPresenter::create() {
- //infoout << wxT("ScummBlockInfoPresenter::create(): ") << std::endl;
+void ScummBlockPresenterBase::create() {
+ //infoout << wxT("ScummBlockPresenterBase::create(): ") << std::endl;
if(_created)
return;
_created = true;
IProvider<FileNScummBlock>* iprov = _blockSlot->getInterface();
if (!iprov) {
- errout << wxT("ScummBlockInfoPresenter::create(): could not get IProvider<FileNScummBlock> interface") << std::endl;
+ errout << wxT("ScummBlockPresenterBase::create(): could not get IProvider<FileNScummBlock> interface") << std::endl;
return;
}
@@ -42,16 +40,86 @@
ScummBlock* block = iprov->getData()->getBlock();
if (!block) {
- errout << wxT("ScummBlockInfoPresenter::create(): NULL block") << std::endl;
+ errout << wxT("ScummBlockPresenterBase::create(): NULL block") << std::endl;
_blockSlot->releaseInterface();
return;
}
+ uint32 hsize;
+ if (!block->determineHeaderSize(hsize)) {
+ errout << wxT("ScummBlockInfoPresenterBase::create(): could not determine header size") << std::endl;
+ _blockSlot->releaseInterface();
+ return;
+ }
+
ScummTag* tag = block->getTag();
ASSERT(tag);
-
_title = tag->toString();
+ Common::SeekableReadStream* stream = block->getStream();
+ ASSERT(stream);
+
+ stream->seek(hsize, SEEK_SET);
+
+ inCreate(block, stream);
+
+ _blockSlot->releaseInterface();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+PIN_DESCS_EX(ScummBlockInfoPresenterBase)
+ PIN_DESC_r(_textPin, PIN_DEFAULT | PIN_MULTICAST, getTextImpl, ITextImpl)
+END_DESCS
+
+
+void ScummBlockInfoPresenterBase::inCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummBlockInfoPresenterBase::inCreate(): ") << std::endl;
+ doCreate(block, stream);
+}
+
+ITextImpl* ScummBlockInfoPresenterBase::getTextImpl() {
+ //infoout << wxT("ScummBlockInfoPresenterBase::getTextImpl(): ") << std::endl;
+ create();
+ if (_text.IsEmpty())
+ return new ITextImpl(wxT("ERROR"), wxT("no info to display"));
+ return new ITextImpl(_title, _text, _monospace);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+PIN_DESCS_EX(ScummBlockImagePresenter)
+ PIN_DESC_r(_imagePin, PIN_DEFAULT | PIN_MULTICAST, getImageImpl, IImageImpl)
+END_DESCS
+
+
+void ScummBlockImagePresenter::inCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummBlockImagePresenter::inCreate(): ") << std::endl;
+ doCreate(block, stream);
+}
+
+IImageImpl* ScummBlockImagePresenter::getImageImpl() {
+ //infoout << wxT("ScummBlockImagePresenter::getImageImpl(): ") << std::endl;
+ create();
+ return new IImageImpl(/*_title,*/ &_image, false);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+PIN_DESCS_EX(ScummBlockInfoPresenter)
+ PIN_DESC_r(_urlPin, PIN_DEFAULT | PIN_MULTICAST, getUrlImpl, IUrlImpl)
+END_DESCS
+
+void ScummBlockInfoPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummBlockInfoPresenter::doCreate(): ") << std::endl;
+ ScummTag* tag = block->getTag();
+ ASSERT(tag);
+
+ _title = wxT("Block Info");
+
_text = wxT("");
_text << wxT("Block type: ") << _title << wxEndl();
_text << wxT("Size mode: ") << block->_sizeMode << wxEndl();
@@ -72,18 +140,8 @@
_text << wxT("Could not find block info.") << wxEndl();
_url = wxT("");
}
-
- _blockSlot->releaseInterface();
}
-ITextImpl* ScummBlockInfoPresenter::getTextImpl() {
- //infoout << wxT("ScummBlockInfoPresenter::getTextImpl(): ") << std::endl;
- create();
- if (_text.IsEmpty())
- return NULL;
- return new ITextImpl(_title, _text);
-}
-
IUrlImpl* ScummBlockInfoPresenter::getUrlImpl() {
//infoout << wxT("ScummBlockInfoPresenter::getUrlImpl(): ") << std::endl;
create();
@@ -97,4 +155,323 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+void ScummEntryBlockPresenter::determineNumEntries(ScummBlock* block, Common::SeekableReadStream* stream) {
+ switch(_countMode) {
+ case ENTRY_COUNT_MODE_BYTE:
+ _numEntries = stream->readByte();
+ break;
+ case ENTRY_COUNT_MODE_INT32BE:
+ _numEntries = stream->readUint32BE();
+ break;
+ case ENTRY_COUNT_MODE_INT32LE:
+ _numEntries = stream->readUint32LE();
+ break;
+ case ENTRY_COUNT_MODE_CUSTOM:
+ {
+ uint32 p = stream->pos();
+ uint32 s = stream->size();
+ _numEntries = (s - p) / _customEntrySize;
+ }
+ break;
+ case ENTRY_COUNT_MODE_FIXED:
+ //use current _numEntries
+ break;
+ default:
+ errout << wxT("ScummEntryBlockPresenter::determineNumEntries(): invalid count mode") << std::endl;
+ _numEntries = 0;
+ break;
+ }
+}
+
+void ScummEntryBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummEntryBlockPresenter::doCreate(): ") << std::endl;
+
+ determineNumEntries(block, stream);
+
+ _text = doPreEntries(block, stream);
+ for (uint32 i = 0; i < _numEntries; ++i) {
+ _text += doReadEntry(block, i, stream);
+ }
+ _text += doPostEntries(block, stream);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+wxString toHex(uint32 num, int digits = 8) {
+ return wxString::Format(wxString::Format(wxT("%%0%dX"), digits), num);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+wxString ScummLOFFBlockPresenter::doPreEntries(ScummBlock* block, Common::SeekableReadStream* stream) {
+ return wxString::Format(wxT("Number of rooms: %d\n\n"), _numEntries);
+}
+
+wxString ScummLOFFBlockPresenter::doReadEntry(ScummBlock* block, uint32 idx, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummLOFFBlockPresenter::doReadEntry(): ") << std::endl;
+
+ byte roomNumber = stream->readByte();
+ uint32 offset = stream->readUint32LE();
+
+ wxString txt;
+ txt << wxT("Room Number: ") << roomNumber << wxEndl();
+ txt << wxT("Offset: ") << toHex(offset) << wxEndl();
+ return txt;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+wxString ScummOFFSBlockPresenter::doPreEntries(ScummBlock* block, Common::SeekableReadStream* stream) {
+ return wxString::Format(wxT("Number of offsets: %d\n\n"), _numEntries);
+}
+
+wxString ScummOFFSBlockPresenter::doReadEntry(ScummBlock* block, uint32 idx, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummLOFFBlockPresenter::doReadEntry(): ") << std::endl;
+
+ uint32 offset = stream->readUint32LE();
+
+ wxString txt;
+ txt << wxT("Offset: ") << toHex(offset) << wxEndl();
+ return txt;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+void ScummRMHDBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummRMHDBlockPresenter::doCreate(): ") << std::endl;
+
+ uint32 width = stream->readUint16LE();
+ uint32 height = stream->readUint16LE();
+ uint32 objs = stream->readUint16LE();
+
+ wxString txt;
+ txt << wxT("Room Width: ") << width << wxEndl();
+ txt << wxT("Room Height: ") << height << wxEndl();
+ txt << wxT("Number Of Objects: ") << objs << wxEndl();
+ _text = txt;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+void ScummTRNSBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummTRNSBlockPresenter::doCreate(): ") << std::endl;
+
+ uint32 transparentColor = stream->readUint16LE();
+
+ wxString txt;
+ txt << wxT("Transparent Color: ") << transparentColor << wxEndl();
+ _text = txt;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+int _getScummVersionDialog() {
+ int choice;
+ wxString games[22] = {
+ wxT("Maniac Mansion (C64)"),
+ wxT("Maniac Mansion (PC)"),
+ wxT("Zak McKracken"),
+ wxT("Zak McKracken (FM Towns)"),
+ wxT("Indiana Jones & The Last Crusade"),
+ wxT("Sampler (Loom, Indy3, SOMI)"),
+ wxT("The Secret of Monkey Island (Demo)"),
+ wxT("The Secret of Monkey Island (EGA)"),
+ wxT("The Secret of Monkey Island"),
+ wxT("Loom"),
+ wxT("Loom (CD)"),
+ wxT("Monkey Island 2: LeChuck's Revenge"),
+ wxT("Indiana Jones & The Fate of Atlantis"),
+ wxT("Day of the Tentacle"),
+ wxT("Sam & Max Hit The Road (Demo)"),
+ wxT("Sam & Max Hit The Road (Mac demo)"),
+ wxT("Sam & Max Hit The Road (Disk)"),
+ wxT("Sam & Max Hit The Road (CD)"),
+ wxT("Full Throttle"),
+ wxT("The Dig"),
+ wxT("The Dig (Win95)"),
+ wxT("The Curse of Monkey Island")
+ };
+
+ wxSingleChoiceDialog *dialog = new wxSingleChoiceDialog(getMainForm(), wxT("Please select the correct game"), wxT("Scumm version selection"), 22, games, NULL, wxOK|wxCANCEL|wxCENTRE, wxDefaultPosition);
+ int ret = 0;
+ if (dialog->ShowModal() == wxID_OK) {
+ choice = dialog->GetSelection();
+ switch (choice) {
+ case 0:
+ ret = 1;
+ break;
+ case 1:
+ case 2:
+ ret = 2;
+ break;
+ case 3:
+ case 4:
+ case 9:
+ ret = 3;
+ break;
+ case 5:
+ case 6:
+ case 7:
+ ret = 4;
+ break;
+ case 8:
+ case 10:
+ case 11:
+ case 12:
+ ret = 5;
+ break;
+ case 13:
+ case 14:
+ case 16:
+ ret = 6;
+ break;
+ case 17:
+ case 18:
+ case 19:
+ ret = 7;
+ break;
+ case 20:
+ case 21:
+ ret = 8;
+ break;
+ }
+ }
+ dialog->Destroy();
+ return ret;
+}
+
+void ScummScriptBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummTRNSBlockPresenter::doCreate(): ") << std::endl;
+
+ _monospace = true;
+ _title = wxT("Script");
+
+ static int _scummVersion = 0; //FIXME:
+ if (_scummVersion == 0)
+ _scummVersion = _getScummVersionDialog();
+ if (_scummVersion != 0) {
+ Common::SeekableReadStream* stream = block->getStream();
+ stream->seek(0, SEEK_SET);
+ DeScumm descumm(*stream, stream->size(), _scummVersion);
+ _text = descumm.getText();
+ if (_text.IsEmpty())
+ _text = wxT("<Empty script>");
+ } else {
+ if (_text.IsEmpty())
+ _text = wxT("<Unknown Scumm Version>");
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+void ScummPALBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummPALBlockPresenter::doCreate(): ") << std::endl;
+
+ ScummPALBlock* palBlock = dynamic_cast<ScummPALBlock*>(block);
+ if (!palBlock) {
+ errout << wxT("ScummPALBlockPresenter::doCreate(): unknown palette format") << std::endl;
+ return;
+ }
+
+ int palCnt = palBlock->getColCount();
+ byte* palData = palBlock->getPAL();
+
+ const int _w = 16;
+ const int _h = (palCnt + _w - 1) / _w;
+ const int w = 10;
+ const int h = 10;
+ _image.Create(16*w, 16*h, false);
+
+ for (int _y = 0; _y < _h; ++_y)
+ for (int _x = 0; _x < _w; ++_x)
+ for (int y = 0; y < h; ++y)
+ for (int x = 0; x < w; ++x) {
+ int col = _y * _w + _x;
+ if (col < palCnt)
+ _image.SetRGB(_x * w + x, _y * h + y,
+ palData[col * 3 + 0], palData[col * 3 + 1], palData[col * 3 + 2]);
+ else
+ _image.SetRGB(_x * w + x, _y * h + y, 0, 0, 0);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
} // namespace Browser
+
+#include "scumm/ScummImageDetail.h"
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+void ScummIMGBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummIMGBlockPresenter::doCreate(): ") << std::endl;
+
+ Image img;
+
+ ScummTag* tag = block->getTag();
+
+ bool obj = false;
+ obj |= tag->equals("IM01");
+ obj |= tag->equals("IM02");
+ obj |= tag->equals("IM03");
+ obj |= tag->equals("IM04");
+ obj |= tag->equals("IM05");
+ obj |= tag->equals("IM06");
+ obj |= tag->equals("IM07");
+ obj |= tag->equals("IM08");
+ obj |= tag->equals("IM09");
+ obj |= tag->equals("IM0A");
+ obj |= tag->equals("IM0B");
+ obj |= tag->equals("IM0C");
+ obj |= tag->equals("IM0D");
+ obj |= tag->equals("IM0E");
+ obj |= tag->equals("IM0F");
+
+ obj |= tag->equals("OI");
+ obj |= tag->equals("OBIM");
+
+ if (obj) {
+ if (!img.drawObject(block, _image))
+ _image.Create(5,5,false);
+ return;
+ }
+
+ bool bkg = false;
+ bkg |= tag->equals("BM");
+ bkg |= tag->equals("RMIM");
+ bkg |= tag->equals("IMAG");
+
+ if (bkg) {
+ if (!img.drawBG(block, _image))
+ _image.Create(5,5,false);
+
+ /*if (_boxesDisplayed)
+ g_scummex->boxesDraw(block);*/
+ return;
+ }
+
+ /*case BOXD:
+ case BX:
+ g_scummex->boxesDraw(_blockId);
+ break;
+
+ case FOBJ:
+ g_scummex->SmushFrameDraw(_blockId);
+ break;*/
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockInfoPresenter.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockInfoPresenter.h 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockInfoPresenter.h 2007-07-10 04:54:41 UTC (rev 28001)
@@ -6,6 +6,7 @@
//#include "scumm/ScummBlockPresenter.h"
#include "CoreInterfaces.h"
+#include "GUIInterfaces.h"
#include "scumm/resource.h"
@@ -18,34 +19,219 @@
struct FileNScummBlock;
-class ScummBlockInfoPresenter : public BObject {
- DECLARE_BOBJECT_CLASS(ScummBlockInfoPresenter, BObject)
+class ScummBlockPresenterBase : public BObject {
+ DECLARE_BOBJECT_CLASS(ScummBlockPresenterBase, BObject)
protected:
Slot< IProvider<FileNScummBlock> >* _blockSlot;
- Pin<IText>* _textPin;
- Pin<IUrl>* _urlPin;
bool _created;
- wxString _title, _text, _url;
+ wxString _title;
public:
ASSIGN_DESC(0,wxT("ScummObjects"), 1)
- PINS_DECL
SLOTS_DECL
- ScummBlockInfoPresenter()
+ ScummBlockPresenterBase()
: _created(false) {}
virtual void create();
+ //recieves stream positioned right after the header
+ virtual void inCreate(ScummBlock* block, Common::SeekableReadStream* stream) = 0;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class ScummBlockInfoPresenterBase : public ScummBlockPresenterBase {
+ DECLARE_BOBJECT_CLASS(ScummBlockInfoPresenterBase, ScummBlockPresenterBase)
+
+protected:
+ Pin<IText>* _textPin;
+
+ bool _monospace;
+ wxString _text;
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ PINS_DECL
+
+ ScummBlockInfoPresenterBase()
+ : _monospace(false) {}
+
+ virtual void inCreate(ScummBlock* block, Common::SeekableReadStream* stream);
+ virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream) = 0;
ITextImpl* getTextImpl();
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class ScummBlockImagePresenter : public ScummBlockPresenterBase {
+ DECLARE_BOBJECT_CLASS(ScummBlockImagePresenter, ScummBlockPresenterBase)
+
+protected:
+ Pin<IImage>* _imagePin;
+
+ wxImage _image;
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ PINS_DECL
+
+ virtual void inCreate(ScummBlock* block, Common::SeekableReadStream* stream);
+ virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream) = 0;
+ IImageImpl* getImageImpl();
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class ScummBlockInfoPresenter : public ScummBlockInfoPresenterBase {
+ DECLARE_BOBJECT_CLASS(ScummBlockInfoPresenter, ScummBlockInfoPresenterBase)
+
+protected:
+ Pin<IUrl>* _urlPin;
+
+ wxString _url;
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ PINS_DECL
+
+ virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream);
IUrlImpl* getUrlImpl();
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+enum EntryCountMode {
+ ENTRY_COUNT_MODE_BYTE,
+ ENTRY_COUNT_MODE_INT32BE,
+ ENTRY_COUNT_MODE_INT32LE,
+ ENTRY_COUNT_MODE_CUSTOM, //size of stream (minus header) / customEntrySize
+ ENTRY_COUNT_MODE_FIXED, //numEntries
+};
+
+class ScummEntryBlockPresenter : public ScummBlockInfoPresenterBase {
+ DECLARE_BOBJECT_CLASS(ScummEntryBlockPresenter, ScummBlockInfoPresenterBase)
+
+protected:
+ EntryCountMode _countMode;
+ uint32 _customEntrySize;
+ uint32 _numEntries;
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ ScummEntryBlockPresenter(EntryCountMode countMode = ENTRY_COUNT_MODE_BYTE, uint32 customEntrySize = -1, uint32 numEntries = -1)
+ : _countMode(countMode), _customEntrySize(customEntrySize), _numEntries(numEntries) {}
+
+ virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream);
+
+ virtual void determineNumEntries(ScummBlock* block, Common::SeekableReadStream* stream);
+ virtual wxString doPreEntries(ScummBlock* block, Common::SeekableReadStream* stream) { return wxT(""); }
+ virtual wxString doReadEntry(ScummBlock* block, uint32 idx, Common::SeekableReadStream* stream) { return wxT(""); }
+ virtual wxString doPostEntries(ScummBlock* block, Common::SeekableReadStream* stream) { return wxT(""); }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class ScummLOFFBlockPresenter : public ScummEntryBlockPresenter {
+ DECLARE_BOBJECT_CLASS(ScummLOFFBlockPresenter, ScummEntryBlockPresenter)
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ virtual wxString doPreEntries(ScummBlock* block, Common::SeekableReadStream* stream);
+ virtual wxString doReadEntry(ScummBlock* block, uint32 idx, Common::SeekableReadStream* stream);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class ScummOFFSBlockPresenter : public ScummEntryBlockPresenter {
+ DECLARE_BOBJECT_CLASS(ScummOFFSBlockPresenter, ScummEntryBlockPresenter)
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ ScummOFFSBlockPresenter()
+ : ScummEntryBlockPresenter(ENTRY_COUNT_MODE_CUSTOM, 4) {}
+
+ virtual wxString doPreEntries(ScummBlock* block, Common::SeekableReadStream* stream);
+ virtual wxString doReadEntry(ScummBlock* block, uint32 idx, Common::SeekableReadStream* stream);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class ScummRMHDBlockPresenter : public ScummBlockInfoPresenterBase {
+ DECLARE_BOBJECT_CLASS(ScummRMHDBlockPresenter, ScummBlockInfoPresenterBase)
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class ScummTRNSBlockPresenter : public ScummBlockInfoPresenterBase {
+ DECLARE_BOBJECT_CLASS(ScummTRNSBlockPresenter, ScummBlockInfoPresenterBase)
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class ScummScriptBlockPresenter : public ScummBlockInfoPresenterBase {
+ DECLARE_BOBJECT_CLASS(ScummScriptBlockPresenter, ScummBlockInfoPresenterBase)
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class ScummPALBlockPresenter : public ScummBlockImagePresenter {
+ DECLARE_BOBJECT_CLASS(ScummPALBlockPresenter, ScummBlockImagePresenter)
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class ScummIMGBlockPresenter : public ScummBlockImagePresenter {
+ DECLARE_BOBJECT_CLASS(ScummIMGBlockPresenter, ScummBlockImagePresenter)
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
} // namespace Browser
#endif //_SCUMM_BLOCK_INFO_PRESENTER_H_
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.cpp 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -23,6 +23,15 @@
SAFE_STATIC(scummBlockInfoPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummBlockInfoPresenter"), 1) )
SAFE_STATIC(blockyBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("BlockyBlockPresenter"), 1) )
+SAFE_STATIC(scummLOFFBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummLOFFBlockPresenter"), 1) )
+SAFE_STATIC(scummOFFSBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummOFFSBlockPresenter"), 1) )
+SAFE_STATIC(scummRMHDBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummRMHDBlockPresenter"), 1) )
+SAFE_STATIC(scummTRNSBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummTRNSBlockPresenter"), 1) )
+SAFE_STATIC(scummPALBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummPALBlockPresenter"), 1) )
+SAFE_STATIC(scummIMGBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummIMGBlockPresenter"), 1) )
+
+SAFE_STATIC(scummScriptBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummScriptBlockPresenter"), 1) )
+
//SAFE_STATIC(rootDirectoryFileType, RecognizedFileType,
// (PERFECT_MATCH, BGUID(wxT("CoreFileTypes"), wxT("Root Directory"), 1)) )
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.h 2007-07-10 01:26:12 UTC (rev 28000)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.h 2007-07-10 04:54:41 UTC (rev 28001)
@@ -25,6 +25,15 @@
SAFE_STATIC_DECL(scummBlockInfoPresenterGUID, BGUID)
SAFE_STATIC_DECL(blockyBlockPresenterGUID, BGUID)
+SAFE_STATIC_DECL(scummLOFFBlockPresenterGUID, BGUID)
+SAFE_STATIC_DECL(scummOFFSBlockPresenterGUID, BGUID)
+SAFE_STATIC_DECL(scummRMHDBlockPresenterGUID, BGUID)
+SAFE_STATIC_DECL(scummTRNSBlockPresenterGUID, BGUID)
+SAFE_STATIC_DECL(scummPALBlockPresenterGUID, BGUID)
+SAFE_STATIC_DECL(scummIMGBlockPresenterGUID, BGUID)
+
+SAFE_STATIC_DECL(scummScriptBlockPresenterGUID, BGUID)
+
//SAFE_STATIC_DECL(rootDirectoryFileType, RecognizedFileType)
/////////////////////////////////////////////////////////////////////////////
Added: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImage.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImage.cpp (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImage.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -0,0 +1,33 @@
+/////////////////////////////////////////////////////////////////////////////
+// ScummBlockPresenter.cpp
+
+#include "plugins_stdafx.h"
+
+#include "scumm/ScummBlockInfoPresenter.h"
+#include "scumm/ScummBlockPresenter.h"
+
+#include "CoreInterfaces.h"
+
+#include <iostream>
+
+#include "debugmem.h"
+
+namespace Browser {
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+//#include "ScummImageDetail.h"
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+/*void ScummRMIMBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummRMIMBlockPresenter::doCreate(): ") << std::endl;
+
+}*/
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+} // namespace Browser
Property changes on: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImage.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImageDetail.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImageDetail.h (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImageDetail.h 2007-07-10 04:54:41 UTC (rev 28001)
@@ -0,0 +1,1047 @@
+/* ScummEX - Viewer for Scumm data files
+* Copyright (C) 2003 Adrien Mercier
+* Copyright (C) 2003 The ScummVM project
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*
+* $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummex/trunk/image.h $
+* $Id: image.h 20579 2006-02-11 20:07:58Z fingolfin $
+*
+*/
+
+#include "common/common_stdafx.h"
+#include "scumm/codec37.h"
+#include "scumm/codec47.h"
+#include "scumm/bomp.h"
+
+using namespace Browser;
+
+struct rgbtable {
+ int red;
+ int green;
+ int blue;
+};
+
+struct points {
+ uint x;
+ uint y;
+};
+
+class Image {
+ struct rgbtable _rgbTable[256];
+ struct points _points[40][4];
+ uint32 _palette[256];
+ int _transp;
+ uint32 *_offsets;
+ int _width;
+ int _height;
+ byte _decomp_shr;
+ byte _decomp_mask;
+ int _vertStripNextInc;
+ Codec37Decoder _codec37;
+ Codec47Decoder _codec47;
+
+ void GetStrip(byte *dst, const byte *src, int numLinesToProcess);
+ void decodeCodec44(byte *dst, const byte *src, uint32 length);
+ void decodeCodec1(byte *dst, byte *src, int height);
+ void decodeStripEGA(byte *dst, const byte *src, int height);
+ void unkDecodeA(byte *dst, const byte *src, int height);
+ void unkDecodeB(byte *dst, const byte *src, int height);
+ void unkDecodeC(byte *dst, const byte *src, int height);
+ void unkDecode7(byte *dst, const byte *src, int height);
+ void unkDecode8(byte *dst, const byte *src, int height);
+ void unkDecode9(byte *dst, const byte *src, int height);
+ void unkDecode10(byte *dst, const byte *src, int height);
+ void unkDecode11(byte *dst, const byte *src, int height);
+ void decodeStrip3DO(byte *dst, const byte *src, int height, byte transpCheck);
+ void decodeStripHE(byte *dst, const byte *src, int height);
+
+public:
+ Image();
+ ~Image();
+ //void drawPalette(ScummBlock* block, wxImage& _image);
+ bool drawBG(ScummBlock* block, wxImage& _image);
+ bool drawObject(ScummBlock* block, wxImage& _image);
+ //void drawSmushFrame(ScummBlock* block, wxImage& _image);
+ //void drawBoxes(ScummBlock* block, wxImage& _image);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+Image::Image() {
+ _transp = 0;
+ _width = 0;
+ _height = 0;
+ _offsets = NULL;
+}
+
+Image::~Image() {
+ //if (_offsets)
+ //delete [] _offsets;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+bool Image::drawBG(ScummBlock* block, wxImage& _image) {
+ int version; // FIXME: initialize it?
+
+ ScummBlock* headerID = NULL;
+ if (block->getTag()->equals("BM")) {
+ version = 3;
+ headerID = block->findBlock("HD", -1);
+ } else {
+ ScummBlock* prev = block->getPrev();
+ if (prev && prev->getTag()->equals("IMHD")) {
+ version = 8;
+ headerID = prev;
+ } else {
+ version = 5;
+ headerID = block->findBlock("RMHD", -1);
+ }
+ }
+
+ if (!headerID) {
+ errout << wxT("Image::drawBG(): unknown image format") << std::endl;
+ return false;
+ }
+
+ ScummWidthHeightBlock* whBlock = dynamic_cast<ScummWidthHeightBlock*>(headerID);
+ if (!whBlock) {
+ errout << wxT("Image::drawBG(): unknown image format (wh)") << std::endl;
+ return false;
+ }
+
+ _width = whBlock->getWidth();
+ _height = whBlock->getHeight();
+
+ _image.Create(_width, _height, false);
+
+ ScummBlock* paletteID;
+ if (version > 4) {
+ paletteID = block->findBlock("CLUT", -1);
+ if (!paletteID)
+ paletteID = block->findBlock("APAL", -1);
+ if (!paletteID)
+ paletteID = block->findBlock("NPAL", -1);
+ } else {
+ _transp = 260;
+ paletteID = block->findBlock("PA", -1);
+ if (paletteID) {
+ version = 4;
+ } else {
+ version = 3;
+ }
+ }
+
+ if (version > 3) {
+ ;
+ } else {
+ paletteID = getEGAPalette();
+ }
+
+ ASSERT(paletteID);
+ ScummPALBlock* palBlock = dynamic_cast<ScummPALBlock*>(paletteID);
+ if (!palBlock) {
+ errout << wxT("Image::drawBG(): unknown image format (pal)") << std::endl;
+ return false;
+ }
+
+ int palCnt = palBlock->getColCount();
+ byte* palData = palBlock->getPAL();
+ for (int j = 0; j < palCnt; j++) {
+ _rgbTable[j].red = *palData++;
+ _rgbTable[j].green = *palData++;
+ _rgbTable[j].blue = *palData++;
+ }
+
+ ScummBlock* dataID;
+ if (version > 4) {
+ dataID = block->findChild("SMAP");
+ if (!dataID) {
+ errout << wxT("Image::drawBG(): unknown image format (smap)") << std::endl;
+ return false;
+ }
+ } else {
+ dataID = block;
+ }
+
+ ASSERT(dataID);
+ uint32 blockSize = dataID->blockSize();
+
+ if (block->getTag()->equals("IMAG")) {
+ version = 8;
+ dataID = dataID->findBlock("OFFS", +1);
+ ScummBlock* prev = dataID->getPrev();
+ ASSERT(prev);
+ blockSize = prev->blockSize() - 8;
+ }
+
+ uint32* _offsets = new uint32[_width/8];
+
+ Common::SeekableReadStream& _input = *dataID->getStream();
+ _input.seek(8, SEEK_SET);
+
+ if (version > 4) {
+ for (int x = 0; x < _width/8; x++)
+ _offsets[x] = _input.readUint32LE();
+ } else if (version == 4) {
+ for (int x = 0; x < _width/8; x++) {
+ _input.seek(2, SEEK_CUR);
+ _offsets[x] = _input.readUint16LE() + 6;
+ }
+ } else {
+ for (int x = 0; x < _width/8; x++)
+ _offsets[x] = _input.readUint16LE() + 6;
+ }
+
+ _input.seek(0, SEEK_SET);
+ byte *dstorg, *dst, *src;
+ dstorg = dst = (byte *)malloc(_width * _height);
+ src = (byte *)malloc(blockSize);
+ _input.read(src, blockSize);
+
+ for (int x = 0; x < _width/8; x++) {
+ if (version < 4)
+ decodeStripEGA(dst + (8 * x), src + _offsets[x], _height);
+ else
+ GetStrip(dst + (8 * x), src + _offsets[x], _height);
+ }
+ free(src);
+
+ byte* dstFinal;
+ /*if (_image->_scaleFactor > 1) {
+ dstorg = dstFinal = (byte *)malloc((_width * _image->_scaleFactor) * (_height * _image->_scaleFactor));
+ scale(_image->_scaleFactor, dst, _width, dstFinal, _width * _image->_scaleFactor, _width, _height);
+ free(dst);
+ } else*/ {
+ dstFinal = dst;
+ }
+
+ for (int y=0; y<_height /** _image->_scaleFactor*/; y++) {
+ for (int x=0; x<_width /** _image->_scaleFactor*/; x++) {
+ int color = *dstFinal++;
+ _image.SetRGB(x, y, _rgbTable[color].red, _rgbTable[color].green, _rgbTable[color].blue);
+ }
+ }
+
+ free(dstorg);
+
+ delete [] _offsets;
+ return true;
+}
+
+bool Image::drawObject(ScummBlock* block, wxImage& _image)
+{
+ int version = 5;
+
+ ScummBlock* headerID = NULL;
+ ScummBlock* paletteID = NULL;
+ if (block->getTag()->equals("OBIM")) {
+ headerID = block->findBlock("IMHD", +1);
+ } else if (block->getTag()->equals("OI")) {
+ version = 3;
+ headerID = block;
+ while (1) {
+ headerID = headerID->findBlock("OC", +1);
+ if (!headerID) {
+ errout << wxT("Image::drawObject(): unknown image format (OC)") << std::endl;
+ return false;
+ }
+ errout << wxT("Image::drawObject(): not implemented (OC)") << std::endl; //TODO: implement it
+ return false;
+ //if (headerID->_numFiles == block->_numFiles)
+ // break;
+ }
+ paletteID = block->findBlock("PA", -1);
+ if (paletteID) {
+ version = 4;
+ }
+ } else {
+ headerID = block->findBlock("IMHD", -1);
+ }
+
+ if (!headerID) {
+ errout << wxT("Image::drawObject(): unknown image format") << std::endl;
+ return false;
+ }
+
+ ScummWidthHeightBlock* whBlock = dynamic_cast<ScummWidthHeightBlock*>(headerID);
+ if (!whBlock) {
+ errout << wxT("Image::drawObject(): unknown image format (wh)") << std::endl;
+ return false;
+ }
+
+ _width = whBlock->getWidth();
+ _height = whBlock->getHeight();
+
+ _image.Create(_width, _height, false);
+
+
+ if (version > 4) {
+ paletteID = block->findBlock("CLUT", -1);
+ if (!paletteID)
+ paletteID = block->findBlock("APAL", -1);
+ if (!paletteID)
+ paletteID = block->findBlock("NPAL", -1);
+ }
+
+ if (version > 3) {
+ ;
+ } else {
+ paletteID = getEGAPalette();
+ }
+
+ ASSERT(paletteID);
+ ScummPALBlock* palBlock = dynamic_cast<ScummPALBlock*>(paletteID);
+ if (!palBlock) {
+ errout << wxT("Image::drawBG(): unknown image format (pal)") << std::endl;
+ return false;
+ }
+
+ int palCnt = palBlock->getColCount();
+ byte* palData = palBlock->getPAL();
+ for (int j = 0; j < palCnt; j++) {
+ _rgbTable[j].red = *palData++;
+ _rgbTable[j].green = *palData++;
+ _rgbTable[j].blue = *palData++;
+ }
+
+
+ ScummBlock* dataID;
+ uint32 plusOffs = 0;
+ if (version > 4) {
+ dataID = block->findChild("SMAP");
+ if (!dataID) {
+ errout << wxT("Image::drawObject(): unknown image format (smap)") << std::endl;
+ return false;
+ }
+ } else {
+ dataID = block;
+ plusOffs = 2;
+ }
+
+ ASSERT(dataID);
+ uint32 blockSize = dataID->blockSize();
+
+ Common::SeekableReadStream& _input = *dataID->getStream();
+ _input.seek(8 + plusOffs, SEEK_SET);
+
+ _offsets = new uint32[_width/8];
+
+ if (version > 4) {
+ for (int x = 0; x < _width/8; x++)
+ _offsets[x] = _input.readUint32LE();
+ } else if (version == 4) {
+ for (int x = 0; x < _width/8; x++) {
+ _input.seek(2, SEEK_CUR);
+ _offsets[x] = _input.readUint16LE() + 8;
+ }
+ } else {
+ for (int x = 0; x < _width/8; x++)
+ _offsets[x] = _input.readUint16LE() + 8;
+ }
+
+ byte *dstorg, *dst, *src;
+ _input.seek(0, SEEK_SET);
+ dstorg = dst = (byte *)malloc(_width * _height);
+ src = (byte *)malloc(blockSize);
+ _input.read(src, blockSize);
+
+ for (int x = 0; x < _width/8; x++) {
+ if (version > 3)
+ GetStrip(dst + (8 * x), src + _offsets[x], _height);
+ else
+ decodeStripEGA(dst + (8 * x), src + _offsets[x], _height);
+ }
+ free(src);
+
+ byte *dstFinal;
+ /*if (_image->_scaleFactor > 1) {
+ dstorg = dstFinal = (byte *)malloc((_width * _image->_scaleFactor) * (_height * _image->_scaleFactor));
+ scale(_image->_scaleFactor, dst, _width, dstFinal, _width * _image->_scaleFactor, _width, _height);
+ free(dst);
+ } else*/ {
+ dstFinal = dst;
+ }
+
+ for (int y=0; y<_height /** _image->_scaleFactor*/; y++) {
+ for (int x=0; x<_width /** _image->_scaleFactor*/; x++) {
+ int color = *dstFinal++;
+ _image.SetRGB(x, y, _rgbTable[color].red, _rgbTable[color].green, _rgbTable[color].blue);
+ }
+ }
+
+ free(dstorg);
+
+ delete [] _offsets;
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+void Image::GetStrip(byte *dst, const byte *src, int numLinesToProcess)
+{
+ byte code = *src++;
+ _decomp_shr = (code % 10);
+ _decomp_mask = 0xFF >> (8 - _decomp_shr);
+
+ _vertStripNextInc = _height * _width - 1;
+
+ switch (code)
+ {
+ case 1:
+ unkDecode7(dst, src, numLinesToProcess);
+ break;
+
+ case 2:
+ unkDecode8(dst, src, numLinesToProcess);
+ break;
+
+ case 3:
+ unkDecode9(dst, src, numLinesToProcess);
+ break;
+
+ case 4:
+ unkDecode10(dst, src, numLinesToProcess);
+ break;
+
+ case 7:
+ unkDecode11(dst, src, numLinesToProcess);
+ break;
+
+ // 8/9 used in 3do version of puttputt joins the parade maybe others
+ case 8:
+ decodeStrip3DO(dst, src, numLinesToProcess, true);
+ break;
+
+ case 9:
+ decodeStrip3DO(dst, src, numLinesToProcess, false);
+ break;
+
+ case 10:
+ decodeStripEGA(dst, src, numLinesToProcess);
+ break;
+
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ case 34:
+ case 35:
+ case 36:
+ case 37:
+ case 38:
+ unkDecodeC(dst, src, numLinesToProcess);
+ break;
+
+ case 24:
+ case 25:
+ case 26:
+ case 27:
+ case 28:
+ case 44:
+ case 45:
+ case 46:
+ case 47:
+ case 48:
+ unkDecodeB(dst, src, numLinesToProcess);
+ break;
+
+ case 64:
+ case 65:
+ case 66:
+ case 67:
+ case 68:
+ case 84:
+ case 85:
+ case 86:
+ case 87:
+ case 88:
+ case 104:
+ case 105:
+ case 106:
+ case 107:
+ case 108:
+ case 124:
+ case 125:
+ case 126:
+ case 127:
+ case 128:
+ unkDecodeA(dst, src, numLinesToProcess);
+ break;
+
+ case 134:
+ case 135:
+ case 136:
+ case 137:
+ case 138:
+ decodeStripHE(dst, src, numLinesToProcess);
+ break;
+
+ case 144:
+ case 145:
+ case 146:
+ case 147:
+ case 148:
+ decodeStripHE(dst, src, numLinesToProcess);
+ break;
+
+ default:
+ printf("Unknown codec: %d!\n", code);
+ }
+
+}
+
+void Image::decodeCodec44(byte *dst, const byte *src, uint32 length) {
+ byte val;
+ uint16 size_line, num;
+
+ do {
+ size_line = READ_LE_UINT16(src);
+ src += 2;
+ length -= 2;
+
+ while (size_line != 0) {
+ num = *src++;
+ val = *src++;
+ memset(dst, val, num);
+ dst += num;
+ length -= 2;
+ size_line -= 2;
+ if (size_line != 0) {
+ num = READ_LE_UINT16(src) + 1;
+ src += 2;
+ memcpy(dst, src, num);
+ dst += num;
+ src += num;
+ length -= num + 2;
+ size_line -= num + 2;
+ }
+ }
+ dst--;
+
+ } while (length > 1);
+}
+
+void Image::decodeCodec1(byte *dst, byte *src, int height) {
+ byte val, code;
+ int32 length;
+ int h = height, size_line;
+
+ for (h = 0; h < height; h++) {
+ size_line = READ_LE_UINT16(src);
+ src += 2;
+ while (size_line > 0) {
+ code = *src++;
+ size_line--;
+ length = (code >> 1) + 1;
+ if (code & 1) {
+ val = *src++;
+ size_line--;
+ if (val)
+ memset(dst, val, length);
+ dst += length;
+ } else {
+ size_line -= length;
+ while (length--) {
+ val = *src++;
+ if (val)
+ *dst = val;
+ dst++;
+ }
+ }
+ }
+ }
+}
+
+void Image::decodeStripEGA(byte *dst, const byte *src, int height) {
+ byte color = 0;
+ int run = 0, x = 0, y = 0, z;
+
+ while (x < 8) {
+ color = *src++;
+
+ if (color & 0x80) {
+ run = color & 0x3f;
+
+ if (color & 0x40) {
+ color = *src++;
+
+ if (run == 0) {
+ run = *src++;
+ }
+ for (z = 0; z < run; z++) {
+ *(dst + y * _width + x) = (z&1) ? color & 0xf : color >> 4;
+
+ y++;
+ if (y >= height) {
+ y = 0;
+ x++;
+ }
+ }
+ } else {
+ if (run == 0) {
+ run = *src++;
+ }
+
+ for (z = 0; z < run; z++) {
+ *(dst + y * _width + x) = *(dst + y * _width + x - 1);
+
+ y++;
+ if (y >= height) {
+ y = 0;
+ x++;
+ }
+ }
+ }
+ } else {
+ run = color >> 4;
+ if (run == 0) {
+ run = *src++;
+ }
+
+ for (z = 0; z < run; z++) {
+ *(dst + y * _width + x) = color & 0xf;
+
+ y++;
+ if (y >= height) {
+ y = 0;
+ x++;
+ }
+ }
+ }
+ }
+}
+
+#define READ_BIT (cl--, bit = bits&1, bits>>=1,bit)
+#define FILL_BITS do { \
+ if (cl <= 8) { \
+ bits |= (*src++ << cl); \
+ cl += 8; \
+ } \
+ } while (0)
+
+void Image::unkDecodeA(byte *dst, const byte *src, int height) {
+ byte color = *src++;
+ uint bits = *src++;
+ byte cl = 8;
+ byte bit;
+ byte incm, reps;
+
+ do {
+ int x = 8;
+ do {
+ FILL_BITS;
+ *dst++ = color;
+
+ againPos:
+ if (!READ_BIT) {
+ } else if (!READ_BIT) {
+ FILL_BITS;
+ color = bits & _decomp_mask;
+ bits >>= _decomp_shr;
+ cl -= _decomp_shr;
+ } else {
+ incm = (bits & 7) - 4;
+ cl -= 3;
+ bits >>= 3;
+ if (incm) {
+ color = (byte)((color+incm)&0xFF);
+ } else {
+ FILL_BITS;
+ reps = bits & 0xFF;
+ do {
+ if (!--x) {
+ x = 8;
+ dst += _width - 8;
+ if (!--height)
+ return;
+ }
+ *dst++ = color;
+ } while (--reps);
+ bits >>= 8;
+ bits |= (*src++) << (cl - 8);
+ goto againPos;
+ }
+ }
+ } while (--x);
+ dst += _width - 8;
+ } while (--height);
+}
+
+void Image::unkDecodeB(byte *dst, const byte *src, int height) {
+ byte color = *src++;
+ uint bits = *src++;
+ byte cl = 8;
+ byte bit;
+ int8 inc = -1;
+
+ do {
+ int x = 8;
+ do {
+ FILL_BITS;
+ *dst++ = color;
+ if (!READ_BIT) {
+ } else if (!READ_BIT) {
+ FILL_BITS;
+ color = bits & _decomp_mask;
+ bits >>= _decomp_shr;
+ cl -= _decomp_shr;
+ inc = -1;
+ } else if (!READ_BIT) {
+ color += inc;
+ } else {
+ inc = -inc;
+ color += inc;
+ }
+ } while (--x);
+ dst += _width - 8;
+ } while (--height);
+}
+
+void Image::unkDecodeC(byte *dst, const byte *src, int height) {
+ byte color = *src++;
+ uint bits = *src++;
+ byte cl = 8;
+ byte bit;
+ int8 inc = -1;
+
+ int x = 8;
+ do {
+ int h = height;
+ do {
+ FILL_BITS;
+ *dst = color;
+ dst += _width;
+ if (!READ_BIT) {
+ } else if (!READ_BIT) {
+ FILL_BITS;
+ color = bits & _decomp_mask;
+ bits >>= _decomp_shr;
+ cl -= _decomp_shr;
+ inc = -1;
+ } else if (!READ_BIT) {
+ color += inc;
+ } else {
+ inc = -inc;
+ color += inc;
+ }
+ } while (--h);
+ dst -= _vertStripNextInc;
+ } while (--x);
+}
+
+void Image::decodeStrip3DO(byte *dst, const byte *src, int height, byte transpCheck) {
+ int destbytes, olddestbytes2, olddestbytes1;
+ byte color;
+ int data;
+
+ olddestbytes1 = 0;
+
+ destbytes = height << 3;
+
+ if (!height)
+ return;
+
+ do {
+ data = *src;
+ src++;
+
+ if (!(data & 1)) {
+ data >>= 1;
+ data++;
+ destbytes -= data;
+ if (destbytes < 0)
+ data += destbytes;
+
+ olddestbytes2 = destbytes;
+ destbytes = olddestbytes1;
+
+ for (; data > 0; data--, src++, dst++) {
+ //if (*src != _transparentColor || !transpCheck)
+ *dst = *src;
+
+ destbytes++;
+ if (!(destbytes & 7))
+ dst += 312;
+ }
+
+ olddestbytes1 = destbytes;
+ if (olddestbytes2 > 0) {
+ destbytes = olddestbytes2;
+ }
+ } else {
+ data >>= 1;
+ color = *src;
+ src++;
+
+ data++;
+ destbytes -= data;
+ if (destbytes < 0)
+ data += destbytes;
+
+ olddestbytes2 = destbytes;
+ destbytes = olddestbytes1;
+
+ for (; data > 0; data--, dst++) {
+ //if (color != _transparentColor || !transpCheck)
+ *dst = color;
+ destbytes++;
+ if (!(destbytes & 7))
+ dst += 312;
+ }
+ olddestbytes1 = destbytes;
+ if (olddestbytes2 > 0) {
+ destbytes = olddestbytes2;
+ }
+ }
+ } while (olddestbytes2 > 0);
+}
+
+
+void Image::decodeStripHE(byte *dst, const byte *src, int height) {
+ uint32 color, dataBit, data, shift, iteration;
+
+ color = *src;
+ src++;
+ data = (src[2] << 16) + (src[1] << 8) + src[0];
+ src += 3;
+ shift = 24;
+
+ while (height) {
+ for (iteration = 0; iteration < 8; iteration++) {
+ *dst = color;
+ dst++;
+ if (shift <= 16) {
+ data |= *src << shift;
+ src++;
+ shift += 8;
+ data |= *src << shift;
+ src++;
+ shift += 8;
+ }
+
+ dataBit = data & 1;
+ shift--;
+ data >>= 1;
+ if (dataBit) {
+ dataBit = data & 1;
+ shift--;
+ data >>= 1;
+ if (!dataBit) {
+ color = _decomp_mask & data;
+ shift -= _decomp_shr;
+ data >>= _decomp_shr;
+ } else {
+ dataBit = data & 7;
+ shift -= 3;
+ data >>= 3;
+ if (dataBit >= 4)
+ color += dataBit - 3;
+ else
+ color += dataBit - 4;
+ }
+ }
+ }
+ dst += 312;
+ height--;
+ }
+}
+
+#undef READ_BIT
+#undef FILL_BITS
+
+/* Ender - Zak256/Indy256 decoders */
+#define READ_256BIT \
+ do { \
+ if ((mask <<= 1) == 256) { \
+ buffer = *src++; \
+ mask = 1; \
+ } \
+ bits = ((buffer & mask) != 0); \
+ } while (0)
+
+#define NEXT_ROW \
+ do { \
+ dst += _width; \
+ if (--h == 0) { \
+ if (!--x) \
+ return; \
+ dst -= _vertStripNextInc; \
+ h = height; \
+ } \
+ } while (0)
+
+void Image::unkDecode7(byte *dst, const byte *src, int height) {
+ uint h = height;
+
+ //if (_vm->_features & GF_OLD256) {
+ int x = 8;
+ for (;;) {
+ *dst = *src++;
+ NEXT_ROW;
+ }
+ return;
+ //}
+
+ do {
+#if defined(SCUMM_NEED_ALIGNMENT)
+ memcpy(dst, src, 8);
+#else
+ ((uint32 *)dst)[0] = ((const uint32 *)src)[0];
+ ((uint32 *)dst)[1] = ((const uint32 *)src)[1];
+#endif
+ dst += _width;
+ src += 8;
+ } while (--height);
+}
+
+void Image::unkDecode8(byte *dst, const byte *src, int height) {
+ uint h = height;
+
+ int x = 8;
+ for (;;) {
+ uint run = (*src++) + 1;
+ byte color = *src++;
+
+ do {
+ *dst = color;
+ NEXT_ROW;
+ } while (--run);
+ }
+}
+
+void Image::unkDecode9(byte *dst, const byte *src, int height) {
+ unsigned char c, bits, color, run;
+ int i, j;
+ uint buffer = 0, mask = 128;
+ int h = height;
+ i = j = run = 0;
+
+ int x = 8;
+ for (;;) {
+ c = 0;
+ for (i = 0; i < 4; i++) {
+ READ_256BIT;
+ c += (bits << i);
+ }
+
+ switch (c >> 2) {
+ case 0:
+ color = 0;
+ for (i = 0; i < 4; i++) {
+ READ_256BIT;
+ color += bits << i;
+ }
+ for (i = 0; i < ((c & 3) + 2); i++) {
+ *dst = (run * 16 + color);
+ NEXT_ROW;
+ }
+ break;
+
+ case 1:
+ for (i = 0; i < ((c & 3) + 1); i++) {
+ color = 0;
+ for (j = 0; j < 4; j++) {
+ READ_256BIT;
+ color += bits << j;
+ }
+ *dst = (run * 16 + color);
+ NEXT_ROW;
+ }
+ break;
+
+ case 2:
+ run = 0;
+ for (i = 0; i < 4; i++) {
+ READ_256BIT;
+ run += bits << i;
+ }
+ break;
+ }
+ }
+}
+
+void Image::unkDecode10(byte *dst, const byte *src, int height) {
+ int i;
+ unsigned char local_palette[256], numcolors = *src++;
+ uint h = height;
+
+ for (i = 0; i < numcolors; i++)
+ local_palette[i] = *src++;
+
+ int x = 8;
+
+ for (;;) {
+ byte color = *src++;
+ if (color < numcolors) {
+ *dst = local_palette[color];
+ NEXT_ROW;
+ } else {
+ uint run = color - numcolors + 1;
+ color = *src++;
+ do {
+ *dst = color;
+ NEXT_ROW;
+ } while (--run);
+ }
+ }
+}
+
+void Image::unkDecode11(byte *dst, const byte *src, int height) {
+ int bits, i;
+ uint buffer = 0, mask = 128;
+ unsigned char inc = 1, color = *src++;
+ int x = 8;
+ do {
+ int h = height;
+ do {
+ *dst = color;
+ dst += _width;
+ for (i = 0; i < 3; i++) {
+ READ_256BIT;
+ if (!bits)
+ break;
+ }
+ switch (i) {
+ case 1:
+ inc = -inc;
+ color -= inc;
+ break;
+
+ case 2:
+ color -= inc;
+ break;
+
+ case 3:
+ color = 0;
+ inc = 1;
+ for (i = 0; i < 8; i++) {
+ READ_256BIT;
+ color += bits << i;
+ }
+ break;
+ }
+ } while (--h);
+ dst -= _vertStripNextInc;
+ } while (--x);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
Property changes on: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImageDetail.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/bomp.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/bomp.cpp (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/bomp.cpp 2007-07-10 04:54:41 UTC (rev 28001)
@@ -0,0 +1,396 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2003 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummex/trunk/bomp.cpp $
+ * $Id: bomp.cpp 20579 2006-02-11 20:07:58Z fingolfin $
+ *
+ */
+
+#include "plugins_stdafx.h"
+#include "common/common_stdafx.h"
+
+#include "scumm/bomp.h"
+
+#include "debugmem.h"
+
+
+byte defaultScaleTable[768];
+byte revBitMask[8];
+
+//static void bompScaleFuncX(byte *line_buffer, byte *scaling_x_ptr, byte skip, int32 size);
+
+static void bompApplyShadow0(const byte *line_buffer, byte *dst, int32 size, byte transparency);
+static void bompApplyShadow1(const byte *shadowPalette, const byte *line_buffer, byte *dst, int32 size, byte transparency);
+static void bompApplyShadow3(const byte *shadowPalette, const byte *line_buffer, byte *dst, int32 size, byte transparency);
+//static void bompApplyActorPalette(byte *actorPalette, byte *line_buffer, int32 size);
+
+
+
+void decompressBomp(byte *dst, const byte *src, int w, int h) {
+ assert(w > 0);
+ assert(h > 0);
+
+ do {
+ bompDecodeLine(dst, src + 2, w);
+ src += READ_LE_UINT16(src) + 2;
+ dst += w;
+ } while (--h);
+}
+
+void bompDecodeLine(byte *dst, const byte *src, int size) {
+ assert(size > 0);
+
+ int len, num;
+ byte code, color;
+
+ len = size;
+ while (len) {
+ code = *src++;
+ num = (code >> 1) + 1;
+ if (num > len)
+ num = len;
+ len -= num;
+ if (code & 1) {
+ color = *src++;
+ memset(dst, color, num);
+ } else {
+ memcpy(dst, src, num);
+ src += num;
+ }
+ dst += num;
+ }
+}
+
+void bompDecodeLineReverse(byte *dst, const byte *src, int size) {
+ assert(size > 0);
+
+ dst += size;
+
+ int len, num;
+ byte code, color;
+
+ len = size;
+ while (len) {
+ code = *src++;
+ num = (code >> 1) + 1;
+ if (num > len)
+ num = len;
+ len -= num;
+ dst -= num;
+ if (code & 1) {
+ color = *src++;
+ memset(dst, color, num);
+ } else {
+ memcpy(dst, src, num);
+ src += num;
+ }
+ }
+}
+
+void bompApplyMask(byte *line_buffer, byte *mask, byte maskbit, int32 size, byte transparency) {
+ while (1) {
+ do {
+ if (size-- == 0)
+ return;
+ if (*mask & maskbit) {
+ *line_buffer = transparency;
+ }
+ line_buffer++;
+ maskbit >>= 1;
+ } while (maskbit);
+ mask++;
+ maskbit = 128;
+ }
+}
+
+void bompApplyShadow(int shadowMode, const byte *shadowPalette, const byte *line_buffer, byte *dst, int32 size, byte transparency) {
+ assert(size > 0);
+ switch(shadowMode) {
+ case 0:
+ bompApplyShadow0(line_buffer, dst, size, transparency);
+ break;
+ case 1:
+ bompApplyShadow1(shadowPalette, line_buffer, dst, size, transparency);
+ break;
+ case 3:
+ bompApplyShadow3(shadowPalette, line_buffer, dst, size, transparency);
+ break;
+ default:
+ printf("Unknown shadow mode %d", shadowMode);
+ }
+}
+void bompApplyShadow0(const byte *line_buffer, byte *dst, int32 size, byte transparency) {
+ while (size-- > 0) {
+ byte tmp = *line_buffer++;
+ if (tmp != transparency) {
+ *dst = tmp;
+ }
+ dst++;
+ }
+}
+
+void bompApplyShadow1(const byte *shadowPalette, const byte *line_buffer, byte *dst, int32 size, byte transparency) {
+ while (size-- > 0) {
+ byte tmp = *line_buffer++;
+ if (tmp != transparency) {
+ if (tmp == 13) {
+ tmp = shadowPalette[*dst];
+ }
+ *dst = tmp;
+ }
+ dst++;
+ }
+}
+
+void bompApplyShadow3(const byte *shadowPalette, const byte *line_buffer, byte *dst, int32 size, byte transparency) {
+ while (size-- > 0) {
+ byte tmp = *line_buffer++;
+ if (tmp != transparency) {
+ if (tmp < 8) {
+ tmp = shadowPalette[*dst + (tmp << 8)];
+ }
+ *dst = tmp;
+ }
+ dst++;
+ }
+}
+
+/* FIXME can this be deleted?
+void bompApplyActorPalette(byte *actorPalette, byte *line_buffer, int32 size) {
+ if (actorPalette != 0) {
+ actorPalette[255] = 255;
+ while (size-- > 0) {
+ *line_buffer = actorPalette[*line_buffer];
+ line_buffer++;
+ }
+ }
+}
+
+void bompScaleFuncX(byte *line_buffer, byte *scaling_x_ptr, byte skip, int32 size) {
+ byte *line_ptr1 = line_buffer;
+ byte *line_ptr2 = line_buffer;
+
+ byte tmp = *scaling_x_ptr++;
+
+ while (size--) {
+ if ((skip & tmp) == 0) {
+ *line_ptr1++ = *line_ptr2;
+ }
+ line_ptr2++;
+ skip >>= 1;
+ if (skip == 0) {
+ skip = 128;
+ tmp = *scaling_x_ptr++;
+ }
+ }
+}
+*/
+
+/*void Scumm::drawBomp(const BompDrawData &bd, bool mirror) {
+ const byte *src;
+ byte *dst;
+ byte maskbit;
+ byte *mask = 0;
+ byte *charset_mask;
+ int clip_left, clip_right, clip_top, clip_bottom;
+ byte *scalingYPtr = bd.scalingYPtr;
+ byte skip_y_bits = 0x80;
+ byte skip_y_new = 0;
+ byte tmp;
+
+
+ if (bd.x < 0) {
+ clip_left = -bd.x;
+ } else {
+ clip_left = 0;
+ }
+
+ if (bd.y < 0) {
+ clip_top = -bd.y;
+ } else {
+ clip_top = 0;
+ }
+
+ clip_right = bd.srcwidth;
+ if (clip_right > bd.outwidth - bd.x) {
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list