aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorMatthew Hoops2007-09-11 21:39:16 +0000
committerMatthew Hoops2007-09-11 21:39:16 +0000
commitf4414ac084f08ed4e1e8b2b4cbd649588ef33820 (patch)
tree190b85afd687f56cf7576e70d556304588b44f22 /engines/agi
parentbe013e6c45c7547ac8c57d9061293eb5e82602e2 (diff)
downloadscummvm-rg350-f4414ac084f08ed4e1e8b2b4cbd649588ef33820.tar.gz
scummvm-rg350-f4414ac084f08ed4e1e8b2b4cbd649588ef33820.tar.bz2
scummvm-rg350-f4414ac084f08ed4e1e8b2b4cbd649588ef33820.zip
remove the rest of the PreAGI loader
svn-id: r28895
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/agi.h32
-rw-r--r--engines/agi/loader_preagi.cpp224
-rw-r--r--engines/agi/module.mk1
-rw-r--r--engines/agi/preagi.cpp20
-rw-r--r--engines/agi/preagi_mickey.cpp27
5 files changed, 24 insertions, 280 deletions
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 6a83670619..c9fd0d59a9 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -556,33 +556,6 @@ public:
virtual int getIntVersion() = 0;
};
-class AgiLoader_preagi : public AgiLoader {
-private:
- int _intVersion;
- PreAgiEngine *_vm;
-
- int loadDir(AgiDir *agid, Common::File *fp, uint32 offs, uint32 len);
- uint8 *loadVolRes(AgiDir *agid);
-
-public:
-
- AgiLoader_preagi(PreAgiEngine *vm) {
- _vm = vm;
- _intVersion = 0;
- }
-
- virtual int init();
- virtual int deinit();
- virtual int detectGame();
- virtual int loadResource(int, int);
- virtual int unloadResource(int, int);
- virtual int loadObjects(const char *);
- virtual int loadWords(const char *);
- virtual int version();
- virtual void setIntVersion(int);
- virtual int getIntVersion();
-};
-
class AgiLoader_v2 : public AgiLoader {
private:
int _intVersion;
@@ -677,7 +650,6 @@ public:
AgiDebug _debug;
AgiGame _game;
Common::RandomSource *_rnd;
- AgiLoader *_loader; /* loader */
virtual void agiTimerLow() = 0;
virtual int agiGetKeypressLow() = 0;
@@ -772,6 +744,7 @@ public:
GfxMgr *_gfx;
SoundMgr *_sound;
PictureMgr *_picture;
+ AgiLoader *_loader; /* loader */
void clearImageStack();
void recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
@@ -974,9 +947,6 @@ public:
int agiGetKeypressLow() { return 0; }
int agiIsKeypressLow() { return 0; }
- int preAgiLoadResource(int r, int n);
- int preAgiUnloadResource(int r, int n);
-
PreAgiEngine(OSystem *syst);
virtual ~PreAgiEngine();
int getGameId() {
diff --git a/engines/agi/loader_preagi.cpp b/engines/agi/loader_preagi.cpp
deleted file mode 100644
index 4e0b3e06a7..0000000000
--- a/engines/agi/loader_preagi.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/stdafx.h"
-
-#include "agi/agi.h"
-#include "agi/lzw.h"
-#include "agi/preagi_mickey.h"
-
-#include "common/config-manager.h"
-#include "common/fs.h"
-
-namespace Agi {
-
-int AgiLoader_preagi::version() {
- return 0;
-}
-
-void AgiLoader_preagi::setIntVersion(int ver) {
- _intVersion = ver;
-}
-
-int AgiLoader_preagi::getIntVersion() {
- return _intVersion;
-}
-
-int AgiLoader_preagi::detectGame() {
- // TODO: Only Mickey/Winnie are detected for now
- if (!(Common::File::exists("1.pic") || Common::File::exists("title.pic")))
- return errInvalidAGIFile;
-
- _intVersion = 0x0000;
- return errOK;
-}
-
-int AgiLoader_preagi::loadDir(struct AgiDir *agid, Common::File *fp,
- uint32 offs, uint32 len) {
- int ec = errOK;
-/* uint8 *mem;
- unsigned int i;
-
- fp->seek(offs, SEEK_SET);
- if ((mem = (uint8 *)malloc(len + 32)) != NULL) {
- fp->read(mem, len);
-
- // set all directory resources to gone
- for (i = 0; i < MAX_DIRS; i++) {
- agid[i].volume = 0xff;
- agid[i].offset = _EMPTY;
- }
-
- // build directory entries
- for (i = 0; i < len; i += 3) {
- agid[i / 3].volume = *(mem + i) >> 4;
- agid[i / 3].offset = READ_BE_UINT24(mem + i) & (uint32) _EMPTY;
- }
-
- free(mem);
- } else {
- ec = errNotEnoughMemory;
- }
-*/
- return ec;
-}
-
-int AgiLoader_preagi::init() {
- int ec = errOK;
- //int i;
- //uint16 xd[4];
- Common::File fp;
- Common::String path;
-
- // TODO : load all preagi resources here
-
- return ec;
-}
-
-int AgiLoader_preagi::deinit() {
- int ec = errOK;
- return ec;
-}
-
-int AgiLoader_preagi::unloadResource(int t, int n) {
- switch (t) {
- case rPICTURE:
- _vm->_picture->unloadPicture(n);
- break;
- case rVIEW:
- //_vm->unloadView(n);
- break;
- case rSOUND:
- //_vm->_sound->unloadSound(n);
- break;
- }
-
- return errOK;
-}
-
-/*
- * This function does noting but load a raw resource into memory.
- * If further decoding is required, it must be done by another
- * routine.
- *
- * NULL is returned if unsucsessful.
- */
-uint8 *AgiLoader_preagi::loadVolRes(AgiDir *agid) {
-
- return NULL;
-}
-
-/*
- * Loads a resource into memory, a raw resource is loaded in
- * with above routine, then further decoded here.
- */
-int AgiLoader_preagi::loadResource(int t, int n) {
- int ec = errOK;
- uint8 *data = NULL;
- char szFile[255] = {0};
- Common::File infile;
-
- if (n > MAX_DIRS)
- return errBadResource;
-
- switch (t) {
- case rPICTURE:
- /* if picture is currently NOT loaded *OR* cacheing is off,
- * unload the resource (caching==off) and reload it
- */
- if (~_vm->_game.dirPic[n].flags & RES_LOADED) {
- unloadResource(rPICTURE, n);
-
- data = new uint8[4096];
-
- sprintf(szFile, IDS_MSA_PATH_PIC, n);
- if (!infile.open(szFile))
- return errBadResource;
- infile.read(data, infile.size());
-
- if (data != NULL) {
- _vm->_game.pictures[n].rdata = data;
- _vm->_game.dirPic[n].len = infile.size();
- _vm->_game.dirPic[n].flags |= RES_LOADED;
- } else {
- ec = errBadResource;
- }
-
- infile.close();
- }
- break;
- case rSOUND:
- /*
- if (_vm->_game.dirSound[n].flags & RES_LOADED)
- break;
-
- data = loadVolRes(&_vm->_game.dirSound[n]);
- if (data != NULL) {
- // Freeing of the raw resource from memory is delegated to the createFromRawResource-function
- _vm->_game.sounds[n] = AgiSound::createFromRawResource(data, _vm->_game.dirSound[n].len, n, *_vm->_sound);
- _vm->_game.dirSound[n].flags |= RES_LOADED;
- } else {
- ec = errBadResource;
- }
- */
- break;
- case rVIEW:
- data = new uint8[4096];
-
- sprintf(szFile, IDS_MSA_PATH_OBJ, IDS_MSA_NAME_OBJ[n]);
-
- if (!infile.open(szFile))
- return errBadResource;
- infile.read(data, infile.size());
-
- if (data != NULL) {
- _vm->_game.pictures[n].rdata = data;
- _vm->_game.dirPic[n].len = infile.size();
- _vm->_game.dirPic[n].flags |= RES_LOADED;
- } else {
- ec = errBadResource;
- }
-
- infile.close();
- break;
- default:
- ec = errBadResource;
- break;
- }
-
- return ec;
-}
-
-int AgiLoader_preagi::loadObjects(const char *fname) {
- return 0;
- //return _vm->loadObjects(fname);
-}
-
-int AgiLoader_preagi::loadWords(const char *fname) {
- return 0;
- //return _vm->loadWords(fname);
-}
-
-} // End of namespace Agi
diff --git a/engines/agi/module.mk b/engines/agi/module.mk
index eae3ea1d64..4da361734d 100644
--- a/engines/agi/module.mk
+++ b/engines/agi/module.mk
@@ -11,7 +11,6 @@ MODULE_OBJS = \
id.o \
inv.o \
keyboard.o \
- loader_preagi.o \
loader_v2.o \
loader_v3.o \
logic.o \
diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp
index 67632bcd84..33a136e6a6 100644
--- a/engines/agi/preagi.cpp
+++ b/engines/agi/preagi.cpp
@@ -178,15 +178,6 @@ void PreAgiEngine::initialize() {
debugC(2, kDebugLevelMain, "Detect game");
- _loader = new AgiLoader_preagi(this);
-
- if (_loader->detectGame() == errOK) {
- _game.state = STATE_LOADED;
- debugC(2, kDebugLevelMain, "game loaded");
- } else {
- report("Could not open PreAGI game");
- }
-
/* clear all resources and events */
for (int i = 0; i < MAX_DIRS; i++) {
memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
@@ -195,9 +186,6 @@ void PreAgiEngine::initialize() {
memset(&_game.dirSound[i], 0, sizeof(struct AgiDir));
}
- // load resources
- _loader->init();
-
debugC(2, kDebugLevelMain, "Init sound");
}
@@ -252,12 +240,4 @@ int PreAgiEngine::go() {
return 0;
}
-int PreAgiEngine::preAgiLoadResource(int r, int n) {
- return _loader->loadResource(r, n);
-}
-
-int PreAgiEngine::preAgiUnloadResource(int r, int n) {
- return _loader->unloadResource(r, n);
-}
-
} // End of namespace Agi
diff --git a/engines/agi/preagi_mickey.cpp b/engines/agi/preagi_mickey.cpp
index 44795b9e40..20679fdee2 100644
--- a/engines/agi/preagi_mickey.cpp
+++ b/engines/agi/preagi_mickey.cpp
@@ -682,21 +682,40 @@ void Mickey::debug() {
// Graphics
void Mickey::drawObj(ENUM_MSA_OBJECT iObj, int x0, int y0) {
- _vm->preAgiLoadResource(rVIEW, iObj);
+ uint8* buffer = new uint8[4096];
+ char szFile[255] = {0};
+ sprintf(szFile, IDS_MSA_PATH_OBJ, IDS_MSA_NAME_OBJ[iObj]);
+
+ Common::File file;
+ if (!file.open(szFile))
+ return;
+ uint32 size = file.size();
+ file.read(buffer, size);
+ file.close();
if (iObj == IDI_MSA_OBJECT_CRYSTAL)
_vm->_picture->setPictureFlags(kPicFStep);
_vm->_picture->setOffset(x0, y0);
- _vm->_picture->decodePicture(iObj, false, false, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
+ _vm->_picture->decodePicture(buffer, size, false, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
_vm->_picture->setOffset(0, 0);
_vm->_picture->showPic(10, 0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
}
void Mickey::drawPic(int iPic) {
- _vm->preAgiLoadResource(rPICTURE, iPic);
+ uint8* buffer = new uint8[4096];
+ char szFile[255] = {0};
+ sprintf(szFile, IDS_MSA_PATH_PIC, iPic);
+
+ Common::File file;
+ if (!file.open(szFile))
+ return;
+ uint32 size = file.size();
+ file.read(buffer, size);
+ file.close();
+
// Note that decodePicture clears the screen
- _vm->_picture->decodePicture(iPic, true, false, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
+ _vm->_picture->decodePicture(buffer, size, true, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
_vm->_picture->showPic(10, 0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
//_vm->_gfx->doUpdate();
//_vm->_system->updateScreen(); // TODO: this should go in the game's main loop