aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-08-01 21:32:05 -0400
committerPaul Gilbert2014-08-01 21:32:05 -0400
commit857f94423fcf4464df44e5b46241f68e33f800a3 (patch)
tree2977f73f03b939bdf21b476cbb51736d88a2e40e /engines
parent4d24209eae5e776fe150775771e7cd70579a518e (diff)
downloadscummvm-rg350-857f94423fcf4464df44e5b46241f68e33f800a3.tar.gz
scummvm-rg350-857f94423fcf4464df44e5b46241f68e33f800a3.tar.bz2
scummvm-rg350-857f94423fcf4464df44e5b46241f68e33f800a3.zip
ACCESS: Implement decoding of game cursors
Diffstat (limited to 'engines')
-rw-r--r--engines/access/access.cpp27
-rw-r--r--engines/access/access.h20
-rw-r--r--engines/access/events.cpp54
-rw-r--r--engines/access/events.h11
-rw-r--r--engines/access/graphics.cpp46
-rw-r--r--engines/access/graphics.h51
-rw-r--r--engines/access/module.mk1
-rw-r--r--engines/access/resources.cpp24
-rw-r--r--engines/access/resources.h2
9 files changed, 221 insertions, 15 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index e4b4159f9b..8aabac2b0b 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -33,11 +33,13 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_gameDescription(gameDesc), Engine(syst), _randomSource("Access") {
_debugger = nullptr;
_events = nullptr;
+ _graphics = nullptr;
}
AccessEngine::~AccessEngine() {
delete _debugger;
delete _events;
+ delete _graphics;
}
void AccessEngine::initialize() {
@@ -48,19 +50,42 @@ void AccessEngine::initialize() {
_debugger = new Debugger(this);
_events = new EventsManager(this);
+ _graphics = new GraphicsManager(this);
}
Common::Error AccessEngine::run() {
initialize();
+ setVGA();
+ _graphics->setPalettte();
+ _graphics->setPanel(0);
+ _events->setCursor(CURSOR_0);
+ _events->showCursor();
+
+ dummyLoop();
return Common::kNoError;
}
+void AccessEngine::dummyLoop() {
+ // Dummy game loop
+ while (!shouldQuit()) {
+ _events->pollEvents();
+ g_system->delayMillis(50);
+ g_system->updateScreen();
+
+ if (_events->_leftButton) {
+ CursorType cursorId = _events->getCursor();
+ _events->setCursor((cursorId == CURSOR_HELP) ? CURSOR_0 : (CursorType)(cursorId + 1));
+ }
+ }
+
+}
+
int AccessEngine::getRandomNumber(int maxNumber) {
return _randomSource.getRandomNumber(maxNumber);
}
-void AccessEngine::SETVGA() {
+void AccessEngine::setVGA() {
initGraphics(320, 200, false);
}
diff --git a/engines/access/access.h b/engines/access/access.h
index 5c9207db22..16487ea64f 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -32,6 +32,7 @@
#include "graphics/surface.h"
#include "access/debugger.h"
#include "access/events.h"
+#include "access/graphics.h"
/**
* This is the namespace of the Access engine.
@@ -58,27 +59,28 @@ struct AccessGameDescription;
class AccessEngine : public Engine {
private:
- const AccessGameDescription *_gameDescription;
- Common::RandomSource _randomSource;
-
- Graphics::Surface _buffer1;
- Graphics::Surface _buffer2;
- Graphics::Surface _vidbuf;
- Graphics::Surface _plotBuf;
-
/**
* Handles basic initialisation
*/
void initialize();
- void SETVGA();
+ /**
+ * Set VGA mode
+ */
+ void setVGA();
+
+ void dummyLoop();
protected:
+ const AccessGameDescription *_gameDescription;
+ Common::RandomSource _randomSource;
+
// Engine APIs
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
public:
Debugger *_debugger;
EventsManager *_events;
+ GraphicsManager *_graphics;
public:
AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
virtual ~AccessEngine();
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 47908ff1cb..29f6270387 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -23,9 +23,14 @@
#include "common/scummsys.h"
#include "graphics/cursorman.h"
#include "common/events.h"
+#include "common/endian.h"
#include "engines/util.h"
#include "access/access.h"
#include "access/events.h"
+#include "access/resources.h"
+
+#define CURSOR_WIDTH 16
+#define CURSOR_HEIGHT 16
namespace Access {
@@ -40,7 +45,49 @@ EventsManager::~EventsManager() {
}
void EventsManager::setCursor(CursorType cursorId) {
+ if (cursorId == _cursorId)
+ return;
_cursorId = cursorId;
+
+ // Get a pointer to the mouse data to use, and get the cursor hotspot
+ const byte *srcP = Amazon::CURSORS[cursorId];
+ int hotspotX = (int16)READ_LE_UINT16(srcP);
+ int hotspotY = (int16)READ_LE_UINT16(srcP + 2);
+ srcP += 4;
+
+ // Create a surface to build up the cursor on
+ Graphics::Surface cursorSurface;
+ cursorSurface.create(16, 16, Graphics::PixelFormat::createFormatCLUT8());
+ byte *destP = (byte *)cursorSurface.getPixels();
+ Common::fill(destP, destP + CURSOR_WIDTH * CURSOR_HEIGHT, 0);
+
+ // Loop to build up the cursor
+ for (int y = 0; y < CURSOR_HEIGHT; ++y) {
+ destP = (byte *)cursorSurface.getBasePtr(0, y);
+ int width = CURSOR_WIDTH;
+ int skip = *srcP++;
+ int plot = *srcP++;
+ if (skip >= width)
+ break;
+
+ // Skip over pixels
+ destP += skip;
+ width -= skip;
+
+ // Write out the pixels to plot
+ while (plot > 0 && width > 0) {
+ *destP++ = *srcP++;
+ --plot;
+ --width;
+ }
+ }
+
+ // Set the cursor
+ CursorMan.replaceCursor(cursorSurface.getPixels(), CURSOR_WIDTH, CURSOR_HEIGHT,
+ hotspotX, hotspotY, 0);
+
+ // Free the cursor surface
+ cursorSurface.free();
}
void EventsManager::showCursor() {
@@ -58,6 +105,8 @@ bool EventsManager::isCursorVisible() {
void EventsManager::pollEvents() {
checkForNextFrameCounter();
+ _leftButton = false;
+
Common::Event event;
while (g_system->getEventManager()->pollEvent(event)) {
// Handle keypress
@@ -78,10 +127,9 @@ void EventsManager::pollEvents() {
return;
case Common::EVENT_LBUTTONDOWN:
_leftButton = true;
- break;
+ return;
case Common::EVENT_LBUTTONUP:
- _leftButton = false;
- break;
+ return;
default:
break;
}
diff --git a/engines/access/events.h b/engines/access/events.h
index b30670cdbc..3cf610ece6 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -29,7 +29,11 @@
namespace Access {
-enum CursorType { CURSOR_NONE = 0 };
+enum CursorType {
+ CURSOR_NONE = -1,
+ CURSOR_0 = 0, CURSOR_1, CURSOR_2, CURSOR_3, CURSOR_EYE, CURSOR_HAND,
+ CURSOR_GET, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP
+};
#define GAME_FRAME_RATE 50
#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
@@ -64,6 +68,11 @@ public:
void setCursor(CursorType cursorId);
/**
+ * Return the current cursor Id
+ */
+ CursorType getCursor() const { return _cursorId; }
+
+ /**
* Show the mouse cursor
*/
void showCursor();
diff --git a/engines/access/graphics.cpp b/engines/access/graphics.cpp
new file mode 100644
index 0000000000..8f0e22f2b1
--- /dev/null
+++ b/engines/access/graphics.cpp
@@ -0,0 +1,46 @@
+/* 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.
+ *
+ */
+
+#include "graphics/palette.h"
+#include "access/access.h"
+#include "access/graphics.h"
+#include "access/resources.h"
+
+namespace Access {
+
+GraphicsManager::GraphicsManager(AccessEngine *vm) : _vm(vm) {
+ _vesaCurrentWin = 0;
+ _currentPanel = 0;
+ _hideFlag = true;
+}
+
+void GraphicsManager::setPanel(int num) {
+ assert(num < 4);
+ _currentPanel = num;
+ _msVirtualOffset = _virtualOffsetsTable[num];
+}
+
+void GraphicsManager::setPalettte() {
+ g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18);
+}
+
+} // End of namespace Access
diff --git a/engines/access/graphics.h b/engines/access/graphics.h
new file mode 100644
index 0000000000..c7d2acd54e
--- /dev/null
+++ b/engines/access/graphics.h
@@ -0,0 +1,51 @@
+/* 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.
+ *
+ */
+
+#ifndef ACCESS_GRAPHICS_H
+#define ACCESS_GRAPHICS_H
+
+#include "common/rect.h"
+#include "graphics/surface.h"
+
+namespace Access {
+
+class AccessEngine;
+
+class GraphicsManager {
+private:
+ AccessEngine *_vm;
+public:
+ int _vesaCurrentWin;
+ int _currentPanel;
+ Common::Point _msVirtualOffset;
+ Common::Point _virtualOffsetsTable[4];
+ bool _hideFlag;
+public:
+ GraphicsManager(AccessEngine *vm);
+
+ void setPanel(int num);
+ void setPalettte();
+};
+
+} // End of namespace Access
+
+#endif /* ACCESS_GRAPHICS_H */
diff --git a/engines/access/module.mk b/engines/access/module.mk
index f04e51630e..d8867bc593 100644
--- a/engines/access/module.mk
+++ b/engines/access/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS := \
debugger.o \
detection.o \
events.o \
+ graphics.o \
resources.o \
amazon\amazon_game.o
diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp
index 4ab3dd9513..cf8b491900 100644
--- a/engines/access/resources.cpp
+++ b/engines/access/resources.cpp
@@ -24,6 +24,27 @@
namespace Access {
+const byte INITIAL_PALETTE[18 * 3] = {
+ 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff,
+ 0xf0, 0xf0, 0xf0,
+ 0xe0, 0xe0, 0xe0,
+ 0xd0, 0xd0, 0xd0,
+ 0xc0, 0xc0, 0xc0,
+ 0xb0, 0xb0, 0xb0,
+ 0xa0, 0xa0, 0xa0,
+ 0x90, 0x90, 0x90,
+ 0x80, 0x80, 0x80,
+ 0x70, 0x70, 0x70,
+ 0x60, 0x60, 0x60,
+ 0x50, 0x50, 0x50,
+ 0x40, 0x40, 0x40,
+ 0x30, 0x30, 0x30,
+ 0x20, 0x20, 0x20,
+ 0x10, 0x10, 0x10,
+ 0x00, 0x00, 0x00
+};
+
namespace Amazon {
const byte *CURSORS[10] = {
@@ -31,7 +52,8 @@ const byte *CURSORS[10] = {
};
const byte MOUSE0[] = {
- 0, 0, 0, 0, 0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1,
+ 0, 0, 0, 0,
+ 0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1,
0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6,
1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6,
6, 6, 6, 6, 6, 1, 0, 7, 6, 6, 6, 6, 6, 6, 1, 0, 6, 6,
diff --git a/engines/access/resources.h b/engines/access/resources.h
index cabaac96a1..7bd2354c06 100644
--- a/engines/access/resources.h
+++ b/engines/access/resources.h
@@ -27,6 +27,8 @@
namespace Access {
+extern const byte INITIAL_PALETTE[18 * 3];
+
namespace Amazon {
extern const byte MOUSE0[];