Restore direct-installation Classic baseline for OpenBMH 1.0 (by Codex)
This commit is contained in:
1 parent
c8f04d0099
commit
c3704878d6
255 files changed
+311
-21131
No files matched your search
+3
-11
@@ -1,5 +1,4 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/content.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/rule_base.hpp"
|
||||
|
||||
@@ -37,21 +36,14 @@ void save_image(const LeImage& image, const std::filesystem::path& path) {
|
||||
if (!file) throw FormatError("cannot write the OpenBMH image");
|
||||
}
|
||||
|
||||
LeImage load_le(const std::filesystem::path& path, bool apply_supported_rules) {
|
||||
if (const auto r = content::find(path)) {
|
||||
if (r->key != "bmh.exe")
|
||||
throw FormatError("content: unknown Classic table set");
|
||||
auto tables = apply_supported_rules ? r->content->executable : r->content->source_tables;
|
||||
tables.set_display_start_year(r->display_start_year);
|
||||
return tables;
|
||||
}
|
||||
LeImage load_le(const std::filesystem::path& path) {
|
||||
const Bytes raw = read_file(path);
|
||||
if (raw.size() >= sizeof kImageMagic + 8 && std::equal(kImageMagic, kImageMagic + sizeof kImageMagic, raw.begin())) {
|
||||
const auto word = [&](size_t at) { return uint32_t(raw[at] | raw[at + 1] << 8 | raw[at + 2] << 16) | uint32_t(raw[at + 3]) << 24; };
|
||||
const uint32_t base = word(sizeof kImageMagic), size = word(sizeof kImageMagic + 4);
|
||||
if (raw.size() != sizeof kImageMagic + 8 + size_t(size)) throw FormatError("OpenBMH image: wrong size");
|
||||
LeImage img = LeImage::from_bytes(base, Bytes(raw.begin() + sizeof kImageMagic + 8, raw.end()));
|
||||
if (apply_supported_rules) apply_rule_base(img);
|
||||
apply_rule_base(img);
|
||||
return img;
|
||||
}
|
||||
auto u8 = [&](size_t o) -> uint32_t {
|
||||
@@ -141,7 +133,7 @@ LeImage load_le(const std::filesystem::path& path, bool apply_supported_rules) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (apply_supported_rules) apply_rule_base(img);
|
||||
apply_rule_base(img);
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user