Restore full environment controls and original match pacing for 0.1.2 (by Codex)
Build without game data / build (windows-x64, windows-2022) (push) Canceled after 0s
Build without game data / build (macos-arm64, macos-14) (push) Canceled after 0s
Build without game data / build (linux-x64, ubuntu-24.04) (push) Canceled after 0s
Prepare release packages / build (push) Canceled after 0s
Prepare release packages / draft (push) Canceled after 0s

This commit is contained in:
Codex committed 2026-10-17 21:09:38 +02:00
1 parent 4fb8b2f551
commit 310e3e2464
30 files changed
+422 -383

No files matched your search

+2 -2
View File
@@ -4558,9 +4558,9 @@ bool CareerSession::dispatch_settings(const ui::SettingsWriteRequest& request, u
const bool consumed = (request.column == 7 &&
((request.row <= 6) || request.row == 7 || request.row == 9 || request.row == 10 ||
(scoped_settings && request.row == 8))) ||
// B9:C9 chance result; D9:E9 bookings; F9:G9 rolling ball;
// A9 match minutes; B9:C9 chance result; D9:E9 bookings; F9:G9 rolling ball;
// I9 cup draw; K9 Reality report; M9 preview/shootout; P9 shot.
(request.column == 8 && ((request.row >= 1 && request.row <= 6) ||
(request.column == 8 && ((request.row >= 0 && request.row <= 6) ||
request.row == 7 || request.row == 8 || request.row == 10 || request.row == 12 || request.row == 15));
if (!consumed || old >= 200) {
error = "Diese Einstellung ist noch nicht verfügbar.";
+6 -10
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "ui/live_timing.hpp"
// openbmh_play - the UI of src/ui connected to the engine: options, manager dialogs, a new
// career initialised by the engine (app/career_session.hpp) and its desk.
//
@@ -97,7 +98,7 @@ int main(int argc, char** argv) {
fs::path data, save_directory;
uint32_t seed = uint32_t(std::chrono::system_clock::now().time_since_epoch().count());
bool muted = false, music_enabled = true;
int live_frame_ms = 10;
int live_frame_ms = 0;
bool live_frame_ms_explicit = false;
if (const char* configured = std::getenv("BMH_LIVE_FRAME_MS")) {
live_frame_ms = std::clamp(std::atoi(configured), 0, 1000);
@@ -478,14 +479,8 @@ int main(int argc, char** argv) {
}
};
auto wait_source_retraces = [&](unsigned count) {
// SDL has no VGA status-port equivalent. Approximate Source's
// retrace waits with the active display's reported refresh period;
// keep the previous frame visible and present the next frame once.
SDL_DisplayMode mode{};
const int display = SDL_GetWindowDisplayIndex(window);
int refresh_hz = display >= 0 && SDL_GetCurrentDisplayMode(display, &mode) == 0
? mode.refresh_rate : 0;
if (refresh_hz <= 0) refresh_hz = 60; // explicit host fallback; not an Original VGA claim
// Keep the VGA cadence on 60/120/144-Hz host displays alike.
constexpr auto refresh_hz = ui::kOriginalRefreshHz;
const Uint64 frequency = SDL_GetPerformanceFrequency();
const Uint64 ticks_per_wait = (frequency + Uint64(refresh_hz) - 1) / Uint64(refresh_hz);
for (unsigned i = 0; running && i < count; ++i) {
@@ -2158,7 +2153,8 @@ int main(int argc, char** argv) {
live_frame_shown = true;
}
}
const int frame_delay = live_frame_ms_explicit ? live_frame_ms : std::max(live_frame_ms, 250);
const int frame_delay = live_frame_ms_explicit ? live_frame_ms :
int(ui::live_delay_milliseconds(state.memory.u8(::bmh::layout::Main_FormatError_ExecutableField)));
if (live_frame_shown && !live_skipped && frame_delay > 0)
SDL_Delay(Uint32(frame_delay));
},
+16 -18
View File
@@ -1,11 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
// OpenBMH deviates from the original: uses monthly staff levels in increments of five thousand and the supported youth-academy controls.
// The club environment (menu 24, docs/CLI_CONCEPT/06-verein.md 10, H2 p. 93, supported rule profile p. 107,
// 111): co-trainer, doctor and physio in levels of 5 000 a month, and the supported rule profile youth
// academy that costs a season price of the league.
//
// The rules are the engine's (src/game/environment.hpp, a port of Image with the
// supported rule profile patch); a command is one click of the original screen.
// The console and desktop share all six monthly environment budgets.
#include "app/desktop_actions.hpp"
#include "cli/console/console.hpp"
@@ -19,20 +13,21 @@ using namespace detail;
void Console::register_environment_commands() {
auto show = [this] {
const EnvironmentState s = environment_state(session_->state(), active_slot());
std::vector<std::vector<std::string>> rows = {
{"AssistantCoach", std::to_string(s.level[kCoTrainer]), money(s.monthly[kCoTrainer])},
{"Doctor", std::to_string(s.level[kDoctor]), money(s.monthly[kDoctor])},
{"Physio", std::to_string(s.level[kPhysio]), money(s.monthly[kPhysio])},
{"YouthAcademy", s.monthly[kYouthAcademy] != 0 ? "on" : "off", money(s.youth_price) + " per season"}};
emit_table({"Item", "Level", "Costs"}, rows);
emit('i', std::string("youth academy: ") + (s.youth_paid ? "paid this season" : s.youth_open ? "can be started (July/August)"
: "too late for this season"));
std::vector<std::vector<std::string>> rows;
constexpr const char* names[] = {"YouthYoungest", "YouthAcademy", "YouthOldest", "AssistantCoach", "Doctor", "Physio"};
for (int i = 0; i < kEnvironmentItems; ++i)
rows.push_back({names[i], std::to_string(s.level[size_t(i)]), money(s.monthly[size_t(i)])});
emit_table({"Item", "Level", "MonthlyCosts"}, rows);
rows.clear();
for (size_t i = 0; i < 3; ++i)
rows.push_back({names[i], std::to_string(s.youth_position[i] + 1), std::to_string(s.youth_league[i] + 1)});
emit_table({"YouthTeam", "Position", "Division"}, rows);
};
openers_[24] = [this, show] {
open_window("Environment");
show();
};
add({"Environment", "ShowEnvironment", {}, "staff levels and the youth academy", false}, [show](const Values&) { show(); });
add({"Environment", "ShowEnvironment", {}, "all six monthly budgets and youth tables", false}, [show](const Values&) { show(); });
auto apply = [this, show](int item, int level) {
std::string error;
const auto r=app::EnvironmentActions(*session_).set_console(
@@ -44,11 +39,14 @@ void Console::register_environment_commands() {
add({"Environment", "SetStaffLevel", {choice("role", {"AssistantCoach", "Doctor", "Physio"}), integer("level", 0, 6)},
"click a staff tile: level 0..6, 5 000 a month each", true},
[apply](const Values& v) { apply(kCoTrainer + v.choice("role"), int(v.integer("level"))); });
add({"Environment", "SetYouthAcademy", {choice("state", {"On", "Off"})}, "start (July/August) or stop the youth academy", true},
add({"Environment", "SetYouthLevel", {choice("team", {"Youngest", "Academy", "Oldest"}), integer("level", 0, 6)},
"set one youth team's monthly budget, level 0..6", true},
[apply](const Values& v) { apply(v.choice("team"), int(v.integer("level"))); });
add({"Environment", "SetYouthAcademy", {choice("state", {"On", "Off"})}, "set the middle youth budget to level 6 or 0", true},
[this, apply](const Values& v) {
const bool on = environment_state(session_->state(), active_slot()).monthly[kYouthAcademy] != 0;
const bool want = v.choice("state") == 0;
// the original's click on an active academy switches it off: click only for a change
// Retain the old On/Off command as an alias for the middle youth budget.
if (on == want) emit('+', std::string("youth academy already ") + (on ? "on" : "off"));
else apply(kYouthAcademy, want ? 6 : 0);
});
+5
View File
@@ -1026,6 +1026,11 @@ inline constexpr auto EnglishLeagueCupSemiFinalResults = 0x7d002;
inline constexpr auto Environment_FormatError_RuntimeField = 0xa50f0;
inline constexpr auto Environment_FormatError_RuntimeField2 = 0xa50f6;
inline constexpr auto Environment_Render_TextPointer = 0xaeb74;
inline constexpr auto EnvironmentYouthTeams = 0xbd4bc;
inline constexpr auto EnvironmentYouthPositionSuffix = 0xa1698;
inline constexpr auto EnvironmentCostSuffix = 0xa169d;
inline constexpr auto EnvironmentYouthLeagueTextPointer = 0xaeb78;
inline constexpr auto EnvironmentYouthColors = 0xa50fc;
inline constexpr auto Environment_SetEnvironment_ExecutableField = 0xaf394;
inline constexpr auto EuropeNameTable = 0xae710;
inline constexpr auto EventPasses = 0xa2ba1;
+7 -17
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include "game/balance_plan.hpp"
#include <algorithm>
@@ -160,13 +161,6 @@ uint32_t catering_per_game(const GameState& g, int m, int32_t gate) {
return sum;
}
// OpenBMH deviates from the original: omits the discontinued youth-group cost categories and uses league-specific youth-academy limits.
// TeamLeague3 (supported rule profile patch): the youth academy limit of the league
int32_t youth_limit(const GameState& g, int m) {
const int league = team_league(g.manager_teams.at(size_t(m)));
return league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
}
// The redraw of BalanceFromGame2 (with its continuation Redraw and the patch at
// Redraw2): recomputes the items if `refresh` asks for it, then the spectator income
// and the totals.
@@ -228,12 +222,12 @@ void redraw(const GameState& source, BalancePlanDraft& d) {
r[4] = wrap(int64_t(r[4]) + int64_t(facility_income(g, m)) * months);
const uint32_t catering = catering_per_game(g, m, r[kBalanceAverageGate]);
r[4] = wrap(int64_t(r[4]) + int64_t((catering * uint32_t(home)) / 12) * months);
// running costs Spending: the patch counts only the youth academy (index 1),
// with the whole league limit while +0x880 is below it
const uint32_t costs = ::bmh::layout::Spending + uint32_t(m) * 0x24;
if (mem32(g, costs + 4) != 0 && int64_t(months) * mem32(g, costs + 4) != 0) {
const int32_t limit = youth_limit(g, m);
if (uint32_t(rec32(g, m, 0x880)) < uint32_t(limit)) r[9] = wrap(int64_t(r[9]) + limit);
for (int k = 0; k < 3; ++k) {
const auto value = environment_monthly_cost(g, m, k);
const auto raw = mem32(g, costs + uint32_t(k) * 4);
const int count = k == kYouthAcademy && raw > kEnvironmentStep[k] * 6 ? 1 : months;
r[9] = wrap(int64_t(r[9]) + int64_t(count) * value);
}
for (int k = 0; k < 3; k++) r[size_t(10 + k)] = wrap(int64_t(r[size_t(10 + k)]) + int64_t(months) * mem32(g, costs + 0xc + uint32_t(k) * 4));
for (int k = 0; k < 2; k++) r[size_t(14 + k)] = wrap(int64_t(r[size_t(14 + k)]) + int64_t(months) * rec32(g, m, 0x854 + size_t(k) * 4));
@@ -276,11 +270,7 @@ int32_t stadium_required_attendance(const GameState& source, int manager) {
int32_t costs = wrap(int64_t(facility_costs(g, m)) + rec32(g, m, 0x854) + rec32(g, m, 0x858));
costs = wrap(int64_t(costs) + monthly_pay(g, m, 0xa));
for (int k = 0; k < 6; ++k) {
int32_t value = mem32(g, ::bmh::layout::Spending + uint32_t(m) * 0x24 + uint32_t(k) * 4);
if (k == 0 || k == 2) value = 0; // OpenBMH deviates from the original: omits the discontinued youth-group cost categories and uses league-specific youth-academy limits.
// supported rule profile MonthlyExpenses
if (k == 1 && value != 0)
value = uint32_t(rec32(g, m, 0x880)) < uint32_t(youth_limit(g, m)) ? youth_limit(g, m) : 0;
const int32_t value = environment_monthly_cost(g, m, k);
costs = wrap(int64_t(costs) + value);
}
costs = wrap(int64_t(costs) - shares_and_loans(g, m, 2, 0) + int(rec8(g, m, 0x179)) * 1000);
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// OpenBMH deviates from the original: uses the supported staff and youth-academy cost categories.
// All three youth budgets and staff costs share the monthly environment model.
// The balance plan ("Bilanz", desk menu 28, mode III; H2 p. 26-27; BMH.exe V2.24 + supported rule profile
// patch): the screen BalanceFromGame2 projects the club's income and expenses for the business
// year and lets the manager change every item. When he leaves the screen the resulting
+97 -87
View File
@@ -1,103 +1,113 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include <algorithm>
#include "game/messages.hpp"
#include "game/schedule.hpp"
#include "game/week.hpp"
#include <cstdlib>
namespace bmh {
namespace {
constexpr uint32_t kSpending = ::bmh::layout::Spending; // + manager * 0x24 + item * 4
constexpr size_t kRecordSize = 0xb0c;
constexpr size_t kYouthPaid = 0x880; // youth expenses booked this season
// EnvironmentRuntimeField: the step of each item in thousands (items 3..5: 5 000 per level)
constexpr int kUnit[kEnvironmentItems] = {2, 4, 5, 5, 5, 5};
uint32_t spending_at(int manager, int item) { return kSpending + uint32_t(manager) * 0x24 + uint32_t(item) * 4; }
// TeamLeague3: the academy's season price by the club's league
int32_t youth_price(const GameState& g, int manager) {
const int league = team_league(g.manager_teams.at(size_t(manager)));
return league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
uint32_t youth_at(int manager) { return layout::EnvironmentYouthTeams + uint32_t(manager) * 0x24; }
uint32_t spending_at(int manager, int item) {
return layout::Spending + uint32_t(manager) * 0x24 + uint32_t(item) * 4;
}
// YouthOpen: July (unless the Bundesliga is past its 17th round) or August
bool youth_open(const GameState& g) {
const int month = month_code(g.date);
if (month == 7) return !(g.league_rounds.at(0) > 0x11);
return month == 8;
void validate_manager(const GameState& g, int manager) {
if (manager < 0 || size_t(manager) >= g.manager_teams.size() ||
!g.memory.has(youth_at(manager) + 8) || !g.memory.has(spending_at(manager, 5) + 3))
throw FormatError("environment: invalid manager or truncated budgets");
}
bool youth_paid(const GameState& g, int manager) {
const size_t at = size_t(manager) * kRecordSize + kYouthPaid;
const uint32_t paid = uint32_t(g.manager_records.at(at)) | uint32_t(g.manager_records.at(at + 1)) << 8 |
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
return paid >= uint32_t(youth_price(g, manager));
int direction(int value) { return (value > 0) - (value < 0); }
int signed_clamp(int value, int low, int high) {
return std::clamp(int(int8_t(uint8_t(value))), low, high);
}
bool legacy_academy(const GameState& g, int manager) {
const auto value = g.memory.u32(spending_at(manager, kYouthAcademy));
return value == 1500000 || value == 1000000 || value == 580000 || value == 280000;
}
uint32_t academy_paid(const GameState& g, int manager) {
const auto at = size_t(manager) * 0xb0c + 0x880;
return uint32_t(g.manager_records.at(at)) | uint32_t(g.manager_records.at(at + 1)) << 8 |
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
}
}
int32_t environment_monthly_cost(const GameState& g, int manager, int item) {
const auto value = g.memory.u32(spending_at(manager, item));
if (item == kYouthAcademy && legacy_academy(g, manager) && academy_paid(g, manager) >= value) return 0;
return int32_t(value);
}
bool environment_academy_active(const GameState& g, int manager) {
const auto value = g.memory.u32(spending_at(manager, kYouthAcademy));
return value != 0 && (!legacy_academy(g, manager) || academy_paid(g, manager) >= value);
}
} // namespace
EnvironmentState environment_state(const GameState& g, int manager) {
EnvironmentState s;
for (int i = 0; i < kEnvironmentItems; i++) {
s.monthly[size_t(i)] = int32_t(g.memory.u32(spending_at(manager, i)));
// the stars (SizeT7): staff value / step, the academy 6 when on, 0/2 none
if (i >= 3) s.level[size_t(i)] = std::clamp(s.monthly[size_t(i)] / (kUnit[i] * 1000), 0, 6);
else if (i == kYouthAcademy) s.level[size_t(i)] = s.monthly[size_t(i)] != 0 ? 6 : 0;
validate_manager(g, manager);
EnvironmentState result;
for (int i = 0; i < kEnvironmentItems; ++i) {
result.monthly[size_t(i)] = int32_t(g.memory.u32(spending_at(manager, i)));
result.level[size_t(i)] = std::clamp(result.monthly[size_t(i)] / kEnvironmentStep[size_t(i)], 0, 6);
}
s.youth_price = youth_price(g, manager);
s.youth_paid = youth_paid(g, manager);
s.youth_open = youth_open(g);
return s;
}
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message) {
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || item < 0 || item >= kEnvironmentItems || level < 0 ||
level > 6 || !g.memory.has(spending_at(manager, item) + 3))
return EnvironmentResult::invalid;
const uint32_t at = spending_at(manager, item);
const int32_t before = int32_t(g.memory.u32(at));
int32_t value = 0;
EnvironmentResult result = EnvironmentResult::changed;
if (item >= 3) {
value = level * kUnit[item] * 1000;
} else if (item == kYouthAcademy) {
// YouthPrice: a click on an active academy means "off"
int wanted = level;
if (before != 0 && wanted != 0) wanted = 0;
const int32_t price = youth_price(g, manager);
if (!youth_paid(g, manager)) {
if (wanted == 0) {
value = 0;
} else if (!youth_open(g)) {
value = 0;
result = EnvironmentResult::too_late;
if (message) *message = message_text(g, ::bmh::layout::Environment_SetEnvironment_ExecutableField); // "Zu spät für diese Saison..."
} else {
value = price;
}
} else {
// paid this season: stays on; a click meant as "off" brings the second string of
// the same text block (*Environment_SetEnvironment_ExecutableField + 0x42)
value = price;
if (wanted == 0) {
result = EnvironmentResult::contract_runs;
if (message) {
*message = message_text_following(g, ::bmh::layout::Environment_SetEnvironment_ExecutableField);
// OpenBMH-authored notice when an edition has no academy tail text.
if (message->empty()) *message = "This academy contract stays active until the season ends.";
}
}
}
for (uint32_t i = 0; i < 3; ++i) {
result.youth_strength[i] = g.memory.u8(youth_at(manager) + i);
result.youth_position[i] = g.memory.u8(youth_at(manager) + 3 + i);
result.youth_league[i] = g.memory.u8(youth_at(manager) + 6 + i);
if (result.youth_position[i] > 11 || result.youth_league[i] > 2)
throw FormatError("environment: invalid youth table");
}
g.memory.set32(at, uint32_t(value));
if (result == EnvironmentResult::changed && value == before) result = EnvironmentResult::unchanged;
return result;
}
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message) {
if (message) message->clear();
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || item < 0 || item >= kEnvironmentItems ||
level < 0 || level > 6 || !g.memory.has(spending_at(manager, item) + 3))
return EnvironmentResult::invalid;
const auto at = spending_at(manager, item);
const auto value = uint32_t(level * kEnvironmentStep[size_t(item)]);
if (g.memory.u32(at) == value) return EnvironmentResult::unchanged;
g.memory.set32(at, value);
return EnvironmentResult::changed;
}
void advance_youth_teams(GameState& g, int manager, WatcomRandom& rand) {
const auto observed = environment_state(g, manager);
std::array<uint8_t, 44> movement{};
uint8_t step = 4;
for (auto& value : movement) {
value = step;
if (step != 0 && rand.range(0, 8) == 0) --step;
}
const auto round = g.league_rounds.at(0);
if (round >= movement.size()) throw FormatError("environment: youth round outside season");
constexpr int division_strength[] = {85, 70, 57};
for (size_t i = 0; i < 3; ++i) {
int strength = observed.youth_strength[i];
int position = observed.youth_position[i];
const int opponent = uint8_t(division_strength[observed.youth_league[i]] - position);
const int ratio = strength == 0 ? 100 :
int((((int64_t(observed.monthly[i]) * 100 / ((1 << i) * 10000)) >> 1) + 40) * 100 / strength);
int change = direction(ratio - 100);
if (rand.range(0, 4) == 0) change = rand.range(0, 2) - 1;
if (std::abs(ratio - 100) <= rand.range(0, 30)) change = 0;
if (rand.range(0, 2) == 0) strength = uint8_t(strength + change);
strength = signed_clamp(strength, 10, 85);
g.memory.set8(youth_at(manager) + uint32_t(i), uint8_t(strength));
const int difference = strength - opponent;
change = direction(difference);
if (rand.range(0, 4) == 0) change = rand.range(0, 2) - 1;
if (rand.range(0, 3) != 0 && std::abs(difference) * 2 < rand.range(1, 18)) change = 0;
position = signed_clamp(uint8_t(position - change * rand.range(1, movement[round])), 0, 11);
g.memory.set8(youth_at(manager) + 3 + uint32_t(i), uint8_t(position));
}
}
void finish_youth_season(GameState& g, int manager) {
const auto observed = environment_state(g, manager);
for (int i = 2; i >= 0; --i) {
auto division = observed.youth_league[size_t(i)];
const int position = observed.youth_position[size_t(i)];
int next_position = 5;
if (position < 2 && division != 0) { --division; next_position = position + 10; }
if (position > 10 && division < 2) { ++division; next_position = position - 10; }
if (i != 0) g.memory.set8(youth_at(manager) + uint32_t(i),
uint8_t((int(observed.youth_strength[size_t(i - 1)]) + observed.youth_strength[size_t(i)] * 2) / 3));
g.memory.set8(youth_at(manager) + 3 + uint32_t(i), uint8_t(next_position));
g.memory.set8(youth_at(manager) + 6 + uint32_t(i), division);
}
}
} // namespace bmh
+17 -33
View File
@@ -1,47 +1,31 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
// OpenBMH deviates from the original: enables the supported youth academy and represents staff levels in monthly increments of five thousand.
// The club environment ("Umfeld", desk menu 24, H2 p. 93; supported rule profile manual p. 107, 111):
// the screen Image with the supported rule profile patch (SizeT7 / EnvironmentOperation /
// YouthPrice / YouthOpen). Six monthly running costs per manager live at
// Spending + manager * 0x24 (u32 each); the month change books them
// (month.cpp monthly_expenses) and the staff values steer training, injuries and healing.
//
// item 0, 2 the original's two other youth age groups: the patch always sets 0
// item 1 the youth academy (supported rule profile): on or off. On it is the league's season price
// (TeamLeague3: 1.5 M, 1 M, 580 000, 280 000), paid in full at the next month
// change while record +0x880 (youth expenses this season) is below it. It can
// be switched on in July and August only ("Zu spät für diese Saison...") and
// not switched off once paid ("Der Vertrag läuft bis zum Saisonende.").
// item 3..5 co-trainer, doctor, physio: level 0..6 times 5 000 a month (EnvironmentRuntimeField)
//
// A click on a tile sets the level from the mouse position (supported rule profile: one click per value).
#include <array>
#include <cstdint>
#include <string>
#include "game/random.hpp"
#include "game/state.hpp"
namespace bmh {
constexpr int kEnvironmentItems = 6;
enum EnvironmentItem : int { kYouthAcademy = 1, kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
enum EnvironmentItem : int { kYouthYoungest = 0, kYouthAcademy = 1, kYouthOldest = 2,
kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
// OpenBMH deviates from the original: uses six monthly environment budgets across data editions while retaining the shared staff prices and academy player-generation strength bands.
inline constexpr std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
struct EnvironmentState {
std::array<int32_t, kEnvironmentItems> monthly{}; // Spending values
std::array<int, kEnvironmentItems> level{}; // the stars the screen draws (0..6)
int32_t youth_price = 0; // the season price of the academy for the club's league
bool youth_paid = false; // record +0x880 reached the price: cannot be switched off
bool youth_open = false; // July/August: the academy can still be switched on
std::array<int32_t, kEnvironmentItems> monthly{};
std::array<int, kEnvironmentItems> level{};
std::array<uint8_t, 3> youth_strength{}, youth_position{}, youth_league{};
};
EnvironmentState environment_state(const GameState& g, int manager);
enum class EnvironmentResult : uint8_t { changed, unchanged, too_late, contract_runs, invalid };
// A click on `item` at `level` (0..6; for the academy any level > 0 means "on" and a click on
// an active academy switches it off). `message` gets the original's message box text, if any.
// Preserve already saved lump-sum academy contracts until the user edits them.
int32_t environment_monthly_cost(const GameState& g, int manager, int item);
bool environment_academy_active(const GameState& g, int manager);
enum class EnvironmentResult : uint8_t { changed, unchanged, invalid };
// Set a monthly budget to level 0..6, without an immediate debit or random draw.
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message = nullptr);
// Youth results advance with first-division matchdays. Promotion/relegation and
// the handover to the next age group happen before annual accounts.
void advance_youth_teams(GameState& g, int manager, WatcomRandom& rand);
void finish_youth_season(GameState& g, int manager);
} // namespace bmh
+2 -25
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include "game/matchday.hpp"
#include <algorithm>
@@ -676,30 +677,6 @@ void manager_match_record(GameState& g, const MatchGroup& grp, int m, int home_g
}
// TicketPriceDraws: per human manager on a first league matchday. It once let the three
// ticket prices drift; in this version its stores were turned into comparisons (CMP
// instead of MOV), so only the random numbers remain.
void ticket_price_draws(const GameState& g, int manager, WatcomRandom& rand) {
uint8_t step[0x2c];
int b = 4;
for (int i = 0; i < 0x2c; i++) {
step[i] = uint8_t(b);
if (b != 0 && rand.range(0, 8) == 0) b--;
}
(void)g;
(void)manager;
const int round = g.league_rounds.empty() ? 0 : g.league_rounds[0];
for (int i = 0; i < 3; i++) {
// the direction terms depend on the prices, but only as values, not as draw counts
if (rand.range(0, 4) == 0) rand.range(0, 2);
rand.range(0, 30);
rand.range(0, 2);
if (rand.range(0, 4) == 0) rand.range(0, 2);
if (rand.range(0, 3) != 0) rand.range(1, 18);
rand.range(1, step[round < 0x2c ? round : 0x2b]);
}
}
// ManagerOf(manager, 0, value): the manager's position of this season.
static void store_season_position(GameState& g, int manager, int value) {
int season = std::min(g.season, 0x31);
@@ -742,7 +719,7 @@ void advance_league_rounds(GameState& g, uint32_t competitions, WatcomRandom& ra
for (int league = kFirst[c]; league < kFirst[c] + kCount[c]; league++) {
if (league == 0) {
for (size_t m = 0; m < g.manager_teams.size(); m++) {
ticket_price_draws(g, int(m), rand);
advance_youth_teams(g, int(m), rand);
const size_t rec = m * kManagerRecord;
if (g.league_rounds.at(0) == 0x10) wr32(g.manager_records, rec + 0x320, rd32(g.manager_records, rec + 0x308));
uint8_t& d = g.manager_records.at(rec + 0x220); // point deduction countdown
+3 -15
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include "game/month.hpp"
#include "game/trace.hpp"
@@ -482,11 +483,9 @@ void return_loans(GameState& g, WatcomRandom& rand, GameRandom* game, MinuteRepo
}
}
// OpenBMH deviates from the original: omits the two discontinued youth-group cost categories from monthly accounts.
// OriginalFinancePreview(1): the month's expenses of a human manager: facility maintenance
// (BMHExeXa), record +0x854/+0x858, the wages of the squad (MonthlyPay with flags
// 14), the six running costs of Spending (the youth work capped per league by the
// supported rule profile patch MonthlyExpenses, which also drops the youth groups 0 and 2) and the debt
// 14), all six monthly environment budgets and the debt
// service (+0x179 x 1000); each booked in the statistics.
int32_t monthly_expenses(GameState& g, int m) {
std::vector<uint8_t>& r = g.manager_records;
@@ -514,18 +513,7 @@ int32_t monthly_expenses(GameState& g, int m) {
}
sum += wages;
for (int k = 0; k < 6; k++) {
int32_t v = int32_t(g.memory.u32(::bmh::layout::Spending + uint32_t(m) * 0x24 + uint32_t(k) * 4));
// OpenBMH deviates from the original: omits the two discontinued youth-group cost categories from monthly accounts.
// MonthlyExpenses (supported rule profile patch): the two other youth groups (items 0 and 2) cost
// nothing any more, whatever the saved value
if (k == 0 || k == 2) v = 0;
if (k == 1 && v != 0) {
// TeamLeague3: the limit of the league (1.5 M, 1 M, 580000, 280000); the full
// limit is paid while +0x880 is below it, nothing after
const int league = team_league(g.manager_teams.at(size_t(m)));
const uint32_t limit = league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
v = rd32(r, rec + 0x880) < limit ? int32_t(limit) : 0;
}
const int32_t v = environment_monthly_cost(g, m, k);
if (k >= 3 && k <= 5) add32(r, rec + 0x878 + size_t(k) * 4, v);
else add32(r, rec + 0x880, v);
sum += v;
+15 -17
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include "game/season.hpp"
#include <algorithm>
@@ -641,25 +642,21 @@ namespace {
} // namespace
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
// YouthAcademyPlayer(manager) with the supported rule profile patch (SeasonOperation2, SeasonOperation3, SeasonOperation4,
// SeasonOperation5): the youth academy's player at the season accounts. Only when the academy
// was paid in full this season (record +0x880 reached the league's price, TeamLeague3) and
// the squad has at most 22 players (SquadCount(team, 3)). A computer club's young player
// moves to the club: the slots 0x86f..0 of the big clubs are searched downwards (squads of
// human managers skipped) for a player not on loan whose age (years after 16) is at most
// G(t, t + 3), t starting at 15 and lowered by one for every pass that finds none. He leaves
// his club (ReleasePlayer), gets new values around a level of the club's league
// (GeneratePlayer with 0x3000: G(79, 95) first division, G(69, 85) second, G(49, 68) third,
// G(29, 48) below), a place in the squad with a fresh board entry (PendingOfferAnswer with the
// player id | 0xf000), mood 0x69 and an age of W(0, 4) (16..20). Returns whether a player
// came. The original's G(0, 0) before the search is kept.
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
// The middle youth budget enables the existing enhanced academy recruitment.
// Old lump-sum contracts remain eligible after their saved season payment.
// Player search, strength bands, age and board setup retain the shared rules.
bool youth_academy_player(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report) {
const int team = g.manager_teams.at(size_t(m));
const int league = club_league(team);
const uint32_t price = league == 0 ? 1500000 : league == 1 ? 1000000 : league <= 3 ? 580000 : 280000;
if (uint32_t(rec32(g, m, 0x880)) < price) return false;
if (!environment_academy_active(g, m)) return false;
if (squad_count(g, team, 3) > 0x16) return false;
const auto budget = g.memory.u32(::bmh::layout::Spending + uint32_t(m) * 0x24 + kYouthAcademy * 4);
if (budget <= uint32_t(kEnvironmentStep[kYouthAcademy] * 6) &&
g.memory.u8(::bmh::layout::CareerDuration) != 1 &&
int(g.memory.u8(::bmh::layout::EnvironmentYouthTeams + uint32_t(m) * 0x24 + 2)) <
team_average(g, team, 0xf3).value - 25)
return false;
const SquadRange own = squad_range(team);
if (game.range(0, 0) != 0) return false;
for (int t = 0xf;; --t) {
@@ -708,6 +705,7 @@ namespace {
void season_accounts(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report,
const SeasonTaxHooks& tax_hooks, SeasonTaxState& tax_state) {
for (size_t i = 0; i < 0xc; i++) rec8(g, m, 0x754 + i) = 0;
finish_youth_season(g, m);
if (!g.memory.has(::bmh::layout::Season_SeasonAccounts_RuntimeField)) g.memory.add_block(::bmh::layout::Season_SeasonAccounts_RuntimeField, 4); // (runtime only, not saved)
g.memory.set8(::bmh::layout::Season_SeasonAccounts_RuntimeField + uint32_t(m), 0);
season_event(g, m, game, rand, report);
@@ -720,8 +718,8 @@ void season_accounts(GameState& g, int m, GameRandom& game, WatcomRandom& rand,
const SquadRange range = squad_range(team);
for (size_t s = 0; s < 24; s++)
if (g.squad_slots.at(range.first + s) != 0x0FFF) season_bonus(g, m, int(s), uint8_t(pos), true);
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
// YouthAcademyPlayer: the youth academy's player (supported rule profile), posted as Season_SeasonAccounts_TextPointer
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
// Academy recruitment is posted after the youth season has settled.
if (youth_academy_player(g, m, game, rand, report)) post_text(g, m, text_id(::bmh::layout::Season_SeasonAccounts_TextPointer));
if (report.unsupported) return;
if (league == 0 && pos < 100) rec8(g, m, 0x21c) = 1; // the best human club of the first division
+5 -5
View File
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#pragma once
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
// From one season to the next (BMH.exe V2.24 + supported rule profile patch).
//
// On 1 July the "Weiter" loop (DailyInterest) ends the season: CareerSession_RuntimeError_RuntimeField4 = 1, the season
@@ -94,10 +94,10 @@ void answer_offers(GameState& g, int manager, bool accept, WatcomRandom& rand, M
// offer slots (transfer list entries 0x28..0x2b, OfferSlots) are freed.
void free_offer_slots(GameState& g);
// OpenBMH deviates from the original: uses the enhanced youth-academy season settlement and player-generation rules.
// YouthAcademyPlayer (supported rule profile youth academy, season accounts): when manager `m` paid the academy in
// full this season (+0x880) and has room, a young player of a computer club joins his squad
// with values by the league (see season.cpp). Returns whether one came.
// OpenBMH deviates from the original: retains the enhanced academy player-generation strength bands with monthly youth budgets.
// Annual recruitment with an active middle youth budget (or a paid legacy
// academy contract), provided the squad has room. Shared player strength bands
// remain in effect; see season.cpp.
bool youth_academy_player(GameState& g, int m, GameRandom& game, WatcomRandom& rand, MinuteReport& report);
// ClubBalance(0): every club's mood (TeamMorale, W(20, 30)) and flags (*TeamFlags): a random
+4 -14
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#include "game/environment.hpp"
#include "ui/advertising.hpp"
#include "ui/game_end.hpp"
@@ -182,10 +183,9 @@ AdvertisingFinancePreview original_finance_preview_impl(const GameState& game, i
std::array<int, 13>{0,31,28,31,30,31,30,31,31,30,31,30,31}[size_t(month)];
income = wrap_add(income, wrap_neg(wrap_mul(original_finance_adjustment(game, manager), month_factor)));
// OpenBMH deviates from the original: uses the supported youth-academy cap and its saved cost fields.
// OriginalFinancePreview(0): pure amount of BMHExeXa, record +0x854/+0x858,
// OriginalFinancePreview(0): pure amount of BMHExeXa, record +0x854/+0x858,
// MonthlyPay flags 0x0a (salary+bonus without statistic writes), and six
// saved supported rule profile cost words. The cap for index 1 comes from TeamLeague3.
// saved monthly environment budgets.
int32_t expenses = 0;
for (int i = 0; i < 14; ++i) expenses = wrap_add(expenses, kFacilityCost[size_t(i)]);
for (int i = 14; i < 22; ++i)
@@ -202,18 +202,8 @@ AdvertisingFinancePreview original_finance_preview_impl(const GameState& game, i
expenses = wrap_add(expenses, signed32(u32(game.tactics, board + 0x50)));
expenses = wrap_add(expenses, int32_t(bonus));
}
const int team = int(u32(game.manager_records, rec + 0x290) & 0xffff);
const int league = team > 0x164 ? 0 : team_league(team); // TeamLeague2
const int32_t youth_cap = league == 0 ? 1500000 : league == 1 ? 1000000 :
league <= 3 ? 580000 : 280000;
for (int k = 0; k < 6; ++k) {
int32_t item = mem_i32(game, ::bmh::layout::Spending + uint32_t(manager) * 0x24 + uint32_t(k) * 4);
if (k == 0 || k == 2) {
// MonthlyExpenses clears these indexes unconditionally (CMP AX,3 / CMP AX,1).
item = 0;
} else if (k == 1 && item != 0) {
item = u32(game.manager_records, rec + 0x880) < uint32_t(youth_cap) ? youth_cap : 0;
}
const int32_t item = environment_monthly_cost(game, manager, k);
expenses = wrap_add(expenses, item);
}
expenses = wrap_add(expenses, wrap_neg(original_share_adjustment(game, manager, false)));
+6 -6
View File
@@ -167,17 +167,17 @@ int main(int argc, char** argv) {
cap_fixture.memory.set32(::bmh::layout::Spending + 4, 99);
cap_fixture.memory.set32(::bmh::layout::Spending, 111);
cap_fixture.memory.set32(::bmh::layout::Spending + 8, 222);
check(advertising_from_game(cap_fixture, 0).finance_preview.expenses == 1543400,
"costs 0/2 stay zero while the youth-cost item uses the source league cap");
check(advertising_from_game(cap_fixture, 0).finance_preview.expenses == 43832,
"all three youth budgets enter the monthly finance preview");
put32(cap_fixture.manager_records, 0x880, 1500000);
const auto no_cap_preview = advertising_from_game(cap_fixture, 0).finance_preview;
check(no_cap_preview.expenses == 43400,
"the youth-cost item is suppressed once funds reach the strict source threshold");
check(no_cap_preview.expenses == 43832,
"ordinary monthly youth budgets continue after the former academy threshold");
GameState ignored_cost_fixture = finance_fixture;
ignored_cost_fixture.memory.set32(::bmh::layout::Spending, 111);
ignored_cost_fixture.memory.set32(::bmh::layout::Spending + 8, 222);
check(advertising_from_game(ignored_cost_fixture, 0).finance_preview.expenses == 43400,
"legacy routine clears cost items zero and two regardless of their saved values");
check(advertising_from_game(ignored_cost_fixture, 0).finance_preview.expenses == 43733,
"the youngest and oldest youth budgets both enter expenses");
GameState loan_fixture = finance_fixture;
loan_fixture.memory.set32(::bmh::layout::Loans + 8, 100);
const auto loan_preview = advertising_from_game(loan_fixture, 0).finance_preview;
+24 -13
View File
@@ -72,6 +72,11 @@ EnvironmentView environment_from_game(const bmh::GameState& game, uint64_t revis
view.values = bmh::environment_state(game, manager);
for (int i = 0; i < kEnvironmentItems; ++i)
view.cost_text[size_t(i)] = bmh::format_number(game, view.values.monthly[size_t(i)], 0x185);
for (size_t i = 0; i < 3; ++i) {
view.youth_position_text[i] = format_number(game, view.values.youth_position[i] + 1, 0x81);
view.youth_league_text[i] = format_number(game, view.values.youth_league[i] + 1, 2) +
message_text(game, ::bmh::layout::EnvironmentYouthLeagueTextPointer);
}
view.decorated_background = !game.memory.has(::bmh::layout::PlainBackground) || game.memory.u8(::bmh::layout::PlainBackground) == 0;
view.gradient_text = (!game.memory.has(::bmh::layout::TextGradientDisabled) || game.memory.u8(::bmh::layout::TextGradientDisabled) == 0);
view.solid_panel_background = game.memory.has(::bmh::layout::SolidPanelBackground) && game.memory.u8(::bmh::layout::SolidPanelBackground) != 0;
@@ -117,9 +122,14 @@ std::string environment_view_json(const EnvironmentView& s) {
for (size_t i = 0; i < s.values.monthly.size(); ++i) { if (i) out << ','; out << s.values.monthly[i]; }
out << "],\"level\":[";
for (size_t i = 0; i < s.values.level.size(); ++i) { if (i) out << ','; out << s.values.level[i]; }
out << "],\"youth_price\":" << s.values.youth_price << ",\"youth_paid\":"
<< (s.values.youth_paid ? "true" : "false") << ",\"youth_open\":"
<< (s.values.youth_open ? "true" : "false") << '}';
out << "],\"youth_teams\":[";
for (size_t i = 0; i < 3; ++i) {
if (i) out << ',';
out << "{\"strength\":" << int(s.values.youth_strength[i])
<< ",\"position\":" << int(s.values.youth_position[i])
<< ",\"league\":" << int(s.values.youth_league[i]) << '}';
}
out << "]}";
return out.str();
}
@@ -194,9 +204,6 @@ Image EnvironmentScreen::render() const {
throw FormatError("environment: Original badge crop outside atlas");
crop(out, badge_atlas_, badge_x, 0, 0x8c, 0x61, 0x26, 0x26);
for (int item = 0; item < kEnvironmentItems; ++item) {
// OpenBMH deviates from the original: omits the two discontinued youth groups from the environment screen.
// supported rule profile BypassesTwoDiscontinuedYouthGroups bypasses the two discontinued youth groups.
if (item < 3 && item != kYouthAcademy) continue;
const int x = exe_.u8(::bmh::layout::Environment_FormatError_RuntimeField + item), y = exe_.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item);
crop(out, tiles_, item * 0x33, 0x46, x, y, 0x33, 0x29);
// CallsTwiceForUpperLowerCaptionStrips calls LoadGameEndTaxAnimationAssets twice for the upper and lower caption strips.
@@ -215,25 +222,29 @@ Image EnvironmentScreen::render() const {
for (int yy = top; yy <= bottom; ++yy) out.at(right, yy) = 0x40;
};
panel(x - 4, y - 10, x + 0x36, y - 1);
panel(x - 4, y + 0x29, x + 0x36, y + 0x31);
const int unit = item == kYouthAcademy ? 1 : item >= 3 ? 5000 : 1;
const int count = item == kYouthAcademy ? (state_.values.monthly[size_t(item)] != 0 ? 6 : 0)
: std::clamp(state_.values.monthly[size_t(item)] / unit, 0, 6);
panel(x - 4, y + 0x29, x + 0x36, y + 0x31 + (item < 3 ? 6 : 0));
const int count = state_.values.level[size_t(item)];
for (int star = 0; star < count; ++star)
crop(out, tiles_, 0x1e, 0x1e, x + star * 9, y - 8, 7, 6, 0);
// The tile artwork already contains its Source caption. CallsTwiceForUpperLowerCaptionStrips draws
// the dynamic expense in the lower strip at baseline y+0x30; a second
// invented TEXTD caption here overwrote the baked-in names and shifted
// the cost down into the hit area.
const auto& cost = state_.cost_text[size_t(item)];
const auto cost = state_.cost_text[size_t(item)] + exe_.cstring(::bmh::layout::EnvironmentCostSuffix);
text(out, x + 0x32 / 2 - font_.text_width(cost) / 2, y + 0x30, cost, 0x6b);
if (item < 3) {
const auto caption = state_.youth_position_text[size_t(item)] +
exe_.cstring(::bmh::layout::EnvironmentYouthPositionSuffix) + state_.youth_league_text[size_t(item)];
text(out, x + 0x32 / 2 - font_.text_width(caption) / 2, y + 0x36,
caption, exe_.u8(::bmh::layout::EnvironmentYouthColors + item));
}
}
return out;
}
bool EnvironmentScreen::pointer_down(int x, int y, bool right) {
if (pending_) return false;
press_seen_ = true;
pending_.reset();
pressed_item_ = pressed_level_ = -1;
pressed_right_ = right;
if (right) return true;
@@ -241,7 +252,7 @@ bool EnvironmentScreen::pointer_down(int x, int y, bool right) {
const int left = exe_.u8(::bmh::layout::Environment_FormatError_RuntimeField + item), top = exe_.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item);
if (x >= left - 9 && x <= left + 0x36 && y >= top - 10 && y <= top + 0x29) {
pressed_item_ = item;
pressed_level_ = std::clamp((x - left + 4) / 9, 0, 6);
pressed_level_ = std::clamp((x - left + 9) / 9, 0, 6);
return true;
}
}
+1
View File
@@ -26,6 +26,7 @@ struct EnvironmentView {
std::string club_name;
uint16_t badge_sprite = 0;
std::array<std::string, 6> cost_text{};
std::array<std::string, 3> youth_position_text{}, youth_league_text{};
bool decorated_background = true;
bool gradient_text = true;
bool solid_panel_background = false;
+15 -13
View File
@@ -33,9 +33,11 @@ void original_pixels(const std::filesystem::path& data, const LeImage& exe,
const auto panel = load_vga(asset_path(data / "KB", "56.VGA"));
const auto body = load_font(asset_path(data / "F", "BMH3.FNT"));
SpriteFont sprite(data);
// All four visible groups exercise an empty and an occupied star rail.
state.values.monthly[1] = 0;
for (int item = 3; item < 6; ++item) state.values.monthly[size_t(item)] = 10000;
// All six visible groups exercise an empty and an occupied star rail.
for (int item = 0; item < 6; ++item) {
state.values.level[size_t(item)] = item < 3 ? 0 : 2;
state.values.monthly[size_t(item)] = state.values.level[size_t(item)] * kEnvironmentStep[size_t(item)];
}
for (int mode = 0; mode < 3; ++mode) {
state.decorated_background = mode != 1;
state.plain_background = mode == 2;
@@ -56,9 +58,9 @@ void original_pixels(const std::filesystem::path& data, const LeImage& exe,
sprite.draw(base, 5, 235, original_to_utf8(state.club_name), 5);
for (int y = 0; y < 240; ++y) for (int x = 0; x < 320; ++x) {
bool foreground = x >= 125 && x <= 195 && y >= 82 && y <= 151;
for (int item : {1, 3, 4, 5}) {
for (int item : {0, 1, 2, 3, 4, 5}) {
const int tx = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField + item), ty = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item);
foreground |= x >= tx - 4 && x <= tx + 54 && y >= ty - 10 && y <= ty + 49;
foreground |= x >= tx - 4 && x <= tx + 54 && y >= ty - 10 && y <= ty + 49 + (item < 3 ? 6 : 0);
}
if (!foreground) check(pixel(actual, x, y) == pixel(base, x, y),
"Source KB129/flat background, centered title and active club footer");
@@ -76,14 +78,14 @@ void original_pixels(const std::filesystem::path& data, const LeImage& exe,
check(transparent_center > 0 && center_ink > 0, "central crop oracle covers transparent and ink pixels");
check(actual.at(139, 96) == 0x46 && actual.at(178, 96) == 0x40 &&
actual.at(139, 135) == 0x40, "Source badge frame and corner overwrite order");
for (int item : {1, 3, 4, 5}) {
for (int item : {0, 1, 2, 3, 4, 5}) {
const int tx = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField + item), ty = exe.u8(::bmh::layout::Environment_FormatError_RuntimeField2 + item);
for (int y = 0; y < 41; ++y) for (int x = 0; x < 51; ++x)
check(pixel(actual, tx + x, ty + y) == pixel(art, item * 51 + x, 70 + y),
"legacy routine tile is opaque, without a fabricated c0 comparekey");
// The Source upper panel is copied first; each nonzero star pixel
// replaces it. A zero in the star bitmap exposes that panel.
const int stars = item == 1 ? 0 : 2;
const int stars = state.values.level[size_t(item)];
for (int y = ty - 9; y <= ty - 2; ++y) for (int x = tx - 3; x <= tx + 53; ++x) {
uint8_t expected = state.solid_panel_background ? 0x42 : pixel(panel, x - 1, y - 20);
for (int n = 0; n < stars; ++n)
@@ -93,7 +95,7 @@ void original_pixels(const std::filesystem::path& data, const LeImage& exe,
}
check(pixel(actual, x, y) == expected, "Source star zero pixels expose the opaque KB56/flat rail");
}
const auto& cost = state.cost_text[size_t(item)];
const auto cost = state.cost_text[size_t(item)] + exe.cstring(::bmh::layout::EnvironmentCostSuffix);
const int width = body.text_width(cost), left = tx + 25 - width / 2;
Image mask(width, body.height);
body.draw(mask, 0, 0, cost, 1);
@@ -171,7 +173,7 @@ int main(int argc, char** argv) {
check(screen.key("ESC").kind == EnvironmentRequestKind::none && !screen.close_requested() &&
screen.state_json() == held, "back cannot steal a held staff control before its release");
const auto request = screen.release(x + 31, y + 5);
check(request.kind == EnvironmentRequestKind::set_item && request.item == 3 && request.level == 3 &&
check(request.kind == EnvironmentRequestKind::set_item && request.item == 3 && request.level == 4 &&
request.manager_slot == state.manager_slot && request.runtime_club == state.runtime_club &&
request.revision == 17 && request.owner == owner,
"tile release emits a typed, manager/revision-owned level request");
@@ -182,13 +184,13 @@ int main(int argc, char** argv) {
auto updated = state;
updated.revision = 18;
updated.values.level[3] = 3;
updated.values.monthly[3] = 15000;
updated.cost_text[3] = format_number(game, 15000, 0x185);
updated.values.level[3] = 4;
updated.values.monthly[3] = 20000;
updated.cost_text[3] = format_number(game, 20000, 0x185);
updated.owner.revision = 18;
screen.acknowledge(updated);
check(!screen.pending() && screen.state().revision == 18 &&
screen.state().values.monthly[3] == 15000,
screen.state().values.monthly[3] == 20000,
"valid source mutation ACK refreshes the screen and clears the pending action");
const auto notice = environment_notice_dialog(game, state.manager_slot,
+13
View File
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <cstdint>
namespace bmh::ui {
// Saved column-nine delays are source timer units. Values below six use
// integer halving; zero genuinely disables the pause.
constexpr uint32_t live_delay_milliseconds(uint8_t saved) {
return uint32_t(saved < 6 ? saved / 2 : saved) * 20;
}
// VGA mode 13h timing is independent of the host monitor's refresh rate.
inline constexpr unsigned kOriginalRefreshHz = 70;
} // namespace bmh::ui