Skip to content

Commit

Permalink
HOPKINS: Misc refactoring and renaming, remove some dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Feb 7, 2013
1 parent 901c4fa commit e96edd8
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 161 deletions.
18 changes: 7 additions & 11 deletions engines/hopkins/events.cpp
Expand Up @@ -313,8 +313,8 @@ int EventsManager::waitKeyPress() {
}

void EventsManager::VBL() {
signed int v11 = 0;
signed int v12 = 0;
int bottom = 0;
int right = 0;
int height = 0;
int width = 0;
int xp = 0;
Expand Down Expand Up @@ -355,12 +355,12 @@ void EventsManager::VBL() {
if (yp + _mouseSizeY >= mouseHeight + _vm->_graphicsManager._maxY)
height = _vm->_graphicsManager._maxY - mouseHeight - yp;
}
v12 = width + xp;
v11 = yp + height;
right = xp + width;
bottom = yp + height;
}
}

if (!_vm->_globals.PUBEXIT)
if (!_vm->_globals._linuxEndDemoFl)
_vm->_objectsManager.displaySprite();
if (!_mouseFl) {
updateCursor();
Expand All @@ -376,7 +376,7 @@ void EventsManager::VBL() {
}
} else if (yp < _vm->_graphicsManager._maxY && xp < _vm->_graphicsManager._maxX && width > 1 && height > 1) {
_vm->_eventsManager.updateCursor();
_vm->_graphicsManager.addVesaSegment(xp, yp, v12, v11);
_vm->_graphicsManager.addVesaSegment(xp, yp, right, bottom);
}

_vm->_globals._speed = 2;
Expand Down Expand Up @@ -432,12 +432,8 @@ void EventsManager::VBL() {
_vm->_graphicsManager.unlockScreen();
_vm->_graphicsManager.dstrect[0] = Common::Rect(0, 20, SCREEN_WIDTH, 460);

for (int i = 1; i < _vm->_globals.NBBLOC + 1; i++) {
if (_vm->_globals.BLOC[i]._activeFl)
_vm->_globals.BLOC[i]._activeFl = false;
}
_vm->_graphicsManager.RESET_SEGMENT_VESA();

_vm->_globals.NBBLOC = 0;
_startPos.x = _vm->_graphicsManager._scrollPosX;
_vm->_graphicsManager._scrollOffset = _vm->_graphicsManager._scrollPosX;
_vm->_graphicsManager._scrollPosX = _vm->_graphicsManager._scrollPosX;
Expand Down
5 changes: 1 addition & 4 deletions engines/hopkins/globals.cpp
Expand Up @@ -86,8 +86,6 @@ Globals::Globals() {
}
for (int i = 0; i < 300; ++i)
Common::fill((byte *)&ObjetW[i], (byte *)&ObjetW[i] + sizeof(ObjetWItem), 0);
for (int i = 0; i < 250; ++i)
Common::fill((byte *)&BLOC[i], (byte *)&BLOC[i] + sizeof(BlocItem), 0);
for (int i = 0; i < 25; ++i)
Common::fill((byte *)&Cache[i], (byte *)&Cache[i] + sizeof(CacheItem), 0);

Expand All @@ -108,7 +106,7 @@ Globals::Globals() {
// Initialize fields
_language = LANG_EN;

PUBEXIT = false;
_linuxEndDemoFl = false;
_speed = 1;
_oldFrameIndex = 0;
_oldDirection = 0;
Expand All @@ -131,7 +129,6 @@ Globals::Globals() {
_screenId = 0;
_prevScreenId = 0;
_characterMaxPosY = 0;
NBBLOC = 0;
_menuScrollType = 0;
_menuScrollSpeed = 0;
_menuSpeed = 0;
Expand Down
12 changes: 1 addition & 11 deletions engines/hopkins/globals.h
Expand Up @@ -127,14 +127,6 @@ struct ObjetWItem {
byte field7;
};

struct BlocItem {
uint16 _activeFl;
int _x1;
int _y1;
int _x2;
int _y2;
};

/**
* Mode for SortItem records
*/
Expand Down Expand Up @@ -289,7 +281,6 @@ class Globals {
LockAnimItem _lockedAnims[30];
VBobItem VBob[30];
ObjetWItem ObjetW[300];
BlocItem BLOC[250];
CacheItem Cache[25];
int BOBZONE[105];
bool BOBZONE_FLAG[105];
Expand All @@ -298,7 +289,7 @@ class Globals {
int _inventory[36];
SortItem _sortedDisplay[51];
Language _language;
bool PUBEXIT;
bool _linuxEndDemoFl;
int PERSO_TYPE;
uint _speed;
Common::String FICH_ZONE;
Expand Down Expand Up @@ -338,7 +329,6 @@ class Globals {
int _characterMaxPosY;
bool _disableInventFl;
bool NOMARCHE;
int NBBLOC;
byte *_optionDialogSpr;
bool _optionDialogFl;
int _menuDisplayType;
Expand Down
91 changes: 33 additions & 58 deletions engines/hopkins/graphics.cpp
Expand Up @@ -45,6 +45,7 @@ GraphicsManager::GraphicsManager() {
_scrollPosX = 0;
_largeScreenFl = false;
_oldScrollPosX = 0;
NBBLOC = 0;

_lineNbr2 = 0;
Agr_x = Agr_y = 0;
Expand All @@ -63,12 +64,16 @@ GraphicsManager::GraphicsManager() {
Red_x = Red_y = 0;
Red = 0;
_width = 0;
spec_largeur = 0;
_specialWidth = 0;

Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0);
Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0);
Common::fill(&_palette[0], &_palette[PALETTE_EXT_BLOCK_SIZE], 0);
Common::fill(&_oldPalette[0], &_oldPalette[PALETTE_EXT_BLOCK_SIZE], 0);

for (int i = 0; i < 250; ++i)
Common::fill((byte *)&BLOC[i], (byte *)&BLOC[i] + sizeof(BlocItem), 0);

}

GraphicsManager::~GraphicsManager() {
Expand Down Expand Up @@ -923,6 +928,14 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int
} while (rowCount2 != 1);
}

/**
* Draws a sprite onto the screen
* @param surface Destination surface
* @param spriteData The raw data for a sprite set
* @param xp X co-ordinate. For some reason, starts from 300 = first column
* @param yp Y co-ordinate. FOr some reason, starts from 300 = top row
* @param spriteIndex Index of the sprite to draw
*/
void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, int yp, int spriteIndex) {
// Get a pointer to the start of the desired sprite
const byte *spriteP = spriteData + 3;
Expand Down Expand Up @@ -1080,12 +1093,10 @@ void GraphicsManager::VISU_ALL() {
}

void GraphicsManager::RESET_SEGMENT_VESA() {
if (_vm->_globals.NBBLOC > 0) {
for (int idx = 0; idx != _vm->_globals.NBBLOC; idx++)
_vm->_globals.BLOC[idx]._activeFl = false;
for (int idx = 0; idx <= NBBLOC; idx++)
BLOC[idx]._activeFl = false;

_vm->_globals.NBBLOC = 0;
}
NBBLOC = 0;
}

// Add VESA Segment
Expand All @@ -1104,19 +1115,15 @@ void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) {
if (y1 < _minY)
y1 = _minY;

if (_vm->_globals.NBBLOC > 1) {
int16 blocIndex = 0;
do {
BlocItem &bloc = _vm->_globals.BLOC[blocIndex];
if (bloc._activeFl && tempX >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2)
addFlag = false;
++blocIndex;
} while (_vm->_globals.NBBLOC + 1 != blocIndex);
}
for (int blocIndex = 0; blocIndex <= NBBLOC; blocIndex++) {
BlocItem &bloc = BLOC[blocIndex];
if (bloc._activeFl && tempX >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2)
addFlag = false;
};

if (addFlag) {
assert(_vm->_globals.NBBLOC < 250);
BlocItem &bloc = _vm->_globals.BLOC[++_vm->_globals.NBBLOC];
assert(NBBLOC < 250);
BlocItem &bloc = BLOC[++NBBLOC];

bloc._activeFl = true;
bloc._x1 = tempX;
Expand All @@ -1128,13 +1135,13 @@ void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) {

// Display VESA Segment
void GraphicsManager::displayVesaSegment() {
if (_vm->_globals.NBBLOC == 0)
if (NBBLOC == 0)
return;

lockScreen();

for (int idx = 1; idx <= _vm->_globals.NBBLOC; ++idx) {
BlocItem &bloc = _vm->_globals.BLOC[idx];
for (int idx = 1; idx <= NBBLOC; ++idx) {
BlocItem &bloc = BLOC[idx];
Common::Rect &dstRect = dstrect[idx - 1];
if (!bloc._activeFl)
continue;
Expand Down Expand Up @@ -1163,10 +1170,10 @@ void GraphicsManager::displayVesaSegment() {
unlockScreen();
}

_vm->_globals.BLOC[idx]._activeFl = false;
BLOC[idx]._activeFl = false;
}

_vm->_globals.NBBLOC = 0;
NBBLOC = 0;
unlockScreen();
}

Expand Down Expand Up @@ -1516,7 +1523,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
_width = spriteWidth;
if (flipFl) {
byte *dest2P = spriteWidth + dest1P;
spec_largeur = spriteWidth;
_specialWidth = spriteWidth;
if (_posYClipped) {
if (_posYClipped >= spriteHeight1 || spriteHeight1 < 0)
return;
Expand Down Expand Up @@ -1548,12 +1555,12 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
++spritePixelsP;
--dest2P;
}
spritePixelsP = spec_largeur + spritePixelsCopy2P;
spritePixelsP = _specialWidth + spritePixelsCopy2P;
dest2P = _lineNbr2 + destCopy2P;
spriteHeight1 = yCtr2 - 1;
} while (yCtr2 != 1);
} else {
spec_largeur = spriteWidth;
_specialWidth = spriteWidth;
if (_posYClipped) {
if (_posYClipped >= spriteHeight1 || spriteHeight1 < 0)
return;
Expand Down Expand Up @@ -1583,7 +1590,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
++dest1P;
++spritePixelsP;
}
spritePixelsP = spec_largeur + spritePixelsCopyP;
spritePixelsP = _specialWidth + spritePixelsCopyP;
dest1P = _lineNbr2 + dest1CopyP;
spriteHeight1 = yCtr1 - 1;
} while (yCtr1 != 1);
Expand Down Expand Up @@ -1805,38 +1812,6 @@ void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) {
}
}

void GraphicsManager::Copy_Video_Vbe(const byte *src) {
assert(_videoPtr);
int destOffset = 0;
const byte *srcP = src;
for (;;) {
byte byteVal = *srcP;
if (*srcP < kByteStop)
break;
else {
if (byteVal == kByteStop)
return;
if (byteVal == k8bVal) {
destOffset += srcP[1];
byteVal = srcP[2];
srcP += 2;
} else if (byteVal == k16bVal) {
destOffset += READ_LE_UINT16(srcP + 1);
byteVal = srcP[3];
srcP += 3;
} else {
destOffset += READ_LE_UINT32(srcP + 1);
byteVal = srcP[5];
srcP += 5;
}
}

*((byte *)_videoPtr->pixels + destOffset) = byteVal;
++srcP;
++destOffset;
}
}

// Reduce Screen
void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int xp, int yp, int width, int height, int zoom) {
const byte *srcP = xp + _lineNbr2 * yp + srcSurface;
Expand Down

0 comments on commit e96edd8

Please sign in to comment.