[Scummvm-cvs-logs] CVS: scummvm/sky grid.h,NONE,1.1 grid.cpp,1.1,1.2 screen.cpp,1.7,1.8 sky.cpp,1.18,1.19 sky.h,1.14,1.15
Robert G?ffringmann
lavosspawn at users.sourceforge.net
Fri Apr 25 16:15:09 CEST 2003
Update of /cvsroot/scummvm/scummvm/sky
In directory sc8-pr-cvs1:/tmp/cvs-serv27209/sky
Modified Files:
grid.cpp screen.cpp sky.cpp sky.h
Added Files:
grid.h
Log Message:
added class SkyGrid (still untested)
--- NEW FILE: grid.h ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 The ScummVM project
* Copyright (C) 2003 Robert "LavosSpawn" Goeffringmann
*
* 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: /cvsroot/scummvm/scummvm/sky/grid.h,v 1.1 2003/04/25 23:14:41 lavosspawn Exp $
*
*/
#ifndef __SkyGrid__
#define __SkyGrid__
#include "stdafx.h"
#include "disk.h"
#include "struc.h"
#include "compact.h"
class SkyGrid {
public:
SkyGrid(SkyDisk *pDisk);
~SkyGrid(void);
// grid.asm routines
void loadGrids(void);
bool getGridValues(Compact *cpt, uint32 *resBitNum, uint32 *resWidth);
bool getGridValues(uint32 x, uint32 y, uint32 width, Compact *cpt, uint32 *resBitNum, uint32 *resWidth);
void removeObjectFromWalk(Compact *cpt);
void removeObjectFromWalk(uint32 bitNum, uint32 width);
void objectToWalk(Compact *cpt);
void objectToWalk(uint32 bitNum, uint32 width);
// function.asm
// note that this routine does the same as objectToWalk, it just doesn't get
// its x, y, width parameters from cpt.
void plotGrid(uint32 x, uint32 y, uint32 width, Compact *cpt);
// same here, it's basically the same as removeObjectFromWalk
void removeGrid(uint32 x, uint32 y, uint32 width, Compact *cpt);
private:
static int8 _gridConvertTable[];
uint8 *_gameGrids;
SkyDisk *_disk;
};
#endif //__SkyGrid__
Index: grid.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/grid.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- grid.cpp 7 Mar 2003 14:52:22 -0000 1.1
+++ grid.cpp 25 Apr 2003 23:14:40 -0000 1.2
@@ -1,5 +1,6 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 The ScummVM project
+ * Copyright (C) 2003 Robert "LavosSpawn" Goeffringmann
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -19,13 +20,11 @@
*
*/
-#include "stdafx.h"
-#include "sky/sky.h"
-#include "sky/skydefs.h"
+#include "grid.h"
#define GRID_FILE_START 60000
-int8 gridConvertTable[] = {
+int8 SkyGrid::_gridConvertTable[] = {
1, //1
2, //2
@@ -125,8 +124,114 @@
69, //96
};
-void SkyState::initialiseGrids() {
+/*void SkyState::initialiseGrids() {
- _gameGrids = (byte *)malloc(TOT_NO_GRIDS * GRID_SIZE);
+ _gameGrids = (uint8 *)malloc(TOT_NO_GRIDS * GRID_SIZE);
+}*/
+
+SkyGrid::SkyGrid(SkyDisk *pDisk) {
+
+ _gameGrids = (uint8 *)malloc(TOT_NO_GRIDS * GRID_SIZE);
+ _disk = pDisk;
+}
+
+SkyGrid::~SkyGrid(void) {
+
+ free(_gameGrids);
+}
+
+void SkyGrid::loadGrids(void) {
+
+ // no endian conversion necessary as I'm using uint8* instead of uint32*
+ for (uint8 cnt = 0; cnt < TOT_NO_GRIDS; cnt++)
+ _disk->loadFile(GRID_FILE_START + cnt, _gameGrids + (cnt * GRID_SIZE));
+ // todo: add BASS hack for Reich's door (grid.asm, load_grids proc)
}
+bool SkyGrid::getGridValues(Compact *cpt, uint32 *resBitNum, uint32 *resWidth) {
+
+ uint32 width = *(uint32*)SkyCompact::getCompactElem(cpt,cpt->extCompact->megaSet+C_GRID_WIDTH);
+ return getGridValues(cpt->xcood, cpt->ycood, width, cpt, resBitNum, resWidth);
+}
+
+bool SkyGrid::getGridValues(uint32 x, uint32 y, uint32 width, Compact *cpt, uint32 *resBitNum, uint32 *resWidth) {
+
+ uint32 bitPos;
+ if (y < TOP_LEFT_Y) return false; // off screen
+ y -= TOP_LEFT_Y;
+ y >>= 3; // convert to blocks
+ if (y >= GRID_Y) return false; // off screen
+ bitPos = y * 40;
+ width++;
+ x >>= 3; // convert to blocks
+
+ int32 x_signed = (x - (TOP_LEFT_X >> 3));
+ if (x_signed < 0) { // at least partially off screen
+ if (x_signed + width <= 0) return false; // completely off screen
+ else width += x_signed; // adjust width to visible part and continue
+ // x_signed is negative, so it's +=
+ }
+ if ((GAME_SCREEN_WIDTH >> 3) <= x_signed) return false; // off screen
+ if ((GAME_SCREEN_WIDTH >> 3) < x_signed + width) { // at least partially of screen
+ if ((uint32)((GAME_SCREEN_WIDTH >> 3) - x_signed) >= width) return false; // off screen
+ else width -= (GAME_SCREEN_WIDTH >> 3) - x_signed; // adjust width
+ }
+ bitPos += x_signed;
+ int32 screenGridOfs = _gridConvertTable[cpt->screen] * GRID_SIZE;
+ bitPos += (screenGridOfs << 3); // convert to bits
+ int32 tmpBits = bitPos&0x1F;
+ bitPos &= ~0x1F; // divide into dword address and bit number
+ tmpBits = ~(tmpBits-0x1F); // NOTE THE ~ !!
+ bitPos += tmpBits; // anyone have an idea what this calculation is meant for?!
+ *resBitNum = bitPos;
+ *resWidth = width;
+ return true;
+}
+
+void SkyGrid::removeObjectFromWalk(Compact *cpt) {
+
+ uint32 bitNum, width;
+ if (getGridValues(cpt, &bitNum, &width))
+ removeObjectFromWalk(bitNum, width);
+}
+
+void SkyGrid::removeObjectFromWalk(uint32 bitNum, uint32 width) {
+
+ for (uint32 cnt = 0; cnt < width; cnt++) {
+ _gameGrids[bitNum >> 3] &= ~(1 << (bitNum & 0x7));
+ bitNum--;
+ if ((bitNum & 0x1F) == 0)
+ bitNum += 0x3F;
+ }
+}
+
+void SkyGrid::objectToWalk(Compact *cpt) {
+
+ uint32 bitNum, width;
+ if (getGridValues(cpt, &bitNum, &width))
+ objectToWalk(bitNum, width);
+}
+
+void SkyGrid::objectToWalk(uint32 bitNum, uint32 width) {
+
+ for (uint32 cnt = 0; cnt < width; cnt++) {
+ _gameGrids[bitNum >> 3] |= (1 << (bitNum & 0x7));
+ bitNum--;
+ if ((bitNum & 0x1F) == 0)
+ bitNum += 0x3F;
+ }
+}
+
+void SkyGrid::plotGrid(uint32 x, uint32 y, uint32 width, Compact *cpt) {
+
+ uint32 resBitPos, resWidth;
+ if (getGridValues(x, y, width-1, cpt, &resBitPos, &resWidth))
+ objectToWalk(resBitPos, resWidth);
+}
+
+void SkyGrid::removeGrid(uint32 x, uint32 y, uint32 width, Compact *cpt) {
+
+ uint32 resBitPos, resWidth;
+ if (getGridValues(x, y, width, cpt, &resBitPos, &resWidth))
+ removeObjectFromWalk(resBitPos, resWidth);
+}
Index: screen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/screen.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- screen.cpp 24 Mar 2003 10:55:58 -0000 1.7
+++ screen.cpp 25 Apr 2003 23:14:40 -0000 1.8
@@ -57,7 +57,7 @@
_system->init_size(FULL_SCREEN_WIDTH, FULL_SCREEN_HEIGHT);
_backScreen = (uint8 *)malloc(FULL_SCREEN_WIDTH * FULL_SCREEN_HEIGHT);
- _gameGrid = (uint8 *)malloc(GRID_X * GRID_Y * 2);
+ //_gameGrid = (uint8 *)malloc(GRID_X * GRID_Y * 2);
_workPalette = (uint8 *)malloc(VGA_COLOURS * 3);
//blank the first 240 colors of the palette
Index: sky.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sky.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- sky.cpp 25 Apr 2003 15:41:14 -0000 1.18
+++ sky.cpp 25 Apr 2003 23:14:40 -0000 1.19
@@ -114,9 +114,9 @@
//initMouse();
initItemList();
//initScript();
- initialiseGrids();
//initialiseRouter();
_skyText = getSkyText();
+ _grid = new SkyGrid(_skyDisk);
_skyLogic = new SkyLogic(_skyDisk);
}
Index: sky.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sky.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- sky.h 25 Apr 2003 15:17:49 -0000 1.14
+++ sky.h 25 Apr 2003 23:14:41 -0000 1.15
@@ -32,8 +32,10 @@
#include "sky/disk.h"
#include "sky/struc.h"
#include "sky/skymusic.h"
+#include "sky/grid.h"
class SkyLogic;
+class SkyGrid;
class SkyState : public Engine {
void errorString(const char *buf_input, char *buf_output);
@@ -70,6 +72,7 @@
SkySound *_sound;
SkyDisk *_skyDisk;
SkyText *_skyText;
+ SkyGrid *_grid;
SkyLogic *_skyLogic;
SkyMusic *_music;
@@ -79,9 +82,6 @@
byte *_workPalette;
byte *_halfPalette;
byte *_scrollAddr;
-
- byte *_gameGrid;
- byte *_gameGrids;
public:
SkyState(GameDetector *detector, OSystem *syst);
More information about the Scummvm-git-logs
mailing list