Build 0.2 native launcher and portable Classic runtime (by Codex)

This commit is contained in:
Codex committed 2026-10-18 11:28:51 +02:00
1 parent 3a021fc160
commit 2552528176
84 files changed
+5004 -197

No files matched your search

+2 -1
View File
@@ -478,7 +478,7 @@ DeskDate desk_date(uint32_t counter, const LeImage& exe) {
d.day -= month_days();
if (++d.month == 13) { d.month = 1; ++years; }
}
d.year = 2026 + years;
d.year = exe.display_start_year() + years;
return d;
}
@@ -518,6 +518,7 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
// runtime (0x165) suppresses this consumer while manual mailbox access remains valid.
if (d.runtime_club != kNoTeam && d.manager_slot >= 0 && d.manager_slot < 32 && g.memory.has(::bmh::layout::MailboxRecipientMask))
d.mailbox_notification_pending = (g.memory.u32(::bmh::layout::MailboxRecipientMask) & (uint32_t(1) << d.manager_slot)) != 0;
d.date.year += g.display_start_year - exe.display_start_year();
project_table_position(d, g);
if (!current_groups && g.date == 0 && g.season == 0 && g.season_day() == 0 && g.texts) {
const size_t title = (::bmh::layout::DeskState_DeskFromGame_TextPointer - ::bmh::layout::TextPointerTable) / 4 + 33;
+22 -5
View File
@@ -11,6 +11,7 @@
#include "ui/host_path.hpp"
#include "ui/setup.hpp"
#include "formats/fbm.hpp"
#include "content/save.hpp"
namespace bmh::ui {
namespace {
@@ -38,13 +39,21 @@ void rect(Image& image, int x, int y, int w, int h, uint8_t color) {
for (int yy = std::max(0, y); yy < std::min(image.height, y + h); ++yy)
for (int xx = std::max(0, x); xx < std::min(image.width, x + w); ++xx) image.at(xx, yy) = color;
}
bool has_file_kind_extension(const std::filesystem::path& path, SaveLoadFileKind kind) {
bool has_file_kind_extension(const std::filesystem::path &path, SaveLoadFileKind kind, bool native) {
std::string ext = path_to_utf8(path.extension());
std::transform(ext.begin(), ext.end(), ext.begin(), [](unsigned char c) { return char(std::tolower(c)); });
if (native)
return ext == (kind == SaveLoadFileKind::menu_layout ? ".oblayout"
: kind == SaveLoadFileKind::settings ? ".obsettings"
: ".obs");
return ext == (kind == SaveLoadFileKind::menu_layout ? ".men" :
kind == SaveLoadFileKind::settings ? ".ein" : ".fbm");
}
std::string_view file_kind_extension(SaveLoadFileKind kind) {
std::string_view file_kind_extension(SaveLoadFileKind kind, bool native) {
if (native)
return kind == SaveLoadFileKind::menu_layout ? ".oblayout"
: kind == SaveLoadFileKind::settings ? ".obsettings"
: ".obs";
return kind == SaveLoadFileKind::menu_layout ? ".MEN" :
kind == SaveLoadFileKind::settings ? ".EIN" : ".FBM";
}
@@ -85,13 +94,14 @@ SaveLoadScreen::SaveLoadScreen(const std::filesystem::path& data, std::filesyste
throw FormatError("save/load: unsupported state");
if (widgets_.width != 77 || widgets_.height != 112 || font_.height != 8 || footer_font_.height != 6)
throw FormatError("save/load: unsupported Original font or widget atlas");
native_ = bool(content::find(data));
std::error_code ec;
if (std::filesystem::is_directory(directory_, ec)) {
for (std::filesystem::directory_iterator it(directory_, ec), end; !ec && it != end; it.increment(ec)) {
std::error_code file_error;
const auto status = it->symlink_status(file_error);
if (!file_error && std::filesystem::is_regular_file(status) &&
has_file_kind_extension(it->path(), file_kind_))
has_file_kind_extension(it->path(), file_kind_, native_))
entries_.push_back({it->path()});
}
std::sort(entries_.begin(), entries_.end(), [](const auto& a, const auto& b) {
@@ -183,7 +193,13 @@ bool SaveLoadScreen::info_press(int x, int y) {
if (file_kind_ != SaveLoadFileKind::game || pending_ || info_ || x <= 52 || x >= 200 || y <= 40 ||
y >= 192 || !select_row(y)) return false;
try {
const auto saved = load_savegame(entries_.at(size_t(selected_)).path);
Savegame saved;
if (native_) {
saved.plain_header = content::save_information(entries_.at(size_t(selected_)).path);
saved.version = "V2.24";
saved.checksum_ok = true;
} else
saved = load_savegame(entries_.at(size_t(selected_)).path);
const auto& h = saved.plain_header;
if (!saved.checksum_ok || saved.version != "V2.24" || h.size() < 172 || h[0] < 1 || h[0] > 4)
throw FormatError("save/load: invalid native information header");
@@ -306,7 +322,8 @@ void SaveLoadScreen::request_action() {
if (!valid_filename(filename_)) {
feedback_ = "UNGUELTIGER DATEINAME"; return;
}
auto path = directory_ / path_from_utf8(filename_ + std::string(file_kind_extension(file_kind_)));
auto path =
directory_ / path_from_utf8(filename_ + std::string(file_kind_extension(file_kind_, native_)));
// Selecting an existing mixed-case extension must overwrite that same file.
if (selected_ >= 0 && size_t(selected_) < entries_.size() &&
path_to_utf8(entries_[size_t(selected_)].path.stem()) == filename_)
+1
View File
@@ -67,6 +67,7 @@ private:
TextDb texts_;
SpriteFont sprite_font_;
Font footer_font_;
bool native_ = false;
bool gradient_text_ = true;
std::vector<SaveLoadEntry> entries_;
int selected_ = 0, scroll_ = 0;
+21 -11
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "ui/settings.hpp"
#include "formats/content.hpp"
#include <algorithm>
#include <cctype>
@@ -304,18 +305,27 @@ SettingsReadmeScreen::SettingsReadmeScreen(const std::filesystem::path& data,
// DOS resolves it case-insensitively; also try its uppercase spelling on
// case-sensitive host filesystems.
const std::filesystem::path source_name(texts_[839]);
std::ifstream file(data / source_name, std::ios::binary);
if (!file) {
auto uppercase_name = source_name.string();
std::transform(uppercase_name.begin(), uppercase_name.end(), uppercase_name.begin(),
[](unsigned char c) { return char(std::toupper(c)); });
file.open(data / uppercase_name, std::ios::binary);
if (const auto resource = content::find(data / source_name)) {
const auto it = resource->content->supplemental.find(resource->key);
if (it == resource->content->supplemental.end())
return;
file_available_ = true;
content_.assign(it->second.begin(), it->second.begin() + std::min(size_t(20000), it->second.size()));
} else {
std::ifstream file(data / source_name, std::ios::binary);
if (!file) {
auto uppercase_name = source_name.string();
std::transform(uppercase_name.begin(), uppercase_name.end(), uppercase_name.begin(),
[](unsigned char c) { return char(std::toupper(c)); });
file.open(data / uppercase_name, std::ios::binary);
}
if (!file)
return;
file_available_ = true;
std::array<char, 20000> bytes{};
file.read(bytes.data(), std::streamsize(bytes.size()));
content_.assign(bytes.data(), size_t(file.gcount()));
}
if (!file) return;
file_available_ = true;
std::array<char, 20000> bytes{};
file.read(bytes.data(), std::streamsize(bytes.size()));
content_.assign(bytes.data(), size_t(file.gcount()));
pages_.emplace_back();
int x = 0, baseline = 19;
bool emphasized = false, new_page_before_next_byte = false;
+3
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "ui/setup.hpp"
#include "formats/content.hpp"
#include <algorithm>
#include <cctype>
@@ -30,6 +31,8 @@ void copy_rect(Image& dst, const Image& src, int sx, int sy, int dx, int dy,
} // namespace
std::filesystem::path asset_path(const std::filesystem::path& directory, const std::string& name) {
if (content::find(directory / name))
return directory / name;
std::filesystem::path found;
for (const auto& e : std::filesystem::directory_iterator(directory)) {
if (e.is_regular_file() && folded(e.path().filename().string()) == folded(name)) {
+9
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "ui/sportschau.hpp"
#include "formats/content.hpp"
#include <algorithm>
#include <array>
@@ -89,6 +90,14 @@ Image load_kb(const std::filesystem::path& data_directory, const char* file) {
}
std::optional<Palette> load_optional_embedded_palette(const std::filesystem::path& path) {
if (const auto resource = content::find(path)) {
auto name = std::filesystem::path(resource->key);
name.replace_extension();
const auto it = resource->content->image_palettes.find(name.generic_string());
if (it == resource->content->image_palettes.end())
return std::nullopt;
return it->second;
}
const Bytes bytes = read_file(path);
if (bytes.size() < 8) throw FormatError("sportschau: VGA palette source is truncated");
const size_t rle_end = 8 + size_t(le32(bytes, 4));