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,47 @@
/* 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 "mm/shared/utils/bitmap_font.h"
namespace MM {
namespace MM1 {
namespace Gfx {
/**
* The Might and Magic 1 font only has uppercase. So we
* override the base BitmapFont class to uppercase characters
*/
class BitmapFont : public ::MM::BitmapFont {
public:
void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const override {
chr = (chr & 0x80) | toupper(chr & 0x7f);
MM::BitmapFont::drawChar(dst, chr, x, y, color);
}
void drawChar(Graphics::ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const override {
chr = (chr & 0x80) | toupper(chr & 0x7f);
MM::BitmapFont::drawChar(dst, chr, x, y, color);
}
};
} // namespace Gfx
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,49 @@
/* 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 "common/file.h"
#include "mm/mm1/gfx/dta.h"
#include "mm/mm1/gfx/screen_decoder.h"
namespace MM {
namespace MM1 {
namespace Gfx {
Common::SeekableReadStream *DTA::load(uint entryIndex) {
Common::File f;
if (!f.open(_fname))
error("Could not open - %s", _fname.toString().c_str());
uint indexSize = f.readUint16LE();
assert(entryIndex < (indexSize / 4));
f.seek(entryIndex * 4, SEEK_CUR);
size_t entryOffset = f.readUint32LE();
size_t nextOffset = (entryIndex == (indexSize / 4 - 1)) ?
f.size() : f.readUint32LE();
f.seek(2 + indexSize + entryOffset);
return f.readStream(nextOffset - entryOffset);
}
} // namespace Gfx
} // namespace MM1
} // namespace MM

51
engines/mm/mm1/gfx/dta.h Normal file
View File

@@ -0,0 +1,51 @@
/* 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 MM1_GFX_DTA_H
#define MM1_GFX_DTA_H
#include "graphics/managed_surface.h"
namespace MM {
namespace MM1 {
namespace Gfx {
#define WALLPIX_DTA (g_engine->isEnhanced() ? "gfx/wallpix.dta" : "wallpix.dta")
#define MONPIX_DTA (g_engine->isEnhanced() ? "gfx/monpix.dta" : "monpix.dta")
class DTA {
public:
Common::Path _fname;
public:
DTA(const Common::Path &fname) : _fname(fname) {
}
/**
* Returns a read stream for an entry
*/
Common::SeekableReadStream *load(uint entryIndex);
};
} // namespace Gfx
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,86 @@
/* 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 "common/system.h"
#include "common/debug.h"
#include "graphics/paletteman.h"
#include "graphics/screen.h"
#include "mm/mm1/gfx/gfx.h"
namespace MM {
namespace MM1 {
namespace Gfx {
byte EGA_INDEXES[EGA_PALETTE_COUNT];
static const uint32 EGA_PALETTE[16] = {
0x000000, 0x0000aa, 0x00aa00, 0x00aaaa,
0xaa0000, 0xaa00aa, 0xaa5500, 0xaaaaaa,
0x555555, 0x5555ff, 0x55ff55, 0x55ffff,
0xff5555, 0xff55ff, 0xffff55, 0xffffff
};
void GFX::setEgaPalette() {
byte pal[16 * 3];
byte *pDest = pal;
for (int i = 0; i < EGA_PALETTE_COUNT; ++i) {
*pDest++ = (EGA_PALETTE[i] >> 16) & 0xff;
*pDest++ = (EGA_PALETTE[i] >> 8) & 0xff;
*pDest++ = EGA_PALETTE[i] & 0xff;
EGA_INDEXES[i] = i;
}
g_system->getPaletteManager()->setPalette(pal, 0, 16);
uint32 c = 0xffffffff;
g_system->getPaletteManager()->setPalette((const byte *)&c, 255, 1);
// Set the EGA palette indexes to be themselves
}
void GFX::findPalette(const byte palette[256 * 3]) {
for (int col = 0; col < 16; ++col) {
byte r = (EGA_PALETTE[col] >> 16) & 0xff;
byte g = (EGA_PALETTE[col] >> 8) & 0xff;
byte b = EGA_PALETTE[col] & 0xff;
int closestDiff = 0x7fffffff;
byte closest = 0;
const byte *pal = &palette[0];
for (int i = 0; i < 256; ++i, pal += 3) {
int diff = ABS((int)r - (int)pal[0]) +
ABS((int)g - (int)pal[1]) +
ABS((int)b - (int)pal[2]);
if (diff < closestDiff) {
closestDiff = diff;
closest = i;
}
}
EGA_INDEXES[col] = closest;
}
}
} // namespace Gfx
} // namespace MM1
} // namespace MM

53
engines/mm/mm1/gfx/gfx.h Normal file
View File

@@ -0,0 +1,53 @@
/* 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 MM1_GFX_H
#define MM1_GFX_H
namespace MM {
namespace MM1 {
namespace Gfx {
#define SCREEN_W 320
#define SCREEN_H 200
#define EGA_PALETTE_COUNT 16
extern byte EGA_INDEXES[EGA_PALETTE_COUNT];
class GFX {
public:
/**
* Sets the EGA palette
*/
static void setEgaPalette();
/**
* Called after the Xeen palette has been loaded, to determine
* which palette indexes most closely match the EGA colors
*/
static void findPalette(const byte palette[256 * 3]);
};
} // namespace Gfx
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,102 @@
/* 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 "common/file.h"
#include "common/system.h"
#include "graphics/screen.h"
#include "mm/mm1/gfx/gfx.h"
#include "mm/mm1/gfx/screen_decoder.h"
namespace MM {
namespace MM1 {
namespace Gfx {
#define IMAGE_SIZE 16000
ScreenDecoder::~ScreenDecoder() {
destroy();
}
void ScreenDecoder::destroy() {
_surface.free();
}
bool ScreenDecoder::loadFile(const Common::Path &fname,
int16 w, int16 h) {
Common::File f;
if (!f.open(fname))
return false;
f.skip(2); // Skip size word
return loadStream(f, w, h);
}
bool ScreenDecoder::loadStream(Common::SeekableReadStream &stream,
int16 w, int16 h) {
byte bytes[IMAGE_SIZE];
byte v;
int len;
const byte *srcP;
byte *destP = &bytes[0];
int index = 0;
int imgSize = w * h / 4;
// Decompress the image bytes
int x = 0;
while (x < (w / 4) && !stream.eos()) {
v = stream.readByte();
if (v != 0x7B) {
len = 1;
} else {
len = stream.readByte() + 1;
v = stream.readByte();
}
for (; len > 0; --len) {
destP[index] = v;
index += (w / 4);
if (index >= imgSize) {
index = 0;
++destP;
++x;
}
}
}
// Create surface from splitting up the pairs of bits
_surface.free();
_surface.create(w, h, Graphics::PixelFormat::createFormatCLUT8());
srcP = &bytes[0];
destP = (byte *)_surface.getPixels();
for (int i = 0; i < w * h / 4; ++i, ++srcP) {
v = *srcP;
for (int j = 0; j < 4; ++j, v <<= 2)
*destP++ = EGA_INDEXES[_indexes[v >> 6]];
}
return true;
}
} // namespace Gfx
} // End of namespace Xeen
} // End of namespace MM

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 MM1_GFX_SCREEN_DECODER_H
#define MM1_GFX_SCREEN_DECODER_H
#include "image/image_decoder.h"
#include "graphics/managed_surface.h"
#include "graphics/palette.h"
namespace MM {
namespace MM1 {
namespace Gfx {
class ScreenDecoder : public Image::ImageDecoder {
private:
Graphics::Surface _surface;
Graphics::Palette _palette;
public:
byte _indexes[4] = { 0 }; // EGA palete indexes used
public:
ScreenDecoder() : _palette(0) {}
~ScreenDecoder() override;
void destroy() override;
bool loadFile(const Common::Path &fname,
int16 w = 320, int16 h = 200);
bool loadStream(Common::SeekableReadStream &stream, int16 w, int16 h);
bool loadStream(Common::SeekableReadStream &stream) override {
return loadStream(stream, 320, 200);
}
const Graphics::Surface *getSurface() const override {
return &_surface;
}
const Graphics::Palette &getPalette() const override { return _palette; }
void clear() { _surface.free(); }
};
} // namespace Gfx
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,69 @@
/* 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 "common/file.h"
#include "image/bmp.h"
#include "image/png.h"
#include "mm/mm1/gfx/symbols.h"
namespace MM {
namespace MM1 {
namespace Gfx {
void Symbols::load() {
Common::File f;
if (!f.open("symbols.bin"))
error("Could not load symbols.bin");
for (uint i = 0; i < MAX_SYMBOLS; ++i) {
const Common::String fname1 = Common::String::format("gfx//symbols.bin//image%.2d.bmp", i);
const Common::String fname2 = Common::String::format("gfx//symbols.bin//image%.2d.bmp", i);
Common::File fOverride1, fOverride2;
Image::BitmapDecoder bmpDecoder;
Image::PNGDecoder pngDecoder;
if (fOverride1.open(fname1.c_str()) && bmpDecoder.loadStream(fOverride1)) {
// Load the bitmap
_data[i].copyFrom(*bmpDecoder.getSurface());
f.skip(SYMBOL_WIDTH * SYMBOL_HEIGHT);
} else if (fOverride2.open(fname2.c_str()) && pngDecoder.loadStream(fOverride2)) {
// Load the png
_data[i].copyFrom(*pngDecoder.getSurface());
f.skip(SYMBOL_WIDTH * SYMBOL_HEIGHT);
} else {
// Fall back on the default
_data[i].create(SYMBOL_WIDTH, SYMBOL_HEIGHT);
f.read((byte *)_data[i].getPixels(), SYMBOL_WIDTH * SYMBOL_HEIGHT);
}
}
f.close();
}
void Symbols::draw(Graphics::ManagedSurface &dest, const Common::Point &destPos, int symbolNum) {
assert(symbolNum < MAX_SYMBOLS);
dest.blitFrom(_data[symbolNum], destPos);
}
} // namespace Gfx
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,49 @@
/* 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 MM1_GFX_SYMBOLS_H
#define MM1_GFX_SYMBOLS_H
#include "graphics/managed_surface.h"
namespace MM {
namespace MM1 {
namespace Gfx {
#define MAX_SYMBOLS 20
#define SYMBOL_WIDTH 8
#define SYMBOL_HEIGHT 8
class Symbols {
private:
Graphics::ManagedSurface _data[20];
public:
void load();
void draw(Graphics::ManagedSurface &dest, const Common::Point &destPos, int symbolNum);
};
} // namespace Gfx
} // namespace MM1
} // namespace MM
#endif