This application features a few nifty touches, including converting bitmap (.bmp) files to HII, merging bitmaps using transparency and a nifty maze generation algorithm. This application uses both the standard C library, as well as UEFI-specific libraries.
This game doesn’t have any villains or time limits, yet. Originally, I planned to integrate the thermometer application previously discussed so that the main character got hotter and hotter and little ice cubs in the maze would cool him down. You can add villains in the maze, or the animation could move smoothly from cell to cell or there could be some sort of time limit.
The source is spread over two .C files. It also uses three bitmap files, which are included in the online source code. These bitmaps are: a rock, a player, and a solid green background.
The First Source File: Game.c
|Figure 1: Global Variables in Game.c|
These are the include files for the standard C library, basic UEFI services and, surprise(!) bitmaps. The MdePkg\Include\IndustryStandard contains constants, data structures and file formats from many popular industry standards, including PCI, ACPI and USB.
These are the key function declarations from the other source file, Bitmap.c. Rather than create a separate header file, they are just listed here.
|Figure 4 Setup bitmap images and Graphics Output Protocol in Game.c|
The first step for the game is to load all of the bitmaps out of the files.
Find the instance of the UEFI Graphics Output protocol.
Load each of the three bitmaps from external files. Each of the files is formatted using the industry standard .bmp file format.
In the next installment, we'll look at exactly how to initialize UEFI's Graphics Output Protocol and load a bitmap.