[Scummvm-cvs-logs] CVS: scummvm/sky logic.cpp,1.82,1.83 logic.h,1.25,1.26 mouse.cpp,1.7,1.8 mouse.h,1.7,1.8 screen.cpp,1.26,1.27 sky.cpp,1.53,1.54 sky.h,1.30,1.31 skydefs.h,1.20,1.21 text.cpp,1.29,1.30 text.h,1.18,1.19
Robert G?ffringmann
lavosspawn at users.sourceforge.net
Thu Jun 5 12:05:14 CEST 2003
Update of /cvsroot/scummvm/scummvm/sky
In directory sc8-pr-cvs1:/tmp/cvs-serv7616/sky
Modified Files:
logic.cpp logic.h mouse.cpp mouse.h screen.cpp sky.cpp sky.h
skydefs.h text.cpp text.h
Log Message:
fixed sprite drawing, added some mouse support and some logic routines.
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.cpp,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- logic.cpp 4 Jun 2003 18:02:40 -0000 1.82
+++ logic.cpp 5 Jun 2003 18:54:25 -0000 1.83
@@ -396,7 +396,7 @@
}
void SkyLogic::cursor() {
- error("Stub: SkyLogic::cursor");
+ _skyText->logicCursor(_compact, _skyMouse->giveMouseX(), _skyMouse->giveMouseY());
}
/*
@@ -1470,7 +1470,7 @@
bool SkyLogic::fnNoHuman(uint32 a, uint32 b, uint32 c) {
if (!_scriptVariables[MOUSE_STOP]) {
- _scriptVariables[MOUSE_STOP] &= 1;
+ _scriptVariables[MOUSE_STATUS] &= 1;
runGetOff();
fnBlankMouse(0, 0, 0);
}
@@ -1500,7 +1500,9 @@
}
bool SkyLogic::fnPointerText(uint32 a, uint32 b, uint32 c) {
- error("Stub: fnPointerText");
+
+ _skyText->fnPointerText(a, _skyMouse->giveMouseX(), _skyMouse->giveMouseY());
+ return true;
}
bool SkyLogic::fnQuit(uint32 a, uint32 b, uint32 c) {
@@ -2050,7 +2052,8 @@
}
bool SkyLogic::fnSaveCoods(uint32 a, uint32 b, uint32 c) {
- error("Stub: fnSaveCoods");
+ _skyMouse->fnSaveCoods();
+ return true;
}
bool SkyLogic::fnPlotGrid(uint32 x, uint32 y, uint32 width) {
Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- logic.h 4 Jun 2003 17:13:24 -0000 1.25
+++ logic.h 5 Jun 2003 18:54:26 -0000 1.26
@@ -42,6 +42,9 @@
BUTTON = 15,
SPECIAL_ITEM = 17,
GET_OFF = 18,
+ CURSOR_ID = 22,
+ SAFEX = 25,
+ SAFEY = 26,
PLAYER_X = 27,
PLAYER_Y = 28,
PLAYER_MOOD = 29,
@@ -89,6 +92,7 @@
void pause();
void waitSync();
void simpleAnim();
+ uint16 script(uint32 num) { return script((uint16)(num & 0xFFFF), (uint16)(num >> 16)); };
uint16 script(uint16 scriptNo, uint16 offset);
bool fnCacheChip(uint32 a, uint32 b, uint32 c);
Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/mouse.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mouse.cpp 4 Jun 2003 18:02:40 -0000 1.7
+++ mouse.cpp 5 Jun 2003 18:54:26 -0000 1.8
@@ -77,10 +77,9 @@
24829
};
-SkyMouse::SkyMouse(OSystem *system, SkyDisk *skyDisk, SkyLogic *skyLogic) {
+SkyMouse::SkyMouse(OSystem *system, SkyDisk *skyDisk) {
_skyDisk = skyDisk;
- _skyLogic = skyLogic;
_system = system;
_mouseWidth = 6;
_mouseHeight = 6;
@@ -112,23 +111,6 @@
_skyDisk->loadFile(fileNo, _objectMouseData);
}
-/*bool SkyMouse::fnBlankMouse(void) {
- _mouseXOff = 0; //re-align mouse
- spriteMouse(MOUSE_BLANK, 0, 0);
- return true;
-}
-
-bool SkyMouse::fnDiskMouse(void) {
- //turn the mouse into a disk mouse
- spriteMouse(MOUSE_DISK, 11, 11);
- return true; //don't quit from the interpreter
-}
-
-bool SkyMouse::fnNormalMouse(void) {
- spriteMouse(MOUSE_NORMAL, 0, 0);
- 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
@@ -148,9 +130,8 @@
//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));
+ if (SkyLogic::_scriptVariables[GET_OFF])
+ _skyLogic->script(SkyLogic::_scriptVariables[GET_OFF]);
SkyLogic::_scriptVariables[SPECIAL_ITEM] = 0xFFFFFFFF;
SkyLogic::_scriptVariables[GET_OFF] = RESET_MOUSE;
@@ -159,6 +140,11 @@
return true;
}
+void SkyMouse::fnSaveCoods(void) {
+ SkyLogic::_scriptVariables[SAFEX] = _tMouseX;
+ SkyLogic::_scriptVariables[SAFEY] = _tMouseY;
+}
+
void SkyMouse::lockMouse(void) {
_lockMouseX = _aMouseX;
_lockMouseY = _aMouseY;
@@ -180,14 +166,10 @@
//drawMouse();
}
-void SkyMouse::spriteMouse(uint16 frameNum, uint16 mouseX, uint16 mouseY) {
+void SkyMouse::spriteMouse(uint16 frameNum, uint8 mouseX, uint8 mouseY) {
SkyState::_systemVars.mouseFlag |= MF_IN_INT;
_mouseType2 = frameNum;
- _mouseOffsetX = mouseX;
- _mouseOffsetY = mouseY;
- //restoreMouseData(frameNum);
- printf("drawing mouse %d\n",frameNum);
byte *mouseData = _miceData;
uint32 pos = ((struct dataFileHeader *)mouseData)->s_sp_size * frameNum;
pos += sizeof(struct dataFileHeader);
@@ -196,16 +178,18 @@
_mouseWidth = ((struct dataFileHeader *)mouseData)->s_width;
_mouseHeight = ((struct dataFileHeader *)mouseData)->s_height;
- _system->set_mouse_cursor(_mouseData2, _mouseWidth, _mouseHeight, mouseX, mouseY);
+ //_system->set_mouse_cursor(_mouseData2, _mouseWidth, _mouseHeight, mouseX, mouseY);
+ // there's something wrong about the mouse's hotspot. using 0/0 works fine.
+ _system->set_mouse_cursor(_mouseData2, _mouseWidth, _mouseHeight, 0, 0);
if (frameNum == MOUSE_BLANK) _system->show_mouse(false);
else _system->show_mouse(true);
- //drawNewMouse();
-
SkyState::_systemVars.mouseFlag &= ~MF_IN_INT;
}
-void SkyMouse::mouseEngine(void) {
+void SkyMouse::mouseEngine(uint16 mouseX, uint16 mouseY) {
+ _aMouseX = mouseX;
+ _aMouseY = mouseY;
_tMouseX = _aMouseX + TOP_LEFT_X;
_tMouseY = _aMouseY + TOP_LEFT_Y;
@@ -223,7 +207,39 @@
}
void SkyMouse::pointerEngine(void) {
- warning("Stub: pointerEngine()");
+ uint32 currentListNum = SkyLogic::_scriptVariables[MOUSE_LIST_NO];
+ uint16 *currentList;
+ do {
+ currentList = (uint16*)SkyState::fetchCompact(currentListNum);
+ while ((*currentList != 0) && (*currentList != 0xFFFF)) {
+ uint16 itemNum = *currentList;
+ Compact *itemData = SkyState::fetchCompact(itemNum);
+ currentList++;
+ if ((itemData->screen == SkyLogic::_scriptVariables[SCREEN]) && (itemData->status & 16)) {
+ if (itemData->xcood + itemData->mouseRelX > _tMouseX) continue;
+ if (itemData->xcood + itemData->mouseRelX + itemData->mouseSizeX < _tMouseX) continue;
+ if (itemData->ycood + itemData->mouseRelY > _tMouseY) continue;
+ if (itemData->ycood + itemData->mouseRelY + itemData->mouseSizeY < _tMouseY) continue;
+ // we've hit the item
+ if (SkyLogic::_scriptVariables[SPECIAL_ITEM] == itemNum)
+ return;
+ SkyLogic::_scriptVariables[SPECIAL_ITEM] = itemNum;
+ if (SkyLogic::_scriptVariables[GET_OFF])
+ _skyLogic->script(SkyLogic::_scriptVariables[GET_OFF]);
+ SkyLogic::_scriptVariables[GET_OFF] = itemData->mouseOff;
+ if (itemData->mouseOn) _skyLogic->script(itemData->mouseOn);
+ return;
+ }
+ }
+ if (*currentList == 0xFFFF) currentListNum = currentList[1];
+
+ } while (*currentList != 0);
+ if (SkyLogic::_scriptVariables[SPECIAL_ITEM] != 0) {
+ SkyLogic::_scriptVariables[SPECIAL_ITEM] = 0;
+ if (SkyLogic::_scriptVariables[GET_OFF])
+ _skyLogic->script(SkyLogic::_scriptVariables[GET_OFF]);
+ SkyLogic::_scriptVariables[GET_OFF] = 0;
+ }
}
void SkyMouse::buttonEngine1(void) {
Index: mouse.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/mouse.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mouse.h 4 Jun 2003 18:02:41 -0000 1.7
+++ mouse.h 5 Jun 2003 18:54:26 -0000 1.8
@@ -33,21 +33,25 @@
public:
- SkyMouse(OSystem *system, SkyDisk *skyDisk, SkyLogic *skyLogic);
+ SkyMouse(OSystem *system, SkyDisk *skyDisk);
~SkyMouse(void);
+ void mouseEngine(uint16 mouseX, uint16 mouseY);
void replaceMouseCursors(uint16 fileNo);
- //void setMouseSprite(uint8 sprNum, uint16 mouseX, uint16 mouseY);
bool fnAddHuman(void);
+ void fnSaveCoods(void);
void lockMouse(void);
void unlockMouse(void);
void restoreMouseData(uint16 frameNum);
void drawNewMouse(void);
- void spriteMouse(uint16 frameNum, uint16 mouseX, uint16 mouseY);
+ void spriteMouse(uint16 frameNum, uint8 mouseX, uint8 mouseY);
+ void useLogicInstance(SkyLogic *skyLogic) { _skyLogic = skyLogic; };
+ void buttonPressed(void) { _bMouseB = 1; };
+ uint16 giveMouseX(void) { return _aMouseX; };
+ uint16 giveMouseY(void) { return _aMouseY; };
protected:
- void mouseEngine(void);
void pointerEngine(void);
void buttonEngine1(void);
@@ -65,9 +69,6 @@
uint16 _lockMouseX;
uint16 _lockMouseY;
-
- uint16 _mouseOffsetX; //for offsetting the mouse
- uint16 _mouseOffsetY; //positive offsets only, mouse moves left or up
uint16 _mouseType2; //number of current mouse
byte *_mouseData2; //pointer to mouse data
Index: screen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/screen.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- screen.cpp 3 Jun 2003 18:35:18 -0000 1.26
+++ screen.cpp 5 Jun 2003 18:54:26 -0000 1.27
@@ -591,7 +591,7 @@
spriteData += sizeof(dataFileHeader);
int32 spriteY = sprCompact->ycood + (int16)FROM_LE_16(sprDataFile->s_offset_y) - TOP_LEFT_Y;
if (spriteY < 0) {
- spriteY = ~spriteY;
+ spriteY = -spriteY;
if (_sprHeight <= (uint32)spriteY) {
_sprWidth = 0;
return ;
@@ -612,7 +612,7 @@
_sprY = (uint32)spriteY;
int32 spriteX = sprCompact->xcood + (int16)FROM_LE_16(sprDataFile->s_offset_x) - TOP_LEFT_X;
if (spriteX < 0) {
- spriteX = ~spriteX;
+ spriteX = -spriteX;
if (_sprWidth <= (uint32)spriteX) {
_sprWidth = 0;
return ;
@@ -621,9 +621,9 @@
_maskX1 = spriteX;
spriteX = 0;
} else {
- int32 rightClip = GAME_SCREEN_WIDTH - FROM_LE_16(sprDataFile->s_width) - spriteX;
+ int32 rightClip = GAME_SCREEN_WIDTH - (FROM_LE_16(sprDataFile->s_width) + spriteX);
if (rightClip < 0) {
- rightClip = ~rightClip;
+ rightClip = (-rightClip) + 1;
if (_sprWidth <= (uint32)rightClip) {
_sprWidth = 0;
return ;
@@ -643,7 +643,7 @@
for (uint8 cnty = 0; cnty < _sprHeight; cnty++) {
for (uint8 cntx = 0; cntx < _sprWidth; cntx++)
if (spriteData[cntx + _maskX1]) screenPtr[cntx] = spriteData[cntx + _maskX1];
- spriteData += _sprWidth;
+ spriteData += _sprWidth + _maskX2;
screenPtr += GAME_SCREEN_WIDTH;
}
// Convert the sprite coordinate/size values to blocks for vertical mask and/or vector to game
Index: sky.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sky.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- sky.cpp 4 Jun 2003 17:13:24 -0000 1.53
+++ sky.cpp 5 Jun 2003 18:54:26 -0000 1.54
@@ -125,12 +125,6 @@
strcpy(buf2, buf1);
}
-void SkyState::pollMouseXY() {
-
- _mouse_x = _sdl_mouse_x;
- _mouse_y = _sdl_mouse_y;
-}
-
void SkyState::go() {
if (!_dump_file)
@@ -147,6 +141,7 @@
while (1) {
delay(50);
+ _skyMouse->mouseEngine((uint16)_sdl_mouse_x, (uint16)_sdl_mouse_y);
_skyLogic->engine();
_skyScreen->recreate();
_skyScreen->spriteEngine();
@@ -174,16 +169,16 @@
_systemVars.systemFlags |= SF_PLAY_VOCS;
_skyText = new SkyText(_skyDisk);
- _skyMouse = new SkyMouse(_system, _skyDisk, _skyLogic);
+ _skyMouse = new SkyMouse(_system, _skyDisk);
_skyScreen = new SkyScreen(_system, _skyDisk);
initVirgin();
- //initMouse();
initItemList();
//initScript();
//initialiseRouter();
loadFixedItems();
_skyLogic = new SkyLogic(_skyScreen, _skyDisk, _skyText, _skyMusic, _skyMouse, _skySound);
+ _skyMouse->useLogicInstance(_skyLogic);
_timer = Engine::_timer; // initialize timer *after* _skyScreen has been initialized.
_timer->installProcedure(&timerHandler, 1000000 / 50); //call 50 times per second
@@ -271,7 +266,6 @@
uint32 start = _system->get_msecs();
uint32 cur = start;
_key_pressed = 0; //reset
- _mouse_pos_changed = false;
_rnd.getRandomNumber(2);
do {
@@ -288,12 +282,12 @@
case OSystem::EVENT_MOUSEMOVE:
_sdl_mouse_x = event.mouse.x;
_sdl_mouse_y = event.mouse.y;
- _mouse_pos_changed = true;
_system->set_mouse_pos(_sdl_mouse_x, _sdl_mouse_y);
break;
- case OSystem::EVENT_LBUTTONDOWN:
+ case OSystem::EVENT_LBUTTONDOWN:
_left_button_down++;
+ _skyMouse->buttonPressed();
#ifdef _WIN32_WCE
_sdl_mouse_x = event.mouse.x;
_sdl_mouse_y = event.mouse.y;
Index: sky.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sky.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- sky.h 2 Jun 2003 06:42:42 -0000 1.30
+++ sky.h 5 Jun 2003 18:54:26 -0000 1.31
@@ -65,15 +65,11 @@
uint16 _debugMode;
uint16 _debugLevel;
- uint _mouse_x, _mouse_y;
- uint _mouse_x_old, _mouse_y_old;
- bool _mouse_pos_changed;
uint _left_button_down;
int _numScreenUpdates;
Timer *_timer;
- //int _timer_id;
FILE *_dump_file;
@@ -116,7 +112,6 @@
protected:
void logic_engine();
void delay(uint amount);
- void pollMouseXY();
void go();
//intro related
Index: skydefs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/skydefs.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- skydefs.h 4 Jun 2003 18:02:41 -0000 1.20
+++ skydefs.h 5 Jun 2003 18:54:26 -0000 1.21
@@ -4299,5 +4299,7 @@
#define MOUSE_CROSS 7 // angry mouse
#define MOUSE_UP 8 // mouse up
+#define TEXT_MOUSE_WIDTH 0x80
+
#endif
Index: text.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/text.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- text.cpp 2 Jun 2003 06:42:42 -0000 1.29
+++ text.cpp 5 Jun 2003 18:54:26 -0000 1.30
@@ -176,6 +176,31 @@
} while(textChar);
}
+void SkyText::fnPointerText(uint32 pointedId, uint16 mouseX, uint16 mouseY) {
+
+ Compact *ptrComp = SkyState::fetchCompact(pointedId);
+ lowTextManager_t text = lowTextManager(ptrComp->cursorText, TEXT_MOUSE_WIDTH, L_CURSOR, 242, false);
+ SkyLogic::_scriptVariables[CURSOR_ID] = text.compactNum;
+ if (SkyLogic::_scriptVariables[MENU]) {
+ _mouseOfsY = TOP_LEFT_Y - 2;
+ if (mouseX < 150) _mouseOfsX = TOP_LEFT_X + 24;
+ else _mouseOfsX = TOP_LEFT_X - 8 - _lowTextWidth;
+ } else {
+ _mouseOfsY = TOP_LEFT_Y - 10;
+ if (mouseX < 150) _mouseOfsX = TOP_LEFT_X + 13;
+ else _mouseOfsX = TOP_LEFT_X - 8 - _lowTextWidth;
+ }
+ Compact *textCompact = SkyState::fetchCompact(text.compactNum);
+ logicCursor(textCompact, mouseX, mouseY);
+}
+
+void SkyText::logicCursor(Compact *textCompact, uint16 mouseX, uint16 mouseY) {
+
+ textCompact->xcood = (uint16)(mouseX + _mouseOfsX);
+ textCompact->ycood = (uint16)(mouseY + _mouseOfsY);
+ if (textCompact->ycood < TOP_LEFT_Y) textCompact->ycood = TOP_LEFT_Y;
+}
+
bool SkyText::getTBit() {
if (_shiftBits) {
@@ -376,7 +401,7 @@
cpt->logic = logicNum;
cpt->status = ST_LOGIC | ST_FOREGROUND | ST_RECREATE;
- cpt->screen = (uint16) SkyLogic::_scriptVariables[SCREEN];
+ cpt->screen = (uint16) SkyLogic::_scriptVariables[SCREEN];
struct lowTextManager_t ret;
ret.textData = _dtData;
Index: text.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/text.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- text.h 2 Jun 2003 06:42:42 -0000 1.18
+++ text.h 5 Jun 2003 18:54:26 -0000 1.19
@@ -23,6 +23,7 @@
#define SKYTEXT_H
#include "sky/disk.h"
+#include "sky/struc.h"
struct HuffTree {
unsigned char lChild;
@@ -41,6 +42,8 @@
struct lowTextManager_t lowTextManager(uint32 textNum, uint16 width, uint16 logicNum, uint8 color, bool centre);
void fnSetFont(uint32 fontNr);
void fnTextModule(uint32 textInfoId, uint32 textNo);
+ void fnPointerText(uint32 pointedId, uint16 mouseX, uint16 mouseY);
+ void logicCursor(Compact *textCompact, uint16 mouseX, uint16 mouseY);
protected:
bool getTBit();
@@ -79,7 +82,7 @@
uint32 _dtWidth; //width of chars in last line (for editing (?))
uint32 _dtLastWidth;
bool _dtCentre; //set for centre text
- uint32 _lowTextWidth;
+ uint32 _lowTextWidth, _mouseOfsX, _mouseOfsY;
public:
uint32 _dtLetters; //no of chars in message
More information about the Scummvm-git-logs
mailing list