psxsdk

split

A split screen: two players, each with a cube to drive among stone pillars and a camera of their own following it, one above the other or side by side.

Controls

The directions on the first controller move the first cube; the second cube moves with the second controller's directions, or with the first controller's triangle, cross, square and circle. Select switches between the halves one above the other and side by side.

A port of the SCEE tutorial's chapter 10, examples 20 and 21, the horizontal and vertical split screens, in one program. The trick is two ordering tables a frame, one for each half. Each half's models are sorted into its own table, with the GTE set to that half's camera, and when the frame is drawn each table is drawn with its own drawing offset, the screen position the camera's centre lands on, and its own clip, the half of the screen it may draw in. GsSetOffset and GsSetClip change both, for the buffer being drawn, and the next GsSwapDispBuff puts them back.

They take effect at once rather than in turn with what the GPU is drawing, and the library asks that the GPU not be drawing when they are called; so the frame waits with DrawSync for one half to be drawn before it sets up the next. The tutorial did not wait, which leaves the second half's settings to land in the middle of the first half's drawing.

The scene is drawn twice, once for each camera, so a split screen costs twice the sorting of one view; a game with two players kept its scenes smaller, or drew less far, to make up for it. Here it is ten cubes.

The models and the texture are the tutorial's own: CUBE.TMD, a cube of coloured, lit triangles, for the players, and CUBETEX.TMD with STONE02.TIM for the pillars.

Differences from the tutorial: there each half showed one of two cubes, moved with the one controller, through one camera; here each half has a camera that follows its player's cube, and the scene is the same in both; the two examples are one, switched with select; and the frame waits for each half to be drawn.

Source on GitHub