/* * Copyright (c) 2023 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * aurora.c * But beyond the windows you beheld an everchanging sight on a busy monday. */ #include #include #include #include #include #include union c { struct { uint8_t b; uint8_t g; uint8_t r; }; uint32_t v; }; static void render(uint32_t* fb, uint32_t w, uint32_t h, uint32_t t, uint32_t s) { /* rules? */ /* static wallpapers can be dynamic */ for ( uint32_t y = 0; y < h; y++ ) /* everchanging */ /* generative */ { /* variant on theme */ /* fast */ /* procedural */ for ( uint32_t x = 0; x < w; x++ ) /* O(h*w) */ { /* 4k is enough for everyone */ /* for the professional desktop */ uint32_t r = /* seeded */ 3793 * x + 6959 * y + 1889 * t + 7901 * s; r ^= (5717 * x * 2953 /* pretty good */ * y) ^ s ^ t;/* 1024 b yea*/ r = (r >> 24) ^ (r >> 16) ^ (r >> 8) ^ r; /* 512 b gold */ union c c; /* of the world *//* quota/size the more the merrier ^ */ if ( x && (r & 0x3) == 2 ) /* as seen through the translucent */ c.v = fb[(h - 1 - y) * w + (x - 1)]; /* 95X11 today */ else if ( y && (r & 0x3) == 1 ) /* only render counts iirc */ c.v = fb[(h - 1 - (y - 1)) * w + x];/* <-- official wallpaper */ else if ( x && y ) /* **for demonstration only** */ c.v = fb[(h - 1 - (y - 1)) * w + (x - 1)]; /* a cat??? */ else /* ~~ image formats are so ports/ ~~ */ { /* looks cool */ /* clever */ /* screenshot */ /* useful */ c.v = t; /* wow! you bought a x87 */ // fb bullshit section c.r = (c.r & 0xc0) | (r >> 0 & 0x3f);/*ub!*/ /* ephemeral --> */ c.g = (c.g & 0xc0) | (r >> 4 & 0x3f); /* powerful. yep. */ c.b = (c.b & 0xc0) | (r >> 8 & 0x3f); /* want to save this */ } /* warning: mere guidelines */ /* contrast */ /* pretty */ if ( (r & 0xf0) == 0x10 && c.r ) c.r--; /* time of day allowed */ if ( (r & 0xf0) == 0x20 && c.g ) c.g--; /* execute only art */ if ( (r & 0xf0) == 0x30 && c.b ) c.b--; /* icons are readable */ if ( (r & 0xf0) == 0x40 && c.r != 255 ) c.r++; /* occasional */ if ( (r & 0xf0) == 0x50 && c.g != 255 ) c.g++; /* disables nft */ if ( (r & 0xf0) == 0x60 && c.b != 255 ) c.b++; union c tc = {.v = t}; // 1st iteration (.text) intentionally blank if ( c.r && c.r - tc.r > (int8_t) (r >> 0) + 64 ) c.r--; // sortix. if ( c.r != 255 && tc.r - c.r > (int8_t) (r >> 4) + 240 ) c.r++; if ( c.g && c.g - tc.g > (int8_t) (r >> 8) + 64) c.g--; // ahti. if ( c.g != 255 && tc.g - c.g > (int8_t) (r >> 12) + 240 ) c.g++; if ( c.b && c.b - tc.b > (int8_t) (r >> 16) + 64 ) c.b--; // space if ( c.b != 255 && tc.b - c.b > (int8_t) (r >> 20) + 240 ) c.b++; fb[(h - 1 - y) * w + x] = c.v; /* what the fuck? */ //bias } /* infohazard: */ /* x86_64-sortix-gcc -DGOLF -Os -s, size(1) */ } // have fun /* make -C /src/libc OPTLEVEL='-Os -s' install boom 3688 b */ } /* any submissions can and will be used against you on your sortix desktop */ struct bmp { char signature[2]; uint32_t file_size; uint32_t reserved; uint32_t data_offset; uint32_t size; uint32_t width; uint32_t height; uint16_t num_planes; uint16_t bit_count; uint32_t compression; uint32_t image_size; uint32_t xpixels_per_meter; uint32_t ypixels_per_meter; uint32_t num_colors_used; uint32_t num_important_colors; } __attribute__ ((packed)); static struct bmp bmp = { .signature[0] = 'B', .signature[1] = 'M', .file_size = sizeof(struct bmp), .data_offset = sizeof(struct bmp), .size = sizeof(struct bmp) - offsetof(struct bmp, size), .num_planes = 1, .bit_count = 32, }; #ifdef GOLF /* You WoUDn'T StatIC Link A MAllOc */ const int width = 1920; const int height = 1080; static uint32_t frame[1920 * 1080]; size_t size = sizeof(frame); uint32_t theme = 0x3d6f49a6; uint32_t seed = 0x5a63c89a; #endif #include int main(int argc, char* argv[]) { #ifndef GOLF unsigned int width = 1 < argc ? strtoul(argv[1], NULL, 0) : 1920; unsigned int height = 2 < argc ? strtoul(argv[2], NULL, 0) : 1080; size_t size = width * height * sizeof(uint32_t); uint32_t* frame = malloc(size); if ( !frame ) err(1, "malloc"); uint32_t theme = 3 < argc ? strtoul(argv[3], NULL, 0) : arc4random(); uint32_t seed = 4 < argc ? strtoul(argv[4], NULL, 0) : arc4random(); #else (void) argc, (void) argv; #endif render(frame, width, height, theme, seed); bmp.file_size += size; bmp.width = width; bmp.height = height; for ( size_t i = 0; i < sizeof(bmp); ) i += write(1, (char*) &bmp + i, sizeof(bmp) - i); for ( size_t i = 0; i < size; ) i += write(1, (char*) frame + i, size - i); return 0; }