diff options
author | Benji Dial <benji6283@gmail.com> | 2021-03-01 22:35:26 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-03-01 22:35:26 -0500 |
commit | 1d69a46f5d9823bbf2e6211ca367b409d2d5f7a7 (patch) | |
tree | a49a5498080551270a827a205cde49477d4d89ff /src/kernel/window.c | |
parent | 6f1b50a4cc6c232ee505a543f006abb1c6cd33cf (diff) | |
download | portland-os-1d69a46f5d9823bbf2e6211ca367b409d2d5f7a7.tar.gz |
minimal file writing, shutdown keybinding (Win+Shift+Q)
Diffstat (limited to 'src/kernel/window.c')
-rw-r--r-- | src/kernel/window.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/kernel/window.c b/src/kernel/window.c index 79d718e..1c4eb26 100644 --- a/src/kernel/window.c +++ b/src/kernel/window.c @@ -82,6 +82,60 @@ static void blit() { } } +#define POWER_OFF_MESSAGE_PITCH 45 +#define POWER_OFF_MESSAGE_ROWS 28 +static const bool power_off_message[] = { + 1,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,0,1, + 1,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,1, + 0,1,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,1,0,1,1,0,0,1,0,0,0,1,0,0,0,1,0,1,0, + 0,1,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,0,0,1,1,1,1,1,0,0,0,1,0,1,0, + 0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,1,0,0, + 0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0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,0,0,0,0,0,0,0, +}; + +#define POWER_OFF_SCALE 3 + +void show_shutdown() { + for (uint32_t i = 0; i < VBE_MODE_INFO->height * VBE_MODE_INFO->width; ++i) + buffer[i] = (struct pixel){.r = 0, .g = 0, .b = 0}; + + const uint16_t x_pad = (VBE_MODE_INFO->width - POWER_OFF_MESSAGE_PITCH * POWER_OFF_SCALE) / 2; + const uint16_t y_pad = (VBE_MODE_INFO->height - POWER_OFF_MESSAGE_ROWS * POWER_OFF_SCALE) / 2; + + for (uint8_t r = 0; r < POWER_OFF_MESSAGE_ROWS; ++r) + for (uint8_t i = 0; i < POWER_OFF_MESSAGE_PITCH; ++i) + if (power_off_message[r * POWER_OFF_MESSAGE_PITCH + i]) { + const uint32_t o = x_pad + i * POWER_OFF_SCALE + (y_pad + r * POWER_OFF_SCALE) * VBE_MODE_INFO->width; + for (uint8_t y = 0; y < POWER_OFF_SCALE; ++y) + for (uint8_t x = 0; x < POWER_OFF_SCALE; ++x) + buffer[o + x + y * VBE_MODE_INFO->width] = (struct pixel){.r = 255, .g = 255, .b = 255}; + } + + blit(); +} + static inline void draw_hz_line(uint16_t y, uint16_t xs, uint16_t xm, struct pixel color) { if (y >= VBE_MODE_INFO->height) return; |