Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/permutationlock/dumbcycle
A step-by-step example showing how to make a Linux game from scratch with x86_64 assembly and C99 without libc.
https://github.com/permutationlock/dumbcycle
Last synced: 2 days ago
JSON representation
A step-by-step example showing how to make a Linux game from scratch with x86_64 assembly and C99 without libc.
- Host: GitHub
- URL: https://github.com/permutationlock/dumbcycle
- Owner: permutationlock
- Created: 2024-04-27T21:35:13.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-05-09T02:47:30.000Z (6 months ago)
- Last Synced: 2024-05-10T01:33:43.838Z (6 months ago)
- Language: C
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DumbCycle
A commit-by-commit (hopefully) instructional example of how to make a game
using the dumb frame buffer interface of the Linux Direct Rendering Manager.
The entire game is ~1000 lines of
C99 code with a small `x86_64` assembly runtime. No libraries or preprocessor
directives were allowed, even libc.The intent is for a reader to step through each commit, starting from
a basic executable and building up to a double buffered snake/LightCycle game.
I also [wrote an article][13] going through the development step-by-step.## Requirements
In order to build the game on an `x86_64` Linux machine you will need a C
compiler that supports the C99 standard along with [make][7] and [binutils][8]
for the `as` assembler and `ld` linker.To run the game you will need a working
`/dev/dri/card0` device and a working keyboard device in `/dev/input/`,
and the game must have permission to access these files.
The game will take over an entire display as well as the system
keyboard, so it will be necessary for you to turn off your window
manager/compositor if you usually run one.```
make
sudo ./dumb_cycle
```![DumbCycle](https://musing.permutationlock.com/static/dumb_cycle.gif)
You can also run the game in a virtual machine if you install [QEMU][9] and
[tiger vnc][10].```
make test
```The command will download a [`vm.tar.gz`][11] zip file
containing a Linux kernel and a basic initial ram filesystem using
[toybox][6] for a simple shell environment. If you want to build the kernel
and toybox yourself a corresponding [`vm_src.tar.gz`][12] is provided.## References
- [drm-howto][4]
- [barebones linux][5]
- [toybox][6]
- [musl libc][1]
- [libdrm][2]
- [linux source][3][1]: https://musl.libc.org/
[2]: https://gitlab.freedesktop.org/mesa/drm
[3]: https://github.com/torvalds/linux
[4]: https://github.com/dvdhrm/docs/tree/master/drm-howto
[5]: https://suchprogramming.com/barebones-linux-system/
[6]: https://github.com/landley/toybox
[7]: https://www.gnu.org/software/make/
[8]: https://www.gnu.org/software/binutils/
[9]: https://www.qemu.org/
[10]: https://tigervnc.org/
[11]: https://musing.permutationlock.com/static/vm.tar.gz
[12]: https://musing.permutationlock.com/static/vm_src.tar.gz
[13]: https://musing.permutationlock.com/posts/blog-dumb-cycle.html