(by Codex) Restore original startup screens and edition runtime defaults
This commit is contained in:
1 parent
db56c323aa
commit
c8ae7a31d2
11 files changed
+136
-7
No files matched your search
@@ -512,6 +512,10 @@ add_executable(national_friendly_actions_tests tests/national_friendly_actions_t
|
||||
target_link_libraries(national_friendly_actions_tests PRIVATE bmhcore)
|
||||
add_test(NAME national_friendly_actions_tests COMMAND national_friendly_actions_tests)
|
||||
|
||||
add_executable(edition_startup_app_tests tests/edition_startup_app_tests.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(edition_startup_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
bmh_add_data_test(NAME edition_startup_app_tests COMMAND edition_startup_app_tests "${BMH_DATA}")
|
||||
|
||||
add_executable(manager_join_app_tests tests/manager_join_app_tests.cpp ${BMH_APP_CONTROLLER_SOURCE} ${BMH_APP_SESSION_SDL_SOURCE})
|
||||
target_link_libraries(manager_join_app_tests PRIVATE bmhui openbmh_audio ${BMH_SDL_TARGET})
|
||||
if(MSVC)
|
||||
@@ -936,6 +940,7 @@ bmh_add_data_test(NAME league_views_data_tests COMMAND league_views_data_tests "
|
||||
# FLTD is translated by launch_check/the launcher first. Do not point these
|
||||
# tests at the raw DOS directory: the shared UI consumes the prepared image.
|
||||
set(BMH_ENGLISH_DATA "" CACHE PATH "Prepared Football Limited game-data directory")
|
||||
bmh_add_data_test(NAME english_edition_startup_app_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND edition_startup_app_tests "${BMH_ENGLISH_DATA}")
|
||||
bmh_add_data_test(NAME english_pairings_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND league_pairings_data_tests "${BMH_ENGLISH_DATA}")
|
||||
bmh_add_data_test(NAME english_desktop_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND desktop_data_tests "${BMH_ENGLISH_DATA}" --english)
|
||||
bmh_add_data_test(NAME english_league_views_data_tests DATA_DIR "${BMH_ENGLISH_DATA}" COMMAND league_views_data_tests "${BMH_ENGLISH_DATA}")
|
||||
|
||||
@@ -31,6 +31,18 @@ The six-budget monthly environment implementation has been checked against the p
|
||||
|
||||
Release acceptance of individual editions is recorded separately from their recognition. Source compatibility and automated tests do not establish full original-game or platform validation.
|
||||
|
||||
The graphical startup presents the supplied publisher, credits and title images
|
||||
before the game options. The first two original waits are three and one seconds.
|
||||
OpenBMH deviates from the original: the title remains visible for 1.5 seconds
|
||||
instead of depending on DOS database initialization time. A key or mouse release
|
||||
skips the opening sequence without also changing a setup option.
|
||||
|
||||
Setup restores ordinary scene-backed manager dialogs before a career is created
|
||||
or loaded. The executable's boot-only black dialog mode is process state and is
|
||||
not restored from native save files. Football Limited's translated data includes
|
||||
its own verified calendar year and weekday operands; German epochs are not used
|
||||
as a substitute for the English edition.
|
||||
|
||||
## Diamond 3.7 foreign crests
|
||||
|
||||
The supplied edition controls whether foreign league clubs use individual
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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{};
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -41,5 +41,14 @@ int main()try {
|
||||
auto different=image(1995,5);const uint8_t unknown=0;different.patch(bmh::layout::CalendarDateSetup,&unknown,1);
|
||||
rejected=false;try{bmh::calendar_epoch_from_executable(different);}catch(const bmh::FormatError&){rejected=true;}
|
||||
check(rejected,"unknown date routine was guessed");
|
||||
auto english=image(1995,5);
|
||||
const uint8_t english_setup[]={0xc6,0x45,0xf6,5,0xc6,0x45,0xf7,7,0x66,0xc7,0x45,0xf8,0xcb,7};
|
||||
english.patch(bmh::layout::CalendarDateSetup,english_setup,sizeof english_setup);
|
||||
const auto english_epoch=bmh::calendar_epoch_from_executable(english);
|
||||
check(english_epoch.year==1995&&english_epoch.weekday==5,"translated English date operands rejected");
|
||||
const uint8_t invalid_weekday=7;
|
||||
english.patch(bmh::layout::CalendarDateSetup+3,&invalid_weekday,1);
|
||||
rejected=false;try{bmh::calendar_epoch_from_executable(english);}catch(const bmh::FormatError&){rejected=true;}
|
||||
check(rejected,"invalid translated English weekday accepted");
|
||||
std::cout<<"Edition calendar epoch, save header and year rollover passed\n";return 0;
|
||||
}catch(const std::exception&e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
@@ -15,6 +15,8 @@ int main(int argc,char**argv){try{
|
||||
auto db=load_database(data/"M3D.MAN");auto texts=load_textd(data/"TEXTD.BLK");
|
||||
auto before=startup_state(exe,db,read_file(data/"M3.MEN"),read_file(data/"M3.DAT"));
|
||||
before.texts=&texts;
|
||||
check(before.memory.has(layout::CompactDialogFrame)&&before.memory.u8(layout::CompactDialogFrame)==0,
|
||||
"options entry disables the boot-only black dialog frame");
|
||||
for(unsigned i=0;i<4;++i)check(exe.u32(::bmh::layout::OfferSlots+i*4)==0&&before.memory.u32(::bmh::layout::OfferSlots+i*4)==0,
|
||||
"raw EXE BSS and startup_state carry zero, not empty pending offer sentinel");
|
||||
// Use the existing exact6ba3e split helpers as unchanged baseline, with
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "app/controller.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/save.hpp"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace bmh;
|
||||
using namespace bmh::ui;
|
||||
namespace { void check(bool ok,const char* message){if(!ok)throw std::runtime_error(message);} }
|
||||
int main(int argc,char** argv)try {
|
||||
if(argc<2||!*argv[1])return 77;
|
||||
const std::filesystem::path data=argv[1];
|
||||
StartupFlow flow(data);
|
||||
std::unique_ptr<app::CareerSession> session;
|
||||
uint64_t revision=0;
|
||||
openbmh::audio::Playback playback;
|
||||
std::optional<uint64_t> audio;
|
||||
const auto serve=[&](const FlowResult& result) {
|
||||
check(app::serve_flow_request(flow,result,session,data,data,0x12345678,
|
||||
revision,playback,audio,false).empty(),"production startup/navigation failed");
|
||||
};
|
||||
flow.click(150,215);flow.click(5,225,true);flow.click(5,225,true);
|
||||
serve(flow.click(90,169));
|
||||
check(session&&flow.screen_name()=="desktop","edition did not reach an actual career desk");
|
||||
check(session->state().memory.has(layout::CompactDialogFrame)&&
|
||||
session->state().memory.u8(layout::CompactDialogFrame)==0,
|
||||
"setup retained the boot-only black dialog mode");
|
||||
const auto native=save_stream(session->state());
|
||||
const auto game=session->game();const auto random=session->rand();
|
||||
const auto before_revision=revision;
|
||||
for(int kind:{8,7}) {
|
||||
const auto& items=flow.desktop()->state().items;
|
||||
const auto it=std::find_if(items.begin(),items.end(),[&](const auto& item){return item.kind==kind&&!item.disabled;});
|
||||
check(it!=items.end(),"edition lacks the enabled original calendar menu");
|
||||
serve(flow.click(it->x+it->width/2,it->y+it->height/2));
|
||||
check(flow.calendar()&&flow.screen_name()==(kind==8?"calendar":"reschedule_calendar"),
|
||||
"original calendar menu did not open");
|
||||
check(flow.render().pixels.size()==320*240,"calendar did not render a complete original frame");
|
||||
serve(flow.send_key("ESC"));
|
||||
check(flow.screen_name()=="desktop"&&!flow.desktop()->pending(),"calendar did not return its desk owner");
|
||||
}
|
||||
check(save_stream(session->state())==native&&revision==before_revision&&
|
||||
session->game().seed()==game.seed()&&session->game().calls()==game.calls()&&
|
||||
session->rand().seed()==random.seed()&&session->rand().calls()==random.calls(),
|
||||
"opening calendars changed the career or random streams");
|
||||
std::cout<<"Edition career startup, original calendar/rescheduling navigation and dialog mode passed\n";
|
||||
return 0;
|
||||
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}
|
||||
Reference in new issue
Block a user