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
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:
1 parent
4fb8b2f551
commit
310e3e2464
30 files changed
+422
-383
No files matched your search
+4
-14
@@ -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)));
|
||||
|
||||
@@ -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
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user