diff options
author | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2023-12-21 06:41:30 +0100 |
---|---|---|
committer | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2023-12-21 06:41:30 +0100 |
commit | b62ea8cffcf257f64215bd2c480dbd8990814f42 (patch) | |
tree | 152a1bce8de869671bb510f61688f67328f62d4b /stage3/shell.c | |
parent | 1ad6bbe4b3baee113bf6f37e0d02030910543fbd (diff) | |
download | cuddles-b62ea8cffcf257f64215bd2c480dbd8990814f42.tar.xz |
add cheese command
Diffstat (limited to 'stage3/shell.c')
-rw-r--r-- | stage3/shell.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/stage3/shell.c b/stage3/shell.c index 055c296..7341eea 100644 --- a/stage3/shell.c +++ b/stage3/shell.c @@ -231,6 +231,42 @@ void cmd_shutdown(str arg) outw(0x604, 0x2000); } +void cmd_cheese(str arg) +{ + (void) arg; + + const u32 texsize = 400; + u32 *texture = malloc(texsize * texsize * sizeof *texture); + for (u32 y = 0; y < texsize; y++) + for (u32 x = 0; x < texsize; x++) { + texture[y*texsize+x] = 0xfff5c92a; + } + + int holes = 40 + rand() % 5; + for (int i = 0; i < holes; i++) { + u32 xo = rand() % texsize; + u32 yo = rand() % texsize; + i32 radius = 15 + rand() % 5; + + for (i32 xi = -radius; xi <= radius; xi++) { + i32 x = xi+xo; + if (!(x >= 0 && x < (i32)texsize)) + continue; + double hi = sin(acos((double) xi / (double) radius))*radius; + for (i32 yi = -hi; yi <= hi; yi++) { + i32 y = yi+yo; + if (!(y >= 0 && y < (i32)texsize)) + continue; + texture[y*texsize+x] = 0xff302b24; + } + } + } + + gfx_draw_img(gfx_info->width-texsize, 0, texsize, texsize, texture); + + free(texture); +} + typedef struct { str name; void (*fn)(str arg); @@ -250,6 +286,7 @@ static command registry[] = { { S("uname"), &cmd_uname }, { S("ls"), &cmd_ls }, { S("shutdown"), &cmd_shutdown }, + { S("cheese"), &cmd_cheese }, }; void shell_run_cmd(str cmd) |