{"id":13627348,"url":"https://github.com/donno2048/snake","last_synced_at":"2025-05-14T23:04:51.978Z","repository":{"id":178645740,"uuid":"344617026","full_name":"donno2048/snake","owner":"donno2048","description":"A minimal snake in assembly ","archived":false,"fork":false,"pushed_at":"2025-03-02T05:58:12.000Z","size":1389,"stargazers_count":1136,"open_issues_count":0,"forks_count":30,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-13T19:49:59.735Z","etag":null,"topics":["assembly","dos","snake-game","x86"],"latest_commit_sha":null,"homepage":"https://donno2048.github.io/snake/","language":"Assembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/donno2048.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["donno2048"]}},"created_at":"2021-03-04T21:41:07.000Z","updated_at":"2025-04-09T09:16:43.000Z","dependencies_parsed_at":"2023-09-23T23:03:54.999Z","dependency_job_id":"df9a0798-0afa-468b-8d56-3f0ef4993aef","html_url":"https://github.com/donno2048/snake","commit_stats":null,"previous_names":["donno2048/snake"],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donno2048%2Fsnake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donno2048%2Fsnake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donno2048%2Fsnake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donno2048%2Fsnake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/donno2048","download_url":"https://codeload.github.com/donno2048/snake/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254243358,"owners_count":22038046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","dos","snake-game","x86"],"created_at":"2024-08-01T22:00:33.135Z","updated_at":"2025-05-14T23:04:46.962Z","avatar_url":"https://github.com/donno2048.png","language":"Assembly","funding_links":["https://github.com/sponsors/donno2048"],"categories":["Projects by main language","Assembly"],"sub_categories":["assembly"],"readme":"# Snake\n\n[![Build status](https://github.com/donno2048/snake/actions/workflows/update.yml/badge.svg)](https://github.com/donno2048/snake/actions/workflows/update.yml)\n\nThis is an x86 snake game made for DOS, but there is also a [version](https://github.com/donno2048/snake-bios) that requires no BIOS, bootloader or OS.\n\nThe game has been featured on many sites, among them:\n - [Techspot](https://www.techspot.com/news/106339-coder-shrinks-classic-snake-game-down-56-byte.html)\n - [Tom's Hardware](https://www.tomshardware.com/video-games/pc-gaming/snake-game-port-is-only-56-bytes-big-and-and-fits-in-a-qr-code)\n - [Hackaday](https://hackaday.com/2023/08/03/its-snake-in-a-qr-code-but-smaller/)\n\n## Running\n\n### Online demo\n\nYou can try the game in the [online demo](https://donno2048.github.io/snake/), which updates for every change to [`snake.asm`](/snake.asm). Use your arrow keys on PC or swipe on mobile.\n\n### Self-hosting\n\nTo test it just run [`main.sh`](/main.sh) or [`main.bat`](/main.bat) and open http://localhost:8000.\n\n## Motivation\n\nThe project was inspired by [MattKC's video](https://youtu.be/ExwqNreocpg), _\"Can you fit a whole game into a QR code?\"_, which was also [featured on Hackaday](https://hackaday.com/2020/08/17/fitting-snake-into-a-qr-code/).\n\n\u003cdetails\u003e\n  \u003csummary\u003eIt was made to create the smallest \"fun\" game possible.\u003c/summary\u003e\n  \u003cbr/\u003e\n\nFor the people mentioning jinX's snake64 I'd note that without disparaging the achievement made by jinX, his implementation does not obey the same restrictions mine does: In his version, the snake can go through the right side directly to the left side but not from top to bottom, food items randomly spawn so there could be 30 simultaneously, some random pixels are turning white, you need to use 4, 6, 8, 2 keys to move instead of the arrows, you must start the game with downwards movement or it crashes, you have to `clear` the screen before starting the game, you have to initialize the correct video mode ahead, when you go through the top and supposed to lose you can just go back down, and as jinX stated \"It will not work if you run a game from DOSBox terminal. It requires 0 (or 50h, 80h, 0D0h...) value in port 60h on start.\"\n\nFor the countless people saying I'm intentionally not mentioning the _Hugi Size Coding Competition_ (a competition in which the competitors had to make the smallest nibbles game to win) here is my reply to one such comment (from when the game was still 133 bytes):\n\n\u003e Firstly, it seems that you didn't even read the rules of the \"Nibbles\" game:\n\u003e\n\u003e \u003e in the inside of this border  a  \"snake\"  is  supposed  to grow,  whose size  is  one  pixel at the beginning. after starting the program, the snake's size shall grow one pixel more in each repetition  of the program's main-loop.\n\u003e\n\u003e Which is simply not the same as snake and a **lot** less difficult to implement.\n\u003e\n\u003e Secondly, the implementations from this competition have flaws (not that they're not good but I'm saying it doesn't make my version bad) like, for example from the comments in the winning entry:\n\u003e\n\u003e \u003e game can't handle any other keys but keypad arrow keys, you need to start it by typing pause|nibbles in DOS prompt and then hitting an arrow key\n\u003e\n\u003e and\n\u003e\n\u003e \u003e Because top memory segment in PSP is environment dependant\\[sic\\] you need version suitable for your environment\n\u003e\n\u003e and it doesn't even work on DOSBox because of some special configurations needed.\n\u003e\n\u003e From the second place entry:\n\u003e\n\u003e \u003e When starting this program, press the 2 (DOWN) key \\_\\_IMMEDIATELY\\_\\_\n\u003e\n\u003e And it too won't work without setting the cycle count and changing it sometimes breaks the game\n\u003e\n\u003e As for the third place\n\u003e\n\u003e \u003e press  '8','4','6' but not '2' once game begins immediately\n\u003e\n\u003e and the game breaks in the same way the second place does (and needs the same cycle adjusting) but the walls are also broken.\n\u003e\n\u003e I'll look at the fourth place entry and stop wasting my time doing this,\n\u003e\n\u003e Well, just looked at it and couldn't make it to boot\n\u003e\n\u003e And lastly, what place is your entry to the competition? Before you criticize other people first check your criticism is correct and try doing it yourself before you judge.\n\u003e\n\u003e Thanks for the feedback anyways :)\n\u003e\n\u003e P.S. I didn't even claim my version was ideal, the main point of the post was asking for help, and this comment actually made me feel better about my implementation in a way, as in an actual size optimization competition someone had a submission of 121 bytes for just a line extending over the screen and my entire snake game (which obviously contains this functionality just as a small part of the entire program) takes only 12 bytes more now, and if I can fix the PR only 7 bytes more.\n\nAFAIK This is the smallest snake game ever made.\n\u003c/details\u003e\n\n## Perspectives\n\nIt is so small I could fit it into a single QR:\n\n\u003cimg src=\"/demo/qr.png\" width=\"250\"/\u003e\n\nThe entire game fits in 56 bytes.\n\n\u003cdetails\u003e\n  \u003csummary\u003eHex\u003c/summary\u003e\n  \u003cbr/\u003e\n    \n```\nc57800b80a2099\n92cd1089fc8b37\n93fecf000f78f8\nbbd007e460f6ea\nd414d5449801f0\n39d8ab96d01c71\nd872e129d3880f\n75fa5b883779dd\n```\n\u003c/details\u003e\n\nHow little is 56 bytes?\n\n- Even a simple sentance like this one weighs more than 60 bytes.\n- And so does this arbitrary pair of emojis: 👩🏼‍❤️‍💋‍👨🏼👩🏼‍❤️‍💋‍👨🏼\n- An **empty** C program compiled with `gcc -w -xc - \u003c\u003c\u003c \"main;\"` on linux-x86_64 is 15776 bytes.\n- An empty C program compiled with size optimization, no startup code, no standard libraries, no `main` or `_start` functions, no symbol information, and no code at all, compiled with `gcc -Os -nostartfiles -nodefaultlibs --entry 0 -Wl,--strip-all -xc /dev/null` on linux-x86_64 is 9056 bytes.\n\n### Comparison\n\n||My version|MattKC's version|ibara's version|EimaMei's version|\n|-|-|-|-|-|\n|Bytes|56|~1400 (compressed)|2024|2953|\n|QR|\u003cimg src=\"/demo/qr.png\" width=\"250\"/\u003e|\u003cimg src=\"https://mattkc.com/etc/snakeqr/code.png\" width=\"250\"/\u003e|\u003cimg src=\"https://raw.githubusercontent.com/ibara/snakeqr/master/snakeqr.png\" width=\"250\"/\u003e|\u003cimg src=\"https://raw.githubusercontent.com/EimaMei/snake-qr/main/images/code.png\" width=\"250\"/\u003e|\n|Link|https://github.com/donno2048/snake|https://mattkc.com/etc/snakeqr/|https://github.com/ibara/snakeqr|https://github.com/EimaMei/snake-qr|\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonno2048%2Fsnake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdonno2048%2Fsnake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonno2048%2Fsnake/lists"}