diff options
Diffstat (limited to 'engines/zvision/graphics/cursors')
-rw-r--r-- | engines/zvision/graphics/cursors/cursor.cpp | 40 | ||||
-rw-r--r-- | engines/zvision/graphics/cursors/cursor.h | 1 | ||||
-rw-r--r-- | engines/zvision/graphics/cursors/cursor_manager.cpp | 42 | ||||
-rw-r--r-- | engines/zvision/graphics/cursors/cursor_manager.h | 4 |
4 files changed, 32 insertions, 55 deletions
diff --git a/engines/zvision/graphics/cursors/cursor.cpp b/engines/zvision/graphics/cursors/cursor.cpp index 07323b45c4..2c011668ac 100644 --- a/engines/zvision/graphics/cursors/cursor.cpp +++ b/engines/zvision/graphics/cursors/cursor.cpp @@ -36,35 +36,6 @@ ZorkCursor::ZorkCursor() _hotspotY(0) { } -ZorkCursor::ZorkCursor(const Common::String &fileName) - : _width(0), - _height(0), - _hotspotX(0), - _hotspotY(0) { - Common::File file; - if (!file.open(fileName)) - return; - - uint32 magic = file.readUint32BE(); - if (magic != MKTAG('Z', 'C', 'R', '1')) { - warning("%s is not a Zork Cursor file", fileName.c_str()); - return; - } - - _hotspotX = file.readUint16LE(); - _hotspotY = file.readUint16LE(); - _width = file.readUint16LE(); - _height = file.readUint16LE(); - - uint dataSize = _width * _height * sizeof(uint16); - _surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); - uint32 bytesRead = file.read(_surface.getPixels(), dataSize); - assert(bytesRead == dataSize); - - // Convert to RGB 565 - _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); -} - ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName) : _width(0), _height(0), @@ -72,7 +43,7 @@ ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName) _hotspotY(0) { Common::File file; if (!engine->getSearchManager()->openFile(file, fileName)) - return; + error("Cursor file %s does not exist", fileName.c_str()); uint32 magic = file.readUint32BE(); if (magic != MKTAG('Z', 'C', 'R', '1')) { @@ -86,12 +57,15 @@ ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName) _height = file.readUint16LE(); uint dataSize = _width * _height * sizeof(uint16); - _surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); + _surface.create(_width, _height, engine->_resourcePixelFormat); uint32 bytesRead = file.read(_surface.getPixels(), dataSize); assert(bytesRead == dataSize); - // Convert to RGB 565 - _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); +#ifndef SCUMM_LITTLE_ENDIAN + int16 *buffer = (int16 *)_surface.getPixels(); + for (uint32 i = 0; i < dataSize / 2; ++i) + buffer[i] = FROM_LE_16(buffer[i]); +#endif } ZorkCursor::ZorkCursor(const ZorkCursor &other) { diff --git a/engines/zvision/graphics/cursors/cursor.h b/engines/zvision/graphics/cursors/cursor.h index 0c1e99411f..6e0083520a 100644 --- a/engines/zvision/graphics/cursors/cursor.h +++ b/engines/zvision/graphics/cursors/cursor.h @@ -39,7 +39,6 @@ namespace ZVision { class ZorkCursor { public: ZorkCursor(); - ZorkCursor(const Common::String &fileName); ZorkCursor(ZVision *engine, const Common::String &fileName); ZorkCursor(const ZorkCursor &other); ~ZorkCursor(); diff --git a/engines/zvision/graphics/cursors/cursor_manager.cpp b/engines/zvision/graphics/cursors/cursor_manager.cpp index 92fd461c72..eeab18f4ba 100644 --- a/engines/zvision/graphics/cursors/cursor_manager.cpp +++ b/engines/zvision/graphics/cursors/cursor_manager.cpp @@ -37,7 +37,7 @@ const char *CursorManager::_cursorNames[NUM_CURSORS] = { "active", "arrow", "bac "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow" }; -const char *CursorManager::_zgiCursorFileNames[NUM_CURSORS] = { "g0gbc011.zcr", "g0gac001.zcr", "g0gac021.zcr", "g0gac031.zcr", "g0gac041.zcr", "g0gac051.zcr", "g0gac061.zcr", "g0gac071.zcr", "g0gac081.zcr", +const char *CursorManager::_zgiCursorFileNames[NUM_CURSORS] = { "g0gbc011.zcr", "g0gac011.zcr", "g0gac021.zcr", "g0gac031.zcr", "g0gac041.zcr", "g0gac051.zcr", "g0gac061.zcr", "g0gac071.zcr", "g0gac081.zcr", "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr" }; @@ -45,7 +45,7 @@ const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" }; -CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat) +CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat pixelFormat) : _engine(engine), _pixelFormat(pixelFormat), _cursorIsPushed(false), @@ -55,6 +55,11 @@ CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixel for (int i = 0; i < NUM_CURSORS; i++) { if (_engine->getGameId() == GID_NEMESIS) { Common::String name; + if (i == 1) { + // Cursors "arrowa.zcr" and "arrowb.zcr" are missing + _cursors[i][0] = _cursors[i][1] = ZorkCursor(); + continue; + } name = Common::String::format("%sa.zcr", _zNemCursorFileNames[i]); _cursors[i][0] = ZorkCursor(_engine, name); // Up cursor name = Common::String::format("%sb.zcr", _zNemCursorFileNames[i]); @@ -106,7 +111,7 @@ void CursorManager::initialize() { } void CursorManager::changeCursor(const ZorkCursor &cursor) { - CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, _pixelFormat); + CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, &_pixelFormat); } void CursorManager::cursorDown(bool pushed) { @@ -119,31 +124,30 @@ void CursorManager::cursorDown(bool pushed) { } void CursorManager::changeCursor(int id) { - int _id = id; - - if (_item && - (_id == CursorIndex_Active || - _id == CursorIndex_Idle || - _id == CursorIndex_HandPu)) { - - if (_id == CursorIndex_Idle) - _id = CursorIndex_ItemIdle; - else - _id = CursorIndex_ItemAct; + if (_item && (id == CursorIndex_Active || + id == CursorIndex_Idle || + id == CursorIndex_HandPu)) { + if (id == CursorIndex_Idle) { + id = CursorIndex_ItemIdle; + } else { + id = CursorIndex_ItemAct; + } } - if (_currentCursor != _id || - ((_id == CursorIndex_ItemAct || _id == CursorIndex_ItemIdle) && _lastitem != _item)) { - _currentCursor = _id; + if (_currentCursor != id || ((id == CursorIndex_ItemAct || id == CursorIndex_ItemIdle) && _lastitem != _item)) { + _currentCursor = id; _lastitem = _item; changeCursor(_cursors[_currentCursor][_cursorIsPushed]); } } int CursorManager::getCursorId(const Common::String &name) { - for (int i = 0; i < NUM_CURSORS; i++) - if (name.equals(_cursorNames[i])) + for (int i = 0; i < NUM_CURSORS; i++) { + if (name.equals(_cursorNames[i])) { return i; + } + } + return CursorIndex_Idle; } diff --git a/engines/zvision/graphics/cursors/cursor_manager.h b/engines/zvision/graphics/cursors/cursor_manager.h index bbfa085c23..35c605baf8 100644 --- a/engines/zvision/graphics/cursors/cursor_manager.h +++ b/engines/zvision/graphics/cursors/cursor_manager.h @@ -58,7 +58,7 @@ enum CursorIndex { */ class CursorManager { public: - CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat); + CursorManager(ZVision *engine, const Graphics::PixelFormat pixelFormat); private: static const int NUM_CURSORS = 18; @@ -67,7 +67,7 @@ private: ZorkCursor _cursors[NUM_CURSORS + 2][2]; ZVision *_engine; - const Graphics::PixelFormat *_pixelFormat; + const Graphics::PixelFormat _pixelFormat; bool _cursorIsPushed; int _item; int _lastitem; |