Skip to content

Commit

Permalink
HOPKINS: Disabled VBL() method code and added ScummVM cursor display.
Browse files Browse the repository at this point in the history
I'm not yet sure whether VBL was only concerned with displaying the cursor, but it had some loops using the lItCounter, so it was causing infinite loops. Whatever else VBL actually does besides cursor display will have to be converted to a more ScummVM friendly implementation.
  • Loading branch information
dreammaster committed Sep 21, 2012
1 parent f20e411 commit 1a63930
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
49 changes: 49 additions & 0 deletions engines/hopkins/events.cpp
Expand Up @@ -105,11 +105,13 @@ bool EventsManager::BMOUSE() {

void EventsManager::MOUSE_OFF() {
souris_flag = false;
g_system->showMouse(false);
}

void EventsManager::MOUSE_ON() {
souris_on();
souris_flag = true;
g_system->showMouse(true);
}

void EventsManager::CHANGE_MOUSE(int id) {
Expand All @@ -124,6 +126,53 @@ void EventsManager::CHANGE_MOUSE(int id) {
if (OLD_ICONE != cursorId || !cursorId) {
OLD_ICONE = cursorId;
souris_n = cursorId;

// Backup the current sprite clipping bounds and reset them
Common::Rect clipBounds(_vm->_graphicsManager.min_x, _vm->_graphicsManager.min_y,
_vm->_graphicsManager.max_x, _vm->_graphicsManager.max_y);
_vm->_graphicsManager.min_x = _vm->_graphicsManager.min_y = 0;
_vm->_graphicsManager.max_x = _vm->_globals.OBJL;
_vm->_graphicsManager.max_y = _vm->_globals.OBJH;
int pitch = _vm->_graphicsManager.nbrligne2;
_vm->_graphicsManager.nbrligne2 = _vm->_globals.OBJL;

// Draw the cursor onto a temporary surface
byte *cursorSurface = new byte[_vm->_globals.OBJH * _vm->_globals.OBJL];
Common::fill(cursorSurface, cursorSurface + _vm->_globals.OBJH * _vm->_globals.OBJL, 0);
_vm->_graphicsManager.Sprite_Vesa(cursorSurface, pointeur_souris, 300, 300, cursorId);

// Reset the clipping bounds
_vm->_graphicsManager.min_x = clipBounds.left;
_vm->_graphicsManager.min_y = clipBounds.top;
_vm->_graphicsManager.max_x = clipBounds.right;
_vm->_graphicsManager.max_y = clipBounds.bottom;
_vm->_graphicsManager.nbrligne2 = pitch;

// Convert the cursor to the pixel format. At the moment, it's hardcoded
// to expect the game to be in 16-bit mode
uint16 *cursorPixels = new uint16[_vm->_globals.OBJH * _vm->_globals.OBJL];
const byte *srcP = cursorSurface;
uint16 *destP = cursorPixels;

for (int yp = 0; yp < _vm->_globals.OBJH; ++yp) {
const byte *lineSrcP = srcP;
uint16 *lineDestP = destP;

for (int xp = 0; xp < _vm->_globals.OBJL; ++xp)
*lineDestP++ = *(uint16 *)&_vm->_graphicsManager.PAL_PIXELS[*lineSrcP++ * 2];

srcP += _vm->_globals.OBJL;
destP += _vm->_globals.OBJL;
}

// Set the ScummVM cursor from the surface
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
g_system->setMouseCursor(cursorPixels, _vm->_globals.OBJL, _vm->_globals.OBJH,
0, 0, 0, true, &pixelFormat);

// Delete the cursor surface
delete[] cursorPixels;
delete[] cursorSurface;
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions engines/hopkins/graphics.cpp
Expand Up @@ -114,7 +114,6 @@ void GraphicsManager::SET_MODE(int width, int height) {
height = Reel_Zoom(height, SDL_ECHELLE);
}

//Graphics::PixelFormat pixelFormat16(2, 5, 5, 5, 0, 10, 5, 0, 0);
Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0);

if (bpp == 8) {
Expand Down Expand Up @@ -2131,6 +2130,8 @@ void GraphicsManager::Affiche_Perfect(byte *destSurface, const byte *srcData, in
}

void GraphicsManager::VBL() {
// Bulk of method currently disabled
/*
int a1 = 0;
signed __int16 v1;
int v2;
Expand Down Expand Up @@ -2249,6 +2250,10 @@ void GraphicsManager::VBL() {
do {
for (;;) {
// TODO: Figure out the purpose of this loop waiting on lItCounter..
// maybe it's for cursor animatoin?
_vm->_eventsManager.delay(10);
while (_vm->_eventsManager.CASSE || _vm->_globals.iRegul != 1) {
if (_vm->_eventsManager.CASSE != 1)
goto LABEL_63;
Expand Down Expand Up @@ -2365,7 +2370,7 @@ void GraphicsManager::VBL() {
}
LABEL_113:

*/
_vm->_soundManager.VERIF_SOUND();
return _vm->_eventsManager.CONTROLE_MES();
}
Expand Down

0 comments on commit 1a63930

Please sign in to comment.