aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche
diff options
context:
space:
mode:
authorStrangerke2013-09-28 10:00:23 +0200
committerStrangerke2013-09-28 10:00:23 +0200
commit7d66cdf417f4e4673004fd5802e4a9649e38d179 (patch)
tree6b6e55800effc5d4d7400d8577ef9314838308bf /engines/avalanche
parent7a8d252ddb9115d4cfea0bdc5e94b38ac3ddad23 (diff)
downloadscummvm-rg350-7d66cdf417f4e4673004fd5802e4a9649e38d179.tar.gz
scummvm-rg350-7d66cdf417f4e4673004fd5802e4a9649e38d179.tar.bz2
scummvm-rg350-7d66cdf417f4e4673004fd5802e4a9649e38d179.zip
AVALANCHE: Move mouse cursor display functions to Graphics
Diffstat (limited to 'engines/avalanche')
-rw-r--r--engines/avalanche/avalanche.h2
-rw-r--r--engines/avalanche/avalot.cpp80
-rw-r--r--engines/avalanche/dialogs.cpp6
-rw-r--r--engines/avalanche/graphics.cpp56
-rw-r--r--engines/avalanche/graphics.h7
-rw-r--r--engines/avalanche/menu.cpp8
-rw-r--r--engines/avalanche/pingo.cpp2
7 files changed, 78 insertions, 83 deletions
diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h
index 2e2724f864..1d36c4c640 100644
--- a/engines/avalanche/avalanche.h
+++ b/engines/avalanche/avalanche.h
@@ -348,9 +348,7 @@ public:
void spriteRun();
Common::String intToStr(int32 num);
- void newMouse(byte id);
void setMousePointerWait(); // Makes hourglass.
- void loadMouse(byte which);
void setBackgroundColor(byte x);
diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp
index 096a5d7dd0..33bffb0f52 100644
--- a/engines/avalanche/avalot.cpp
+++ b/engines/avalanche/avalot.cpp
@@ -498,7 +498,7 @@ void AvalancheEngine::loadAlso(byte num) {
Common::String filename;
filename = Common::String::format("also%d.avd", num);
if (!file.open(filename))
- error("AVALANCHE: Lucerna: File not found: %s", filename.c_str());
+ error("AVALANCHE: File not found: %s", filename.c_str());
file.seek(128);
@@ -581,7 +581,7 @@ void AvalancheEngine::loadRoom(byte num) {
Common::String filename = Common::String::format("place%d.avd", num);
if (!file.open(filename))
- error("AVALANCHE: Lucerna: File not found: %s", filename.c_str());
+ error("AVALANCHE: File not found: %s", filename.c_str());
file.seek(146);
if (!_roomnName.empty())
@@ -1086,10 +1086,10 @@ void AvalancheEngine::thinkAbout(byte object, bool type) {
if (type == kThing) {
if (!file.open("thinks.avd"))
- error("AVALANCHE: Lucerna: File not found: thinks.avd");
+ error("AVALANCHE: File not found: thinks.avd");
} else { // kPerson
if (!file.open("folk.avd"))
- error("AVALANCHE: Lucerna: File not found: folk.avd");
+ error("AVALANCHE: File not found: folk.avd");
object -= 149;
if (object >= 25)
@@ -1113,7 +1113,7 @@ void AvalancheEngine::thinkAbout(byte object, bool type) {
void AvalancheEngine::drawToolbar() {
if (!file.open("useful.avd"))
- error("AVALANCHE: Lucerna: File not found: useful.avd");
+ error("AVALANCHE: File not found: useful.avd");
file.seek(40);
@@ -1286,17 +1286,17 @@ void AvalancheEngine::checkClick() {
after_the_scroll = false;*/
if ((0 <= cursorPos.y) && (cursorPos.y <= 21))
- newMouse(0); // up arrow
+ _graphics->loadMouse(0); // up arrow
else if ((317 <= cursorPos.y) && (cursorPos.y <= 339))
- newMouse(7); //I-beam
+ _graphics->loadMouse(7); //I-beam
else if ((340 <= cursorPos.y) && (cursorPos.y <= 399))
- newMouse(1); // screwdriver
+ _graphics->loadMouse(1); // screwdriver
else if (!_menu->isActive()) { // Dropdown can handle its own pointers.
if (_holdLeftMouse) {
- newMouse(6); // Mark's crosshairs
+ _graphics->loadMouse(6); // Mark's crosshairs
guideAvvy(cursorPos); // Normally, if you click on the picture, you're guiding Avvy around.
} else
- newMouse(3); // fletch
+ _graphics->loadMouse(3); // fletch
}
if (_holdLeftMouse) {
@@ -1454,20 +1454,12 @@ Common::String AvalancheEngine::intToStr(int32 num) {
return Common::String::format("%d", num);
}
-void AvalancheEngine::newMouse(byte id) {
- if (id == _currentMouse)
- return;
-
- _currentMouse = id;
- loadMouse(id);
-}
-
/**
* Set the mouse pointer to 'HourGlass"
* @remarks Originally called 'wait'
*/
void AvalancheEngine::setMousePointerWait() {
- newMouse(4);
+ _graphics->loadMouse(4);
}
void AvalancheEngine::resetVariables() {
@@ -1767,56 +1759,6 @@ Common::String AvalancheEngine::f5Does() {
return Common::String::format("%c", kVerbCodePardon); // If all else fails...
}
-void AvalancheEngine::loadMouse(byte which) {
- Common::File f;
-
- if (!f.open("mice.avd"))
- error("AVALANCHE: Gyro: File not found: mice.avd");
-
- ::Graphics::Surface cursor;
- cursor.create(16, 32, ::Graphics::PixelFormat::createFormatCLUT8());
- cursor.fillRect(Common::Rect(0, 0, 16, 32), 255);
-
-
- // The AND mask.
- f.seek(kMouseSize * 2 * which + 134);
-
- ::Graphics::Surface mask = _graphics->loadPictureGraphic(f);
-
- for (int j = 0; j < mask.h; j++) {
- for (int i = 0; i < mask.w; i++) {
- byte pixel = *(byte *)mask.getBasePtr(i, j);
- if (pixel == 0) {
- *(byte *)cursor.getBasePtr(i, j * 2 ) = 0;
- *(byte *)cursor.getBasePtr(i, j * 2 + 1) = 0;
- }
- }
- }
-
- mask.free();
-
- // The OR mask.
- f.seek(kMouseSize * 2 * which + 134 * 2);
-
- mask = _graphics->loadPictureGraphic(f);
-
- for (int j = 0; j < mask.h; j++) {
- for (int i = 0; i < mask.w; i++) {
- byte pixel = *(byte *)mask.getBasePtr(i, j);
- if (pixel != 0) {
- *(byte *)cursor.getBasePtr(i, j * 2 ) = pixel;
- *(byte *)cursor.getBasePtr(i, j * 2 + 1) = pixel;
- }
- }
- }
-
- mask.free();
- f.close();
-
- CursorMan.replaceCursor(cursor.getPixels(), 16, 32, kMouseHotSpots[which]._horizontal, kMouseHotSpots[which]._vertical * 2, 255, false);
- cursor.free();
-}
-
void AvalancheEngine::setBackgroundColor(byte x) {
warning("STUB: background()");
}
diff --git a/engines/avalanche/dialogs.cpp b/engines/avalanche/dialogs.cpp
index 3970f68231..d37d7592a4 100644
--- a/engines/avalanche/dialogs.cpp
+++ b/engines/avalanche/dialogs.cpp
@@ -115,7 +115,7 @@ void Dialogs::scrollModeNormal() {
setReadyLight(3);
_vm->_seeScroll = true;
- _vm->newMouse(3);
+ _vm->_graphics->loadMouse(3);
::Graphics::Surface temp;
temp.copyFrom(_vm->_graphics->_surface);
@@ -206,7 +206,7 @@ void Dialogs::scrollModeDialogue() {
warning("STUB: Scrolls::scrollModeDialogue()");
// It should work with keypresses too! TODO: Implement it!
- _vm->loadMouse(5);
+ _vm->_graphics->loadMouse(5);
::Graphics::Surface temp;
temp.copyFrom(_vm->_graphics->_surface);
@@ -254,7 +254,7 @@ void Dialogs::scrollModeMusic() {
setReadyLight(3);
_vm->_seeScroll = true;
CursorMan.showMouse(false);
- _vm->newMouse(3);
+ _vm->_graphics->loadMouse(3);
TuneType played;
for (unsigned int i = 0; i < sizeof(played); i++)
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index efed0fa97f..744876d27f 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -78,7 +78,7 @@ void Graphics::loadDigits(Common::File &file) { // Load the scoring digits & r
const byte rwlitesize = 126;
if (!file.open("digit.avd"))
- error("AVALANCHE: Lucerna: File not found: digit.avd");
+ error("AVALANCHE: File not found: digit.avd");
for (int i = 0; i < 10; i++) {
file.seek(i * digitsize);
@@ -93,6 +93,60 @@ void Graphics::loadDigits(Common::File &file) { // Load the scoring digits & r
file.close();
}
+void Graphics::loadMouse(byte which) {
+ if (which == _vm->_currentMouse)
+ return;
+
+ _vm->_currentMouse = which;
+
+ Common::File f;
+ if (!f.open("mice.avd"))
+ error("AVALANCHE: Gyro: File not found: mice.avd");
+
+ ::Graphics::Surface cursor;
+ cursor.create(16, 32, ::Graphics::PixelFormat::createFormatCLUT8());
+ cursor.fillRect(Common::Rect(0, 0, 16, 32), 255);
+
+
+ // The AND mask.
+ f.seek(kMouseSize * 2 * which + 134);
+
+ ::Graphics::Surface mask = loadPictureGraphic(f);
+
+ for (int j = 0; j < mask.h; j++) {
+ for (int i = 0; i < mask.w; i++) {
+ byte pixel = *(byte *)mask.getBasePtr(i, j);
+ if (pixel == 0) {
+ *(byte *)cursor.getBasePtr(i, j * 2 ) = 0;
+ *(byte *)cursor.getBasePtr(i, j * 2 + 1) = 0;
+ }
+ }
+ }
+
+ mask.free();
+
+ // The OR mask.
+ f.seek(kMouseSize * 2 * which + 134 * 2);
+
+ mask = loadPictureGraphic(f);
+
+ for (int j = 0; j < mask.h; j++) {
+ for (int i = 0; i < mask.w; i++) {
+ byte pixel = *(byte *)mask.getBasePtr(i, j);
+ if (pixel != 0) {
+ *(byte *)cursor.getBasePtr(i, j * 2 ) = pixel;
+ *(byte *)cursor.getBasePtr(i, j * 2 + 1) = pixel;
+ }
+ }
+ }
+
+ mask.free();
+ f.close();
+
+ CursorMan.replaceCursor(cursor.getPixels(), 16, 32, AvalancheEngine::kMouseHotSpots[which]._horizontal, AvalancheEngine::kMouseHotSpots[which]._vertical * 2, 255, false);
+ cursor.free();
+}
+
void Graphics::fleshColors() {
g_system->getPaletteManager()->setPalette(_egaPalette[39], 13, 1);
g_system->getPaletteManager()->setPalette(_egaPalette[28], 5, 1);
diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h
index ea05ef13ef..137d3e4ade 100644
--- a/engines/avalanche/graphics.h
+++ b/engines/avalanche/graphics.h
@@ -71,11 +71,12 @@ public:
~Graphics();
void init();
void loadDigits(Common::File &file); // Load the scoring digits & rwlites
+ void loadMouse(byte which);
void fleshColors();
// Taken from Free Pascal's Procedure InternalEllipseDefault. Used to replace Pascal's procedure arc.
- // Returns the end point of the arc. (Needed in Lucerna::lucerna_clock().)
+ // Returns the end point of the arc. (Needed in Clock.)
// TODO: Make it more accurate later.
Common::Point drawArc(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
@@ -91,7 +92,7 @@ public:
::Graphics::Surface loadPictureRow(Common::File &file, uint16 width, uint16 height); // Reads Row-planar EGA data.
void drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 y);
- void drawPicture(::Graphics::Surface &target, const ::Graphics::Surface &picture, uint16 destX, uint16 destY); // Can't call .free() here. See Lucerna::showscore() for example.
+ void drawPicture(::Graphics::Surface &target, const ::Graphics::Surface &picture, uint16 destX, uint16 destY); // Can't call .free() here. See showScore() for example.
void refreshScreen();
void loadBackground(Common::File &file);
void refreshBackground();
@@ -99,7 +100,7 @@ public:
private:
static const byte kEgaPaletteIndex[16];
- ::Graphics::Surface _digits[10]; // digitsize and rwlitesize are defined in Lucerna::load_digits() !!!
+ ::Graphics::Surface _digits[10]; // digitsize and rwlitesize are defined in loadDigits() !!!
::Graphics::Surface _directions[9]; // Maybe it will be needed to move them to the class itself instead.
::Graphics::Surface _screen; // Only used in refreshScreen() to make it more optimized. (No recreation of it at every call of the function.)
byte _egaPalette[64][3];
diff --git a/engines/avalanche/menu.cpp b/engines/avalanche/menu.cpp
index 81fb818025..c868765047 100644
--- a/engines/avalanche/menu.cpp
+++ b/engines/avalanche/menu.cpp
@@ -701,14 +701,14 @@ void Menu::update() { // TODO: Optimize it ASAP!!! It really needs it...
cursorPos = _vm->getMousePos();
// Change arrow...
if ((0 <= cursorPos.y) && (cursorPos.y <= 21))
- _vm->newMouse(0); // Up arrow
+ _vm->_graphics->loadMouse(0); // Up arrow
else if ((22 <= cursorPos.y) && (cursorPos.y <= 339)) {
if ((cursorPos.x >= _activeMenuItem._flx1 * 8) && (cursorPos.x <= _activeMenuItem._flx2 * 8) && (cursorPos.y > 21) && (cursorPos.y <= _activeMenuItem._fly * 2 + 1))
- _vm->newMouse(2); // Right-arrow
+ _vm->_graphics->loadMouse(2); // Right-arrow
else
- _vm->newMouse(3); // Fletch
+ _vm->_graphics->loadMouse(3); // Fletch
} else if ((340 <= cursorPos.y) && (cursorPos.y <= 399))
- _vm->newMouse(1); // Screwdriver
+ _vm->_graphics->loadMouse(1); // Screwdriver
_activeMenuItem.lightUp(cursorPos);
diff --git a/engines/avalanche/pingo.cpp b/engines/avalanche/pingo.cpp
index 9a11e6f661..bffceabe07 100644
--- a/engines/avalanche/pingo.cpp
+++ b/engines/avalanche/pingo.cpp
@@ -79,7 +79,7 @@ void Pingo::winningPic() {
_vm->dusk();
if (!f.open("finale.avd"))
- error("AVALANCHE: Lucerna: File not found: finale.avd");
+ error("AVALANCHE: File not found: finale.avd");
#if 0
for (int bit = 0; bit <= 3; bit++) {