• Stars
    star
    672
  • Rank 64,672 (Top 2 %)
  • Language
    Assembly
  • License
    MIT License
  • Created about 3 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A minimal snake in assembly

Snake

This is an x86 snake game made for DOS.

The game was covered on Hackaday.

Running

Online demo

To test the code you can view the online demo which updates for every change in snake.asm (Use your arrow keys on PC or swipe on mobile).

Self-hosting

If you want to test the code yourself you need to install the requirements for the build process and run it on your computer.

Installation

I'm using nasm and python3 which can be installed with apt install nasm python3 -y.

Building

To test it just run main.sh and open http://localhost:8000.

Motivation

Inspired by "Can you fit a whole game into a QR code?" by @itsmattkc which was also featured on Hackaday.

It was made to create the smallest "fun" game possible.

For 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):

Firstly, it seems that you didn't even read the rules of the "Nibbles" game:

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.

Which is simply not the same as snake and a lot less difficult to implement.

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:

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

and

Because top memory segment in PSP is environment dependant[sic] you need version suitable for your environment

and it doesn't even work on DOSBox because of some special configurations needed.

From the second place entry:

When starting this program, press the 2 (DOWN) key __IMMEDIATELY__

And it too won't work without setting the cycle count and changing it sometimes breaks the game

As for the third place

press '8','4','6' but not '2' once game begins immediately

and the game breaks in the same way the second place does (and needs the same cycle adjusting) but the walls are also broken.

I'll look at the fourth place entry and stop wasting my time doing this,

Well, just looked at it and couldn't make it to boot

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.

Thanks for the feedback anyways :)

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.

AFAIK This is the smallest snake game ever made.

Perspectives

It is so small I could fit it into a single QR:

It's 60 bytes.

How little is 60 bytes? Well, this line of text weighs more than 70 bytes.

And so does this arbitrary sequence of emojis: 👩🏼‍❤️‍💋‍👨🏼🧔🏽‍♀️👩🏼‍❤️‍💋‍👨🏼

An empty C program generated with gcc -Os -w -xc - <<< "main;" on linux-x86_64 is 15776 bytes.

Hex
c53000b80000cd108b3f
8d22e54021c30837bbd0
0778f5e4606bc00ad414
d5449801c739df73dc30
1d79d8ad893a7bdc880f
83eb5079f95b202779d6

Comparison

My version MattKC's version ibara's version
Bytes 60 ~1400 2024
QR
Link https://github.com/donno2048/snake https://mattkc.com/etc/snakeqr/ https://github.com/ibara/snakeqr

More Repositories

1

win95

Run Windows95 on the web
HTML
30
star
2

polyglots

Create polyglots for different file types
Python
14
star
3

restricted-functions

Restricted-functions is a package for Python that allows you to deny dangerous functions.
Python
12
star
4

gitback

The easiest way to makes a backup of all your repositories and gists from GitHub using Python
Python
11
star
5

HTML-PDF-JPEG

An HTML page which is also a valid PDF file and JPEG image
Python
10
star
6

pygoto

Use goto in Python
Python
7
star
7

win95.exe

Microsoft Windows 95 as an executable (using python and pyinstaller)
HTML
6
star
8

im2ascii

Turn Images to ascii
JavaScript
6
star
9

zipbomb

Create zipbombs using python
Python
5
star
10

DDos

DDos any site using python (for educational purposes)
Python
5
star
11

spaceship

Spaceship game in C
C
5
star
12

termrec

Record your terminal and play it
Python
4
star
13

running-cat

Show a running cat on the taskbar, the faster it runs the faster your CPU is
C
4
star
14

recurzip

recursive zip and gzip files
Go
4
star
15

imtost

Automatically convert images to stickers [WhatsApp bot]
JavaScript
4
star
16

Viruses

Please don't run this code
C++
4
star
17

beep

A python module to generate sounds
C
3
star
18

Rosehip

Reliable Operating System by Elisha Hollander Implemented in Python
Python
3
star
19

CITUR-L

New version of CITUR corresponding to the Linux version of Rosehip
Shell
3
star
20

Debiandroid

Run Debian on Android
Shell
3
star
21

czipbomb

Zipbomb using C
C
3
star
22

pyas

Run machine code, assembly and webassembly
Python
2
star
23

stepng

Encode data into photos using a simple LSB steganographic algorithm
Python
2
star
24

Canon

Play canon in d but not in d
Python
2
star
25

1000000

2
star
26

webdoom

Run DOOM online
HTML
2
star
27

yt2mp4

Download YouTube videos and playlists as MP4 files (and other formats)
Python
2
star
28

Win95-source

The original Microsoft's win95
2
star
29

Rosehip-L

Linux version for Rosehip
Python
2
star
30

Notepad--

This notepad app will take you 200 years back to the Typewriter.
Java
2
star
31

dotfiles

Files I use to set-up my Debian machine
Shell
2
star
32

bfc

Brainfuck compiler
Python
2
star
33

netflix-zoom

This extension makes it look like you're in a zoom call while you're watching Netflix.
JavaScript
1
star
34

lydia-web

A Lydia bot using flask to create an online chatbot
Python
1
star
35

mp4-to-subs

Turn mp4 input into subtitles
Python
1
star
36

Unreachable

Files you can't open
1
star
37

refcon

restricted-functions's Debian package
Python
1
star
38

BlueScreenOfDeath

Easy to use
HTML
1
star
39

CITUR

create iso to use Rosehip
Shell
1
star
40

Joker

An exe to print jokes rapidly
Tcl
1
star
41

Heython

Python Hebrew transpiler
Python
1
star
42

Rosehip-pypi

The Rosehip pypi upload
Python
1
star
43

pytray

A Python module to interact with the Windows tray.
C
1
star
44

pc

Online "operating system"
JavaScript
1
star
45

spamcmd

Delete every three letters command in the cmd using brute-force
Python
1
star
46

Portfolio

My portfolio as published to https://donno2048.github.io/Portfolio/ and https://stupefied-mclean-bb6293.netlify.app
HTML
1
star
47

quine

A web server quine using ruby
Ruby
1
star
48

Mandelbrot-cli

Display the Mandelbrot set plot all over your cmd
Python
1
star
49

PyOnline

Simple pyodide implementation
JavaScript
1
star
50

NoHTML

This is a website with absolutely no HTML
Python
1
star
51

Speeder

Use this chrome extension to speed up every video in the current tab
HTML
1
star
52

exe2png

Convert executables (or any other file) into an image
Python
1
star
53

hollywood

Hollywood effects for your terminal.
Shell
1
star
54

nasm-quine

A quine in x86 assembly
Assembly
1
star
55

mp42uni

Use this to show a video in the terminal (Unicode art)
Python
1
star
56

games

HTML games
JavaScript
1
star
57

gif-quine

A GIF quine
C
1
star
58

tinycore

TinyCore online
HTML
1
star
59

pybracket

Add brackets and good semicolons to Python
Python
1
star
60

Anti-Wallis

This repo is meant to show how horrible the Wallis function is and to ask every developer in the world to demolish it.
C
1
star
61

anti-not-paid

Your developer hid some code in your website because you didn't pay and now your webpage's opacity is decreased every day? Add a piece of JavaScript to overcome his code.
HTML
1
star
62

Dino

Chrome extension to make you invulnerable on Google Dino game
JavaScript
1
star