some more mouse stuff..

svn-id: r8295
This commit is contained in:
Joost Peters 2003-06-04 17:13:24 +00:00
parent ac57e79ca2
commit d496cecc98
5 changed files with 96 additions and 13 deletions

View File

@ -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) {

View File

@ -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();

View File

@ -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);
}
}
}

View File

@ -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

View File

@ -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();