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.