Skip to content

Latest commit

 

History

History
47 lines (36 loc) · 1.76 KB

README.md

File metadata and controls

47 lines (36 loc) · 1.76 KB

DumbCycle

A simple Snake/LightCycle game for x86_64 Linux implemented in assembly and C99 with no linked libraries (no libc) and no preprocessor directives (no #ifdef, #define, #include, etc).

Images are drawn to the screen using the "dumb buffer" API provided by the Direct Rendering Manager (DRM) subsystem of Linux. Keyboard input is read directly from a keyboard device file. DumbCycle should run on any x86_64 Linux system with DRM support, a video card, and a keyboard1.

DumbCycle can be compiled with any C compiler that supports C99 and ATT syntax x86_64 assembly. The primary motivation for eschewing the C preprocessor is to allow the project to compile using only cproc-qbe, QBE, and GNU binutils (for as and ld). Passing the game code through cproc and QBE results just over 2000 lines of simple and readable x86_64 assembly.

Building and running

Run the game by executing make run (or make run_cproc) with the required permissions1. You can also run make and ./dumb_cycle, but make run also executes clear to automatically restore terminal when the game exits.

Playing

Steer with WASD and avoid the walls. Press ESC to exit.

References

Footnotes

  1. The executable must have permissions to open the video device /dev/dri/card0 and the input devices in /dev/input/. No other programs should be drawing to /dev/dri/card0, i.e. you need to close your X11 and/or Wayland server. 2