(by Codex) Restore original startup screens and edition runtime defaults

This commit is contained in:
Codex committed 2026-11-01 17:37:48 +01:00
1 parent db56c323aa
commit c8ae7a31d2
11 files changed
+136 -7

No files matched your search

+9 -6
View File
@@ -549,9 +549,9 @@ static void install_league_sizes(const LeImage& exe) {
}
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed)
: data_directory_(data), exe_(load_le(data / "BMH.exe")),
db_(load_database(data / "M3D.MAN")),
texts_(load_textd(data / "TEXTD.BLK")),
: data_directory_(data), exe_(load_le(ui::asset_path(data, "BMH.exe"))),
db_(load_database(ui::asset_path(data, "M3D.MAN"))),
texts_(load_textd(ui::asset_path(data, "TEXTD.BLK"))),
rand_(watcom_seed) {
install_league_sizes(exe_);
turn_driver_.alternate_match_event_roll = exe_.u8(::bmh::layout::AlternateEventRoll) != 0;
@@ -560,7 +560,7 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
? TransferAllocatorContext::zero : TransferAllocatorContext::blocked;
session_id_ = next_session_id.fetch_add(1, std::memory_order_relaxed);
initialize_club_modal_runtime();
g_ = startup_state(exe_, db_, read_file(data / "M3.MEN"), read_file(data / "M3.DAT"));
g_ = startup_state(exe_, db_, read_file(ui::asset_path(data, "M3.MEN")), read_file(ui::asset_path(data, "M3.DAT")));
g_.texts = &texts_;
g_.currency_suffix = exe_.cstring(::bmh::layout::CurrencySuffixText); // CurrencySuffixText
configure_training_camp_data(g_, exe_);
@@ -576,8 +576,8 @@ CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed,
const std::filesystem::path& save_path)
: data_directory_(data), exe_(load_le(data / "BMH.exe")), db_(load_database(data / "M3D.MAN")),
texts_(load_textd(data / "TEXTD.BLK")), rand_(watcom_seed) {
: data_directory_(data), exe_(load_le(ui::asset_path(data, "BMH.exe"))), db_(load_database(ui::asset_path(data, "M3D.MAN"))),
texts_(load_textd(ui::asset_path(data, "TEXTD.BLK"))), rand_(watcom_seed) {
install_league_sizes(exe_);
turn_driver_.alternate_match_event_roll = exe_.u8(::bmh::layout::AlternateEventRoll) != 0;
turn_driver_.disable_match_events = exe_.u8(::bmh::layout::MatchEventsDisabled) != 0;
@@ -926,6 +926,9 @@ std::optional<PendingOfferResult> CareerSession::dispatch_club_player_pending_of
}
void CareerSession::initialize_club_modal_runtime() {
// Setup clears the boot-only dialog mode before either creating or loading
// a career. This process flag is deliberately absent from native saves.
club_modal_runtime_.emplace(layout::CompactDialogFrame, 0);
// LE object4 has bb cdd/de/e1 in its zero-initialized virtual tail;
// CareerSession_InitializeClubModalRuntime_ExecutableField is file-backed zero. These are explicit process-start values,
// carried by this runtime owner across modal entry/return, not FBM bytes.
+26
View File
@@ -3599,6 +3599,32 @@ int main(int argc, char** argv) {
if (expired.request != ui::FlowRequest::none || expired.changed) handle(expired);
}
};
// Original boot order: publisher, credits, then the game's title. Keep
// these in the graphical frontend; creating a session starts at options.
// OpenBMH deviates from the original: keep the title visible for 1.5s
// instead of relying on the duration of DOS database initialization.
bool skip_opening = false;
for (const auto [picture, milliseconds] :
std::array<std::pair<int, Uint64>, 3>{{{138, 3000}, {139, 1000}, {137, 1500}}}) {
if (!running || skip_opening) break;
present_season(load_vga(ui::asset_path(data / "KB", std::to_string(picture) + ".VGA")),
window_title.c_str());
const auto until = SDL_GetTicks64() + milliseconds;
while (running && !skip_opening && SDL_GetTicks64() < until) {
SDL_Event opening_event;
while (SDL_PollEvent(&opening_event)) {
if (opening_event.type == SDL_QUIT) running = false;
if (opening_event.type == SDL_KEYDOWN || opening_event.type == SDL_MOUSEBUTTONUP)
skip_opening = true;
}
SDL_Delay(10);
}
}
// Opening input must not also change an option on the first setup frame.
SDL_FlushEvents(SDL_KEYDOWN, SDL_KEYUP);
SDL_FlushEvents(SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP);
season_backdrop.reset();
dirty = true;
SDL_StartTextInput();
bool filename_input_active = false;
std::array<bool, 2> setup_button_down{};
+12
View File
@@ -10,6 +10,18 @@ CalendarEpoch calendar_epoch_from_executable(const LeImage& exe) {
constexpr uint8_t month_and_year_prefix[] = {0xc6,0x44,0x24,0x0c,0x07,0xc7,0x04,0x24};
if (!exe.contains(setup) || !exe.contains(setup + 16))
throw FormatError("calendar: missing original date setup");
constexpr uint8_t english_prefix[] = {0xc6,0x45,0xf6};
constexpr uint8_t english_month_and_year[] = {0xc6,0x45,0xf7,0x07,0x66,0xc7,0x45,0xf8};
bool english = true;
for (uint32_t i=0;i<sizeof english_prefix;++i)
english = english && exe.u8(setup+i)==english_prefix[i];
for (uint32_t i=0;i<sizeof english_month_and_year;++i)
english = english && exe.u8(setup+4+i)==english_month_and_year[i];
if (english) {
const auto year=exe.u16(setup+12); const int weekday=exe.u8(setup+3);
if(year<1600||year>9999||weekday>6)throw FormatError("calendar: invalid original English epoch");
return {int(year),weekday};
}
for (uint32_t i=0;i<sizeof weekday_prefix;++i)
if(exe.u8(setup+i)!=weekday_prefix[i])throw FormatError("calendar: unverified weekday setup");
for (uint32_t i=0;i<sizeof month_and_year_prefix;++i)
+4
View File
@@ -171,6 +171,10 @@ GameState startup_state(const LeImage& exe, const Database& db, const Bytes& m3_
}
const SaveState save(stream, counts);
GameState g = GameState::from_save(save, counts);
// The original options entry restores ordinary dialogs before any manager
// confirmation. The executable's initial value belongs to its boot screens.
g.memory.add_block(layout::CompactDialogFrame, 1);
g.memory.set8(layout::CompactDialogFrame, 0);
competition_pointers(g.memory, exe); // CompetitionPointers
return g;
}
+6
View File
@@ -25,6 +25,7 @@ namespace {
constexpr uint32_t kEnFileOffset = 0x496d;
constexpr uint32_t kEnDataStart = ::bmh::layout::EnDataStart, kEnDataEnd = ::bmh::layout::Career_CompetitionPointersEnglish_RuntimeField;
constexpr uint32_t kFltdSize = 507925;
constexpr uint32_t kEnglishCalendarDateSetup = 0x684;
// The German image the engine expects: LE objects from layout field, data object GermanDataSegmentBegin-layout field.
constexpr uint32_t kDeBase = 0x10000, kDeEnd = ::bmh::layout::GermanImageEnd;
// A zero byte in the German BSS: the empty string of empty_pointers entries.
@@ -118,6 +119,11 @@ LeImage translate_fltd(const fs::path& fltd_exe) {
}
}
}
// Preserve the English date-setup operands in the shared epoch slot. The
// English routine uses a different stack layout; the calendar reader
// verifies that layout before reading its year and weekday.
for (uint32_t i = 0; i < 14; ++i)
put(layout::CalendarDateSetup + i, en(kEnglishCalendarDateSetup + i));
LeImage out = LeImage::from_bytes(kDeBase, std::move(image));
return out;
}
+1 -1
View File
@@ -379,7 +379,7 @@ ResolvedGame resolve_game(const fs::path& input, const fs::path& cache) {
const fs::path marker = prepared / ".openbmh-english";
// the version of the translation (launch/fltd.cpp, fltd_map.inc): a cache built
// by another version is built again
constexpr const char* kTranslation = "english translation 13"; // 13: setup toggle rows, positive balance colour and desktop bar controls
constexpr const char* kTranslation = "english translation 14"; // 14: preserve verified English calendar epoch operands
std::string built;
{
std::ifstream in(marker);