[back to main site]
Snowdrop OS - a homebrew operating system from scratch, in assembly language
Once I decided to continue developing Snowdrop OS and its libraries past a trivial set of functionality, I naturally gravitated towards game development.

The notion of Snowdrop OS as the platform for my future game development became attractive. As a consequence, I have progressively added functionality towards this goal; one day, the libraries would be sufficient to enable creation of simple games.

You might find this interesting if you're a developer who'd like to create his own mini-game in x86 assembler, but wouldn't want to rely on a commercial operating system.


To keep things simple, I decided that the main graphics mode for Snowdrop OS will be "mode 13h", that is, 320x200, 8bits per pixel. This graphics mode has its linear frame buffer conveniently contained with a single 64kb memory segment, yet supports enough colours to allow for beautiful scenes.

As further convenience, each pixel is represented by one byte in memory.

Therefore, graphics will be drawn using a palette of 256 colours, where colour 255 represents transparency. Each of the 256 colours is chosen via 6bit colour components (red, green, blue).

The image above demonstrates all colours of the built-in VGA palette, with all 256 colours in the correct order. Designing your backgrounds and sprites using this BMP image as a starting point guarantees that you won't need to perform any palette manipulation (e.g. loading a custom palette).

Currently, Snowdrop OS supports one graphical file format: 256-colour uncompressed BMP with width and height that are multiples of 4.

As for backgrounds, Snowdrop OS contains a test app which shows how to load an image from a BMP file and display it on the screen.

The bmptest app shows how to load and display a background from a BMP file

To represent game objects which must be moved on top of a background (preserving its pixels), sprites are used. Snowdrop OS includes a software sprites library which lets you move bitmaps of up to a maximum size on the screen. The sprite library's total number of sprites is also limited.

See source file src\apps\common\sprites.asm for these limits.

The sprtest app shows how to load sprite pixel data from a BMP file, and then move sprites on top of a generated background.

Sprites can also be animated. By providing a bitmap strip and specifying the number of frames on the strip, Snowdrop OS's sprites framework will animate the sprites.

The anisprt app shows how to animate a single sprite from a BMP frame strip.


Version 12 saw the introduction of a keyboard driver. This driver is not meant to replace the BIOS keyboard services, but extend them with two important capabilities which are necessary for video games:
  • the ability to check which keys are pressed at any given moment, and
  • the ability to handle multiple keys pressed at once

Interacting with the keyboard driver is easy; the kbtest app shows how to check the status of all supported scan codes

For games that require a mouse, Snowdrop OS has had a PS/2 mouse driver since version 2. It can be initialized with desired bounding width and height, and it will automatically keep the mouse location within the given bounds, converting movement deltas to an (x, y) location.

The colourful mousegui app shows how to display a mouse cursor on top of a background.

The mouse cursor is rendered and refreshed using a sprite.


Thanks to the sound driver added in version 11, games can now play sounds of arbitrary duration without any overhead. Simply call the kernel-offered interrupt to specify the properties of the sound, and the driver will take care of turning the speaker on and off at the right time.

The sndtest app shows how to play sounds in all supported modes, for both flat and frequency shifted tones.

The main properties to be supplied for a sound to be played are frequency and duration. Duration is given in system timer ticks (10ms per tick). For frequency values, see documentation for interrupt 89h.