[Scummvm-cvs-logs] SF.net SVN: scummvm:[42031] scummvm/branches/gsoc2009-draci/engines/draci
dkasak13 at users.sourceforge.net
dkasak13 at users.sourceforge.net
Thu Jul 2 18:15:32 CEST 2009
Revision: 42031
http://scummvm.svn.sourceforge.net/scummvm/?rev=42031&view=rev
Author: dkasak13
Date: 2009-07-02 16:15:32 +0000 (Thu, 02 Jul 2009)
Log Message:
-----------
DraciEngine now opens and stores pointers to essential archives. Changed code that used those archives to use that instead of opening them manually. Replaced BArchive::operator[] functionality with BArchive::getFile() to prevent ugliness when accessing archives via pointers.
Modified Paths:
--------------
scummvm/branches/gsoc2009-draci/engines/draci/barchive.cpp
scummvm/branches/gsoc2009-draci/engines/draci/barchive.h
scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
scummvm/branches/gsoc2009-draci/engines/draci/draci.h
scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
scummvm/branches/gsoc2009-draci/engines/draci/mouse.cpp
Modified: scummvm/branches/gsoc2009-draci/engines/draci/barchive.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/barchive.cpp 2009-07-02 16:07:14 UTC (rev 42030)
+++ scummvm/branches/gsoc2009-draci/engines/draci/barchive.cpp 2009-07-02 16:15:32 UTC (rev 42031)
@@ -391,7 +391,7 @@
}
-BAFile *BArchive::operator[](unsigned int i) const {
+BAFile *BArchive::getFile(unsigned int i) const {
// Check whether requested file exists
if (i >= _fileCount) {
Modified: scummvm/branches/gsoc2009-draci/engines/draci/barchive.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/barchive.h 2009-07-02 16:07:14 UTC (rev 42030)
+++ scummvm/branches/gsoc2009-draci/engines/draci/barchive.h 2009-07-02 16:15:32 UTC (rev 42031)
@@ -53,7 +53,7 @@
public:
BArchive() : _files(NULL), _fileCount(0), _opened(false) {}
- BArchive(Common::String &path) :
+ BArchive(const Common::String &path) :
_files(NULL), _fileCount(0), _opened(false) {
openArchive(path);
}
@@ -72,7 +72,7 @@
void clearCache();
- BAFile *operator[](unsigned int i) const;
+ BAFile *getFile(unsigned int i) const;
private:
// Archive header data
Modified: scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp 2009-07-02 16:07:14 UTC (rev 42030)
+++ scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp 2009-07-02 16:15:32 UTC (rev 42031)
@@ -42,6 +42,12 @@
namespace Draci {
+// Data file paths
+
+const Common::String objectsPath("OBJEKTY.DFW");
+const Common::String palettePath("PALETY.DFW");
+const Common::String spritesPath("OBR_AN.DFW");
+
DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc)
: Engine(syst) {
// Put your engine in a sane state, but do nothing big yet;
@@ -66,6 +72,11 @@
// Initialize graphics using following:
initGraphics(kScreenWidth, kScreenHeight, false);
+ // Open game's archives
+ _objectsArchive = new BArchive(objectsPath);
+ _spritesArchive = new BArchive(spritesPath);
+ _paletteArchive = new BArchive(palettePath);
+
_screen = new Screen(this);
_font = new Font();
_mouse = new Mouse(this);
@@ -75,6 +86,21 @@
// Load default font
_font->setFont(kFontBig);
+ if(!_objectsArchive->isOpen()) {
+ debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening objects archive failed");
+ return Common::kUnknownError;
+ }
+
+ if(!_spritesArchive->isOpen()) {
+ debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening sprites archive failed");
+ return Common::kUnknownError;
+ }
+
+ if(!_paletteArchive->isOpen()) {
+ debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening palette archive failed");
+ return Common::kUnknownError;
+ }
+
// Basic archive test
debugC(2, kDraciGeneralDebugLevel, "Running archive tests...");
Common::String path("INIT.DFW");
@@ -83,7 +109,7 @@
debugC(3, kDraciGeneralDebugLevel, "Number of file streams in archive: %d", ar.size());
if(ar.isOpen()) {
- f = ar[0];
+ f = ar.getFile(0);
} else {
debugC(2, kDraciGeneralDebugLevel, "ERROR - Archive not opened");
return Common::kUnknownError;
@@ -102,18 +128,9 @@
debugC(2, kDraciGeneralDebugLevel, "Running graphics/animation test...");
- Common::String path("PALETY.DFW");
- BArchive ar(path);
BAFile *f;
- ar.openArchive(path);
-
- if(ar.isOpen()) {
- f = ar[0];
- } else {
- debugC(2, kDraciGeneralDebugLevel, "ERROR - Archive not opened");
- return Common::kUnknownError;
- }
+ f = _paletteArchive->getFile(0);
_screen->setPalette(f->_data, 0, kNumColours);
@@ -157,13 +174,6 @@
_screen->copyToScreen();
// Draw and animate the dragon
- path = "OBR_AN.DFW";
- ar.openArchive(path);
-
- if(!ar.isOpen()) {
- debugC(2, kDraciGeneralDebugLevel, "ERROR - Archive not opened");
- return Common::kUnknownError;
- }
testString = "I'm transparent";
xpos = (kScreenWidth - _font->getStringWidth(testString, 1)) / 2;
@@ -177,7 +187,7 @@
debugC(5, kDraciGeneralDebugLevel, "Drawing frame %d...", t);
// Load frame to memory
- f = ar[t];
+ f = _spritesArchive->getFile(t);
Sprite sp(f->_data, f->_length, ((kScreenWidth - 50) / 2), 60, 0);
// Delete previous frame
@@ -227,6 +237,10 @@
delete _mouse;
delete _game;
delete _script;
+
+ delete _paletteArchive;
+ delete _objectsArchive;
+ delete _spritesArchive;
// Remove all of our debug levels here
Common::clearAllDebugChannels();
Modified: scummvm/branches/gsoc2009-draci/engines/draci/draci.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/draci.h 2009-07-02 16:07:14 UTC (rev 42030)
+++ scummvm/branches/gsoc2009-draci/engines/draci/draci.h 2009-07-02 16:15:32 UTC (rev 42031)
@@ -35,6 +35,7 @@
#include "draci/screen.h"
#include "draci/font.h"
#include "draci/script.h"
+#include "draci/barchive.h"
namespace Draci {
@@ -55,6 +56,10 @@
Game *_game;
Script *_script;
+ BArchive *_objectsArchive;
+ BArchive *_spritesArchive;
+ BArchive *_paletteArchive;
+
private:
Common::RandomSource _rnd;
};
Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.cpp 2009-07-02 16:07:14 UTC (rev 42030)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.cpp 2009-07-02 16:15:32 UTC (rev 42031)
@@ -41,7 +41,7 @@
// Read in persons
- file = initArchive[5];
+ file = initArchive.getFile(5);
Common::MemoryReadStream personData(file->_data, file->_length);
unsigned int numPersons = file->_length / personSize;
@@ -55,7 +55,7 @@
// Read in dialog offsets
- file = initArchive[4];
+ file = initArchive.getFile(4);
Common::MemoryReadStream dialogData(file->_data, file->_length);
unsigned int numDialogs = file->_length / sizeof(uint16);
@@ -69,7 +69,7 @@
// Read in game info
- file = initArchive[3];
+ file = initArchive.getFile(3);
Common::MemoryReadStream gameData(file->_data, file->_length);
_info = new GameInfo();
@@ -92,7 +92,7 @@
// Read in variables
- file = initArchive[2];
+ file = initArchive.getFile(2);
unsigned int numVariables = file->_length / sizeof (int16);
_variables = new int16[numVariables];
@@ -104,13 +104,13 @@
// Read in item status
- file = initArchive[1];
+ file = initArchive.getFile(1);
_itemStatus = new byte[file->_length];
memcpy(_itemStatus, file->_data, file->_length);
// Read in object status
- file = initArchive[0];
+ file = initArchive.getFile(0);
unsigned int numObjects = file->_length;
_objects = new GameObject[numObjects];
@@ -136,15 +136,15 @@
}
void Game::loadObject(uint16 objNum) {
- Common::String path("OBJEKTY.DFW");
-
- BArchive objArchive(path);
BAFile *file;
- file = objArchive[objNum * 3];
+ // Convert to real index (indexes begin with 1 in the data files)
+ objNum -= 1;
+
+ file = _vm->_objectsArchive->getFile(objNum * 3);
Common::MemoryReadStream objReader(file->_data, file->_length);
- GameObject *obj = getObject(objNum);
+ GameObject *obj = _objects + objNum;
obj->_init = objReader.readUint16LE();
obj->_look = objReader.readUint16LE();
@@ -169,11 +169,11 @@
obj->_seqTab = new uint16[obj->_numSeq];
- file = objArchive[objNum * 3 + 1];
+ file = _vm->_objectsArchive->getFile(objNum * 3 + 1);
obj->_title = new byte[file->_length];
memcpy(obj->_title, file->_data, file->_length);
- file = objArchive[objNum * 3 + 2];
+ file = _vm->_objectsArchive->getFile(objNum * 3 + 2);
obj->_program._bytecode = new byte[file->_length];
obj->_program._length = file->_length;
memcpy(obj->_program._bytecode, file->_data, file->_length);
@@ -184,7 +184,7 @@
// Convert to real index (indexes begin with 1 in the data files)
objNum -= 1;
- return &_objects[objNum];
+ return _objects + objNum;
}
Game::~Game() {
Modified: scummvm/branches/gsoc2009-draci/engines/draci/mouse.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/mouse.cpp 2009-07-02 16:07:14 UTC (rev 42030)
+++ scummvm/branches/gsoc2009-draci/engines/draci/mouse.cpp 2009-07-02 16:15:32 UTC (rev 42031)
@@ -90,7 +90,7 @@
ar.openArchive(path);
if(ar.isOpen()) {
- f = ar[_cursorType];
+ f = ar.getFile(_cursorType);
} else {
debugC(2, kDraciGeneralDebugLevel, "ERROR - Archive not opened - %s", path.c_str());
return;
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