Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/nuvie/core/nuvie_defs.h"
#include "ultima/nuvie/conf/configuration.h"
#include "ultima/nuvie/gui/widgets/console.h"
#include "ultima/nuvie/files/nuvie_io_file.h"
#include "ultima/nuvie/files/u6_shape.h"
#include "ultima/nuvie/screen/dither.h"
#include "ultima/nuvie/core/game.h"
#include "ultima/nuvie/actors/actor_manager.h"
#include "ultima/nuvie/actors/actor.h"
#include "ultima/nuvie/portraits/portrait.h"
#include "ultima/nuvie/portraits/portrait_u6.h"
#include "ultima/nuvie/portraits/portrait_md.h"
#include "ultima/nuvie/portraits/portrait_se.h"
#include "ultima/nuvie/files/u6_lzw.h"
#include "ultima/nuvie/misc/u6_misc.h"
#include "ultima/nuvie/files/u6_lib_n.h"
#include "ultima/nuvie/core/u6_objects.h"
namespace Ultima {
namespace Nuvie {
Portrait *newPortrait(nuvie_game_t gametype, const Configuration *cfg) {
// Correct portrait class for each game
switch (gametype) {
case NUVIE_GAME_U6 :
return new PortraitU6(cfg);
break;
case NUVIE_GAME_MD :
return new PortraitMD(cfg);
break;
case NUVIE_GAME_SE :
return new PortraitSE(cfg);
break;
}
return nullptr;
}
Portrait::Portrait(const Configuration *cfg) : config(cfg), avatar_portrait_num(0), width(0), height(0) {
}
uint8 Portrait::get_avatar_portrait_num() const {
return get_portrait_num(Game::get_game()->get_actor_manager()->get_avatar());
}
unsigned char *Portrait::get_wou_portrait_data(U6Lib_n *lib, uint8 num) {
// MD/SE
U6Shape *shp;
unsigned char *shp_data;
NuvieIOBuffer shp_buf;
U6Lib_n shp_lib;
unsigned char *new_portrait;
uint16 portrait_w;
uint16 portrait_h;
shp_data = lib->get_item(num, nullptr);
shp_buf.open(shp_data, lib->get_item_size(num), NUVIE_BUF_NOCOPY);
if (shp_buf.get_size() == 0) { // no portrait at that index
free(shp_data);
return nullptr;
}
shp = new U6Shape();
shp_lib.open(&shp_buf, 4, NUVIE_GAME_SE);
shp->load(&shp_lib, 0);
shp->get_size(&portrait_w, &portrait_h);
new_portrait = (unsigned char *)malloc(portrait_w * portrait_h);
memcpy(new_portrait, shp->get_data(), portrait_w * portrait_h);
//new_portrait=shp->get_data(); // probably need to copy here
delete shp;
shp_lib.close();
free(shp_data);
return new_portrait;
}
} // End of namespace Nuvie
} // End of namespace Ultima

View File

@@ -0,0 +1,82 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef NUVIE_PORTRAIT_PORTRAIT_H
#define NUVIE_PORTRAIT_PORTRAIT_H
namespace Ultima {
namespace Nuvie {
class Configuration;
class Actor;
class U6Lib_n;
class NuvieIO;
#define PORTRAIT_WIDTH 56
#define PORTRAIT_HEIGHT 64
#define NO_PORTRAIT_FOUND 255
Portrait *newPortrait(nuvie_game_t gametype, const Configuration *cfg);
class Portrait {
protected:
const Configuration *config;
uint8 avatar_portrait_num;
uint8 width;
uint8 height;
public:
Portrait(const Configuration *cfg);
virtual ~Portrait() {};
virtual bool init() = 0;
virtual bool load(NuvieIO *objlist) = 0;
virtual unsigned char *get_portrait_data(Actor *actor) = 0;
uint8 get_portrait_width() const {
return width;
}
uint8 get_portrait_height() const {
return height;
}
bool has_portrait(Actor *actor) const {
return (get_portrait_num(actor) != NO_PORTRAIT_FOUND);
}
uint8 get_avatar_portrait_num() const;
protected:
unsigned char *get_wou_portrait_data(U6Lib_n *lib, uint8 num);
private:
virtual uint8 get_portrait_num(Actor *actor) const = 0;
};
} // End of namespace Nuvie
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,151 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/nuvie/core/nuvie_defs.h"
#include "ultima/nuvie/conf/configuration.h"
#include "ultima/nuvie/gui/widgets/console.h"
#include "ultima/nuvie/files/nuvie_io_file.h"
#include "ultima/nuvie/files/u6_shape.h"
#include "ultima/nuvie/core/game.h"
#include "ultima/nuvie/actors/actor_manager.h"
#include "ultima/nuvie/actors/actor.h"
#include "ultima/nuvie/portraits/portrait_md.h"
#include "ultima/nuvie/misc/u6_misc.h"
#include "ultima/nuvie/save/obj_list.h"
#include "ultima/nuvie/script/script.h"
namespace Ultima {
namespace Nuvie {
bool PortraitMD::init() {
Common::Path filename;
avatar_portrait_num = 0;
width = 76;
height = 83;
config_get_path(config, "mdfaces.lzc", filename);
if (faces.open(filename, 4) == false) {
ConsoleAddError("Opening " + filename.toString());
return false;
}
return true;
}
bool PortraitMD::load(NuvieIO *objlist) {
objlist->seek(OBJLIST_OFFSET_MD_GENDER);
avatar_portrait_num = objlist->read1() == 0 ? 1 : 0; //read in the avatar portrait number from objlist.
//if(avatar_portrait_num > 0)
// avatar_portrait_num--;
return true;
}
uint8 PortraitMD::get_portrait_num(Actor *actor) const {
if (actor == nullptr)
return NO_PORTRAIT_FOUND;
uint8 num = Game::get_game()->get_script()->call_get_portrait_number(actor);
if (num != NO_PORTRAIT_FOUND)
num++;
return num;
}
unsigned char *PortraitMD::get_portrait_data(Actor *actor) {
uint8 num = get_portrait_num(actor);
if (num == NO_PORTRAIT_FOUND)
return nullptr;
U6Shape *bg_shp = get_background_shape(num);
unsigned char *temp_buf = faces.get_item(num);
if (!temp_buf)
return nullptr;
U6Shape *p_shp = new U6Shape();
p_shp->load(temp_buf + 8);
free(temp_buf);
uint16 w, h;
bg_shp->get_size(&w, &h);
unsigned char *bg_data = bg_shp->get_data();
unsigned char *p_data = p_shp->get_data();
for (int i = 0; i < w * h; i++) {
if (p_data[i] != 255) {
bg_data[i] = p_data[i];
}
}
p_data = (unsigned char *)malloc(w * h);
memcpy(p_data, bg_data, w * h);
delete bg_shp;
delete p_shp;
return p_data;
}
U6Shape *PortraitMD::get_background_shape(uint8 actor_num) {
U6Lib_n file;
U6Shape *bg = new U6Shape();
Common::Path filename;
config_get_path(config, "mdback.lzc", filename);
file.open(filename, 4, NUVIE_GAME_MD);
unsigned char *temp_buf = file.get_item(get_background_shape_num(actor_num));
bg->load(temp_buf + 8);
free(temp_buf);
return bg;
}
uint8 PortraitMD::get_background_shape_num(uint8 actor_num) const {
const uint8 bg_tbl[] = {
0x22, 0x17, 0x50, 0x0, 0x0, 0x0, 0x0, 0x0, 0x56, 0x27, 0x0, 0x0, 0x55, 0x45,
0x70, 0x0, 0x53, 0x25, 0x45, 0x15, 0x17, 0x37, 0x45, 0x32, 0x24,
0x53, 0x21, 0x42, 0x13, 0x66, 0x61, 0x20, 0x67, 0x23, 0x15, 0x60,
0x0, 0x0, 0x0, 0x0, 0x37, 0x45, 0x32, 0x24, 0x75, 0x73, 0x50, 0x12,
0x51, 0x2, 0x65, 0x61, 0x45, 0x46, 0x31, 0x0, 0x24, 0x77, 0x6, 0x50,
0
};
actor_num--;
//FIXME add logic word_4115A return 0;
if (actor_num > 121) {
return NUVIE_RAND() % 7;
}
uint8 v = bg_tbl[actor_num / 2];
if ((actor_num & 1) == 0) {
return v >> 4;
}
return v & 0xf;
}
} // End of namespace Nuvie
} // End of namespace Ultima

View File

@@ -0,0 +1,57 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef NUVIE_PORTRAIT_PORTRAIT_MD_H
#define NUVIE_PORTRAIT_PORTRAIT_MD_H
#include "ultima/nuvie/portraits/portrait.h"
#include "ultima/nuvie/files/u6_lib_n.h"
namespace Ultima {
namespace Nuvie {
class Configuration;
class Actor;
class U6Shape;
class PortraitMD : public Portrait {
U6Lib_n faces;
public:
PortraitMD(const Configuration *cfg): Portrait(cfg) {};
bool init() override;
bool load(NuvieIO *objlist) override;
unsigned char *get_portrait_data(Actor *actor) override;
protected:
uint8 get_portrait_num(Actor *actor) const override;
private:
U6Shape *get_background_shape(uint8 actor_num);
uint8 get_background_shape_num(uint8 actor_num) const;
};
} // End of namespace Nuvie
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,199 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/nuvie/core/nuvie_defs.h"
#include "ultima/nuvie/conf/configuration.h"
#include "ultima/nuvie/gui/widgets/console.h"
#include "ultima/nuvie/files/nuvie_io_file.h"
#include "ultima/nuvie/files/u6_shape.h"
#include "ultima/nuvie/core/game.h"
#include "ultima/nuvie/actors/actor_manager.h"
#include "ultima/nuvie/actors/actor.h"
#include "ultima/nuvie/core/game_clock.h"
#include "ultima/nuvie/portraits/portrait_se.h"
#include "ultima/nuvie/misc/u6_misc.h"
namespace Ultima {
namespace Nuvie {
bool PortraitSE::init() {
Common::Path filename;
avatar_portrait_num = 0;
width = 79;
height = 85;
config_get_path(config, "faces.lzc", filename);
if (faces.open(filename, 4) == false) {
ConsoleAddError("Opening " + filename.toString());
return false;
}
return true;
}
bool PortraitSE::load(NuvieIO *objlist) {
// U6 only?
objlist->seek(0x1c72);
avatar_portrait_num = objlist->read1(); //read in the avatar portrait number from objlist.
if (avatar_portrait_num > 0)
avatar_portrait_num--;
return true;
}
uint8 PortraitSE::get_portrait_num(Actor *actor) const {
uint8 num;
if (actor == nullptr)
return NO_PORTRAIT_FOUND;
num = actor->get_actor_num();
return num;
}
U6Shape *PortraitSE::get_background_shape(Actor *actor) {
U6Lib_n file;
U6Shape *bg = new U6Shape();
Common::Path filename;
config_get_path(config, "bkgrnd.lzc", filename);
file.open(filename, 4, NUVIE_GAME_MD);
unsigned char *temp_buf = file.get_item(get_background_shape_num(actor));
bg->load(temp_buf + 8);
free(temp_buf);
return bg;
}
uint8 PortraitSE::get_background_shape_num(Actor *actor) const {
const struct {
uint16 x;
uint16 y;
uint16 x1;
uint16 y1;
uint8 bg_num;
} bg_lookup_tbl[27] = {
{0x1E8, 0x208, 0x287, 0x25F, 0x4},
{0x0E0, 0x260, 0x107, 0x287, 0xC},
{0x140, 0xC0, 0x187, 0xEF, 0xC},
{0x168, 0x218, 0x19F, 0x23F, 0xC},
{0x290, 0x318, 0x2C7, 0x34F, 0xC},
{0x188, 0x108, 0x1B7, 0x13F, 0xC},
{0x3D0, 0x130, 0x3F7, 0x167, 0xC},
{0x220, 0x120, 0x25F, 0x15F, 0xC},
{0x228, 0x60, 0x25F, 0x8F, 0xC},
{0x0F0, 0xA8, 0x307, 0x12F, 0x1},
{0x1F8, 0x40, 0x257, 0x8F, 0x1},
{0x1D8, 0x140, 0x207, 0x167, 0x1},
{0x340, 0xE8, 0x3FF, 0x1DF, 0x1},
{0x130, 0x130, 0x167, 0x1A7, 0x1},
{0x168, 0x1D0, 0x209, 0x227, 0x1},
{0x58, 0x268, 0x90, 0x2A8, 0x1},
{0x118, 0x40, 0x13F, 0x77, 0x1},
{0x280, 0x310, 0x29F, 0x327, 0x1},
{0x160, 0xF8, 0x21F, 0x1A7, 0xB},
{0x230, 0x160, 0x2C7, 0x1E7, 0xB},
{0x100, 0x48, 0x15F, 0xA7, 0xB},
{0x178, 0x100, 0x1C8, 0x12F, 0xB},
{0x120, 0xB0, 0x13F, 0xDF, 0xB},
{0x1A8, 0x78, 0x1EF, 0xB7, 0xB},
{0x0A8, 0x238, 0x100, 0x27F, 0xB},
{0x148, 0x228, 0x1BF, 0x287, 0xB},
{0x0, 0x0, 0x3FF, 0x3FF, 0x2}
};
uint16 x = actor->get_x();
uint16 y = actor->get_y();
uint8 z = actor->get_z();
if (z == 3) {
return 10;
} else if (z != 0) {
return 9;
}
for (int i = 0; i < 27; i++) {
if (x >= bg_lookup_tbl[i].x && y >= bg_lookup_tbl[i].y && x <= bg_lookup_tbl[i].x1 && y <= bg_lookup_tbl[i].y1) {
if (bg_lookup_tbl[i].bg_num < 5) {
GameClock *clock = Game::get_game()->get_clock();
if (clock) {
uint8 hour = clock->get_hour();
if (hour >= 18 || hour < 5) {
return bg_lookup_tbl[i].bg_num + 4;
}
}
}
return bg_lookup_tbl[i].bg_num;
}
}
return 2;
}
unsigned char *PortraitSE::get_portrait_data(Actor *actor) {
uint8 num = get_portrait_num(actor);
if (num == NO_PORTRAIT_FOUND)
return nullptr;
U6Shape *bg_shp = get_background_shape(actor);
unsigned char *temp_buf = faces.get_item(num);
if (!temp_buf)
return nullptr;
U6Shape *p_shp = new U6Shape();
p_shp->load(temp_buf + 8);
free(temp_buf);
//blit the background into the portrait while keeping the 1 pixel border.
uint16 bg_w, bg_h;
bg_shp->get_size(&bg_w, &bg_h);
uint16 p_w, p_h;
p_shp->get_size(&p_w, &p_h);
unsigned char *bg_data = bg_shp->get_data();
unsigned char *p_data = p_shp->get_data();
p_data += p_w;
p_data += 1;
for (int i = 0; i < bg_h; i++) {
for (int j = 0; j < bg_w; j++)
if (p_data[j] == 255) {
p_data[j] = bg_data[j];
}
p_data += p_w;
bg_data += bg_w;
}
bg_data = (unsigned char *)malloc(p_w * p_h);
memcpy(bg_data, p_shp->get_data(), p_w * p_h);
delete bg_shp;
delete p_shp;
return bg_data;
}
} // End of namespace Nuvie
} // End of namespace Ultima

View File

@@ -0,0 +1,55 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef NUVIE_PORTRAIT_PORTRAIT_SE_H
#define NUVIE_PORTRAIT_PORTRAIT_SE_H
#include "ultima/nuvie/portraits/portrait.h"
#include "ultima/nuvie/files/u6_lib_n.h"
namespace Ultima {
namespace Nuvie {
class Configuration;
class Actor;
class PortraitSE : public Portrait {
U6Lib_n faces;
public:
PortraitSE(const Configuration *cfg): Portrait(cfg) {};
bool init() override;
bool load(NuvieIO *objlist) override;
unsigned char *get_portrait_data(Actor *actor) override;
private:
U6Shape *get_background_shape(Actor *actor);
uint8 get_background_shape_num(Actor *actor) const;
uint8 get_portrait_num(Actor *actor) const override;
};
} // End of namespace Nuvie
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,159 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/nuvie/core/nuvie_defs.h"
#include "ultima/nuvie/conf/configuration.h"
#include "ultima/nuvie/gui/widgets/console.h"
#include "ultima/nuvie/files/nuvie_io_file.h"
#include "ultima/nuvie/files/u6_shape.h"
#include "ultima/nuvie/screen/dither.h"
#include "ultima/nuvie/core/game.h"
#include "ultima/nuvie/actors/actor_manager.h"
#include "ultima/nuvie/actors/actor.h"
#include "ultima/nuvie/portraits/portrait_u6.h"
#include "ultima/nuvie/files/u6_lzw.h"
#include "ultima/nuvie/misc/u6_misc.h"
#include "ultima/nuvie/core/u6_objects.h"
namespace Ultima {
namespace Nuvie {
//define temporary portraits.
#define PORTRAIT_U6_GARGOYLE 194
#define PORTRAIT_U6_GUARD 193
#define PORTRAIT_U6_WISP 192
#define PORTRAIT_U6_EXODUS 191
#define PORTRAIT_U6_NOTHING 188
bool PortraitU6::init() {
Common::Path filename;
avatar_portrait_num = 0;
width = 56;
height = 64;
config_get_path(config, "portrait.a", filename);
if (portrait_a.open(filename, 4) == false) {
ConsoleAddError("Opening " + filename.toString());
return false;
}
config_get_path(config, "portrait.b", filename);
if (portrait_b.open(filename, 4) == false) {
ConsoleAddError("Opening " + filename.toString());
return false;
}
config_get_path(config, "portrait.z", filename);
if (portrait_z.open(filename, 4) == false) {
ConsoleAddError("Opening " + filename.toString());
return false;
}
return true;
}
bool PortraitU6::load(NuvieIO *objlist) {
// U6 only?
objlist->seek(0x1c72);
avatar_portrait_num = objlist->read1(); //read in the avatar portrait number from objlist.
if (avatar_portrait_num > 0)
avatar_portrait_num--;
return true;
}
uint8 PortraitU6::get_portrait_num(Actor *actor) const {
uint8 num;
if (actor == nullptr)
return NO_PORTRAIT_FOUND;
num = actor->get_actor_num();
if (actor->is_avatar()) { // avatar portrait
num = avatar_portrait_num;
} else {
if (num != 0)
num -= 1;
if (num == (188 - 1))
num = PORTRAIT_U6_EXODUS - 1; // Exodus
else if (num >= (192 - 1) && num <= (200 - 1)) // Shrines, Temple of Singularity
return NO_PORTRAIT_FOUND;
else if (num > 194) { // there are 194 npc portraits
switch (actor->get_obj_n()) { //check for temporary actors with portraits. eg guards and wisps
case OBJ_U6_GUARD :
num = PORTRAIT_U6_GUARD - 1;
break;
case OBJ_U6_WISP :
num = PORTRAIT_U6_WISP - 1;
break;
case OBJ_U6_GARGOYLE :
num = PORTRAIT_U6_GARGOYLE - 1;
break;
default :
return NO_PORTRAIT_FOUND;
}
}
}
return num;
}
unsigned char *PortraitU6::get_portrait_data(Actor *actor) {
U6Lzw lzw;
U6Lib_n *portrait;
unsigned char *lzw_data;
uint32 new_length;
unsigned char *new_portrait;
uint8 num = get_portrait_num(actor);
if (num == NO_PORTRAIT_FOUND)
return nullptr;
if (actor->is_avatar()) { // avatar portrait
portrait = &portrait_z;
} else {
if (num < 98)
portrait = &portrait_a;
else {
num -= 98;
portrait = &portrait_b;
}
}
lzw_data = portrait->get_item(num);
if (!lzw_data)
return nullptr;
new_portrait = lzw.decompress_buffer(lzw_data, portrait->get_item_size(num), new_length);
free(lzw_data);
Game::get_game()->get_dither()->dither_bitmap(new_portrait, PORTRAIT_WIDTH, PORTRAIT_HEIGHT, true);
return new_portrait;
}
} // End of namespace Nuvie
} // End of namespace Ultima

View File

@@ -0,0 +1,58 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef NUVIE_PORTRAIT_PORTRAIT_U6_H
#define NUVIE_PORTRAIT_PORTRAIT_U6_H
#include "ultima/nuvie/portraits/portrait.h"
#include "ultima/nuvie/files/u6_lib_n.h"
namespace Ultima {
namespace Nuvie {
class Configuration;
class Actor;
class NuvieIO;
class PortraitU6 : public Portrait {
U6Lib_n portrait_a;
U6Lib_n portrait_b;
U6Lib_n portrait_z;
public:
PortraitU6(const Configuration *cfg) : Portrait(cfg) {};
~PortraitU6() override {};
bool init() override;
bool load(NuvieIO *objlist) override;
unsigned char *get_portrait_data(Actor *actor) override;
private:
uint8 get_portrait_num(Actor *actor) const override;
};
} // End of namespace Nuvie
} // End of namespace Ultima
#endif