Inventory::Inventory(TeenAgentEngine *engine) { _engine = engine; _active = false; FilePack varia; varia.open("varia.res"); { Common::ScopedPtr<Common::SeekableReadStream> s(varia.getStream(3)); if (!s) error("no inventory background"); debug(0, "loading inventory background..."); _background.load(*s, Surface::kTypeOns); } uint32 items_size = varia.getSize(4); if (items_size == 0) error("invalid inventory items size"); debug(0, "loading items, size: %u", items_size); _items = new byte[items_size]; varia.read(4, _items, items_size); byte offsets = _items[0]; assert(offsets == 92); for (byte i = 0; i < offsets; ++i) { _offset[i] = READ_LE_UINT16(_items + i * 2 + 1); } _offset[92] = items_size; Resources *res = Resources::instance(); for (byte i = 0; i <= 92; ++i) { InventoryObject io; uint16 obj_addr = res->dseg.get_word(0xc4a4 + i * 2); if (obj_addr != 0) io.load(res->dseg.ptr(obj_addr)); _objects.push_back(io); } _inventory = res->dseg.ptr(0xc48d); 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; _graphics[i]._rect.top = 23 + 31 * y - 1; _graphics[i]._rect.right = _graphics[i]._rect.left + 40; _graphics[i]._rect.bottom = _graphics[i]._rect.top + 26; } varia.close(); _hoveredObj = _selectedObj = NULL; }
bool TeenAgentEngine::showMetropolis() { _system->fillScreen(0); _system->updateScreen(); FilePack varia; varia.open("varia.res"); byte palette[0x400]; memset(palette, 0, sizeof(palette)); { Common::ScopedPtr<Common::SeekableReadStream> s(varia.getStream(5)); for(uint c = 0; c < 0x400; c += 4) { s->read(palette + c, 3); palette[c] *= 4; palette[c + 1] *= 4; palette[c + 2] *= 4; } } _system->setPalette(palette, 0, 0x100); byte varia_6[21760], varia_9[18302]; varia.read(6, varia_6, sizeof(varia_6)); varia.read(9, varia_9, sizeof(varia_9)); byte colors[56 * 160 * 2]; memset(colors, 0, sizeof(colors)); int logo_y = -56; for(uint f = 0; f < 300; ++f) { { int r = skipEvents(); if (r != 0) return r > 0? true: false; } Graphics::Surface *surface = _system->lockScreen(); if (logo_y > 0) { surface->fillRect(Common::Rect(0, 0, 320, logo_y), 0); } { //generate colors matrix memmove(colors + 320, colors + 480, 8480); for(uint c = 0; c < 17; ++c) { byte x = (random.getRandomNumber(184) + 5) & 0xff; uint offset = 8800 + random.getRandomNumber(158); colors[offset++] = x; colors[offset++] = x; } for(uint y = 1; y < 56; ++y) { for(uint x = 1; x < 160; ++x) { uint offset = y * 160 + x; uint v = (uint)colors[offset - 161] + colors[offset - 160] + colors[offset - 159] + (uint)colors[offset - 1] + colors[offset + 1] + (uint)colors[offset + 161] + colors[offset + 160] + colors[offset + 159]; v >>= 3; colors[offset + 8960] = v; } } memmove(colors, colors + 8960, 8960); } byte *dst = (byte *)surface->getBasePtr(0, 131); byte *src = varia_6; for(uint y = 0; y < 68; ++y) { for(uint x = 0; x < 320; ++x) { if (*src++ == 1) { *dst++ = colors[19 * 160 + y / 2 * 160 + x / 2]; } else ++dst; } } _system->unlockScreen(); _system->copyRectToScreen( varia_9 + (logo_y < 0? -logo_y * 320: 0), 320, 0, logo_y >= 0? logo_y: 0, 320, logo_y >= 0? 57: 57 + logo_y); if (logo_y < 82 - 57) ++logo_y; _system->updateScreen(); _system->delayMillis(100); } return true; }