diff options
author | Joost Peters | 2003-05-05 13:19:59 +0000 |
---|---|---|
committer | Joost Peters | 2003-05-05 13:19:59 +0000 |
commit | f762c5dbba3b456ee0337100b1870915d32e71cb (patch) | |
tree | 224ddcce11a89457e3e0c1c1f028694018325e5e /sky | |
parent | 5944d40eaae53fbbc5bc93e8a0c4f075525c43a6 (diff) | |
download | scummvm-rg350-f762c5dbba3b456ee0337100b1870915d32e71cb.tar.gz scummvm-rg350-f762c5dbba3b456ee0337100b1870915d32e71cb.tar.bz2 scummvm-rg350-f762c5dbba3b456ee0337100b1870915d32e71cb.zip |
some mouse stuff + fnEnterSection
svn-id: r7347
Diffstat (limited to 'sky')
-rw-r--r-- | sky/logic.cpp | 34 | ||||
-rw-r--r-- | sky/logic.h | 13 | ||||
-rw-r--r-- | sky/module.mk | 1 | ||||
-rw-r--r-- | sky/mouse.cpp | 172 | ||||
-rw-r--r-- | sky/mouse.h | 84 | ||||
-rw-r--r-- | sky/sky.cpp | 4 | ||||
-rw-r--r-- | sky/sky.h | 2 | ||||
-rw-r--r-- | sky/skydefs.h | 50 |
8 files changed, 352 insertions, 8 deletions
diff --git a/sky/logic.cpp b/sky/logic.cpp index 3529818dec..2c22dd1ffc 100644 --- a/sky/logic.cpp +++ b/sky/logic.cpp @@ -48,10 +48,13 @@ static const LogicTable logicTable[] = { &SkyLogic::simpleAnim, // 16 Module anim without x,y's }; -SkyLogic::SkyLogic(SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText) { +SkyLogic::SkyLogic(SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, uint32 gameVersion) { _skyDisk = skyDisk; _skyGrid = skyGrid; _skyText = skyText; + _skyMusic = skyMusic; + _skyMouse = skyMouse; + _gameVersion = gameVersion; _skyAutoRoute = new SkyAutoRoute(_skyGrid); for (uint i = 0; i < sizeof(_moduleList)/sizeof(uint16*); i++) @@ -1076,8 +1079,7 @@ uint32 SkyLogic::fnNormalMouse(uint32 a, uint32 b, uint32 c) { } uint32 SkyLogic::fnBlankMouse(uint32 a, uint32 b, uint32 c) { - warning("Stub: fnBlankMouse"); - return 1; + return _skyMouse->fnBlankMouse(); } uint32 SkyLogic::fnCrossMouse(uint32 a, uint32 b, uint32 c) { @@ -1532,8 +1534,30 @@ uint32 SkyLogic::fnLeaveSection(uint32 a, uint32 b, uint32 c) { error("Stub: fnLeaveSection"); } -uint32 SkyLogic::fnEnterSection(uint32 a, uint32 b, uint32 c) { - error("Stub: fnEnterSection"); +uint32 SkyLogic::fnEnterSection(uint32 sectionNo, uint32 b, uint32 c) { + + if (SkyState::isDemo(_gameVersion)) + if (sectionNo > 2) + error("End of demo"); + + _scriptVariables[CUR_SECTION] = sectionNo; + + if (sectionNo == 5) //linc section - has different mouse icons + _skyMouse->replaceMouseCursors(60302); + + else + if (sectionNo != _currentSection) { + + _currentSection = sectionNo; + _saveCurrentSection = sectionNo; + + sectionNo++; + _skyMusic->loadSectionMusic(sectionNo); + _skyGrid->loadGrids(); + + } + + return 1; } uint32 SkyLogic::fnRestoreGame(uint32 a, uint32 b, uint32 c) { diff --git a/sky/logic.h b/sky/logic.h index 3a088af047..b0cea353b3 100644 --- a/sky/logic.h +++ b/sky/logic.h @@ -26,10 +26,12 @@ #include "sky/disk.h" #include "sky/grid.h" #include "sky/autoroute.h" +#include "sky/musicbase.h" +#include "sky/mouse.h" class SkyLogic { public: - SkyLogic(SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText); + SkyLogic(SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, uint32 gameVersion); void engine(); void lreturn(); @@ -144,7 +146,7 @@ public: uint32 fnEyeball(uint32 a, uint32 b, uint32 c); uint32 fnCursorUp(uint32 a, uint32 b, uint32 c); uint32 fnLeaveSection(uint32 a, uint32 b, uint32 c); - uint32 fnEnterSection(uint32 a, uint32 b, uint32 c); + uint32 fnEnterSection(uint32 sectionNo, uint32 b, uint32 c); uint32 fnRestoreGame(uint32 a, uint32 b, uint32 c); uint32 fnRestartGame(uint32 a, uint32 b, uint32 c); uint32 fnNewSwingSeq(uint32 a, uint32 b, uint32 c); @@ -185,10 +187,17 @@ protected: Compact *_compact; uint32 _scriptVariables[838]; + uint32 _currentSection; + uint32 _saveCurrentSection; + + uint32 _gameVersion; + SkyDisk *_skyDisk; SkyGrid *_skyGrid; SkyText *_skyText; + SkyMusicBase *_skyMusic; SkyAutoRoute *_skyAutoRoute; + SkyMouse *_skyMouse; }; #endif diff --git a/sky/module.mk b/sky/module.mk index 992baeb47b..802a4c8a42 100644 --- a/sky/module.mk +++ b/sky/module.mk @@ -13,6 +13,7 @@ MODULE_OBJS = \ sky/grid.o \ sky/intro.o \ sky/logic.o \ + sky/mouse.o \ sky/musicbase.o \ sky/rnc_deco.o \ sky/screen.o \ diff --git a/sky/mouse.cpp b/sky/mouse.cpp new file mode 100644 index 0000000000..0b21d93fe4 --- /dev/null +++ b/sky/mouse.cpp @@ -0,0 +1,172 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2003 The ScummVM project + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + * + */ + +#include "stdafx.h" +#include "sky/sky.h" + +#define MICE_FILE 60300 +#define NO_MAIN_OBJECTS 24 +#define NO_LINC_OBJECTS 21 + +uint32 _mouseObjectList[] = { + + 65, + 9, + 66, + 64, + 8, + 63, + 10, + 11, + 71, + 76, + 37, + 36, + 42, + 75, + 79, + 6, + 74, + 39, + 49, + 43, + 34, + 35, + 77, + 38, + + //Link cursors + + 24625, + 24649, + 24827, + 24651, + 24583, + 24581, + 24582, + 24628, + 24650, + 24629, + 24732, + 24631, + 24584, + 24630, + 24626, + 24627, + 24632, + 24643, + 24828, + 24830, + 24829 +}; + +SkyMouse::SkyMouse(SkyDisk *skyDisk) { + + _skyDisk = skyDisk; + _mouseWidth = 6; + _mouseHeight = 6; + _maskWidth = 6; + _maskHeight = 6; + + _miceData = _skyDisk->loadFile(MICE_FILE, NULL); + _mouseData2 = _miceData; + + uint16 width = FROM_LE_16(((struct dataFileHeader *)_miceData)->s_width); + uint16 height = FROM_LE_16(((struct dataFileHeader *)_miceData)->s_height); + + _savedData = (byte *)malloc((width * height) + sizeof(struct dataFileHeader)); + + //load in the object mouse file + _objectMouseData = _skyDisk->loadFile(MICE_FILE + 1, NULL); + _mouseWidth = 1; + _mouseHeight = 1; + + //_systemFlags |= SF_MOUSE;; + +} + +SkyMouse::~SkyMouse( ){ + free (_miceData); + free (_savedData); + free (_objectMouseData); +} + +void SkyMouse::replaceMouseCursors(uint16 fileNo) { + + _skyDisk->loadFile(fileNo, _objectMouseData); + +} + +uint32 SkyMouse::fnBlankMouse(void) { + + _mouseXOff = 0; //re-align mouse + spriteMouse(MOUSE_BLANK, 0, 0); + + return 1; + +} + +void SkyMouse::lockMouse(void) { + + _lockMouseX = _aMouseX; + _lockMouseY = _aMouseY; + +} + +void SkyMouse::unlockMouse(void) { + + _aMouseX = _lockMouseX; + _aMouseY = _lockMouseY; + +} + +void SkyMouse::restoreMouseData(uint16 frameNum) { + warning("Stub: SkyMouse::restoreMouseData"); +} + +void SkyMouse::drawNewMouse() { + warning("Stub: SkyMouse::drawNewMouse"); + //calculateMouseValues(); + //saveMouseData(); + //drawMouse(); +} + +void SkyMouse::spriteMouse(uint16 frameNum, uint16 mouseX, uint16 mouseY) { + + //_mouseFlag |= MF_IN_INT; + _mouseType2 = frameNum; + _mouseOffsetX = mouseX; + _mouseOffsetY = mouseY; + + restoreMouseData(frameNum); + + byte *mouseData = _miceData; + uint32 pos = ((struct dataFileHeader *)mouseData)->s_sp_size * ((struct dataFileHeader *)mouseData)->s_sp_size; + pos += sizeof(struct dataFileHeader); + _mouseData2 = mouseData + pos; + + _mouseWidth = ((struct dataFileHeader *)mouseData)->s_width; + _mouseHeight = ((struct dataFileHeader *)mouseData)->s_height; + + drawNewMouse(); + + //_mouseFlag ^= (~_mouseFlag | MF_IN_INT); +} diff --git a/sky/mouse.h b/sky/mouse.h new file mode 100644 index 0000000000..3f136ffc36 --- /dev/null +++ b/sky/mouse.h @@ -0,0 +1,84 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2003 The ScummVM project + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + * + */ + +#ifndef __SkyMouse__ +#define __SkyMouse__ + +#include "stdafx.h" +#include "sky/disk.h" +#include "sky/struc.h" + +class SkyMouse { + +public: + SkyMouse(SkyDisk *skyDisk); + ~SkyMouse(void); + + void replaceMouseCursors(uint16 fileNo); + uint32 fnBlankMouse(void); + void lockMouse(void); + void unlockMouse(void); + void restoreMouseData(uint16 frameNum); + void drawNewMouse(void); + void spriteMouse(uint16 frameNum, uint16 mouseX, uint16 mouseY); + + +protected: + uint16 _aMouseX; //actual mouse coordinates + uint16 _aMouseY; + + 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 + + uint16 _mouseWidth; //mouse width and height + uint16 _mouseHeight; + + byte *_mousePosition; //current screen address of mouse + uint16 _maskWidth; //width on screen + uint16 _maskHeight; //height on screen + + byte *_savedData; //place for saved data + + uint32 _mouseFlag; //bit 0 set when in handler + //bit 1 set when screen data has been saved + //bit 2 set when we don't want to show mouse + + byte *_miceData; //address of mouse sprites + byte *_objectMouseData; //address of object mouse sprites + + uint16 _tMouseX; + uint16 _tMouseY; + + uint16 _mouseXOff; + + static uint32 _mouseObjectList[]; + + SkyDisk *_skyDisk; + +}; + +#endif //__SkyMouse__ diff --git a/sky/sky.cpp b/sky/sky.cpp index 0f311940ff..b5c4ed48cc 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -25,6 +25,7 @@ #include "sky/compact.h" #include "sky/logic.h" #include "sky/debug.h" +#include "sky/mouse.h" #include "common/file.h" #include "common/gameDetector.h" #include <errno.h> @@ -128,6 +129,7 @@ void SkyState::initialise(void) { _gameVersion = _skyDisk->determineGameVersion(); _skyText = getSkyText(); + _skyMouse = new SkyMouse(_skyDisk); initialiseScreen(); initVirgin(); @@ -137,7 +139,7 @@ void SkyState::initialise(void) { //initialiseRouter(); loadFixedItems(); _skyGrid = new SkyGrid(_skyDisk); - _skyLogic = new SkyLogic(_skyDisk, _skyGrid, _skyText); + _skyLogic = new SkyLogic(_skyDisk, _skyGrid, _skyText, _skyMusic, _skyMouse, _gameVersion); } void SkyState::initItemList() { @@ -35,6 +35,7 @@ #include "sky/musicbase.h" #include "sky/adlibmusic.h" #include "sky/gmmusic.h" +#include "sky/mouse.h" class SkyLogic; class SkyGrid; @@ -89,6 +90,7 @@ protected: SkyText *_skyText; SkyGrid *_skyGrid; SkyLogic *_skyLogic; + SkyMouse *_skyMouse; SkyMusicBase *_skyMusic; GameDetector *_detector; // necessary for music diff --git a/sky/skydefs.h b/sky/skydefs.h index 3c4af5454d..dc393cffb5 100644 --- a/sky/skydefs.h +++ b/sky/skydefs.h @@ -43,6 +43,7 @@ #define HIT_ID 38 #define THE_CHOSEN_ONE 52 #define TEXT1 54 +#define CUR_SECTION 144 //screen/grid defines #define GAME_SCREEN_WIDTH 320 @@ -4243,3 +4244,52 @@ #define C_ALT 84 #define C_REQUEST 86 +//system flags +#define SF_TIMER (1 << 0) // set if timer interrupt redirected +#define SF_GRAPHICS (1 << 1) // set if screen is in graphics mode +#define SF_MOUSE (1 << 2) // set if mouse handler installed +#define SF_KEYBOARD (1 << 3) // set if keyboard interrupt redirected +#define SF_MUSIC_BOARD (1 << 4) // set if a music board detected +#define SF_ROLAND (1 << 5) // set if roland board present +#define SF_ADLIB (1 << 6) // set if adlib board present +#define SF_SBLASTER (1 << 7) // set if sblaster present +#define SF_TANDY (1 << 8) // set if tandy present +#define SF_MUSIC_BIN (1 << 9) // set if music driver is loaded +#define SF_PLUS_FX (1 << 10) // set if extra fx module needed +#define SF_FX_OFF (1 << 11) // set if fx disabled +#define SF_MUS_OFF (1 << 12) // set if music disabled +#define SF_TIMER_TICK (1 << 13) // set every timer interupt + +// Status flags +#define SF_CHOOSING (1 << 14) // set when choosing text +#define SF_NO_SCROLL (1 << 15) // when set don't scroll +#define SF_SPEED (1 << 16) // when set allow speed options +#define SF_GAME_RESTORED (1 << 17) // set when game restored or restarted +#define SF_REPLAY_RST (1 << 18) // set when loading restart data (used to stop rewriting of replay file) +#define SF_SPEECH_FILE (1 << 19) // set when loading speech file +#define SF_VOC_PLAYING (1 << 20) // set when a voc file is playing +#define SF_PLAY_VOCS (1 << 21) // set when we want speech instead of text +#define SF_CRIT_ERR (1 << 22) // set when critical error routine trapped +#define SF_ALLOW_SPEECH (1 << 23) // speech allowes on cd sblaster version +#define SF_ALLOW_TEXT (1 << 24) // text allowed on cd sblaster version +#define SF_ALLOW_QUICK (1 << 25) // when set allow speed playing +#define SF_TEST_DISK (1 << 26) // set when loading files +#define SF_MOUSE_STOPPED (1 << 27) // set if mouse handler skipped to prevent stack overflow + +// Mouse flags +#define MF_NO_UPDATE (1 << 0) // set to disable mouse updating +#define MF_IN_INT (1 << 1) // set when in mouse interrupt +#define MF_SAVED (1 << 2) // set when saved data is valid +#define MF_GOT_INT (1 << 3) // set when mouse interrupt received + +#define MOUSE_NORMAL (1 << 1) // normal mouse +#define MOUSE_DISK (1 << 2) // disk mouse +#define MOUSE_DOWN (1 << 3) +#define MOUSE_RIGHT (1 << 4) // right pointer +#define MOUSE_LEFT (1 << 5) // left pointer +#define MOUSE_BLANK (1 << 6) // blank mouse +#define MOUSE_CROSS (1 << 7) // angry mouse +#define MOUSE_UP (1 << 8) // mouse up + + + |