Skip to content

Commit

Permalink
HOPKINS: Initial implementation of some code that will be needed for …
Browse files Browse the repository at this point in the history
…cursor display
  • Loading branch information
dreammaster committed Sep 19, 2012
1 parent 044f9b8 commit 9900adf
Show file tree
Hide file tree
Showing 18 changed files with 502 additions and 77 deletions.
42 changes: 4 additions & 38 deletions engines/hopkins/anim.cpp
Expand Up @@ -416,8 +416,8 @@ int AnimationManager::CHARGE_BANK_SPRITE1(int idx, const Common::String &filenam
v8 = 0;
do {
ptr = v4;
width = Get_Largeur(v4, v8);
height = Get_Hauteur(ptr, v8);
width = _vm->_objectsManager.Get_Largeur(v4, v8);
height = _vm->_objectsManager.Get_Hauteur(ptr, v8);
v4 = ptr;
if (!width && !height)
v7 = 1;
Expand Down Expand Up @@ -449,9 +449,9 @@ int AnimationManager::CHARGE_BANK_SPRITE1(int idx, const Common::String &filenam
v20 = READ_LE_UINT16(v13 + 6);
v13 += 8;

set_offsetxy(GLOBALS.Bank[idx].data, v14, v16, v17, 0);
_vm->_objectsManager.set_offsetxy(GLOBALS.Bank[idx].data, v14, v16, v17, 0);
if (GLOBALS.Bank[idx].fileHeader == 2)
set_offsetxy(GLOBALS.Bank[idx].data, v14, v21, v20, 1);
_vm->_objectsManager.set_offsetxy(GLOBALS.Bank[idx].data, v14, v21, v20, 1);
}
}

Expand All @@ -473,24 +473,6 @@ int AnimationManager::CHARGE_BANK_SPRITE1(int idx, const Common::String &filenam
return result;
}

void AnimationManager::set_offsetxy(byte *data, int idx, int xp, int yp, bool isSize) {
byte *startP = data + 3;
for (int i = idx; i; --i)
startP += READ_LE_UINT32(startP) + 16;

byte *rectP = startP + 8;
if (isSize == 1) {
// Set size
byte *pointP = rectP + 4;
WRITE_LE_UINT16(pointP, xp);
WRITE_LE_UINT16(pointP + 2, yp);
} else {
// Set position
WRITE_LE_UINT16(rectP, xp);
WRITE_LE_UINT16(rectP + 2, yp);
}
}

void AnimationManager::RECHERCHE_ANIM(const byte *data, int idx, int nbytes) {
int v4;
const byte *v5;
Expand Down Expand Up @@ -598,20 +580,4 @@ void AnimationManager::RECHERCHE_ANIM(const byte *data, int idx, int nbytes) {
} while (v21 <= nbytes && !doneFlag);
}

int AnimationManager::Get_Largeur(const byte *data, int idx) {
const byte *rectP = data + 3;
for (int i = idx; i; --i)
rectP += READ_LE_UINT32(rectP) + 16;

return (int16)READ_LE_UINT16(rectP + 4);
}

int AnimationManager::Get_Hauteur(const byte *data, int idx) {
const byte *rectP = data + 3;
for (int i = idx; i; --i)
rectP += READ_LE_UINT32(rectP) + 16;

return (int16)READ_LE_UINT16(rectP + 6);
}

} // End of namespace Hopkins
3 changes: 0 additions & 3 deletions engines/hopkins/anim.h
Expand Up @@ -49,10 +49,7 @@ class AnimationManager {
void BOBANIM_OFF(int idx);
void CHARGE_ANIM(const Common::String &animName);
void CLEAR_ANIM();
void set_offsetxy(byte *data, int idx, int xp, int yp, bool isSize);
void RECHERCHE_ANIM(const byte *data, int idx, int nbytes);
int Get_Largeur(const byte *data, int idx);
int Get_Hauteur(const byte *data, int idx);
};

} // End of namespace Hopkins
Expand Down
278 changes: 273 additions & 5 deletions engines/hopkins/events.cpp
Expand Up @@ -24,12 +24,22 @@
#include "common/events.h"
#include "common/textconsole.h"
#include "hopkins/events.h"
#include "hopkins/files.h"
#include "hopkins/globals.h"
#include "hopkins/hopkins.h"
#include "hopkins/sound.h"

namespace Hopkins {

EventsManager::EventsManager() {
souris_flag = false;
mouse_linux = false;
min_x = 0;
min_y = 20;
max_x = 1280;
max_y = 460;
min_x = min_y = 0;
max_x = max_y = 0;
souris_sizex = souris_sizey = 0;
ofset_souris_x = ofset_souris_y = 0;
start_x = start_y = 0;
Expand All @@ -41,6 +51,11 @@ EventsManager::EventsManager() {
lItCounter = 0;
ESC_KEY = false;
_priorFrameTime = 0;
btsouris = 0;
}

void EventsManager::setParent(HopkinsEngine *vm) {
_vm = vm;
}

void EventsManager::INSTALL_SOURIS() {
Expand Down Expand Up @@ -95,15 +110,28 @@ bool EventsManager::BMOUSE() {
}

void EventsManager::MOUSE_OFF() {
warning("TODO: MOUSE_OFF");
souris_flag = false;
}

void EventsManager::MOUSE_ON() {
warning("TODO: MOUSE_ON");
souris_on();
souris_flag = true;
}

void EventsManager::CHANGE_MOUSE(int id) {
warning("TODO: CHANGE_MOUSE");
int cursorId = id;

if (btsouris != 23) {
if (id == 4 && btsouris == 4 && _vm->_globals.NOMARCHE)
cursorId = 0;
if (cursorId == 25)
cursorId = 5;

if (OLD_ICONE != cursorId || !cursorId) {
OLD_ICONE = cursorId;
souris_n = cursorId;
}
}
}

void EventsManager::CONTROLE_MES() {
Expand Down Expand Up @@ -156,7 +184,247 @@ void EventsManager::pollEvents() {
}

void EventsManager::VBL() {
warning("TODO: VBL");
}
int a1 = 0;
signed __int16 v1;
int v2;
int v3;
int v4;
int v5;
int v6;
signed __int16 v7;
int v10;
signed int v11 = 0;
signed int v12 = 0;
int v13 = 0;
unsigned int v14 = 0;
int v15 = 0;

if (_vm->_graphicsManager.REDRAW) {
_vm->_graphicsManager.DD_Lock();
if (CASSE) {
_vm->_graphicsManager.CopyAsm(_vm->_graphicsManager.VESA_BUFFER);
_vm->_graphicsManager.REDRAW = 0;
} else {
if (_vm->_globals.iRegul == 3)
_vm->_graphicsManager.m_scroll(_vm->_graphicsManager.VESA_BUFFER, _vm->_graphicsManager.ofscroll, 50, SCREEN_WIDTH, 340, 0, 50);
else
_vm->_graphicsManager.m_scroll(_vm->_graphicsManager.VESA_BUFFER, _vm->_graphicsManager.ofscroll, 20, SCREEN_WIDTH, 440, 0, 20);
FileManager::DMESS();
--_vm->_graphicsManager.REDRAW;
}
_vm->_graphicsManager.DD_Unlock();
}

if (souris_flag) {
v1 = 20;
if (!mouse_linux)
v1 = 10;
v2 = 20;
if (!mouse_linux)
v2 = 15;

v15 = souris_x - v1;
a1 = souris_y;
v14 = souris_sizex;
v13 = souris_sizey;
if (btsouris == 23) {
v14 = _vm->_globals.OBJL;
v13 = _vm->_globals.OBJH;
goto LABEL_35;
}

if (CASSE) {
if (v15 < min_x)
v15 = min_x;
if (souris_y < min_y)
a1 = min_y;

if (souris_sizex + v15 >= max_x)
v14 = souris_sizex - (souris_sizex + v15 - max_x);
if (a1 + souris_sizey < max_y)
goto LABEL_34;

v3 = a1 + souris_sizey - max_y;
} else {
if (v15 < min_x)
v15 = min_x - v1;
v2 = (signed __int16)v2;
if (souris_y < min_y - (signed __int16)v2)
a1 = min_y - (signed __int16)v2;
if (souris_sizex + v15 >= max_x)
v14 = souris_sizex - (souris_sizex + v15 - max_x - v1);
if (a1 + souris_sizey < v2 + max_y)
goto LABEL_34;

v3 = v2 + a1 + souris_sizey - max_y;
}

v13 = souris_sizey - v3;
LABEL_34:
v12 = v14 + v15;
v11 = a1 + v13;
}
LABEL_35:

if (!_vm->_globals.PUBEXIT)
_vm->_graphicsManager.AFF_SPRITES();
if (souris_flag != 1)
goto LABEL_54;
if (btsouris == 23)
goto LABEL_45;

if (a1 >= max_y || v15 >= max_x || (signed int)v14 <= 1 || v13 <= 1) {
if (btsouris != 23)
goto LABEL_54;

LABEL_45:
if (a1 < max_y && v15 < max_x) {
if ((signed int)(v14 + v15) > max_x)
v14 -= v14 + v15 - max_x;
if (a1 + v13 > max_y)
v13 -= a1 + v13 - max_y;

if ((signed int)v14 > 1 && v13 > 1) {
_vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.cache_souris, v15, a1, v14, v13);
_vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.Bufferobjet, v15 + 300, a1 + 300, 0, 0, 0, 0);
_vm->_graphicsManager.Ajoute_Segment_Vesa(v15, a1, v14 + v15, a1 + v13);
}
}
goto LABEL_54;
}

_vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.cache_souris, v15, a1, v14, v13);
_vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, pointeur_souris, v15 + 300, a1 + 300, souris_n);
_vm->_graphicsManager.Ajoute_Segment_Vesa(v15, a1, v12, v11);

LABEL_54:
_vm->_globals.vitesse = 2;

do {
for (;;) {
while (CASSE || _vm->_globals.iRegul != 1) {
if (CASSE != 1)
goto LABEL_63;

if (lItCounter > 1)
goto LABEL_65;
}

if (_vm->_globals.vitesse != 2)
break;

if (lItCounter > 9)
goto LABEL_65;
}
LABEL_63:
;
} while (_vm->_globals.iRegul == 3 && lItCounter <= 15);

LABEL_65:
_vm->_globals.vitesse = 2;
lItCounter = 0;

if (_vm->_graphicsManager.DOUBLE_ECRAN != 1 || _vm->_graphicsManager.no_scroll == 1) {
_vm->_graphicsManager.Affiche_Segment_Vesa();
} else {
if (_vm->_graphicsManager.no_scroll != 2) {
if ((signed __int16)XMOUSE() > _vm->_graphicsManager.SCROLL + 620)
_vm->_graphicsManager.SCROLL += _vm->_graphicsManager.SPEED_SCROLL;

if ((signed __int16)XMOUSE() < _vm->_graphicsManager.SCROLL + 10)
_vm->_graphicsManager.SCROLL -= _vm->_graphicsManager.SPEED_SCROLL;
}

if (_vm->_graphicsManager.SCROLL < 0)
_vm->_graphicsManager.SCROLL = 0;

if (_vm->_graphicsManager.SCROLL > SCREEN_WIDTH)
_vm->_graphicsManager.SCROLL = SCREEN_WIDTH;

if (_vm->_graphicsManager.SDL_ECHELLE)
v4 = _vm->_graphicsManager.Magic_Number(_vm->_graphicsManager.SCROLL);
else
v4 = _vm->_graphicsManager.SCROLL;

if (_vm->_graphicsManager.OLD_SCROLL == v4) {
_vm->_graphicsManager.Affiche_Segment_Vesa();
} else {
_vm->_fontManager.TEXTE_OFF(9);
_vm->_graphicsManager.DD_Lock();
if (_vm->_graphicsManager.SDL_ECHELLE) {
if (_vm->_graphicsManager.Winbpp == 2) {
v5 = _vm->_graphicsManager.Reel_Zoom(20, _vm->_graphicsManager.SDL_ECHELLE);
_vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_BUFFER, v4, 20, 640, 440, 0, v5);
} else {
v6 = _vm->_graphicsManager.Reel_Zoom(20, _vm->_graphicsManager.SDL_ECHELLE);
_vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_BUFFER, v4, 20, 640, 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(20, _vm->_graphicsManager.SDL_ECHELLE);
_vm->_graphicsManager.dstrect[0].setWidth(_vm->_graphicsManager.Reel_Zoom(SCREEN_WIDTH, _vm->_graphicsManager.SDL_ECHELLE));
_vm->_graphicsManager.dstrect[0].setHeight(_vm->_graphicsManager.Reel_Zoom(440, _vm->_graphicsManager.SDL_ECHELLE));
} else {
if (_vm->_graphicsManager.Winbpp == 2)
_vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_BUFFER, v4, 20, 640, 440, 0, 20);
else
_vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_BUFFER, v4, 20, 640, 440, 0, 20);

_vm->_graphicsManager.DD_Unlock();
_vm->_graphicsManager.dstrect[0] = Common::Rect(0, 20, SCREEN_WIDTH, SCREEN_HEIGHT - 40);
}

if (!_vm->_globals.BPP_NOAFF) {
// TODO: Useful for future dirty rect processing?
// SDL_UpdateRects(LinuxScr, 1, dstrect);
}
if (_vm->_globals.NBBLOC) {
v7 = 1;
v10 = _vm->_globals.NBBLOC + 1;

do {
if (_vm->_globals.BLOC[v7].field0 == 1)
_vm->_globals.BLOC[v7].field0 = 0;
++v7;
} while (v10 != v7);
}

_vm->_globals.NBBLOC = 0;
start_x = v4;
_vm->_graphicsManager.ofscroll = v4;
_vm->_graphicsManager.SCROLL = v4;
}

_vm->_graphicsManager.OLD_SCROLL = v4;
start_x = v4;
_vm->_graphicsManager.ofscroll = v4;
}

souris_bb = souris_b;
souris_b = 0;
if (souris_flag == 1) {
if (btsouris != 23) {
if (a1 < max_y && v15 < max_x && (signed int)v14 > 1 && v13 > 1) {
_vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.cache_souris, v15, a1, v14, v13);
_vm->_graphicsManager.Ajoute_Segment_Vesa(v15, a1, v12, v11);
goto LABEL_113;
}

if (btsouris != 23)
goto LABEL_113;
}

if (a1 < max_y && v15 < max_x && (signed int)v14 > 1 && v13 > 1) {
_vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.cache_souris, v15, a1, v14, v13);
_vm->_graphicsManager.Ajoute_Segment_Vesa(v15, a1, v14 + v15, a1 + v13);
}
}

LABEL_113:

_vm->_soundManager.VERIF_SOUND();
return CONTROLE_MES();
}

} // End of namespace Hopkins

0 comments on commit 9900adf

Please sign in to comment.