- fixes bug in fileData (introduced with last commit)

- show mouse cursor in Screen::setMouseCursor if it's allready shown
- a little bit more kyra3 init stuff

svn-id: r23623
This commit is contained in:
Johannes Schickel 2006-07-30 08:22:39 +00:00
parent 92649de672
commit 6cc1a57d3b
4 changed files with 37 additions and 6 deletions

View File

@ -133,6 +133,7 @@ int KyraEngine_v3::init() {
_gameShapes[i] = _screen->getPtrToShape(_mouseSHPBuf, i); _gameShapes[i] = _screen->getPtrToShape(_mouseSHPBuf, i);
} }
initItems();
// XXX // XXX
_screen->setMouseCursor(0, 0, *_gameShapes); _screen->setMouseCursor(0, 0, *_gameShapes);
@ -531,4 +532,28 @@ void KyraEngine_v3::realInit() {
debugC(9, kDebugLevelMain, "KyraEngine::realInit()"); debugC(9, kDebugLevelMain, "KyraEngine::realInit()");
} }
#pragma mark - items
void KyraEngine_v3::initItems() {
debugC(9, kDebugLevelMain, "KyraEngine::initItems()");
_screen->loadBitmap("ITEMS.CSH", 3, 3, 0);
// XXX
_screen->loadBitmap("ITEMS2.CSH", 3, 3, 0);
uint32 size = 0;
uint8 *itemsDat = _res->fileData("_ITEMS.DAT", &size);
assert(size >= 72+144);
memcpy(_itemBuffer1, itemsDat , 72);
memcpy(_itemBuffer2, itemsDat+72, 144);
delete [] itemsDat;
_screen->_curPage = 0;
}
} // end of namespace Kyra } // end of namespace Kyra

View File

@ -100,6 +100,8 @@ private:
// items // items
uint8 *_itemBuffer1; uint8 *_itemBuffer1;
uint8 *_itemBuffer2; uint8 *_itemBuffer2;
void initItems();
}; };
} // end of namespace Kyra } // end of namespace Kyra

View File

@ -156,12 +156,14 @@ uint8 *Resource::fileData(const char *file, uint32 *size) {
// test to open it in the main dir // test to open it in the main dir
if (file_.open(file)) { if (file_.open(file)) {
if (size) uint32 temp = file_.size();
*size = file_.size(); buffer = new uint8[temp];
buffer = new uint8[*size];
assert(buffer); assert(buffer);
file_.read(buffer, *size); file_.read(buffer, temp);
if (size)
*size = temp;
file_.close(); file_.close();
} else { } else {

View File

@ -1907,10 +1907,12 @@ void Screen::setMouseCursor(int x, int y, byte *shape) {
fillRect(0, 0, mouseWidth, mouseHeight, 0, 8); fillRect(0, 0, mouseWidth, mouseHeight, 0, 8);
drawShape(8, shape, 0, 0, 0, 0); drawShape(8, shape, 0, 0, 0, 0);
CursorMan.showMouse(false); if (!_mouseLockCount)
CursorMan.showMouse(false);
copyRegionToBuffer(8, 0, 0, mouseWidth, mouseHeight, cursor); copyRegionToBuffer(8, 0, 0, mouseWidth, mouseHeight, cursor);
CursorMan.replaceCursor(cursor, mouseWidth, mouseHeight, x, y, 0); CursorMan.replaceCursor(cursor, mouseWidth, mouseHeight, x, y, 0);
CursorMan.showMouse(true); if (!_mouseLockCount)
CursorMan.showMouse(true);
free(cursor); free(cursor);
// makes sure that the cursor is drawn // makes sure that the cursor is drawn