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,133 @@
/* 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/shared/std/string.h"
#include "ultima/nuvie/core/nuvie_defs.h"
#include "ultima/nuvie/files/nuvie_io_file.h"
#include "ultima/nuvie/conf/configuration.h"
#include "ultima/nuvie/screen/screen.h"
#include "ultima/nuvie/fonts/bmp_font.h"
namespace Ultima {
namespace Nuvie {
BMPFont::BMPFont() : char_w(0), char_h(0), font_width_data(nullptr),
font_surface(nullptr), rune_mode(false), dual_font_mode(false) {
}
BMPFont::~BMPFont() {
if (font_surface)
delete font_surface;
if (font_width_data)
free(font_width_data);
}
bool BMPFont::init(const Common::Path &bmp_filename, bool dual_fontmap) {
dual_font_mode = dual_fontmap;
num_chars = 256;
Common::Path full_filename = bmp_filename;
full_filename.appendInPlace(".bmp");
font_surface = SDL_LoadBMP(full_filename);
font_surface->setTransparentColor(font_surface->format.RGBToColor(0, 0x70, 0xfc));
char_w = font_surface->w / 16;
char_h = font_surface->h / 16;
//read font width data. For variable width fonts.
full_filename = bmp_filename;
full_filename.appendInPlace(".dat");
NuvieIOFileRead font_width_data_file;
if (font_width_data_file.open(full_filename)) {
font_width_data = font_width_data_file.readAll();
font_width_data_file.close();
}
return true;
}
uint16 BMPFont::getStringWidth(const char *str, uint16 string_len) {
uint16 i;
uint16 w = 0;
for (i = 0; i < string_len; i++) {
if (dual_font_mode && str[i] == '<') {
offset = 128;
} else if (dual_font_mode && str[i] == '>') {
offset = 0;
} else {
w += getCharWidth(str[i] + offset);
}
}
return w;
}
uint16 BMPFont::getCharWidth(uint8 c) {
if (font_width_data) {
return font_width_data[c];
}
return char_w;
}
uint16 BMPFont::drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y,
uint8 color) {
Common::Rect src;
Common::Rect dst;
if (dual_font_mode) {
if (char_num == '<') {
rune_mode = true;
return 0;
} else if (char_num == '>') {
rune_mode = false;
return 0;
}
}
if (rune_mode) {
char_num += 128;
}
src.left = (char_num % 16) * char_w;
src.top = (char_num / 16) * char_h;
src.setWidth(char_w);
src.setHeight(char_h);
dst.left = x;
dst.top = y;
dst.setWidth(char_w);
dst.setHeight(char_h);
SDL_BlitSurface(font_surface, &src, screen->get_sdl_surface(), &dst);
return getCharWidth(char_num);
}
} // End of namespace Nuvie
} // End of namespace Ultima

View File

@@ -0,0 +1,61 @@
/* 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_FONTS_BMP_FONT_H
#define NUVIE_FONTS_BMP_FONT_H
#include "ultima/nuvie/fonts/font.h"
namespace Ultima {
namespace Nuvie {
class Configuration;
class Screen;
class BMPFont : public Font {
Graphics::ManagedSurface *font_surface;
uint8 *font_width_data;
uint16 char_w, char_h;
bool dual_font_mode;
bool rune_mode;
public:
BMPFont();
~BMPFont() override;
bool init(const Common::Path &bmp_filename, bool dual_fontmap = false);
uint16 getCharWidth(uint8 c) override;
uint16 getCharHeight() override {
return 16;
}
uint16 drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y,
uint8 color) override;
uint16 getStringWidth(const char *str, uint16 string_len) override;
};
} // End of namespace Nuvie
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,62 @@
/* 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/shared/std/string.h"
#include "ultima/nuvie/core/nuvie_defs.h"
#include "ultima/nuvie/screen/screen.h"
#include "ultima/nuvie/fonts/conv_font.h"
namespace Ultima {
namespace Nuvie {
ConvFont::ConvFont() : data_offset(0), f_data(nullptr), f_w_data(nullptr) {
}
ConvFont::~ConvFont() {
}
bool ConvFont::init(unsigned char *data, uint8 *width_data, uint16 num_c, uint16 char_offset) {
assert(data && width_data);
data_offset = char_offset;
num_chars = num_c;
f_data = data;
f_w_data = width_data;
return true;
}
uint16 ConvFont::getCharWidth(uint8 c) {
return f_w_data[c + data_offset];
}
uint16 ConvFont::drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y,
uint8 color) {
unsigned char *buf = (unsigned char *)f_data + (data_offset * 64) + (char_num % 16) * 8 + (char_num / 16) * 128 * 8;
screen->blit(x, y, buf, 8, 8, 8, 128, true, nullptr);
return getCharWidth(char_num);
}
} // 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_FONTS_CONV_FONT_H
#define NUVIE_FONTS_CONV_FONT_H
#include "ultima/nuvie/fonts/font.h"
namespace Ultima {
namespace Nuvie {
class Configuration;
class Screen;
class ConvFont : public Font {
unsigned char *f_data;
uint8 *f_w_data;
uint16 data_offset;
public:
ConvFont();
~ConvFont() override;
bool init(unsigned char *data, uint8 *width_data, uint16 num_chars, uint16 char_offset);
uint16 getCharWidth(uint8 c) override;
uint16 getCharHeight() override {
return 0;
}
uint16 drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y,
uint8 color) override;
};
} // End of namespace Nuvie
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,97 @@
/* 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/screen/screen.h"
#include "ultima/nuvie/files/u6_lzw.h"
#include "ultima/nuvie/files/u6_shape.h"
#include "ultima/nuvie/fonts/font.h"
#include "ultima/nuvie/core/game.h"
namespace Ultima {
namespace Nuvie {
Font::Font() : num_chars(0), offset(0), default_color(FONT_COLOR_U6_NORMAL),
default_highlight_color(FONT_COLOR_U6_HIGHLIGHT) {
}
Font::~Font() {
}
uint16 Font::drawString(Screen *screen, const char *str, uint16 x, uint16 y) {
return drawString(screen, str, strlen(str), x, y, default_color, default_highlight_color);
}
uint16 Font::drawString(Screen *screen, const char *str, uint16 x, uint16 y, uint8 color, uint8 highlight_color) {
return drawString(screen, str, strlen(str), x, y, color, highlight_color);
}
uint16 Font::drawString(Screen *screen, const char *str, uint16 string_len, uint16 x, uint16 y, uint8 color, uint8 highlight_color) {
uint16 i;
bool highlight = false;
uint16 font_len = 0;
for (i = 0; i < string_len; i++) {
if (str[i] == '@')
highlight = true;
else {
if (!Common::isAlpha(str[i]))
highlight = false;
font_len += drawChar(screen, get_char_num(str[i]), x + font_len, y,
highlight ? highlight_color : color);
}
}
highlight = false;
return font_len;
}
uint8 Font::get_char_num(uint8 c) {
if (c >= offset && c < offset + num_chars)
c -= offset;
else
c = 0;
return c;
}
uint16 Font::getStringWidth(const char *str) {
return getStringWidth(str, strlen(str));
}
uint16 Font::getStringWidth(const char *str, uint16 string_len) {
uint16 i;
uint16 w = 0;
for (i = 0; i < string_len; i++) {
w += getCharWidth(str[i]);
}
return w;
}
uint16 Font::drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y) {
return drawChar(screen, char_num, x, y, default_color);
}
} // End of namespace Nuvie
} // End of namespace Ultima

View File

@@ -0,0 +1,95 @@
/* 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_FONTS_FONT_H
#define NUVIE_FONTS_FONT_H
namespace Ultima {
namespace Nuvie {
#define FONT_COLOR_U6_NORMAL 0x48
#define FONT_COLOR_U6_HIGHLIGHT 0x0c
#define FONT_COLOR_WOU_NORMAL 0
#define FONT_COLOR_WOU_CONVERSE_INPUT 1
#define FONT_COLOR_WOU_HIGHLIGHT 4
#define FONT_UP_ARROW_CHAR 19
#define FONT_DOWN_ARROW_CHAR 20
class Configuration;
class Screen;
class U6Shape;
class Font {
protected:
uint16 num_chars;
uint16 offset;
uint8 default_color, default_highlight_color;
private:
public:
Font();
virtual ~Font();
uint8 getDefaultColor() {
return default_color;
}
void setDefaultColor(uint8 color) {
default_color = color;
}
void setDefaultHighlightColor(uint8 color) {
default_highlight_color = color;
}
// bool drawString(Screen *screen, Std::string str, uint16 x, uint16 y);
uint16 drawString(Screen *screen, const char *str, uint16 x, uint16 y);
uint16 drawString(Screen *screen, const char *str, uint16 x, uint16 y, uint8 color, uint8 highlight_color);
uint16 drawString(Screen *screen, const char *str, uint16 string_len, uint16 x, uint16 y, uint8 color, uint8 highlight_color);
uint16 drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y);
virtual uint16 drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y,
uint8 color) = 0;
uint16 drawStringToShape(U6Shape *shp, const char *str, uint16 x, uint16 y, uint8 color);
uint8 drawCharToShape(U6Shape *shp, uint8 char_num, uint16 x, uint16 y, uint8 color);
virtual uint16 getCharWidth(uint8 c) = 0;
virtual uint16 getCharHeight() = 0;
uint16 getStringWidth(const char *str);
virtual uint16 getStringWidth(const char *str, uint16 string_len);
void setOffset(uint16 off) {
offset = off;
}
protected:
uint8 get_char_num(uint8 c);
};
} // End of namespace Nuvie
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,198 @@
/* 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/gui.h"
#include "ultima/nuvie/files/nuvie_io_file.h"
#include "ultima/nuvie/files/u6_lib_n.h"
#include "ultima/nuvie/files/nuvie_bmp_file.h"
#include "ultima/nuvie/fonts/font_manager.h"
#include "ultima/nuvie/fonts/font.h"
#include "ultima/nuvie/fonts/conv_font.h"
#include "ultima/nuvie/fonts/u6_font.h"
#include "ultima/nuvie/fonts/wou_font.h"
#include "ultima/nuvie/misc/u6_misc.h"
namespace Ultima {
namespace Nuvie {
FontManager::FontManager(const Configuration *cfg) : config(cfg), num_fonts(0),
conv_font(nullptr), conv_garg_font(nullptr), conv_font_data(nullptr),
conv_font_widths(nullptr) {
}
FontManager::~FontManager() {
for (auto *font : fonts) {
delete font;
}
if (conv_font) {
delete conv_font;
}
if (conv_garg_font) {
delete conv_garg_font;
}
if (conv_font_data) {
free(conv_font_data);
}
if (conv_font_widths) {
free(conv_font_widths);
}
}
bool FontManager::init(nuvie_game_t game_type) {
initConvFonts(game_type);
if (game_type == NUVIE_GAME_U6)
return initU6();
return initWOUSystemFont();
}
bool FontManager::initU6() {
U6Font *font;
unsigned char *font_data;
Common::Path filename;
NuvieIOFileRead u6_ch;
config_get_path(config, "u6.ch", filename);
if (u6_ch.open(filename) == false)
return false;
font_data = u6_ch.readAll();
if (font_data == nullptr || u6_ch.get_size() < 256 * 8)
return false;
// english font
font = new U6Font();
font->init(font_data, 128, 0);
fonts.push_back(font);
num_fonts++;
// runic & gargoyle font
font = new U6Font();
font->init(&font_data[128 * 8], 128, 0);
fonts.push_back(font);
num_fonts++;
free(font_data);
return true;
}
bool FontManager::initWOU(Std::string filename) {
WOUFont *font;
Common::Path path;
U6Lib_n lib_file;
config_get_path(config, filename, path);
lib_file.open(path, 4, NUVIE_GAME_MD); //can be either SE or MD just as long as it isn't set to U6 type.
font = new WOUFont();
unsigned char *buf = lib_file.get_item(0);
font->initWithBuffer(buf, lib_file.get_item_size(0)); //buf will be freed by ~Font()
fonts.push_back(font);
num_fonts++;
/*
font = new Font();
font->init(path.c_str());
fonts.push_back(font);
num_fonts++;
*/
return true;
}
bool FontManager::initWOUSystemFont() {
U6Font *font;
Common::Path path;
U6Lib_n lib_file;
config_get_path(config, "system.lzc", path);
lib_file.open(path, 4, NUVIE_GAME_MD);
font = new U6Font();
unsigned char *buf = lib_file.get_item(3);
font->init(buf, 128, 0);
font->setDefaultColor(FONT_COLOR_WOU_NORMAL);
font->setDefaultHighlightColor(FONT_COLOR_WOU_HIGHLIGHT);
free(buf);
fonts.push_back(font);
num_fonts++;
return true;
}
bool FontManager::initConvFonts(nuvie_game_t game_type) {
char filename[7]; // u6.bmp\0 or u6.dat\0
Common::Path datadir = GUI::get_gui()->get_data_dir();
Common::Path path;
build_path(datadir, "images", path);
datadir = path;
build_path(datadir, "gumps", path);
datadir = path;
build_path(datadir, "fonts", path);
datadir = path;
Common::Path imagefile;
Common::sprintf_s(filename, "%s.bmp", get_game_tag(Game::get_game()->get_game_type()));
build_path(datadir, filename, imagefile);
NuvieBmpFile bmp;
bmp.load(imagefile);
conv_font_data = bmp.getRawIndexedDataCopy();
Common::Path widthfile;
Common::sprintf_s(filename, "%s.dat", get_game_tag(Game::get_game()->get_game_type()));
build_path(datadir, filename, widthfile);
NuvieIOFileRead datfile;
datfile.open(widthfile);
uint32 bytes_read;
conv_font_widths = datfile.readBuf(256, &bytes_read);
datfile.close();
conv_font = new ConvFont();
((ConvFont *)conv_font)->init(conv_font_data, conv_font_widths, 256, 0);
if (game_type == NUVIE_GAME_U6) {
conv_garg_font = new ConvFont();
((ConvFont *)conv_garg_font)->init(conv_font_data, conv_font_widths, 256, 128);
}
return true;
}
Font *FontManager::get_font(uint16 font_number) {
if (num_fonts > 0 && font_number < num_fonts)
return fonts[font_number]; //fonts.at(font_number);
return nullptr;
}
} // End of namespace Nuvie
} // End of namespace Ultima

View File

@@ -0,0 +1,72 @@
/* 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_FONTS_FONT_MANAGER_H
#define NUVIE_FONTS_FONT_MANAGER_H
#include "ultima/shared/std/string.h"
namespace Ultima {
namespace Nuvie {
class Configuration;
class Font;
#define NUVIE_FONT_NORMAL 0
#define NUVIE_FONT_GARG 1
class FontManager {
const Configuration *config;
Std::vector<Font *> fonts;
uint16 num_fonts;
Font *conv_font;
Font *conv_garg_font;
unsigned char *conv_font_data;
uint8 *conv_font_widths;
public:
FontManager(const Configuration *cfg);
~FontManager();
bool init(nuvie_game_t game_type);
Font *get_font(uint16 font_number);
Font *get_conv_font() {
return conv_font;
}
Font *get_conv_garg_font() {
return conv_garg_font;
}
protected:
bool initU6();
bool initWOU(Std::string filename);
bool initWOUSystemFont();
bool initConvFonts(nuvie_game_t game_type);
};
} // End of namespace Nuvie
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,80 @@
/* 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/screen/screen.h"
#include "ultima/nuvie/fonts/u6_font.h"
namespace Ultima {
namespace Nuvie {
U6Font::U6Font() : font_data(nullptr) {
}
U6Font::~U6Font() {
if (font_data != nullptr)
free(font_data);
}
bool U6Font::init(unsigned char *data, uint16 num_c, uint16 char_offset) {
offset = char_offset;
num_chars = num_c;
font_data = (unsigned char *)malloc(num_chars * 8);
memcpy(font_data, data, num_chars * 8);
return true;
}
uint16 U6Font::drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y,
uint8 color) {
unsigned char buf[64];
unsigned char *pixels;
uint16 i, j;
unsigned char *font;
uint16 pitch;
memset(buf, 0xff, 64);
//pixels = (unsigned char *)screen->get_pixels();
pixels = buf;
pitch = 8;//screen->get_pitch();
font = &font_data[char_num * 8];
//pixels += y * pitch + x;
for (i = 0; i < 8; i++) {
for (j = 8; j > 0; j--) {
if (font[i] & (1 << (j - 1)))
pixels[8 - j] = color; // 0th palette entry should be black
}
pixels += pitch;
}
screen->blit(x, y, buf, 8, 8, 8, 8, true, nullptr);
return 8;
}
} // End of namespace Nuvie
} // End of namespace Ultima

View File

@@ -0,0 +1,62 @@
/* 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_FONTS_U6_FONT_H
#define NUVIE_FONTS_U6_FONT_H
#define FONT_COLOR_U6_NORMAL 0x48
#define FONT_COLOR_U6_HIGHLIGHT 0x0c
#include "ultima/nuvie/fonts/font.h"
namespace Ultima {
namespace Nuvie {
class Configuration;
class Screen;
class U6Font : public Font {
private:
unsigned char *font_data;
public:
U6Font();
~U6Font() override;
bool init(unsigned char *data, uint16 num_chars, uint16 char_offset);
uint16 getCharWidth(uint8 c) override {
return 8;
}
uint16 getCharHeight() override {
return 8;
}
uint16 drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y,
uint8 color) override;
protected:
};
} // End of namespace Nuvie
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,171 @@
/* 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/screen/screen.h"
#include "ultima/nuvie/files/u6_lzw.h"
#include "ultima/nuvie/files/u6_shape.h"
#include "ultima/nuvie/fonts/wou_font.h"
#include "ultima/nuvie/core/game.h"
namespace Ultima {
namespace Nuvie {
WOUFont::WOUFont() : font_data(nullptr), char_buf(nullptr), height(0),
pixel_char(0) {
}
WOUFont::~WOUFont() {
if (font_data != nullptr)
free(font_data);
if (char_buf != nullptr)
free(char_buf);
}
bool WOUFont::init(const Common::Path &filename) {
U6Lzw lzw;
uint32 decomp_size;
font_data = lzw.decompress_file(filename, decomp_size);
height = font_data[0];
pixel_char = font_data[2];
num_chars = 256;
if (Game::get_game()->get_game_type() != NUVIE_GAME_U6) {
default_color = FONT_COLOR_WOU_NORMAL;
default_highlight_color = FONT_COLOR_WOU_HIGHLIGHT;
}
return initCharBuf();
}
bool WOUFont::initWithBuffer(unsigned char *buffer, uint32 buffer_len) {
font_data = buffer;
height = font_data[0];
pixel_char = font_data[2];
num_chars = 256;
if (Game::get_game()->get_game_type() != NUVIE_GAME_U6) {
default_color = FONT_COLOR_WOU_NORMAL;
default_highlight_color = FONT_COLOR_WOU_HIGHLIGHT;
}
return initCharBuf();
}
bool WOUFont::initCharBuf() {
uint8 max_width = 0;
for (uint16 i = 0; i < num_chars; i++) {
uint8 width = font_data[0x4 + i];
if (width > max_width) {
max_width = width;
}
}
char_buf = (unsigned char *)malloc(max_width * height);
if (char_buf == nullptr)
return false;
return true;
}
uint16 WOUFont::getCharWidth(uint8 c) {
if (font_data == nullptr)
return 0;
return font_data[0x4 + get_char_num(c)];
}
uint16 WOUFont::drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y,
uint8 color) {
unsigned char *pixels;
uint16 width;
if (font_data == nullptr)
return false;
pixels = font_data + font_data[0x204 + char_num] * 256 + font_data[0x104 + char_num];
width = font_data[0x4 + char_num];
memset(char_buf, 0xff, width * height);
//pixels += y * pitch + x;
for (uint8 i = 0; i < (width * height); i++) {
if (pixels[i] == pixel_char)
char_buf[i] = color;
}
screen->blit(x, y, char_buf, 8, width, height, width, true, nullptr);
return width;
}
uint16 WOUFont::drawStringToShape(U6Shape *shp, const char *str, uint16 x, uint16 y, uint8 color) {
uint16 i;
uint16 string_len = strlen(str);
if (font_data == nullptr)
return x;
for (i = 0; i < string_len; i++) {
x += drawCharToShape(shp, get_char_num(str[i]), x, y, color);
}
return x;
}
uint8 WOUFont::drawCharToShape(U6Shape *shp, uint8 char_num, uint16 x, uint16 y,
uint8 color) {
unsigned char *pixels;
uint16 i, j;
unsigned char *font;
uint16 pitch;
uint16 dst_w, dst_h;
pixels = shp->get_data();
shp->get_size(&dst_w, &dst_h);
pitch = dst_w;
pixels += y * pitch + x;
uint16 width;
font = font_data + font_data[0x204 + char_num] * 256 + font_data[0x104 + char_num];
width = font_data[0x4 + char_num];
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
if (font[j] == pixel_char) {
pixels[j] = color;
}
}
font += width;
pixels += pitch;
}
return width;
}
} // End of namespace Nuvie
} // End of namespace Ultima

View File

@@ -0,0 +1,67 @@
/* 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_FONTS_WOU_FONT_H
#define NUVIE_FONTS_WOU_FONT_H
#include "ultima/nuvie/fonts/font.h"
namespace Ultima {
namespace Nuvie {
class Configuration;
class Screen;
class U6Shape;
class WOUFont : public Font {
private:
unsigned char *font_data;
unsigned char *char_buf;
uint16 height;
uint8 pixel_char;
public:
WOUFont();
~WOUFont() override;
bool init(const Common::Path &filename);
bool initWithBuffer(unsigned char *buffer, uint32 buffer_len);
uint16 drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y,
uint8 color) override;
uint16 drawStringToShape(U6Shape *shp, const char *str, uint16 x, uint16 y, uint8 color);
uint8 drawCharToShape(U6Shape *shp, uint8 char_num, uint16 x, uint16 y, uint8 color);
uint16 getCharWidth(uint8 c) override;
uint16 getCharHeight() override {
return height;
}
private:
bool initCharBuf();
};
} // End of namespace Nuvie
} // End of namespace Ultima
#endif