Skip to content

Commit

Permalink
ACCESS: Beginnings of code for text bubble drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 17, 2014
1 parent a42e52f commit 8d6c8ed
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 5 deletions.
1 change: 1 addition & 0 deletions engines/access/access.h
Expand Up @@ -125,6 +125,7 @@ class AccessEngine : public Engine {
int _establishGroup;
int _numAnimTimers;
TimerList _timers;
Font _font;
Common::Array<Common::Rect> _newRects;
Common::Array<Common::Rect> _oldRects;
Common::Array<ExtraCell> _extraCells;
Expand Down
21 changes: 21 additions & 0 deletions engines/access/asurface.cpp
Expand Up @@ -127,6 +127,7 @@ void ASurface::init() {

ASurface::~ASurface() {
free();
_savedBlock.free();
}

void ASurface::clearBuffer() {
Expand Down Expand Up @@ -309,4 +310,24 @@ void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) {
copyRectToSurface(*src, bounds.left, bounds.top, bounds);
}

void ASurface::saveBlock(const Common::Rect &bounds) {
_savedBounds = bounds;
_savedBounds.clip(Common::Rect(0, 0, this->w, this->h));

_savedBlock.free();
_savedBlock.create(bounds.width(), bounds.height(),
Graphics::PixelFormat::createFormatCLUT8());
_savedBlock.copyRectToSurface(*this, 0, 0, _savedBounds);
}

void ASurface::restoreBlock() {
if (!_savedBounds.isEmpty()) {
copyRectToSurface(_savedBlock, _savedBounds.left, _savedBounds.top,
Common::Rect(0, 0, _savedBlock.w, _savedBlock.h));

_savedBlock.free();
_savedBounds = Common::Rect(0, 0, 0, 0);
}
}

} // End of namespace Access
12 changes: 11 additions & 1 deletion engines/access/asurface.h
Expand Up @@ -36,6 +36,9 @@ class SpriteResource;
class SpriteFrame;

class ASurface : public Graphics::Surface {
private:
Graphics::Surface _savedBlock;
Common::Rect _savedBounds;
public:
static int _leftSkip, _rightSkip;
static int _topSkip, _bottomSkip;
Expand All @@ -46,7 +49,8 @@ class ASurface : public Graphics::Surface {

static void init();
public:
virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt);
Common::Point _printOrg;
Common::Point _printStart;
public:
virtual ~ASurface();

Expand All @@ -69,6 +73,12 @@ class ASurface : public Graphics::Surface {
void copyTo(ASurface *dest, const Common::Point &destPos);

void copyTo(ASurface *dest, const Common::Rect &bounds);

void saveBlock(const Common::Rect &bounds);

void restoreBlock();

virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt);
};

class SpriteFrame : public ASurface {
Expand Down
13 changes: 13 additions & 0 deletions engines/access/data.h
Expand Up @@ -78,6 +78,19 @@ class ExtraCell {
int _vidSTable1;
};

struct FontVal {
public:
int _lo, _hi;

FontVal() { _lo = _hi = 0; }
};

class Font {
public:
FontVal _charSet;
FontVal _charFor;
};

} // End of namespace Access

#endif /* ACCESS_DATA_H */
3 changes: 3 additions & 0 deletions engines/access/events.cpp
Expand Up @@ -204,5 +204,8 @@ void EventsManager::debounceLeft() {
}
}

void EventsManager::waitKeyMouse() {
error("TODO: waitKeyPress");
}

} // End of namespace Access
2 changes: 2 additions & 0 deletions engines/access/events.h
Expand Up @@ -104,6 +104,8 @@ class EventsManager {
void delay(int time);

void debounceLeft();

void waitKeyMouse();
};

} // End of namespace Access
Expand Down
54 changes: 54 additions & 0 deletions engines/access/room.cpp
Expand Up @@ -584,6 +584,34 @@ int Room::validateBox(int boxId) {
return _vm->_scripts->executeScript();
}

void Room::placeBubble() {
_bubbleBox._maxChars = 27;
placeBubble1();
}

void Room::placeBubble1() {
_bubbleBox.clearBubbles();
_vm->_font._charSet._lo = 1;
_vm->_font._charSet._hi = 8;
_vm->_font._charFor._lo = 29;
_vm->_font._charFor._hi = 32;

calcBubble();

Common::Rect r = _bubbleBox._bubbles[0];
r.translate(-2, 0);
_vm->_screen->saveBlock(r);
printBubble();
}

void Room::calcBubble() {
error("TODO: calcBubble");
}

void Room::printBubble() {
error("TODO: printBubble");
}

/*------------------------------------------------------------------------*/

RoomInfo::RoomInfo(const byte *data) {
Expand Down Expand Up @@ -642,4 +670,30 @@ RoomInfo::RoomInfo(const byte *data) {
}
}

/*------------------------------------------------------------------------*/

BubbleBox::BubbleBox() {
_field0 = 2;
_bounds = Common::Rect(64, 32, 130, 122);
_bubblePtr = -1;
_maxChars = 0;
}

void BubbleBox::load(Common::SeekableReadStream *stream) {
_bubbleTit.clear();

byte v;
do {
v = stream->readByte();
_bubbleTit.push_back(v);
} while (v != 0);

_bubblePtr = 0;
}

void BubbleBox::clearBubbles() {
_bubbles.clear();
}


} // End of namespace Access
24 changes: 24 additions & 0 deletions engines/access/room.h
Expand Up @@ -58,6 +58,22 @@ class JetFrame {
}
};

class BubbleBox {
public:
int _field0;
Common::Rect _bounds;
Common::Array<int> _bubbleTit;
int _bubblePtr;
int _maxChars;
Common::Array<Common::Rect> _bubbles;
public:
BubbleBox();

void load(Common::SeekableReadStream *stream);

void clearBubbles();
};

class Room: public Manager {
private:
void roomLoop();
Expand Down Expand Up @@ -114,6 +130,7 @@ class Room: public Manager {
public:
Plotter _plotter;
Common::Array<JetFrame> _jetFrame;
BubbleBox _bubbleBox;
int _function;
int _roomFlag;
byte *_playField;
Expand Down Expand Up @@ -141,6 +158,13 @@ class Room: public Manager {
void buildRow(int playY, int screenY);

void init4Quads();

void placeBubble();
void placeBubble1();

void calcBubble();

void printBubble();
};


Expand Down
27 changes: 24 additions & 3 deletions engines/access/scripts.cpp
Expand Up @@ -87,7 +87,7 @@ void Scripts::executeCommand(int commandIndex) {
&Scripts::CMDOBJECT, &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook,
&Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove,
&Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull,
&Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::cmdAnim,
&Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim,
&Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto,
&Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory,
&Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE,
Expand Down Expand Up @@ -116,7 +116,11 @@ void Scripts::executeCommand(int commandIndex) {
(this->*COMMAND_LIST[commandIndex])();
}

void Scripts::CMDOBJECT() { error("TODO CMDOBJECT"); }
void Scripts::CMDOBJECT() {
byte id;

_vm->_room->_bubbleBox.load(_data);
}

void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); }

Expand Down Expand Up @@ -165,7 +169,24 @@ void Scripts::cmdJumpTalk() {
void Scripts::cmdNull() {
}

void Scripts::CMDPRINT() { error("TODO CMDPRINT"); }
#define PRINT_TIMER 25

void Scripts::cmdPrint() {
_vm->_screen->_printOrg = Common::Point(20, 42);
_vm->_screen->_printStart = Common::Point(20, 42);
_vm->_timers[PRINT_TIMER]._timer = 50;
_vm->_timers[PRINT_TIMER]._initTm = 50;
_vm->_timers[PRINT_TIMER]._flag = true;

_vm->_room->placeBubble();
_vm->_events->waitKeyMouse();

while (_vm->_timers[PRINT_TIMER]._flag) {
_vm->_events->pollEvents();
}

_vm->_screen->restoreBlock();
}

void Scripts::cmdRetPos() {
_endFlag = true;
Expand Down
2 changes: 1 addition & 1 deletion engines/access/scripts.h
Expand Up @@ -52,7 +52,7 @@ class Scripts {
void cmdJumpUse();
void cmdJumpTalk();
void cmdNull();
void CMDPRINT();
void cmdPrint();
void cmdRetPos();
void cmdAnim();
void cmdSetFlag();
Expand Down

0 comments on commit 8d6c8ed

Please sign in to comment.