Were PS2 Games Really Just C++? The Vector Units Ran Assembly
The PS2's main core ran game logic in C and C++, but its two vector units took hand-written assembly and microcode. The piece covers each layer of the machine, Naughty Dog's GOAL, the toolchain from 2000 to 2005 and the PS2DEV homebrew kit as of 2015.
views
The PlayStation 2 launched in 2000 with a main chip that held more than one kind of processor, and that design is why the question of what its games were written in has no one-word answer. The language of the game logic covers only the top layer of the machine. The code that made a PS2 game fast lived underneath it, on parts of the chip that took their programs in another form.
C and C++ ran on the main core
The heart of the console was the Emotion Engine, and its CPU core is a MIPS R5900, a two-way superscalar in-order RISC processor. C and C++ compilers turned source code into MIPS instructions for that core. The rules and state of a game, the part most programmers picture as game code, ran there, so for game logic the short answer of C++ holds.
The R5900 was a two-way superscalar in-order processor with a 6-stage integer pipeline. Two-way superscalar means the core could issue up to two instructions at once. In-order means it executed them in the sequence the compiler produced and did not reshuffle them itself.

That core was one processor among several on the same chip. The Emotion Engine also carried two vector units, VU0 and VU1, which worked alongside it. C and C++ suited the general-purpose core, so the C++ answer is accurate as far as it goes. It goes as far as that core and no further, because the vector units took their programs in assembly.
The vector units ran assembly
Both vector units can run in micro-mode, which means uploading an assembly program directly into the unit and running it there locally. Macro-mode, where the unit is driven from the CPU's own code, is possible only with VU0, because VU0 is wired directly to the Emotion Engine's CPU. That connection let a programmer inject inline assembly into an ordinary C program and drive VU0 from there, with C and assembly side by side in one source file.
VU1 sat further from the game code. It is a separate processor attached to the GS, the Graphics Synthesizer, and it operates independently, parallel to the CPU core, under the control of microcode. Because it is separate, VU1 is programmable only in micro-mode, so VU0 had two ways in and VU1 had one. Code for VU1 was an assembly program uploaded into the unit and left to run beside the core.

Naughty Dog wrote a language that mixed in assembly
One studio took that mix further than inline assembly in C. Naughty Dog wrote Game Oriented Assembly Lisp, known as GOAL, a language whose compiler was written in Allegro Common Lisp. GOAL let programmers freely mix assembly and higher-level constructs within one function. What C reached through inline assembly, GOAL made part of the language, so one compiler handled both kinds of code.
Naughty Dog did not carry GOAL into its next-generation development. Scott Shumaker gave the reason: "In all honesty, the biggest reason we're not using GOAL for next-gen development is because we're now part of Sony." His "we" is Naughty Dog, so this is the studio's own account, and he called it the biggest reason, which leaves room for others. Sony had bought the studio in 2001, the year after the PS2 launched.
Official tools and the homebrew SDK
Sony's official development kit was by far the most widely used by game studios. SN Systems released its ProDG development tools for PlayStation 2 in 2000, the year the console launched, as a company outside Sony. In 2005 Sony Computer Entertainment acquired SN Systems, so from then on the company behind ProDG belonged to Sony as well.
As of 2015, the community PS2DEV SDK, a hobbyist toolchain separate from Sony's own, built the main PS2 program from C or C++ with GCC version 3, a compiler from around 2002. Homebrew programmers could write the main program that way and drive VU0 from the same C code through inline assembly. VU1 was the gap: PS2DEV then provided no support for programming it, and that work needed Sony's official tools.
What made the PS2 hard to program
The split across a general core and two vector units meant that, with VU1 running parallel to the core under its own microcode, two programs in different languages were working at once and had to stay in step.
Graphics memory was small as well. VU1 is attached to the GS, which uses its video memory for the framebuffers, the z-buffer and textures, and with only 4 MB of video memory, managing that space efficiently can be quite challenging.
One developer's 2013 Reddit post, quoted by Den of Geek, describes being handed a 10-inch-thick stack of manuals written by Japanese hardware engineers, and the site itself notes that PS2 development kits were rough. The same poster says getting a first triangle on screen, the usual opening test for any graphics code, took some teams over a month.
In a 2009 interview about the PS3, Kaz Hirai of Sony acknowledged that the console was hard to program for.
"it's hard to program for"
Kaz Hirai, Sony, on the PS3 in 2009
Giving up the one-word answer costs a tidy reply, and in return you get the PS2 as it was built, with game logic in C and C++ on the R5900 core and the speed work in assembly on the vector units.
Matías Fuentealba
The fights fans have over video games and consoles are what Matías Fuentealba writes about. He also covers football.
View profileMore from Matías Fuentealba
View all →Recommended for you
More stories →
Durable Cases For Steam Deck With Battery Pack
How to Add LED Lights to Xbox Without Overheating
27″ Curved Monitor with FreeSync and HDR - Game On!
Leave a Comment