aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2012-11-01 22:35:33 +1100
committerPaul Gilbert2012-11-01 22:35:33 +1100
commite9c9b8b428b66968bd8e88eb718061b1c8fd041d (patch)
treef7a6cafc254c08292a6ff2403de5cf75087a855e /engines
parentbf3f30bc140e87a933f929986f4ec500a8b7abf4 (diff)
downloadscummvm-rg350-e9c9b8b428b66968bd8e88eb718061b1c8fd041d.tar.gz
scummvm-rg350-e9c9b8b428b66968bd8e88eb718061b1c8fd041d.tar.bz2
scummvm-rg350-e9c9b8b428b66968bd8e88eb718061b1c8fd041d.zip
HOPKINS: Refactoring to show the selected inventory item using ScummVM cursor manager
Diffstat (limited to 'engines')
-rw-r--r--engines/hopkins/events.cpp118
-rw-r--r--engines/hopkins/events.h3
-rw-r--r--engines/hopkins/globals.cpp6
-rw-r--r--engines/hopkins/globals.h1
-rw-r--r--engines/hopkins/graphics.cpp36
-rw-r--r--engines/hopkins/graphics.h2
-rw-r--r--engines/hopkins/objects.cpp6
7 files changed, 95 insertions, 77 deletions
diff --git a/engines/hopkins/events.cpp b/engines/hopkins/events.cpp
index 0b3d252f57..a65e27e186 100644
--- a/engines/hopkins/events.cpp
+++ b/engines/hopkins/events.cpp
@@ -47,11 +47,16 @@ EventsManager::EventsManager() {
GAME_KEY = KEY_NONE;
btsouris = 0;
OLD_ICONE = 0;
+ Bufferobjet = NULL;
_priorCounterTime = 0;
_priorFrameTime = 0;
}
+EventsManager::~EventsManager() {
+ _vm->_globals.dos_free2(Bufferobjet);
+}
+
void EventsManager::setParent(HopkinsEngine *vm) {
_vm = vm;
}
@@ -141,55 +146,7 @@ void EventsManager::CHANGE_MOUSE(int id) {
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;
- }
-
- // Calculate the X offset within the pointer image to the actual cursor data
- int xOffset = !mouse_linux ? 10 : 20;
-
- // Set the ScummVM cursor from the surface
- Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
- g_system->setMouseCursor(cursorPixels, _vm->_globals.OBJL, _vm->_globals.OBJH,
- xOffset, 0, 0, true, &pixelFormat);
-
- // Delete the cursor surface
- delete[] cursorPixels;
- delete[] cursorSurface;
+ updateCursor();
}
}
}
@@ -370,11 +327,13 @@ LABEL_45:
if (yp + v13 > _vm->_graphicsManager.max_y)
v13 -= yp + v13 - _vm->_graphicsManager.max_y;
if (v14 > 1 && v13 > 1) {
+ _vm->_eventsManager.updateCursor();
/* Commented out in favour of using ScummVM cursor display
_vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.cache_souris, v15, yp, v14, v13);
-*/
+
_vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.Bufferobjet, v15 + 300, yp + 300, 0, 0, 0, 0);
_vm->_graphicsManager.Ajoute_Segment_Vesa(v15, yp, v14 + v15, yp + v13);
+*/
}
}
goto LABEL_54;
@@ -498,4 +457,63 @@ LABEL_113:
CONTROLE_MES();
}
+void EventsManager::updateCursor() {
+ // 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;
+
+ // Create the temporary cursor surface
+ byte *cursorSurface = new byte[_vm->_globals.OBJH * _vm->_globals.OBJL];
+ Common::fill(cursorSurface, cursorSurface + _vm->_globals.OBJH * _vm->_globals.OBJL, 0);
+
+ if (btsouris != 23) {
+ // Draw standard cursor
+ _vm->_graphicsManager.Sprite_Vesa(cursorSurface, pointeur_souris, 300, 300, souris_n);
+ } else {
+ // Draw the active inventory object
+ _vm->_graphicsManager.Affiche_Perfect(cursorSurface, Bufferobjet, 300, 300, 0, 0, 0, 0);
+ }
+
+ // 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;
+ }
+
+ // Calculate the X offset within the pointer image to the actual cursor data
+ int xOffset = !mouse_linux ? 10 : 20;
+
+ // Set the ScummVM cursor from the surface
+ Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
+ g_system->setMouseCursor(cursorPixels, _vm->_globals.OBJL, _vm->_globals.OBJH,
+ xOffset, 0, 0, true, &pixelFormat);
+
+ // Delete the cursor surface
+ delete[] cursorPixels;
+ delete[] cursorSurface;
+}
+
} // End of namespace Hopkins
diff --git a/engines/hopkins/events.h b/engines/hopkins/events.h
index 364a74fcf8..158e08c8de 100644
--- a/engines/hopkins/events.h
+++ b/engines/hopkins/events.h
@@ -43,6 +43,7 @@ private:
void pollEvents();
void handleKey(Common::Event &event);
void checkForNextFrameCounter();
+ void updateCursor();
public:
bool souris_flag;
bool mouse_linux;
@@ -64,8 +65,10 @@ public:
bool NOESC;
DIALOG_KEY GAME_KEY;
int btsouris;
+ byte *Bufferobjet;
public:
EventsManager();
+ ~EventsManager();
void setParent(HopkinsEngine *vm);
void INSTALL_SOURIS();
diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp
index 1ed40701e1..1717ea8110 100644
--- a/engines/hopkins/globals.cpp
+++ b/engines/hopkins/globals.cpp
@@ -193,7 +193,6 @@ Globals::Globals() {
essai0 = NULL;
essai1 = NULL;
essai2 = NULL;
- Bufferobjet = NULL;
inventaire2 = NULL;
GESTE = NULL;
INVENTAIRE_OBJET = NULL;
@@ -255,7 +254,6 @@ Globals::~Globals() {
dos_free2(SPRITE_ECRAN);
dos_free2((byte *)SAUVEGARDE);
dos_free2(BUFFERTAPE);
- dos_free2(Bufferobjet);
dos_free2(inventaire2);
dos_free2(GESTE);
dos_free2(INVENTAIRE_OBJET);
@@ -324,7 +322,7 @@ void Globals::clearAll() {
ADR_FICHIER_OBJ = g_PTRNUL;
NUM_FICHIER_OBJ = 0;
Bufferdecor = g_PTRNUL;
- Bufferobjet = g_PTRNUL;
+ _vm->_eventsManager.Bufferobjet = g_PTRNUL;
_vm->_dialogsManager.Winventaire = g_PTRNUL;
_vm->_dialogsManager.inventaire2 = g_PTRNUL;
COUCOU = g_PTRNUL;
@@ -375,7 +373,7 @@ void Globals::clearAll() {
largeur_boite = 240;
TEXTE_FORMATE = 300;
- Bufferobjet = dos_malloc2(2500);
+ _vm->_eventsManager.Bufferobjet = dos_malloc2(2500);
INVENTAIRE_OBJET = dos_malloc2(2500);
ADR_FICHIER_OBJ = g_PTRNUL;
diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h
index 0110e674e8..204c05e4ed 100644
--- a/engines/hopkins/globals.h
+++ b/engines/hopkins/globals.h
@@ -367,7 +367,6 @@ public:
int16 *essai0;
int16 *essai1;
int16 *essai2;
- byte *Bufferobjet;
byte *inventaire2;
byte *GESTE;
int OBJET_EN_COURS;
diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp
index 718a428ba6..72c01c2c37 100644
--- a/engines/hopkins/graphics.cpp
+++ b/engines/hopkins/graphics.cpp
@@ -1710,7 +1710,7 @@ int GraphicsManager::Asm_Reduc(int v, int percentage) {
}
// Display 'Perfect?'
-void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int a6, int a7, int a8) {
+void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int zoom1, int zoom2, int modeFlag) {
const byte *spriteStartP;
int i;
const byte *spriteSizeP;
@@ -1796,16 +1796,16 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
if ((uint16)yp300 < (uint16)(max_y + 300)) {
clip_y1 = max_y + 300 - yp300;
dest1P = xp300 + nbrligne2 * (yp300 - 300) - 300 + surface;
- if (a7) {
+ if (zoom2) {
Compteur_y = 0;
Agr_x = 0;
Agr_y = 0;
Agr_Flag_y = 0;
Agr_Flag_x = 0;
Largeur = spriteWidth;
- v20 = Asm_Zoom(spriteWidth, a7);
- v22 = Asm_Zoom(v21, a7);
- if (a8) {
+ v20 = Asm_Zoom(spriteWidth, zoom2);
+ v22 = Asm_Zoom(v21, zoom2);
+ if (modeFlag) {
v29 = v20 + dest1P;
if (clip_y) {
if ((uint16)clip_y >= v22)
@@ -1814,7 +1814,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
v52 = v20;
v30 = 0;
v31 = (uint16)clip_y;
- while (Asm_Zoom(v30 + 1, a7) < v31)
+ while (Asm_Zoom(v30 + 1, zoom2) < v31)
;
v20 = v52;
spritePixelsP += Largeur * v30;
@@ -1833,7 +1833,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
v29 -= v32;
v62 = v22;
v33 = 0;
- while (Asm_Zoom(v33 + 1, a7) < v32)
+ while (Asm_Zoom(v33 + 1, zoom2) < v32)
;
v34 = v33;
v22 = v62;
@@ -1855,7 +1855,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
--v29;
++spritePixelsP;
if (!Agr_Flag_x)
- Agr_x = a7 + Agr_x;
+ Agr_x = zoom2 + Agr_x;
if ((uint16)Agr_x < 0x64u)
break;
Agr_x = Agr_x - 100;
@@ -1873,7 +1873,7 @@ R_Aff_Zoom_Larg_Cont1:
v29 = nbrligne2 + v53;
++Compteur_y;
if (!Agr_Flag_y)
- Agr_y = a7 + Agr_y;
+ Agr_y = zoom2 + Agr_y;
if ((uint16)Agr_y < 0x64u)
break;
Agr_y = Agr_y - 100;
@@ -1894,7 +1894,7 @@ R_Aff_Zoom_Larg_Cont1:
v49 = v20;
v23 = 0;
v24 = (uint16)clip_y;
- while (Asm_Zoom(v23 + 1, a7) < v24)
+ while (Asm_Zoom(v23 + 1, zoom2) < v24)
;
v20 = v49;
spritePixelsP += Largeur * v23;
@@ -1910,7 +1910,7 @@ R_Aff_Zoom_Larg_Cont1:
v50 = v20;
v25 = (uint16)clip_x;
v26 = 0;
- while (Asm_Zoom(v26 + 1, a7) < v25)
+ while (Asm_Zoom(v26 + 1, zoom2) < v25)
;
v27 = v26;
v22 = v59;
@@ -1935,7 +1935,7 @@ R_Aff_Zoom_Larg_Cont1:
++dest1P;
++spritePixelsP;
if (!Agr_Flag_x)
- Agr_x = a7 + Agr_x;
+ Agr_x = zoom2 + Agr_x;
if ((uint16)Agr_x < 0x64u)
break;
Agr_x = Agr_x - 100;
@@ -1952,7 +1952,7 @@ Aff_Zoom_Larg_Cont1:
spritePixelsP = Largeur + v45;
dest1P = nbrligne2 + v51;
if (!Agr_Flag_y)
- Agr_y = a7 + Agr_y;
+ Agr_y = zoom2 + Agr_y;
if ((uint16)Agr_y < 0x64u)
break;
Agr_y = Agr_y - 100;
@@ -1966,15 +1966,15 @@ Aff_Zoom_Larg_Cont1:
v22 = v60 - 1;
} while (v60 != 1);
}
- } else if (a6) {
+ } else if (zoom1) {
Compteur_y = 0;
Red_x = 0;
Red_y = 0;
Largeur = spriteWidth;
- Red = a6;
- if (a6 < 100) {
+ Red = zoom1;
+ if (zoom1 < 100) {
v37 = Asm_Reduc(spriteWidth, Red);
- if (a8) {
+ if (modeFlag) {
v40 = v37 + dest1P;
do {
v65 = spriteHeight2;
@@ -2042,7 +2042,7 @@ Aff_Zoom_Larg_Cont1:
} else {
Largeur = spriteWidth;
Compteur_y = 0;
- if (a8) {
+ if (modeFlag) {
dest2P = spriteWidth + dest1P;
spec_largeur = spriteWidth;
if (clip_y) {
diff --git a/engines/hopkins/graphics.h b/engines/hopkins/graphics.h
index 8b93efcbc6..5112672848 100644
--- a/engines/hopkins/graphics.h
+++ b/engines/hopkins/graphics.h
@@ -169,7 +169,7 @@ public:
void Restore_Mem(byte *destSurface, const byte *src, int xp, int yp, int width, int height);
int Reel_Zoom(int v, int percentage);
int Reel_Reduc(int v, int percentage);
- void Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int a6, int a7, int a8);
+ void Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int zoom1, int zoom2, int modeFlag);
void AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int spriteIndex);
void SCOPY(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY);
void Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned int width, int height, byte *destSurface, int destX, int destY);
diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp
index 60e64c2b23..e2ad687bf9 100644
--- a/engines/hopkins/objects.cpp
+++ b/engines/hopkins/objects.cpp
@@ -101,7 +101,7 @@ void ObjectsManager::setParent(HopkinsEngine *vm) {
// Change Object
byte *ObjectsManager::CHANGE_OBJET(int objIndex) {
byte *result = CAPTURE_OBJET(objIndex, 1);
- _vm->_globals.Bufferobjet = result;
+ _vm->_eventsManager.Bufferobjet = result;
_vm->_globals.Nouv_objet = 1;
_vm->_globals.OBJET_EN_COURS = objIndex;
return result;
@@ -141,8 +141,8 @@ byte *ObjectsManager::CAPTURE_OBJET(int objIndex, int mode) {
break;
case 1:
- sprite_alone(_vm->_globals.ADR_FICHIER_OBJ, _vm->_globals.Bufferobjet, val2);
- dataP = _vm->_globals.Bufferobjet;
+ sprite_alone(_vm->_globals.ADR_FICHIER_OBJ, _vm->_eventsManager.Bufferobjet, val2);
+ dataP = _vm->_eventsManager.Bufferobjet;
break;
case 3: