diff --git a/README.md b/README.md
index 9ae98673..b72454e9 100644
--- a/README.md
+++ b/README.md
@@ -14,12 +14,18 @@ A Splitscreen Mod for Halo the Master Chief Collection
| 8 Players Campaign
 | Splitscreen With [Mod](https://steamcommunity.com/sharedfiles/filedetails/?id=3153235187) (By [Priception](https://steamcommunity.com/id/priception))
 |
### Features
-* Splitscreen (all games)
+* Splitscreen (all games), side by side in every game, 3-4 players in every game
+* Anniversary graphics with 3-4 players in Halo CE and Halo 2 (experimental)
+* Per-player HUD: size, area, element positions and colour
+* Spawn menus: vehicles, weapons and AI in front of any player, a menu per player on the D-pad
+* Players window and hot join: join with A, also in the middle of a mission (experimental)
* "Xbox 360" Menu (controller-friendly, toggled with F4/Left Stick Click + Start)
* Advanced Menu (for greater customization, toggled with F1)
* Camera Tool (H3)
* Object Browser (H3)
+See the [Feature Guide](#feature-guide) below for how to use each one.
+
### Installation
Good news! We now have a launcher for quickly setting up the mod. You can find [the repository here](https://github.com/megabitt01/alpharing-launcher-v2).
For a quick guide, watch this YouTube video: https://www.youtube.com/watch?v=E_0IjFBD2pI&t=30s
@@ -57,11 +63,101 @@ Works with **any Proton version** (Proton 9.0, Proton Experimental, Proton GE, e
> **Note:** Tested on Batocera Linux with the unofficial Batocera add-ons Steam client.
### Usage
-Toggle menu: `F4` or `Controller Back` + `Controller Start`
+"Xbox 360" Menu: `F4` or `Controller Start` + `Left Stick Click`. Advanced Menu: `F1` or `Controller Start` + `Right Stick Click`. Both can be changed in `alpha_ring_menu.cfg`.
+
+To navigate the Advanced Menu using Controller use the `Right Stick` to move the mouse and `RB` to click.
+
+When a menu is open, game input is disabled.
-To navigate using Controller use the `Right Stick` to move the mouse and `RB` to click.
+Spawn menu: in a campaign mission of Halo CE, Halo 2, Halo 3 or ODST, each player presses `D-pad Down` on their own controller (see [Spawn Menus](#spawn-menus-halo-ce-halo-2-halo-3-and-odst-campaigns)).
+
+---
-When the menu is open, game input is disabled.
+## Feature Guide
+
+### Split Screen: Side by Side and 3-4 Players in Every Game
+- **Side by side (Left / Right)** works in Halo CE, Halo 2, Halo 3, ODST, Halo 4 and Halo Reach (Reach's is XiaoDanny's). 2 players get two full-height halves. 3 players put player 1 on the left half and players 2 and 3 on the right quarters. 1 and 4 players keep the game's own layout.
+- **Turn it on:** Advanced Menu → **Dev Tools** → **Split-screen layout** (above the game tabs): *Top / Bottom* or *Left / Right*. It's one saved choice for every game. Halo 3, ODST, Halo 4 and Reach switch at once; Halo CE and Halo 2 at the next mission start.
+- **Crosshair and HUD centred in each view** (Halo 3, ODST, Halo 4, Reach). These games fitted every split-screen view into the whole screen's title-safe area, which pulled each player's crosshair and HUD toward the middle of the screen. Each view now gets its own.
+- **3-4 players:**
+ - Halo 4 no longer stays black: a 3-4 player mission starts with two players, and the others join about 3 seconds later.
+ - ODST's quarters and side-by-side halves use its full HUD (its quarter HUD only has the ammo panel).
+ - Halo CE and Halo 2 start 3-4 player missions in Classic graphics, since their Anniversary renderers only draw two views. MCC's own graphics setting is left alone. To keep Anniversary, see the next section.
+- **Known limits:**
+ - Halo CE and Halo 2 are side by side in Classic graphics only. A side-by-side mission starts in Classic. Back to Anniversary shows the game's own stacked views, and Back to Classic brings side by side back.
+ - Halo 4 side by side on a screen wider than 16:9: each half's HUD is centred vertically but not horizontally.
+
+### Anniversary Graphics with 3-4 Players (Halo CE and Halo 2, experimental)
+- Both Anniversary renderers only draw two views. With this on, 3-4 player missions keep Anniversary graphics: each frame still draws two views, and the pairs take turns (players 1 and 2, then players 3 and 4), so each view updates at half the frame rate.
+- **Turn it on:** Advanced Menu → **Dev Tools** → *Anniversary graphics with 3-4 players (Halo CE, Halo 2; experimental)*, under the layout. It's off by default, saved like the layout, and takes effect at the next mission start. MCC's own graphics setting still decides whether a mission is in Anniversary, and Back switches between Classic and Anniversary in the middle of it, with every view drawn.
+- **Three players:** Halo 2 gives player 1 the top half; Halo CE uses quarters and leaves the fourth black.
+- **Halo 2 Anniversary with 2 players** draws each view into its half (it came out a quarter of the screen tall before). This doesn't depend on the checkbox.
+- **Known limits:**
+ - With it off, Back to Anniversary in the middle of a 3-4 player mission doesn't draw every view: Halo 2 is black under the HUD, and Halo CE shows two views.
+ - Turned on after Halo CE has loaded in a session, it takes effect the next time Halo CE loads. Until then, Halo CE's 3-4 player missions start in Classic.
+ - Side by side still starts in Classic.
+ - Halo 2's players 3 and 4 see black until they spawn, as in Classic.
+
+### Per-Player HUD (Halo CE, Halo 2, Halo 3, ODST and Reach)
+- **Each player** can resize their whole HUD; move, resize or hide each element (motion tracker, shield/health, weapon/ammo, grenades, crosshair, equipment, messages); and pick a **HUD area**: *Game default*, *Screen edges*, *21:9 box*, *16:9 box* or *4:3 box*.
+ - An area moves the HUD's left and right elements to the sides of a centred box of that shape in the player's view. Use it to pull them in from the far edges of an ultrawide or two-monitor view, or to spread Halo CE's 4:3 HUD out to the view's edges.
+ - The crosshair can be resized or hidden, but not moved.
+- **Colour** (Halo 3, ODST, Reach): shift the HUD toward a hue, with a strength. Whites and enemy reds keep their colour.
+- **With the mouse:** Advanced Menu → **HUD**, with a tab per player, *Reset this player* and *Copy to all players*.
+- **From a controller:** the spawn menu's **MY HUD** page (D-pad Down, then LB / RB): area, size, colour and Reset.
+- **Not saved yet:** changes show up at once and last until MCC closes.
+- Messages move in Halo CE and Halo 2, and equipment in Halo 3, ODST and Reach. Halo 2's shield moves with its motion tracker. Halo 4 has no per-player settings.
+- **Halo 2 on a screen wider than 16:9:** with MCC's *HUD anchor: Centered* (the default), Halo 2 squeezes every split-screen HUD into a 16:9 box in the middle of the whole screen. Dev Tools → **halo2** → *HUD at screen edges* (off by default) keeps each player's HUD at the edges of their own view, with one player too.
+- **Halo 4:** where a split view isn't the shape its HUD layout was made for (a screen that isn't 16:9, or the black bars removed), its HUD fits the view instead of keeping to part of it.
+
+### Spawn Menus (Halo CE, Halo 2, Halo 3 and ODST Campaigns)
+Spawn vehicles, weapons, equipment and AI characters in front of any player. Characters can be on their own side, allies or enemies, with a weapon you pick.
+- **Open:** in a campaign mission, a player presses **D-pad Down** on their own controller, and a menu opens in that player's part of the screen. While it's open their Spartan holds still; the other players keep playing, or open their own menus.
+
+| Button | In the spawn menu |
+|--------|-------------------|
+| LB / RB | Vehicles, Weapons, Equipment, Characters, My HUD |
+| Up / Down | choose |
+| A | spawn in front of you |
+| Left / Right | characters: their own side, ally, enemy |
+| LT / RT | characters: their usual weapon, or any weapon the level has loaded |
+| Y | refresh the list after reaching a new part of the mission |
+| B | close |
+
+- **With the mouse:** Advanced Menu → **Spawn**: pick the player, the page and an item (with a search box, and side and weapon for characters). A player on keyboard and mouse uses this window.
+- **Halo Reach** has no spawning, so its menu opens on My HUD. **Halo 4** has neither, so D-pad Down goes to the game there.
+- No menu opens while the Advanced Menu or the "Xbox 360" Menu is open, and opening either closes the open menus.
+- **Change or turn off the button:** add a line to `alpha_ring_menu.cfg` (read when MCC starts): `spawn_menu_controller=DPAD_DOWN`, any button or combo like `BACK+DPAD_DOWN`, or `NONE`.
+- **Nothing is saved:** the menus and the Spawn window write no file.
+- **Known limits:**
+ - Spawned characters borrow an empty squad of the mission, so a mission script waiting on that squad can wait while they live. Kill them if a mission stops progressing.
+ - Spawned allies fight but don't follow you.
+ - The game keeps running while a menu is open.
+
+### Players Window and Hot Join (experimental)
+- **Players window:** Advanced Menu → **Players**. It shows a card per player with their controller (or keyboard and mouse for player 1). While it's open, every controller answers in it directly:
+ - At MCC's menus, **A** on a controller nobody plays with adds a player with it, and **B** on a player's controller takes that player out. The players after them move up a slot, each keeping their controller.
+ - **Y** on a player's controller, or the button on their card, switches them between Spartan and Elite, from the next game, in Halo 2, Halo 3 and Reach. It's offered in split screen for player 1, and for players 2-4 unless *Use player1's profile* is on.
+ - In a game, it shows who's playing, with the controllers they have now. Players join there only with hot join.
+- **The same players everywhere:** a join or a leave changes the players and controllers in the shared menu settings, so the "Xbox 360" Menu and the Advanced Menu show it, a game start applies it, and the next time a menu saves, it's written.
+- **Hot join:** the **Hot join (experimental)** checkbox at the bottom of the Players window. Then, in a mission, a controller nobody is playing with presses **A** to join, with or without the menu open, and the new player comes in beside a teammate. Works in Halo CE, Halo 2, Halo 3, ODST, Reach and Halo 4. The press a player joins with doesn't reach the game until it's let go.
+ - Halo 3, ODST, Reach and Halo 4 take the new player the way they take a controller signing in.
+ - Halo 2 brings them in through its co-op respawn. Legendary and the Iron skull turn that off, so there they come in at a starting place.
+ - Halo CE puts them on a spot a teammate just walked through. If there's none yet (at a mission's start, say), they come in at a starting place and are moved beside a teammate if such a spot turns up within 10 seconds.
+ - In Halo CE and Halo 2, going back to a checkpoint saved before a player joined brings them back the same way, not at the mission's start.
+ - Leaving in the middle of a mission works only in Halo CE: the last player who joined presses **B** with the Players window open. The other games end the mission when a player signs out, so players leave at MCC's menus.
+ - Halo CE and Halo 2 take the choice as a mission starts, so in their games it's changed at MCC's menus (the checkbox is greyed out in their games). Until such a game ends, the player count changes only by joining and leaving: the "Xbox 360" Menu's count and the Advanced Menu's -/+ are held.
+- **One at a time:** while the "Xbox 360" Menu is open, the Players window isn't drawn and hot join doesn't listen. The same goes while the Splitscreen window's **Bind** is waiting for a controller.
+- **Not saved:** the Players window writes no file of its own. The hot join choice and each player's species last until MCC closes.
+- **Known limits:**
+ - Made for campaigns and not tried in multiplayer.
+ - A player who joins in the middle of a mission doesn't get their team setting until the next game start.
+
+### Ready for MCC Updates
+- AlphaRing carries byte patterns for the addresses it uses. On MCC 1.3528 nothing changes and nothing is searched.
+- On another MCC build, each game DLL is searched once as it loads. Anything that can't be found is logged (`[Offsets]` in the log) and just that feature stays off, instead of hooking the wrong code.
+- If an address it needs in MCC's own executable can't be found, AlphaRing stays off and MCC runs unmodified.
+- Tested with a simulated update, not yet with a real one.
---
@@ -87,7 +183,8 @@ Output: `build/Release/WTSAPI32.dll`
## Credits
- **Original AlphaRing:** [WinterSquire](https://github.com/WinterSquire/AlphaRing)
-- **Controller Binding and Proton Fixes Fork:** [kirklandsig](https://github.com/kirklandsig/AlphaRing)
-- [Assembly](https://github.com/XboxChaos/Assembly) for the tag group research.
+- **Controller Binding and Proton Fixes Fork:** [kirklandsig](https://github.com/kirklandsig/AlphaRing), also for side by side in every game, Anniversary graphics with 3-4 players, the per-player HUD, the spawn menus, the Players window and hot join
+- [XiaoDanny](https://github.com/XiaoDanny) for Halo Reach's vertical split, per-player FOV and render-quality controls.
+- [Assembly](https://github.com/XboxChaos/Assembly) for the tag group research, and its plugins for the scenario layouts the spawn menus use.
- [Blender](https://github.com/blender/blender) for the bezier curve calculation.
- [Priception](https://github.com/Priception) for adding UI controller support and helping with the interface and crash issue.
diff --git a/docs/REVERSE_ENGINEERING.md b/docs/REVERSE_ENGINEERING.md
index 450243bd..73f73f97 100644
--- a/docs/REVERSE_ENGINEERING.md
+++ b/docs/REVERSE_ENGINEERING.md
@@ -246,6 +246,10 @@ See Alpha Ring Notes for the disassembly this was derived from and the three-pas
**Resume point:** the diagnostic hook that would answer this — `hud_reticle.cpp`, detouring `OFFSET_HALOREACH_PF_PROJECT_HUD_MARKER`, distinguishing the five call sites by return address — was removed from the release branch as out-of-scope diagnostic infrastructure (reticle/third-person work is deferred past this release). It produced no behavior change; fully recoverable verbatim from git history (branch `vertical-splitscreen`) behind `AlphaRing::DebugFlags::g_hudReticle` to resume this question.
+### Side-by-side HUD box centring
+
+**Known.** `ComputeHudAnchorFrame` builds each full-height Left/Right half's HUD box against the whole screen's centre line: at 1920x1080 the left half's box starts 128 px in and ends 4 px from its inner edge, the right half's starts 4 px in (yInset 64 vs 80), so both HUDs crowd the middle of the screen, more so at 21:9 (reported by salty). `hud_anchor.cpp` already centred the box for quarter slots (semantic 2); the Left/Right branch (semantic 3) returned after its canvas-height fit, so it now centres too (`CentreHudBox`, gate `g_centreHudBox`). Box-verified in the kirklandsig fork at 1920x1080 and a 1920x822 (21:9) window: each half's compass at its view's centre, identical margins. Reach's motion sensor getting a per-player offset twice is under "Per-player HUD" below.
+
## Halo Reach ultrawide and dual-monitor viewport path
Static Ghidra/source trace of the stock two-player viewport pipeline, underlying every fix above.
@@ -336,6 +340,39 @@ Multipliers: high `3.0` (light-count group `10.0`), mid `1.0`, low `0.5` (water
**Not done:** a forced-2P tier as a middle setting for 3P/4P (deliberately deferred — same 5 bytes, would need mutual exclusion with the 1P patch). Open: a per-game Performance-preset capture (low/mid tier values are currently derived, not measured); frame-cost measurement; portability to other Halo titles.
+**Known (2026-09-27): the patch makes a Reach split-screen fault hit sooner.** With the patch on and 4 local players, after repeated deaths and respawns (corpses piling up) players 3/4 saw Spartans and their own first-person weapon black or invisible (flashing on animation changes), and corpses flickered; what P1 looked at changed it. Reproduced on the test box with a real pad at The Package and confirmed by toggling the 5 bytes live: off restored P3/P4 at once, on broke them again. Writing the stock 4P record into the 1P record slot (patch on) also restored them; the 2P record did not. No single field is responsible: the shadow fields or the object/structure budget floats each push P4 black. Player records and unit objects are identical for all four players; `disable_render_state_cache_optimization` has no effect. At 2 local players the same symptoms appear after enough deaths with the patch off, so gating the patch by player count is not a fix: the cause is the per-frame skinning pool (next section), which the forced record fills sooner.
+
+## Halo Reach split screen: later views stop drawing objects as bodies pile up
+
+**Symptom** (XiaoDanny's report, reproduced 2026-09-27): after many deaths in one area, the later split-screen views draw Spartans and first-person weapons black, over-bright or not at all, and bodies flicker. The last view goes first (P4, then P3; P2 at 2 players), and what the earlier players look at changes it.
+
+**Known:**
+- It's Reach, not AlphaRing: it still happens with every AlphaRing Reach hook restored to its original bytes live, and with the render-quality patch off (the patch makes it hit sooner).
+- It follows the world object count (bodies and dropped weapons pile up at about 6 objects per death). At The Package it breaks from ~440 objects at 4 players (fine at 412) and ~495 at 2 (fine at 466 and below). Measured with a temporary in-DLL harness that kills local player 2 through `unit_kill`'s worker `0x47CAA8(unit, 0, 1, 2, 0)` in bursts of 5 and screenshots each step.
+- Reach's own collector holds the pile right at that level. `0x4FF1FC(mode 0)` starts collecting when any of these hold:
+ - more than 120 objects are waiting (`[gc+4]`, the imm8 at `0x4FF314`);
+ - object memory is low (`0xA990FC` / `0xA990F8`);
+ - fewer than 102 free object slots remain.
+- It then runs the strategy table at `0xB7393C` (0x28 per entry) while the pressure flags from `0x4FEE78` still hold. For garbage (more than 115 waiting, the imm8 at `0x4FEF10`), `0x4FF0A4` sorts the candidates' spatial groups by population (`0x4FEC3C`) and takes the earliest deadline in the first eligible group (`0x4FEF84`) - biggest pile first, not globally oldest. It works in three passes:
+ 1. flags 4: past its deadline (`+0x148`) and out of every player's sight (`0x474A2C`);
+ 2. flags 5: ignoring the deadline;
+ 3. flags 7: visible ones too.
+- For garbage pressure, it stops as soon as 115 or fewer are waiting. So in split screen the pile sits at 115-120 garbage, about 500 objects at The Package, which is above the limit. (Lowering only the 120 live did nothing, because the 115 stop is checked first.)
+- `garbage_collect_unsafe` (request word `[[TLS+0x140]+1] = 0x0101`, i.e. flags 3; `garbage_collect_now` is `0x0001`; consumer `0x47B76C` → `0x4FF1FC`) brings every view back at once. It purges every candidate, including weapons dropped a moment ago. TLS is the game thread's block: objects at +0x10, players at +0x18.
+- Ruled out as the limit:
+ - the render-state cache ("cached object render states", 1024 × 0x270 at the render thread's TLS +0x218, created by `0x256564`) holds 804 after 100 deaths at 4P;
+ - no Blam data array is full in the broken state (all ~630 scanned);
+ - `0x229558`'s 0x200 cap is a clipping vertex pool.
+
+**The limit: the per-frame skinning pool.** Every skinned object drawn in a frame - in any view, and again for shadows - gets its bone matrices from one pool of `0x35C00` bytes (about 215 KB) at `0xC51C40`, reset every frame (`0x1D3843`):
+- The allocator `0x25093C(size, flagged)` rounds the size to 4 and returns `frame << 18 | byte offset`, or -1 once it's full. `mov ecx, 0x35C00` is the limit; unflagged requests also leave the last `0x5000` bytes free. The used count is at `0x4E3888C`, the high-water mark at `0x4E38880`.
+- Its callers ask for `bones x 0x30 + 0x48` bytes: `0x24B190` once per object per frame (unflagged, handle cached with the frame number) and `0x27EBE0` (flagged). A Spartan with its weapon takes ~3.7 KB, so the pool holds about 55 of them.
+- Its users decode handles as `lea reg, [rip + pool]` + `and reg, 0x3FFFF`: ten `lea`s (one is the startup clear in `0xC390`) and ten masks in `0x24AF80`, `0x27EBE0`, `0x298A94`, `0x2993E8`, `0x299EF0`, `0x2A2400`. The pool is CPU-side only (no GPU buffer of that size; each draw copies its matrices into the `SkinningVS` constants), and nothing reads the frame bits back.
+- Measured (temporary harness, 4P, stock collector): the high-water mark climbs with the pile - 136 K at 343 objects, 213 K at 425, the full 220 K at 462 - exactly where P3 and P4 break. A skinned draw that gets -1 is drawn without its bones, which is the black/over-bright/missing body or weapon; the views are drawn in order, so the last ones lose.
+- How it was found: the render-state cache (461/1024 in the broken state) and memory diffs of `.data` didn't show it; a scan for bump allocators in the render code (a static counter loaded, advanced, compared and stored back) did - its used count swung between 16 K and 102 K within one healthy frame, against a high-water mark of 102 K.
+
+**Fix (`haloreach/skinning.cpp`).** As `haloreach.dll` loads, a 4 MB buffer is allocated within 2 GB after the module (its users reach it RIP-relative), the ten `lea`s are pointed at it, the ten masks widened to `0x3FFFFF`, the allocator's limit raised to `0x400000` and its handle shift moved from 18 to 22 bits. These are same-length edits, found by scanning the code for `lea`s to the pool and for the masks in their functions' `.pdata` ranges; they're written in an order where every partial state is a working pool (the `lea`s, the handle shift, the masks, then the limit; the instruction cache flushed after each), and undone last first as the module unloads. A build laid out differently (not exactly 10 + 10) is left alone. Box-verified (kirklandsig fork) at 4P with Reach's stock collector (the pile at 115-120 garbage, 480-540 objects): every view drew its first-person weapon and the bodies, with the high-water mark at 329 K. The collector is left as it is, so bodies stay as long as they do in single player; the cost is drawing them (~45 fps at 4P with the full pile on the test box, GPU-bound).
+
## Per-player HUD (Halo CE, 2, 3, ODST, Reach)
**Known — mechanism.** MCC's host object (`CGameManager`) has three HUD methods the games call while drawing: `+0x2F8` `get_hud_element_anchor(element, int* anchor)`, `+0x300` `get_hud_element_transform(element, float* dx, float* dy, float* scale)` and `+0x308` `transform_hud_color(user, argb)`; MCC's own versions back a feature-flagged HUD editor and the colour-blind filter. Halo CE, 2, 3, ODST and Reach ask for a transform right before placing each HUD element (MCC element ids: 1 motion sensor, 2-5 grenades, 6 shield/health, 7 weapon, 9 crosshair, 11 equipment, 12 messages) and keep the player being drawn in a global; Halo 3, ODST and Reach also pass every HUD colour, with its user, through `+0x308`. `src/mcc/hud` answers for the drawing player, on top of MCC's answer.
@@ -352,6 +389,112 @@ Multipliers: high `3.0` (light-count group `10.0`), mid `1.0`, low `0.5` (water
- **The motion sensor is asked for before its view's canvas is set.** Halo 3, ODST and Reach ask for element 1 while they set each view's HUD up, before they store that view's canvas (Halo 3 `0x2ED267`, canvas `0x2ED40C`; ODST `0x3287F5`, `0x328991`; Reach `0x2D96B7`, `0x2D984E`), so the canvas at that ask is still the previous view's - wrong wherever the views differ in size (3 players). The other elements are asked for while the view's widgets are placed (Halo 3 `0x2EDD80`, ODST `0x3292E4`, Reach `0x2D93A4`), after it. `Hud.cpp` keeps each user's canvas from those asks and gives the motion sensor's ask its own view's, as of the frame before. Halo 2 reads its view bounds right after each ask (`0x829490`), so it doesn't have this.
- **Halo 2 and "HUD anchor: Centered"** (the profiles' `LockMaxAspectRatio`, a global at `0x197EE40`, the last loaded profile's). On a screen wider than 16:9, `0x954DD0` insets the whole-screen HUD frame to a centred 16:9 box and `0x7E0A40` splits that box among the players, so every split-screen HUD bunches toward the middle of the screen and the crosshairs leave their views' centres. The embedded patch "HUD at screen edges" (`0x954DF2` `74` → `EB`, off by default) skips the inset - MCC's "HUD anchor: Edge" - with any number of players. Halo 3's `chud_draw_begin` (`0x2ED0D4`) insets each player's own view instead, so it doesn't bunch.
+## Anniversary graphics with 3-4 players (Halo CE, Halo 2)
+
+**Known — mechanism.** Both Anniversary (Saber3D) renderers draw split screen as exactly two stacked views: two cameras, render targets with two half-height children, a composite that puts each view's image on its half of the screen, and a good deal of per-view state with two slots. The 3-4 player mode (`module/entry/halo1/anniversary.cpp`, `halo2/anniversary.cpp`; Dev Tools' *Anniversary graphics with 3-4 players*, saved as `anniversary_quad`) keeps that two-view frame and alternates what is in it: players 1 and 2 on one frame, 3 and 4 on the next, so each view updates at half the frame rate. Without the choice, `Splitscreen::ClassicGraphicsScope` clears the Anniversary bit of the game options only while the engine copies them, so a 3-4 player mission starts in Classic and MCC's setting is left alone.
+- **Halo CE:** quarter-size children are made beside every split render target as the game makes those (only while the choice is on, so turned on after Halo CE made its targets it takes effect the next time Halo CE loads) and swapped in for each frame; views 3 and 4 get cameras made with the renderer's own AddCamera, kept past its camera count so everything it bounds by that count stays at two views; each view is copied into its quadrant of an image of ours, which goes to the screen before the HUD. Three players get quarters, the fourth left black (the split-screen window hook lays three windows out as four).
+- **Halo 2:** the game's glue only splits the screen for exactly two local players, so at its six `== 2` sites (by return address) the local player count answers 2 while the mode runs. Players 3 and 4 get camera copies of ours, each in its player's cell of Halo 2's own grid (with three players, player 1 keeps the top half). The game's composite quad (`0x1D2A00`) leaves no pixels with more than two players, so it's collapsed to a point and each view's image is drawn into its cell by `CellShaders.h`; the other pair's cells are kept in a texture of ours and put back before the HUD. With two players (no quad mode, the choice on or off), each view's image is drawn into its half by the same shaders: under megabitt01's D3D11 composite clip (#23, `render/d3d11/Hook.cpp`) the game's quad already placed the image in its half and the clip's viewport shrank it again, so each view came out a quarter of the screen tall. Until the shaders are made for the device, and for a view with no image, the game's composite runs as it does under the clip.
+
+### Halo 2: each view drawn at its cell's size
+
+Each frame draws two views, as two-player split screen does, and H2A's two-player split screen is itself GPU-bound at ~35 fps on the test box (82% GPU, 1080p); each view was drawn at full width and half height and squeezed into its quarter cell (30 fps with four players). What the renderer draws a view into:
+- Its render targets are built by `0xF7750` (set*, name, ... 9 args): a set keeps its count at `+0xC` and 0x30-byte entries at `+0x10` (texture* `+0`, flags `+8`). A split target gets a `_split0` child (flags 0x20000000, full width, half height) that both views are drawn into in turn, and targets with per-view history (`__HALF_F16_SSR_PREV_FRAME`) a `_split1` (0x40000000). 48 such textures at 1080p (`__FULL_8888_n___split0`, `__HALF_*`, `__QUATER_*`, `__PC_Z_BUFFER___split0`, ...).
+- The renderer sizes a view by its target, not by the camera's viewport (`camera+0x13C` x, `+0x140` y, `+0x144` width, `+0x148` height; `+0x154` field of view, `+0x158` aspect): shrinking the viewport alone drew the full target with the cell's projection (a cropped, zoomed picture, no speed-up).
+- Texture objects: vtable `+0xA0` `bool (texture*, width, height, mips, format, depth, samples, data)` writes the description (`+0x20` width, `+0x22` height, `+0x24` depth, `+0x26` format, `+0x28` samples, int16; `+0x2A` mips, byte) and makes the resources (`+0xB8`) - but only while bit 27 of `+0x98` is clear; once set, a different size is refused (returns false). `+0xC8` releases the GPU resources and views. Reference count at `+0x78`.
+
+**Fix (`QuarterViews`):** every `_split` texture is recorded as `0xF7750` adds it, and on the mode's frames (render thread, before drawing) each is remade at half width: release (`+0xC8`), clear bit 27, `+0xA0` with the new width, bit restored. Leaving the mode puts the widths back; a width the renderer changed itself (a new resolution) is taken as the new original. The listed cameras get their cell's viewport too. Box (kirklandsig fork): 4P at the same spot 30 fps @ 82% GPU before, 60 fps (vsync) @ 69% after, four samples; all four cells drawn whole.
+
+**Texture lifetime.** A reference (`+0x78`) doesn't keep a texture: a set's teardown `0xF8750` drops its reference and calls the manager's remove `0x1A5AC0` (texture*, under the manager's critical section at `0x1AB4A98`), whose delete `0x1A5990` (manager*, index into `+0x220`, count `+0x228`) removes the children (`+0xC0`, `+0xC8`), releases the resources and runs the destructor whatever the count. A hook on `0x1A5990` takes the texture out of both lists first, under the lists' mutex, which the render thread holds while remaking. Nothing under `+0xA0`/`+0xB8`/`+0xC8` takes the manager's lock or deletes (static walk, three calls deep), so the delete thread waiting on the mutex can't deadlock. Box (kirklandsig fork): Save & Quit deleted all 48 tracked textures through the hook (on another thread than the render thread, which does the narrowing), and the mission reloaded in the same process narrowed 48 new ones. Halo CE has the same hazard: its texture manager's delete (`0x1F6BF0`, texture*[] at `+0x1B8`; a render target set's release `0x20B000` gets there) removes a texture's split children (`+0xA8`, `+0xB0`) first, so its hook puts the game's own children back in a parent before the parent goes and forgets any of ours that went.
+
+### Halo 2: each view's exposure
+
+The AHDR keeps, per HDR view (four), an entry at `0x1AB8600 + view * 0x4C` (settings the level loads for views 0-1 - `+0x18` is 150 there and 11 in 2-3, `+0x35` a flag; state: `+0x3C` measured luminance, `+0x40` exposure, `+0x44` adapted luminance, int `+0x48` frames) and two 1x1 staging textures (`0x1AB8758`, texture*[4][2], made by `0x20F670`). The HDR pass `0x210BF0` (tail-called from `0x1D1C60`, the view index being the listed camera's `+0x220` slot) calls the luminance pass `0x2100C0`: the 1x1 luminance (one chain for all views, `0x1AB8730..0x1AB8750`) is copied into `read_back[view][frames & 1]`, the frame count bumped, and `read_back[view][(frames - 1) & 1]` - the frame before's - mapped and read; the adapted luminance moves toward it and sets the exposure. With the pairs alternating, the frame before was the other pair's. Measured (player 3 standing still, player 1 turning between the sky and the ground): player 3's cell 70.6, 53.9, 65.1, 54.6, and player 1's sky blown out (98).
+
+**Fix:** on the second pair's frames the HDR pass hook swaps in that pair's 16-byte adaptation state and views 2-3's read-backs (two views never use them) around the pass. After: player 3 62.4, 62.7, 62.8, 62.6; player 1's sky 87. Four other functions read a view's adapted luminance (`+0x44`, clamped, for effects' brightness): `0x14BD20`, `0x16FBA0`, `0x3CE210`, `0x4FD540`. A temporary probe (1200 quad frames) found none of them on the render thread inside the frame: `0x14BD20` (~650 calls a frame) and `0x16FBA0` (~12) run outside any frame, `0x3CE210` (~500) on worker threads, almost all while the other pair's frame is drawn (the next list being built), `0x4FD540` not at all there. So swapping for the whole frame would hand them the wrong pair; players 3-4's lists keep the first pair's value for those (**open**, minor: visible only when the pairs' exposures differ a lot). Redirecting them would take the list's pair in each reader. (A nearby player's charging plasma weapon lights the world and the other players' guns; that's normal lighting, not a leak between views.)
+
+### Halo CE: why the four views aren't all drawn every frame
+
+Three ways to draw all four each frame were tried or measured:
+
+- **Four cameras in one list** (the pair's two plus the other pair's): crashes in the next commit - prepare frame `0x455170` -> `0x2E2480` -> `0x2B0090` (access violation at `+0x2B00EC` on a garbage refcount pointer). The renderer's light manager (global at `0x1BEA9D0`) keeps per-view light lists for exactly two views: 4 entries (count `+0x158 + view*0x488`, 0x120 bytes each) and 28 (count `+0xA68 + view*0x1F88`), view 1's second block ending where the next array begins (`+0x4978`); the per-view render job (`0x452EF0` -> `0x45A8E0`) indexes it by view. Objects' hidden flags (vtable `+0x328`/`+0x330`) and the first-person models are per slot, two slots too.
+- **Rendering the frame twice**, swapping in the other pair between passes: each pass would need its own light lists (made in the commit, main thread), hidden flags and first-person models, all two-slot state the engine fills once per tick - not attempted.
+- **Presenting only complete frames** (skip the present after players 1-2, so every shown frame has both pairs fresh): measured with the present skipped on alternate frames - presents dropped to 30/s but the loop stayed at 60 quad frames/s. MCC caps the loop at 60 by itself (its settings are in `SystemSettingsData.bin`; `GameUserSettings.ini`'s `bUseVSync` isn't read - Present still got sync interval 1), so each view would still update at 30 Hz.
+- **Two game frames per MCC frame** (2026-09-29): MCC's loop (`0x1243C90`) calls the game's whole frame `0x87F90` (no arguments) through a pointer at `0x1243E34`; calling it twice in quad mode ran 60 game frames/s at 30 loops/s - each call takes the full 16.7 ms, waiting in the job system (`0xC2D50` -> `0xC2560`/`0xC19C0` at the frame's end, `0x899AD`) for MCC's frame. The pacing isn't Present (skipping every other present halves presents, the loop stays at 60) and isn't reachable from config: `Engine.ini` `[SystemSettings] t.MaxFPS`, `rhi.SyncInterval=0`, `r.VSync=0` and `[/Script/Engine.Engine] bSmoothFrameRate=False` changed nothing. MCC's executable carries UE4's RHI frame pacer (`rhi.SyncInterval`, "the RHI vsync thread"), which paces frames without a present - the likely source.
+
+The 4P frame costs 53% GPU at 60 fps on the test box, so drawing both pairs would fit if the engine had four view slots; unlocking MCC's pacing for CE quad mode instead would need about twice the GPU time per shown frame (fine on the test box at best, too much for a Steam Deck).
+
+### Halo CE: players 3-4's cameras and first-person models
+
+Each frame the game thread commits the list the previous sync built (prepare `0x455170` with the commit fields set), then runs the sync `0x89F00` (under the Saber sync lock `0x1BA3AB8`, which the classic HUD pass `0x740B0` also takes: the whole game frame `0xAC29C0`, the first-person hand-off, the objects' sync), while a worker builds the next list and the render thread draws the committed one (render job `0x452740`, a job-graph node queued by `0x87F90`, frame `0x455A10`).
+- **What the renderer copies when.** The per-slot first-person state (models' poses, per-view visibility) is taken with the commit, not while the list is built or drawn: with a temporary 0.3 ms stall injected before the sync's first-person hand-off, player 1's gun was in all 1200 frames.
+- **Cameras.** The hand-over (`0x89B70`) hands views 0-1 over (`0xB29268` at `0x89D6A`/`0x89D81`), then queues the list build itself: `0x3BBA10` (`0x89DA7`) pushes the scene job `0x1BAA780` onto the worker pool (`0x1C33FA8`) and sets its event. The build (the prepare without the commit fields, `list_camera` `0x2EA720`) copies each view's camera. Views 2-3 handed over after the hand-over returned were too late: a temporary detector counted 2351 of 4200 copies of their cameras made before their hand-over (the frame before's camera; players 3-4's views jumped between two frames). Views 2-3 now go over from a hook on `0xB29268`, right after the game's view 1 and before the queue: 2 of 7200 early, both while player 3 was joining. (Making the build wait for the sync instead cost 0.33 ms of a worker per frame, and a build picked up after the next sync began would have overlapped that sync's resubmission of the same job, which the job system doesn't guard against.)
+- **First-person models.** The renderer's first-person models (`0x2B050E8`: entry*, count `+8`; entry 0x20 {int slot, int object (the weapon's or arms' render model tag), model index `+8`, model* `+0x10`, camo `+0x18`, bytes `+0x1C`/`+0x1E` hidden in view 0/1 wanted, `+0x1D`/`+0x1F` applied}) are keyed by (slot, object). `0x7AC60(object, slot)` makes the entry on first use (`0x76170`), copies the pose from the node block of the view whose weapon (`0x1B7AA88` -> nodes `0x1C384A0`) or arms (`0x1B7AA98` -> `0x1C350A0`) the object is (int[4] and 0xD00 x 4), sets the wanted flags (slot 0 in view 0, any other slot in view 1) and the camo from `0xAB16A4(slot)`; its `cmp r15d, 1; ja` (`0x7AE64`) gives slots past 1 no nodes (a memcpy from null). The sync sets every entry's wanted flags hidden, hands over views 0-1's weapon and arms, then applies the changes per view (the model's vtable `+0x328`/`+0x330`). The rest of a first-person gun is addressed by local player index 0-3: its display (`0xB3E4F8` per tick over the four local players -> `0xAB30C0` -> `0x917C0` calls the model's Flash `asSetAmmo`, the model found by `0x91680(object, index)`; its caches, like `0x1B7B788`, have four entries), its events (`0x91440(object, name)`: the local player whose `first_person_weapons` (`0x2D9CD90`, 0x1E94 each) `+8` is the object, then entries of that slot), its camo. So players 3-4's displays and events found no model, and players 1 and 3 shared slot 0's: player 3's assault rifle showed player 1's round count.
+- **Fix.** The second pair's syncs hand its models over as slots 2-3 (the `cmp` widened to 3 once the mode first runs, after its bytes are checked, and put back as the module unloads; the hook hands over only an object that is view 2/3's weapon or arms, and a missing view's object is -1), shown in views 0-1: slot 2's wanted flags are moved to view 0. The display, events and camo then find players 3-4's models by their own index. Box (kirklandsig fork): player 3's and player 1's rifles each count their own rounds through firing and reloading, no gun lost in 1200 frames with player 3 unspawned, a two-minute soak, leave/rejoin, Back to Classic and back.
+
+### Back (Classic <-> Anniversary) in the middle of a mission
+
+Both games switch graphics in place when a player presses Back, but their Anniversary renderers only draw two stacked views. With the choice on, the mode is set up for the whole 3-4 player mission, whichever graphics it starts in (`ClassicGraphicsScope`; Halo CE makes its extra cameras as split screen starts, `QuadReady`, without the on-screen test, so a Classic start works too), and runs while Anniversary is on screen: Halo 2's `0xE21280` nonzero and `0x1E8CE73` clear, Halo CE's `0x1B7AA84` (int, nonzero while Anniversary is on screen; `0x745B0` is `bool ()` "Classic", reading it - found by diffing halo1.dll's writable sections across Back presses: 5358 bytes flip with the renderer state, 6 are isolated 0/1 bytes, and this one is read at 42 sites). With the choice off, a 3-4 player mission switched to Anniversary shows what the renderers draw by themselves (Halo 2 black under the HUD, Halo CE two views). Halo CE / Halo 2 side by side is a Classic layout: `LeftRight::OnScreen` and each game's `ClassicShown` ask whether Classic is on screen, so Back to Anniversary shows the game's stacked views (2 players) or, with the choice on, the mode's views (3-4), and Back to Classic restores side by side. Box (kirklandsig fork, where the mode ran whatever the choice): CE and H2 at 2, 3, 4 players, side by side and stacked - Classic -> Anniversary -> Classic drew every view each time.
+
+## Halo 4 side by side: the first-person camera's aspect factor
+
+`0x34EC44` builds the first-person camera from the view's: its field of view is multiplied by `k` (the weapon's scale and zoom), times `S` = screen aspect (`0xE84608`/`0xE8460C`) over the view's (rect `+0x30..+0x36`): `mulss xmm5, xmm1` / `divss xmm5, xmm0` at `0x34ED92`/`0x34ED96`. The world camera (`0x374C84` -> `0x38F658` -> `0x38F3A4`) keeps a fixed vertical field of view. Stock split-screen views are wide (8:3, S = 0.667, keeping the gun's framing); a 960x1080 Left/Right half gives S = 2 - both arms and the whole gun in frame, drawn big. Halo 3 (`0x279BEC`) and Reach (`0x286C6C`) have no S.
+
+**Fix (`halo4/splitscreen.cpp`, `OFFSET_HALO4_VIEWMODEL_ASPECT_DIVIDE`):** while Left/Right is on screen the divide's register byte goes `E8 -> E9` (`divss xmm5, xmm1`: by the screen's aspect, S = 1), after its four bytes are checked, switched from the frame hook before the frame is drawn (`Splitscreen::Frame`, on the same thread as `0x34EC44`), and restored otherwise and as the module unloads. Box (kirklandsig fork): 3 players side by side, the live byte `E9` with the fix and `E8` without in the same scene, the left view's gun at world scale.
+
+## Halo 2 campaign: Save & Quit and players 3-4 at a mission start
+
+### Save & Quit from a modded campaign with 2+ players
+
+**Symptom** (SR388): Save & Quit sits on the level's loading screen forever with the "Halo 2 3/4 Player Coop Fixes" mod and 2+ players. The built-in campaign with 2 players and the mod with 1 player quit fine. Box states: a good quit reports Exiting (10) then 5 to MCC; the hung one reports Loading (0).
+
+**Known:**
+- MCC's main thread polls an object's outstanding count (`+0xC8`, set by 0xBA2934, cleared by 0xBA0D20 when the session state machine sees state 5) and waits; Halo 2's main loop keeps running frames (its thread sleeps in the frame limiter 0x6BFAB8), so nothing is deadlocked - the game just never exits.
+- At the quit, Halo 2's main-loop quit handling (0x679CD0) asks `0x6A6320` - session object `[0xE80A78]`: `+8 == 1 && byte +0x2C8 != 0`, i.e. "this game came from a Halo 2 lobby" - at `0x679EE0`. True: `0x37040` -> `0x370E0(4)` requests a map change to Halo 2's main-menu map (options type 3), which never loads under MCC; false: `0x36F70` quits to the host.
+- Traced with temporary hooks: `0x370E0(4)` fires from 0x679EEE right at the quit (pending map change 0 -> 1, flow state `[0x1A7CA44]` 2); `main_game_change` (0x34E40, quit = null options) isn't called.
+- `0x6A6320` has 42 other callers, so it's left alone; only the quit decision is patched.
+
+**Fix:** embedded patch "Save & Quit to MCC" (`OFFSET_HALO2_PF_QUIT_TO_LOBBY_TEST`, `call 0x6A6320` -> `xor eax, eax`, on by default): MCC is always the lobby. Box-verified in the kirklandsig fork: modded campaign, 2 and 4 players, Save & Quit -> Exiting, 5, back to MCC's menu.
+
+### Starting places and the co-op respawn
+
+**Known:**
+- Players globals (`PV_RESPAWN` 0xE80A20) hold the int16 local count at `+8` and handle[4] at `+0xC`, both kept by `0x69E4A0`, which maps a player to a local index (count ++/--, player `+0x28` = its index). A mission's first ticks map the players one by one (1 of 4 at the first `players_update`).
+- `players_update` (0x6A3910), in a campaign (the session object `[0xE80A78]`: mode `+8` == 1, as `0x6A6310` tests it; not MCC's game options - `copy_game_options` 0x39CE0 memcpys those, 0x2BF30 bytes, to 0x1A840A0, and their `+8` isn't the mode): a player without a unit and with flag 8 at `+6` spawns through `player_spawn` (0x69E580, returns bool) at the best-scored scenario starting location (scenario `+0x100` count, `+0x104` block, 0x34 each; scored by 0x7471D0, 0x747320 checks it); the others wait for the co-op respawn 0x6A1320, which picks a teammate out of combat ("Waiting to respawn (teammate in combat)"), calls `player_spawn` and moves the new unit beside that teammate.
+- The built-in missions have two starting places, so players 3 and 4 waited until players 1 and 2 walked off theirs. Delta Halo's are about 1.5 km from the drop pod its intro leaves players 1-2 in: stock, player 3 spawned on player 1's starting place during the intro and was left there, about 490 units from players 1-2.
+- Before a waiting player's co-op respawn, `players_update` asks `0x6A6320` (a co-op campaign: session mode `+8` == 1 and byte `+0x2C8`) and `0x6A5D40` (not with the Iron skull, `0x6EEF70(11)`, not on Legendary, session `+0x2C6` == 3). Where they say no, a player without a unit and without flag 8 never spawns, and `0x6A16F0` counts them as dead (players globals `+5`, read by `0x6A0BD0`; `+4` all dead, by `0x6A0BC0`); in a co-op campaign on Legendary or Iron any dead player starts the revert (`0x6A7493`: session `+0x1809` timer).
+- Also in `player_spawn`: `player +0x34` holds a unit to take over (`player_set_unit` 0x69E2A0), 0x68CC40 fills the placement's change colours (player `+0x7C`, `+0xB8`), and `[players globals] +0xD8` is a spare unit placed at the location.
+
+**Fix (`halo2/players.cpp`):** a hook on `players_update` clears flag 8 of a local player past the mission's starting locations (index at or past their count) who has no unit yet, so they come in through the co-op respawn beside a teammate, as after a death - only where both tests above say yes. Box: a fresh four-player Delta Halo start put players 3-4 1.8-2.4 units from player 1 at once; with three players, player 3 came in 2.4 units from player 1 at the drop pod once the intro was skipped. A co-op respawn gives what the game gives after a death (no grenades and 120 rounds, against 4 and 180 at a starting place). Without the Legendary/Iron test (the kirklandsig fork up to v2.0.1) the mission reverted to the checkpoint over and over there (box, Legendary 3P: player 3 never spawned, a revert every 30-45 s); with it, player 3 came in at once and nothing reverted.
+
+## Hot join: local players in the middle of a mission
+
+**MCC.** MCC counts local users through `CGameManager::get_xbox_user_id(index)` (true for index < count). When the count rises in the middle of a mission, Halo 3, ODST, Reach and Halo 4 sign the new user in and make the player, who spawns beside a teammate (Halo 4's deferred 3-4 player start relies on the same). When it falls, MCC ends the mission ("Leaving...", state 10 Exiting then 5), so only Halo CE lets players leave. Joins are taken only while the map runs (`CGameManager::running()`: from `set_state` Running until a map loads or the session exits). Resuming a checkpoint saved with more players than are signed in: Halo 3 exits about 1.3 s after Running (also with AlphaRing's split screen off); Reach stays black until the missing players join.
+
+Halo CE and Halo 2 make their local players as a map loads, so a hot-join mission starts with four (`Splitscreen::HotJoinSlots`: `get_xbox_user_id` answers for all four slots) and each game's module holds the game's local player count at the players who joined.
+
+**Joining (`splitscreen/Join.cpp`).** The Players window and hot join change the shared menu state (`MenuSettings::State()`, under `MenuSettings::Mutex()`), which the "Xbox 360" Menu and the Advanced Menu both show: a join puts the new player's controller in place, then the count, published last with a release store (`WriteRelease` on the split-screen settings' plain `int`, `PublishPlayerCount`); the game thread reads the count with acquire loads (`Splitscreen::PlayerCount`: the Halo CE and Halo 2 modules, `active_player_count`), so a reader that sees a new player sees their controller. The pad a player joins with gives the game nothing until its buttons and triggers are let go (`JoinPressHeld`, in `get_key_state`). On a running map the window's state takes each player's controller, and player 1's keyboard and mouse, live from the profiles and split-screen settings, which the Splitscreen window's Input, Bind and "Enable K/M for player1" edit: a rebound controller isn't free, and a join or a leave keeps it. A game start's `MenuSettings::ApplyAll(true)` puts the joined players in place from that state, `ApplySplitscreen(true)` keeping split screen on while hot join is chosen, and the next time a menu saves (`MenuSettings::Save`) it's written to `alpha_ring_menu.bin` with the rest.
+
+**Bind and the pads.** The Splitscreen window's Bind has the controllers while its player's page was drawn waiting this frame or the last, with the overlay shown (`BindPending`): hot join and the Players window act on no press then, and read again from what's held afterwards; a Bind whose player is gone is dropped. Bind skips a controller still holding a press they acted on (a join, a leave, a species: `PressTaken`). That mark and the join press's are let go in `HotJoinPoll` each frame once the controller holds nothing (`LetGoTaken`), since the game's input poll doesn't read the pads while the overlay is shown (with "Disable Input", the default).
+
+**A hot-join Halo CE or Halo 2 game** (`HotJoinHeld`: hot join chosen and the module there, until the session exits) has MCC holding all four local players from the mission's start, and MCC ends it if they go away. So the count changes there only by joining and leaving: the Splitscreen window's -/+ is held, and the "Xbox 360" Menu's player-count Increment/Decrement plays its denied sound and does nothing (`StateMachine::handleOption`).
+
+### Halo CE (`halo1/hotjoin.cpp`)
+
+**Known:**
+- Players globals `+0xB4` is the local count, which views, HUD, input and cameras follow live; handle[4] at `+0xB8`, unit[4] at `+0xC8`. The module holds it and `PV_PLAYER_COUNT` at the joined count each `players_update` tick. An unjoined player's `player_spawn` (0xAD4184) is skipped, and a leaver's unit is detached (`player_set_unit(player, -1)`, 0xAD2404) before it's deleted (0xC579D4 skips players' units).
+- A player's first spawn (`players_update` 0xAD0720's initial-spawn dispatch, 0xAD0B63 -> `player_spawn` 0xAD4184) is at a scenario starting location: `player_spawn` asks 0xAD39AC (`int16 (player)`: the best-scoring location, -1 if none scores above 0; scenario `+0x354` count, `+0x358` block, 0x34 each, scored by 0xAA7078 times a small random factor) and then 0xAD3940 (`entry* (int16 index)`: point, then facing at `+0xC`) for the entry it spawns at. The built-in missions have two (a30: both in the lifeboat). The co-op respawn (`players_update`, 0xAD0546) spawns a waiting player the same way and then moves their unit beside a teammate (0xAD058F -> 0xAD2FBC, `bool (player, other, -)`, true when it did).
+- Players and their globals are game state (allocated through 0xACD75C), so going back to a checkpoint saved before someone joined brings back their record without a unit, and the initial-spawn dispatch puts them at the mission's start (the chooser called at 0xAD436C).
+
+**Joining beside a teammate.** Each joined player's trail is kept: every 15 ticks (half a second), a spot on foot (within 2 units across and 0.25 up or down of the last sample) at least a stride (0.8) from the last spot kept, the newest 8 kept - so standing still doesn't flush them. During the `player_spawn` of a joiner whose placement is armed, 0xAD39AC returns 0 and 0xAD3940 a copy of entry 0 holding the newest trail spot within 10 units of its teammate now and at least 0.6 from every player, facing that teammate, so the body is made there directly. With no such spot yet (nobody has walked near), the joiner comes in at a starting place and is moved onto one as soon as there is one, for up to 300 ticks, with `object_set_position` (0xB359E8: object, point*, forward*, up*; null keeps it) and 0xBA83EC (what `object_teleport` resets after its move: HS evaluate 0xB196D0 -> 0xC57B9C). A player held back at any point in the mission is remembered until the next one starts (`s_held_back`), and whenever they have no unit their placement is armed again, so a checkpoint revert brings them back beside a teammate too; players who were in from the start are left alone. The placement is cleared when the spawn took the offered spot (`t_spot_taken`, set by the 0xAD3940 hook) or when the co-op respawn's move moved them (0xAD2FBC hooked, `OFFSET_HALO1_PF_PLAYER_MOVE_BESIDE`), so a player the game already put beside a teammate isn't moved again. Box (kirklandsig fork): players 2 and 3 appeared 1-2 steps behind player 1 on Halo's opening path.
+
+**The Anniversary picture.** The renderer's split flag (`0x2E3B821`) is set only while the map loads (`0x66DF0`: `setg` on the local count > 1 at `0x6762A`) and applied by `set_split` (`0x4150F0`: adds or drops camera 1 and lays the views out; the only other writer, `0x67AB0`, clears it with a count of 2 around load/unload). A hot-join mission loads with four slots, so it stayed split for one player; the module's per-tick update sets the flag from the held count and applies it through `set_split` (`FollowSplit`).
+
+### Halo 2 (`halo2/hotjoin.cpp`)
+
+The module holds the int16 local count at players globals `+8` at the joined count. The game counts players as it maps them (in no set order over a fresh mission's first ticks) and unmaps them, so the hold follows the mapped handles (`+0xC`), not the first count: until every player who joined is mapped, the game keeps its own count. The players let in are taken once a tick, as `players_update` starts (`s_admitted`), and that one count is used by the flag-8 pass, the `player_spawn` hook (a player not let in doesn't spawn) and `Account`: a player who joins in the middle of a tick is let in on the next, after their record is sent to the co-op respawn - spawning first, they would take the mission's starting place (0x6A3B93). A player held back at any point in the mission is remembered until the next one starts and takes the co-op respawn whenever they have no unit (flag 8 cleared, as for players 3-4 above; on Legendary or with Iron, a starting place): players and their globals are game state (allocated through 0x15A0AF0's allocator), so a checkpoint saved before they joined brings back their record waiting for a starting place, which `players_update`'s dispatch (0x6A3B93 -> `player_spawn` 0x69E580) would honour at the mission's start. Box (kirklandsig fork): joiners 0.8-1.9 units from player 1.
+
+**The players held back keep waiting for a starting place**, as players do before their first spawn: one without a unit who isn't waiting for one is a dead teammate to Halo 2 (`0x6A16F0` sets players globals `+5`), and `game_safe_to_save` (`0x7005C0`, at `0x70067E`) refuses every checkpoint while there is one. Waiting so, they count as alive in Halo 2's "every player is dead" (`+4`), which sends a mission whose players have all died back to its checkpoint, so after each `players_update` tick both bytes are worked out over the players who joined (`Account`). Outside a hot-join mission the hook does exactly what it did.
+
## Other durable findings
### `CPatch` backup-capture idempotency (generic, not Reach-specific)
@@ -374,15 +517,15 @@ Multipliers: high `3.0` (light-count group `10.0`), mid `1.0`, low `0.5` (water
### Offsets across MCC updates (pattern mode)
-**Known — mechanism.** Every module address lives in `lib/game/inc//offset_*.h` as `DefOffset(OFFSET_X, 0x…)`: an `AlphaRing::Offset` object that reads as its number (`module + OFFSET_X`). Plain `#define`s there are not addresses (entry values, counts). When a game module loads, `CModule::load_module` calls `Offsets::Prepare`: a module whose PE timestamp and image size match the build the headers were written for keeps the written values, with no scan. Any other build is scanned once (one pass over its code sections) for the byte patterns in `patterns_.inc`, and each offset is either replaced by what was found or marked not found (value 0, `found()` false); every result goes to the log (`[Offsets]`). MCC's executable is the same, through `Hook::Initialize` (the Windows Store 1.3498 build keeps its own `OFFSET_MCC_WS_*` offsets); in an unknown executable AlphaRing stays off if any of its offsets isn't found, apart from two that nothing uses yet (`Hook.cpp` `Optional`).
+**Known — mechanism.** Every module address lives in `lib/game/inc//offset_*.h` as `DefOffset(OFFSET_X, 0x…)`: an `AlphaRing::Offset` object that reads as its number (`module + OFFSET_X`). Plain `#define`s there are not addresses (entry values, counts). When a game module loads, `CModule::load_module` calls `Offsets::Prepare`: a module whose PE timestamp and image size match the build the headers were written for keeps the written values, with no scan. Any other build is scanned once (one pass over its code sections) for the byte patterns in `patterns_.inc`, and each offset is either replaced by what was found or marked not found (value 0, `found()` false); every result goes to the log (`[Offsets]`). MCC's executable is the same, through `Hook::Initialize` (the Windows Store 1.3498 build keeps its own `OFFSET_MCC_WS_*` offsets); in an unknown executable AlphaRing stays off if any of its offsets isn't found, apart from two that nothing uses yet (`Hook.cpp` `Optional`; not the XUID lookup - without its hook a split-screen player changing team freezes the game).
-What uses an offset that isn't found stays off: a hook isn't installed, and hooks whose detours reach other offsets are grouped per file (or namespace) with `EntryFeature(name, offsets their detours use)` (the hooks' own targets join automatically) - none of a group is hooked if one is missing; embedded patches aren't captured or written, and neither is one whose `needs` (`CPatch`) finds what it relies on missing - Reach's black-bar patches need its painter and CUI-variant hooks, Halo 2's four splitscreen patches go on only all together; `patch.xml` patches (fixed offsets) are off in any unknown build; `INVOKE`/`DefPtr` do nothing for a missing one; other paths check `Found({...})` / `.found()`. Reach's Left/Right layout goes on screen only where every hook that draws it is in (`SplitscreenConfigStore::LeftRightAvailable`); elsewhere a saved Left/Right is kept but the stock split is used. `tools/offsets/check_gates.py` fails when a file uses an offset outside such a gate. Hooks and patches keep a reference to their `Offset`, never a copy of its value: they are made during static initialization, before any lookup.
+What uses an offset that isn't found stays off: a hook isn't installed, and hooks whose detours reach other offsets are grouped per file (or namespace) with `EntryFeature(name, offsets their detours use)` (the hooks' own targets join automatically) - none of a group is hooked if one is missing, and a group that only works with another goes off with it (`Feature::Requires`: Halo 4's Left/Right needs its HUD fit, Halo CE's Anniversary 3-4 its split-screen hooks, Halo 2's hot join its co-op respawn hook); spawning and the per-player HUD carry a `Feature` per game; embedded patches aren't captured or written, and neither is one whose `needs` (`CPatch`) finds what it relies on missing - Reach's black-bar patches need its painter and CUI-variant hooks, Halo 2's four splitscreen patches go on only all together; `patch.xml` patches (fixed offsets) are off in any unknown build; `INVOKE`/`DefPtr` do nothing for a missing one; other paths check `Found({...})` / `.found()`. Reach's Left/Right layout goes on screen only where every hook that draws it is in (`SplitscreenConfigStore::LeftRightAvailable`); elsewhere a saved Left/Right is kept but the stock split is used. `tools/offsets/check_gates.py` fails when a file uses an offset outside such a gate. Hooks and patches keep a reference to their `Offset`, never a copy of its value: they are made during static initialization, before any lookup.
-A pattern is a run of whole instructions with RIP displacements, call/jump targets, image-relative displacements and relocated bytes left out, unique in the module's code, at least 16 fixed bytes, kept inside one function. A function is found by its first instructions and by a call to it; a global by the instructions that address it (two different functions where possible, or a field of it in writable data); patched mid-function sites by patterns that also cover the code their patch assumes (`gen_patterns.py` `COVER`), and a return address by one that takes its call. Up to two per offset: a unique match that disagrees with the other, or lands in the wrong kind of section, makes the offset not found rather than guessed.
+A pattern is a run of whole instructions with RIP displacements, call/jump targets, image-relative displacements and relocated bytes left out, unique in the module's code, at least 16 fixed bytes, kept inside one function. A function is found by its first instructions and by a call to it; a global by the instructions that address it (two different functions where possible, or a field of it in writable data); patched and hooked mid-function sites by patterns that also cover the code their patch or detour assumes (`gen_patterns.py` `COVER` after the site, `COVER_BEFORE` before it), and a return address by one that takes its call. Up to two per offset: a unique match that disagrees with the other, or lands in the wrong kind of section, makes the offset not found rather than guessed.
-**Changing an offset:** edit the header, run `python tools/offsets/gen_patterns.py` against the installed build (it must be the headers' version; needs `capstone`, `pefile`, `numpy`), rebuild, run `build/Release/offset_test.exe` (every pattern of every offset must resolve exactly) and `python tools/offsets/check_gates.py`. A new patched site needs a `COVER` entry. `python tools/offsets/perturb.py` fakes an update (code grown and shifted between functions with every relative reference fixed up, data moved, patterns broken or duplicated; `--churn F` also scrambles bytes in a fraction of all functions) and checks every offset is found where it moved or reported missing, never wrong. In game, `DebugFlags::g_forceOffsetLookup` runs pattern mode on the known build (every offset looked up and logged "at X (was X)").
+**Changing an offset:** edit the header, run `python tools/offsets/gen_patterns.py` against the installed build (it must be the headers' version; needs `capstone`, `pefile`, `numpy`), rebuild, run `build/Release/offset_test.exe` (every pattern of every offset must resolve exactly) and `python tools/offsets/check_gates.py`. A new patched site needs a `COVER` entry, and a mid-function hook whose detour rewrites what the code before it set up a `COVER_BEFORE` one. `python tools/offsets/perturb.py` fakes an update (code grown and shifted between functions with every relative reference fixed up, data moved, patterns broken or duplicated; `--churn F` also scrambles bytes in a fraction of all functions) and checks every offset is found where it moved or reported missing, never wrong. In game, `DebugFlags::g_forceOffsetLookup` runs pattern mode on the known build (every offset looked up and logged "at X (was X)").
-**Not covered by patterns:** the Windows Store executable's offsets (no binary to generate from). Struct field offsets, vtable slot indices and `module_info_t` are layout assumptions a pattern can't check; an update that changes them needs new code regardless.
+**Not covered by patterns:** the Windows Store executable's offsets (no binary to generate from). Struct field offsets, vtable slot indices (`CGameManager::FunctionTable`) and `module_info_t` are layout assumptions a pattern can't check; an update that changes them needs new code regardless.
### Selected active offsets
diff --git a/lib/game/inc/1.3528.0.0/offset_halo1.h b/lib/game/inc/1.3528.0.0/offset_halo1.h
index bf799f1e..0150ad5b 100644
--- a/lib/game/inc/1.3528.0.0/offset_halo1.h
+++ b/lib/game/inc/1.3528.0.0/offset_halo1.h
@@ -24,6 +24,17 @@ DefOffset(OFFSET_HALO1_PF_OBJECT_TRY_AND_GET, 0xB389A4) // void* (int object, un
DefOffset(OFFSET_HALO1_PF_ACTOR_CUSTOMIZE_UNIT, 0xC01DD0) // (int actor_variant, int unit) - weapon, grenades, colors
DefOffset(OFFSET_HALO1_PF_AI_ATTACH_FREE, 0xBFF120) // (int unit, int actor_variant) - creates an encounterless actor
+// hot join (module/entry/halo1/hotjoin.cpp)
+DefOffset(OFFSET_HALO1_PF_PLAYERS_UPDATE, 0xAD0720) // void (state*) - each tick: the players' respawns (calls the below)
+DefOffset(OFFSET_HALO1_PF_PLAYER_SPAWN, 0xAD4184) // void (int player) - a start location or the co-op respawn; callers check the unit
+DefOffset(OFFSET_HALO1_PF_CHOOSE_START_LOCATION, 0xAD39AC) // int16 (int player) - the best free starting location, -1: none
+DefOffset(OFFSET_HALO1_PF_START_LOCATION, 0xAD3940) // entry* (int16 index) - a starting location, 0x34: point, facing +0xC
+DefOffset(OFFSET_HALO1_PF_OBJECT_DELETE, 0xC579D4) // void (int object) - object_destroy's; skips a player's unit
+DefOffset(OFFSET_HALO1_PF_PLAYER_SET_UNIT, 0xAD2404) // void (int player, int unit) - -1 takes the player out of theirs
+DefOffset(OFFSET_HALO1_PF_OBJECT_SET_POSITION, 0xB359E8) // void (int object, point3*, vector3* forward, vector3* up) - null keeps
+DefOffset(OFFSET_HALO1_PF_OBJECT_TELEPORTED, 0xBA83EC) // void (int object) - what object_teleport resets after the move
+DefOffset(OFFSET_HALO1_PF_PLAYER_MOVE_BESIDE, 0xAD2FBC) // bool (int player, int other, void*) - moves a just-spawned player's unit beside another player (the co-op respawn, players_update 0xAD058F); true when it did
+
// Left/Right split screen (mcc/splitscreen/LeftRight)
DefOffset(OFFSET_HALO1_PF_SPLIT_GRID, 0xAC4108) // void (int views, int* columns, int* rows) - the window grid, rows first
DefOffset(OFFSET_HALO1_PF_SPLIT_WINDOW, 0xAC4154) // void (int view, int views, short rect[4], short copy[4]) - a view's window
diff --git a/lib/game/inc/1.3528.0.0/offset_halo2.h b/lib/game/inc/1.3528.0.0/offset_halo2.h
index 21e66175..fd89af39 100644
--- a/lib/game/inc/1.3528.0.0/offset_halo2.h
+++ b/lib/game/inc/1.3528.0.0/offset_halo2.h
@@ -30,6 +30,7 @@ DefOffset(OFFSET_HALO2_PF_PLAYERS_UPDATE, 0x6A3910)
DefOffset(OFFSET_HALO2_PF_COOP_CAMPAIGN, 0x6A6320) // bool () - a co-op campaign: session [0xE80A78] mode +8 == 1, byte +0x2C8
DefOffset(OFFSET_HALO2_PF_COOP_RESPAWN_ALLOWED, 0x6A5D40) // bool () - not with the Iron skull (11), not on Legendary
DefOffset(OFFSET_HALO2_PV_SCENARIO, 0xE6F768) // the loaded scenario*: int starting locations +0x100
+DefOffset(OFFSET_HALO2_PF_PLAYER_SPAWN, 0x69E580) // bool (int player) - a new unit at the best starting location (hot join)
// spawning (mcc/spawn)
DefOffset(OFFSET_HALO2_PV_TAG_INSTANCES, 0x15E4B30) // {u32 group, u32 datum, u32 address, u32 size}[tag count]
diff --git a/lib/game/inc/1.3528.0.0/patterns_halo1.inc b/lib/game/inc/1.3528.0.0/patterns_halo1.inc
index bed06e32..808f0578 100644
--- a/lib/game/inc/1.3528.0.0/patterns_halo1.inc
+++ b/lib/game/inc/1.3528.0.0/patterns_halo1.inc
@@ -48,6 +48,33 @@ const OffsetPatterns kHalo1Patterns[] = {
Rel("E8 ?? ?? ?? ?? 8B 06 B9 02 00 00 00 44 88 7C 24 58 45 8B CE", 0x1, 0x5, 0x0)}},
{&OFFSET_HALO1_PF_AI_ATTACH_FREE, 0xbff120, Code, {
At("48 83 EC 68 48 8B 05 ?? ?? ?? ?? 41 BB 02 00 00 00 44 8B C2", 0x0)}},
+ {&OFFSET_HALO1_PF_PLAYERS_UPDATE, 0xad0720, Code, {
+ At("48 8B C4 48 89 58 10 48 89 70 18 48 89 78 20 55 41 54 41 55 41 56 41 57 48 8D A8 D8 FB FF FF", 0x0),
+ Rel("48 8D 4C 24 30 E8 ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 38 58 03 74 ?? F3 0F 10 05", 0x6, 0xa, 0x0)}},
+ {&OFFSET_HALO1_PF_PLAYER_SPAWN, 0xad4184, Code, {
+ At("48 8B C4 48 89 58 10 48 89 70 18 48 89 78 20 55 41 54 41 55 41 56 41 57 48 8D 68 A1 48 81 EC 00 01 00 00 0F 29 70 C8 48 8B 05", 0x0),
+ Rel("E8 ?? ?? ?? ?? 39 6F 64 74 ?? 8B 4C 24 2C 41 0F B7 D6 4C 8D 04 52", 0x1, 0x5, 0x0)}},
+ {&OFFSET_HALO1_PF_CHOOSE_START_LOCATION, 0xad39ac, Code, {
+ At("48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 57 48 83 EC 50 0F 29 70 E8 83 CF FF", 0x0),
+ Rel("E8 ?? ?? ?? ?? 45 33 DB 66 41 3B C5 0F 84 ?? ?? ?? ?? 48 8B 35 ?? ?? ?? ?? 41 8B CB", 0x1, 0x5, 0x0)}},
+ {&OFFSET_HALO1_PF_START_LOCATION, 0xad3940, Code, {
+ At("4C 8B 05 ?? ?? ?? ?? 33 D2 66 85 C9 78 ?? 0F BF C1 41 3B 80 54 03 00 00", 0x0),
+ Rel("E8 ?? ?? ?? ?? 48 8B F8 66 39 68 10 0F 87 ?? ?? ?? ?? 4C 8D 40 14 8B CD", 0x1, 0x5, 0x0)}},
+ {&OFFSET_HALO1_PF_OBJECT_DELETE, 0xc579d4, Code, {
+ At("83 F9 FF 74 1C 53 48 83 EC 20 8B D9 E8 ?? ?? ?? ?? 84 C0 75", 0x0),
+ Rel("48 0F BF C9 8B 0C 88 EB ?? 8B CA 3B CA 74 ?? E8 ?? ?? ?? ?? 48 83 C4 28", 0x10, 0x14, 0x0)}},
+ {&OFFSET_HALO1_PF_PLAYER_SET_UNIT, 0xad2404, Code, {
+ At("48 89 6C 24 08 48 89 74 24 10 48 89 7C 24 18 41 54", 0x0),
+ Rel("E8 ?? ?? ?? ?? 8B 4D C8 89 4B 4C 8A 4D C8 88 8B CE 00 00 00", 0x1, 0x5, 0x0)}},
+ {&OFFSET_HALO1_PF_OBJECT_SET_POSITION, 0xb359e8, Code, {
+ At("48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 55 41 56 41 57 48 83 EC 60 4C 8B 3D", 0x0),
+ Rel("E8 ?? ?? ?? ?? B8 D4 01 00 00 49 8D 9F 08 02 00 00 48 03 DF", 0x1, 0x5, 0x0)}},
+ {&OFFSET_HALO1_PF_OBJECT_TELEPORTED, 0xba83ec, Code, {
+ At("83 F9 FF 74 1F 80 3D ?? ?? ?? ?? 00 74 ?? 48 8B 05 ?? ?? ?? ?? 0F B7 C9 48 69 D1 4C 0D 00 00", 0x0),
+ Rel("8B CB E8 ?? ?? ?? ?? 33 D2 8B CF E8 ?? ?? ?? ?? 48 8B 5C 24 30 48 83 C4 20", 0x3, 0x7, 0x0)}},
+ {&OFFSET_HALO1_PF_PLAYER_MOVE_BESIDE, 0xad2fbc, Code, {
+ At("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 48 8B 05 ?? ?? ?? ?? 8B EA", 0x0),
+ Rel("49 81 C0 90 00 00 00 4D 03 C1 44 3B CD 4C 0F 44 C0 E8 ?? ?? ?? ??", 0x12, 0x16, 0x0)}},
{&OFFSET_HALO1_PF_SPLIT_GRID, 0xac4108, Code, {
At("48 89 5C 24 08 BB 01 00 00 00 4D 8B D8 44 8B CB", 0x0),
Rel("E8 ?? ?? ?? ?? 44 8B 5C 24 58 41 8B C3 0F AF 44 24 50 3B C3", 0x1, 0x5, 0x0)}},
diff --git a/lib/game/inc/1.3528.0.0/patterns_halo2.inc b/lib/game/inc/1.3528.0.0/patterns_halo2.inc
index b8c873bc..4adcbdb3 100644
--- a/lib/game/inc/1.3528.0.0/patterns_halo2.inc
+++ b/lib/game/inc/1.3528.0.0/patterns_halo2.inc
@@ -47,6 +47,9 @@ const OffsetPatterns kHalo2Patterns[] = {
{&OFFSET_HALO2_PV_SCENARIO, 0xe6f768, Data, {
Rel("48 8B 05 ?? ?? ?? ?? 8B DE 48 89 7C 24 68 39 98 10 02 00 00", 0x3, 0x7, 0x0),
Rel("48 8B 05 ?? ?? ?? ?? 33 D2 4C 63 80 6C 01 00 00 41 83 F8 FF", 0x3, 0x7, 0x0)}},
+ {&OFFSET_HALO2_PF_PLAYER_SPAWN, 0x69e580, Code, {
+ At("40 55 53 56 57 41 54 41 56 41 57 48 8D AC 24 60 EF FF FF", 0x0),
+ Rel("E8 ?? ?? ?? ?? B0 01 EB ?? 32 C0 48 8B 5C 24 30 48 8B 74 24 38 48 8B 7C 24 40", 0x1, 0x5, 0x0)}},
{&OFFSET_HALO2_PV_TAG_INSTANCES, 0x15e4b30, Data, {
Rel("48 8B 05 ?? ?? ?? ?? 48 03 C9 4C 89 7C 24 50 4C 63 74 C8 08", 0x3, 0x7, 0x0),
Rel("66 90 0F B7 C8 48 8B 05 ?? ?? ?? ?? 48 03 C9 48 63 5C C8 08", 0x8, 0xc, 0x0)}},
diff --git a/src/mcc/CGameManager.cpp b/src/mcc/CGameManager.cpp
index 5a691106..6b707dcd 100644
--- a/src/mcc/CGameManager.cpp
+++ b/src/mcc/CGameManager.cpp
@@ -4,6 +4,7 @@
#include "mcc/mcc.h"
#include "mcc/settings/MenuSettings.h"
#include "log/MatchLog.h"
+#include "mcc/splitscreen/Splitscreen.h"
#include
#include
@@ -164,6 +165,7 @@ void CGameManager::apply_profiles() {
if (profile) {
memcpy(&profile->profile, base_profile, sizeof(CUserProfile));
memcpy(&profile->mapping, base_mapping, sizeof(CGamepadMapping));
+ MCC::Splitscreen::ApplySpecies(i, profile->profile);
}
}
}
diff --git a/src/mcc/CGameManager.h b/src/mcc/CGameManager.h
index c96fcff1..ab058997 100644
--- a/src/mcc/CGameManager.h
+++ b/src/mcc/CGameManager.h
@@ -41,8 +41,11 @@
static void apply_profiles();
// Increments every time a map starts loading.
static unsigned load_generation();
- // Local players in the game right now (see CGameManagerSplitscreen.cpp: Halo 4 starts with two).
+ // Local players in the game right now (see CGameManagerSplitscreen.cpp: Halo 4 starts with two; a hot-join
+ // Halo CE or Halo 2 mission is told of all four and holds back the others, Splitscreen::HotJoinSlots).
static int active_player_count();
+ // The current map runs: from its Running state until a map loads or the session exits.
+ static bool running();
private:
static void track_state(eState state);
diff --git a/src/mcc/CGameManagerSplitscreen.cpp b/src/mcc/CGameManagerSplitscreen.cpp
index 3322c453..e9f8349e 100644
--- a/src/mcc/CGameManagerSplitscreen.cpp
+++ b/src/mcc/CGameManagerSplitscreen.cpp
@@ -12,6 +12,7 @@ using AlphaRing::MatchLog::Describe;
using AlphaRing::MatchLog::FirstThisMatch;
#include "input/MenuConfig.h"
#include "mcc/spawn/Spawn.h"
+#include "mcc/splitscreen/Splitscreen.h"
#include
@@ -43,14 +44,19 @@ static constexpr ULONGLONG kDeferredJoinDelayMs = 3000;
static std::atomic s_running_since; // 0 until the current session first runs
static std::atomic s_load_generation;
+static std::atomic s_map_running; // from the Running state until a map loads or the session exits
unsigned CGameManager::load_generation() { return s_load_generation; }
+bool CGameManager::running() { return s_map_running; }
+
void CGameManager::track_state(eState state) {
if (state == Loading)
++s_load_generation;
if (state == Running && !s_running_since) // also re-sent after level transitions
s_running_since = GetTickCount64();
+ if (state == Running || state == Loading || state == Exit || state == Exiting)
+ s_map_running = state == Running;
}
// MCC ends every session with a restart after the exit states. The clock is cleared there,
@@ -58,6 +64,7 @@ void CGameManager::track_state(eState state) {
// it, and the next session queries its players before its own loading state.
void CGameManager::end_session() {
s_running_since = 0;
+ s_map_running = false;
}
static int deferred_player_count(int count) {
@@ -78,7 +85,7 @@ static int deferred_player_count(int count) {
int CGameManager::active_player_count() {
static std::atomic s_last_logged = -1;
- int active = deferred_player_count(AlphaRing::Global::MCC::Splitscreen()->player_count);
+ int active = deferred_player_count(MCC::Splitscreen::PlayerCount());
if (active != s_last_logged) {
s_last_logged = active;
@@ -100,7 +107,8 @@ static bool get_xbox_user_id_inner(CGameManager *self, __int64 *pId, wchar_t *pN
return CGameManager::ppOriginal.get_xbox_user_id(self, pId, pName, size, index);
}
- if (index >= CGameManager::active_player_count()) {
+ // MCC counts the local players it asks for here (all four slots in a Halo CE or Halo 2 hot-join mission)
+ if (index >= MCC::Splitscreen::HotJoinSlots(CGameManager::active_player_count())) {
*path = "beyond player_count";
return false;
}
@@ -212,9 +220,11 @@ bool CGameManager::get_key_state(CGameManager *self, DWORD index, input_data_t *
MATCH_LOG("input player={} first press buttons={:#06x} (input_user={})", index,
p_device->state.Gamepad.wButtons, p_device->input_user);
- // While the player's spawn menu is open it has the pad, which the game sees released; after it closes, what
- // was held then is taken out of the pad until released.
- if (MCC::Spawn::HandlePlayerInput(index, p_device->state.Gamepad))
+ // Until what a player who just joined pressed is let go (Players window, hot join), and while the player's
+ // spawn menu is open, which then has the pad, the game sees it released; after a menu closes, what was held
+ // then is taken out of the pad until released.
+ if (MCC::Splitscreen::JoinPressHeld(p_device->input_user, p_device->state.Gamepad) ||
+ MCC::Spawn::HandlePlayerInput(index, p_device->state.Gamepad))
memset(&p_device->state.Gamepad, 0, sizeof(p_device->state.Gamepad));
}
@@ -265,7 +275,7 @@ CUserProfile* CGameManager::get_player_profile(CGameManager *self, __int64 xid)
// Reach initializes armor into the player-0 profile after game_setup fires, so the
// snapshot taken by apply_profiles() is stale. Sync armor from the live player-0
// profile on every call while preserving the per-player custom colors and look
- // settings we applied.
+ // settings we applied, and a species chosen in the Players window.
auto* gg = GameGlobal();
if (gg && gg->current_game == CGameGlobal::HaloReach) {
auto* base = ppOriginal.get_player_profile(self, get_xuid(0));
@@ -293,6 +303,7 @@ CUserProfile* CGameManager::get_player_profile(CGameManager *self, __int64 xid)
dest->profile.HorizontalLookSensitivity = horizSens;
// and the armor picked for this player in the advanced menu
AlphaRing::MenuSettings::ApplyArmor(get_index(xid), dest->profile);
+ MCC::Splitscreen::ApplySpecies(index, dest->profile);
}
}
diff --git a/src/mcc/module/entry/halo1/graphics.cpp b/src/mcc/module/entry/halo1/graphics.cpp
index ae0eab3d..bce17bbc 100644
--- a/src/mcc/module/entry/halo1/graphics.cpp
+++ b/src/mcc/module/entry/halo1/graphics.cpp
@@ -6,6 +6,7 @@
namespace Halo1::Entry::Graphics {
Halo1Entry(entry, OFFSET_HALO1_PF_GAME_START, __int64, detour, void* self, void* manager, unsigned char* game_options, void* a4) {
MCC::Splitscreen::ClassicGraphicsScope classic(game_options, CGameGlobal::Halo1);
+ HotJoin::Start(MCC::Splitscreen::HotJoinOn());
return ((detour_t)entry.m_pOriginal)(self, manager, game_options, a4);
}
}
diff --git a/src/mcc/module/entry/halo1/halo1.h b/src/mcc/module/entry/halo1/halo1.h
index c87074f5..6bcf3723 100644
--- a/src/mcc/module/entry/halo1/halo1.h
+++ b/src/mcc/module/entry/halo1/halo1.h
@@ -22,4 +22,8 @@ namespace Halo1::Entry {
namespace Anniversary {
bool Quad(__int64 module); // 3-4 players drawn in quarters, Anniversary graphics (anniversary.cpp)
}
+
+ namespace HotJoin {
+ void Start(bool on); // as a mission starts (graphics.cpp): whether it's a hot-join one (hotjoin.cpp)
+ }
}
diff --git a/src/mcc/module/entry/halo1/hotjoin.cpp b/src/mcc/module/entry/halo1/hotjoin.cpp
new file mode 100644
index 00000000..3b96f334
--- /dev/null
+++ b/src/mcc/module/entry/halo1/hotjoin.cpp
@@ -0,0 +1,260 @@
+// Halo CE hot join (mcc/splitscreen/Join.cpp): Halo CE only makes its local players as a mission loads, so a hot-join
+// mission starts with all four (MCC is told of four, CGameManagerSplitscreen.cpp) and the game's local player count -
+// which its views, HUD, input and cameras follow, live - is held at the player count; the others don't spawn and have
+// no body. Halo CE spawns players only at the mission's starting places, which a player joining later could be far
+// behind or find taken (the built-in missions have two, where the others may still stand), so a player who joins
+// comes in on a spot a teammate walked through lately - or, while there's none, at a starting place and is moved to
+// one as soon as there is.
+#include "halo1.h"
+
+#include "global/Global.h"
+#include "mcc/splitscreen/Splitscreen.h"
+
+#include
+#include
+#include
+#include
+
+namespace Halo1::Entry::HotJoin {
+ EntryFeature("Halo CE hot join", OFFSET_HALO1_PF_GAME_START, OFFSET_HALO1_PV_LOCAL_PLAYERS,
+ OFFSET_HALO1_PV_PLAYER_COUNT, OFFSET_HALO1_PF_OBJECT_DELETE, OFFSET_HALO1_PF_PLAYER_SET_UNIT,
+ OFFSET_HALO1_PF_OBJECT_GET_ORIGIN, OFFSET_HALO1_PF_OBJECT_SET_POSITION,
+ OFFSET_HALO1_PF_OBJECT_TELEPORTED, OFFSET_HALO1_PV_SABER_SPLIT, OFFSET_HALO1_PV_SABER_SPLIT_STATE,
+ OFFSET_HALO1_PF_SABER_SET_SPLIT);
+
+ constexpr int kSlots = 4;
+
+ std::atomic s_active = false; // the running mission is a hot-join one
+ int s_slots = 0; // local players it was started with (read on its first update)
+
+ // Where each player walked lately on foot: every half second (the game ticks 30 times a second), a spot a step
+ // from the one before at about the same height - not driving, jumping or falling - and a stride from the last one
+ // kept, so a player standing still keeps where they walked before. And for how many more ticks a player is to be
+ // brought beside a teammate once they have a body: set while they're out of the mission, so it's there when they
+ // join.
+ struct Point {
+ float x, y, z;
+ };
+ struct Spawn { // a starting place's first 0x10 bytes
+ Point at;
+ float facing;
+ };
+ constexpr int kTrail = 8, kTrailTicks = 15, kPlaceTicks = 300;
+ constexpr float kStep = 2.0f, kRise = 0.25f; // world units in half a second
+ constexpr float kStride = 0.8f; // between the spots kept
+ constexpr float kClear = 0.6f; // from every player now (a Spartan is about 0.2 across)
+ constexpr float kNear = 10.0f; // from the teammate now: spots left behind by a teleport, a
+ // checkpoint or a drive aren't used
+ Point s_trail[kSlots][kTrail]; // newest first
+ int s_trail_count[kSlots] = {};
+ Point s_sampled[kSlots]; // the last half-second sample, on foot or not
+ bool s_has_sample[kSlots] = {};
+ int s_place[kSlots] = {};
+ int s_tick = 0;
+ // Held back in this mission at some point, until the next one starts. Players and their globals are game state
+ // (allocated through 0xACD75C), so going back to a checkpoint from before such a player joined brings back their
+ // record without a unit, to spawn at a starting place (0xAD0B63 -> 0xAD4184 -> 0xAD39AC): whenever they have no
+ // unit they're to be brought beside a teammate again.
+ bool s_held_back[kSlots] = {};
+
+ // players globals: int16 local player count +0xB4, player handle[4] +0xB8, unit[4] +0xC8
+ char* Globals(__int64 module) { return *(char**)(module + OFFSET_HALO1_PV_LOCAL_PLAYERS); }
+ int Handle(char* globals, int local) { return *(int*)(globals + 0xB8 + 4 * local); }
+ int Unit(char* globals, int local) { return *(int*)(globals + 0xC8 + 4 * local); }
+
+ int Joined() { return std::clamp(MCC::Splitscreen::PlayerCount(), 1, kSlots); }
+
+ int LocalIndex(char* globals, int player) {
+ for (int j = 0; j < kSlots; ++j)
+ if (Handle(globals, j) == player) return j;
+ return -1;
+ }
+
+ Point Origin(__int64 module, int object) {
+ Point at{};
+ ((void (*)(int, Point*))(module + OFFSET_HALO1_PF_OBJECT_GET_ORIGIN))(object, &at);
+ return at;
+ }
+
+ float Distance2(Point a, Point b) {
+ float dx = a.x - b.x, dy = a.y - b.y, dz = a.z - b.z;
+ return dx * dx + dy * dy + dz * dz;
+ }
+
+ void Sample(__int64 module, int local, int unit) {
+ Point at = Origin(module, unit), before = s_sampled[local];
+ bool on_foot = s_has_sample[local] && std::abs(at.z - before.z) <= kRise &&
+ Distance2({at.x, at.y, 0}, {before.x, before.y, 0}) <= kStep * kStep;
+ s_sampled[local] = at;
+ s_has_sample[local] = true;
+ if (!on_foot || (s_trail_count[local] > 0 && Distance2(at, s_trail[local][0]) < kStride * kStride)) return;
+ std::copy_backward(s_trail[local], s_trail[local] + kTrail - 1, s_trail[local] + kTrail);
+ s_trail[local][0] = at;
+ s_trail_count[local] = (std::min)(s_trail_count[local] + 1, kTrail);
+ }
+
+ void Forget(int local) {
+ s_trail_count[local] = 0;
+ s_has_sample[local] = false;
+ }
+
+ // The newest spot a teammate walked through, near where they are now, that no player is on now, and which way to
+ // face there (toward that teammate); false while there's none (nobody has walked anywhere near yet).
+ bool Spot(__int64 module, char* globals, int joiner, int joined, Spawn* spawn) {
+ Point now[kSlots];
+ bool here[kSlots] = {};
+ for (int k = 0; k < joined; ++k)
+ if (k != joiner && Unit(globals, k) != -1) {
+ here[k] = true;
+ now[k] = Origin(module, Unit(globals, k));
+ }
+ for (int t = 0; t < joined; ++t) {
+ if (!here[t]) continue;
+ for (int n = 0; n < s_trail_count[t]; ++n) {
+ Point at = s_trail[t][n];
+ if (Distance2(at, now[t]) > kNear * kNear) continue;
+ bool clear = true;
+ for (int k = 0; k < joined && clear; ++k) clear = !here[k] || Distance2(at, now[k]) >= kClear * kClear;
+ if (!clear) continue;
+ *spawn = {at, std::atan2(now[t].y - at.y, now[t].x - at.x)};
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // A joiner who spawned at a starting place, moved to a teammate's spot.
+ bool Place(__int64 module, char* globals, int joiner, int joined) {
+ Spawn spawn;
+ if (!Spot(module, globals, joiner, joined, &spawn)) return false;
+ int unit = Unit(globals, joiner);
+ ((void (*)(int, Point*, void*, void*))(module + OFFSET_HALO1_PF_OBJECT_SET_POSITION))(unit, &spawn.at, nullptr,
+ nullptr);
+ ((void (*)(int))(module + OFFSET_HALO1_PF_OBJECT_TELEPORTED))(unit);
+ return true;
+ }
+
+ // Halo CE sets its Anniversary renderer's split screen only while the map loads, from the local player count
+ // (0x6762A) - four in a hot-join mission, which left one player split in two. It follows the players in the
+ // mission instead, applied as the game applies it: set_split adds or drops the second camera and lays the views
+ // out (halo1/anniversary.cpp's detour of it makes and drops the cameras for players 3 and 4).
+ void FollowSplit(__int64 module, int joined) {
+ char* state = *(char**)(module + OFFSET_HALO1_PV_SABER_SPLIT_STATE);
+ if (state == nullptr) return;
+ bool split = joined > 1;
+ *(bool*)(module + OFFSET_HALO1_PV_SABER_SPLIT) = split;
+ if ((state[0x41] != 0) != split) ((void (*)(char*))(module + OFFSET_HALO1_PF_SABER_SET_SPLIT))(state);
+ }
+
+ // Each tick: the bodies of the players who aren't in the mission, the game's local player count, and bringing the
+ // players who joined to the others.
+ void Update(__int64 module) {
+ char* globals = Globals(module);
+ if (globals == nullptr) return;
+ if (s_slots == 0) s_slots = std::clamp((int)*(short*)(globals + 0xB4), 1, kSlots);
+ int joined = (std::min)(Joined(), s_slots);
+ for (int j = joined; j < s_slots; ++j) {
+ s_held_back[j] = true;
+ s_place[j] = kPlaceTicks;
+ Forget(j);
+ int unit = Unit(globals, j);
+ if (unit == -1) continue;
+ // the game won't delete a player's unit: the player leaves it first
+ ((void (*)(int, int))(module + OFFSET_HALO1_PF_PLAYER_SET_UNIT))(Handle(globals, j), -1);
+ ((void (*)(int))(module + OFFSET_HALO1_PF_OBJECT_DELETE))(unit);
+ }
+ *(short*)(globals + 0xB4) = (short)joined;
+ *(short*)(module + OFFSET_HALO1_PV_PLAYER_COUNT) = (short)joined;
+ FollowSplit(module, joined);
+
+ bool sample = ++s_tick % kTrailTicks == 0;
+ for (int j = 0; j < joined; ++j) {
+ int unit = Unit(globals, j);
+ if (unit == -1) {
+ Forget(j); // the next body starts a new trail
+ if (s_held_back[j]) s_place[j] = kPlaceTicks;
+ } else if (s_place[j] > 0) {
+ if (Place(module, globals, j, joined) || --s_place[j] == 0) s_place[j] = 0;
+ } else if (sample) {
+ Sample(module, j, unit);
+ }
+ }
+ }
+
+ Halo1Entry(entry_update, OFFSET_HALO1_PF_PLAYERS_UPDATE, void, players_update, void* state) {
+ if (s_active) Update(entry_update.m_target - entry_update.m_offset);
+ ((players_update_t)entry_update.m_pOriginal)(state);
+ }
+
+ // A joiner's first body at a teammate's spot: while they spawn, the starting place the game picks is that spot
+ // (the game thread's).
+ thread_local const Spawn* t_spawn = nullptr;
+ thread_local bool t_spot_taken = false; // the spawn going on took that spot
+ char s_start[0x34];
+
+ Halo1Entry(entry_choose_start, OFFSET_HALO1_PF_CHOOSE_START_LOCATION, short, choose_start, int player) {
+ return t_spawn ? 0 : ((choose_start_t)entry_choose_start.m_pOriginal)(player);
+ }
+
+ Halo1Entry(entry_start, OFFSET_HALO1_PF_START_LOCATION, char*, start_location, short index) {
+ char* entry = ((start_location_t)entry_start.m_pOriginal)(index);
+ if (!t_spawn || entry == nullptr) return entry;
+ memcpy(s_start, entry, sizeof s_start);
+ memcpy(s_start, t_spawn, sizeof *t_spawn);
+ t_spot_taken = true;
+ return s_start;
+ }
+
+ // The co-op respawn (players_update, 0xAD0546) spawns a waiting player - at a starting place, through the two
+ // above - and then moves them beside a teammate, true when it could: moved, they're where Place would bring them.
+ Halo1Entry(entry_move_beside, OFFSET_HALO1_PF_PLAYER_MOVE_BESIDE, bool, move_beside, int player, int other,
+ void* where) {
+ bool moved = ((move_beside_t)entry_move_beside.m_pOriginal)(player, other, where);
+ if (moved && s_active) {
+ char* globals = Globals(entry_move_beside.m_target - entry_move_beside.m_offset);
+ int local = globals ? LocalIndex(globals, player) : -1;
+ if (local >= 0) s_place[local] = 0;
+ }
+ return moved;
+ }
+
+ // Players who aren't in the mission don't spawn, and one who joined comes in at a teammate's spot if there is one.
+ Halo1Entry(entry_spawn, OFFSET_HALO1_PF_PLAYER_SPAWN, void, player_spawn, int player) {
+ auto original = (player_spawn_t)entry_spawn.m_pOriginal;
+ if (!s_active) return original(player);
+ __int64 module = entry_spawn.m_target - entry_spawn.m_offset;
+ char* globals = Globals(module);
+ int local = globals ? LocalIndex(globals, player) : -1;
+ int joined = Joined();
+ if (local >= joined) return;
+ Spawn spawn;
+ bool at_spot = local >= 0 && s_place[local] > 0 && Spot(module, globals, local, joined, &spawn);
+ t_spawn = at_spot ? &spawn : nullptr;
+ t_spot_taken = false;
+ original(player);
+ t_spawn = nullptr;
+ if (t_spot_taken && Unit(globals, local) != -1) s_place[local] = 0; // where Place would have moved them
+ }
+
+ bool Available() { return entry_feature->Available(); }
+
+ void Reset() {
+ s_active = false;
+ s_slots = s_tick = 0;
+ for (int j = 0; j < kSlots; ++j) {
+ s_place[j] = 0;
+ s_held_back[j] = false;
+ Forget(j);
+ }
+ }
+ const bool s_reset = (Halo1EntrySet()->on_remove(&Reset), true);
+
+ // As a mission starts (halo1/graphics.cpp).
+ void Start(bool on) {
+ Reset();
+ s_active = on && Available();
+ if (s_active) LOG_INFO("Halo CE hot join: this mission holds back the players who haven't joined");
+ }
+
+ bool Active() { return s_active; }
+}
diff --git a/src/mcc/module/entry/halo2/graphics.cpp b/src/mcc/module/entry/halo2/graphics.cpp
index f668ab85..a8830ed4 100644
--- a/src/mcc/module/entry/halo2/graphics.cpp
+++ b/src/mcc/module/entry/halo2/graphics.cpp
@@ -6,6 +6,7 @@
namespace Halo2::Entry::Graphics {
Halo2Entry(entry, OFFSET_HALO2_PF_COPY_GAME_OPTIONS, __int64, detour, unsigned char* game_options, void* a2, void* a3, void* a4) {
MCC::Splitscreen::ClassicGraphicsScope classic(game_options, CGameGlobal::Halo2);
+ HotJoin::Start(MCC::Splitscreen::HotJoinOn());
return ((detour_t)entry.m_pOriginal)(game_options, a2, a3, a4);
}
}
diff --git a/src/mcc/module/entry/halo2/halo2.h b/src/mcc/module/entry/halo2/halo2.h
index d49d1d38..851af127 100644
--- a/src/mcc/module/entry/halo2/halo2.h
+++ b/src/mcc/module/entry/halo2/halo2.h
@@ -16,10 +16,24 @@ inline EntrySet* Halo2EntrySet() {return &g_pHalo2EntrySet;};
namespace Halo2::Entry {
namespace Players {
- int Handle(__int64 module, int local); // local player `local`'s player handle, -1: none (players.cpp)
+ const ::AlphaRing::Feature& Hooks(); // its hook and offsets, which hot join requires (players.cpp)
+ int Handle(__int64 module, int local); // local player `local`'s player handle, -1: none
char* Player(__int64 module, int handle); // that player's data, or null
}
+ namespace HotJoin {
+ void Start(bool on); // as a mission starts (graphics.cpp): whether it's a hot-join one (hotjoin.cpp)
+ // Each tick (players.cpp), before the game's: in a hot-join mission, the game's local player count held at the
+ // players who joined, and that number; 4 otherwise.
+ int Hold(__int64 module);
+ // Local player `local` was held back in this hot-join mission at some point (with the players who haven't
+ // joined; past the count, the caller tells them apart).
+ bool JoinedLate(int local);
+ // After the game's tick: in a hot-join mission, "every player is dead" and "a player is", over the ones who
+ // joined.
+ void Account(__int64 module);
+ }
+
namespace Splitscreen {
bool ClassicShown(__int64 module); // Classic graphics are on screen (Back switches them in a mission)
}
diff --git a/src/mcc/module/entry/halo2/hotjoin.cpp b/src/mcc/module/entry/halo2/hotjoin.cpp
new file mode 100644
index 00000000..9c275425
--- /dev/null
+++ b/src/mcc/module/entry/halo2/hotjoin.cpp
@@ -0,0 +1,132 @@
+// Halo 2 hot join (mcc/splitscreen/Join.cpp), as Halo CE's (halo1/hotjoin.cpp): Halo 2 only makes its local players as
+// a mission loads, so a hot-join mission starts with all four (MCC is told of four, CGameManagerSplitscreen.cpp) and
+// the game's local player count - which its views, HUD and input follow - is held at the player count; the others
+// don't spawn. A player who joins comes in beside a teammate through the co-op respawn (players.cpp), where the game
+// gives co-op respawns (not on Legendary or with the Iron skull: there, at a starting place).
+//
+// The players held back keep waiting for a starting place, as players do before their first spawn: a player without a
+// unit who isn't waiting for one counts as a dead teammate (0x6A16F0 sets players globals +5), which keeps every
+// checkpoint from being saved (game_safe_to_save, 0x7005C0, at 0x70067E). Waiting so, though, they count as alive in
+// the game's "every player is dead" (+4), so that's worked out over every player but them (Account).
+#include "halo2.h"
+
+#include "global/Global.h"
+#include "mcc/splitscreen/Splitscreen.h"
+
+#include
+#include
+#include
+
+namespace Halo2::Entry::HotJoin {
+ // players.cpp holds the count each tick, from its players_update hook
+ EntryFeature("Halo 2 hot join", OFFSET_HALO2_PF_COPY_GAME_OPTIONS, OFFSET_HALO2_PV_RESPAWN, OFFSET_HALO2_PV_PLAYERS);
+ const bool s_requires_players = (entry_feature->Requires(Players::Hooks()), true);
+
+ constexpr int kSlots = 4;
+
+ std::atomic s_active = false; // the running mission is a hot-join one
+ // Held back in it at some point, until the next mission starts (game thread). A checkpoint saved before such a
+ // player joined brings back, as it's restored, their record waiting for a starting place without a unit (players
+ // and their globals are game state, allocated through 0x15A0AF0's allocator): they're still sent to the co-op
+ // respawn, as whenever they have no unit (players.cpp).
+ bool s_held_back[kSlots] = {};
+ // The players it lets into the mission, taken once a tick, as players_update starts (Hold, game thread): one who
+ // joins in the middle of a tick waits for the next, so that their record is sent to the co-op respawn before they
+ // can spawn - spawning first, they would take the mission's starting place (0x6A3B93).
+ std::atomic s_admitted = kSlots;
+
+ // players globals: int16 local player count +8, player handle[4] +0xC (both kept by 0x69E4A0, which maps a player
+ // to a local index; Players::Handle reads the handles), bytes +4 every player dead and +5 one is (0x6A16F0)
+ char* Globals(__int64 module) { return *(char**)(module + OFFSET_HALO2_PV_RESPAWN); }
+
+ int Joined() { return std::clamp(MCC::Splitscreen::PlayerCount(), 1, kSlots); }
+
+ int LocalIndex(__int64 module, int player) {
+ for (int j = 0; j < kSlots; ++j)
+ if (Players::Handle(module, j) == player) return j;
+ return -1;
+ }
+
+ // A player's record: unit +0x2C, flags +6.
+ bool HasUnit(const char* record) { return *(const int*)(record + 0x2C) != -1; }
+
+ // The count the game's local players are held at: the ones who joined, once they're all mapped; until then 0, and
+ // the game keeps its own count. The game counts players as it maps them (in no set order over a fresh mission's
+ // first ticks) and unmaps them, so a count past the ones mapped would run on past four.
+ int Held(__int64 module, int joined) {
+ for (int j = 0; j < joined; ++j)
+ if (Players::Handle(module, j) == -1) return 0;
+ return joined;
+ }
+
+ int Hold(__int64 module) {
+ if (!s_active) return kSlots;
+ int joined = s_admitted = Joined();
+ for (int j = joined; j < kSlots; ++j) s_held_back[j] = true;
+ if (char* globals = Globals(module))
+ if (int held = Held(module, joined)) *(short*)(globals + 8) = (short)held;
+ return joined;
+ }
+
+ bool JoinedLate(int local) { return s_active && local >= 0 && local < kSlots && s_held_back[local]; }
+
+ // Over every player, as 0x6A16F0 walks them (network co-op teammates included), but the local ones held back. The
+ // players data array, as its iterator (0x67B050) reads it: int count +0x3C, in-use bits at +*(+0x50), elements of
+ // int size +0x24 at +*(+0x48).
+ void Account(__int64 module) {
+ char* globals = s_active ? Globals(module) : nullptr;
+ int joined = s_admitted;
+ if (globals == nullptr || !Held(module, joined)) return; // until they're all mapped, the game's own
+ char* players = *(char**)(module + OFFSET_HALO2_PV_PLAYERS);
+ if (players == nullptr) return;
+ __int64 bits_at = *(__int64*)(players + 0x50), data_at = *(__int64*)(players + 0x48);
+ if (bits_at == 0 || data_at == 0) return;
+ auto bits = (const unsigned*)(players + bits_at);
+ int count = *(int*)(players + 0x3C), size = *(int*)(players + 0x24);
+
+ int held_back[kSlots];
+ for (int j = 0; j < kSlots; ++j) {
+ int handle = j >= joined ? Players::Handle(module, j) : -1;
+ held_back[j] = handle != -1 ? handle & 0xFFFF : -1;
+ }
+
+ bool all_dead = true, dead = false;
+ for (int i = 0; i < count; ++i) {
+ if (!(bits[i >> 5] >> (i & 31) & 1) || std::find(held_back, held_back + kSlots, i) != held_back + kSlots)
+ continue;
+ const char* record = players + data_at + (__int64)i * size;
+ if (HasUnit(record) || (*(const unsigned short*)(record + 6) & 8)) all_dead = false; // or waiting to spawn
+ else dead = true;
+ }
+ globals[4] = all_dead;
+ globals[5] = dead;
+ }
+
+ // Players who aren't in the mission don't spawn (a starting place, or the co-op respawn beside a teammate).
+ Halo2Entry(entry_spawn, OFFSET_HALO2_PF_PLAYER_SPAWN, bool, player_spawn, int player) {
+ if (s_active) {
+ int local = LocalIndex(entry_spawn.m_target - entry_spawn.m_offset, player); // -1 without the globals
+ if (local >= s_admitted) return false;
+ }
+ return ((player_spawn_t)entry_spawn.m_pOriginal)(player);
+ }
+
+ bool Available() { return entry_feature->Available(); }
+
+ void Reset() {
+ s_active = false;
+ s_admitted = kSlots;
+ std::fill(std::begin(s_held_back), std::end(s_held_back), false);
+ }
+ const bool s_reset = (Halo2EntrySet()->on_remove(&Reset), true);
+
+ // As a mission starts (halo2/graphics.cpp).
+ void Start(bool on) {
+ Reset();
+ s_admitted = Joined();
+ s_active = on && Available();
+ if (s_active) LOG_INFO("Halo 2 hot join: this mission holds back the players who haven't joined");
+ }
+
+ bool Active() { return s_active; }
+}
diff --git a/src/mcc/module/entry/halo2/players.cpp b/src/mcc/module/entry/halo2/players.cpp
index e921257c..dbe9a0c4 100644
--- a/src/mcc/module/entry/halo2/players.cpp
+++ b/src/mcc/module/entry/halo2/players.cpp
@@ -5,10 +5,14 @@
// there. Local players past the mission's starting locations take the co-op respawn instead, which brings them in
// beside a teammate (once that teammate is out of combat, as for any co-op respawn) - only where the game gives co-op
// respawns. On Legendary or with the Iron skull it doesn't, and counts a co-op player waiting for one as dead, which
-// reverts to the checkpoint: there they keep waiting for a starting location, as before.
+// reverts to the checkpoint: there they keep waiting for a starting location, as before. In a hot-join mission
+// (hotjoin.cpp) the players who haven't joined keep waiting for a starting location (one waiting for the co-op respawn
+// counts as a dead teammate, and no checkpoint would be saved), and one who has joined takes the co-op respawn whenever
+// they have no unit - a checkpoint from before they joined included - so they come in beside a teammate.
namespace Halo2::Entry::Players {
EntryFeature("Halo 2 co-op respawn", OFFSET_HALO2_PV_RESPAWN, OFFSET_HALO2_PV_PLAYERS, OFFSET_HALO2_PV_SCENARIO,
OFFSET_HALO2_PF_COOP_CAMPAIGN, OFFSET_HALO2_PF_COOP_RESPAWN_ALLOWED);
+ const ::AlphaRing::Feature& Hooks() { return *entry_feature; }
// players globals: player handle per local player, int[4] at +0xC (-1: none)
int Handle(__int64 module, int local) {
@@ -36,13 +40,16 @@ namespace Halo2::Entry::Players {
Halo2Entry(entry, OFFSET_HALO2_PF_PLAYERS_UPDATE, void, detour, void* state) {
__int64 module = entry.m_target - entry.m_offset;
+ int joined = HotJoin::Hold(module); // every slot outside a hot-join mission
int places = CoopRespawn(module) ? StartingLocations(module) : 0;
- for (int local = places; places > 0 && local < 4; ++local) {
+ for (int local = 0; places > 0 && local < 4; ++local) {
+ if (local >= joined || (local < places && !HotJoin::JoinedLate(local))) continue;
int handle = Handle(module, local);
char* player = handle != -1 ? Player(module, handle) : nullptr;
if (player && *(int*)(player + 0x2C) == -1) // still waiting for a unit
*(unsigned short*)(player + 6) &= ~8;
}
((detour_t)entry.m_pOriginal)(state);
+ HotJoin::Account(module);
}
}
diff --git a/src/mcc/settings/MenuSettings.cpp b/src/mcc/settings/MenuSettings.cpp
index bf6bacd3..c4a1e31c 100644
--- a/src/mcc/settings/MenuSettings.cpp
+++ b/src/mcc/settings/MenuSettings.cpp
@@ -6,6 +6,7 @@
#include "filesystem/Filesystem.h"
#include "mcc/CGameManager.h"
#include "mcc/CGameGlobal.h"
+#include "mcc/splitscreen/Splitscreen.h"
#include "render/imgui/game/xbox/CXboxColorMapping.h"
#include
@@ -589,8 +590,9 @@ namespace AlphaRing::MenuSettings {
auto p_setting = AlphaRing::Global::MCC::Splitscreen();
if (!p_setting) return;
auto& ms = State();
+ // hot join brings players in through AlphaRing's split screen, a lone player 1 as the first of several
if (atGameStart)
- p_setting->b_override = ms.playerCount > 1;
+ p_setting->b_override = ms.playerCount > 1 || MCC::Splitscreen::HotJoinChosen();
else if (ms.playerCount > 1)
p_setting->b_override = true;
p_setting->player_count = ms.playerCount;
diff --git a/src/mcc/splitscreen/Join.cpp b/src/mcc/splitscreen/Join.cpp
new file mode 100644
index 00000000..b1b714be
--- /dev/null
+++ b/src/mcc/splitscreen/Join.cpp
@@ -0,0 +1,339 @@
+// The Players window: couch-style joining. Every controller answers here directly: A joins as the next player, B
+// leaves, Y picks Spartan or Elite. At MCC's menus the players and their controllers can still change before a
+// mission. In a game it shows the lineup: the game reads the controllers live, so players only join there with hot
+// join (a controller no player uses presses A), and only in Halo CE does the last player leave (B).
+//
+// The players and their controllers are the menus' (mcc/settings/MenuSettings, which the dashboard and the overlay
+// share): a change goes into that state and in place at once, as the Splitscreen window's player count does, and is
+// written with the rest when a menu saves (the overlay closing, for one). A game start applies the state, joins
+// included. On a running map the controllers are the ones the players have then (State).
+#include "Splitscreen.h"
+
+#include "common.h"
+
+#include "global/Global.h"
+#include "input/Input.h"
+#include "mcc/CGameManager.h"
+#include "mcc/mcc.h"
+#include "mcc/settings/MenuSettings.h"
+#include "render/imgui/game/xbox/CXboxContext.h"
+
+#include "imgui.h"
+
+#include
+#include
+#include
+#include
+
+namespace MCC::Splitscreen {
+ static constexpr int kSlots = 4;
+ static constexpr ImU32 kColors[kSlots] = {IM_COL32(85, 164, 242, 255), IM_COL32(242, 85, 85, 255),
+ IM_COL32(85, 242, 85, 255), IM_COL32(242, 216, 85, 255)}; // the cards
+
+ // ---- the lineup: how many play, with which controllers, and player 1 on keyboard and mouse or not
+
+ namespace Settings = AlphaRing::MenuSettings;
+
+ // The menus' state, under Settings::Mutex(). On a running map the game reads each player's controller and keyboard
+ // and mouse for player 1 live (CGameManager::get_input_device), as that game's start put them in place and the
+ // Splitscreen window's Input, Bind and "Enable K/M for player1" may have changed them since: those are the
+ // players', so a controller rebound to a player isn't a free one, and a join or a leave keeps them.
+ static MenuState& State() {
+ auto& state = Settings::State();
+ if (MCC::IsInGame() && CGameManager::running()) {
+ for (int i = 0; i < kSlots; ++i)
+ state.controllerIndex[i] = CGameManager::get_profile(i)->controller_index;
+ state.useKM = AlphaRing::Global::MCC::Splitscreen()->b_player0_use_km;
+ }
+ return state;
+ }
+
+ // The player count, published last with a release store and read on the game thread with an acquire load, so that
+ // whoever reads a new count sees the controllers put in place before it. It's the dashboard's plain int (Global.h),
+ // so through Windows' interlocked-ordered accessors for it (winnt.h).
+ static_assert(sizeof(LONG) == sizeof(int));
+ static void PublishPlayerCount(int count) {
+ WriteRelease(reinterpret_cast(&AlphaRing::Global::MCC::Splitscreen()->player_count), count);
+ }
+
+ int PlayerCount() {
+ return ReadAcquire(reinterpret_cast(&AlphaRing::Global::MCC::Splitscreen()->player_count));
+ }
+
+ // A change goes in place as the Splitscreen window's player count puts its own (Settings::ApplySplitscreen): the
+ // controllers, keyboard and mouse for player 1, split screen on above one player, and the count.
+ static void PutInPlace(const MenuState& state) {
+ auto setting = AlphaRing::Global::MCC::Splitscreen();
+ for (int i = 0; i < kSlots; ++i) CGameManager::get_profile(i)->controller_index = state.controllerIndex[i];
+ setting->b_player0_use_km = state.useKM;
+ if (state.playerCount > 1) setting->b_override = true;
+ PublishPlayerCount(state.playerCount); // last: a new player's controller before the count makes them one
+ }
+
+ // The player `pad` plays as, or -1 (player 1 on keyboard and mouse has no pad).
+ static int SlotOf(int pad) {
+ auto& state = State();
+ for (int i = state.useKM ? 1 : 0; i < state.playerCount; ++i)
+ if (state.controllerIndex[i] == pad) return i;
+ return -1;
+ }
+
+ // A pad that just joined gives the game nothing until what it joined with is let go: the A would jump, and anything
+ // else held would act at once (JoinPressHeld, from the game's input poll).
+ static std::atomic s_join_held[kSlots] = {};
+
+ static bool Held(const XINPUT_GAMEPAD& gamepad) {
+ return gamepad.wButtons || gamepad.bLeftTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD ||
+ gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD;
+ }
+
+ bool JoinPressHeld(int pad, const XINPUT_GAMEPAD& gamepad) {
+ if (pad < 0 || pad >= kSlots || !s_join_held[pad]) return false;
+ if (Held(gamepad)) return true;
+ s_join_held[pad] = false;
+ return false;
+ }
+
+ // A press hot join or the window acted on (a join, a leave, a species), which the Splitscreen window's Bind doesn't
+ // also take until it's let go (PressTaken): Bind can take a press in the same frame, after them (BindPending).
+ static bool s_taken[kSlots] = {};
+
+ bool PressTaken(int pad, const XINPUT_GAMEPAD& gamepad) {
+ if (pad < 0 || pad >= kSlots || !s_taken[pad]) return false;
+ if (Held(gamepad)) return true;
+ s_taken[pad] = false;
+ return false;
+ }
+
+ // Each frame (HotJoinPoll), whether Bind is drawn or not, and whether the game reads the controller or not (not
+ // while the overlay is shown, by default): a press acted on, a join's included, is let go once its controller holds
+ // nothing.
+ static void LetGoTaken() {
+ for (int pad = 0; pad < kSlots; ++pad) {
+ XINPUT_STATE state{};
+ if ((s_taken[pad] || s_join_held[pad]) &&
+ (!AlphaRing::Input::GetXInputGetState(pad, &state) || !Held(state.Gamepad))) {
+ s_taken[pad] = false;
+ s_join_held[pad] = false;
+ }
+ }
+ }
+
+ // A new player with `pad`: their slot, or -1. The game reads these live in a mission (hot join), so the pad is held
+ // back before the count makes it a player's.
+ static int Join(int pad) {
+ auto& state = State();
+ int slot = state.playerCount;
+ if (slot >= kSlots || SlotOf(pad) >= 0) return -1;
+ s_join_held[pad] = true;
+ s_taken[pad] = true;
+ state.controllerIndex[slot] = pad;
+ state.playerCount = slot + 1;
+ PutInPlace(state);
+ return slot;
+ }
+
+ // Everyone after the leaving player moves up a slot, keeping their controller; the leaver's goes to the slot left
+ // free, so each of the dashboard's player pages keeps a controller of its own.
+ static bool Leave(int slot) {
+ auto& state = State();
+ if (slot < 0 || slot >= state.playerCount || state.playerCount <= 1) return false;
+ std::rotate(state.controllerIndex + slot, state.controllerIndex + slot + 1,
+ state.controllerIndex + state.playerCount);
+ --state.playerCount;
+ PutInPlace(state);
+ return true;
+ }
+
+ static bool DashboardOpen() { return g_pXboxContext && g_pXboxContext->isOpen(); }
+
+ // ---- the pads, read at most once a frame, by hot join or the window, whichever needs them first: which are
+ // connected, and the buttons newly down on each. Buttons already held when reading starts aren't presses.
+
+ static unsigned s_frame = 0, s_read_frame = ~0u; // frames counted by HotJoinPoll; not read yet
+ static WORD s_buttons[kSlots] = {}, s_pressed[kSlots] = {};
+ static bool s_connected[kSlots] = {};
+
+ static void ReadPads() {
+ if (s_read_frame == s_frame) return;
+ bool continuing = s_read_frame + 1 == s_frame;
+ s_read_frame = s_frame;
+ for (int pad = 0; pad < kSlots; ++pad) {
+ XINPUT_STATE state{};
+ s_connected[pad] = AlphaRing::Input::GetXInputGetState(pad, &state);
+ s_pressed[pad] = continuing ? state.Gamepad.wButtons & ~s_buttons[pad] : 0;
+ s_buttons[pad] = state.Gamepad.wButtons;
+ }
+ }
+
+ // The Splitscreen window's Bind has the controllers while it waits for one: nothing here acts on them, and reading
+ // starts again from what's held then, so the press Bind took is no press here until it's let go.
+ static bool BindHasPads() {
+ if (!BindPending()) return false;
+ s_read_frame = ~0u;
+ return true;
+ }
+
+ // ---- species: each player's Spartan or Elite (CUserProfile::UseEliteModel), which Halo 2, Halo 3 and Reach read
+ // as a game loads. -1: the profile's own (player 1's, which AlphaRing copies to every player's profile).
+
+ static std::atomic s_species[kSlots] = {-1, -1, -1, -1};
+
+ void ApplySpecies(int index, CUserProfile& profile) {
+ int species = index >= 0 && index < kSlots ? s_species[index].load() : -1;
+ if (species >= 0) profile.UseEliteModel = species != 0;
+ }
+
+ // The game takes an AlphaRing profile of the player's own (CGameManager::get_player_profile): only with
+ // AlphaRing's split screen on, player 1's while "Override profile" is, the others' unless they share player 1's.
+ static bool OwnsProfile(int slot) {
+ auto setting = AlphaRing::Global::MCC::Splitscreen();
+ if (!setting->b_override) return false;
+ return slot == 0 ? setting->b_override_profile : !setting->b_use_player0_profile;
+ }
+
+ static bool Elite(int slot) {
+ int species = s_species[slot];
+ return species >= 0 ? species != 0 : CGameManager::get_profile(slot)->profile.UseEliteModel;
+ }
+
+ static void ToggleSpecies(int slot) {
+ if (!OwnsProfile(slot)) return;
+ bool elite = !Elite(slot);
+ s_species[slot] = elite;
+ CGameManager::get_profile(slot)->profile.UseEliteModel = elite;
+ }
+
+ // ---- hot join (Splitscreen::HotJoinActive): the lineup changes during a mission
+
+ void HotJoinPoll() {
+ std::lock_guard lock(Settings::Mutex());
+ ++s_frame;
+ LetGoTaken();
+ // the dashboard has the controllers while it's open
+ if (BindHasPads() || !HotJoinActive() || DashboardOpen() || State().playerCount >= kSlots) return;
+ ReadPads();
+ for (int pad = 0; pad < kSlots; ++pad) {
+ int slot = s_pressed[pad] & XINPUT_GAMEPAD_A && SlotOf(pad) < 0 ? Join(pad) : -1;
+ if (slot >= 0) LOG_INFO("Hot join: controller {} joins as player {}", pad + 1, slot + 1);
+ }
+ }
+
+ // A Halo CE hot-join mission: the last player leaves.
+ static void HotJoinLeave(int slot) {
+ if (!HotJoinLeaves() || slot <= 0 || slot != State().playerCount - 1 || !Leave(slot)) return;
+ LOG_INFO("Hot join: player {} leaves", slot + 1);
+ }
+
+ // ---- the window (the overlay's menu bar)
+
+ static bool s_show = false;
+
+ static void PollPads(bool changes) {
+ ReadPads();
+ for (int pad = 0; pad < kSlots; ++pad) {
+ WORD pressed = s_pressed[pad];
+ int slot = SlotOf(pad);
+ if (changes && (pressed & XINPUT_GAMEPAD_A)) {
+ Join(pad);
+ } else if (pressed & XINPUT_GAMEPAD_B) {
+ s_taken[pad] = true;
+ if (changes) Leave(slot);
+ else HotJoinLeave(slot);
+ } else if ((pressed & XINPUT_GAMEPAD_Y) && slot >= 0) {
+ s_taken[pad] = true;
+ ToggleSpecies(slot);
+ }
+ }
+ }
+
+ static void Card(int slot, bool changes) {
+ auto& state = State();
+ bool joined = slot < state.playerCount;
+ float unit = ImGui::GetFontSize();
+ ImVec2 size(unit * 13.0f, unit * 8.0f);
+ ImVec2 at = ImGui::GetCursorScreenPos();
+ auto draw = ImGui::GetWindowDrawList();
+ ImU32 color = kColors[slot];
+ draw->AddRectFilled(at, ImVec2(at.x + size.x, at.y + size.y),
+ joined ? (color & 0x60FFFFFF) : IM_COL32(40, 40, 40, 160), unit * 0.5f);
+ draw->AddRect(at, ImVec2(at.x + size.x, at.y + size.y), joined ? color : IM_COL32(90, 90, 90, 255),
+ unit * 0.5f, 0, 3.0f);
+
+ float x = at.x + unit * 0.8f;
+ char line[64];
+ std::snprintf(line, sizeof(line), "PLAYER %d", slot + 1);
+ draw->AddText(ImVec2(x, at.y + unit * 0.7f), joined ? color : IM_COL32(160, 160, 160, 255), line);
+ const char* status;
+ if (!joined) {
+ status = changes ? "Press A to join" : "Free";
+ } else if (slot == 0 && state.useKM) {
+ status = "Keyboard & mouse";
+ } else if (int pad = state.controllerIndex[slot]; pad < 0 || pad >= kSlots) {
+ status = "No controller"; // the Splitscreen window's NONE
+ } else {
+ bool connected = s_connected[pad];
+ std::snprintf(line, sizeof(line), "Controller %d%s", pad + 1, connected ? "" : " (disconnected)");
+ status = line;
+ }
+ draw->AddText(ImVec2(x, at.y + unit * 2.4f), IM_COL32(230, 230, 230, 255), status);
+
+ if (joined && OwnsProfile(slot)) { // Spartan or Elite, also with Y on the player's controller
+ ImGui::SetCursorScreenPos(ImVec2(x, at.y + unit * 4.1f));
+ std::snprintf(line, sizeof(line), "%s##species%d", Elite(slot) ? "Elite" : "Spartan", slot);
+ if (ImGui::SmallButton(line)) ToggleSpecies(slot);
+ if (ImGui::IsItemHovered())
+ ImGui::SetTooltip("Spartan or Elite (Y on the player's controller): Halo 2, Halo 3 and Reach, from "
+ "the next game");
+ }
+ if (changes && joined && !(slot == 0 && state.useKM))
+ draw->AddText(ImVec2(x, at.y + unit * 6.1f), IM_COL32(170, 170, 170, 255), "B to leave");
+ ImGui::SetCursorScreenPos(at);
+ ImGui::Dummy(size);
+ }
+
+ void JoinContext() {
+ std::lock_guard lock(Settings::Mutex());
+ bool bind = BindHasPads(); // every overlay frame, before the Splitscreen window can take a press (ImGuiContext)
+ if (ImGui::BeginMainMenuBar()) {
+ ImGui::MenuItem("Players", nullptr, &s_show);
+ ImGui::EndMainMenuBar();
+ }
+ if (!s_show || DashboardOpen()) return; // one open at a time: the dashboard has the controllers
+
+ bool changes = !MCC::IsInGame();
+ if (!bind) PollPads(changes);
+ if (ImGui::Begin("Players", &s_show,
+ ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize |
+ ImGuiWindowFlags_NoSavedSettings)) {
+ for (int slot = 0; slot < kSlots; ++slot) {
+ if (slot) ImGui::SameLine();
+ Card(slot, changes);
+ }
+ if (bind) ImGui::TextDisabled("Bind (Splitscreen window) is waiting for a controller");
+ else if (changes) ImGui::TextDisabled("A: join B: leave Y: Spartan / Elite");
+ else if (HotJoinLeaves())
+ ImGui::TextDisabled("Hot join: A on a free controller joins, B leaves (the last player) Y: Spartan / Elite");
+ else if (HotJoinActive())
+ ImGui::TextDisabled("Hot join: A on a free controller joins; players leave at MCC's menus Y: Spartan / Elite");
+ else ImGui::TextDisabled("In a game: players join and leave at MCC's menus Y: Spartan / Elite");
+
+ bool hot_join = HotJoinChosen();
+ ImGui::BeginDisabled(HotJoinLocked());
+ if (ImGui::Checkbox("Hot join (experimental)", &hot_join)) ChooseHotJoin(hot_join);
+ ImGui::EndDisabled();
+ if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
+ ImGui::BeginTooltip(); // wrapped: one line would run off a 1080p screen
+ ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
+ ImGui::TextUnformatted("Players join in the middle of a mission: a controller nobody is playing with "
+ "presses A to join, and comes in beside a teammate. In Halo CE the last player can "
+ "also leave, with B here; in the other games players leave at MCC's menus. Halo CE "
+ "and Halo 2 take it as a mission starts, so in their games it's changed at MCC's "
+ "menus. On until MCC closes.");
+ ImGui::PopTextWrapPos();
+ ImGui::EndTooltip();
+ }
+ }
+ ImGui::End();
+ }
+}
diff --git a/src/mcc/splitscreen/Splitscreen.cpp b/src/mcc/splitscreen/Splitscreen.cpp
index a2e47c2e..46e250b1 100644
--- a/src/mcc/splitscreen/Splitscreen.cpp
+++ b/src/mcc/splitscreen/Splitscreen.cpp
@@ -9,6 +9,7 @@
#include "../CGameManager.h"
#include "log/MatchLog.h"
#include "mcc/CGameGlobal.h"
+#include "mcc/mcc.h"
#include "mcc/module/patch/SplitscreenConfigStore.h"
#include "LeftRight.h"
@@ -16,6 +17,8 @@
namespace Halo1::Entry::Anniversary { bool Available(); bool QuadShown(); }
namespace Halo2::Entry::Anniversary { bool Available(); }
+namespace Halo1::Entry::HotJoin { bool Available(); bool Active(); }
+namespace Halo2::Entry::HotJoin { bool Available(); bool Active(); }
namespace MCC::Splitscreen {
DefDetourFunction(__int64, __fastcall, get_index_by_xuid, void* a1, __int64 xuid) {
@@ -68,23 +71,28 @@ namespace MCC::Splitscreen {
auto p_setting = AlphaRing::Global::MCC::Splitscreen();
bool split = p_setting->b_override && game_options != nullptr; // AlphaRing's split screen sets this mission up
- bool left_right = split && LeftRight::Chosen() && LeftRight::Supports(game, p_setting->player_count);
+ // A hot-join mission can have any number of players: it's set up as one for four, and side by side for when
+ // two or three are in.
+ bool hot_join = split && HotJoinReserves(game);
+ bool left_right = split && LeftRight::Chosen() &&
+ LeftRight::Supports(game, hot_join ? 2 : p_setting->player_count);
LeftRight::StartClassicMission(game, left_right);
// Chosen, the 3-4 player mode is set up for the whole mission, whichever graphics it starts in: Back
// switches Halo CE and Halo 2 to Anniversary in the middle of one, side by side included.
bool quad = split && AnniversaryQuadChosen() && AnniversaryQuadAvailable(game);
s_anniversary_quad_game = quad ? game : -1;
if (!split) return;
- if (p_setting->player_count <= 2 && !left_right) return;
+ if (p_setting->player_count <= 2 && !hot_join && !left_right) return;
bool anniversary = game_options[0] & 1;
if (!anniversary) return;
if (quad && !left_right) {
- LOG_INFO("Splitscreen: {} players in Anniversary graphics (experimental)", p_setting->player_count);
+ LOG_INFO("Splitscreen: {} players{} in Anniversary graphics (experimental)", p_setting->player_count,
+ hot_join ? " and hot join" : "");
return;
}
- LOG_INFO("Splitscreen: {} players{}, starting in Classic graphics", p_setting->player_count,
- left_right ? " side by side" : "");
+ LOG_INFO("Splitscreen: {} players{}{}, starting in Classic graphics", p_setting->player_count,
+ left_right ? " side by side" : "", hot_join ? " and hot join" : "");
m_options = game_options;
m_saved = game_options[0];
game_options[0] &= ~1;
@@ -93,6 +101,70 @@ namespace MCC::Splitscreen {
ClassicGraphicsScope::~ClassicGraphicsScope() {
if (m_options) m_options[0] = m_saved;
}
+
+ static std::atomic s_hot_join{false};
+
+ bool HotJoinChosen() { return s_hot_join; }
+
+ // The slots are AlphaRing's, a lone player 1 the first of several; every game start keeps split screen on for it
+ // too (AlphaRing::MenuSettings::ApplySplitscreen).
+ void ChooseHotJoin(bool on) {
+ s_hot_join = on;
+ if (on) AlphaRing::Global::MCC::Splitscreen()->b_override = true;
+ }
+
+ bool HotJoinOn() { return AlphaRing::Global::MCC::Splitscreen()->b_override && s_hot_join; }
+
+ // How a game takes a player joining in the middle of a mission. Halo 3, ODST, Reach and Halo 4 make the player MCC
+ // signs in. Halo CE and Halo 2 make their players as a mission loads, so their modules keep all four and hold back
+ // the ones who haven't joined (module/entry/halo1/hotjoin.cpp, halo2/hotjoin.cpp), where this build has all the
+ // module's addresses; the module notes whether the running mission started so (Active).
+ bool HotJoinReserves(int game) {
+ return HotJoinOn() && (game == CGameGlobal::Halo1 ? Halo1::Entry::HotJoin::Available()
+ : game == CGameGlobal::Halo2 && Halo2::Entry::HotJoin::Available());
+ }
+
+ static bool SignsIn(int game) {
+ return game == CGameGlobal::Halo3 || game == CGameGlobal::Halo3ODST || game == CGameGlobal::HaloReach ||
+ game == CGameGlobal::Halo4;
+ }
+
+ // A running map takes joins (not one that is still loading).
+ bool HotJoinActive() {
+ if (!HotJoinOn() || !MCC::IsInGame() || !CGameManager::running()) return false;
+ auto p_global = GameGlobal();
+ if (p_global == nullptr) return false;
+ int game = p_global->current_game;
+ return game == CGameGlobal::Halo1 ? Halo1::Entry::HotJoin::Active()
+ : game == CGameGlobal::Halo2 ? Halo2::Entry::HotJoin::Active()
+ : SignsIn(game);
+ }
+
+ // Players leave in the middle of a Halo CE mission only: its module takes the leaver's Spartan away, and the games
+ // that sign players in end the mission when MCC signs one out.
+ bool HotJoinLeaves() {
+ auto p_global = GameGlobal();
+ return HotJoinActive() && p_global && p_global->current_game == CGameGlobal::Halo1;
+ }
+
+ int HotJoinSlots(int player_count) {
+ auto p_global = GameGlobal();
+ return p_global && HotJoinReserves(p_global->current_game) ? 4 : player_count;
+ }
+
+ // Halo CE and Halo 2 take the choice as a mission starts, and MCC ends one whose held-back players go away.
+ bool HotJoinLocked() {
+ auto p_global = GameGlobal();
+ return MCC::IsInGame() && p_global &&
+ (p_global->current_game == CGameGlobal::Halo1 || p_global->current_game == CGameGlobal::Halo2);
+ }
+
+ // Its missions start as hot-join ones (with split screen on, as every game start puts it with hot join chosen).
+ bool HotJoinHeld() {
+ if (!HotJoinChosen() || !HotJoinLocked()) return false;
+ return GameGlobal()->current_game == CGameGlobal::Halo1 ? Halo1::Entry::HotJoin::Available()
+ : Halo2::Entry::HotJoin::Available();
+ }
}
#include "imgui.h"
@@ -124,6 +196,7 @@ namespace MCC::Splitscreen {
for (int i = 0; i < 4; i++) {
XINPUT_STATE state;
if (AlphaRing::Input::GetXInputGetState(i, &state)) {
+ if (PressTaken(i, state.Gamepad)) continue; // the Players window or hot join acted on it (Join.cpp)
if (state.Gamepad.wButtons != 0 ||
state.Gamepad.bLeftTrigger > 30 ||
state.Gamepad.bRightTrigger > 30) {
@@ -137,9 +210,21 @@ namespace MCC::Splitscreen {
// Binding state: which player slot is waiting for controller input (-1 = none)
static int s_binding_player = -1;
+ // Bind takes a controller only on its player's page as it's drawn, with the overlay shown: so only while that page
+ // was drawn waiting the frame before (or this one: before a frame starts the count is still the last one's). A Bind
+ // whose player has gone is dropped.
+ static int s_binding_frame = -2; // the frame the page last drew the Bind waiting
+ bool BindPending() {
+ if (s_binding_player >= PlayerCount()) s_binding_player = -1;
+ return s_binding_player >= 0 && AlphaRing::Global::Global()->show_imgui &&
+ s_binding_frame >= ImGui::GetFrameCount() - 1;
+ }
+
void ImGuiContext() {
static bool show_splitscreen;
+ JoinContext();
+
if (ImGui::BeginMainMenuBar()) {
ImGui::MenuItem("Splitscreen", nullptr, &show_splitscreen);
ImGui::EndMainMenuBar();
@@ -455,6 +540,7 @@ namespace MCC::Splitscreen {
s_binding_player = index;
}
}
+ if (s_binding_player == index) s_binding_frame = ImGui::GetFrameCount(); // BindPending
if (p_profile->controller_index != controller_index) {
ms.controllerIndex[index] = p_profile->controller_index;
@@ -560,7 +646,9 @@ namespace MCC::Splitscreen {
ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Players");
ImGui::SameLine();
- ImGui::BeginDisabled(player_count <= 1);
+ // in a hot-join Halo CE or Halo 2 game the count changes only by joining and leaving
+ bool held = HotJoinHeld();
+ ImGui::BeginDisabled(held || player_count <= 1);
if (ImGui::Button("-", ImVec2(button_size, button_size)))
--player_count;
ImGui::EndDisabled();
@@ -572,10 +660,12 @@ namespace MCC::Splitscreen {
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (button_size - text_width) * 0.5f);
ImGui::TextUnformatted(count_text);
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.x + (button_size - text_width) * 0.5f);
- ImGui::BeginDisabled(player_count >= 4);
+ ImGui::BeginDisabled(held || player_count >= 4);
if (ImGui::Button("+", ImVec2(button_size, button_size)))
++player_count;
ImGui::EndDisabled();
+ if (held && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
+ ImGui::SetTooltip("Players join and leave in the Players window until this hot-join game ends");
if (player_count != ms.playerCount) {
ms.playerCount = player_count;
Settings::ApplySplitscreen(false);
diff --git a/src/mcc/splitscreen/Splitscreen.h b/src/mcc/splitscreen/Splitscreen.h
index 0466c51f..ebfe21d3 100644
--- a/src/mcc/splitscreen/Splitscreen.h
+++ b/src/mcc/splitscreen/Splitscreen.h
@@ -1,17 +1,46 @@
#pragma once
+struct CUserProfile;
+struct _XINPUT_GAMEPAD;
+
namespace MCC::Splitscreen {
bool Initialize();
void ImGuiContext();
}
+namespace MCC::Splitscreen {
+ // The Players window (Join.cpp): each controller presses A to join and B to leave. It changes the menus' player
+ // state (mcc/settings/MenuSettings) - the players and their controllers - as the Splitscreen window's player count
+ // does, and a menu saving writes it with the rest.
+ void JoinContext();
+ // From the game's input poll (CGameManagerSplitscreen.cpp): true while controller `pad` still holds what it joined
+ // with, when the game must see it released - until its buttons and triggers are all let go.
+ bool JoinPressHeld(int pad, const _XINPUT_GAMEPAD& gamepad);
+ // From the Splitscreen window's Bind: true while controller `pad` still holds a press the Players window or hot join
+ // acted on (a join, a leave, a species), which Bind doesn't also take - until it's let go.
+ bool PressTaken(int pad, const _XINPUT_GAMEPAD& gamepad);
+ // The Splitscreen window's Bind is waiting for a controller on its player's page, drawn with the overlay shown
+ // (Splitscreen.cpp): until it has one it has the controllers, as the dashboard has while it's open, so the Players
+ // window and hot join don't act on them. Once the page isn't drawn they're theirs again.
+ bool BindPending();
+ // The player count (Global::MCC::Splitscreen), read with an acquire load: the Players window and hot join put a new
+ // player's controller in place before the count, which they publish with a release store, so a reader on the game
+ // thread that sees the count sees the controller too.
+ int PlayerCount();
+ // A player's species (Spartan or Elite) chosen in the Players window, back on their AlphaRing profile after it was
+ // copied over from player 1's (CGameManager::apply_profiles, Reach's armour sync); nothing if none was chosen.
+ void ApplySpecies(int index, CUserProfile& profile);
+}
+
namespace MCC::Splitscreen {
// Halo CE and Halo 2's Anniversary renderer only ever drew two views, stacked, so missions with
// three or four players, or side by side (LeftRight.h, which takes the layout choice here), start in
// Classic: bit 0 of the first game-options byte selects Anniversary visuals in both engines, and it
// is cleared only while the engine copies the options, leaving MCC's own setting untouched. With 3-4
// players (not side by side) both can keep Anniversary instead, an experimental choice
- // (module/entry/halo1/anniversary.cpp, module/entry/halo2/anniversary.cpp).
+ // (module/entry/halo1/anniversary.cpp, module/entry/halo2/anniversary.cpp). A hot-join mission
+ // starts as one for four players would, side by side for when two or three are in: a player can
+ // join it at any time.
class ClassicGraphicsScope {
public:
// `game`: CGameGlobal::Halo1 or Halo2
@@ -36,3 +65,27 @@ namespace MCC::Splitscreen {
// Halo 2's keeps its own grid, player 1 on the top half.
bool AnniversaryQuartersShown(int game);
}
+
+namespace MCC::Splitscreen {
+ // Hot join (experimental): players join in the middle of a mission, and in Halo CE leave (Join.cpp). The choice
+ // is kept for the session (off as MCC starts) and needs AlphaRing's split screen, which it turns on: whether it's
+ // chosen, and on; whether the running mission takes joins, and leaves; each frame, a controller no player uses
+ // joining with A.
+ bool HotJoinChosen();
+ void ChooseHotJoin(bool on);
+ bool HotJoinOn();
+ bool HotJoinActive();
+ bool HotJoinLeaves();
+ void HotJoinPoll();
+ // Local players MCC is told of: all four slots in a hot-join Halo CE or Halo 2 mission, else the player count.
+ int HotJoinSlots(int player_count);
+ // A Halo CE or Halo 2 mission of `game` starting now is a hot-join one: hot join is on and the game's module, which
+ // holds back the players who haven't joined, has its addresses (module/entry/halo1/hotjoin.cpp, halo2/hotjoin.cpp).
+ bool HotJoinReserves(int game);
+ // In a Halo CE or Halo 2 game, where the choice takes effect as a mission starts, it's changed at MCC's menus.
+ bool HotJoinLocked();
+ // In a Halo CE or Halo 2 game with hot join (its module there), MCC has all four local players from the mission's
+ // start until the session exits, and ends it if they go away; the held-back ones come in only by joining. So until
+ // then the player count changes only by joining and leaving, not with the dashboard's or the Splitscreen window's.
+ bool HotJoinHeld();
+}
diff --git a/src/render/imgui/ImGui.cpp b/src/render/imgui/ImGui.cpp
index 98e276d8..2e5151ee 100644
--- a/src/render/imgui/ImGui.cpp
+++ b/src/render/imgui/ImGui.cpp
@@ -21,6 +21,7 @@
#include "mcc/CGameGlobal.h"
#include "mcc/settings/MenuSettings.h"
#include "mcc/spawn/Spawn.h"
+#include "mcc/splitscreen/Splitscreen.h"
static ICContext* pages[7] {
nullptr,
@@ -128,6 +129,7 @@ namespace AlphaRing::Render::ImGui {
}
void Render() {
+ MCC::Splitscreen::HotJoinPoll();
AlphaRing::Input::Update();
bool xboxOpen = g_pXboxContext && g_pXboxContext->isOpen();
diff --git a/src/render/imgui/game/mcc/CMCCContext.cpp b/src/render/imgui/game/mcc/CMCCContext.cpp
index 004c0619..95f625eb 100644
--- a/src/render/imgui/game/mcc/CMCCContext.cpp
+++ b/src/render/imgui/game/mcc/CMCCContext.cpp
@@ -10,7 +10,8 @@
static const char* tutorial_message = R"(TUTORIAL:
-Press "F4" or "Start + Back" to toggle the menu.
+Press "F1" or "Start + Right Stick Click" to toggle this menu, and "F4" or "Start + Left Stick Click" for the
+"Xbox 360" menu (both can be changed in alpha_ring_menu.cfg).
To navigate using Controller use the "Right Stick" to move the mouse and "RB" to click.
diff --git a/src/render/imgui/game/xbox/CStateMachine.cpp b/src/render/imgui/game/xbox/CStateMachine.cpp
index 3d49991a..93329f97 100644
--- a/src/render/imgui/game/xbox/CStateMachine.cpp
+++ b/src/render/imgui/game/xbox/CStateMachine.cpp
@@ -2,6 +2,7 @@
#include "CXboxRender.hpp"
#include "CStateMachine.h"
+#include "mcc/splitscreen/Splitscreen.h"
#include
#include
@@ -266,7 +267,11 @@ void StateMachine::handleOption() {
auto& opt = currentState.menu.pages[currentState.pageIndex]
.options[currentState.optionIndex];
- Mix_PlayChannel(-1, currentState.sounds[4], 0);
+ // in a hot-join Halo CE or Halo 2 game the player count changes only by joining and leaving
+ bool held = currentState.pageIndex == 0 && MCC::Splitscreen::HotJoinHeld() &&
+ (opt.type == OptionType::Increment || opt.type == OptionType::Decrement);
+ Mix_PlayChannel(-1, currentState.sounds[held ? 5 : 4], 0);
+ if (held) return;
if (currentState.pageIndex == 0) {
if (opt.type == OptionType::Increment && currentState.menuState.playerCount < 4)