Skip to content

Commit

Permalink
ACCESS: MM - Implement getList
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Jan 14, 2015
1 parent 3a57f20 commit f1aa191
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 19 deletions.
12 changes: 6 additions & 6 deletions engines/access/access.cpp
Expand Up @@ -95,7 +95,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
for (int i = 0; i < 60; i++)
TRAVEL[i] = 0;
STARTTRAVELITEM = STARTTRAVELBOX = 0;
for (int i = 0; i < 16; i++)
for (int i = 0; i < 33; i++)
ASK[i];
_startAboutItem = _startAboutBox = 0;
_byte26CB5 = 0;
Expand Down Expand Up @@ -163,12 +163,12 @@ void AccessEngine::initialize() {

// Create sub-objects of the engine
_animation = new AnimationManager(this);
_bubbleBox = new BubbleBox(this, TYPE_2, 64, 32, 130, 122, 0, 0, 0, 0, "", nullptr);
_bubbleBox = new BubbleBox(this, TYPE_2, 64, 32, 130, 122, 0, 0, 0, 0, "");
if (getGameID() == GType_MartianMemorandum) {
_helpBox = new BubbleBox(this, TYPE_1, 64, 24, 146, 122, 1, 32, 2, 76, "HELP", TEMPLIST);
_travelBox = new BubbleBox(this, TYPE_1, 64, 32, 194, 122, 1, 24, 2, 74, "TRAVEL", TEMPLIST);
_invBox = new BubbleBox(this, TYPE_1, 64, 32, 146, 122, 1, 32, 2, 76, "INVENTORY", TEMPLIST);
_aboutBox = new BubbleBox(this, TYPE_1, 64, 32, 194, 122, 1, 32, 2, 76, "ASK ABOUT", TEMPLIST);
_helpBox = new BubbleBox(this, TYPE_1, 64, 24, 146, 122, 1, 32, 2, 76, "HELP");
_travelBox = new BubbleBox(this, TYPE_1, 64, 32, 194, 122, 1, 24, 2, 74, "TRAVEL");
_invBox = new BubbleBox(this, TYPE_1, 64, 32, 146, 122, 1, 32, 2, 76, "INVENTORY");
_aboutBox = new BubbleBox(this, TYPE_1, 64, 32, 194, 122, 1, 32, 2, 76, "ASK ABOUT");
} else {
_helpBox = nullptr;
_travelBox = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion engines/access/access.h
Expand Up @@ -211,9 +211,9 @@ class AccessEngine : public Engine {
// Fields used by MM
// TODO: Refactor
int TRAVEL[60];
int ASK[33];
int STARTTRAVELITEM;
int STARTTRAVELBOX;
int ASK[16];
int _startAboutItem;
int _startAboutBox;
int BOXDATASTART;
Expand Down
26 changes: 20 additions & 6 deletions engines/access/bubble_box.cpp
Expand Up @@ -26,7 +26,7 @@

namespace Access {

BubbleBox::BubbleBox(AccessEngine *vm, Access::BoxType type, int x, int y, int w, int h, int val1, int val2, int val3, int val4, Common::String title, byte *tmpList) : Manager(vm) {
BubbleBox::BubbleBox(AccessEngine *vm, Access::BoxType type, int x, int y, int w, int h, int val1, int val2, int val3, int val4, Common::String title) : Manager(vm) {
_type = type;
_bounds = Common::Rect(x, y, x + w, y + h);
_bubbleDisplStr = title;
Expand All @@ -40,7 +40,8 @@ BubbleBox::BubbleBox(AccessEngine *vm, Access::BoxType type, int x, int y, int w
BOXENDX = BOXENDY = 0;
BOXPSTARTX = BOXPSTARTY = 0;
// Unused in AGoE
_tempListPtr = tmpList;
for (int i = 0; i < 60; i++)
_tempListPtr[i] = "";
}

void BubbleBox::load(Common::SeekableReadStream *stream) {
Expand Down Expand Up @@ -294,14 +295,14 @@ void BubbleBox::displayBoxData() {
_vm->_fonts._charFor._lo = 15; // 0xFF
_vm->_fonts._charFor._hi = 15;

if (!_tempListPtr)
if (_tempListPtr[0].size() == 0)
return;

int idx = 0;
if ((_type == TYPE_1) || (_type == TYPE_3)) {
_vm->BCNT = 0;

if (_tempListPtr[idx] == -1) {
if (_tempListPtr[idx].size() == 0) {
_vm->BOXDATAEND = 1;
return;
}
Expand All @@ -322,7 +323,7 @@ void BubbleBox::displayBoxData() {
++BOXPSTARTY;

for (int i = 0; i < _vm->BOXDATASTART; i++, idx++) {
while (_tempListPtr[idx] != 0)
while (_tempListPtr[idx].size() != 0)
++idx;
}

Expand All @@ -332,7 +333,7 @@ void BubbleBox::displayBoxData() {
++idx;
++BOXPSTARTY;
++_vm->BCNT;
if (_tempListPtr[idx] == nullptr) {
if (_tempListPtr[idx].size() == 0) {
BOXPSTARTY = oldPStartY;
_vm->_events->showCursor();
_vm->BOXDATAEND = 1;
Expand Down Expand Up @@ -565,4 +566,17 @@ int BubbleBox::doBox_v1(int item, int box, int &type) {
warning("TODO: more dobox_v1");
return -1;
}

void BubbleBox::getList(const char *data[], int *flags) {
int srcIdx = 0;
int destIdx = 0;
while (data[srcIdx]) {
if (flags[srcIdx]) {
_tempListPtr[destIdx] = Common::String(data[srcIdx]);
++destIdx;
}
srcIdx++;
}
_tempListPtr[destIdx] = "";
}
} // End of namespace Access
6 changes: 3 additions & 3 deletions engines/access/bubble_box.h
Expand Up @@ -57,7 +57,7 @@ class BubbleBox : public Manager {
Common::StringArray _nameIndex;
Common::String _bubbleTitle;
Common::String _bubbleDisplStr;
byte *_tempListPtr;
Common::String _tempListPtr[60];
int _btnId1;
int _btnX1;
int _btnId2;
Expand All @@ -67,7 +67,7 @@ class BubbleBox : public Manager {

Common::Array<Common::Rect> _bubbles;
public:
BubbleBox(AccessEngine *vm, Access::BoxType type, int x, int y, int w, int h, int val1, int val2, int val3, int val4, Common::String title, byte* tmpList);
BubbleBox(AccessEngine *vm, Access::BoxType type, int x, int y, int w, int h, int val1, int val2, int val3, int val4, Common::String title);

void load(Common::SeekableReadStream *stream);

Expand Down Expand Up @@ -95,7 +95,7 @@ class BubbleBox : public Manager {
void doBox(int item, int box);

int doBox_v1(int item, int box, int &type);
void getList() { warning("TODO: getList"); } // TODO: Check if implementation is useful
void getList(const char *data[], int *flags);
};

} // End of namespace Access
Expand Down
1 change: 1 addition & 0 deletions engines/access/martian/martian_game.cpp
Expand Up @@ -74,6 +74,7 @@ void MartianEngine::initVariables() {
_mouseMode = 0;
_numAnimTimers = 0;
TRAVEL[7] = 1;
ASK[33] = 1;
}

void MartianEngine::setNoteParams() {
Expand Down
10 changes: 9 additions & 1 deletion engines/access/martian/martian_resources.cpp
Expand Up @@ -807,7 +807,7 @@ const int RMOUSE[10][2] = {
{ 155, 185 }, { 188, 216 }, { 219, 260 }, { 263, 293 }, { 295, 214 }
};

const char *const TRAVDATA[] = {
const char *TRAVDATA[] = {
"GALACTIC PICTURES", "TERRAFORM", "WASHROOM", "MR. BIG", "ALEXIS' HOME",
"JOHNNY FEDORA", "JUNKYARD IN", "TEX'S OFFICE", "MURDER SCENE", "PLAZA HOTEL",
"RESTAURANT", "GIFT SHOP", "LOVE SCENE", "RICK LOGAN", "HUT",
Expand All @@ -832,6 +832,14 @@ const char *const ASKTBL[] = {
"LARRRY HAMMOND", nullptr
};


byte HELP[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1
};

const byte DEATH_SCREENS[] = {
5, 5, 3, 3, 7, 4, 6, 2, 2, 2, 1, 5, 3, 5, 2, 8, 5, 3, 8, 5
};
Expand Down
3 changes: 2 additions & 1 deletion engines/access/martian/martian_resources.h
Expand Up @@ -55,8 +55,9 @@ extern const byte ICON_DATA[];

extern const int RMOUSE[10][2];

extern const char *const TRAVDATA[];
extern byte HELP[];
extern const char *const ASKTBL[];
extern const char *TRAVDATA[];

extern const byte DEATH_SCREENS[];
extern const char *const DEATHMESSAGE[];
Expand Down
2 changes: 1 addition & 1 deletion engines/access/scripts.cpp
Expand Up @@ -617,7 +617,7 @@ void Scripts::cmdRemoveLast() {

void Scripts::cmdDoTravel() {
while (true) {
_vm->_travelBox->getList();
_vm->_travelBox->getList(Martian::TRAVDATA, _vm->TRAVEL);
int type = 0;
int boxX = _vm->_travelBox->doBox_v1(_vm->STARTTRAVELITEM, _vm->STARTTRAVELBOX, type);
_vm->STARTTRAVELITEM = _vm->BOXDATASTART;
Expand Down

0 comments on commit f1aa191

Please sign in to comment.