Repository navigation
139 worked example split screen
Question: step 3 of the two-player roadmap (issues #114, #115): show a two-player match. Each player needs their own camera and overlays (panel, fade, hangar, skull), and the classic layout needs the original's two-player screen. Document 134 traced the views, offsets and panel positions. Still to read: the two-player strip and the picture between the two views, and how the original loads them. Scripts and field names are in the tracing cheat sheet.
Short answer: the original loads one of four strips by player count and display mode, and in a two-player game a second picture, 2pMScr, which is the bar between the two views (document 96 had guessed it was "the two-player map screen"). The port now builds a view per player. With one player the view is in the window as before. With two, each view is in its own SubViewport sharing the match's world. In the classic layout each SubViewport is the player's column of the 4:3 picture and draws the original's screen.
The file names are in RFIRE.BIN in mixed case (ART\1pBScrL.rfa at 0x44dfe8 ...), so a search for the upper-case names finds nothing. A pointer search finds a table of four at 0x44e280, and ART\2pMScr.rfa (0x44e290) used once, both inside FUN_004313c0 (DecompileMany.java 0x004313c0):
idx = (players == 1) ? (hires != 0) : 3 - (hires == 0); // 0 1pBScrL, 1 1pBScrH, 2 2pBScrL, 3 2pBScrH (table 0x44e280)
load(table[idx], ... &strip);
if (players == 2) {
load("ART\\2pMScr.rfa", ... ÷r); // 24 x 299
if (!hires) { rect = {16, 0, divider.width (24), 0x96}; x = 0x9c; } // x 16-24, rows 0-150, at x = 156
else { rect = {0, 0, 0x10, divider.height (299)}; x = 0x138; } // x 0-16, all rows, at x = 312
}The blit (0x4315e5..0x431606) is DirectDraw's BltFast(screen, x, 0, divider, &rect, DDBLTFAST_WAIT).
Translation: 2pMScr is the bar between the two views. One image holds both resolutions: the left 16 columns are the high-resolution bar, and the right 8 columns (rows 0 to 150) are the low-resolution one. In low resolution it is drawn at (156, 0), filling the 8-pixel gap between the 156-wide views down to the strip. The two-player strip 2pBScrL.rfa is 320 x 92 and holds two panel windows, the same size as the one-player one.
The drawing, FUN_004314d0 (DisasmForce.java 0x4314d0 0x431640), runs each frame the strip needs it. Which path it takes depends on DAT_00448d20:
004314dc CMP dword [0x448d20],0 ; JNE 0x43159f ; the panels are shown: the bar, then the strip
004314e9 CMP byte [0x442fbc],2 ; JNZ (return) ; panels hidden: only a two-player screen draws anything
00431531 BltFast(screen, bar_x, 0, divider, &rect) ; the bar at the top ...
00431579 MOVSX EAX, word [0x448d54] ; SUB EAX, [0x458f2c] ; ... and again at y = the screen's height - the bar's height (150 / 299)
004315e5 BltFast(screen, bar_x, 0, divider, &rect) ; panels shown: the bar at the top
0043161e MOVSX EAX, word [0x448d54] ; SUB EAX, [strip + 0xc]
00431635 BltFast(screen, 0, EAX, strip, NULL) ; the strip at the bottom: y = the screen's height - the strip's
DAT_00448d20 is "the panels are shown". The panel code reads it (0x4115f0-0x412a00, document 66). Starting a game sets it (0x421d2f, 0x3ff Restart), and the hidden command 0x402 toggles it. That command is in no menu: it is the accelerator Alt+0 (document 136). Its handler FUN_004216e0(DAT_00448d20 == 0) resizes the views:
if (show) { one player: view (0, 0, 320, 152); two: (0, 0, 156, 149) and (164, 0, 156, 149); DAT_00448d20 = 1; }
else { one player: view (0, 0, 320, 240); two: (0, 0, 156, 240) and (164, 0, 156, 240); DAT_00448d20 = 0; }Translation: Alt+0 hides the panels and their strip, and the game view takes the whole screen height. With two players nothing would then fill the gap between the views below the 150-row bar. So the second path draws the bar twice, at the top and at the bottom: two 150-row bars overlap to fill 240 rows, or 299-row bars fill 480. (The two other display modes, DAT_00448d5c 3 and 7, use 200-row views; they are not part of this.) The port does not have the panels-hidden view yet.
| Piece | Where (low resolution, the 320 x 240 picture) | Source |
|---|---|---|
| Player 0's view | 156 x 149 at (0, 0) |
FUN_004096f0, document 134 |
| Player 1's view | 156 x 149 at (164, 0) | document 134 |
| The bar between them | 8 x 150 at (156, 0) | Step 1 |
| The strip | 320 x 92 at y = 148 | Step 1 (240 - 92) |
| Player 0's panel / player 1's panel | (14, 162) / (165, 162) |
FUN_00412ad0(2), document 66 |
| The view offsets | (8, 12) / (-8, 12) |
FUN_00416ab0, document 134 |
Mermaid source
flowchart TB
subgraph top["the 320 x 240 picture: the views"]
direction LR
v0["player 0's view<br/>156 x 149 at (0, 0)<br/>view offset (8, 12)"] ~~~ bar["bar 2PMSCR<br/>8 x 150<br/>at (156, 0)"] ~~~ v1["player 1's view<br/>156 x 149 at (164, 0)<br/>view offset (-8, 12)"]
end
subgraph strip["the strip: 2PBSCRL.RFA, 320 x 92 at y 148"]
direction LR
p0["player 0's panel<br/>at (14, 162)"] ~~~ p1["player 1's panel<br/>at (165, 162)"]
end
top ~~~ strip
The match (MatchController, engine): with players == 2 the level's side-0 spawn point is player 0's and its side-1 spawn point player 1's (whatever order the level lists them in), each a PlayerSlot with its own vehicle and controls, and no computer opponent. A level with one side's spawn point only plays as one player. The loops that meant "every vehicle" now use all_vehicles() (both players and any computer opponents), so the players hit, block and see each other; the radar's direction cursor points at the other side's vehicle.
The views (PlayerView, engine, new): the camera, the original's camera rig (each rig has its own view_offset: (0, 12) alone, (8, 12) / (-8, 12) with two) and the player's HUD, taken out of the level scene, which now only owns the world and the match:
func _build_views() -> void:
...
for i in n:
controller.slots[i].column = i
var box := SubViewportContainer.new()
...
var sub := SubViewport.new()
sub.world_3d = get_world_3d() # the same world: one match, two cameras
box.add_child(sub)
var pv := PlayerView.new()
sub.add_child(pv)
pv.setup(self, controller.slots[i], n, i, false)No renderer in the world faces the camera, so two cameras on one world need nothing else. Each player's pad pit and dock light, and both vehicles' renderers, are made per player. The end of the match (the ribbon, its banner, Enter to continue) is one window-wide HUD, because the ribbon is the whole screen's (document 135).
The overlays take their player's PlayerSlot instead of reading slot 0 (HudPanel, RadarView, SelectorScreen, DeathSkullView, PlaceholderHud, HangarPit3D, DockReadyIndicator3D).
The classic layout (HudLayout): each player's SubViewport covers their column of the picture, the left or the right 160 x 240 (a port choice: the split at x = 160, the middle of the bar). Every layout function takes the column (HudLayout.column(ps)) and gives the traced rectangles in it:
const VIEW_RECTS_2P := [Rect2(0.0, 0.0, 156.0, 149.0), Rect2(164.0, 0.0, 156.0, 149.0)]
const PANEL_POS_2P := [Vector2(14.0, 162.0), Vector2(165.0, 162.0)]
const STRIP_TOP_2P := 148.0
const DIVIDER_2P := Rect2(156.0, 0.0, 8.0, 150.0)
static func in_column(r: Rect2, viewport: Vector2, col: int) -> Rect2:
var k := classic_scale(viewport, col)
return Rect2(picture_rect(viewport, col).position + (r.position - Vector2(COLUMN_SIZE.x * col, 0.0)) * k, r.size * k)ClassicFrame draws the column's half of the two-player strip and its side of the bar. The camera keeps the one-player scale: a 156-wide view shows 156/320 of the one-player picture's width (document 96's rule), and it moves sideways (h_offset) so the followed point lands at the view's centre, which is 2 units off the column's. The panel is the player's at its traced place. The hangar screen is centred across the player's view and starts at its top, with its panel (the player's HUD panel on its hangar template, document 78) at the player's panel place. Where the original puts the hangar in a two-player view is not traced; this matches the footage.
The modern layout (the port's own): the window's two halves at the one-player world scale. The 8/320 gap between them shows the original's bar (divider_2p_high.png stretched to the window's height). The left player's panel is in their bottom left and the right player's mirrored in their bottom right, with their status labels at the top right; each label fits its half, ending in "..." when it is longer. The frame-rate counter moves over the bar.
The art (#115): both importers write hud/strip_2p_low.png / strip_2p_high.png and the two bars divider_2p_low.png (8 x 150) / divider_2p_high.png (16 x 299) cut as Step 1 says.
The high-resolution art (ClassicFrame). Once the classic picture is drawn at twice its size or more (640 x 480 on screen), the frame draws the high-resolution strip and bar (strip_1p_high / strip_2p_high, divider_2p_high) at their own sizes, in one- and two-player alike. This is a port choice, as the original picks them by its display mode. The positions are the traced ones. The strip sits at the bottom (y = height - its rows): 152 for both one-player strips; 148 for the 92-row two-player strip, and 297 / 2 = 148.5 for the 183-row one. The bar starts at the top, at x = 156, or x = 312 at high resolution, and is 149.5 units tall at high resolution:
func _pick(low: Texture2D, high: Texture2D, k: float) -> Array:
if high != null and k >= HIGH_FROM: # HIGH_FROM = 2.0
return [high, high.get_size() * 0.5]
return [low, low.get_size() if low != null else Vector2.ZERO]
...
draw_texture_rect(strip[0], HudLayout.in_column(Rect2(0.0, HudLayout.SCREEN.y - strip[1].y, strip[1].x, strip[1].y), vp, column), false)
draw_texture_rect(bar[0], HudLayout.in_column(Rect2(HudLayout.DIVIDER_2P.position, bar[1]), vp, column), false)tests/two_player_check.gd checks the choice. Screenshots at 1280 x 960 (one and two players) show the high art; the green and tan column at the strip's outer edges is in the art itself.
A two-player match is started from the Multiplayer stage select, which now has an Opponent group with two Windows 95 radio buttons, vs AI and vs Human (a port feature: the original's two-player maps are always two people). vs Human (the default) starts the map with two players; vs AI starts it with one, and the computer opponent takes the other side. The choice is GameSettings.versus_human, kept in user://settings.cfg; GameFlow.players_for(mode) turns it into the level scene's players. The skin draws the radio buttons as Windows 95's sunken white circle with a black dot, inside an etched group box (UiSkin.radio, UiSkin.group_box). RF_PLAYERS=2 starts a two-player match for one run. The stage select's preview window now always shows its "Best time" line, "--" until there is one, so it keeps its height.
Checks: the engine's tests/two_player_check.gd:
- the match: two slots on sides 0 and 1, their vehicles and binding sets, no computer opponent, separate bases;
- input: player 2's keypad 8 drives player 2's vehicle only;
- the scene: two SubViewports sharing the world, each with a camera and the traced offsets, the HUD per view and one for the match, both vehicles drawn;
- the classic geometry: the views, the panels, the bar, the columns splitting the picture, the one-player view unchanged.
Screenshots at 1280 x 960 (classic) and 1280 x 720 (modern) on RFMAP101, both players on their pads and both in the hangar, compared with the split-screen footage.
- The panels-hidden view (Alt+0, Step 1): traced, not built.
-
The two-player rules (step 4): done, document 140. -
Starting a two-player game from the menus (step 5): done, document 141.
Next: back to the issues list.
Return Fire, rebuilt
Elsewhere