Skip to content

134 worked example the two player screen

Alex Diakovsky edited this page Oct 12, 2026 · 2 revisions

134. Worked example: the two-player screen

Question: what does the port need for the original's split-screen two-player game? What does the original's two-player screen look like, how is it set up, and what in the port still assumes one player? (Issue #72; the work is split into #112 to #116.) Scripts and field names are in the tracing cheat sheet.

Short answer: two views side by side, each with its own camera, panel, start-of-game vehicle choice, spawn point and a block of per-player starting values. All of it is set up by one function, FUN_004096f0, the two-player twin of the one-player FUN_00409420 (document 96). Reading the one-player function again for comparison found a bug in the port's camera: the one-player view offset had been taken from the layout the shipped game never uses (issue #111, fixed below).

Step 1: the footage

The recording Playing Split Screen Return Fire with Sucra (1280 x 720) is an edited stream: the game picture sits at about crop=830:625:441:50, surrounded by the uploader's webcam, a camouflage background and the players' names over its top rows. The picture's edges are also trimmed, so the footage is only good for what things look like; every number below comes from the code.

What it shows:

  • Two game views side by side over a full-width strip with two panels. Each panel shows that player's vehicle type, exactly as in one-player play.
  • The hangar (the vehicle choice) plays inside one player's half while the other player keeps driving; both players can be in the hangar at once.
  • The loss skull, and the drowning skull drawn over the map, play inside one half. Under the two-player skull are rows of the remaining-vehicle icons.
  • The victory ribbon fills the whole screen. Because the stream is edited, this is not proven (#116).

Step 2: the setup, FUN_004096f0

DecompileMany.java 0x004096f0, the branch the shipped game takes (DAT_0048c7dc == 0; document 96 shows that the other branch is never taken). The calls were checked against the disassembly (DisasmForce.java 0x4096f0 0x4098d0):

FUN_0041d1d0(&DAT_00480d50, &DAT_0048ca30, &DAT_0048c7e0, 2,   0, 0, 0x9c, 0x95);   // view 0: (0, 0), 156 x 149
FUN_0041d1d0(&DAT_00480d50, &DAT_0048ca34, &DAT_0048c828, 2, 0xa4, 0, 0x9c, 0x95);   // view 1: (164, 0), 156 x 149
FUN_00416cb0(&DAT_0048b4c0, 0x48c7e0,    0, 0, 0x9c, 0x95);   // camera 0 and its rectangle
FUN_00416cb0(&DAT_0048b70c, 0x48c828, 0xa4, 0, 0x9c, 0x95);   // camera 1
FUN_00416ab0(0x48b4c0,  8, 0xc, 0x94, 0x89);                  // camera 0: offset (8, 12), box 148 x 137
FUN_00416ab0(0x48b70c, -8, 0xc, 0xa7, 0x89);                  // camera 1: offset (-8, 12), box 167 x 137
...
_DAT_0048c894 = &DAT_0048b4c0;                       // player 0's view
_DAT_0048c898 = DAT_0045bfdc; _DAT_0048c89c = DAT_0045bfd4;          // player 0's spawn
copy 5 dwords DAT_0048c72c[0..4] -> 0x48c92c;  DAT_0048c92c |= 1;     // player 0's starting block
_DAT_0048c964 = &DAT_0048b70c;                       // player 1's view
_DAT_0048c968 = DAT_0045bfdc + 4; _DAT_0048c96c = DAT_0045bfd4 + 4;  // player 1's spawn: the second spawn point
copy 5 dwords DAT_0048c72c[5..9] -> 0x48c9fc;  DAT_0048c9fc |= 1;     // player 1's starting block
FUN_00408160(2);                // DAT_0048ca8c = 2
FUN_00412ad0(2);                // two panels (document 66: x = 14 and 165, y = 162)
FUN_00418290(0x48b4c0);         // player 0's vehicle choice (document 95)
FUN_00418290(0x48b70c);         // player 1's
FUN_004232d0(8, 0, 0x48b5a0, 0);   // the left ear follows view 0 ...
FUN_004232d0(8, 1, 0x48b7ec, 1);   // ... and the right ear view 1 (document 117)

Translation:

  • The screen. The views are 156 x 149 at x = 0 and x = 164: an 8-pixel gap down the middle, and 240 - 149 = 91 rows below for the two-player strip (2PBSCRL/H.RFA, 92 rows, in ART/, not yet extracted; #115).
  • The cameras. Each player has a full camera struct (0x48b4c0, 0x48b70c, stride 0x24c). FUN_00416ab0 stores its second and third arguments as the view offset (+0x1c4, +0x1c8, 16.16), and FUN_00416fa0 puts the view's centre at the followed point minus that offset (document 129). So player 0's centre is 8 units west and 12 north of their vehicle, and player 1's is 8 east and 12 north: in both halves the vehicle sits a little toward the middle of the screen and a little below the centre.
  • The box. The fourth and fifth arguments become a box around the offset (+0x1cc..+0x1d8), 148 x 137 for player 0 and 167 x 137 for player 1. The asymmetry is a shared code tail: player 0's branch pushes 0x89 and jumps to 0x409895, where player 1's call pushes 0xa7, and the two calls share that code. What the box is used for is not traced (#116).
  • The player structs (0x48c880 + p * 0xd0) each get five dwords from DAT_0048c72c, which FUN_004092d0 sets to 0x443010: player 0's from 0x443010, player 1's from 0x443024. They land at +0xac..+0xbf, which covers the input-device byte (+0xb0, read by FUN_0042d1a0, document 113), the vehicle stock (+0xb8, document 73) and the mine reserve (+0xbc, whose starting value document 75 could not find). So the starting reserve is probably this block. That is a lead, not proven (#116).
  • Input is already traced: each player has a key table at 0x480db0 + p * 0x94 and can use the keyboard or a joystick (document 132, document 113).

Step 3: the one-player setup again, and a bug

Comparing with FUN_00409420 (document 96), the one-player view's call on the branch that is taken is:

0040947d  PUSH 0x8c
00409482  PUSH 0x120
00409487  PUSH 0xc
00409489  JMP 0x004094e8
...
004094e8  PUSH 0x0
004094ea  PUSH 0x48b4c0
004094ef  CALL 0x00416ab0          ; FUN_00416ab0(view, 0, 12, 288, 140)

FUN_00416ab0(view, 0, -2, 325, 171) is the other branch (DAT_0048c7dc != 0, 0x4094dc..0x4094e6), which the shipped game never takes. Document 129 had read it as the one-player call, because both branches end in the same CALL at 0x4094ef. The one-player view's centre is 12 units north of the followed point, not 2 units south. The one-player reference video agrees: a vehicle on the move sits a few pixels below the middle of the 152-row view.

Applied in the port (issue #111)

game/camera_rig.gd (engine cf1a0ce):

## The one-player view's offset (+0x1c4 / +0x1c8): FUN_00409420 calls FUN_00416ab0(view, 0, 12, 288, 140) on the branch the shipped game
## takes (DAT_0048c7dc == 0, 0x40947d; the (0, -2, 325, 171) call is the other, unreachable layout's, document 96; issue #111). ...
const VIEW_OFFSET := Vector2(0.0, 12.0)

func centre() -> Vector2:
	return Vector2(x, y) - VIEW_OFFSET

tests/camera_rig_check.gd now expects the centre 12 units north of the followed point. All 39 engine checks pass, and so do the RFMAP001 playthrough and the openfire camera, decoration and road checks. A classic-layout screenshot at the hangar exit shows the Tank sitting just below the middle of the view, where before it sat just above.

What the port needs

The engine assumes one player throughout. MatchController has about 227 references to its single vehicle, terrain_view_3d.gd about 88:

  1. Per-player state (#112): a record per player in place of vehicle, vehicle_stock, mine_reserve, the dock and pad state, the vehicle choice, the skull timers, the camping timer and the spawn.
  2. Input per player (#113): a controller that produces the input word (keyboard layout 1 or 2, or a gamepad) instead of Vehicle reading Input; EnemyVehicle drives through the same interface (#77).
  3. Split-screen views (#114): a SubViewport, Camera3D and CameraRig per player (the rig is already one object per view), with the panel, radar, hangar, skull and fades drawn inside that player's half. The classic layout uses the rectangles and offsets above; the modern layout is the port's own and should scale to four players (#40).
  4. The two-player art (#115): 2PBSCRL/H.RFA and 2PMSCR.RFA into the pack.
  5. The traced two-player rules (#72, #108): the submarine hunts both players, the MSV's mine layer works and scattered mines are off, the music's rules, turrets wake for the other team's view, Drones, the panel's second ammo readout, the stereo split, the Tournament table (#84).
  6. The front end: the Player Selector (#85), and per-player key bindings in Settings.

Not traced

All in #116, and all answered in document 135:

  • The two-player skull and loss phases (0x418a50, 0x418af0, 0x418b50, the icon rows) and the other player's stock check in FUN_0040b260.
  • Whether the ribbon covers the whole screen.
  • What FUN_00416ab0's box is used for.
  • Whether 0x443010 + p * 0x14 really is the per-player starting block.

Next: back to the issues list.

Clone this wiki locally