Skip to content

DEF CON 34 talks are here: 354 talks, summarized and searchable.

Browse DEF CON 34

SH4ZAM - Accelerated Vector Math on the Sega Dreamcast

Falco Girgis

Where

Game Hacking Village
DEF CON 34

Duration

17 min

Shows how the Sega Dreamcast's SH4 floating-point hardware is exploited by a hand-optimized math library used in homebrew game ports.

Summary

The talk starts with the motivation for SH4ZAM: a Dreamcast port of Grand Theft Auto 3 that ran poorly because of slow floating-point math. The speaker explains how the library grew from hand-written SH4 assembly into a standalone project with scalar, trigonometry, vector and matrix APIs, each offered in C and C++ headers. Examples include a hardware reciprocal square root used for fast division and square roots, and a single instruction that computes sine and cosine together, which replaced lookup tables and freed memory in a game that used them.

The middle section covers the vector and matrix paths. A four-component dot product instruction and a transform instruction that multiplies a vector by a 4x4 matrix held in a register bank give large speedups over a standard C math library. Demos from Star Fox 64, Mario Kart 64 and Diddy Kong Racing show frame-rate and audio gains, including vectorized audio synthesis. A software back end lets the same math code build for non-Dreamcast targets.

The closing takeaway is that careful use of a console's vector hardware, inline assembly and modern compilers can pay off on old machines. The speaker argues the same lessons apply to other game consoles and to performance-focused math libraries generally. The library is bundled with a community Dreamcast SDK, and the speaker invited questions afterward.

Materials

Related talks

Main Stage·23 min

  • DEF CON
  • Hardware
  • Date: Aug 2026
  • Location: Las Vegas

Andrew 'bunnie' Huang

Explains how the DEF CON 34 badge was designed and built, how attendees can attack it, and how its partly open-source Baochip-1x chip can be inspected.

hardwareopen-sourcedevice+2