Code Monkey home page Code Monkey logo

asm_snake's Introduction

ARM Assembly Snake Game

A simple snake game in pure ARM Assembly for Raspberry Pi. No C functions called, I/O is done using direct system calls. Confirmed to run also on some Android devices (Samsung S10). Note that you should change the delay_ticks variable depending on the speed of the device you are running it on (e.g., 230 000 000 for Raspberry Pi 3, and 800 000 000 for S10).

Snake game

The snake is always moving forward, but you can change the direction with wasd keys to aim for different bugs, which you can eat. With each bug, your snake grows in length, until you are too long and collide with a wall or yourself.

Compile with:

as mato.s -o temp.o
ld temp.o -o mato

and run:

./mato

Some interesting features:

  • Using ANSI ASCII colors!
  • Producing random number seeds with system call to Linux gettimeofday
  • Pseudo random number generator
  • SVC system calls to read and write data
  • Getting immediate, input from keyboard in Linux using ioctl syscalls and termios configuration structures (this was by far the hardest part in the game)
    • kbhit (wait for any key)
    • "getch"-type check the keyboard buffer for possible input

Running on Android

To run the assembly program on Android devices, you need the NDK library. Follow instructions here: https://urish.medium.com/writing-your-first-android-app-in-assembly-30e8e0f8c3fe You can then run the program on the phone with a terminal app, e.g., Termux. After pushing the file into /data/local/tmp/ (see link above), you must copy the program to the Termux home directory (in Termux), so Termux has the permission to run it:

cp /data/local/tmp/mato .

and run:

./mato

asm_snake's People

Contributors

haperofi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.