Skip to content

Commit

Permalink
HOPKINS: Merge two zoom in and out functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Dec 15, 2012
1 parent 0ec1994 commit d7d8c19
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 105 deletions.
12 changes: 6 additions & 6 deletions engines/hopkins/events.cpp
Expand Up @@ -460,17 +460,17 @@ void EventsManager::VBL() {
_vm->_graphicsManager.DD_Lock();
if (_vm->_graphicsManager.SDL_ECHELLE) {
if (_vm->_graphicsManager.Winbpp == 2) {
int v5 = _vm->_graphicsManager.Reel_Zoom(0x14u, _vm->_graphicsManager.SDL_ECHELLE);
int v5 = _vm->_graphicsManager.zoomIn(0x14u, _vm->_graphicsManager.SDL_ECHELLE);
_vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_BUFFER, v4, 20, SCREEN_WIDTH, 440, 0, v5);
} else {
int v6 = _vm->_graphicsManager.Reel_Zoom(0x14u, _vm->_graphicsManager.SDL_ECHELLE);
int v6 = _vm->_graphicsManager.zoomIn(0x14u, _vm->_graphicsManager.SDL_ECHELLE);
_vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_BUFFER, v4, 20, SCREEN_WIDTH, 440, 0, v6);
}
_vm->_graphicsManager.DD_Unlock();
_vm->_graphicsManager.dstrect[0].left = _vm->_graphicsManager.Reel_Zoom(0, _vm->_graphicsManager.SDL_ECHELLE);
_vm->_graphicsManager.dstrect[0].top = _vm->_graphicsManager.Reel_Zoom(0x14u, _vm->_graphicsManager.SDL_ECHELLE);
_vm->_graphicsManager.dstrect[0].setWidth(_vm->_graphicsManager.Reel_Zoom(0x280u, _vm->_graphicsManager.SDL_ECHELLE));
_vm->_graphicsManager.dstrect[0].setHeight(_vm->_graphicsManager.Reel_Zoom(0x1B8u, _vm->_graphicsManager.SDL_ECHELLE));
_vm->_graphicsManager.dstrect[0].left = _vm->_graphicsManager.zoomIn(0, _vm->_graphicsManager.SDL_ECHELLE);
_vm->_graphicsManager.dstrect[0].top = _vm->_graphicsManager.zoomIn(0x14u, _vm->_graphicsManager.SDL_ECHELLE);
_vm->_graphicsManager.dstrect[0].setWidth(_vm->_graphicsManager.zoomIn(0x280u, _vm->_graphicsManager.SDL_ECHELLE));
_vm->_graphicsManager.dstrect[0].setHeight(_vm->_graphicsManager.zoomIn(0x1B8u, _vm->_graphicsManager.SDL_ECHELLE));
} else {
if (_vm->_graphicsManager.Winbpp == 2)
_vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_BUFFER, v4, 20, SCREEN_WIDTH, 440, 0, 20);
Expand Down
52 changes: 25 additions & 27 deletions engines/hopkins/graphics.cpp
Expand Up @@ -122,8 +122,8 @@ void GraphicsManager::SET_MODE(int width, int height) {
bpp = 16;

if (SDL_ECHELLE) {
width = Reel_Zoom(width, SDL_ECHELLE);
height = Reel_Zoom(height, SDL_ECHELLE);
width = zoomIn(width, SDL_ECHELLE);
height = zoomIn(height, SDL_ECHELLE);
}

Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0);
Expand Down Expand Up @@ -1587,18 +1587,18 @@ void GraphicsManager::Affiche_Segment_Vesa() {

if (Winbpp == 2) {
m_scroll16A(VESA_BUFFER, xp, yp, width, height,
Reel_Zoom(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE));
zoomIn(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), zoomIn(yp, SDL_ECHELLE));
} else {
m_scroll2A(VESA_BUFFER, xp, yp, width, height,
Reel_Zoom(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE));
zoomIn(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), zoomIn(yp, SDL_ECHELLE));
}

DD_Unlock();

dstRect.left = Reel_Zoom(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE);
dstRect.top = Reel_Zoom(yp, SDL_ECHELLE);
dstRect.setWidth(Reel_Zoom(width, SDL_ECHELLE));
dstRect.setHeight(Reel_Zoom(height, SDL_ECHELLE));
dstRect.left = zoomIn(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE);
dstRect.top = zoomIn(yp, SDL_ECHELLE);
dstRect.setWidth(zoomIn(width, SDL_ECHELLE));
dstRect.setHeight(zoomIn(height, SDL_ECHELLE));
} else {
// WORKAROUND: Original didn't lock the screen for access
DD_Lock();
Expand Down Expand Up @@ -1763,22 +1763,20 @@ void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, in
} while (yCtr != 1);
}

int GraphicsManager::Reel_Zoom(int v, int percentage) {
return Asm_Zoom(v, percentage);
}

int GraphicsManager::Asm_Zoom(int v, int percentage) {
/**
* Compute the value of a parameter plus a given percentage
*/
int GraphicsManager::zoomIn( int v, int percentage ) {
if (v)
v += percentage * (long int)v / 100;

return v;
}

int GraphicsManager::Reel_Reduc(int v, int percentage) {
return Asm_Reduc(v, percentage);
}

int GraphicsManager::Asm_Reduc(int v, int percentage) {
/**
* Compute the value of a parameter minus a given percentage
*/
int GraphicsManager::zoomOut(int v, int percentage) {
if (v)
v -= percentage * (long int)v / 100;

Expand Down Expand Up @@ -1830,8 +1828,8 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
Agr_Flag_y = 0;
Agr_Flag_x = 0;
Largeur = spriteWidth;
int v20 = Asm_Zoom(spriteWidth, zoom2);
int v22 = Asm_Zoom(spriteHeight1, zoom2);
int v20 = zoomIn(spriteWidth, zoom2);
int v22 = zoomIn(spriteHeight1, zoom2);
if (modeFlag) {
v29 = v20 + dest1P;
if (clip_y) {
Expand All @@ -1841,7 +1839,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
int v52 = v20;
int v30 = 0;
int v31 = (uint16)clip_y;
while (Asm_Zoom(v30 + 1, zoom2) < v31)
while (zoomIn(v30 + 1, zoom2) < v31)
;
v20 = v52;
spritePixelsP += Largeur * v30;
Expand All @@ -1860,7 +1858,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
v29 -= v32;
int v62 = v22;
int v33 = 0;
while (Asm_Zoom(v33 + 1, zoom2) < v32)
while (zoomIn(v33 + 1, zoom2) < v32)
;
int v34 = v33;
v22 = v62;
Expand Down Expand Up @@ -1922,7 +1920,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
int v49 = v20;
int v23 = 0;
int v24 = (uint16)clip_y;
while (Asm_Zoom(v23 + 1, zoom2) < v24)
while (zoomIn(v23 + 1, zoom2) < v24)
;
v20 = v49;
spritePixelsP += Largeur * v23;
Expand All @@ -1938,7 +1936,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
int v50 = v20;
int v25 = (uint16)clip_x;
int v26 = 0;
while (Asm_Zoom(v26 + 1, zoom2) < v25)
while (zoomIn(v26 + 1, zoom2) < v25)
;
int v27 = v26;
v22 = v59;
Expand Down Expand Up @@ -2003,7 +2001,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp
Largeur = spriteWidth;
Red = zoom1;
if (zoom1 < 100) {
int v37 = Asm_Reduc(spriteWidth, Red);
int v37 = zoomOut(spriteWidth, Red);
if (modeFlag) {
v40 = v37 + dest1P;
do {
Expand Down Expand Up @@ -2480,8 +2478,8 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int
Red_x = 0;
Red_y = 0;
if (zoom < 100) {
Reduc_Ecran_L = Asm_Reduc(width, Red);
Reduc_Ecran_H = Asm_Reduc(height, Red);
Reduc_Ecran_L = zoomOut(width, Red);
Reduc_Ecran_H = zoomOut(height, Red);

for (int yCtr = 0; yCtr < height; ++yCtr, srcP += nbrligne2) {
Red_y += Red;
Expand Down
6 changes: 2 additions & 4 deletions engines/hopkins/graphics.h
Expand Up @@ -52,8 +52,6 @@ class GraphicsManager {
HopkinsEngine *_vm;

void CHARGE_ECRAN(const Common::String &file);
int Asm_Zoom(int v, int percentage);
int Asm_Reduc(int v, int percentage);
public:
int _lockCtr;
bool SDL_MODEYES;
Expand Down Expand Up @@ -177,8 +175,8 @@ class GraphicsManager {
void CopyAsm(const byte *surface);
void CopyAsm16(const byte *surface);
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);
int zoomIn(int v, int percentage);
int zoomOut(int v, int percentage);
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);
Expand Down
24 changes: 12 additions & 12 deletions engines/hopkins/lines.cpp
Expand Up @@ -3218,11 +3218,11 @@ int LinesManager::SMOOTH_MOVE(int a3, int a4, int a5, int a6) {
v28 = -v26;
v48 = _vm->_globals.STAILLE[v63];
v45 = v63;
v25 = _vm->_graphicsManager.Reel_Reduc(v25, v28);
v25 = _vm->_graphicsManager.zoomOut(v25, v28);
v29 = v27;
if ((v27 & 0x80000000u) != 0)
v29 = -v27;
v40 = _vm->_graphicsManager.Reel_Reduc(v40, v29);
v40 = _vm->_graphicsManager.zoomOut(v40, v29);
v63 = v45;
v26 = v48;
}
Expand All @@ -3232,11 +3232,11 @@ int LinesManager::SMOOTH_MOVE(int a3, int a4, int a5, int a6) {
if (v26 < 0)
v31 = -v26;
v46 = v63;
v25 = _vm->_graphicsManager.Reel_Zoom(v25, v31);
v25 = _vm->_graphicsManager.zoomIn(v25, v31);
v32 = v30;
if ((v30 & 0x80000000u) != 0)
v32 = -v30;
v40 = _vm->_graphicsManager.Reel_Zoom(v40, v32);
v40 = _vm->_graphicsManager.zoomIn(v40, v32);
v63 = v46;
}
v33 = v63 + v40;
Expand Down Expand Up @@ -3281,11 +3281,11 @@ int LinesManager::SMOOTH_MOVE(int a3, int a4, int a5, int a6) {
v17 = -v15;
v47 = _vm->_globals.STAILLE[v63];
v43 = v63;
v14 = _vm->_graphicsManager.Reel_Reduc(v14, v17);
v14 = _vm->_graphicsManager.zoomOut(v14, v17);
v18 = v16;
if ((v16 & 0x80000000u) != 0)
v18 = -v16;
v39 = _vm->_graphicsManager.Reel_Reduc(v39, v18);
v39 = _vm->_graphicsManager.zoomOut(v39, v18);
v63 = v43;
v15 = v47;
}
Expand All @@ -3295,11 +3295,11 @@ int LinesManager::SMOOTH_MOVE(int a3, int a4, int a5, int a6) {
if (v15 < 0)
v20 = -v15;
v44 = v63;
v14 = _vm->_graphicsManager.Reel_Zoom(v14, v20);
v14 = _vm->_graphicsManager.zoomIn(v14, v20);
v21 = v19;
if ((v19 & 0x80000000u) != 0)
v21 = -v19;
v39 = _vm->_graphicsManager.Reel_Zoom(v39, v21);
v39 = _vm->_graphicsManager.zoomIn(v39, v21);
v63 = v44;
}
v22 = v63 + v39;
Expand Down Expand Up @@ -3336,8 +3336,8 @@ int LinesManager::SMOOTH_MOVE(int a3, int a4, int a5, int a6) {
do {
v10 = _vm->_globals.Hopkins[v51].field2;
v42 = v63;
v11 = _vm->_graphicsManager.Reel_Reduc(_vm->_globals.Hopkins[v51].field0, 0x19u);
v38 = _vm->_graphicsManager.Reel_Reduc(v10, 0x19u);
v11 = _vm->_graphicsManager.zoomOut(_vm->_globals.Hopkins[v51].field0, 0x19u);
v38 = _vm->_graphicsManager.zoomOut(v10, 0x19u);
v63 = v42;
v12 = 0;
if (v11 > 0) {
Expand Down Expand Up @@ -3372,8 +3372,8 @@ int LinesManager::SMOOTH_MOVE(int a3, int a4, int a5, int a6) {
do {
v6 = _vm->_globals.Hopkins[v50].field2;
v41 = v63;
v7 = _vm->_graphicsManager.Reel_Reduc(_vm->_globals.Hopkins[v50].field0, 0x19u);
v37 = _vm->_graphicsManager.Reel_Reduc(v6, 0x19u);
v7 = _vm->_graphicsManager.zoomOut(_vm->_globals.Hopkins[v50].field0, 0x19u);
v37 = _vm->_graphicsManager.zoomOut(v6, 0x19u);
v63 = v41;
v8 = 0;
if (v7 > 0) {
Expand Down

0 comments on commit d7d8c19

Please sign in to comment.