Skip to content

feat: split screen side by side in every game, plus 3-4 player fixes (Halo CE, 2, ODST, 4) - #40

Merged
megabitt01 merged 17 commits into
megabitt01:master-chieffrom
kirklandsig:upstream/05-splitscreen
Nov 17, 2026
Merged

megabitt01 merged 17 commits into
megabitt01:master-chieffrom
kirklandsig:upstream/05-splitscreen

Conversation

@kirklandsig

Copy link
Copy Markdown

Split screen, PR 5 of the series: side by side (Left / Right) in every game, not only Reach, plus the fixes 3 and 4 players need in Halo CE, Halo 2, ODST and Halo 4. It builds on XiaoDanny's saved layout choice from his Reach port, and on #38's offsets: every new address is a DefOffset with byte patterns, and each game's hooks are grouped into features, so a build where something is missing keeps that game's stock split.

What players get

  • One "Split-screen layout" combo in Dev Tools, above the game tabs (it was Reach's "Two-player layout"). With Left / Right:
    • 2 players get equal full-height halves.
    • 3 players put player 1 on the full left half and players 2 and 3 on the right half.
    • 1 or 4 players always use the game's own layout.
  • Halo 3, ODST, Halo 4 and Reach switch at once. Halo CE and Halo 2 switch at the next mission start, in Classic graphics.
  • Each view gets its own title-safe box (Halo 3, ODST, Halo 4, Reach). The games clipped every view by the whole screen's box, which pulled each view's HUD and crosshair toward the middle of the screen: 48 px in a 1080p quarter, and onto the seam of a screen spanning two monitors.
  • ODST with 3-4 players gets the whole HUD. Its quarter layouts carry only the ammo panel, with no compass, health or grenades, so quarters and full-height halves use the full-screen layouts.
  • Halo 4 missions start with 3-4 players. They stayed black in every view. get_xbox_user_id now reports two local players until 3 s after the game state goes Running, and then the engine brings the others in beside a teammate, as it does with a controller signing in mid-game.
  • Halo CE and Halo 2 with 3-4 players, or side by side, start in Classic graphics. Their Anniversary renderers only ever draw two stacked views. The flag is cleared only while the engine copies the mission's options, so MCC's own setting is left alone, and Back still switches to Anniversary mid-mission. PR 6 brings Anniversary graphics to 3-4 players.

How it works

  • Halo 3, ODST, Halo 4 (mcc/splitscreen/LeftRight, entry/<game>/splitscreen.cpp). They share Reach's split-screen table and render-target pool, so it's what XiaoDanny's Reach port does:
    • The table's 2- and 3-player entries are kept on the Left / Right regions, and the entries they replaced are put back on Top / Bottom, black-bar patches included.
    • The divider painter draws the band down the middle.
    • The full-height halves' render target is made half the screen wide. That happens only when doing so reproduces the pool's own size, and a live switch rebuilds the pool with the engine's own release/init pair.
    • Each half's HUD takes the quarter layout at the view's height.
  • Halo 4's HUD fit (halo4/hud_fit.cpp). Halo 4's four helpers that fit its layout to other screen shapes answer for each half, so the half's HUD follows its edges and the crosshair stays centred.
  • Halo 4's side-by-side gun. Its first-person camera divides by the view's aspect, which framed the gun twice as wide in a tall half. While Left / Right is on screen, one register byte is switched so the gun is framed like the world, as Halo 3 and Reach draw it.
  • Halo CE turns its rows-first view grid into columns. Its scope effect gets the view's own re-sample factors from a mid-function hook.
  • Halo 2 has a columns-first grid mode that MCC never passes. While side by side is on screen, the grid, the cells and the divider painter get that mode.

Changes to existing code

  • CModule now installs entry sets for Halo CE, ODST and Halo 4 (they were nullptr):
    • Halo CE's and ODST's render hooks did nothing, so they're removed. ODST's target is now the split-screen render hook's.
    • This also turns on ODST's existing engine and world hooks, as Halo 3 already has them.
    • Halo 4 gets a split-screen-only set (Halo4SplitscreenEntrySet); its old engine, render and world hooks stay off.
  • SplitscreenConfigStore::Load() runs as any game module loads, not only Reach, so the render targets are built for the saved choice.
  • Halo 3, ODST and Halo 4's black-bar checkboxes are disabled while Left / Right is chosen, as Reach's are, because Left / Right owns the same table entries.
  • New helpers:
    • PreservingThunk.h (PreservedEntry, MidFunctionThunk) for detours of small leaves whose callers keep values in volatile registers, and of points inside a function.
    • EntrySet::on_remove, to undo a byte a hook patched as the module unloads.
    • Feature::Requires: Halo 4's Left / Right needs its HUD fit, so without the fit none of it goes in.
  • CPatch::apply now flushes the instruction cache after a write, since the bytes may be code.

Known limits

  • On screens wider than 16:9, a Halo 4 half's HUD isn't centred horizontally. Its UI root takes both extras, but the world-marker projection cancels only one, so centring it would put nametags and waypoints off by 320 HUD units at 32:9. It's unchanged at 16:9.
  • In Halo CE and Halo 2, side by side is a Classic layout. With Anniversary graphics on screen (Back), the game's own layout is used.

Testing (MCC 1.3528, Steam under Proton on Batocera, with virtual pads; not on Windows)

  • Build: clean on current master-chief (3c5520b, after feat: offsets that survive MCC updates (byte patterns, per-feature gating, tools, CI) #38 and fix: Halo 3 and ODST split screen - bodies stay drawn when they pile up #39). check_gates.py passes. The rebase brought no line changes, only context.
  • Box, this branch:
    • Halo 3, 2 players, Left / Right: two full-height halves with the band down the middle, and each half's HUD has its motion tracker at the bottom. fix: Halo 3 and ODST split screen - bodies stay drawn when they pile up #39's pool move is logged beside it.
    • Halo 4, 2 players, Left / Right: each half's HUD fits the half, the crosshair is centred, and the gun is framed like the world.
    • Control: Halo 4 on Top / Bottom gives the stock split, side bars included.
  • Box, on this branch's earlier base (before MenuChange, with your files):
    • Halo 3: 2 and 3 players Left / Right, and 3 players Top / Bottom.
    • ODST: 3 players Left / Right, and 4 players with the whole HUD.
    • Halo 4: 2 and 3 players Left / Right. A 3-player mission start brings in 2 players, then the third. The gun byte is switched.
    • Halo CE at 2 players and Halo 2 at 3 players, both Left / Right in Classic.
    • Controls: Halo 4 with one HUD-fit offset zeroed keeps its whole stock split, and so does Halo 3 with the render-target pool's init offset zeroed.
  • Codex adversarial review: approved. Its rounds made Halo 4's Left / Right require the HUD fit. One more change, giving the HUD-fit extras both axes, was tried and reverted for the world-marker reason above.

Doesn't depend on any open PR. PR 6 (Anniversary graphics with 3-4 players) and PR 7 (per-player HUD) build on this one.

🤖 Generated with Claude Code

kirklandsig and others added 17 commits October 29, 2026 15:09
PreservingThunk.h, for the split-screen hooks that follow:
- PreservingThunk / PreservedEntry: the detour of a small leaf function
  whose callers keep values in volatile registers across the call (Halo 3
  keeps the screen height in r10 across its title-safe box function,
  Halo 4 an xmm register across its ultrawide helpers). The thunk saves
  every volatile register but rax and xmm0 around a C++ detour, which
  also gets the caller's return address.
- MidFunctionThunk: the detour of a point inside a function, called with
  the function's stack pointer there (its locals), resuming through the
  hook's trampoline.

EntrySet::on_remove runs a callback as a module's hooks are removed, for
state that points into the module (a byte a hook patched, say).

check_gates.py counts a PreservedEntry's target as gated, like the other
Entry macros'.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
The addresses the next commits use, as DefOffsets with their byte
patterns (gen_patterns.py; values and patterns as in the kirklandsig
fork, same 1.3528 build):
- Halo CE's and Halo 2's view grid, windows and dividers, and whether
  Classic graphics are on screen;
- the Gen3 games' screen size, player count, divider painter and
  render-target pool, and Halo 3 / ODST's HUD layout records;
- each view's title-safe box (Halo 3, ODST, Halo 4);
- Halo 4's HUD layout picker, its ultrawide UI helpers and the
  first-person camera's aspect divide;
- where Halo CE and Halo 2 take a mission's game options.

COVER pins down the whole divss the Halo 4 gun fix patches; COVER_BEFORE
starts the Halo CE scope hook's pattern 0x45 bytes earlier, over the
locals its detour rewrites.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
src/mcc/splitscreen/LeftRight takes XiaoDanny's saved layout choice
(SplitscreenConfigStore's TwoPlayerLayout) to the other games. It does
what his Reach port showed the layout takes - the table's regions, the
black bars, the half-screen render target and the HUD's shape - for the
Gen3 games, which share Reach's table and render-target pool (each says
where those live in a LeftRight::Gen3), and keeps the choice for Halo CE
and Halo 2, which take it as a mission starts. Reach keeps its own
implementation.

- Active() is the choice with 2 or 3 players on screen. Reach's own gate
  (LeftRightAvailable: every Reach hook that draws it) stays on Reach's
  paths, so it doesn't hold the other games back.
- Choose() saves the choice and puts it on screen in whichever game is
  running, re-applying Reach's enabled patches over the stock entries on
  Top / Bottom.
- The store makes LayoutEntry public and gives each slot's Left/Right
  region (LeftRightRegion). Load() now runs as any game module loads:
  the render targets are built for the saved choice.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
Halo 3's Left/Right split screen (LeftRight::Gen3):
- before each frame the table's 2- and 3-player entries are kept on the
  Left/Right regions; going back to Top / Bottom puts the entries they
  replaced back, black-bar patches included;
- the divider painter draws a band down the middle (and one across the
  right half for 3 players) instead of the black bars;
- the variant-3 render target, the full-height halves' surface, is made
  half the screen wide and full height, from the pool's descriptor and
  only when that reproduces the pool's own size; a live switch rebuilds
  the pool with the engine's own release/init pair;
- a full-height half's HUD takes the quarter layout with its canvas as
  tall as the view, so the motion tracker sits at the bottom.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
ODST's Left/Right split screen, as Halo 3's (LeftRight::Gen3).

ODST never shipped four-player split screen: its quarter HUD layouts carry
only the ammo panel - no compass, health or grenades. Quarters and
full-height halves use the full-screen layouts instead
(Gen3::whole_quarter_hud), in both layouts: with Top / Bottom too, for
3-4 players.

CModule now installs ODST's hooks. render.cpp's render hook did nothing,
and its target is the split-screen render hook's, so it goes. This also
installs ODST's existing engine and world hooks (native info, task
queue), as Halo 3's are.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
Halo 4's Left/Right split screen, as Halo 3's (LeftRight::Gen3), through
Halo 4's own places: its bar painter sets up the render state before
drawing, and it sizes a pool target's view variant in a helper, which is
asked again for the unshrunk size of the halves' surface.

Halo 4 lays each view's HUD out from the view's table variant, the
full-height halves (3) taking the two-player layout, as wide as a
top/bottom half: in a Left/Right half the weapon panel ran off the right
edge. The halves take the quarter layout, exactly their width.

The split-screen hooks get an entry set of their own
(Halo4SplitscreenEntrySet), which CModule installs; the old Halo 4 hooks
(engine, render, world) stay off.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
A full-height half is 960x1080 for the quarter layout's 640x360 HUD
units, and the layout sits in the view's corner, so the HUD kept to the
top half of the view with the motion tracker at mid-height.

Halo 4 already fits its 1280x720 layout to screens of another shape
(ultrawide) through four helpers - wider or not, the aspect over 16:9's,
the extra width or height either side. While a half's HUD is updated or
drawn they now answer for that view and its layout (leaves whose callers
keep values in registers: PreservingThunk), the half's edge-anchored
elements follow its edges, and the crosshair group is moved back to the
view's centre. Every other view (Top / Bottom, quarters) gets the game's
own answers, as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
0x34EC44 builds the first-person camera from the view's: its field of
view times the screen's aspect over the view's (mulss / divss at
0x34ED92 / 0x34ED96). Stock split-screen views are wider than tall, and
that keeps the gun's framing; a 960x1080 Left/Right half doubled it, so
both arms and the whole gun came into frame, drawn big. While Left/Right
is on screen the divide's register byte is switched (divss xmm5, xmm0 ->
xmm1, the screen's aspect: E8 -> E9 at 0x34ED99), so the gun is framed
like the world, as Halo 3 and Reach draw it. It is switched in the render
hook before each frame, on the thread that draws it, put back otherwise,
and put back as the module unloads (EntrySet::on_remove).

CPatch::apply now flushes the instruction cache after a write, since the
bytes may be code.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
A Halo 4 campaign mission that starts with players 3-4 stays black in
every view, but the engine brings late joiners in beside a teammate,
like a controller signing in mid-game. get_xbox_user_id now reports two
local players in Halo 4 until 3 s after the game state goes Running,
then all of them. The clock is cleared at the end of each session
(game_restart, which MCC runs after the exit states): dropping players
while the engine shuts down can hang it, and the next session asks for
its players before its own loading state. The log says "Splitscreen:
exposing N local players" whenever the count changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
…s or side by side

Halo CE's and Halo 2's Anniversary renderers only ever draw two views,
stacked: with 3-4 players the others were missing, and side by side is a
Classic layout. Bit 0 of the first game-options byte selects Anniversary
visuals in both engines. As a mission starts (Halo CE's game_start,
Halo 2's copy_game_options) ClassicGraphicsScope clears it while the
engine copies the options, so MCC's own setting is left alone, and tells
LeftRight whether the mission runs side by side - which Halo CE and
Halo 2 take only there. Back still switches to Anniversary graphics in
the middle of a mission.

CModule now installs Halo CE's hooks; its render hook did nothing, so it
goes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
Halo CE lays its views out on a grid that always grows by rows first:
two players get it turned into two columns; with three, player 1's
window is built as a two-player half and players 2 and 3's as the right
quarters of the four-player grid. The divider painter draws a band down
the middle (and one across the right half for 3) instead of across the
screen.

A zoomed view's scope effect (pistol, sniper) re-samples the view's part
of the screen with factors MCC works out for the stock grid - how many
views the screen is wide and tall, and the view's place in them - which
put a side-by-side player's zoomed view in the wrong part of the screen,
squeezed. A mid-function hook (MidFunctionThunk) sets the same factors
from the view's own window; for the stock layouts they come out as MCC's.

Side by side is Classic's layout: while Anniversary graphics are on
screen (Back) the game's own layout is used.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
Halo 2 lays its views out on a grid it grows by rows or by columns, by a
mode MCC's build always passes as 1 (rows: Top / Bottom); any other mode
grows columns first, and with three players gives player 1 the
full-height left half. While side by side is on screen the grid and cell
calls get mode 2, and so does the divider painter, which reads the
frame's mode from a global and already has a side-by-side branch.

Side by side is Classic's layout: while Anniversary graphics are on
screen (Back) the game's own layout is used.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
Halo 3, ODST, Halo 4 and Reach clip every split-screen view by the whole
screen's title-safe box (5% in from each edge). A view's HUD is laid out
in that box and its crosshair and aim sit at its centre, so they were
pulled toward the middle of the screen: 48 px in a 1080p quarter, and
onto the seam of a screen spanning two monitors. Each view now gets its
own box, the same size, 5% in from its own edges
(LeftRight::ViewSafeBox), with 2-4 players in both layouts; a lone view
keeps the game's box.

- Halo 3 / ODST: the view setup asks a leaf for the screen's box and
  clips the view by it. The leaf answers the view setup's call (by its
  return address, inside a ViewSetup scope) with the view's own box. The
  view setup keeps the screen height in r10 across that call, hence
  PreservedEntry.
- Halo 4 / Reach: a leaf works a view and its box out together
  (LeftRight::ViewportRect); the box is replaced after it. Reach's is
  haloreach/view_safe.cpp, beside XiaoDanny's hooks.
- Halo 3 / ODST also clamp each HUD frame to a share of the whole screen
  (the HUD layout record's safe frame), which trimmed a quarter on its
  outer sides only and sat its HUD ~34 px toward the middle. Split views
  get a copy of the record with it zeroed, which the game skips.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
Dev Tools' "Two-player layout" combo sat in Reach's tab and set Reach's
table only. It moves above the game tabs as "Split-screen layout" and
goes through LeftRight::Choose: saved as before, switched at once in
Halo 3, ODST, Halo 4 and Reach, and at the next mission start in Halo CE
and Halo 2. Going back to Top / Bottom still re-applies Reach's enabled
black-bar patches over the stock entries.

Halo 3, ODST and Halo 4's black-bar checkboxes are disabled while
Left / Right is chosen, as Reach's are: Left / Right owns the same table
entries and puts back the ones it found when Top / Bottom returns, so a
patch toggled meanwhile would be undone.

docs/REVERSE_ENGINEERING.md names the combo's new place, and
LeftRight::Active as the other games' active-layout check.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
Halo 4's Left/Right hooks and its HUD fit (hud_fit.cpp) were separate
features: on an MCC update where one of the fit's offsets is missing, the
table, targets and quarter HUD layout still went to Left/Right while the
HUD kept to the top half of each view, the motion tracker at mid-height.

A feature can now require another (Feature::Requires, Offset.h): Halo 4's
Left/Right feature requires the HUD fit's, so without it none of its hooks
go in and Halo 4 keeps its stock split. No change on 1.3528.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
Compute gave a Left/Right half either extra width or extra height, by
which side of the layout's aspect the half was on. Halo 4's UI root
translation adds both (ExtraWidth at 0x3D61EB, ExtraHeight at 0x3D61FF,
independently), and a half of a screen wider than 16:9 has room either
side of its layout as well as above and below it: at 32:9 a half is
1280x720 HUD units for the quarter layout's 640x360, which wants 320 each
side and 180 above and below, not 180 alone. Each extra is now its own
axis's. On 16:9 the half is exactly the layout's width, so nothing changes
there; not tried on an ultrawide screen.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
Giving a Left/Right half both extras centres its HUD on a screen wider
than 16:9 through the UI's root translation, which adds both (0x3D61EB,
0x3D61FF) - but the world-marker projection (0x3F2783-0x3F27C5) cancels
only the extra that Wide() picks, so nametags and waypoints would land
320 HUD units off at 32:9 (and 160 with the bars removed at 4:3).
Back to one extra until that path cancels the other axis too: on screens
wider than 16:9 a half's HUD stays uncentred horizontally, as before.
Nothing changes at 16:9 either way.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
JCorcho pushed a commit to JCorcho/AlphaRing that referenced this pull request Nov 3, 2026
…phics; campaign color note

The Anniversary renderers of Halo CE and Halo 2 draw two views only: with
three players, player 2's view filled the bottom half and player 3 had
none (both HUDs over it). From kirklandsig's upstream PR megabitt01#40, without its
side-by-side layout: a mission with 3-4 players can start in Classic
graphics, where every view is laid out - bit 0 of the first game-options
byte, cleared only while the engine copies the options (Halo 2's
copy_game_options, Halo CE's game_start; offsets and patterns from the
PR). Off by default: F1 -> Splitscreen -> Options. Halo CE's hook set is
now installed (its render hook did nothing and goes).

README: Halo 2's campaign never shows player colors.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt378zyZWqKFkyBtAuBoBn
@megabitt01
megabitt01 merged commit 0335fe3 into megabitt01:master-chief Nov 17, 2026
1 check passed
@kirklandsig
kirklandsig deleted the upstream/05-splitscreen branch November 20, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants