This application shows animated snow in text mode.
More...
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <UEFIStarter/core.h>
|
UINT32 | random () |
| This generates a very-pseudo random number. More...
|
|
void | init_flake (flake_t *flake, int time_offset) |
| Initializes a snowflake. More...
|
|
int | update_flakes (flake_t flakes[], int iteration, float cross_speed, int land_times[]) |
| Handles snow flake movement for a single frame of animation. More...
|
|
EFI_INPUT_KEY | read_key () |
| Reads keyboard input and returns the pressed key. More...
|
|
void | print_cross_speed (double speed) |
| Debugging function: prints the current wind speed if SHOW_CROSS_SPEED is defined. More...
|
|
void | update_ground (int iteration, int land_times[]) |
| Removes any expired snowflakes on ground. More...
|
|
void | do_print_snow () |
| Main animation loop.
|
|
void | clear () |
| Clears the screen.
|
|
INTN EFIAPI | ShellAppMain (UINTN argc, CHAR16 **argv) |
| Main function, gets invoked by UEFI shell. More...
|
|
This application shows animated snow in text mode.
Press the reft/right arrow keys for wind. Press 'q' to quit.
- Author
- Richard Nusser
- Copyright
- 2017-2018 Richard Nusser
- License
- GPLv3 (see http://www.gnu.org/licenses/)
- See also
- https://github.com/rinusser/UEFIStarter
◆ random()
This generates a very-pseudo random number.
Don't use this function for anything but trivial applications, the numbers are nowhere near random.
- Returns
- a number random enough for this application
- Todo:
- There's a GetRandomNumber32() function in EDK2 but it seems to segfault all the time, see what's up
◆ init_flake()
void init_flake |
( |
flake_t * |
flake, |
|
|
int |
time_offset |
|
) |
| |
Initializes a snowflake.
- Parameters
-
flake | the flake to initialize/reset |
time_offset | the time of the flake's creation |
- Todo:
- use screen height and max cross speed to accurately calculate this
◆ update_flakes()
int update_flakes |
( |
flake_t |
flakes[], |
|
|
int |
iteration, |
|
|
float |
cross_speed, |
|
|
int |
land_times[] |
|
) |
| |
Handles snow flake movement for a single frame of animation.
This function doesn't handle flakes on the ground: those are actually just visual artifacts. The snowflakes fall "through" the ground, get reset to above the screen and start from there. The flakes seen on the ground were just never removed during animation. Instead the flake's landing time is written to land_times, update_ground() will draw over those flakes that landed more than the configured ground lifetime ago.
- Parameters
-
flakes | the snowflakes' data |
iteration | the animation loop iteration number |
cross_speed | the current wind speed |
land_times | the list of flakes' last landing times, one entry per text column |
- Returns
- the number of currently moving snowflakes; on error the (1-based) snowflake number the error happened at
◆ read_key()
EFI_INPUT_KEY read_key |
( |
| ) |
|
Reads keyboard input and returns the pressed key.
Some terminals and terminal multiplexers generate multiple input events for just one keystroke (e.g. escape sequences), this will return the last of them.
- Returns
- the pressed key
◆ print_cross_speed()
void print_cross_speed |
( |
double |
speed | ) |
|
Debugging function: prints the current wind speed if SHOW_CROSS_SPEED is defined.
- Parameters
-
speed | the wind speed to print |
◆ update_ground()
void update_ground |
( |
int |
iteration, |
|
|
int |
land_times[] |
|
) |
| |
Removes any expired snowflakes on ground.
- Parameters
-
iteration | the current animation iteration number |
land_times | the last flake landing times per text column |
◆ ShellAppMain()
INTN EFIAPI ShellAppMain |
( |
UINTN |
argc, |
|
|
CHAR16 ** |
argv |
|
) |
| |
Main function, gets invoked by UEFI shell.
- Parameters
-
argc | the number of command-line arguments passed |
argv | the command-line arguments passed |
- Returns
- an EFI status code for the shell
◆ _argument_list
Initial value:= {
}
#define FLAKE_DEFAULT_UPDATE_INTERVAL_MILLISECONDS
the default update interval (in ms) between frames
Definition: snow.c:25
#define FLAKE_CROSS_SPEED_BASE
the default base wind speed
Definition: snow.c:31
#define FLAKE_DEFAULT_DURATION_SECONDS
the default time (in seconds) this application should run
Definition: snow.c:24
#define FLAKE_MAX_CROSS_SPEED
the default maximum wind speed
Definition: snow.c:29
#define FLAKE_DEFAULT_GROUND_LIFETIME
the default lifetime (in seconds) of snowflakes on the ground
Definition: snow.c:27
#define FLAKE_CROSS_SPEED_FALLOFF_MULT
the default wind speed falloff multiplier
Definition: snow.c:30
#define FLAKE_CROSS_STEP
the default wind acceleration step size
Definition: snow.c:28
integer
Definition: cmdline.h:23
double
Definition: cmdline.h:24
#define FLAKE_DEFAULT_COUNT
the default number of flakes, including off-screen ones
Definition: snow.c:26
command-line arguments