Fix settings switches, training skill bars, editor placement and pointer

- Settings: every unlocked switch is stored, as in the original; the
  whitelist of cells with a consumer is gone (J9, O3, ... no longer
  refused). Locks and 0/1 / numeric limits still apply.
- Training: the seven skill bars show the player row under the pointer
  (FUN_00049399).
- Line-up: the field stays editable inside the set-piece editor while no
  taker kind is chosen.
- Pointer: the original 11x11 bitmap is the default pointer on every
  page, not only on the pitch page.

Refs #57, #59, #60, #62.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-11-04 19:44:46 +01:00
1 parent 04ff3b7656
commit af634ae8ff
10 files changed
+113 -67

No files matched your search

+7 -47
View File
@@ -4539,42 +4539,11 @@ bool CareerSession::dispatch_settings(const ui::SettingsWriteRequest& request, u
const uint8_t old = raw_value;
uint8_t next = old;
if (request.operation == ui::SettingsEdit::toggle_binary) {
// Inventory of actual current consumers: direct match-engine buttons,
// matchday/season flags and the live-scene switch. Other cells are not
// made writable merely because the Original UI displayed a cell.
// Tie the write whitelist to the concrete consumer ranges. League
// remapping reads rows 0..4, columns 0..3; matchday display kinds 1/2
// map to columns 0..2 and rows 0..4 or 17..19.
const bool consumed = (sound_cell && sound_capabilities_.has_value()) ||
(request.row == 0 && request.column == 4) || // A5: match/Sportschau sound
((request.row <= 4 && request.column <= 3) ||
((request.row <= 4 || request.row >= 17) && request.column <= 2)) ||
((request.row == 5 || (request.row >= 9 && request.row <= 12)) && request.column == 0) ||
(request.row == 1 && request.column == 4) || // B5 live-scene option
(request.row == 2 && request.column == 4) || // C5: Reality player numbers (RealityMatch_FormatError_ExecutableField)
(request.row == 5 && request.column == 5) || // F6: Source manager-match desk gate (MatchdaySetup_MatchdayNeedsManagerDesks_RuntimeField)
(request.row == 6 && request.column == 5) || // G6: transfer confirmation wait (OutcomeDelayDisabled)
(request.row == 16 && request.column == 6) || // Q7: own-club Sportschau preference (MatchdaySetup_ConsiderSportschauFixture_RuntimeField)
(request.row == 13 && request.column == 6) || // N7: Source kickoff competition list (SportschauAwards_MatchdayIntroView_RuntimeField)
(request.row == 1 && request.column == 6) || // B7: SportschauIntro intro gate (Controller_FormatError_RuntimeField)
(request.row == 2 && request.column == 6) || // C7: SportschauIntro intro-animation gate (Controller_FormatError_RuntimeField2)
(request.row == 3 && request.column == 6) || // D7: selected report progression (ReplayProgressionMode)
(request.row == 4 && request.column == 6) || // E7: Source-owned Sportschau scenes (ReplayChanceMode)
(request.row == 5 && request.column == 6) || // F7: SportschauIntro fixture-report gate (Controller_FormatError_RuntimeField3)
(request.row == 6 && request.column == 6) || // G7: MatchdayIntro player/award rating (SportschauAwards_FinishSportschauAwards_RuntimeField)
(request.row == 7 && request.column == 6) || // H7: SportschauTeamInfo competition totals (SportschauAwards_SportschauTeamInfoView_RuntimeField)
(request.row == 2 && request.column == 5) || // C6 drawer-handle behavior (CareerSession_DispatchDesktopLayout_RuntimeField)
(request.row == 3 && request.column == 5) || // D6 native desktop drag raster (CareerSession_DispatchDesktopLayout_RuntimeField2)
(request.row == 4 && request.column == 5) || // E6 always-visible shortcut bar (DeskState_FormatError_RuntimeField3)
(request.row == 7 && request.column == 5) || // H6 transfer option
(request.row == 8 && (request.column == 5 || request.column == 6)) || // I6/I7
(request.row >= 10 && request.row <= 13 && request.column == 4) || // K5:N5 match buttons
(request.row >= 10 && request.row <= 12 && request.column == 6) || // K7:M7 presentation
(request.row == 9 && request.column == 6) || // J7 season-entrant visibility (SeasonEntrants_SeasonEntrantsFromGame_TextPointer)
(request.row == 15 && request.column == 4) || // P5
(request.row == 16 && request.column == 4) || // Q5
(request.row == 17 && request.column == 4); // R5: secondary leagues (CalendarState_FormatError_RuntimeField2)
if (!consumed || (old != 0 && old != 1)) {
// The original edits every unlocked switch: the page only stores the value and each
// consumer reads it where it needs it. A switch without a consumer in OpenBMH yet is still
// stored (and saved) and never refused. Locks (bit 7 of the entry-time availability) and
// values other than 0/1 are refused above and below.
if (old != 0 && old != 1) {
error = "Diese Einstellung ist noch nicht verfügbar.";
return false;
}
@@ -4593,17 +4562,8 @@ bool CareerSession::dispatch_settings(const ui::SettingsWriteRequest& request, u
}
next = old ^ 1;
} else {
// Column8: existing presentation speeds B8:F8, H8 process budget,
// J8 postponed limit and K8 autosave. Column9 only exposes values
// already read by Main's Source live presenters or CupDrawScreen.
const bool consumed = (request.column == 7 &&
((request.row <= 6) || request.row == 7 || request.row == 9 || request.row == 10 ||
(scoped_settings && request.row == 8))) ||
// 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 >= 0 && request.row <= 6) ||
request.row == 7 || request.row == 8 || request.row == 10 || request.row == 12 || request.row == 15));
if (!consumed || old >= 200) {
// The numeric columns are stored the same way; values from 200 up are blank cells.
if (old >= 200) {
error = "Diese Einstellung ist noch nicht verfügbar.";
return false;
}
+12
View File
@@ -228,6 +228,18 @@ int main(int argc, char** argv) {
ui::CompetitionWinnerScreen competition_winner(data);
const auto season_exe = load_le(ui::asset_path(data, "BMH.exe"));
english_game = english_game || season_exe.u8(layout::LeagueSizes) == 20;
{
// The pointer of the original is its default 11x11 bitmap (index 0 transparent, hot spot
// top left, set by the window objects' FUN_000559eb); the pitch page draws the same bitmap
// with its own fill colour. The edition's own bitmap is used for the English version.
std::array<uint32_t, 121> bitmap{};
for (uint32_t i = 0; i < bitmap.size(); ++i) {
const auto index = season_exe.u8(layout::OriginalPointerPixels + i);
bitmap[i] = index == 0 ? 0 : palette.argb[index];
}
pitch_pointer.set_default(bitmap);
pitch_pointer.show({}, renderer);
}
app::QuitConfirmation quit_confirmation(window, english_game);
try {
if (!playback.initialize_original(app::original_audio_assets(data, season_exe), audio_error))
+7 -3
View File
@@ -10,7 +10,9 @@
namespace bmh::app {
// SDL owns pointer position; the UI supplies only the original bitmap/colors.
// SDL owns pointer position; the UI supplies only the original bitmap/colors. Everywhere but on the
// pitch page the pointer is the original's default 11x11 bitmap (set_default); the pitch page
// passes the same bitmap with its position-colour fill.
class PitchPointer {
public:
~PitchPointer() { clear(); }
@@ -22,7 +24,9 @@ public:
}
pixels_.reset();
}
void show(const std::optional<std::array<uint32_t,121>>& pixels, SDL_Renderer* renderer) {
void set_default(const std::optional<std::array<uint32_t,121>>& pixels) { default_ = pixels; }
void show(const std::optional<std::array<uint32_t,121>>& requested, SDL_Renderer* renderer) {
const auto& pixels = requested ? requested : default_;
if (!pixels) { SDL_SetCursor(SDL_GetDefaultCursor()); return; }
int width = 320, height = 240;
SDL_GetRendererOutputSize(renderer, &width, &height);
@@ -43,7 +47,7 @@ public:
}
private:
SDL_Cursor* cursor_ = nullptr;
std::optional<std::array<uint32_t,121>> pixels_;
std::optional<std::array<uint32_t,121>> pixels_, default_;
int scale_ = 1;
};
+1 -1
View File
@@ -46,7 +46,7 @@ FlowResult StartupFlow::move_action(int x, int y) {
: contracts_ && !player_card_ ? contracts_->move(x, y)
: matchday_results_ || in_readonly_view() || friendly_match_ ? false
: player_card_ ? false : pitch_ ? pitch_->move(x, y)
: lineup_ ? lineup_->move(x, y) : training_camp_ ? training_camp_->move(x, y)
: lineup_ ? lineup_->move(x, y) : training_ ? training_->move(x, y) : training_camp_ ? training_camp_->move(x, y)
: toto_ ? toto_->move(x, y)
: bank_ || stadium_ ? false
: !desktop_ && manager_ && !pending_ && !awaiting_context_ && manager_->move(x, y);
+4 -1
View File
@@ -657,8 +657,11 @@ PitchRequest PitchScreen::click(int x,int y,bool right){
r.set_piece_selector=shooter_selection_;r.expected_set_piece_value=extras_.set_piece_takers[size_t(shooter_selection_-2)];
pending_=r;return r;
}
if(!selected_)return {};
}
return {};
// OpenBMH extension: the field stays editable inside the editor. A click picks a taker
// only while a taker kind is chosen; otherwise (or with a player already marked for a
// move) the placement below works as on the normal page.
}
if(extras_.mode!=1&&order_panel_open_&&x>=243&&x<=315&&y>=179&&y<=226){
if(!selected_||*selected_>=11){rejection_="Für Anweisungen muss ein Startspieler markiert sein.";return {};}
+7
View File
@@ -169,6 +169,13 @@ int main(int argc,char**argv){try{
selector_copy.acknowledge(selected_lineup,selected);
check(selector_copy.state_json().find("\"shooter_selection\":1")!=std::string::npos,
"accepted taker write returns the original selector to neutral mode 1");
{
// the field stays editable inside the editor while no taker kind is chosen
const auto neutral_frame=selector_copy.render().pixels;
selector_copy.click(20,31);
check(selector_copy.render().pixels!=neutral_frame,
"inside the editor a click marks a player for placement when no taker kind is chosen");
}
auto automatic=selector_copy.click(260,215);
check(automatic.kind==PitchRequestKind::auto_set_piece_takers&&
automatic.expected_set_piece_values[0]==1&&automatic.expected_display_word==0x018b,
+28 -1
View File
@@ -250,7 +250,16 @@ Image TrainingScreen::render() const {
}
rect(out, 190, 222, 66, 6, 0x44);
text(out, 190, 220, texts_[(::bmh::layout::Training_Render_TextPointer4 - ::bmh::layout::TextPointerTable) / 4], 0x51, -1, false);
for (int i = 0; i < 7; ++i) copy(out, skill_atlas_, 256, 32, 190 + i * 10, 222, 16, 5, 0);
// FUN_00049399: seven bars, one per skill (two bits each of the player's skill word); each
// takes the atlas tile of its level 0-3, all empty while no player's row is under the pointer.
const auto hovered = hovered_row_ ? std::find_if(state_.players.begin(), state_.players.end(),
[&](const auto& p) { return p.row == *hovered_row_; })
: state_.players.end();
for (int i = 0; i < 7; ++i) {
const int level = hovered == state_.players.end() ? 0 : int(hovered->skills >> (2 * i) & 3);
const int sx = 256 + level * 16; // KB/2 is 314 wide: the last tile may be cut short
copy(out, skill_atlas_, sx, 32, 190 + i * 10, 222, std::min(16, skill_atlas_.width - sx), 5, 0);
}
// Int6: four original table-driven groups, transparent index DesktopRuntimeField=0.
for (int group = 0; group < 4; ++group) {
const int count = group == 3 ? int(state_.players.size()) : exe_.u8(::bmh::layout::Training_Click_RuntimeField7 + group);
@@ -347,6 +356,24 @@ TrainingRequest TrainingScreen::click(int x, int y, bool right) {
}
return {};
}
bool TrainingScreen::move(int x, int y) {
if (pending_) return false;
// The player group (3) of the click table: its box selects the row exactly as a click does.
std::optional<int> row;
const int count = int(state_.players.size());
const int bx = exe_.u16(::bmh::layout::Training_Click_RuntimeField + 3 * 2), by = exe_.u8(::bmh::layout::Training_Click_RuntimeField3 + 3);
const int dx = exe_.u8(::bmh::layout::Training_Click_RuntimeField8 + 3), dy = exe_.u8(::bmh::layout::Training_Click_RuntimeField9 + 3);
const int ball_dx = exe_.u8(::bmh::layout::Training_Click_RuntimeField5 + 3), ball_dy = exe_.u8(::bmh::layout::Training_Click_RuntimeField6 + 3);
if (x >= bx - 14 && y >= by && x < bx + count * dx + 3 * ball_dx && y < by + count * dy + 3 * ball_dy) {
const int index = dx ? (x - bx) / dx : (y - by) / dy;
if (index >= 0 && index < count &&
std::any_of(state_.players.begin(), state_.players.end(), [&](const auto& p) { return p.row == index; }))
row = index;
}
const bool changed = row != hovered_row_;
hovered_row_ = row;
return changed;
}
TrainingRequest TrainingScreen::key(std::string_view key) {
if (!pending_ && (key == "ESC" || key == "ESCAPE" || key == "BACKSPACE")) close_requested_ = true;
return {};
+4
View File
@@ -54,6 +54,9 @@ public:
Image render() const;
TrainingRequest click(int x, int y, bool right = false);
TrainingRequest key(std::string_view key);
// Original FUN_00049399: while the pointer rests on a player's row of the training list, the
// seven skill bars (T S S P Z F E) at the bottom show that player's skills; leaving it clears them.
bool move(int x, int y);
// Opening an uninitialized original screen invokes Initialize. This
// explicit request must be serviced by an engine adapter, never by render().
TrainingRequest initialize();
@@ -73,6 +76,7 @@ private:
std::optional<TrainingRequest> pending_;
bool close_requested_ = false;
std::string last_rejection_;
std::optional<int> hovered_row_;
void text(Image&, int x, int baseline, std::string_view, uint8_t color, int right = -1, bool shadow = true) const;
void sprite_text(Image&, int x, int baseline, std::string_view, int font) const;
void button(Image&, int x, int y, int width, int height, std::string_view, bool active) const;
+10
View File
@@ -66,6 +66,16 @@ int main(int argc, char** argv) {
"projection may not change original game tables");
TrainingScreen screen(data, s); const auto frame = screen.render().pixels;
check(frame == screen.render().pixels, "repeat rendering is deterministic and pure");
{
// FUN_00049399: the seven skill bars follow the player row under the pointer
const int bx = exe.u16(::bmh::layout::Training_Click_RuntimeField + 6), by = exe.u8(::bmh::layout::Training_Click_RuntimeField3 + 3);
const int dy = exe.u8(::bmh::layout::Training_Click_RuntimeField9 + 3);
TrainingScreen hover(data, s);
check(!hover.move(0, 0) && hover.render().pixels == frame, "a pointer off the list changes nothing");
check(hover.move(bx + 1, by + dy + 1) && hover.render().pixels != frame,
"the skill bars show the player row under the pointer");
check(hover.move(0, 0) && hover.render().pixels == frame, "the bars are empty again when the pointer leaves");
}
check(screen.click(175, 26).kind == TrainingRequestKind::none, "condition+technique cannot exceed four balls");
auto r = screen.click(155, 26);
check(r.kind == TrainingRequestKind::set_area && r.index == 0 && r.value == 1 && r.manager_slot == 1 &&
+33 -14
View File
@@ -3186,28 +3186,46 @@ void check_settings_writer(const std::filesystem::path& data) {
revision == before_revision + 4 && save_stream(game) == save_stream(expected),
"operation mismatch is rejected without changing memory or revision");
const auto unsupported = flow.click(67 + 8 * 24 + 5, 25 + 9 * 10 + 5); // J9, no current Source presentation consumer.
// The original stores every unlocked switch, also one that no OpenBMH consumer reads yet:
// J9 (a number, steps of two) and O3 (a switch) change their byte, one revision per click.
const uint32_t j9_address = ::bmh::layout::LeaguePresentationOptions + 9 * 9 + 8;
const uint8_t j9_old = game.memory.u8(j9_address);
const auto unsupported = flow.click(67 + 8 * 24 + 5, 25 + 9 * 10 + 5); // J9
check(unsupported.request == FlowRequest::settings_action &&
unsupported.settings_action.row == 9 && unsupported.settings_action.operation == SettingsEdit::increment,
"left half maps to one increment action; no implicit held-step loop");
serve(unsupported);
check(!flow.pending_settings() && revision == before_revision + 4 && save_stream(game) == save_stream(expected),
"unconsumed Original numeric field is safely rejected");
const bool j9_stepped = j9_old < 198;
check(!flow.pending_settings() && revision == before_revision + (j9_stepped ? 5 : 4) &&
game.memory.u8(j9_address) == uint8_t(j9_stepped ? j9_old + 2 : j9_old),
"an Original numeric field without a consumer is stored, not refused");
const auto unsupported_minus = flow.click(67 + 8 * 24 + 15, 25 + 9 * 10 + 5);
check(unsupported_minus.request == FlowRequest::settings_action &&
unsupported_minus.settings_action.operation == SettingsEdit::decrement,
"right half maps to one decrement action");
serve(unsupported_minus);
check(revision == before_revision + 4 && save_stream(game) == save_stream(expected),
"unconsumed minus action leaves the exact state unchanged");
check(revision == before_revision + (j9_stepped ? 6 : 4) && game.memory.u8(j9_address) == j9_old,
"the minus action steps the same field back");
const uint32_t o3_address = ::bmh::layout::LeaguePresentationOptions + 14 * 9 + 2;
const auto o3_state = settings_from_game(game, int(game.memory.u8(::bmh::layout::ActiveManager)), revision,
load_le(asset_path(data, "BMH.exe")));
const uint8_t o3_old = game.memory.u8(o3_address);
const bool o3_free = o3_state.display_cells && !((*o3_state.display_cells)[14 * 9 + 2] & 0x80) && o3_old <= 1;
const auto unsupported_o3 = flow.click(67 + 2 * 24 + 5, 25 + 14 * 10 + 5);
check(unsupported_o3.request == FlowRequest::settings_action &&
unsupported_o3.settings_action.row == 14 && unsupported_o3.settings_action.column == 2,
"O3 maps to its exact grid identity");
serve(unsupported_o3);
check(revision == before_revision + 4 && save_stream(game) == save_stream(expected),
"unconsumed middle rows/columns are rejected by the bounded source whitelist");
check(o3_free ? game.memory.u8(o3_address) == uint8_t(o3_old ^ 1)
: game.memory.u8(o3_address) == o3_old,
"an unlocked switch without a consumer toggles; a locked one stays");
if (o3_free) {
serve(flow.click(67 + 2 * 24 + 5, 25 + 14 * 10 + 5));
check(game.memory.u8(o3_address) == o3_old, "O3 toggles back");
}
const uint64_t settled = revision;
check(save_stream(game) == save_stream(expected), "the stepped switches leave the exact state again");
// Exact Q5 date boundary: the Original handler blocks inclusive days 110..230.
for (size_t i = 0; i < 180; ++i) game.memory.set8(::bmh::layout::LeaguePresentationOptions + uint32_t(i), 0);
@@ -3221,13 +3239,13 @@ void check_settings_writer(const std::filesystem::path& data) {
};
auto q5 = q5_request();
const auto q5_before = save_stream(game);
check(!session->dispatch_settings(q5, revision, error) && revision == before_revision + 4 &&
check(!session->dispatch_settings(q5, revision, error) && revision == settled &&
save_stream(game) == q5_before && game.date == game.season_start + 110,
"Q5 is rejected on day 110 with no memory/revision/date change");
game.date = game.season_start + 230;
q5 = q5_request();
const auto q5_end_before = save_stream(game);
check(!session->dispatch_settings(q5, revision, error) && revision == before_revision + 4 &&
check(!session->dispatch_settings(q5, revision, error) && revision == settled &&
save_stream(game) == q5_end_before,
"Q5 is also rejected on inclusive day 230");
@@ -3237,7 +3255,7 @@ void check_settings_writer(const std::filesystem::path& data) {
for (size_t i = 0; i < locked.expected_raw.size(); ++i) locked.expected_raw[i] = game.memory.u8(::bmh::layout::LeaguePresentationOptions + uint32_t(i));
locked.row = 1; locked.column = 4; locked.operation = SettingsEdit::toggle_binary;
const auto lock_before = save_stream(game);
check(!session->dispatch_settings(locked, revision, error) && revision == before_revision + 4 &&
check(!session->dispatch_settings(locked, revision, error) && revision == settled &&
save_stream(game) == lock_before,
"recomputed Original mode lock rejects B5 without a saved write");
@@ -3248,7 +3266,7 @@ void check_settings_writer(const std::filesystem::path& data) {
for (size_t i = 0; i < at_limit.expected_raw.size(); ++i) at_limit.expected_raw[i] = game.memory.u8(::bmh::layout::LeaguePresentationOptions + uint32_t(i));
at_limit.row = 1; at_limit.column = 7; at_limit.operation = SettingsEdit::increment;
const auto limit_before = save_stream(game);
check(!session->dispatch_settings(at_limit, revision, error) && revision == before_revision + 4 &&
check(!session->dispatch_settings(at_limit, revision, error) && revision == settled &&
save_stream(game) == limit_before,
"source table upper bound is a no-op, with no write or revision bump");
@@ -3259,7 +3277,7 @@ void check_settings_writer(const std::filesystem::path& data) {
stale_lock.expected_raw[i] = game.memory.u8(::bmh::layout::LeaguePresentationOptions + uint32_t(i));
stale_lock.row = 10; stale_lock.column = 4; stale_lock.operation = SettingsEdit::toggle_binary;
const auto stale_lock_before = save_stream(game);
check(!session->dispatch_settings(stale_lock, revision, error) && revision == before_revision + 4 &&
check(!session->dispatch_settings(stale_lock, revision, error) && revision == settled &&
save_stream(game) == stale_lock_before,
"recomputed unlocked display does not authorize writing a raw cell still >=2");
@@ -3315,8 +3333,9 @@ void check_settings_writer(const std::filesystem::path& data) {
other_column9.row = 9;
for (size_t i = 0; i < other_column9.expected_raw.size(); ++i)
other_column9.expected_raw[i] = i9_game.memory.u8(::bmh::layout::LeaguePresentationOptions + uint32_t(i));
check(!i9_session.dispatch_settings(other_column9, i9_revision, error) && i9_revision == 3,
"other ninth-column cells remain unavailable until their consumer is ported");
const uint8_t j9_raw = i9_game.memory.u8(::bmh::layout::LeaguePresentationOptions + 9 * 9 + 8);
check(i9_session.dispatch_settings(other_column9, i9_revision, error) == (j9_raw < 198),
"other ninth-column cells are stored too, without waiting for a consumer");
}
void check_live_delay_settings_writer(const std::filesystem::path& data,const std::filesystem::path& save_path) {