Skip to content

Commit

Permalink
ACCESS: MM - Work some more on doBox_v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Jan 12, 2015
1 parent eacc0e0 commit 6a288bc
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 2 deletions.
2 changes: 2 additions & 0 deletions engines/access/access.cpp
Expand Up @@ -99,6 +99,8 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
ASK[i];
_startAboutItem = _startAboutBox = 0;
_byte26CB5 = 0;
BCNT = 0;

_vidEnd = false;
}

Expand Down
1 change: 1 addition & 0 deletions engines/access/access.h
Expand Up @@ -219,6 +219,7 @@ class AccessEngine : public Engine {
int BOXDATASTART;
int BOXSELECTY;
byte _byte26CB5;
int BCNT;
//

bool _vidEnd;
Expand Down
11 changes: 11 additions & 0 deletions engines/access/asurface.cpp
Expand Up @@ -316,6 +316,17 @@ void ASurface::drawRect() {
Graphics::Surface::fillRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2), _lColor);
}

void ASurface::drawLine(int x1, int y1, int x2, int y2, int col) {
Graphics::Surface::drawLine(x1, y1, x2, y2, col);
}

void ASurface::drawBox() {
Graphics::Surface::drawLine(_orgX1, _orgY1, _orgX2, _orgY1, _lColor);
Graphics::Surface::drawLine(_orgX1, _orgY2, _orgX2, _orgY2, _lColor);
Graphics::Surface::drawLine(_orgX2, _orgY1, _orgX2, _orgY1, _lColor);
Graphics::Surface::drawLine(_orgX2, _orgY2, _orgX2, _orgY2, _lColor);
}

void ASurface::flipHorizontal(ASurface &dest) {
dest.create(this->w, this->h);
for (int y = 0; y < h; ++y) {
Expand Down
4 changes: 4 additions & 0 deletions engines/access/asurface.h
Expand Up @@ -95,6 +95,10 @@ class ASurface : public Graphics::Surface {

virtual void drawRect();

virtual void drawLine(int x1, int y1, int x2, int y2, int col);

virtual void drawBox();

virtual void transCopyFrom(ASurface *src, const Common::Point &destPos);

virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds);
Expand Down
124 changes: 123 additions & 1 deletion engines/access/bubble_box.cpp
Expand Up @@ -34,6 +34,10 @@ BubbleBox::BubbleBox(AccessEngine *vm, Access::BoxType type, int x, int y, int w
_fieldE = val2;
_fieldF = val3;
_field10 = val4;
BOXSTARTX = BOXSTARTY = 0;
BICONSTARTX = 0;
BOXENDY = 0;
BOXPSTARTX = BOXPSTARTY = 0;
}

void BubbleBox::load(Common::SeekableReadStream *stream) {
Expand Down Expand Up @@ -280,7 +284,125 @@ void BubbleBox::doBox(int item, int box) {
}

int BubbleBox::doBox_v1(int item, int box, int &type) {
warning("TODO: dobox_v1");
FontManager &fonts = _vm->_fonts;

_startItem = item;
_startBox = box;

// Save state information
_vm->_screen->saveScreen();
_vm->_screen->setDisplayScan();

fonts._charFor._hi = 0xff;
fonts._charSet._lo = 1;
fonts._charSet._hi = 0;

_vm->_destIn = _vm->_screen; // TODO: Redundant

if (_type != TYPE_2) {
Common::Rect r = _bounds;
r.left -= 2;
_vm->_screen->saveBlock(r);
}

// Set the up boundaries and color to use for the box background
_vm->_screen->_orgX1 = _bounds.left - 2;
_vm->_screen->_orgY1 = _bounds.top;
_vm->_screen->_orgX2 = _bounds.right - 2;
_vm->_screen->_orgY2 = _bounds.bottom;
_vm->_screen->_lColor = 0xFB;

// Draw a background for the entire area
_vm->_screen->drawRect();

// Draw the inner box;
++_vm->_screen->_orgX1;
++_vm->_screen->_orgY1;
--_vm->_screen->_orgX2;
--_vm->_screen->_orgY2;
_vm->_screen->_lColor = 0xF9;

// Draw the inner border
_vm->_screen->drawBox();

// Get icons data
Resource *iconData = _vm->_files->loadFile("ICONS.LZ");
SpriteResource *icons = new SpriteResource(_vm, iconData);
delete iconData;

// Draw upper border
_vm->BCNT = (_vm->_screen->_orgX2 - _vm->_screen->_orgX1) >> 4;
int oldX = _vm->_screen->_orgX1;
for ( ;_vm->BCNT > 0; --_vm->BCNT) {
_vm->_screen->plotImage(icons, 16, Common::Point(_vm->_screen->_orgX1, _vm->_screen->_orgY1));
_vm->_screen->_orgX1 += 16;
}

_vm->_screen->_orgX1 = oldX;
int oldY = _vm->_screen->_orgY2;
_vm->_screen->_orgY2 = _vm->_screen->_orgY1 + 8;
_vm->_screen->_lColor = 0xF9;

BOXSTARTY = _vm->_screen->_orgY2 + 1;
_vm->_screen->_orgY2 = oldY;

if (_type != TYPE_2) {
oldY = _vm->_screen->_orgY1;
--_vm->_screen->_orgY2;
_vm->_screen->_orgY2 -= 8;
if (_type == TYPE_3)
_vm->_screen->_orgY2 -= 8;
_vm->_screen->drawRect();

int tmpX = BICONSTARTX = _vm->_screen->_orgX1;
BOXSTARTX = tmpX + 1;
int tmpY = BOXENDY = _vm->_screen->_orgY1;

if (_type == TYPE_3)
BOXSTARTY = tmpY - 7;
else
BOXSTARTY = tmpY + 1;

if (_type == TYPE_3)
warning("TODO: Implement more of TYPE_3");

_vm->_screen->_orgY1 = oldY;
}

if ((_type == TYPE_0) || (_type == TYPE_3))
warning("TODO: Implement more of TYPE_0 or TYPE_3");

int len = _bubbleDisplStr.size();
int ax = _bounds.top >> 3;
ax -= len;
ax /= 2;
int cx = _bounds.left >> 3;
BOXPSTARTX = cx;
ax += cx << 16;

cx = _bounds.right >> 3;
int bp = _bounds.right - (cx << 3) + 1;
if (bp == 8) {
++cx;
bp = 0;
}

_rowOff = bp;
BOXPSTARTY = cx;
ax += cx;

_vm->_fonts._charFor._lo = -1;
_vm->_events->setCursor(CURSOR_ARROW);

_vm->_fonts._font1.drawString(_vm->_screen, _bubbleDisplStr, _vm->_screen->_printOrg);

if (_type == TYPE_2) {
_vm->_events->showCursor();
warning("TODO: pop values");
_vm->_screen->restoreScreen();
}

warning("TODO: more dobox_v1");
return -1;
}

Expand Down
8 changes: 7 additions & 1 deletion engines/access/bubble_box.h
Expand Up @@ -36,13 +36,19 @@ namespace Access {

class AccessEngine;

enum BoxType { TYPE_1 = 1, TYPE_2 = 2, TYPE_4 = 4 };
enum BoxType { TYPE_0 = 0, TYPE_1 = 1, TYPE_2 = 2, TYPE_3 = 3, TYPE_4 = 4 };

class BubbleBox : public Manager {
private:
int _startItem, _startBox;
int _charCol, _rowOff;
Common::Point _fileStart;
int BOXSTARTX;
int BOXSTARTY;
int BOXENDY;
int BICONSTARTX;
int BOXPSTARTX;
int BOXPSTARTY;
public:
BoxType _type;
Common::Rect _bounds;
Expand Down
5 changes: 5 additions & 0 deletions engines/access/screen.cpp
Expand Up @@ -276,6 +276,11 @@ void Screen::drawRect() {
ASurface::drawRect();
}

void Screen::drawBox() {
addDirtyRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2));
ASurface::drawBox();
}

void Screen::transCopyFrom(ASurface *src, const Common::Point &destPos) {
addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + src->w, destPos.y + src->h));
ASurface::transCopyFrom(src, destPos);
Expand Down
2 changes: 2 additions & 0 deletions engines/access/screen.h
Expand Up @@ -92,6 +92,8 @@ class Screen : public ASurface {

virtual void drawRect();

virtual void drawBox();

virtual void transCopyFrom(ASurface *src, const Common::Point &destPos);

virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds);
Expand Down

0 comments on commit 6a288bc

Please sign in to comment.