You are browsing as a guest. Sign up (or log in) to start making projects!

BIOSnake

  • 7 Devlogs
  • 31 Total hours

Snake without an operating system, in 16 bit real mode, in x86 assembly!

Open comments for this post

2h 40m 1s logged

Miscellaneous stuff

Devlog #7

I added input buffering, centered the screen, and added an end animation. I don’t really remember if I added anything else because I haven’t worked on this project in about a month and reading assembly is kinda hard.

0
0
16
Open comments for this post

9h 36m 2s logged

t h i n s n a k e

Devlog #6

Thin Snake!

Finally made the snake thin so it doesn’t turn into a blob.

It should NOT have taken 9 hours, but it really does take a long time to program in assembly. In order to figure out how to bend the snake, it checks the segment in front of the snake, packs the info into 2 bits, and then does the same thing for the segment behind the snake. Then, it does a switch statement (At least, the closest thing to a switch statement in assembly) of the 16 possible values from those 4 bits packed together and then hardcodes drawing the segment. This implementation is definitely a bit strange and not the best way to do it, but it was the first one that worked and I didn’t want to keep trying different methods (doing anything in assembly isn’t very pleasant)

(If the video looks super blurry, that’s because I recorded it at the original 320*240 resolution)

0
0
10
Open comments for this post

2h 0m 35s logged

Nearly Finished!

Devlog #5

Apples!

The snake now has some food that appears on the screen. Not much to say here about the feature, it’s snake! But the implementation is a little bit more interesting. In computers, random numbers aren’t much of a thing, so you’ll usually have to settle for pseudo random numbers, but, CPUs today have an RDRAND instruction for generating random numbers from thermal noise and whatnot inside the CPU. but even though it’s on practically every chip today, I still opted not to use it, because

  1. Unseeded, so you can’t make a game seed or stuff like that, and
  2. They aren’t present on processors before 2012!

And we want this snake to be able to run on the original i386, don’t we?

So instead I decided to use a simple pseudo random number generator I just whipped up on the spot by multiply the seed by some big numbers and xor’ing it with itself a couple times. it’s definitely not cryptographically secure, but it’s snake, so whatever.


What next?

Now that the game is done, I’m gonna add a couple more features just so the game is a bit more more comfortable to play. I plan on adding:

  • Centering the game screen (For obvious reasons)
  • Restart button (so you don’t have to reboot the emulator) (Or if anyone runs this bare metal for some reason, the computer)
  • Choosing colors (Because fun!)
  • Button queuing (for convenience)
  • Maybe some visual flair (like drawing the snake as thin, some sprites if I can figure those out, and stuff like that)
0
0
11
Open comments for this post

5h 33m 21s logged

Hungry snake :(

Devlog #4

Sadly there’s no apple yet so the snake is getting pretty hungry.

The snake moves!

I made the snake finally able to get longer than 1 segment through a circular style array for keeping track of the head. This means that there is an array for all the segments that store the X and Y, and the head slithers through the array overwriting the tail segment so that you don’t need to copy the whole array forward every time the snake moves.


Copy problems

With this way of implementing the snake, you need to shift forward all the segments in front of the snake’s head in memory so that it creates a free space in front of the head, and so the head can move into the free space instead of overwriting the tail.


It’s a pretty simple concept, but I had a lot of trouble enacting this in assembly. Having to think about individual bytes isn’t something I’m used to from having data types handled automatically by higher level languages like C.

2
0
13
Open comments for this post

3h 37m 14s logged

This snake is devouring disk space

Devlog #3

Reading more sectors

As I was writing more assembly, I noticed a moment when whenever I added any more instructions, the screen would just go black. I knew I might be scooching up to the 512 byte limit, so I ndisasm’d the binary and found out that, sure enough, I only had 2 more bytes left!

I was preparing to have use more than 512 bytes for my program, so I knew roughly what I needed to do.
You just need one bios interrupt to read a couple sectors (512 byte chunks) into memory, and moved some code around, and now I have practically unlimited (a couple thousand bytes) to work with!

0
0
10
Open comments for this post

1h 27m 42s logged

New Snake Habitats near You

Devlog #2

Drawing the grid

I drew a grid for the snake to move on.
The code for the nested loop is not readable at all, but then again, it’s in assembly, no matter how you write it it’s unreadable.


CAUTION: Please do not touch or feed snakes, or the DX register.

I had an issue with the rectangle size being 0, because the size is passed to the drawing function through the DX register and I forgot that the MUL instruction doesn’t just store the result in AX, but also the DX register. This part sounds a bit weird but the stardance devlog guide says to “Include the friction”


Dull Devlogs

I know these devlogs may seem uneventful or dull, but writing anything in assembly is a hard task. It took me over an hour to draw a grid!

0
0
7
Open comments for this post

5h 56m 34s logged

I have a rectangle and I’m not afraid to use it

Devlog #1

Introduction

This is my first devlog of making (or at least trying to make) snake without an operating system using BIOS interrupts and 16 bit x86 real mode assembly.


I’ve made my functions for clearing the screen and drawing a rectangle, and it only took 5 hours to do! A lot of was also researching calling conventions, which registers can do what, and wondering why you can’t access memory with the stack pointer register (???? why cant you it LITERALLY has the word pointer in its name)

0
0
9

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…