aboutsummaryrefslogtreecommitdiff
path: root/sky
diff options
context:
space:
mode:
authorJoost Peters2003-06-04 17:13:24 +0000
committerJoost Peters2003-06-04 17:13:24 +0000
commitd496cecc982f13c8010d577236d6c133497af532 (patch)
tree9c6866678d69ec7af761696d0c1efd01f68be49f /sky
parentac57e79ca27222ffc1868e2515d6a07eff3a87a2 (diff)
downloadscummvm-rg350-d496cecc982f13c8010d577236d6c133497af532.tar.gz
scummvm-rg350-d496cecc982f13c8010d577236d6c133497af532.tar.bz2
scummvm-rg350-d496cecc982f13c8010d577236d6c133497af532.zip
some more mouse stuff..
svn-id: r8295
Diffstat (limited to 'sky')
-rw-r--r--sky/logic.cpp3
-rw-r--r--sky/logic.h7
-rw-r--r--sky/mouse.cpp74
-rw-r--r--sky/mouse.h23
-rw-r--r--sky/sky.cpp2
5 files changed, 96 insertions, 13 deletions
diff --git a/sky/logic.cpp b/sky/logic.cpp
index 504d5de081..7f2bdbbbc0 100644
--- a/sky/logic.cpp
+++ b/sky/logic.cpp
@@ -1466,8 +1466,7 @@ bool SkyLogic::fnNoHuman(uint32 a, uint32 b, uint32 c) {
}
bool SkyLogic::fnAddHuman(uint32 a, uint32 b, uint32 c) {
- warning("Stub: fnAddHuman");
- return true;
+ return _skyMouse->fnAddHuman();
}
bool SkyLogic::fnAddButtons(uint32 a, uint32 b, uint32 c) {
diff --git a/sky/logic.h b/sky/logic.h
index f04b1040a4..2acae2339d 100644
--- a/sky/logic.h
+++ b/sky/logic.h
@@ -34,10 +34,13 @@ enum scriptVariableOffsets {
RESULT = 0,
SCREEN = 1,
LOGIC_LIST_NO = 2,
+ MOUSE_LIST_NO = 6,
DRAW_LIST_NO = 8,
CUR_ID = 12,
MOUSE_STATUS = 13,
MOUSE_STOP = 14,
+ BUTTON = 15,
+ SPECIAL_ITEM = 17,
GET_OFF = 18,
PLAYER_X = 27,
PLAYER_Y = 28,
@@ -62,6 +65,7 @@ enum scriptVariableOffsets {
class SkyAutoRoute;
class SkyScreen;
+class SkyMouse;
class SkyLogic {
public:
@@ -85,7 +89,7 @@ public:
void pause();
void waitSync();
void simpleAnim();
-
+ uint16 script(uint16 scriptNo, uint16 offset);
bool fnCacheChip(uint32 a, uint32 b, uint32 c);
bool fnCacheFast(uint32 a, uint32 b, uint32 c);
@@ -211,7 +215,6 @@ protected:
void push(uint32);
uint32 pop();
void checkModuleLoaded(uint16 moduleNo);
- uint16 script(uint16 scriptNo, uint16 offset);
bool collide(Compact *cpt);
void initScriptVariables();
void mainAnim();
diff --git a/sky/mouse.cpp b/sky/mouse.cpp
index 393aacf967..7283bb6df1 100644
--- a/sky/mouse.cpp
+++ b/sky/mouse.cpp
@@ -77,15 +77,15 @@ uint32 _mouseObjectList[] = {
24829
};
-SkyMouse::SkyMouse(OSystem *system, SkyDisk *skyDisk) {
+SkyMouse::SkyMouse(OSystem *system, SkyDisk *skyDisk, SkyLogic *skyLogic) {
_skyDisk = skyDisk;
+ _skyLogic = skyLogic;
_system = system;
_mouseWidth = 6;
_mouseHeight = 6;
_maskWidth = 6;
_maskHeight = 6;
-
_miceData = _skyDisk->loadFile(MICE_FILE, NULL);
_mouseData2 = _miceData;
@@ -129,6 +129,36 @@ bool SkyMouse::fnNormalMouse(void) {
return true;
}
+bool SkyMouse::fnAddHuman(void) {
+ //reintroduce the mouse so that the human can control the player
+ //could still be switched out at high-level
+
+ if (!SkyLogic::_scriptVariables[MOUSE_STOP]) {
+ SkyLogic::_scriptVariables[MOUSE_STATUS] |= 6; //cursor & mouse
+ _tMouseX = _newSafeX;
+ _tMouseY = _newSafeY;
+
+ if (_aMouseY < 2) //stop mouse activating top line
+ _aMouseY = 2;
+
+ //force the pointer engine into running a get-off
+ //even if it's over nothing
+
+ //KWIK-FIX
+ //get off may contain script to remove mouse pointer text
+ //surely this script should be run just in case
+ //I am going to try it anyway
+ uint32 getOff = SkyLogic::_scriptVariables[GET_OFF];
+ if (getOff)
+ _skyLogic->script((uint16)(getOff & 0xFFFF), (uint16)(getOff >> 16));
+
+ SkyLogic::_scriptVariables[SPECIAL_ITEM] = 0xFFFFFFFF; //0?
+ SkyLogic::_scriptVariables[GET_OFF] = RESET_MOUSE;
+ }
+
+ return true;
+}
+
void SkyMouse::lockMouse(void) {
_lockMouseX = _aMouseX;
_lockMouseY = _aMouseY;
@@ -151,7 +181,7 @@ void SkyMouse::drawNewMouse() {
}
void SkyMouse::spriteMouse(uint16 frameNum, uint16 mouseX, uint16 mouseY) {
- //_mouseFlag |= MF_IN_INT;
+ SkyState::_systemVars.mouseFlag |= MF_IN_INT;
_mouseType2 = frameNum;
_mouseOffsetX = mouseX;
_mouseOffsetY = mouseY;
@@ -172,5 +202,41 @@ void SkyMouse::spriteMouse(uint16 frameNum, uint16 mouseX, uint16 mouseY) {
_system->show_mouse(true);
//drawNewMouse();
- //_mouseFlag ^= (~_mouseFlag | MF_IN_INT);
+ SkyState::_systemVars.mouseFlag &= ~MF_IN_INT;
+}
+
+void SkyMouse::mouseEngine(void) {
+ _tMouseX = _aMouseX + TOP_LEFT_X;
+ _tMouseY = _aMouseY + TOP_LEFT_Y;
+
+ _eMouseB = _bMouseB;
+ _bMouseB = 0;
+
+ if (!SkyLogic::_scriptVariables[MOUSE_STOP]) {
+ if (SkyLogic::_scriptVariables[MOUSE_STATUS] & (1 << 1)) {
+ pointerEngine();
+ if (SkyLogic::_scriptVariables[MOUSE_STATUS] & (1 << 2)) //buttons enabled?
+ buttonEngine1();
+ }
+ }
+ _eMouseB = 0; //don't save up buttons
+}
+
+void SkyMouse::pointerEngine(void) {
+ warning("Stub: pointerEngine()");
+}
+
+void SkyMouse::buttonEngine1(void) {
+ //checks for clicking on special item
+ //"compare the size of this routine to S1 mouse_button"
+
+ if (_eMouseB) { //anything pressed?
+ SkyLogic::_scriptVariables[BUTTON] = _eMouseB;
+ _eMouseB = 0;
+ if (SkyLogic::_scriptVariables[SPECIAL_ITEM]) { //over anything?
+ Compact *item = SkyState::fetchCompact(SkyLogic::_scriptVariables[SPECIAL_ITEM]);
+ if (item->mouseClick)
+ _skyLogic->script(item->mouseClick, 0);
+ }
+ }
}
diff --git a/sky/mouse.h b/sky/mouse.h
index b48b364583..b925b81cf0 100644
--- a/sky/mouse.h
+++ b/sky/mouse.h
@@ -24,19 +24,23 @@
#include "stdafx.h"
#include "sky/disk.h"
+#include "sky/logic.h"
#include "sky/struc.h"
+class SkyLogic;
+
class SkyMouse {
public:
- SkyMouse(OSystem *system, SkyDisk *skyDisk);
+ SkyMouse(OSystem *system, SkyDisk *skyDisk, SkyLogic *skyLogic);
~SkyMouse(void);
void replaceMouseCursors(uint16 fileNo);
bool fnBlankMouse(void);
bool fnDiskMouse(void);
bool fnNormalMouse(void);
+ bool fnAddHuman(void);
void lockMouse(void);
void unlockMouse(void);
void restoreMouseData(uint16 frameNum);
@@ -45,9 +49,22 @@ public:
protected:
+ void mouseEngine(void);
+ void pointerEngine(void);
+ void buttonEngine1(void);
+
+ uint16 _eMouseB;
+ uint16 _bMouseB;
+
uint16 _aMouseX; //actual mouse coordinates
uint16 _aMouseY;
+ uint16 _tMouseX;
+ uint16 _tMouseY;
+
+ uint16 _newSafeX;
+ uint16 _newSafeY;
+
uint16 _lockMouseX;
uint16 _lockMouseY;
@@ -73,15 +90,13 @@ protected:
byte *_miceData; //address of mouse sprites
byte *_objectMouseData; //address of object mouse sprites
- uint16 _tMouseX;
- uint16 _tMouseY;
-
uint16 _mouseXOff;
static uint32 _mouseObjectList[];
OSystem *_system;
SkyDisk *_skyDisk;
+ SkyLogic *_skyLogic;
};
#endif //SKYMOUSE_H
diff --git a/sky/sky.cpp b/sky/sky.cpp
index c3654c8193..99d376841d 100644
--- a/sky/sky.cpp
+++ b/sky/sky.cpp
@@ -174,7 +174,7 @@ void SkyState::initialise(void) {
_systemVars.systemFlags |= SF_PLAY_VOCS;
_skyText = new SkyText(_skyDisk);
- _skyMouse = new SkyMouse(_system, _skyDisk);
+ _skyMouse = new SkyMouse(_system, _skyDisk, _skyLogic);
_skyScreen = new SkyScreen(_system, _skyDisk);
initVirgin();