aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/agi.h10
-rw-r--r--engines/agi/loader_preagi.cpp80
-rw-r--r--engines/agi/picture.cpp31
-rw-r--r--engines/agi/picture.h1
-rw-r--r--engines/agi/preagi.cpp8
-rw-r--r--engines/agi/preagi_winnie.cpp16
6 files changed, 41 insertions, 105 deletions
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index a17e426cf1..6a83670619 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -548,8 +548,6 @@ public:
virtual int deinit() = 0;
virtual int detectGame() = 0;
virtual int loadResource(int, int) = 0;
- virtual int loadResource(int, const char*) = 0;
- virtual int loadResource(int, byte*) = 0;
virtual int unloadResource(int, int) = 0;
virtual int loadObjects(const char *) = 0;
virtual int loadWords(const char *) = 0;
@@ -577,8 +575,6 @@ public:
virtual int deinit();
virtual int detectGame();
virtual int loadResource(int, int);
- virtual int loadResource(int, const char*);
- virtual int loadResource(int, byte*);
virtual int unloadResource(int, int);
virtual int loadObjects(const char *);
virtual int loadWords(const char *);
@@ -606,8 +602,6 @@ public:
virtual int deinit();
virtual int detectGame();
virtual int loadResource(int, int);
- virtual int loadResource(int, const char*) { return 0; }
- virtual int loadResource(int, byte*) { return 0; }
virtual int unloadResource(int, int);
virtual int loadObjects(const char *);
virtual int loadWords(const char *);
@@ -635,8 +629,6 @@ public:
virtual int deinit();
virtual int detectGame();
virtual int loadResource(int, int);
- virtual int loadResource(int, const char*) { return 0; }
- virtual int loadResource(int, byte*) { return 0; }
virtual int unloadResource(int, int);
virtual int loadObjects(const char *);
virtual int loadWords(const char *);
@@ -983,8 +975,6 @@ public:
int agiIsKeypressLow() { return 0; }
int preAgiLoadResource(int r, int n);
- int preAgiLoadResource(int r, const char* n);
- int preAgiLoadResource(int r, byte* n);
int preAgiUnloadResource(int r, int n);
PreAgiEngine(OSystem *syst);
diff --git a/engines/agi/loader_preagi.cpp b/engines/agi/loader_preagi.cpp
index 135472bca3..4e0b3e06a7 100644
--- a/engines/agi/loader_preagi.cpp
+++ b/engines/agi/loader_preagi.cpp
@@ -211,86 +211,6 @@ int AgiLoader_preagi::loadResource(int t, int n) {
return ec;
}
-/*
- * Loads a resource into memory, a raw resource is loaded in
- * with above routine, then further decoded here.
- */
-int AgiLoader_preagi::loadResource(int t, const char* n) {
- int ec = errOK;
- uint8 *data = NULL;
- Common::File infile;
-
- 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[0].flags & RES_LOADED)
- unloadResource(rPICTURE, 0);
-
- data = new uint8[4096];
-
- if (!infile.open(n))
- return errBadResource;
- infile.read(data, infile.size());
-
- if (data != NULL) {
- _vm->_game.pictures[0].rdata = data;
- _vm->_game.dirPic[0].len = infile.size();
- _vm->_game.dirPic[0].flags |= RES_LOADED;
- } else {
- ec = errBadResource;
- }
-
- infile.close();
- break;
- case rSOUND:
- break;
- case rVIEW:
- break;
- default:
- ec = errBadResource;
- break;
- }
-
- return ec;
-}
-
-/*
- * Loads a resource into memory, a raw resource is loaded in
- * with above routine, then further decoded here.
- */
-int AgiLoader_preagi::loadResource(int t, byte* n) {
- int ec = errOK;
-
- 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[0].flags & RES_LOADED)
- unloadResource(rPICTURE, 0);
-
- if (n != NULL) {
- _vm->_game.pictures[0].rdata = n;
- _vm->_game.dirPic[0].len = 4096; //FIXME: set up real resource length
- _vm->_game.dirPic[0].flags |= RES_LOADED;
- } else {
- ec = errBadResource;
- }
- break;
- case rSOUND:
- break;
- case rVIEW:
- break;
- default:
- ec = errBadResource;
- break;
- }
-
- return ec;
-}
-
int AgiLoader_preagi::loadObjects(const char *fname) {
return 0;
//return _vm->loadObjects(fname);
diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index 27df79f5c3..2fe40181df 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -802,6 +802,37 @@ int PictureMgr::decodePicture(int n, int clear, bool agi256, int pic_width, int
}
/**
+ * Decode an AGI picture resource.
+ * This function decodes an AGI picture resource into the correct slot
+ * and draws it on the AGI screen, optionally clearing the screen before
+ * drawing.
+ * @param data the AGI Picture data
+ * @param length the size of the picture data buffer
+ * @param clear clear AGI screen before drawing
+ */
+int PictureMgr::decodePicture(byte* data, uint32 length, int clear, int pic_width, int pic_height) {
+ _patCode = 0;
+ _patNum = 0;
+ _priOn = _scrOn = false;
+ _scrColor = 0xF;
+ _priColor = 0x4;
+
+ _data = data;
+ _flen = length;
+ _foffs = 0;
+
+ _width = pic_width;
+ _height = pic_height;
+
+ if (clear) // 256 color pictures should always fill the whole screen, so no clearing for them.
+ memset(_vm->_game.sbuf16c, 0x4f, _width * _height); // Clear 16 color AGI screen (Priority 4, color white).
+
+ drawPicture(); // Draw 16 color picture.
+
+ return errOK;
+}
+
+/**
* Unload an AGI picture resource.
* This function unloads an AGI picture resource and deallocates
* resource data.
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index d92bc92210..d037eebd17 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -83,6 +83,7 @@ public:
PictureMgr(AgiBase *agi, GfxMgr *gfx);
int decodePicture(int n, int clear, bool agi256 = false, int pic_width = _DEFAULT_WIDTH, int pic_height = _DEFAULT_HEIGHT);
+ int decodePicture(byte* data, uint32 length, int clear, int pic_width = _DEFAULT_WIDTH, int pic_height = _DEFAULT_HEIGHT);
int unloadPicture(int);
void drawPicture();
void showPic(int x = 0, int y = 0, int pic_width = _DEFAULT_WIDTH, int pic_height = _DEFAULT_HEIGHT);
diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp
index ef56714164..67632bcd84 100644
--- a/engines/agi/preagi.cpp
+++ b/engines/agi/preagi.cpp
@@ -256,14 +256,6 @@ int PreAgiEngine::preAgiLoadResource(int r, int n) {
return _loader->loadResource(r, n);
}
-int PreAgiEngine::preAgiLoadResource (int r, const char* n) {
- return _loader->loadResource(r, n);
-}
-
-int PreAgiEngine::preAgiLoadResource (int r, byte* n) {
- return _loader->loadResource(r, n);
-}
-
int PreAgiEngine::preAgiUnloadResource(int r, int n) {
return _loader->unloadResource(r, n);
}
diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp
index fc50c77f5e..bad7315779 100644
--- a/engines/agi/preagi_winnie.cpp
+++ b/engines/agi/preagi_winnie.cpp
@@ -968,13 +968,17 @@ void Winnie::drawPic(const char *szName) {
// construct filename
sprintf(szFile, IDS_WTP_PATH, szName);
+ Common::File file;
+ if (!file.open(szName))
+ return;
+ uint32 size = file.size();
+ file.read(buffer, size);
+ file.close();
- _vm->preAgiLoadResource(rPICTURE, szName);
- _vm->_picture->decodePicture(0, true, false, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
+ _vm->_picture->decodePicture(buffer, size, 1, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
_vm->_picture->showPic(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
- _vm->preAgiUnloadResource(rPICTURE, 0);
delete [] buffer;
}
@@ -989,9 +993,8 @@ void Winnie::drawObjPic(int iObj, int x0, int y0) {
readObj(iObj, buffer, 2048);
memcpy(&objhdr, buffer, sizeof(WTP_OBJ_HDR));
- _vm->preAgiLoadResource(rPICTURE, buffer + objhdr.ofsPic - IDI_WTP_OFS_OBJ);
_vm->_picture->setOffset(x0, y0);
- _vm->_picture->decodePicture(0, false, false, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
+ _vm->_picture->decodePicture(buffer + objhdr.ofsPic - IDI_WTP_OFS_OBJ, 4096, 0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
_vm->_picture->setOffset(0, 0);
_vm->_picture->showPic(10, 0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
_vm->_gfx->doUpdate();
@@ -1015,8 +1018,7 @@ void Winnie::drawRoomPic() {
memcpy(&roomhdr, buffer, sizeof(WTP_ROOM_HDR));
// draw room picture
- _vm->preAgiLoadResource(rPICTURE, buffer + roomhdr.ofsPic - IDI_WTP_OFS_ROOM);
- _vm->_picture->decodePicture(0, true, false, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
+ _vm->_picture->decodePicture(buffer + roomhdr.ofsPic - IDI_WTP_OFS_ROOM, 4096, 1, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
_vm->_picture->showPic(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop