tetris-efi

A Tetris clone that runs as a UEFI application.

View on GitHub

Tetris for UEFI

C GitHub tag (with filter) License GitHub commits since latest release (by SemVer including pre-releases) Dependabot pages-build-deployment Stargazers pre-commit CMake Prettier Tests Coverage Status

@Tatsh Buy Me A Coffee Libera.Chat Mastodon Follow Patreon

A Tetris clone that runs as a UEFI application. It uses the Graphics Output Protocol (GOP) at the firmware’s current mode, draws coloured tetrominoes with a back-buffered + Blt render path, includes a ghost-piece preview, and supports hold (store/recall). On game over you can start a new game or quit back to the firmware.

Screenshot

Based on hello-world-efi and Roderick W. Smith’s EFI programming examples.

Features

Controls

Arrow keys move; the four actions also have keyboard alternatives.

Action Primary Alternates
Move left Left arrow H
Move right Right arrow L
Soft drop Down arrow J
Hard drop Up arrow, Space K
Rotate left (CCW) Z A
Rotate right (CW) X S
Hold C none

How to build

Required tools: cmake, GNU EFI, mtools (mformat, mmd, mcopy), and an ISO 9660 builder that supports -eltorito-platform efi (xorrisofs from xorriso, or mkisofs from cdrtools).

  1. Have cmake in your PATH.
  2. Install GNU EFI on your system.
  3. Clone this repository and open a terminal in its root.
  4. mkdir build && cd build
  5. cmake -G Ninja .. (or cmake .. for Make)
  6. ninja (or make)

Output: tetris.efi and a minimal UEFI-bootable tetris.iso (~1.4 MB). The ISO contains a single FAT EFI System Partition image carrying \EFI\BOOT\BOOTX64.EFI, exposed via El Torito with platform ID 0xEF. UEFI firmware loads that file directly — no GRUB or other bootloader.

Project layout

How to run in QEMU

From the build directory:

ninja run-qemu      # or `make run-qemu`

The run-qemu CMake target auto-detects an installed OVMF firmware and boots tetris.iso.

How to run tests

Configure with -DBUILD_TESTS=ON and run ctest:

cmake -G Ninja -DBUILD_TESTS=ON ..
ninja
ctest --output-on-failure

Tests live in tests/ and use cmocka. Each test executable compiles the relevant src/*.c files directly so cmocka --wrap can intercept gnu-efi calls without linking the full libefi/libgnuefi runtime. Tests can only be built with GCC.