TEEN: More code formatting & whitespace changes (automatically generated with astyle)

svn-id: r44101
This commit is contained in:
Max Horn 2009-09-15 08:54:06 +00:00
parent 9369d6b772
commit a8e5df433f
27 changed files with 900 additions and 901 deletions

View File

@ -27,45 +27,45 @@
namespace TeenAgent {
void Actor::render(Graphics::Surface *surface, const Common::Point & position, uint8 orientation, int delta_frame) {
void Actor::render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame) {
const uint8 frames_left_right[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const uint8 frames_up[] = {18, 19, 20, 21, 22, 23, 24, 25, };
const uint8 frames_down[] = {10, 11, 12, 13, 14, 15, 16, 17, };
Surface *s = NULL;
if (delta_frame == 0) {
index = 0; //static animation
}
int dx, dy;
switch(orientation) {
switch (orientation) {
case Object::ActorLeft:
case Object::ActorRight:
if (index >= sizeof(frames_left_right))
if (index >= sizeof(frames_left_right))
index = 1;
s = frames + frames_left_right[index];
dx = 11;
dy = 62;
break;
case Object::ActorUp:
if (index >= sizeof(frames_up))
if (index >= sizeof(frames_up))
index = 1;
s = frames + frames_up[index];
dx = 29;
dy = 67;
break;
case Object::ActorDown:
if (index >= sizeof(frames_down))
if (index >= sizeof(frames_down))
index = 1;
s = frames + frames_down[index];
dx = 29;
dy = 67;
break;
default:
default:
return;
}
index += delta_frame;
int xp = position.x - dx, yp = position.y - dy;
if (xp < 0)
xp = 0;
@ -76,7 +76,7 @@ void Actor::render(Graphics::Surface *surface, const Common::Point & position, u
yp = 0;
if (yp + s->h > 200)
yp = 200 - s->h;
if (s != NULL)
s->render(surface, xp, yp, orientation == Object::ActorLeft);
}

View File

@ -28,8 +28,8 @@
namespace TeenAgent {
class Actor : public Animation {
public:
void render(Graphics::Surface *surface, const Common::Point & position, uint8 orientation, int delta_frame);
public:
void render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame);
};
} // End of namespace TeenAgent

View File

@ -30,10 +30,10 @@ namespace TeenAgent {
Animation::Animation() : id(0), x(0), y(0), loop(true), paused(false), data(0), data_size(0), frames_count(0), frames(0), index(0) {
}
Surface *Animation::firstFrame(){
Surface *Animation::firstFrame() {
if (frames == NULL || frames_count == 0)
return NULL;
Surface *r = frames;
uint16 pos = READ_LE_UINT16(data + 1);
if (pos != 0) {
@ -46,26 +46,26 @@ Surface *Animation::firstFrame(){
Surface *Animation::currentFrame(int dt) {
if (paused)
return firstFrame();
if (frames == NULL || frames_count == 0)
return NULL;
Surface *r;
if (data != NULL) {
uint32 frame = 3 * index;
//debug(0, "%u/%u", index, data_size / 3);
index += dt;
if (!loop && index >= data_size / 3) {
return NULL;
}
if (data[frame] - 1 >= frames_count) {
warning("invalid frame %u(0x%x) (max %u) index %u, mod %u", frame, frame, frames_count, index - 1, data_size / 3);
return NULL;
}
r = frames + data[frame] - 1;
uint16 pos = READ_LE_UINT16(data + frame + 1);
index %= (data_size / 3);
@ -90,22 +90,22 @@ void Animation::free() {
x = y = 0;
loop = true;
paused = false;
delete[] data;
data = NULL;
data_size = 0;
data_size = 0;
frames_count = 0;
delete[] frames;
frames = NULL;
index = 0;
}
void Animation::load(Common::SeekableReadStream *s, Type type) {
//fixme: do not reload the same animation each time
free();
if (s == NULL && s->size() <= 1) {
debug(0, "empty animation");
return;
@ -113,7 +113,7 @@ void Animation::load(Common::SeekableReadStream *s, Type type) {
uint16 pos = 0;
int off = 0;
switch(type) {
switch (type) {
case TypeLan:
data_size = s->readUint16LE();
if (s->eos()) {
@ -124,22 +124,22 @@ void Animation::load(Common::SeekableReadStream *s, Type type) {
data_size -= 2;
data = new byte[data_size];
data_size = s->read(data, data_size);
/* for (int i = 0; i < data_size; ++i) {
debug(0, "%02x ", data[i]);
}
debug(0, ", %u frames", data_size / 3);
*/
/* for (int i = 0; i < data_size; ++i) {
debug(0, "%02x ", data[i]);
}
debug(0, ", %u frames", data_size / 3);
*/
frames_count = s->readByte();
debug(0, "%u physical frames", frames_count);
if (frames_count == 0)
return;
frames = new Surface[frames_count];
s->skip(frames_count * 2 - 2); //sizes
pos = s->readUint16LE();
//debug(0, "pos?: %04x", pos);
for (uint16 i = 0; i < frames_count; ++i) {
frames[i].load(s, Surface::TypeLan);
frames[i].x = 0;
@ -154,7 +154,8 @@ void Animation::load(Common::SeekableReadStream *s, Type type) {
frames_count = 0;
for (byte i = 0; i < data_size / 3; ++i) {
int idx = i * 3;
/* byte unk = */ s->readByte();
/* byte unk = */
s->readByte();
data[idx] = s->readByte();
if (data[idx] == 0)
data[idx] = 1; //fixme: investigate
@ -164,15 +165,15 @@ void Animation::load(Common::SeekableReadStream *s, Type type) {
data[idx + 2] = 0;
//debug(0, "frame #%u", data[idx]);
}
frames = new Surface[frames_count];
for (uint16 i = 0; i < frames_count; ++i) {
frames[i].load(s, Surface::TypeOns);
}
}
break;
case TypeVaria:
frames_count = s->readByte();
debug(0, "loading varia resource, %u physical frames", frames_count);
@ -189,10 +190,10 @@ void Animation::load(Common::SeekableReadStream *s, Type type) {
frames[i].x = 0;
frames[i].y = 0;
}
break;
}
debug(0, "%u frames", data_size / 3);
}

View File

@ -31,31 +31,31 @@
namespace TeenAgent {
class Animation {
public:
public:
uint16 id, x, y;
bool loop, paused;
enum Type {TypeLan, TypeVaria, TypeInventory};
Animation();
void load(Common::SeekableReadStream *s, Type type = TypeLan);
void free();
Surface *firstFrame();
Surface *currentFrame(int dt = 1);
uint16 currentIndex() const { return index; }
~Animation();
bool empty() const { return frames == NULL; }
//uint16 width() const { return frames? frames[0].w: 0; }
//uint16 height() const { return frames? frames[0].h: 0; }
protected:
byte *data;
uint16 data_size;
uint16 frames_count;
Surface *frames;
uint16 index;

File diff suppressed because it is too large Load Diff

View File

@ -50,13 +50,13 @@ static const ADGameDescription teenAgentGameDescriptions[] = {
{"sam_mmm.res", 0, NULL, -1},
{"sam_sam.res", 0, NULL, -1},
{NULL, 0, NULL, 0}
},
},
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
AD_TABLE_END_MARKER,
},
AD_TABLE_END_MARKER,
};
static const ADParams detectionParams = {
@ -91,7 +91,7 @@ public:
case kSupportsListSaves:
case kSupportsDeleteSave:
case kSupportsLoadingDuringStartup:
//case kSavesSupportThumbnail:
//case kSavesSupportThumbnail:
return true;
default:
return false;
@ -118,7 +118,7 @@ public:
virtual SaveStateList listSaves(const char *target) const {
Common::String pattern = target;
pattern += ".*";
Common::StringList filenames = g_system->getSavefileManager()->listSavefiles(pattern);
bool slotsTable[MAX_SAVES];
memset(slotsTable, 0, sizeof(slotsTable));
@ -155,7 +155,7 @@ public:
};
#if PLUGIN_ENABLED_DYNAMIC(TEENAGENT)
REGISTER_PLUGIN_DYNAMIC(TEENAGENT, PLUGIN_TYPE_ENGINE, TeenAgentMetaEngine);
REGISTER_PLUGIN_DYNAMIC(TEENAGENT, PLUGIN_TYPE_ENGINE, TeenAgentMetaEngine);
#else
REGISTER_PLUGIN_STATIC(TEENAGENT, PLUGIN_TYPE_ENGINE, TeenAgentMetaEngine);
REGISTER_PLUGIN_STATIC(TEENAGENT, PLUGIN_TYPE_ENGINE, TeenAgentMetaEngine);
#endif

View File

@ -36,7 +36,7 @@ void Dialog::show(Scene *scene, uint16 addr, uint16 animation1, uint16 animation
int n = 0;
Common::String message;
byte color = color1;
if (animation1 != 0) {
SceneEvent e(SceneEvent::PlayAnimation);
e.animation = animation1;
@ -50,22 +50,22 @@ void Dialog::show(Scene *scene, uint16 addr, uint16 animation1, uint16 animation
e.color = 0xc0 | slot2; //looped, paused
scene->push(e);
}
while (n < 4) {
byte c = res->eseg.get_byte(addr++);
//debug(0, "%02x: %c", c, c > 0x20? c: '.');
switch(c) {
switch (c) {
case 0:
++n;
switch(n) {
case 1:
switch (n) {
case 1:
//debug(0, "new line\n");
message += '\n';
break;
case 2:
case 2:
//debug(0, "displaymessage\n");
if (color == color2 && animation2 != 0) {
//pause animation in other slot
{
@ -93,7 +93,7 @@ void Dialog::show(Scene *scene, uint16 addr, uint16 animation1, uint16 animation
scene->push(e);
}
}
{
SceneEvent e(SceneEvent::Message);
e.message = message;
@ -103,19 +103,18 @@ void Dialog::show(Scene *scene, uint16 addr, uint16 animation1, uint16 animation
}
break;
case 3:
color = color == color1? color2: color1;
case 3:
color = color == color1 ? color2 : color1;
//debug(0, "changing color to %02x", color);
break;
}
break;
case 0xff:
{
//fixme : wait for the next cycle of the animation
}
break;
case 0xff: {
//fixme : wait for the next cycle of the animation
}
break;
default:
message += c;
n = 0;

View File

@ -32,7 +32,7 @@ namespace TeenAgent {
class Scene;
class Dialog {
public:
public:
static uint16 pop(Scene *scene, uint16 addr, uint16 animation1 = 0, uint16 animation2 = 0, byte color1 = 0xd1, byte color2 = 0xd0, byte slot1 = 1, byte slot2 = 2);
static void show(Scene *scene, uint16 addr, uint16 animation1 = 0, uint16 animation2 = 0, byte color1 = 0xd1, byte color2 = 0xd0, byte slot1 = 1, byte slot2 = 2);
};

View File

@ -33,7 +33,7 @@ Font::Font() : grid_color(0xd0), color(0xd1), shadow_color(0), height(0), width_
void Font::load(int id) {
delete[] data;
data = NULL;
Common::SeekableReadStream * s = Resources::instance()->varia.getStream(id);
if (s == NULL)
error("loading font %d failed", id);
@ -62,11 +62,11 @@ uint Font::render(Graphics::Surface *surface, int x, int y, char c) {
for (uint i = 0; i < h; ++i) {
for (uint j = 0; j < w; ++j) {
byte v = *glyph++;
switch(v) {
switch (v) {
case 1:
dst[j] = shadow_color;
break;
case 2:
case 2:
dst[j] = color;
break;
}
@ -86,19 +86,19 @@ uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String
uint max_w = render(NULL, 0, 0, str, false);
if (show_grid)
grid(surface, x - 4, y - 2, max_w + 8, 8 + 6, grid_color);
uint i = 0, j;
do {
j = find_in_str(str, '\n', i);
Common::String line(str.c_str() + i, j - i);
//debug(0, "line: %s", line.c_str());
uint w = render(NULL, 0, 0, line, false);
int xp = x + (max_w - w) / 2;
for (uint k = 0; k < line.size(); ++k) {
xp += render(surface, xp, y, line[k]);
}
y += height;
i = j + 1;
} while (i < str.size());
@ -119,7 +119,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String
}
if (w > max_w)
max_w = w;
return max_w;
}
}

View File

@ -30,18 +30,18 @@
namespace TeenAgent {
class Font {
public:
public:
byte grid_color, color, shadow_color;
byte height, width_pack;
Font();
void load(int id);
uint render(Graphics::Surface *surface, int x, int y, const Common::String &str, bool grid = false);
uint render(Graphics::Surface *surface, int x, int y, char c);
static void grid(Graphics::Surface *surface, int x, int y, int w, int h, byte color);
~Font();
private:
private:
byte *data;
};

View File

@ -35,15 +35,15 @@ void Inventory::init(TeenAgentEngine *engine) {
_engine = engine;
_active = false;
Resources *res = Resources::instance();
Common::SeekableReadStream *s = res->varia.getStream(3);
assert(s != NULL);
debug(0, "loading inventory background...");
background.load(s, Surface::TypeOns);
items = res->varia.getStream(4);
assert(items != NULL);
byte offsets = items->readByte();
assert(offsets == 92);
for (byte i = 0; i < offsets; ++i) {
@ -51,8 +51,8 @@ void Inventory::init(TeenAgentEngine *engine) {
}
objects = res->dseg.ptr(0xc4a4);
inventory = res->dseg.ptr(0xc48d);
for (int y = 0; y < 4; ++y)
for (int y = 0; y < 4; ++y)
for (int x = 0; x < 6; ++x) {
int i = y * 6 + x;
graphics[i].rect.left = 28 + 45 * x - 1;
@ -60,13 +60,13 @@ void Inventory::init(TeenAgentEngine *engine) {
graphics[i].rect.right = graphics[i].rect.left + 40;
graphics[i].rect.bottom = graphics[i].rect.top + 26;
}
hovered_obj = selected_obj = NULL;
}
bool Inventory::has(byte item) const {
for (int i = 0; i < 24; ++i) {
if (inventory[i] == item)
if (inventory[i] == item)
return true;
}
return false;
@ -112,8 +112,8 @@ void Inventory::add(byte item) {
bool Inventory::processEvent(const Common::Event &event) {
Resources *res = Resources::instance();
switch(event.type) {
switch (event.type) {
case Common::EVENT_MOUSEMOVE:
mouse = event.mouse;
if (!active() && event.mouse.y < 5) {
@ -125,17 +125,17 @@ bool Inventory::processEvent(const Common::Event &event) {
activate(false);
return _active;
}
if (!_active)
return false;
hovered_obj = NULL;
for (int i = 0; i < 24; ++i) {
byte item = inventory[i];
if (item == 0)
continue;
graphics[i].hovered = graphics[i].rect.in(mouse);
if (graphics[i].hovered)
hovered_obj = (InventoryObject *)res->dseg.ptr(READ_LE_UINT16(objects + item * 2));
@ -160,8 +160,8 @@ bool Inventory::processEvent(const Common::Event &event) {
byte *table = res->dseg.ptr(0xC335);
while (table[0] != 0 && table[1] != 0) {
if (
(id1 == table[0] && id2 == table[1]) ||
(id2 == table[0] && id1 == table[1])
(id1 == table[0] && id2 == table[1]) ||
(id2 == table[0] && id1 == table[1])
) {
remove(id1);
remove(id2);
@ -179,18 +179,18 @@ bool Inventory::processEvent(const Common::Event &event) {
activate(false);
resetSelectedObject();
return true;
}
}
case Common::EVENT_RBUTTONDOWN:
if (!_active)
return false;
if (hovered_obj != NULL) {
byte id = hovered_obj->id;
debug(0, "rclick object %u", id);
uint i = 0;
for (byte *table = res->dseg.ptr(0xBB6F + 3); //original offset + 3 bytes.
table[0] != 0 && i < 7; table += 3, ++i) {
table[0] != 0 && i < 7; table += 3, ++i) {
if (table[0] == id) {
resetSelectedObject();
activate(false);
@ -199,7 +199,7 @@ bool Inventory::processEvent(const Common::Event &event) {
}
}
}
selected_obj = hovered_obj;
if (selected_obj)
debug(0, "selected object %s", selected_obj->name);
@ -215,8 +215,8 @@ bool Inventory::processEvent(const Common::Event &event) {
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONUP:
return _active;
default:
default:
return false;
}
}
@ -229,8 +229,8 @@ void Inventory::Item::free() {
void Inventory::Item::render(Inventory *inventory, InventoryObject *obj, Graphics::Surface *dst) {
Resources *res = Resources::instance();
rect.render(dst, hovered? 233: 234);
rect.render(dst, hovered ? 233 : 234);
if (obj->animated) {
if (animation.empty()) {
debug(0, "loading item %d from offset %x", obj->id, inventory->offset[obj->id - 1]);
@ -263,7 +263,7 @@ void Inventory::Item::render(Inventory *inventory, InventoryObject *obj, Graphic
name += " & ";
}
name += obj->name;
if (hovered) {
int w = res->font7.render(NULL, 0, 0, name, true);
res->font7.render(dst, (320 - w) / 2, 180, name, true);
@ -276,16 +276,16 @@ void Inventory::render(Graphics::Surface *surface) {
background.render(surface);
Resources *res = Resources::instance();
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 6; x++) {
int idx = x + 6 * y;
byte item = inventory[idx];
if (item == 0)
continue;
//debug(0, "%d,%d -> %u", x0, y0, item);
InventoryObject *obj = (InventoryObject *)res->dseg.ptr(READ_LE_UINT16(objects + item * 2));
graphics[idx].render(this, obj, surface);
}

View File

@ -47,7 +47,7 @@ public:
void activate(bool a) { _active = a; }
bool active() const { return _active; }
bool processEvent(const Common::Event &event);
InventoryObject *selectedObject() { return selected_obj; }
@ -58,7 +58,7 @@ private:
Surface background;
Common::SeekableReadStream *items;
uint16 offset[92];
byte *objects;
byte *inventory;
struct Item {
@ -66,12 +66,12 @@ private:
Surface surface;
Rect rect;
bool hovered;
Item() : hovered(false) {}
void free();
void render(Inventory *inventory, InventoryObject *obj, Graphics::Surface *surface);
} graphics[24];
bool _active;
Common::Point mouse;
int hovered;

View File

@ -46,11 +46,11 @@ bool MusicPlayer::load(int id) {
Common::SeekableReadStream *stream = res->mmm.getStream(id);
if (stream == NULL)
return false;
char header[4];
stream->read(header, 4);
//check header?
//check header?
memset(_samples, 0, sizeof(_samples));
// Load the samples
@ -67,14 +67,14 @@ bool MusicPlayer::load(int id) {
debug(0, "currSample = %d, sample = 0x%02x, resource: %d", currSample, sample, sampleResource);
uint32 sampleSize = res->sam_mmm.get_size(sampleResource);
Common::SeekableReadStream *in = res->sam_mmm.getStream(sampleResource);
if (in == 0) {
warning("load: invalid sample %d (0x%02x)", sample, sample);
_samples[sample].data = NULL;
_samples[sample].size = 0;
continue;
}
byte *sampleData = new byte[sampleSize];
in->read(sampleData, sampleSize);
@ -90,7 +90,7 @@ bool MusicPlayer::load(int id) {
// Load the music data
_rows.clear();
Row row;
row.channels[0].sample = 0;
row.channels[1].sample = 0;
@ -132,7 +132,7 @@ void MusicPlayer::stop() {
void MusicPlayer::interrupt() {
_currRow %= _rows.size();
Row *row = &_rows[_currRow];
for (int chn = 0; chn < 3; ++chn) {
setChannelVolume(chn, row->channels[chn].volume);

View File

@ -46,7 +46,7 @@ protected:
int _id;
struct Row {
struct Channel{
struct Channel {
byte sample;
byte volume;
byte note;

View File

@ -35,25 +35,25 @@ void Rect::render(Graphics::Surface *surface, uint8 color) const {
}
void Walkbox::dump() {
debug(0, "walkbox %02x %02x [%d, %d, %d, %d] %02x %02x %02x %02x ",
unk00, orientation,
rect.left, rect.right, rect.top, rect.bottom,
unk0a, unk0b, unk0c, unk0d);
debug(0, "walkbox %02x %02x [%d, %d, %d, %d] %02x %02x %02x %02x ",
unk00, orientation,
rect.left, rect.right, rect.top, rect.bottom,
unk0a, unk0b, unk0c, unk0d);
}
void Object::dump() {
debug(0, "object: %u %u [%u,%u,%u,%u], actor: [%u,%u,%u,%u], orientation: %u, name: %s", id, enabled,
rect.left, rect.top, rect.right, rect.bottom,
actor_rect.left, actor_rect.top, actor_rect.right, actor_rect.bottom,
actor_orientation, name
);
debug(0, "object: %u %u [%u,%u,%u,%u], actor: [%u,%u,%u,%u], orientation: %u, name: %s", id, enabled,
rect.left, rect.top, rect.right, rect.bottom,
actor_rect.left, actor_rect.top, actor_rect.right, actor_rect.bottom,
actor_orientation, name
);
}
Common::String Object::description(const char *name) {
const char *desc = name + strlen(name) + 1;
if (*desc == 0)
return Common::String();
Common::String result;
while (*desc != 1 && *desc != 0) {
@ -62,17 +62,17 @@ Common::String Object::description(const char *name) {
//debug(0, "%02x ", *desc);
line += *desc++;
}
if (line.empty())
break;
++desc;
result += line;
result += '\n';
}
if (!result.empty())
result.deleteLastChar();
else
else
result = "Cool.";
return result;
}

View File

@ -40,7 +40,7 @@ struct Rect {
inline Rect() : left(0), top(0), right(0), bottom(0) {}
inline Rect(uint16 l, uint16 t, uint16 r, uint16 b) : left(l), top(t), right(r), bottom(b) {}
inline bool in(const Common::Point &point) const {
return point.x >= left && point.x <= right && point.y >= top && point.y <= bottom;
}
@ -54,7 +54,7 @@ struct Rect {
void dump() {
debug(0, "rect[%u, %u, %u, %u]", left, top, right, bottom);
}
void clear() {
left = top = right = bottom = 0;
}

View File

@ -51,10 +51,10 @@ void Pack::open(const Common::String &filename) {
offsets[i] = file.readUint32LE();
//debug(0, "%d: %06x", i, offsets[i]);
}
/* for (uint32 i = 0; i < count; ++i) {
debug(0, "%d: len = %d", i, offsets[i + 1] - offsets[i]);
}
*/
/* for (uint32 i = 0; i < count; ++i) {
debug(0, "%d: len = %d", i, offsets[i + 1] - offsets[i]);
}
*/
}
uint32 Pack::get_size(uint32 id) const {

View File

@ -34,7 +34,7 @@ class Pack {
uint32 count;
uint32 *offsets;
public:
public:
Pack();
~Pack();
void open(const Common::String &filename);

View File

@ -77,7 +77,7 @@ bool Resources::loadArchives(const ADGameDescription *gd) {
font7.height = 10;
font8.load(8);
font8.height = 31;
return true;
}
@ -97,14 +97,14 @@ void Resources::loadOff(Graphics::Surface &surface, byte *palette, int id) {
}
Common::SeekableReadStream *Resources::loadLan(uint32 id) const {
return id <= 500? loadLan000(id): lan500.getStream(id - 500);
return id <= 500 ? loadLan000(id) : lan500.getStream(id - 500);
}
Common::SeekableReadStream *Resources::loadLan000(uint32 id) const {
switch(id) {
switch (id) {
case 81:
if (dseg.get_byte(0xDBAD))
if (dseg.get_byte(0xDBAD))
return lan500.getStream(160);
break;
@ -112,25 +112,25 @@ Common::SeekableReadStream *Resources::loadLan000(uint32 id) const {
if (dseg.get_byte(0xDBC5) == 1) {
if (dseg.get_byte(0xDBC6) == 1)
return lan500.getStream(203);
else
else
return lan500.getStream(202);
}
break;
case 25:
case 25:
if (dseg.get_byte(0xDBDF) == 2) {
return lan500.getStream(332);
}
break;
case 37:
case 37:
if (dseg.get_byte(0xdbe2) == 1) {
return lan500.getStream(351);
} else if (dseg.get_byte(0xdbe2) == 2) {
return lan500.getStream(364);
}
break;
case 29:
if (dseg.get_byte(0xDBE7) == 1) {
return lan500.getStream(380);

View File

@ -37,7 +37,7 @@ namespace TeenAgent {
class Resources {
protected:
Resources();
public:
public:
static Resources *instance();
bool loadArchives(const ADGameDescription *gd);
void deinit();

View File

@ -33,21 +33,22 @@
namespace TeenAgent {
Scene::Scene() : intro(false), _engine(NULL),
_system(NULL),
_id(0), ons(0), walkboxes(0),
orientation(Object::ActorRight),
current_event(SceneEvent::None), hide_actor(false) {}
Scene::Scene() : intro(false), _engine(NULL),
_system(NULL),
_id(0), ons(0), walkboxes(0),
orientation(Object::ActorRight),
current_event(SceneEvent::None), hide_actor(false) {}
void Scene::warp(const Common::Point & _point, byte o) {
void Scene::warp(const Common::Point &_point, byte o) {
Common::Point point(_point);
destination = position = position0 = point;
progress = 0; progress_total = 1;
destination = position = position0 = point;
progress = 0;
progress_total = 1;
if (o)
orientation = o;
}
void Scene::moveTo(const Common::Point & _point, byte orient, bool validate) {
void Scene::moveTo(const Common::Point &_point, byte orient, bool validate) {
Common::Point point(_point);
debug(0, "moveTo(%d, %d, %u)", point.x, point.y, orient);
if (validate) {
@ -56,11 +57,11 @@ void Scene::moveTo(const Common::Point & _point, byte orient, bool validate) {
if (w->rect.in(point)) {
debug(0, "bumped into walkbox %u", i);
byte o = w->orientation;
switch(o) {
switch (o) {
case 1:
point.y = w->rect.top - 1;
break;
case 2:
case 2:
point.x = w->rect.right + 1;
break;
case 3:
@ -83,8 +84,8 @@ void Scene::moveTo(const Common::Point & _point, byte orient, bool validate) {
}
destination = point;
orientation = orient;
position0 = position;
progress_total = 1 + (int)(sqrt((float)position.sqrDist(destination)) / 10);
position0 = position;
progress_total = 1 + (int)(sqrt((float)position.sqrDist(destination)) / 10);
progress = 0;
}
@ -92,7 +93,7 @@ void Scene::moveTo(const Common::Point & _point, byte orient, bool validate) {
void Scene::init(TeenAgentEngine *engine, OSystem *system) {
_engine = engine;
_system = system;
Resources *res = Resources::instance();
Common::SeekableReadStream *s = res->varia.getStream(1);
if (s == NULL)
@ -101,11 +102,11 @@ void Scene::init(TeenAgentEngine *engine, OSystem *system) {
teenagent.load(s, Animation::TypeVaria);
if (teenagent.empty())
error("invalid mark animation");
s = res->varia.getStream(2);
if (s == NULL)
error("invalid resource data");
teenagent_idle.load(s, Animation::TypeVaria);
if (teenagent_idle.empty())
error("invalid mark animation");
@ -127,7 +128,7 @@ void Scene::loadOns() {
uint16 addr = res->dseg.get_word(0xb4f5 + (_id - 1) * 2);
//debug(0, "ons index: %04x", addr);
ons_count = 0;
byte b;
byte on_id[16];
@ -142,7 +143,7 @@ void Scene::loadOns() {
delete[] ons;
ons = NULL;
if (ons_count > 0) {
ons = new Surface[ons_count];
for (uint32 i = 0; i < ons_count; ++i) {
@ -157,10 +158,10 @@ void Scene::loadLans() {
debug(0, "loading lans animation");
Resources *res = Resources::instance();
//load lan000
for (int i = 0; i < 4; ++i) {
animations[i].free();
uint16 bx = 0xd89e + (_id - 1) * 4 + i;
byte bxv = res->dseg.get_byte(bx);
uint16 res_id = 4 * (_id - 1) + i + 1;
@ -171,11 +172,11 @@ void Scene::loadLans() {
Common::SeekableReadStream *s = res->loadLan000(res_id);
if (s != NULL) {
animations[i].load(s, Animation::TypeLan);
if (bxv != 0 && bxv != 0xff)
if (bxv != 0 && bxv != 0xff)
animations[i].id = bxv;
delete s;
}
//uint16 bp = res->dseg.get_word();
}
@ -184,10 +185,10 @@ void Scene::loadLans() {
void Scene::init(int id, const Common::Point &pos) {
debug(0, "init(%d)", id);
_id = id;
if (background.pixels == NULL)
background.create(320, 200, 1);
warp(pos);
Resources *res = Resources::instance();
@ -198,10 +199,10 @@ void Scene::init(int id, const Common::Point &pos) {
//dim down palette
uint i;
for (i = 0; i < 624; ++i) {
palette[i] = palette[i] > 0x20? palette[i] - 0x20: 0;
palette[i] = palette[i] > 0x20 ? palette[i] - 0x20 : 0;
}
for (i = 726; i < 768; ++i) {
palette[i] = palette[i] > 0x20? palette[i] - 0x20: 0;
palette[i] = palette[i] > 0x20 ? palette[i] - 0x20 : 0;
}
}
}
@ -213,7 +214,7 @@ void Scene::init(int id, const Common::Point &pos) {
loadOns();
loadLans();
byte *walkboxes_base = res->dseg.ptr(READ_LE_UINT16(res->dseg.ptr(0x6746 + (id - 1) * 2)));
walkboxes = *walkboxes_base++;
@ -222,11 +223,11 @@ void Scene::init(int id, const Common::Point &pos) {
walkbox[i] = (Walkbox *)(walkboxes_base + 14 * i);
walkbox[i]->dump();
}
//check music
int now_playing = _engine->music->getId();
if (now_playing != res->dseg.get_byte(0xDB90))
if (now_playing != res->dseg.get_byte(0xDB90))
_engine->music->load(res->dseg.get_byte(0xDB90));
}
@ -257,9 +258,9 @@ void Scene::push(const SceneEvent &event) {
}
bool Scene::processEvent(const Common::Event &event) {
switch(event.type) {
switch (event.type) {
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_RBUTTONDOWN:
if (!message.empty()) {
message.clear();
nextEvent();
@ -275,7 +276,7 @@ bool Scene::processEvent(const Common::Event &event) {
sounds.clear();
current_event.clear();
message_color = 0xd1;
for(int i = 0; i < 4; ++i)
for (int i = 0; i < 4; ++i)
custom_animations[i].free();
_engine->playMusic(4);
init(10, Common::Point(136, 153));
@ -299,7 +300,7 @@ bool Scene::render(OSystem *system) {
system->unlockScreen();
return true;
}
bool busy;
bool restart;
@ -364,9 +365,9 @@ bool Scene::render(OSystem *system) {
Common::Point dp(destination.x - position0.x, destination.y - position0.y);
int o;
if (ABS(dp.x) > ABS(dp.y))
o = dp.x > 0? Object::ActorRight: Object::ActorLeft;
o = dp.x > 0 ? Object::ActorRight : Object::ActorLeft;
else
o = dp.y > 0? Object::ActorDown: Object::ActorUp;
o = dp.y > 0 ? Object::ActorDown : Object::ActorUp;
position.x = position0.x + dp.x * progress / progress_total;
position.y = position0.y + dp.y * progress / progress_total;
@ -412,9 +413,9 @@ bool Scene::render(OSystem *system) {
}
*/
} while(restart);
for(Sounds::iterator i = sounds.begin(); i != sounds.end(); ) {
} while (restart);
for (Sounds::iterator i = sounds.begin(); i != sounds.end();) {
Sound &sound = *i;
if (sound.delay == 0) {
debug(0, "sound %u started", sound.id);
@ -425,7 +426,7 @@ bool Scene::render(OSystem *system) {
++i;
}
}
return busy;
}
@ -434,32 +435,35 @@ bool Scene::processEventQueue() {
//debug(0, "processing next event");
current_event = events.front();
events.pop_front();
switch(current_event.type) {
switch (current_event.type) {
case SceneEvent::SetOn: {
byte *ptr = getOns(current_event.scene == 0? _id: current_event.scene);
byte *ptr = getOns(current_event.scene == 0 ? _id : current_event.scene);
debug(0, "on[%u] = %02x", current_event.ons - 1, current_event.color);
ptr[current_event.ons - 1] = current_event.color;
loadOns();
current_event.clear();
} break;
}
break;
case SceneEvent::SetLan: {
if (current_event.lan != 0) {
debug(0, "lan[%u] = %02x", current_event.lan - 1, current_event.color);
byte *ptr = getLans(current_event.scene == 0? _id: current_event.scene);
byte *ptr = getLans(current_event.scene == 0 ? _id : current_event.scene);
ptr[current_event.lan - 1] = current_event.color;
}
loadLans();
current_event.clear();
} break;
}
break;
case SceneEvent::LoadScene: {
init(current_event.scene, current_event.dst);
sounds.clear();
current_event.clear();
} break;
}
break;
case SceneEvent::Walk: {
Common::Point dst = current_event.dst;
if ((current_event.color & 2) != 0) { //relative move
@ -471,17 +475,18 @@ bool Scene::processEventQueue() {
current_event.clear();
} else
moveTo(dst, current_event.orientation);
} break;
case SceneEvent::CreditsMessage:
case SceneEvent::Message:
}
break;
case SceneEvent::CreditsMessage:
case SceneEvent::Message:
//debug(0, "pop(%04x)", current_event.message);
message = current_event.message;
message_pos = messagePosition(message, position);
message_color = current_event.color;
break;
case SceneEvent::PlayAnimation:
case SceneEvent::PlayAnimation:
debug(0, "playing animation %u", current_event.animation);
playAnimation(current_event.color & 0x3 /*slot actually :)*/, current_event.animation, (current_event.color & 0x80) != 0, (current_event.color & 0x40) != 0);
current_event.clear();
@ -494,17 +499,17 @@ bool Scene::processEventQueue() {
break;
case SceneEvent::ClearAnimations:
for(byte i = 0; i < 4; ++i)
for (byte i = 0; i < 4; ++i)
custom_animations[i].free();
current_event.clear();
break;
case SceneEvent::PlayActorAnimation:
case SceneEvent::PlayActorAnimation:
debug(0, "playing actor animation %u", current_event.animation);
playActorAnimation(current_event.animation, (current_event.color & 0x80) != 0);
current_event.clear();
break;
case SceneEvent::PlayMusic:
debug(0, "setting music %u", current_event.music);
_engine->setMusic(current_event.music);
@ -521,30 +526,30 @@ bool Scene::processEventQueue() {
}
current_event.clear();
break;
case SceneEvent::EnableObject: {
debug(0, "%s object #%u", current_event.color?"enabling":"disabling", current_event.object - 1);
Object *obj = getObject(current_event.object - 1, current_event.scene == 0? _id: current_event.scene);
obj->enabled = current_event.color;
current_event.clear();
}
break;
debug(0, "%s object #%u", current_event.color ? "enabling" : "disabling", current_event.object - 1);
Object *obj = getObject(current_event.object - 1, current_event.scene == 0 ? _id : current_event.scene);
obj->enabled = current_event.color;
current_event.clear();
}
break;
case SceneEvent::HideActor:
hide_actor = current_event.color != 0;
current_event.clear();
break;
case SceneEvent::WaitForAnimation:
debug(0, "waiting for the animation");
break;
case SceneEvent::Quit:
debug(0, "quit!");
_engine->quitGame();
break;
default:
default:
error("empty/unhandler event[%d]", (int)current_event.type);
}
}
@ -560,7 +565,7 @@ void Scene::setPalette(OSystem *system, const byte *buf, unsigned mul) {
memset(p, 0, 1024);
for (int i = 0; i < 256; ++i) {
for (int c = 0; c < 3; ++c)
for (int c = 0; c < 3; ++c)
p[i * 4 + c] = buf[i * 3 + c] * mul;
}
@ -570,7 +575,7 @@ void Scene::setPalette(OSystem *system, const byte *buf, unsigned mul) {
Object *Scene::getObject(int id, int scene_id) {
if (scene_id == 0)
scene_id = _id;
Resources *res = Resources::instance();
uint16 addr = res->dseg.get_word(0x7254 + (scene_id - 1) * 2);
//debug(0, "object base: %04x, x: %d, %d", addr, point.x, point.y);
@ -580,7 +585,7 @@ Object *Scene::getObject(int id, int scene_id) {
return obj;
}
Common::Point Scene::messagePosition(const Common::String &str, const Common::Point & position) {
Common::Point Scene::messagePosition(const Common::String &str, const Common::Point &position) {
Resources *res = Resources::instance();
uint w = res->font7.render(NULL, 0, 0, str);
Common::Point message_pos = position;

View File

@ -39,11 +39,11 @@ class TeenAgentEngine;
class Dialog;
struct SceneEvent {
enum Type {
None, Message, Walk, PlayAnimation, PlayActorAnimation, PauseAnimation, ClearAnimations,
LoadScene, SetOn, SetLan, PlayMusic,
PlaySound, EnableObject, HideActor,
WaitForAnimation, CreditsMessage,
enum Type {
None, Message, Walk, PlayAnimation, PlayActorAnimation, PauseAnimation, ClearAnimations,
LoadScene, SetOn, SetLan, PlayMusic,
PlaySound, EnableObject, HideActor,
WaitForAnimation, CreditsMessage,
Quit
} type;
@ -59,9 +59,9 @@ struct SceneEvent {
byte sound;
byte object;
SceneEvent(Type type_) :
type(type_), message(), color(0xd1), animation(0), orientation(0), dst(),
scene(0), ons(0), lan(0), music(0), sound(0), object(0) {}
SceneEvent(Type type_) :
type(type_), message(), color(0xd1), animation(0), orientation(0), dst(),
scene(0), ons(0), lan(0), music(0), sound(0), object(0) {}
void clear() {
type = None;
@ -77,47 +77,47 @@ struct SceneEvent {
sound = 0;
object = 0;
}
inline bool empty() const {
return type == None;
}
void dump() const {
debug(0, "event[%d]: \"%s\"[%02x], animation: %u, dst: (%d, %d) [%u], scene: %u, ons: %u, lan: %u, object: %u, music: %u, sound: %u",
(int)type, message.c_str(), color, animation, dst.x, dst.y, orientation, scene, ons, lan, object, music, sound
);
debug(0, "event[%d]: \"%s\"[%02x], animation: %u, dst: (%d, %d) [%u], scene: %u, ons: %u, lan: %u, object: %u, music: %u, sound: %u",
(int)type, message.c_str(), color, animation, dst.x, dst.y, orientation, scene, ons, lan, object, music, sound
);
}
};
class Scene {
public:
bool intro;
public:
bool intro;
Scene();
void init(TeenAgentEngine *engine, OSystem *system);
void init(int id, const Common::Point &pos);
bool render(OSystem *system);
int getId() const { return _id; }
void warp(const Common::Point & point, byte orientation = 0);
void moveTo(const Common::Point & point, byte orientation = 0, bool validate = 0);
void warp(const Common::Point &point, byte orientation = 0);
void moveTo(const Common::Point &point, byte orientation = 0, bool validate = 0);
Common::Point getPosition() const { return position; }
void displayMessage(const Common::String &str, byte color = 0xd1);
void setOrientation(uint8 o) { orientation = o; }
void push(const SceneEvent &event);
bool processEvent(const Common::Event &event);
void clear();
byte *getOns(int id);
byte *getLans(int id);
bool eventRunning() const { return !current_event.empty(); }
Walkbox *getWalkbox(byte id) { return walkbox[id]; }
Object *getObject(int id, int scene_id = 0);
@ -127,20 +127,20 @@ private:
void playAnimation(byte idx, uint id, bool loop, bool paused);
void playActorAnimation(uint id, bool loop);
byte palette[768];
void setPalette(OSystem *system, const byte *palette, unsigned mul = 1);
static Common::Point messagePosition(const Common::String &str, const Common::Point & position);
static Common::Point messagePosition(const Common::String &str, const Common::Point &position);
bool processEventQueue();
inline bool nextEvent() {
current_event.clear();
return processEventQueue();
}
TeenAgentEngine *_engine;
OSystem *_system;
int _id;
Graphics::Surface background;
Surface on;
@ -152,19 +152,19 @@ private:
Common::Point position0, position, destination;
int progress, progress_total;
uint8 orientation;
byte walkboxes;
Walkbox *walkbox[255];
Common::String message;
Common::Point message_pos;
byte message_color;
typedef Common::List<SceneEvent> EventList;
EventList events;
SceneEvent current_event;
bool hide_actor;
struct Sound {
byte id, delay;
Sound(byte i, byte d): id(i), delay(d) {}

View File

@ -34,12 +34,12 @@ class Segment {
uint32 _size;
byte *_data;
public:
public:
Segment() : _size(0), _data(0) {}
~Segment();
void read(Common::ReadStream *s, uint32 _size);
inline byte get_byte(uint32 offset) const {
assert(offset < _size);
return _data[offset];
@ -64,7 +64,7 @@ public:
assert(offset + 3 < _size);
return WRITE_LE_UINT32(_data + offset, v);
}
const byte *ptr(uint32 addr) const {
assert(addr < _size);
return _data + addr;

View File

@ -36,24 +36,24 @@ Surface::Surface() : x(0), y(0) {
void Surface::load(Common::SeekableReadStream *stream, Type type) {
//debug(0, "load()");
free();
x = y = 0;
memset(flags, 0, sizeof(flags));
if (type == TypeOn) {
byte fn = stream->readByte();
if (stream->eos())
return;
for (byte i = 0; i < fn; ++i) {
flags[i] = stream->readUint16LE();
debug(0, "flags[%u] = %u (0x%04x)", i, flags[i], flags[i]);
}
}
uint16 w_ = stream->readUint16LE();
uint16 h_ = stream->readUint16LE();
if (type != TypeLan) {
uint16 pos = stream->readUint16LE();
x = pos % 320;
@ -63,7 +63,7 @@ void Surface::load(Common::SeekableReadStream *stream, Type type) {
//debug(0, "declared info: %ux%u (%04xx%04x) -> %u,%u", w_, h_, w_, h_, x, y);
if (stream->eos() || w_ == 0)
return;
if (w_ * h_ > stream->size()) {//rough but working
debug(0, "invalid surface %ux%u -> %u,%u", w_, h_, x, y);
return;
@ -81,7 +81,7 @@ void Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror) {
byte *src = (byte *)pixels;
byte *dst = (byte *)surface->getBasePtr(dx + x, dy + y);
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
byte p = src[j];

View File

@ -37,7 +37,7 @@ public:
uint16 flags[255];
uint16 x, y;
Surface();
void load(Common::SeekableReadStream *stream, Type type);
void render(Graphics::Surface *surface, int dx = 0, int dy = 0, bool mirror = false);

View File

@ -56,40 +56,39 @@ void TeenAgentEngine::processObject() {
scene->displayMessage(desc);
//debug(0, "%s[%u]: description: %s", current_object->name, current_object->id, desc.c_str());
}
}
break;
case ActionUse:
{
InventoryObject *inv = inventory->selectedObject();
if (inv != NULL) {
byte *dcall = res->dseg.ptr(0xbb87);
dcall = res->dseg.ptr(READ_LE_UINT16(dcall + scene->getId() * 2 - 2));
for (UseObject *obj = (UseObject *)dcall; obj->inventory_id != 0; ++obj) {
if (obj->inventory_id == inv->id && dst_object->id == obj->object_id) {
debug(0, "combine! %u,%u", obj->x, obj->y);
//moveTo(Common::Point(obj->x, obj->y), NULL, Examine);
inventory->resetSelectedObject();
if (!processCallback(obj->callback))
debug(0, "fixme! display proper description");
return;
}
}
break;
case ActionUse: {
InventoryObject *inv = inventory->selectedObject();
if (inv != NULL) {
byte *dcall = res->dseg.ptr(0xbb87);
dcall = res->dseg.ptr(READ_LE_UINT16(dcall + scene->getId() * 2 - 2));
for (UseObject *obj = (UseObject *)dcall; obj->inventory_id != 0; ++obj) {
if (obj->inventory_id == inv->id && dst_object->id == obj->object_id) {
debug(0, "combine! %u,%u", obj->x, obj->y);
//moveTo(Common::Point(obj->x, obj->y), NULL, Examine);
inventory->resetSelectedObject();
if (!processCallback(obj->callback))
debug(0, "fixme! display proper description");
return;
}
//error
inventory->resetSelectedObject();
displayMessage(0x3457);
break;
} else {
byte *dcall = res->dseg.ptr(0xb89c);
dcall = res->dseg.ptr(READ_LE_UINT16(dcall + scene->getId() * 2 - 2));
dcall += 2 * dst_object->id - 2;
uint16 callback = READ_LE_UINT16(dcall);
if (!processCallback(callback))
scene->displayMessage(dst_object->description());
}
//error
inventory->resetSelectedObject();
displayMessage(0x3457);
break;
} else {
byte *dcall = res->dseg.ptr(0xb89c);
dcall = res->dseg.ptr(READ_LE_UINT16(dcall + scene->getId() * 2 - 2));
dcall += 2 * dst_object->id - 2;
uint16 callback = READ_LE_UINT16(dcall);
if (!processCallback(callback))
scene->displayMessage(dst_object->description());
}
break;
}
break;
case ActionNone:
break;
@ -104,7 +103,7 @@ void TeenAgentEngine::use(Object *object) {
dst_object = object;
object->rect.dump();
object->actor_rect.dump();
if (object->actor_rect.valid())
scene->moveTo(Common::Point(object->actor_rect.right, object->actor_rect.bottom), object->actor_orientation);
if (object->actor_orientation > 0)
@ -115,7 +114,7 @@ void TeenAgentEngine::use(Object *object) {
void TeenAgentEngine::examine(const Common::Point &point, Object *object) {
if (scene->eventRunning())
return;
if (object != NULL) {
Common::Point dst = object->actor_rect.center();
debug(0, "click %d, %d, object %d, %d", point.x, point.y, dst.x, dst.y);
@ -158,11 +157,11 @@ Common::Error TeenAgentEngine::loadGameState(int slot) {
delete in;
return Common::kReadingFailed;
}
delete in;
memcpy(res->dseg.ptr(0x6478), data, sizeof(data));
scene->clear();
setMusic(Resources::instance()->dseg.get_byte(0xDB90));
@ -198,25 +197,25 @@ Common::Error TeenAgentEngine::run() {
Resources *res = Resources::instance();
if (!res->loadArchives(_gameDescription))
return Common::kUnknownError;
Common::EventManager *_event = _system->getEventManager();
initGraphics(320, 200, false);
scene = new Scene;
inventory = new Inventory;
scene->init(this, _system);
inventory->init(this);
_system->setMouseCursor(res->dseg.ptr(0x00da), 8, 12, 0, 0, 1);
syncSoundSettings();
music->load(1);
_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, music, -1, 255, 0, true, false);
music->start();
{
int load_slot = Common::ConfigManager::instance().getInt("save_slot");
debug(0, "slot: %d", load_slot);
@ -230,26 +229,26 @@ Common::Error TeenAgentEngine::run() {
}
uint32 frame = 0;
Common::Event event;
Common::Point mouse;
do {
_system->showMouse(true);
uint32 t0 = _system->getMillis();
Object *current_object = findObject(scene->getId(), mouse);
while (_event->pollEvent(event)) {
if (event.type == Common::EVENT_RTL) {
deinit();
return Common::kNoError;
}
if ((!scene_busy && inventory->processEvent(event)) || scene->processEvent(event))
if ((!scene_busy && inventory->processEvent(event)) || scene->processEvent(event))
continue;
//debug(0, "event");
switch(event.type) {
switch (event.type) {
case Common::EVENT_LBUTTONDOWN:
examine(event.mouse, current_object);
break;
@ -259,10 +258,11 @@ Common::Error TeenAgentEngine::run() {
case Common::EVENT_MOUSEMOVE:
mouse = event.mouse;
break;
default:;
default:
;
}
}
uint32 f0 = frame * 10 / 25, f1 = (frame + 1) * 10 / 25;
if (f0 != f1) {
bool b = scene->render(_system);
@ -274,7 +274,7 @@ Common::Error TeenAgentEngine::run() {
}
}
bool busy = inventory->active() || scene_busy;
Graphics::Surface *surface = _system->lockScreen();
if (!busy) {
@ -287,7 +287,7 @@ Common::Error TeenAgentEngine::run() {
}
if (current_object)
name += current_object->name;
uint w = res->font7.render(NULL, 0, 0, name);
res->font7.render(surface, (320 - w) / 2, 180, name, true);
if (current_object) {
@ -296,17 +296,17 @@ Common::Error TeenAgentEngine::run() {
}
}
}
inventory->render(surface);
_system->unlockScreen();
_system->updateScreen();
uint32 dt = _system->getMillis() - t0;
if (dt < 40)
_system->delayMillis(40 - dt);
++frame;
} while (!_event->shouldQuit());
@ -319,10 +319,10 @@ Object *TeenAgentEngine::findObject(int id, const Common::Point &point) {
uint16 addr = res->dseg.get_word(0x7254 + (id - 1) * 2);
//debug(0, "object base: %04x, x: %d, %d", addr, point.x, point.y);
uint16 object;
for (;(object = res->dseg.get_word(addr)) != 0; addr += 2) {
for (; (object = res->dseg.get_word(addr)) != 0; addr += 2) {
if (object == 0)
return NULL;
Object *obj = (Object *)res->dseg.ptr(object);
//obj->dump();
if (obj->enabled != 0 && obj->rect.in(point))
@ -345,12 +345,11 @@ void TeenAgentEngine::displayMessage(const Common::String &str, byte color) {
Common::String TeenAgentEngine::parseMessage(uint16 addr) {
Common::String message;
for (
const char *str = (const char *)Resources::instance()->dseg.ptr(addr);
str[0] != 0 || str[1] != 0;
++str)
{
const char *str = (const char *)Resources::instance()->dseg.ptr(addr);
str[0] != 0 || str[1] != 0;
++str) {
char c = str[0];
message += c != 0 && c != -1? c: '\n';
message += c != 0 && c != -1 ? c : '\n';
}
if (message.empty()) {
warning("empty message parsed for %04x", addr);
@ -371,7 +370,7 @@ void TeenAgentEngine::displayCredits(uint16 addr) {
event.color = *src++;
event.dst.y = *src;
while(true) {
while (true) {
++src; //skip y position
Common::String line((const char *)src);
event.message += line;
@ -385,7 +384,7 @@ void TeenAgentEngine::displayCredits(uint16 addr) {
scene->push(event);
}
void TeenAgentEngine::moveTo(const Common::Point & dst, byte o, bool warp) {
void TeenAgentEngine::moveTo(const Common::Point &dst, byte o, bool warp) {
moveTo(dst.x, dst.y, o, warp);
}
@ -398,7 +397,7 @@ void TeenAgentEngine::moveTo(uint16 x, uint16 y, byte o, bool warp) {
event.dst.x = x;
event.dst.y = y;
event.orientation = o;
event.color = warp? 1: 0;
event.color = warp ? 1 : 0;
scene->push(event);
}
@ -407,7 +406,7 @@ void TeenAgentEngine::moveRel(int16 x, int16 y, byte o, bool warp) {
event.dst.x = x;
event.dst.y = y;
event.orientation = o;
event.color = (warp? 1: 0) | 2;
event.color = (warp ? 1 : 0) | 2;
scene->push(event);
}
@ -528,7 +527,7 @@ void TeenAgentEngine::playSoundNow(byte id) {
char *data = new char[size];
in->read(data, size);
//debug(0, "playing %u samples...", size);
_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_soundHandle, data, size, 11025, Audio::Mixer::FLAG_AUTOFREE);
}
@ -543,7 +542,7 @@ void TeenAgentEngine::setMusic(byte id) {
bool TeenAgentEngine::hasFeature(EngineFeature f) const {
switch(f) {
switch (f) {
case kSupportsRTL:
case kSupportsLoadingDuringRuntime:
case kSupportsSavingDuringRuntime:

View File

@ -41,9 +41,9 @@ class Scene;
class MusicPlayer;
class TeenAgentEngine: public Engine {
public:
public:
enum Action { ActionNone, ActionExamine, ActionUse };
TeenAgentEngine(OSystem *system, const ADGameDescription *gd);
virtual Common::Error run();
@ -55,9 +55,9 @@ public:
void deinit();
Object *findObject(int id, const Common::Point &point);
void examine(const Common::Point &point, Object *object);
void use(Object *object);
@ -70,7 +70,7 @@ public:
void displayMessage(uint16 addr, byte color = 0xd1);
void displayMessage(const Common::String &str, byte color = 0xd1);
void displayCredits(uint16 addr);
void moveTo(const Common::Point & dst, byte o, bool warp = false);
void moveTo(const Common::Point &dst, byte o, bool warp = false);
void moveTo(uint16 x, uint16 y, byte o, bool warp = false);
void moveTo(Object *obj);
void moveRel(int16 x, int16 y, byte o, bool warp = false);
@ -97,10 +97,10 @@ public:
Scene *scene;
Inventory *inventory;
MusicPlayer *music;
void setMusic(byte id);
private:
private:
void processObject();
bool scene_busy;