Title: British Computer Society May 2005
1British Computer SocietyMay 2005
- Video Game Programming Using The PlayStation2
Games Console - Dr Henry S Fortuna
- School of Computing and Creative Technologies
- University of Abertay Dundee
- E-mail h.s.fortuna_at_abertay.ac.uk
- Web www.hsfortuna.pwp.blueyonder.co.uk
2My Background
- First Degree in Electrical and Electronic
Engineering - PhD in Semiconductor Physics
- Taught Electronics/Microprocessors
- Always interested in playing computer games
- Always interested in computer programming/graphics
- Joined Games Technology Course team at Abertay
- Got involved with Sony Computers Entertainment
- Now lead Games Technology course developments
3Presentation Contents
- Games programming why bother?
- Short historical context
- Components of a Video Game? (video)
- Internal structure of PlayStation2
- Development Environment
- Programming techniques
- What students do/think
- Examples of student work
4The UK Games Industry 2004
- UK Software sales were 934m in 2000
- 1.34 Billion in 2004 even though no new
consoles - GTA San Andreas
- fasting selling game of all time
- 1 million units in 9 days 1.75M in the year
- 5 titles sold more than 600,000 (double platinum)
- Xbox greatest growth, PS2 greatest volume (640
M) - Electronic Arts had 9 titles in top 20
- Top 40 8 sports, 10 film and TV based
5First Video Game (1961)
- MIT student Steve Russell creates Spacewar
- Digital PDP-1 Minicomputer
6Nolan Bushnell Pong 1972
7Space Invaders (1978)
8Other Key Developments
- Atari 400 (1978)
- Commodore 64 (1983)
- Nintendo Entertainment System (1985)
- Sega Master System (1986)
- Nintendo Gameboy (1989)
- Sega 16-bit Genisis (1989)
- Atari Lynx Handheld (1989)
- Nintendo SNES (1991)
- Sega CD (1992)
- Sony Playstation (1995)
- Nintendo N64 (1996)
- Sony Net Yaroze (1997)
- Sega Dreamcast (1999)
- Sony PlayStation2 (2000)
- Microsoft Xbox (2001)
- Nintendo GameCube (2001)
- Sony PlayStation2 Linux Kit (2002)
9Next-Generation Consoles
- Sony PlayStation 3
- Cell Processor (8 Core?)
- Xbox 360
- 3xIBM PowerPC 3.2Ghz cores
- ATI 500MHz graphics processor
- Nintendo Revolution
- Lots of handheld devices
10Components of a Video Game
11Components of a Video Game
- 3D graphics
- User interaction
- Sound effects and music
- 3D models
- 2D textures
- Animation
- Game and level design
- Immersion, excitement, alternate reality
12PlayStation Net Yaroze (1997)(Official
hobbyist Game Development)
- Host-target Development
- Net Yaroze games dev libraries
- No access to hardware
- Sub-optimal Performance
13PlayStation2 Games Console
European Launch November 2000
14(No Transcript)
15Professional Development EnvironmentThe TOOL
- Use the Linux-based tools that come with the TOOL
- Use third party dev tools such as CodeWarrior or
SN systems
16PlayStation2 Linux Kit May 2002
- USB keyboard mouse
- 10/100 Ethernet Adapter
- 40GB Hard Disk
- DVDs
- Linux operating system
- Hardware Manuals
- Development Tools
- Example Applications
17Development Configuration(Several Options)
18(No Transcript)
19(No Transcript)
20Development Tools
- GNU gcc and g compilers
- GNU gdb debugger!
- Vector Command Line Pre-processor
- Vector Unit assembler
- Visual Vector Unit Debugger
- Development can be done offline with Visual
Studio
21Development Environment
22Graphics Transformation Pipeline
- Transforms vertices from model or local space to
2D screen space for rasterisation
23PS2 Graphics Architecture
24PS2 Specific Pipeline
- Transformation Matrices built by CPU
- Matrices and untransformed vertex data sent to
VU1 - VU1 performs vertex transformation, clipping,
lighting, view port scaling. - Transformed data sent to GS.
- GS performs texturing and rasterisation.
- All above (3 processes) can run in parallel !!
25Organisation of Memory
- Dynamic buffer contains data that changes from
frame to frame, e.g. transformed data,
transformation matrices. - Two dynamic buffers needed to exploit parallelism
of PS2 - One buffer is being compiled by the CPU whilst
the other is being sent for rendering. - Utilises Parallelism of PS2
Swap Every Frame
Written by CPU
Read by DMAC
26The Game Loop
- while(Game_Running)
-
- Fire() // Start data transfer
- GetUserInput() //
- DoGameLogic() // AI, Physics, Logic.
-
- // Following code ONLY puts render data into
memory -
- BeginScene() // Clear frame buffer
- SetStaticData() // textures, 3d models etc
- SetDynamicData() // Matrices, TL, etc.
- EndScene() // Wait for previous frame to
render -
27VU Overview
28Architecture of VU1
- 16k data memory, address in qwords (128-bit)
- 16k program memory, address in dwords (64-bit)
- 32 x 128-bit floating point registers
- 16 x 16-bit integer registers (newbie killer!)
- Two execution units (upper and lower)
- Special registers (ACC, I, Q, R, P)
- Dual stream assembly language (.vsm file)
- VU assembler provided by Sony (ee-dvp-as)
- Latency, scheduling, pairing, issues.
29Typical vsm assembly (dual stream)
- NOP
lq VF06,7(VI02)
- mulax ACC,VF02,VF06x
iaddiu VI01,VI01,0x00000001 - madday ACC,VF03,VF06y
iaddiu VI02,VI02,0x00000002
- maddaz ACC,VF04,VF06z
NOP
- maddw VF06,VF05,VF06w
NOP
- NOP
NOP
- NOP
NOP
- NOP
NOP
- mulaw.xyz ACC,VF01,VF00w
div Q,VF00w,VF06w
- NOP
NOP
- NOP
NOP
- NOP
NOP
- NOP
NOP
- NOP
NOP
- NOP
NOP
- mulq.xyz VF06,VF06,Q
waitq
- NOP
NOP
- NOP
NOP
- NOP
NOP
30Typical VCL(Single Stream)
- loop
- lq Vert, StartVert(iVertPtr)
-
- MatrixMultiplyVertex Vert, fTransform, Vert
-
- div q, vf00w, Vertw
- mul.xyz Vert, Vert, q
-
- mula.xyz acc, fScales, vf00w
- madd.xyz Vert, Vert, fScales
- ftoi4.xyz Vert, Vert
31(No Transcript)
32What is the PS2 used for?
- Introduced in year 2
- Introduce console development topics
- 2D graphics, frame buffers, graphics packets,
graphics processors, memory management, console
architecture. - Further Develop programming skills
- C concepts in a games context, Sprite classes
etc., structure of a games program, creating a 2D
game.
33What is the PS2 used for?
- Continued in Year 3
- Introduce 3D console development topics
- 3D graphics, 3D console architecture, Vector
Units, Parallel processing, vertex
transformation, clipping, lighting. - Further develop programming skills
- Further C concepts in a games context, High
level 3D graphics engine design, Low level vertex
processing.
34What is the kit used for?
- Students choose to use the kit for
- Group project work
- Honours project work
- Other initiatives such as Dare To Be Digital
35Evaluation
- Games Employers Value Console Skills
- Steep learning curve for students
- In-house development framework needed
- Similarities to Pro-development
- Motivational for students
- Introduces Linux Linux development tool chain
36Student View of the Kit
- Some Hate it
- Some are indifferent
- But most LOVE it
37Example Applications
38Example Applications
39Example Applications
40Example Applications
41Student Work
- (Video)
- (Example Applications)
42Questions?
- Development framework and tutorials at
- http//www.hsfortuna.pwp.blueyonder.co.uk/
- (Dr Henry S Fortuna)
43Development Environment
- Libps2dev (May 2002)
- Bundled with kit on DVDs
- Examples and some documentation
- Some hardware features emulated
- Sub optimal performance
- SPS2 project (November 2002)
- Available on playstation2-linux.com
- Full access to graphics hardware
- Similar experience to Pro-Development
- Comparable performance to Pro-Development